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