-
Notifications
You must be signed in to change notification settings - Fork 333
/
Copy pathgphoto2-port-portability.h
150 lines (119 loc) · 4.23 KB
/
gphoto2-port-portability.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/** \file gphoto2-port-log.h
*
* Copyright 2001 Lutz Mueller <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#ifndef LIBGPHOTO2_GPHOTO2_PORT_PORTABILITY_H
#define LIBGPHOTO2_GPHOTO2_PORT_PORTABILITY_H
#ifdef _GPHOTO2_INTERNAL_CODE
#if defined(WIN32) && !defined(__WINESRC__)
/************************************************************************
* Begin Windows definitions (but not during WINE compilation)
************************************************************************/
# include <windows.h>
/* done by mingw/wine headers ... defined to struct ... tsaes*/
#undef interface
# include <sys/types.h>
# include <sys/stat.h>
# include <string.h>
# include <stdio.h>
# include <direct.h>
# include <unistd.h>
# ifndef IOLIBS
# define IOLIBS "."
# endif
# define strcasecmp _stricmp
# ifndef snprintf
# define snprintf _snprintf
# endif
#define __func__ __FUNCTION__
#ifndef _SSIZE_T_DEFINED
typedef SSIZE_T ssize_t;
#endif
/* Work-around for readdir() */
typedef struct {
HANDLE handle;
int got_first;
WIN32_FIND_DATA search;
char dir[1024];
char drive[32][2];
int drive_count;
int drive_index;
} GPPORTWINDIR;
/* Directory-oriented functions */
# define gp_system_dir GPPORTWINDIR *
# define gp_system_dirent WIN32_FIND_DATA *
# define gp_system_dir_delim '\\'
# define sleep(x) usleep((x) * 1000 * 1000)
/************************************************************************
* End WIN32 definitions
************************************************************************/
#else
/************************************************************************
* Begin POSIX/XOPEN definitions
************************************************************************/
/* yummy. :) */
/* XOPEN needed for usleep */
#ifndef _XOPEN_SOURCE
# define _XOPEN_SOURCE 500
#else
# if ((_XOPEN_SOURCE - 0) < 500)
# undef _XOPEN_SOURCE
# define _XOPEN_SOURCE 500
# endif
#endif
/* for nanosleep */
# ifndef _POSIX_C_SOURCE
# define _POSIX_C_SOURCE 199309
# endif
# include <time.h>
# include <strings.h>
# include <sys/types.h>
# include <dirent.h>
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
# include <sys/stat.h>
# include <unistd.h>
/* Directory-oriented functions */
/** A system directory handle */
# define gp_system_dir DIR *
/** A system directory entry */
# define gp_system_dirent struct dirent *
/** The directory delimiter character on this platform. */
# define gp_system_dir_delim '/'
/************************************************************************
* End POSIX/XOPEN definitions
************************************************************************/
#endif /* else */
/************************************************************************
* Begin platform independent portability functions
************************************************************************/
int gp_system_mkdir (const char *dirname);
int gp_system_rmdir (const char *dirname);
gp_system_dir gp_system_opendir (const char *dirname);
gp_system_dirent gp_system_readdir (gp_system_dir d);
const char* gp_system_filename (gp_system_dirent de);
int gp_system_closedir (gp_system_dir dir);
int gp_system_is_file (const char *filename);
int gp_system_is_dir (const char *dirname);
/************************************************************************
* End platform independent portability functions
************************************************************************/
#endif /* _GPHOTO2_INTERNAL_CODE */
#endif /* !defined(LIBGPHOTO2_GPHOTO2_PORT_PORTABILITY_H) */
/* end of file */