libgphoto2 photo camera library (libgphoto2) API 2.5.31

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