gphoto2-port-portability.h

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

Generated on Sun Jul 22 19:29:31 2007 for libgphoto2 photo camera library (libgphoto2) by  doxygen 1.5.0