libgphoto2 photo camera library (libgphoto2) API  2.5.28
gphoto2-port-portability.h
1 
21 #ifndef LIBGPHOTO2_GPHOTO2_PORT_PORTABILITY_H
22 #define LIBGPHOTO2_GPHOTO2_PORT_PORTABILITY_H
23 
24 #ifdef _GPHOTO2_INTERNAL_CODE
25 
26 #if defined(WIN32) && !defined(__WINESRC__)
27 
28 /************************************************************************
29  * Begin Windows definitions (but not during WINE compilation)
30  ************************************************************************/
31 
32 # include <windows.h>
33 /* done by mingw/wine headers ... defined to struct ... tsaes*/
34 #undef interface
35 # include <sys/types.h>
36 # include <sys/stat.h>
37 # include <string.h>
38 # include <stdio.h>
39 # include <direct.h>
40 
41 # ifndef IOLIBS
42 # define IOLIBS "."
43 # endif
44 # define strcasecmp _stricmp
45 # ifndef snprintf
46 # define snprintf _snprintf
47 # endif
48 
49 #define __func__ __FUNCTION__
50 
51 typedef SSIZE_T ssize_t;
52 
53 /* Work-around for readdir() */
54 typedef struct {
55  HANDLE handle;
56  int got_first;
57  WIN32_FIND_DATA search;
58  char dir[1024];
59  char drive[32][2];
60  int drive_count;
61  int drive_index;
62 } GPPORTWINDIR;
63 
64 
65 /* Directory-oriented functions */
66 # define gp_system_dir GPPORTWINDIR *
67 # define gp_system_dirent WIN32_FIND_DATA *
68 # define gp_system_dir_delim '\\'
69 
70 # define sleep(x) usleep((x) * 1000 * 1000)
71 
72 
73 
74 /************************************************************************
75  * End WIN32 definitions
76  ************************************************************************/
77 
78 #else
79 
80 /************************************************************************
81  * Begin POSIX/XOPEN definitions
82  ************************************************************************/
83 
84 /* yummy. :) */
85 
86 /* XOPEN needed for usleep */
87 #ifndef _XOPEN_SOURCE
88 # define _XOPEN_SOURCE 500
89 #else
90 # if ((_XOPEN_SOURCE - 0) < 500)
91 # undef _XOPEN_SOURCE
92 # define _XOPEN_SOURCE 500
93 # endif
94 #endif
95 
96 /* for nanosleep */
97 # ifndef _POSIX_C_SOURCE
98 # define _POSIX_C_SOURCE 199309
99 # endif
100 # include <time.h>
101 
102 # include <strings.h>
103 # include <sys/types.h>
104 # include <dirent.h>
105 #ifdef HAVE_SYS_PARAM_H
106 # include <sys/param.h>
107 #endif
108 # include <sys/stat.h>
109 # include <unistd.h>
110 
111 
112 /* Directory-oriented functions */
114 # define gp_system_dir DIR *
115 
116 # define gp_system_dirent struct dirent *
117 
118 # define gp_system_dir_delim '/'
119 
120 /************************************************************************
121  * End POSIX/XOPEN definitions
122  ************************************************************************/
123 
124 #endif /* else */
125 
126 
127 /************************************************************************
128  * Begin platform independent portability functions
129  ************************************************************************/
130 
131 int gp_system_mkdir (const char *dirname);
132 int gp_system_rmdir (const char *dirname);
133 gp_system_dir gp_system_opendir (const char *dirname);
134 gp_system_dirent gp_system_readdir (gp_system_dir d);
135 const char* gp_system_filename (gp_system_dirent de);
136 int gp_system_closedir (gp_system_dir dir);
137 int gp_system_is_file (const char *filename);
138 int gp_system_is_dir (const char *dirname);
139 
140 /************************************************************************
141  * End platform independent portability functions
142  ************************************************************************/
143 #endif /* _GPHOTO2_INTERNAL_CODE */
144 
145 #endif /* !defined(LIBGPHOTO2_GPHOTO2_PORT_PORTABILITY_H) */
146 
147 /* end of file */
gp_system_closedir
int gp_system_closedir(gp_system_dir dir)
closedir UNIX functionality
Definition: gphoto2-port-portability.c:249
gp_system_filename
const char * gp_system_filename(gp_system_dirent de)
retrieve UNIX filename out of a directory entry
Definition: gphoto2-port-portability.c:237
gp_system_readdir
gp_system_dirent gp_system_readdir(gp_system_dir d)
readdir UNIX functionality
Definition: gphoto2-port-portability.c:225
gp_system_is_file
int gp_system_is_file(const char *filename)
check if passed filename is a file
Definition: gphoto2-port-portability.c:263
gp_system_rmdir
int gp_system_rmdir(const char *dirname)
rmdir UNIX functionality
Definition: gphoto2-port-portability.c:194
gp_system_mkdir
int gp_system_mkdir(const char *dirname)
mkdir UNIX functionality
Definition: gphoto2-port-portability.c:180
gp_system_opendir
gp_system_dir gp_system_opendir(const char *dirname)
opendir UNIX functionality
Definition: gphoto2-port-portability.c:211
gp_system_is_dir
int gp_system_is_dir(const char *dirname)
check if passed filename is a directory
Definition: gphoto2-port-portability.c:280