libgphoto2 photo camera library (libgphoto2) API 2.5.30

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#ifndef _SSIZE_T_DEFINED
52 typedef SSIZE_T ssize_t;
53#endif
54
55/* Work-around for readdir() */
56 typedef struct {
57 HANDLE handle;
58 int got_first;
59 WIN32_FIND_DATA search;
60 char dir[1024];
61 char drive[32][2];
62 int drive_count;
63 int drive_index;
64} GPPORTWINDIR;
65
66
67/* Directory-oriented functions */
68# define gp_system_dir GPPORTWINDIR *
69# define gp_system_dirent WIN32_FIND_DATA *
70# define gp_system_dir_delim '\\'
71
72# define sleep(x) usleep((x) * 1000 * 1000)
73
74
75
76/************************************************************************
77 * End WIN32 definitions
78 ************************************************************************/
79
80#else
81
82/************************************************************************
83 * Begin POSIX/XOPEN definitions
84 ************************************************************************/
85
86/* yummy. :) */
87
88/* XOPEN needed for usleep */
89#ifndef _XOPEN_SOURCE
90# define _XOPEN_SOURCE 500
91#else
92# if ((_XOPEN_SOURCE - 0) < 500)
93# undef _XOPEN_SOURCE
94# define _XOPEN_SOURCE 500
95# endif
96#endif
97
98/* for nanosleep */
99# ifndef _POSIX_C_SOURCE
100# define _POSIX_C_SOURCE 199309
101# endif
102# include <time.h>
103
104# include <strings.h>
105# include <sys/types.h>
106# include <dirent.h>
107#ifdef HAVE_SYS_PARAM_H
108# include <sys/param.h>
109#endif
110# include <sys/stat.h>
111# include <unistd.h>
112
113
114/* Directory-oriented functions */
116# define gp_system_dir DIR *
118# define gp_system_dirent struct dirent *
120# define gp_system_dir_delim '/'
121
122/************************************************************************
123 * End POSIX/XOPEN definitions
124 ************************************************************************/
125
126#endif /* else */
127
128
129/************************************************************************
130 * Begin platform independent portability functions
131 ************************************************************************/
132
133 int gp_system_mkdir (const char *dirname);
134 int gp_system_rmdir (const char *dirname);
135gp_system_dir gp_system_opendir (const char *dirname);
136gp_system_dirent gp_system_readdir (gp_system_dir d);
137 const char* gp_system_filename (gp_system_dirent de);
138 int gp_system_closedir (gp_system_dir dir);
139 int gp_system_is_file (const char *filename);
140 int gp_system_is_dir (const char *dirname);
141
142/************************************************************************
143 * End platform independent portability functions
144 ************************************************************************/
145#endif /* _GPHOTO2_INTERNAL_CODE */
146
147#endif /* !defined(LIBGPHOTO2_GPHOTO2_PORT_PORTABILITY_H) */
148
149/* end of file */
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_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_closedir
int gp_system_closedir(gp_system_dir dir)
closedir UNIX functionality
Definition: gphoto2-port-portability.c:249
gp_system_opendir
gp_system_dir gp_system_opendir(const char *dirname)
opendir UNIX functionality
Definition: gphoto2-port-portability.c:211
gp_system_mkdir
int gp_system_mkdir(const char *dirname)
mkdir UNIX functionality
Definition: gphoto2-port-portability.c:180
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_dir
int gp_system_is_dir(const char *dirname)
check if passed filename is a directory
Definition: gphoto2-port-portability.c:280
gp_system_rmdir
int gp_system_rmdir(const char *dirname)
rmdir UNIX functionality
Definition: gphoto2-port-portability.c:194