gphoto2-port-portability.h 7.0 KB

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