doc
c_private.h
Go to the documentation of this file.
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.h"
27
28/* cross platform defines */
29#include "config.h"
30#include <sys/types.h>
31#include <sys/stat.h>
32
33#ifdef _WIN32
34#include <windef.h>
35#include <winbase.h>
36#endif
37
38#ifdef _WIN32
39#define EDQUOT 0
40#define ENODATA 0
41#define S_IRGRP 0
42#define S_IROTH 0
43#define S_IXGRP 0
44#define S_IXOTH 0
45
46#define S_IFSOCK 10000 /* dummy val on Win32 */
47#define S_IFLNK 10001 /* dummy val on Win32 */
48
49#define O_NOFOLLOW 0
50#define O_NOCTTY 0
51
52#define uid_t int
53#define gid_t int
54#define nlink_t int
55#define getuid() 0
56#define geteuid() 0
57#endif
58
59#ifdef _WIN32
60typedef struct _stat csync_stat_t;
61#else
62typedef struct stat csync_stat_t;
63#endif
64
65#ifndef O_NOATIME
66#define O_NOATIME 0
67#endif
68
69#ifndef ENODATA
70#define ENODATA EBADF
71#endif
72
73#if !defined(HAVE_ASPRINTF) && defined(HAVE___MINGW_ASPRINTF)
74#define asprintf __mingw_asprintf
75#endif
76
77#ifndef HAVE_STRERROR_R
78#define strerror_r(errnum, buf, buflen) snprintf(buf, buflen, "%s", strerror(errnum))
79#endif
80
81#ifndef HAVE_LSTAT
82#define lstat _stat
83#endif
84#ifdef _WIN32
85#define fstat _fstat
86#endif
87
88
89/* tchar definitions for clean win32 filenames */
90#define _UNICODE
91
92#if defined _WIN32 && defined _UNICODE
93typedef wchar_t mbchar_t;
94#define _topen _wopen
95#define _tdirent _wdirent
96#define _TDIR _WDIR
97#define _topendir _wopendir
98#define _tclosedir _wclosedir
99#define _treaddir _wreaddir
100#define _trewinddir _wrewinddir
101#define _ttelldir _wtelldir
102#define _tseekdir _wseekdir
103#define _tcreat _wcreat
104#define _tstat _wstat
105#define _tunlink _wunlink
106#define _tmkdir(X,Y) _wmkdir(X)
107#define _trmdir _rmdir
108#define _tchmod _wchmod
109#define _trewinddir _wrewinddir
110#define _tchown(X, Y, Z) /* no chown on Win32 */
111#else
112typedef char mbchar_t;
113#define _tdirent dirent
114#define _topen open
115#define _TDIR DIR
116#define _topendir opendir
117#define _tclosedir closedir
118#define _treaddir readdir
119#define _trewinddir rewinddir
120#define _ttelldir telldir
121#define _tseekdir seekdir
122#define _tcreat creat
123#define _tstat stat
124#define _tunlink unlink
125#define _tmkdir(X,Y) mkdir(X,Y)
126#define _trmdir rmdir
127#define _tchmod chmod
128#define _trewinddir rewinddir
129#define _tchown(X,Y,Z) chown(X,Y,Z)
130#endif
131
132#ifdef WITH_ICONV
133/** @internal */
134int c_setup_iconv(const char* to);
135/** @internal */
136int c_close_iconv(void);
137#endif
138
139#if defined(__GNUC__)
140# define CSYNC_THREAD __thread
141#elif defined(_MSC_VER)
142# define CSYNC_THREAD __declspec(thread)
143#else
144# define CSYNC_THREAD
145#endif
146
147#endif //_C_PRIVATE_H
148
149/* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */
struct stat csync_stat_t
Definition c_private.h:62
char mbchar_t
Definition c_private.h:112