libgphoto2 photo camera library (libgphoto2) API  2.5.3.1
gphoto2-port-portability.h
1 
20 #ifndef __GPHOTO2_PORT_PORTABILITY_H__
21 #define __GPHOTO2_PORT_PORTABILITY_H__
22 
23 #ifdef _GPHOTO2_INTERNAL_CODE
24 
25 #if defined(WIN32) && !defined(__WINESRC__)
26 
27 /************************************************************************
28  * Begin Windows definitions (but not during WINE compilation)
29  ************************************************************************/
30 
31 # include <windows.h>
32 # include <sys/types.h>
33 # include <sys/stat.h>
34 # include <string.h>
35 # include <stdio.h>
36 # include <direct.h>
37 
38 # ifdef IOLIBS
39 # undef IOLIBS
40 # endif
41 # define IOLIBS "."
42 # define strcasecmp _stricmp
43 # define snprintf _snprintf
44 
45 /* Work-around for readdir() */
46 typedef struct {
47  HANDLE handle;
48  int got_first;
49  WIN32_FIND_DATA search;
50  char dir[1024];
51  char drive[32][2];
52  int drive_count;
53  int drive_index;
54 } GPPORTWINDIR;
55 
56 /* Sleep functionality */
57 # define GP_SYSTEM_SLEEP(_ms) do { Sleep(_ms) } while (0)
58 
59 /* Directory-oriented functions */
60 # define gp_system_dir GPPORTWINDIR *
61 # define gp_system_dirent WIN32_FIND_DATA *
62 # define gp_system_dir_delim '\\'
63 
64 /************************************************************************
65  * End WIN32 definitions
66  ************************************************************************/
67 
68 #elif defined(__SOME_OS2_MAGIC_HERE__)
69 
70 /************************************************************************
71  * Begin OS/2 definitions
72  ************************************************************************/
73 
74 # define strcasecmp(foo,bar) stricmp(foo,bar)
75 # define gp_system_dir_delim '\\'
76 
77 # ifndef GPIO_OS2_INCLUDED
78 # define GPIO_OS2_INCLUDED
79 # define IOLIBS getenv("IOLIBS")
80 /*#define IOLIBS "./libgphoto2_port"*/
81 # define RTLD_LAZY 0x001
82 
83 
84 # ifndef HAVE_TERMIOS_H
85 # define INCL_DOSDEVIOCTL /* DosDevIOCtl values */
86 # define IOCTL_ASYNC 0x0001
87 # define ASYNC_SETBAUDRATE 0x0041
88 /* c_cflag bit meaning */
89 # define CBAUD 0x0000100f
90 # define B0 0x00000000 /* hang up */
91 # define B50 0x00000001
92 # define B75 0x00000002
93 # define B110 0x00000003
94 # define B134 0x00000004
95 # define B150 0x00000005
96 # define B200 0x00000006
97 # define B300 0x00000007
98 # define B600 0x00000008
99 # define B1200 0x00000009
100 # define B1800 0x0000000a
101 # define B2400 0x0000000b
102 # define B4800 0x0000000c
103 # define B9600 0x0000000d
104 # define B19200 0x0000000e
105 # define B38400 0x0000000f
106 # define EXTA B19200
107 # define EXTB B38400
108 # define CSIZE 0x00000030
109 # define CS5 0x00000000
110 # define CS6 0x00000010
111 # define CS7 0x00000020
112 # define CS8 0x00000030
113 # define CSTOPB 0x00000040
114 # define CREAD 0x00000080
115 # define PARENB 0x00000100
116 # define PARODD 0x00000200
117 # define HUPCL 0x00000400
118 # define CLOCAL 0x00000800
119 # define CBAUDEX 0x00001000
120 # define B57600 0x00001001
121 # define B115200 0x00001002
122 # define B230400 0x00001003
123 # define B460800 0x00001004
124 # define B76800 0x00001005
125 # define B153600 0x00001006
126 # define B307200 0x00001007
127 # define B614400 0x00001008
128 # define B921600 0x00001009
129 # define B500000 0x0000100a
130 # define B576000 0x0000100b
131 # define B1000000 0x0000100c
132 # define B1152000 0x0000100d
133 # define B1500000 0x0000100e
134 # define B2000000 0x0000100f
135 
136 # endif /* HAVE_TERMIOS_H */
137 
138 # define CIBAUD 0x100f0000 /* input baud rate (not used) */
139 # define CMSPAR 0x40000000 /* mark or space (stick) parity */
140 /* #define CRTSCTS 0x80000000 */ /* flow control */
141 
142 /* modem lines */
143 # define TIOCM_LE 0x001
144 # define TIOCM_DTR 0x002
145 # define TIOCM_RTS 0x004
146 # define TIOCM_ST 0x008
147 # define TIOCM_SR 0x010
148 # define TIOCM_CTS 0x020
149 # define TIOCM_CAR 0x040
150 # define TIOCM_RNG 0x080
151 # define TIOCM_DSR 0x100
152 # define TIOCM_CD TIOCM_CAR
153 # define TIOCM_RI TIOCM_RNG
154 
155 # define TIOCMBIC 0x06C
156 # define TIOCMBIS 0x06B
157 # define TIOCMGET 0x06E
158 
159 # endif /* GPIO_OS2_INCLUDED */
160 
161 /************************************************************************
162  * End OS/2 definitions
163  ************************************************************************/
164 
165 #else
166 
167 /************************************************************************
168  * Begin POSIX/XOPEN definitions
169  ************************************************************************/
170 
171 /* yummy. :) */
172 
173 /* XOPEN needed for usleep */
174 #ifndef _XOPEN_SOURCE
175 # define _XOPEN_SOURCE 500
176 #else
177 # if ((_XOPEN_SOURCE - 0) < 500)
178 # undef _XOPEN_SOURCE
179 # define _XOPEN_SOURCE 500
180 # endif
181 #endif
182 
183 /* for nanosleep */
184 # ifndef _POSIX_C_SOURCE
185 # define _POSIX_C_SOURCE 199309
186 # endif
187 # include <time.h>
188 
189 # include <strings.h>
190 # include <sys/types.h>
191 # include <dirent.h>
192 #ifdef HAVE_SYS_PARAM_H
193 # include <sys/param.h>
194 #endif
195 # include <sys/stat.h>
196 # include <unistd.h>
197 
199 # define GP_SYSTEM_SLEEP(_ms) \
200  do { \
201  struct timespec req; \
202  req.tv_sec = 0; \
203  req.tv_nsec = 1000*1000*((long)(_ms)); \
204  nanosleep(&req, NULL); \
205  } while (0)
206 
207 /* Directory-oriented functions */
209 # define gp_system_dir DIR *
210 
211 # define gp_system_dirent struct dirent *
212 
213 # define gp_system_dir_delim '/'
214 
215 /************************************************************************
216  * End POSIX/XOPEN definitions
217  ************************************************************************/
218 
219 #endif /* else */
220 
221 
222 /************************************************************************
223  * Begin platform independent portability functions
224  ************************************************************************/
225 
226 int gp_system_mkdir (const char *dirname);
227 int gp_system_rmdir (const char *dirname);
228 gp_system_dir gp_system_opendir (const char *dirname);
229 gp_system_dirent gp_system_readdir (gp_system_dir d);
230 const char* gp_system_filename (gp_system_dirent de);
231 int gp_system_closedir (gp_system_dir dir);
232 int gp_system_is_file (const char *filename);
233 int gp_system_is_dir (const char *dirname);
234 
235 /************************************************************************
236  * End platform independent portability functions
237  ************************************************************************/
238 #endif /* _GPHOTO2_INTERNAL_CODE */
239 
240 #endif /* ifndef __GPHOTO2_PORT_PORTABILITY_H__ */
241 /* end of file */
int gp_system_is_file(const char *filename)
check if passed filename is a file
Definition: gphoto2-port-portability.c:254
int gp_system_mkdir(const char *dirname)
mkdir UNIX functionality
Definition: gphoto2-port-portability.c:170
int gp_system_is_dir(const char *dirname)
check if passed filename is a directory
Definition: gphoto2-port-portability.c:271
gp_system_dir gp_system_opendir(const char *dirname)
opendir UNIX functionality
Definition: gphoto2-port-portability.c:202
int gp_system_closedir(gp_system_dir dir)
closedir UNIX functionality
Definition: gphoto2-port-portability.c:240
int gp_system_rmdir(const char *dirname)
rmdir UNIX functionality
Definition: gphoto2-port-portability.c:185
const char * gp_system_filename(gp_system_dirent de)
retrieve UNIX filename out of a directory entry
Definition: gphoto2-port-portability.c:228
gp_system_dirent gp_system_readdir(gp_system_dir d)
readdir UNIX functionality
Definition: gphoto2-port-portability.c:216