LibreOffice Module onlineupdate (master) 1
updatedefines.h
Go to the documentation of this file.
1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5#ifndef UPDATEDEFINES_H
6#define UPDATEDEFINES_H
7
8#include "readstrings.h"
9
10#ifndef MAXPATHLEN
11# ifdef PATH_MAX
12# define MAXPATHLEN PATH_MAX
13# elif defined(MAX_PATH)
14# define MAXPATHLEN MAX_PATH
15# elif defined(_MAX_PATH)
16# define MAXPATHLEN _MAX_PATH
17# elif defined(CCHMAXPATH)
18# define MAXPATHLEN CCHMAXPATH
19# else
20# define MAXPATHLEN 1024
21# endif
22#endif
23
24#if defined(_WIN32)
25# include <windows.h>
26# include <shlwapi.h>
27# include <direct.h>
28# include <io.h>
29# include <stdio.h>
30# include <stdarg.h>
31
32# define F_OK 00
33# define W_OK 02
34# define R_OK 04
35# define S_ISDIR(s) (((s) & _S_IFMT) == _S_IFDIR)
36# define S_ISREG(s) (((s) & _S_IFMT) == _S_IFREG)
37
38# define access _access
39
40# define putenv _putenv
41# define DELETE_DIR L"tobedeleted"
42# define CALLBACK_BACKUP_EXT L".moz-callback"
43
44# define LOG_S "%S"
45# define NS_T(str) L ## str
46# define NS_SLASH NS_T('\\')
47
48static inline int mywcsprintf(WCHAR* dest, size_t count, const WCHAR* fmt, ...)
49{
50 size_t _count = count - 1;
51 va_list varargs;
52 va_start(varargs, fmt);
53 int result = _vsnwprintf(dest, count - 1, fmt, varargs);
54 va_end(varargs);
55 dest[_count] = L'\0';
56 return result;
57}
58#define NS_tsnprintf mywcsprintf
59# define NS_taccess _waccess
60# define NS_tchdir _wchdir
61# define NS_tchmod _wchmod
62# define NS_tfopen _wfopen
63# define NS_tmkdir(path, perms) _wmkdir(path)
64# define NS_tremove _wremove
65// _wrename is used to avoid the link tracking service.
66# define NS_trename _wrename
67# define NS_trmdir _wrmdir
68# define NS_tstat _wstat
69# define NS_tlstat _wstat // No symlinks on Windows
70# define NS_tstat_t _stat
71# define NS_tstrcat wcscat
72# define NS_tstrcmp wcscmp
73# define NS_tstrncmp wcsncmp
74# define NS_tstricmp wcsicmp
75# define NS_tstrcpy wcscpy
76# define NS_tstrncpy wcsncpy
77# define NS_tstrlen wcslen
78# define NS_tstrchr wcschr
79# define NS_tstrrchr wcsrchr
80# define NS_tstrstr wcsstr
81# include "win_dirent.h"
82# define NS_tDIR DIR
83# define NS_tdirent dirent
84# define NS_topendir opendir
85# define NS_tclosedir closedir
86# define NS_treaddir readdir
87#else
88# include <sys/wait.h>
89# include <unistd.h>
90
91#ifdef __sun
92# include <sys/stat.h>
93#else
94# include <fts.h>
95#endif
96# include <dirent.h>
97
98#ifdef MACOSX
99# include <sys/time.h>
100#endif
101
102# define LOG_S "%s"
103# define NS_T(str) str
104# define NS_SLASH NS_T('/')
105# define NS_tsnprintf snprintf
106# define NS_taccess access
107# define NS_tchdir chdir
108# define NS_tchmod chmod
109# define NS_tfopen fopen
110# define NS_tmkdir mkdir
111# define NS_tremove remove
112# define NS_trename rename
113# define NS_trmdir rmdir
114# define NS_tstat stat
115# define NS_tstat_t stat
116# define NS_tlstat lstat
117# define NS_tstrcat strcat
118# define NS_tstrcmp strcmp
119# define NS_tstrncmp strncmp
120# define NS_tstricmp strcasecmp
121# define NS_tstrcpy strcpy
122# define NS_tstrncpy strncpy
123# define NS_tstrlen strlen
124# define NS_tstrrchr strrchr
125# define NS_tstrstr strstr
126# define NS_tDIR DIR
127# define NS_tdirent dirent
128# define NS_topendir opendir
129# define NS_tclosedir closedir
130# define NS_treaddir readdir
131#endif
132
133#define BACKUP_EXT NS_T(".moz-backup")
134
135#endif
Any result