1 /* w32lib.h - Posix emulation layer for Sylpheed (Claws)
3 * This file is part of w32lib.
5 * w32lib is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * w32lib 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
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 * The code has been taken from the package
19 * http://claws.sylpheed.org/win32/sylpheed/w32lib-dev-2004.2.3.0.zip
20 * on 2005-11-17 by Werner Koch <wk@gnupg.org>. There are no regular
21 * copyright notices but the file version.rc from the ZIP archive
24 * #define FILEVER "2004.2.3.0\0"
25 * #define PRODVER "2004.2.3\0"
28 * VALUE "FileDescription", "Posix emulation layer for Sylpheed (Claws)\0"
29 * VALUE "FileVersion", FILEVER
30 * VALUE "ProductVersion", PRODVER
31 * VALUE "LegalCopyright", "GPL\0"
32 * VALUE "CompanyName", "GNU / Free Software Foundation\0"
33 * VALUE "ProductName", "w32lib\0"
35 * Along with the fact that Sylpheed is under the GPL we can assume
36 * that this code is under the GPL. No author information or
37 * changelogs have been found.
38 * Files taken form the package are:
39 * w32_dirent.c w32_reg.c w32_stat.c w32_stdlib.c w32_time.c w32_wait.c
40 * w32_gettext.c w32_signal.c w32_stdio.c w32_string.c w32_unistd.c
45 2007-05-21 Werner Koch <wk@g10code.com>
47 * src/common/w32_account.c: New.
49 * src/common/w32lib.h: Undef "interface".
51 2005-11-17 Werner Koch <wk@g10code.com>
53 Add boilerplate text to all files and explain legal status.
55 * w32_reg.c: Replaced g_free and g_strdup by regular C functions.
56 (get_content_type_from_registry_with_ext): Ditto.
57 * w32_dirent.c (readdir): Ditto.
59 (closedir): Reformatted.
60 (readdir): Reformatted, replaced use of g_strdup_printf and other
61 g-style malloc function by regular ones. Use DIR structure from mingw.
62 * w32lib.h: Don't define finddata_t for mingw. Replaced replacement
63 DIR structure by the one form mingw. Allocate filename in dirent
64 statically to match the defintion ussed by mingw.
65 * w32_reg.c (read_w32_registry_string): Return error for invalid root
80 # define MINGW32_VERSION (__MINGW32_MAJOR_VERSION * 100 \
81 + __MINGW32_MINOR_VERSION)
82 # define MINGW64_VERSION (__MINGW64_VERSION_MAJOR * 100 \
83 + __MINGW64_VERSION_MINOR)
86 # include <sys/time.h>
87 # if MINGW64_VERSION >= 200
88 # include <sys/types.h>
90 #endif /* __MINGW32__ */
92 #include <glib/gstdio.h>
94 /* Mingw32 3.4.4 defines interface to struct and thus breaks our own
95 use of that symbol. Undef it here. */
96 #if defined(_BASETYPS_H) && defined(interface)
104 typedef long int off_t
;
106 typedef unsigned char u_char
;
107 #endif /* __MINGW32__ */
108 typedef unsigned int uid_t
;
112 #define S_IRUSR _S_IREAD
113 #define S_IWUSR _S_IWRITE
114 #define S_IXUSR _S_IEXEC
115 #define S_IRWXU (_S_IREAD|_S_IWRITE|_S_IEXEC)
116 #endif /* __MINGW32__ */
120 #define SIGPIPE _S_IFIFO
124 #define __S_ISTYPE(mode, mask) (((mode) & _S_IFMT) == (mask))
126 #define S_ISFIFO(mode) __S_ISTYPE((mode), _S_IFIFO)
127 #define S_ISDIR(mode) __S_ISTYPE((mode), _S_IFDIR)
128 #define S_ISREG(mode) __S_ISTYPE((mode), _S_IFREG)
129 #endif /* __MINGW32__ */
133 #if MINGW64_VERSION < 200
134 int strcasecmp( const char *s1
, const char *s2
);
135 int strncasecmp( const char *s1
, const char *s2
, size_t n
);
140 typedef void * HANDLE
;
142 #ifndef _FINDDATA_T_DEFINED
143 typedef unsigned long _fsize_t
; /* Could be 64 bits for Win32 */
146 time_t time_create
; /* -1 for FAT file systems */
147 time_t time_access
; /* -1 for FAT file systems */
152 #endif /* !_FINDDATA_T_DEFINED */
156 unsigned short d_reclen
;
157 unsigned short d_namlen
;
158 char d_name
[FILENAME_MAX
];
163 struct _finddata_t dd_dta
;
164 struct dirent dd_dir
;
170 #endif /* !__MINGW32__ */
172 #if defined (__MINGW32__) && MINGW32_VERSION < 312
173 # if MINGW64_VERSION < 200
182 int lstat( const char *file_name
, GStatBuf
*buf
);
185 pid_t
waitpid( pid_t pid
, int *status
, int options
);
188 #if ! defined (__MINGW32__) || MINGW32_VERSION < 312
189 # if MINGW64_VERSION < 200
190 int gettimeofday( struct timeval
*tv
, struct timezone
*tz
);
195 int setpgid( pid_t pid
, pid_t pgid
);
196 pid_t
getppid( void );
197 unsigned int sleep( unsigned int seconds
);
200 long int random( void );
201 void srandom( unsigned int seed
);
202 #if MINGW64_VERSION < 200
203 int truncate( const char *path
, off_t length
);
207 int kill( pid_t pid
, int sig
);
210 #if MINGW64_VERSION < 200
211 FILE *popen( const char *command
, const char *type
);
212 int pclose( FILE *stream
);
215 /*** w32_account.c ***/
216 int w32_is_administrator (void);
219 int write_w32_registry_string( char *parent
, char *section
, char *value
, char *data
);
220 int write_w32_registry_dword( char *parent
, char *section
, char *value
, int data
);
221 char *read_w32_registry_string( char *parent
, char *section
, char *key
);
222 char *get_content_type_from_registry_with_ext( char *ext
);