libgphoto2 photo camera library (libgphoto2) API
2.5.2
|
00001 00002 #ifndef __GPHOTO2_PORT_PORTABILITY_H__ 00003 #define __GPHOTO2_PORT_PORTABILITY_H__ 00004 00005 #ifdef _GPHOTO2_INTERNAL_CODE 00006 00007 #if defined(WIN32) && !defined(__WINESRC__) 00008 00009 /************************************************************************ 00010 * Begin Windows definitions (but not during WINE compilation) 00011 ************************************************************************/ 00012 00013 # include <windows.h> 00014 # include <sys/types.h> 00015 # include <sys/stat.h> 00016 # include <string.h> 00017 # include <stdio.h> 00018 # include <direct.h> 00019 00020 # ifdef IOLIBS 00021 # undef IOLIBS 00022 # endif 00023 # define IOLIBS "." 00024 # define strcasecmp _stricmp 00025 # define snprintf _snprintf 00026 00027 /* Work-around for readdir() */ 00028 typedef struct { 00029 HANDLE handle; 00030 int got_first; 00031 WIN32_FIND_DATA search; 00032 char dir[1024]; 00033 char drive[32][2]; 00034 int drive_count; 00035 int drive_index; 00036 } GPPORTWINDIR; 00037 00038 /* Sleep functionality */ 00039 # define GP_SYSTEM_SLEEP(_ms) do { Sleep(_ms) } while (0) 00040 00041 /* Directory-oriented functions */ 00042 # define gp_system_dir GPPORTWINDIR * 00043 # define gp_system_dirent WIN32_FIND_DATA * 00044 # define gp_system_dir_delim '\\' 00045 00046 /************************************************************************ 00047 * End WIN32 definitions 00048 ************************************************************************/ 00049 00050 #elif defined(__SOME_OS2_MAGIC_HERE__) 00051 00052 /************************************************************************ 00053 * Begin OS/2 definitions 00054 ************************************************************************/ 00055 00056 # define strcasecmp(foo,bar) stricmp(foo,bar) 00057 # define gp_system_dir_delim '\\' 00058 00059 # ifndef GPIO_OS2_INCLUDED 00060 # define GPIO_OS2_INCLUDED 00061 # define IOLIBS getenv("IOLIBS") 00062 /*#define IOLIBS "./libgphoto2_port"*/ 00063 # define RTLD_LAZY 0x001 00064 00065 00066 # ifndef HAVE_TERMIOS_H 00067 # define INCL_DOSDEVIOCTL /* DosDevIOCtl values */ 00068 # define IOCTL_ASYNC 0x0001 00069 # define ASYNC_SETBAUDRATE 0x0041 00070 /* c_cflag bit meaning */ 00071 # define CBAUD 0x0000100f 00072 # define B0 0x00000000 /* hang up */ 00073 # define B50 0x00000001 00074 # define B75 0x00000002 00075 # define B110 0x00000003 00076 # define B134 0x00000004 00077 # define B150 0x00000005 00078 # define B200 0x00000006 00079 # define B300 0x00000007 00080 # define B600 0x00000008 00081 # define B1200 0x00000009 00082 # define B1800 0x0000000a 00083 # define B2400 0x0000000b 00084 # define B4800 0x0000000c 00085 # define B9600 0x0000000d 00086 # define B19200 0x0000000e 00087 # define B38400 0x0000000f 00088 # define EXTA B19200 00089 # define EXTB B38400 00090 # define CSIZE 0x00000030 00091 # define CS5 0x00000000 00092 # define CS6 0x00000010 00093 # define CS7 0x00000020 00094 # define CS8 0x00000030 00095 # define CSTOPB 0x00000040 00096 # define CREAD 0x00000080 00097 # define PARENB 0x00000100 00098 # define PARODD 0x00000200 00099 # define HUPCL 0x00000400 00100 # define CLOCAL 0x00000800 00101 # define CBAUDEX 0x00001000 00102 # define B57600 0x00001001 00103 # define B115200 0x00001002 00104 # define B230400 0x00001003 00105 # define B460800 0x00001004 00106 # define B76800 0x00001005 00107 # define B153600 0x00001006 00108 # define B307200 0x00001007 00109 # define B614400 0x00001008 00110 # define B921600 0x00001009 00111 # define B500000 0x0000100a 00112 # define B576000 0x0000100b 00113 # define B1000000 0x0000100c 00114 # define B1152000 0x0000100d 00115 # define B1500000 0x0000100e 00116 # define B2000000 0x0000100f 00117 00118 # endif /* HAVE_TERMIOS_H */ 00119 00120 # define CIBAUD 0x100f0000 /* input baud rate (not used) */ 00121 # define CMSPAR 0x40000000 /* mark or space (stick) parity */ 00122 /* #define CRTSCTS 0x80000000 */ /* flow control */ 00123 00124 /* modem lines */ 00125 # define TIOCM_LE 0x001 00126 # define TIOCM_DTR 0x002 00127 # define TIOCM_RTS 0x004 00128 # define TIOCM_ST 0x008 00129 # define TIOCM_SR 0x010 00130 # define TIOCM_CTS 0x020 00131 # define TIOCM_CAR 0x040 00132 # define TIOCM_RNG 0x080 00133 # define TIOCM_DSR 0x100 00134 # define TIOCM_CD TIOCM_CAR 00135 # define TIOCM_RI TIOCM_RNG 00136 00137 # define TIOCMBIC 0x06C 00138 # define TIOCMBIS 0x06B 00139 # define TIOCMGET 0x06E 00140 00141 # endif /* GPIO_OS2_INCLUDED */ 00142 00143 /************************************************************************ 00144 * End OS/2 definitions 00145 ************************************************************************/ 00146 00147 #else 00148 00149 /************************************************************************ 00150 * Begin POSIX/XOPEN definitions 00151 ************************************************************************/ 00152 00153 /* yummy. :) */ 00154 00155 /* XOPEN needed for usleep */ 00156 #ifndef _XOPEN_SOURCE 00157 # define _XOPEN_SOURCE 500 00158 #else 00159 # if ((_XOPEN_SOURCE - 0) < 500) 00160 # undef _XOPEN_SOURCE 00161 # define _XOPEN_SOURCE 500 00162 # endif 00163 #endif 00164 00165 /* for nanosleep */ 00166 # ifndef _POSIX_C_SOURCE 00167 # define _POSIX_C_SOURCE 199309 00168 # endif 00169 # include <time.h> 00170 00171 # include <strings.h> 00172 # include <sys/types.h> 00173 # include <dirent.h> 00174 #ifdef HAVE_SYS_PARAM_H 00175 # include <sys/param.h> 00176 #endif 00177 # include <sys/stat.h> 00178 # include <unistd.h> 00179 00181 # define GP_SYSTEM_SLEEP(_ms) \ 00182 do { \ 00183 struct timespec req; \ 00184 req.tv_sec = 0; \ 00185 req.tv_nsec = 1000*1000*((long)(_ms)); \ 00186 nanosleep(&req, NULL); \ 00187 } while (0) 00188 00189 /* Directory-oriented functions */ 00191 # define gp_system_dir DIR * 00192 00193 # define gp_system_dirent struct dirent * 00194 00195 # define gp_system_dir_delim '/' 00196 00197 /************************************************************************ 00198 * End POSIX/XOPEN definitions 00199 ************************************************************************/ 00200 00201 #endif /* else */ 00202 00203 00204 /************************************************************************ 00205 * Begin platform independent portability functions 00206 ************************************************************************/ 00207 00208 int gp_system_mkdir (const char *dirname); 00209 int gp_system_rmdir (const char *dirname); 00210 gp_system_dir gp_system_opendir (const char *dirname); 00211 gp_system_dirent gp_system_readdir (gp_system_dir d); 00212 const char* gp_system_filename (gp_system_dirent de); 00213 int gp_system_closedir (gp_system_dir dir); 00214 int gp_system_is_file (const char *filename); 00215 int gp_system_is_dir (const char *dirname); 00216 00217 /************************************************************************ 00218 * End platform independent portability functions 00219 ************************************************************************/ 00220 #endif /* _GPHOTO2_INTERNAL_CODE */ 00221 00222 #endif /* ifndef __GPHOTO2_PORT_PORTABILITY_H__ */ 00223 /* end of file */