1 /* 2 * cynapses libc functions 3 * 4 * Copyright (c) 2008-2013 by Andreas Schneider <asn@cryptomilk.org> 5 * Copyright (c) 2012-2013 by Dominik Schmidt <dev@dominik-schmidt.de> 6 * Copyright (c) 2012-2013 by Klaas Freitag <freitag@owncloud.com> 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 */ 22 23 #ifndef _C_PRIVATE_H 24 #define _C_PRIVATE_H 25 26 #include "config_csync.h" 27 28 /* cross platform defines */ 29 #include "config_csync.h" 30 #include <sys/types.h> 31 #include <sys/stat.h> 32 33 #ifdef _WIN32 34 #include <windows.h> 35 #include <windef.h> 36 #include <winbase.h> 37 #include <wchar.h> 38 #else 39 #include <unistd.h> 40 #endif 41 42 #include <errno.h> 43 44 #ifdef __MINGW32__ 45 #ifndef S_IRGRP 46 #define S_IRGRP 0 47 #endif 48 #ifndef S_IROTH 49 #define S_IROTH 0 50 #endif 51 #ifndef S_IXGRP 52 #define S_IXGRP 0 53 #endif 54 #ifndef S_IXOTH 55 #define S_IXOTH 0 56 #endif 57 58 #define S_IFSOCK 10000 /* dummy val on Win32 */ 59 #define S_IFLNK 10001 /* dummy val on Win32 */ 60 61 #define O_NOFOLLOW 0 62 #define O_NOCTTY 0 63 64 #define uid_t int 65 #define gid_t int 66 #define nlink_t int 67 #define getuid() 0 68 #define geteuid() 0 69 #elif defined(_WIN32) 70 #define mode_t int 71 #else 72 #include <fcntl.h> 73 #endif 74 75 76 #ifdef _WIN32 77 typedef struct stat64 csync_stat_t; 78 #define _FILE_OFFSET_BITS 64 79 #else 80 typedef struct stat csync_stat_t; 81 #endif 82 83 #ifndef O_NOATIME 84 #define O_NOATIME 0 85 #endif 86 87 #ifndef HAVE_LSTAT 88 #define lstat _stat 89 #endif 90 91 /* tchar definitions for clean win32 filenames */ 92 #ifndef _UNICODE 93 #define _UNICODE 94 #endif 95 96 #if defined _WIN32 && defined _UNICODE 97 typedef wchar_t mbchar_t; 98 #define _topen _wopen 99 #define _tdirent _wdirent 100 #define _topendir _wopendir 101 #define _tclosedir _wclosedir 102 #define _treaddir _wreaddir 103 #define _trewinddir _wrewinddir 104 #define _ttelldir _wtelldir 105 #define _tseekdir _wseekdir 106 #define _tcreat _wcreat 107 #define _tstat _wstat64 108 #define _tfstat _fstat64 109 #define _tunlink _wunlink 110 #define _tmkdir(X,Y) _wmkdir(X) 111 #define _trmdir _wrmdir 112 #define _tchmod _wchmod 113 #define _trewinddir _wrewinddir 114 #define _tchown(X, Y, Z) 0 /* no chown on Win32 */ 115 #define _tchdir _wchdir 116 #define _tgetcwd _wgetcwd 117 #else 118 typedef char mbchar_t; 119 #define _tdirent dirent 120 #define _topen open 121 #define _topendir opendir 122 #define _tclosedir closedir 123 #define _treaddir readdir 124 #define _trewinddir rewinddir 125 #define _ttelldir telldir 126 #define _tseekdir seekdir 127 #define _tcreat creat 128 #define _tstat lstat 129 #define _tfstat fstat 130 #define _tunlink unlink 131 #define _tmkdir(X,Y) mkdir(X,Y) 132 #define _trmdir rmdir 133 #define _tchmod chmod 134 #define _trewinddir rewinddir 135 #define _tchown(X,Y,Z) chown(X,Y,Z) 136 #define _tchdir chdir 137 #define _tgetcwd getcwd 138 #endif 139 140 /* FIXME: Implement TLS for OS X */ 141 #if defined(__GNUC__) && !defined(__APPLE__) 142 # define CSYNC_THREAD __thread 143 #elif defined(_MSC_VER) 144 # define CSYNC_THREAD __declspec(thread) 145 #else 146 # define CSYNC_THREAD 147 #endif 148 149 #endif //_C_PRIVATE_H 150 151 /* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */ 152