2 * User FTP Server, Share folders over FTP without being root.
3 * Copyright (C) 2008 Isaac Jurado
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option) any later
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21 * Hasefroch compatiblity. This header contains the rest of the junk (the
22 * initial junk is at uftps.h) to compile the application with MinGW while
23 * maintaining the UNIX look of the code. Most of the wrappers are trivial, but
24 * still was desirable to avoid having aliases for the underscore prefixed
27 * However, the Hasefroch support is not complete. The way WINVER is defined in
28 * uftps.h prevents this program to be compiled or run in Hasefroch versions
31 * NOTE: Inline functions are preferred over macros as some type checking is
32 * allowed. When this type checking is not appreciated, macros are used
36 #define __MSVCRT_VERSION__ 0x0601
45 * File stat wrappers, with large file support. Structures, fields and macros
46 * and functions. Hasefroch does not have symbolic links, so we do not care
54 #define st_size x.st_size
55 #define st_mode x.st_mode
56 #define st_mtime x.st_mtime
58 #define S_ISDIR _S_ISDIR
59 #define S_ISREG _S_ISREG
61 static inline int lstat (const char *path
, struct stat
*st
)
63 return _stat64(path
, &st
->x
);
68 * File I/O wrappers. No writing support as the server is not supposed to
69 * modify the filesystem.
71 #define O_RDONLY _O_RDONLY
73 static inline int open (const char *pathname
, int flags
)
75 return _open(pathname
, flags
| _O_BINARY
| _O_SEQUENTIAL
);
79 static inline off_t
lseek (int fd
, off_t offset
, int whence
)
81 return _lseeki64(fd
, offset
, whence
);
85 static inline int read (int fd
, void *buf
, size_t count
)
87 return _read(fd
, buf
, count
);
91 static inline int close (int fd
)
98 * Miscellany wrappers. In the case of gmtime, dealing with parameter types
99 * (which obviously differ) is avoided by directly issuing the st_mtime field as
100 * the time parameter.
102 #define gmtime(t) _gmtime64(t)
104 static inline int getpid (void)