1 /** \file gphoto2-port-log.h 2 * 3 * Copyright 2001 Lutz Mueller <lutz@users.sf.net> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; if not, write to the 17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301 USA 19 */ 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 typedef SSIZE_T ssize_t; 51 52 /* Work-around for readdir() */ 53 typedef struct { 54 HANDLE handle; 55 int got_first; 56 WIN32_FIND_DATA search; 57 char dir[1024]; 58 char drive[32][2]; 59 int drive_count; 60 int drive_index; 61 } GPPORTWINDIR; 62 63 64 /* Directory-oriented functions */ 65 # define gp_system_dir GPPORTWINDIR * 66 # define gp_system_dirent WIN32_FIND_DATA * 67 # define gp_system_dir_delim '\\' 68 69 # define sleep(x) usleep((x) * 1000 * 1000) 70 71 72 73 /************************************************************************ 74 * End WIN32 definitions 75 ************************************************************************/ 76 77 #elif defined(__SOME_OS2_MAGIC_HERE__) 78 79 /************************************************************************ 80 * Begin OS/2 definitions 81 ************************************************************************/ 82 83 # define strcasecmp(foo,bar) stricmp(foo,bar) 84 # define gp_system_dir_delim '\\' 85 86 # ifndef GPIO_OS2_INCLUDED 87 # define GPIO_OS2_INCLUDED 88 # define IOLIBS getenv("IOLIBS") 89 /*#define IOLIBS "./libgphoto2_port"*/ 90 # define RTLD_LAZY 0x001 91 92 93 # ifndef HAVE_TERMIOS_H 94 # define INCL_DOSDEVIOCTL /* DosDevIOCtl values */ 95 # define IOCTL_ASYNC 0x0001 96 # define ASYNC_SETBAUDRATE 0x0041 97 /* c_cflag bit meaning */ 98 # define CBAUD 0x0000100f 99 # define B0 0x00000000 /* hang up */ 100 # define B50 0x00000001 101 # define B75 0x00000002 102 # define B110 0x00000003 103 # define B134 0x00000004 104 # define B150 0x00000005 105 # define B200 0x00000006 106 # define B300 0x00000007 107 # define B600 0x00000008 108 # define B1200 0x00000009 109 # define B1800 0x0000000a 110 # define B2400 0x0000000b 111 # define B4800 0x0000000c 112 # define B9600 0x0000000d 113 # define B19200 0x0000000e 114 # define B38400 0x0000000f 115 # define EXTA B19200 116 # define EXTB B38400 117 # define CSIZE 0x00000030 118 # define CS5 0x00000000 119 # define CS6 0x00000010 120 # define CS7 0x00000020 121 # define CS8 0x00000030 122 # define CSTOPB 0x00000040 123 # define CREAD 0x00000080 124 # define PARENB 0x00000100 125 # define PARODD 0x00000200 126 # define HUPCL 0x00000400 127 # define CLOCAL 0x00000800 128 # define CBAUDEX 0x00001000 129 # define B57600 0x00001001 130 # define B115200 0x00001002 131 # define B230400 0x00001003 132 # define B460800 0x00001004 133 # define B76800 0x00001005 134 # define B153600 0x00001006 135 # define B307200 0x00001007 136 # define B614400 0x00001008 137 # define B921600 0x00001009 138 # define B500000 0x0000100a 139 # define B576000 0x0000100b 140 # define B1000000 0x0000100c 141 # define B1152000 0x0000100d 142 # define B1500000 0x0000100e 143 # define B2000000 0x0000100f 144 145 # endif /* HAVE_TERMIOS_H */ 146 147 # define CIBAUD 0x100f0000 /* input baud rate (not used) */ 148 # define CMSPAR 0x40000000 /* mark or space (stick) parity */ 149 /* #define CRTSCTS 0x80000000 */ /* flow control */ 150 151 /* modem lines */ 152 # define TIOCM_LE 0x001 153 # define TIOCM_DTR 0x002 154 # define TIOCM_RTS 0x004 155 # define TIOCM_ST 0x008 156 # define TIOCM_SR 0x010 157 # define TIOCM_CTS 0x020 158 # define TIOCM_CAR 0x040 159 # define TIOCM_RNG 0x080 160 # define TIOCM_DSR 0x100 161 # define TIOCM_CD TIOCM_CAR 162 # define TIOCM_RI TIOCM_RNG 163 164 # define TIOCMBIC 0x06C 165 # define TIOCMBIS 0x06B 166 # define TIOCMGET 0x06E 167 168 # endif /* GPIO_OS2_INCLUDED */ 169 170 /************************************************************************ 171 * End OS/2 definitions 172 ************************************************************************/ 173 174 #else 175 176 /************************************************************************ 177 * Begin POSIX/XOPEN definitions 178 ************************************************************************/ 179 180 /* yummy. :) */ 181 182 # include <time.h> 183 184 # include <strings.h> 185 # include <sys/types.h> 186 # include <dirent.h> 187 #ifdef HAVE_SYS_PARAM_H 188 # include <sys/param.h> 189 #endif 190 # include <sys/stat.h> 191 # include <unistd.h> 192 193 194 /* Directory-oriented functions */ 195 /** A system directory handle */ 196 # define gp_system_dir DIR * 197 /** A system directory entry */ 198 # define gp_system_dirent struct dirent * 199 /** The directory delimiter character on this platform. */ 200 # define gp_system_dir_delim '/' 201 202 /************************************************************************ 203 * End POSIX/XOPEN definitions 204 ************************************************************************/ 205 206 #endif /* else */ 207 208 209 /************************************************************************ 210 * Begin platform independent portability functions 211 ************************************************************************/ 212 213 int gp_system_mkdir (const char *dirname); 214 int gp_system_rmdir (const char *dirname); 215 gp_system_dir gp_system_opendir (const char *dirname); 216 gp_system_dirent gp_system_readdir (gp_system_dir d); 217 const char* gp_system_filename (gp_system_dirent de); 218 int gp_system_closedir (gp_system_dir dir); 219 int gp_system_is_file (const char *filename); 220 int gp_system_is_dir (const char *dirname); 221 222 /************************************************************************ 223 * End platform independent portability functions 224 ************************************************************************/ 225 #endif /* _GPHOTO2_INTERNAL_CODE */ 226 227 #endif /* ifndef __GPHOTO2_PORT_PORTABILITY_H__ */ 228 /* end of file */ 229