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