ReactOS  0.4.10-dev-509-g12e8d7f
libport.h
Go to the documentation of this file.
1 /* @(#)libport.h 1.45 17/05/02 Copyright 1995-2017 J. Schilling */
2 /*
3  * Prototypes for POSIX standard functions that may be missing on the
4  * local platform and thus are implemented inside libschily.
5  *
6  * Copyright (c) 1995-2017 J. Schilling
7  */
8 /*
9  * The contents of this file are subject to the terms of the
10  * Common Development and Distribution License, Version 1.0 only
11  * (the "License"). You may not use this file except in compliance
12  * with the License.
13  *
14  * See the file CDDL.Schily.txt in this distribution for details.
15  * A copy of the CDDL is also available via the Internet at
16  * http://www.opensource.org/licenses/cddl1.txt
17  *
18  * When distributing Covered Code, include this CDDL HEADER in each
19  * file and include the License file CDDL.Schily.txt from this distribution.
20  */
21 
22 
23 #ifndef _SCHILY_LIBPORT_H
24 #define _SCHILY_LIBPORT_H
25 
26 #ifndef _SCHILY_MCONFIG_H
27 #include <schily/mconfig.h>
28 #endif
29 #ifndef _SCHILY_TYPES_H
30 #include <schily/types.h>
31 #endif
32 
33 #ifndef _SCHILY_UNISTD_H
34 #include <schily/unistd.h>
35 #endif
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 #if defined(_INCL_SYS_TYPES_H) || defined(_INCL_TYPES_H) || defined(size_t)
42 # ifndef FOUND_SIZE_T
43 # define FOUND_SIZE_T
44 # endif
45 #endif
46 #if defined(_MSC_VER) && !defined(_SIZE_T_DEFINED)
47 # undef FOUND_SIZE_T
48 #endif
49 
50 #ifdef OPENSERVER
51 /*
52  * Don't use the usleep() from libc on SCO's OPENSERVER.
53  * It will kill our processes with SIGALRM.
54  */
55 /*
56  * Don't #undef HAVE_USLEEP in this file, SCO has a
57  * usleep() prototype in unistd.h
58  */
59 /* #undef HAVE_USLEEP */
60 #endif
61 
62 #ifdef FOUND_SIZE_T
63 /*
64  * We currently cannot define this here because there IRIX has a definition
65  * than violates the standard.
66  */
67 #ifndef HAVE_SNPRINTF
68 /*PRINTFLIKE3*/
69 extern int snprintf __PR((char *, size_t, const char *, ...))
70  __printflike__(3, 4);
71 #endif
72 #endif
73 
74 #ifdef EOF /* stdio.h has been included */
75 #ifdef FOUND_SIZE_T
76 #ifndef HAVE_GETDELIM
77 extern ssize_t getdelim __PR((char **, size_t *, int, FILE *));
78 #endif
79 #endif
80 #endif
81 
82 #ifndef HAVE_GETHOSTID
83 extern long gethostid __PR((void));
84 #endif
85 #ifndef HAVE_GETPAGESIZE
86 extern int getpagesize __PR((void));
87 #endif
88 #ifndef HAVE_USLEEP
89 extern int usleep __PR((int usec));
90 #endif
91 
92 #ifndef HAVE_STRCASECMP
93 extern int strcasecmp __PR((const char *, const char *));
94 #endif
95 #ifdef FOUND_SIZE_T
96 #ifndef HAVE_STRNCASECMP
97 extern int strncasecmp __PR((const char *, const char *,
98  size_t));
99 #endif
100 #endif
101 
102 #ifndef HAVE_STRCAT
103 extern char *strcat __PR((char *s1, const char *s2));
104 #endif
105 #ifndef HAVE_STRCHR
106 extern char *strchr __PR((const char *s1, int c));
107 #endif
108 #ifndef HAVE_STRCMP
109 extern int strcmp __PR((const char *s1, const char *s2));
110 #endif
111 #ifndef HAVE_STRCPY
112 extern char *strcpy __PR((char *s1, const char *s2));
113 #endif
114 #if !defined(HAVE_STRDUP) || defined(__SVR4)
115 extern char *strdup __PR((const char *s));
116 #endif
117 #ifdef FOUND_SIZE_T
118 #ifndef HAVE_STRNDUP
119 extern char *strndup __PR((const char *s, size_t len));
120 #endif
121 #ifndef HAVE_STRLEN
122 extern size_t strlen __PR((const char *s));
123 #endif
124 #ifndef HAVE_STRNLEN
125 extern size_t strnlen __PR((const char *s, size_t len));
126 #endif
127 #ifndef HAVE_STRLCAT
128 extern size_t strlcat __PR((char *s1, const char *s2,
129  size_t len));
130 #endif
131 #ifndef HAVE_STRLCPY
132 extern size_t strlcpy __PR((char *s1, const char *s2,
133  size_t len));
134 #endif
135 #ifndef HAVE_STRNCAT
136 extern char *strncat __PR((char *s1, const char *s2,
137  size_t len));
138 #endif
139 #ifndef HAVE_STRNCMP
140 extern int strncmp __PR((const char *s1, const char *s2,
141  size_t len));
142 #endif
143 #ifndef HAVE_STRNCPY
144 extern char *strncpy __PR((char *s1, const char *s2,
145  size_t len));
146 #endif
147 #endif /* FOUND_SIZE_T */
148 #ifndef HAVE_STRRCHR
149 extern char *strrchr __PR((const char *s1, int c));
150 #endif
151 
152 #ifndef HAVE_STRSTR
153 extern char *strstr __PR((const char *s1, const char *s2));
154 #endif
155 
156 #ifdef _SCHILY_WCHAR_H
157 #ifndef HAVE_WCSCAT
158 extern wchar_t *wcscat __PR((wchar_t *s1, const wchar_t *s2));
159 #endif
160 #ifndef HAVE_WCSCHR
161 extern wchar_t *wcschr __PR((const wchar_t *s1, wchar_t c));
162 #endif
163 #ifndef HAVE_WCSCMP
164 extern int wcscmp __PR((const wchar_t *s1,
165  const wchar_t *s2));
166 #endif
167 #ifndef HAVE_WCSCPY
168 extern wchar_t *wcscpy __PR((wchar_t *s1, const wchar_t *s2));
169 #endif
170 #ifndef HAVE_WCSDUP
171 extern wchar_t *wcsdup __PR((const wchar_t *s));
172 #endif
173 #ifdef FOUND_SIZE_T
174 #ifndef HAVE_WCSNDUP
175 extern wchar_t *wcsndup __PR((const wchar_t *s, size_t len));
176 #endif
177 #ifndef HAVE_WCSLEN
178 extern size_t wcslen __PR((const wchar_t *s));
179 #endif
180 #ifndef HAVE_WCSNLEN
181 extern size_t wcsnlen __PR((const wchar_t *s, size_t len));
182 #endif
183 #ifndef HAVE_WCSLCAT
184 extern size_t wcslcat __PR((wchar_t *s1, const wchar_t *s2,
185  size_t len));
186 #endif
187 #ifndef HAVE_WCSLCPY
188 extern size_t wcslcpy __PR((wchar_t *s1, const wchar_t *s2,
189  size_t len));
190 #endif
191 #ifndef HAVE_WCSNCAT
192 extern wchar_t *wcsncat __PR((wchar_t *s1, const wchar_t *s2,
193  size_t len));
194 #endif
195 #ifndef HAVE_WCSNCMP
196 extern int wcsncmp __PR((const wchar_t *s1,
197  const wchar_t *s2,
198  size_t len));
199 #endif
200 #ifndef HAVE_WCSNCPY
201 extern wchar_t *wcsncpy __PR((wchar_t *s1, const wchar_t *s2,
202  size_t len));
203 #endif
204 #endif /* FOUND_SIZE_T */
205 #ifndef HAVE_WCSRCHR
206 extern wchar_t *wcsrchr __PR((const wchar_t *s1, wchar_t c));
207 #endif
208 
209 #ifndef HAVE_WCSSTR
210 extern wchar_t *wcsstr __PR((const wchar_t *s1,
211  const wchar_t *s2));
212 #endif
213 #endif /* _SCHILY_WCHAR_H */
214 
215 #ifndef HAVE_RENAME
216 extern int rename __PR((const char *__old,
217  const char *__new));
218 #endif
219 
220 /*
221  * XXX Note: libgen.h / -lgen on Solaris contain eaccess()
222  */
223 #ifndef HAVE_EACCESS
224 extern int eaccess __PR((const char *name, int mode));
225 #endif
226 
227 /*
228  * See also libgen.h
229  */
230 #ifndef HAVE_BASENAME
231 extern char *basename __PR((char *name));
232 #endif
233 #ifndef HAVE_DIRNAME
234 extern char *dirname __PR((char *name));
235 #endif
236 
237 #ifndef HAVE_TIMEGM
238 #if defined(_SCHILY_TIME_H)
239 extern time_t timegm __PR((struct tm *));
240 #endif
241 #endif
242 
243 #ifndef HAVE_GETUID
244 extern uid_t getuid __PR((void));
245 #endif
246 #ifndef HAVE_GETEUID
247 extern uid_t geteuid __PR((void));
248 #endif
249 #ifndef HAVE_SETUID
250 extern int setuid __PR((uid_t uid));
251 #endif
252 #ifndef HAVE_SETEUID
253 extern int seteuid __PR((uid_t uid));
254 #endif
255 
256 #ifndef HAVE_GETGID
257 extern gid_t getgid __PR((void));
258 #endif
259 #ifndef HAVE_GETEGID
260 extern gid_t getegid __PR((void));
261 #endif
262 #ifndef HAVE_SETGID
263 extern int setgid __PR((gid_t gid));
264 #endif
265 #ifndef HAVE_SETEGID
266 extern int setegid __PR((gid_t gid));
267 #endif
268 
269 #ifndef HAVE_GETPWNAM
270 extern struct passwd *getpwnam __PR((const char *name));
271 #endif
272 #ifndef HAVE_GETPWENT
273 extern struct passwd *getpwent __PR((void));
274 #endif
275 #ifndef HAVE_GETPWUID
276 extern struct passwd *getpwuid __PR((uid_t uid));
277 #endif
278 #ifndef HAVE_SETPWENT
279 extern void setpwent __PR((void));
280 #endif
281 #ifndef HAVE_ENDPWENT
282 extern void endpwent __PR((void));
283 #endif
284 
285 
286 #ifndef HAVE_GETGRNAM
287 extern struct group *getgrnam __PR((const char *name));
288 #endif
289 #ifndef HAVE_GETGRENT
290 extern struct group *getgrent __PR((void));
291 #endif
292 #ifndef HAVE_GETGRGID
293 extern struct group *getgrgid __PR((gid_t gid));
294 #endif
295 #ifndef HAVE_SETGRENT
296 extern void setgrent __PR((void));
297 #endif
298 #ifndef HAVE_ENDGRENT
299 extern void endgrent __PR((void));
300 #endif
301 
302 #ifndef HAVE_FCHDIR
303 extern int fchdir __PR((int fd));
304 #endif
305 #ifndef HAVE_OPENAT
306 extern int openat __PR((int fd, const char *name, int oflag, ...));
307 #endif
308 
309 
310 #ifndef HAVE_GETTIMEOFDAY
311 #ifdef _SCHILY_TIME_H
312 extern int gettimeofday __PR((struct timeval *__tp, void *__tzp));
313 #endif
314 #endif
315 
316 #ifndef HAVE_FACCESSAT
317 extern int faccessat __PR((int fd, const char *name,
318  int amode, int flag));
319 #endif
320 #ifndef HAVE_FCHMODAT
321 extern int fchmodat __PR((int fd, const char *name,
322  mode_t mode, int flag));
323 #endif
324 #ifndef HAVE_LCHMOD
325 extern int lchmod __PR((const char *name, mode_t mode));
326 #endif
327 
328 #ifndef HAVE_FCHOWNAT
329 extern int fchownat __PR((int fd, const char *name,
330  uid_t owner, gid_t group, int flag));
331 #endif
332 
333 #ifndef HAVE_FDOPENDIR
334 #ifdef _SCHILY_DIRENT_H
335 extern DIR *fdopendir __PR((int fd));
336 #endif
337 #endif
338 
339 #ifdef _SCHILY_STAT_H
340 #ifndef HAVE_FSTATAT
341 extern int fstatat __PR((int fd, const char *name,
342  struct stat *sbuf, int flag));
343 #endif
344 #endif /* _SCHILY_STAT_H */
345 #ifdef _SCHILY_TIME_H
346 #ifndef HAVE_FUTIMENS
347 extern int futimens __PR((int fd,
348  const struct timespec __times[2]));
349 #endif
350 #ifndef HAVE_FUTIMESAT
351 extern int futimesat __PR((int fd, const char *name,
352  const struct timeval __times[2]));
353 #endif
354 #ifndef HAVE_LUTIMENS
355 extern int lutimens __PR((const char *name,
356  const struct timespec __times[2]));
357 #endif
358 #endif /* _SCHILY_TIME_H */
359 #ifndef HAVE_LINKAT
360 extern int linkat __PR((int fd1, const char *name1,
361  int fd2, const char *name2, int flag));
362 #endif
363 #ifndef HAVE_MKDIRAT
364 extern int mkdirat __PR((int fd, const char *name, mode_t mode));
365 #endif
366 #ifndef HAVE_MKFIFO
367 extern int mkfifo __PR((const char *name, mode_t mode));
368 #endif
369 #ifndef HAVE_MKFIFOAT
370 extern int mkfifoat __PR((int fd, const char *name, mode_t mode));
371 #endif
372 #ifndef HAVE_MKNODAT
373 extern int mknodat __PR((int fd, const char *name,
374  mode_t mode, dev_t dev));
375 #endif
376 #ifndef HAVE_READLINKAT
377 extern ssize_t readlinkat __PR((int fd, const char *name,
378  char *lbuf, size_t lbufsize));
379 #endif
380 #ifndef HAVE_RENAMEAT
381 extern int renameat __PR((int oldfd, const char *__old,
382  int newfd, const char *__new));
383 #endif
384 #ifndef HAVE_SYMLINKAT
385 extern int symlinkat __PR((const char *content,
386  int fd, const char *name));
387 #endif
388 #ifndef HAVE_UNLINKAT
389 extern int unlinkat __PR((int fd, const char *name, int flag));
390 #endif
391 #ifdef _SCHILY_TIME_H
392 #ifndef HAVE_UTIMENS
393 extern int utimens __PR((const char *name,
394  const struct timespec __times[2]));
395 #endif
396 #ifndef HAVE_UTIMENSAT
397 extern int utimensat __PR((int fd, const char *name,
398  const struct timespec __times[2],
399  int flag));
400 #endif
401 #endif /* _SCHILY_TIME_H */
402 
403 #ifdef __SUNOS4
404 /*
405  * Define prototypes for POSIX standard functions that are missing on SunOS-4.x
406  * to make compilation smooth.
407  */
408 #include <schily/sunos4_proto.h>
409 
410 #endif /* __SUNOS4 */
411 
412 #ifdef __cplusplus
413 }
414 #endif
415 
416 #endif /* _SCHILY_LIBPORT_H */
struct S2 s2
char * strncat(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:605
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
#define strcasecmp
Definition: fake.h:9
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int usleep(unsigned int useconds)
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
static void basename(LPCWSTR path, LPWSTR name)
Definition: profile.c:38
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
size_t strlcpy(char *d, const char *s, size_t bufsize)
Definition: compat.c:3
#define __printflike__(fmtarg, firstvararg)
Definition: ccomdefs.h:39
__cdecl __MINGW_NOTHROW char * dirname(char *)
#define snprintf
Definition: wintirpc.h:48
static int fd
Definition: io.c:51
EXPORT size_t strlcat(char *s1, const char *s2, size_t len)
Definition: strlcat.c:32
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
static WCHAR name1[]
Definition: record.c:34
long uid_t
Definition: various.h:8
#define gettimeofday(tv, tz)
Definition: adns_win32.h:159
_Check_return_ int __cdecl rename(_In_z_ const char *_OldFilename, _In_z_ const char *_NewFilename)
EXPORT int setuid(uid_t uid)
Definition: uid.c:47
UINT gid_t
Definition: types.h:89
_Check_return_ _CRTIMP char *__cdecl strdup(_In_opt_z_ const char *_Src)
content
Definition: atl_ax.c:993
Definition: dirent.h:39
#define strncasecmp
Definition: fake.h:10
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
wchar_t * wcsndup(wchar_t *name, size_t len)
Definition: getargs.c:36
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean flag
Definition: glfuncs.h:72
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
struct S1 s1
EXPORT int seteuid(uid_t uid)
Definition: uid.c:58
const GLubyte * c
Definition: glext.h:8905
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
EXPORT gid_t getegid()
Definition: gid.c:37
_Check_return_ _CRTIMP int __cdecl wcsncmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
int oflag
Definition: fci.h:172
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
long gethostid __PR((void))
Definition: stat.h:55
int ssize_t
Definition: rosdhcp.h:48
GLdouble s
Definition: gl.h:2039
GLenum GLsizei len
Definition: glext.h:6722
Definition: time.h:76
_Check_return_ _CRTIMP wchar_t *__cdecl wcsdup(_In_z_ const wchar_t *_Str)
size_t getpagesize(void)
_CRTIMP wchar_t *__cdecl wcsncat(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
EXPORT uid_t geteuid()
Definition: uid.c:37
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
EXPORT int setgid(gid_t gid)
Definition: gid.c:47
__kernel_dev_t dev_t
Definition: linux.h:197
__kernel_mode_t mode_t
Definition: linux.h:199
__kernel_time_t time_t
Definition: linux.h:252
char * strndup(char const *name, size_t len)
Definition: getargs.c:25
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
EXPORT int setegid(gid_t gid)
Definition: gid.c:58
uid_t getuid()
Definition: uid.c:27
GLboolean GLuint group
Definition: glext.h:11120
Definition: time.h:88
char * strchr(const char *String, int ch)
Definition: utclib.c:501
EXPORT gid_t getgid()
Definition: gid.c:27
Definition: name.c:36
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static WCHAR name2[]
Definition: record.c:35
EXPORT int eaccess(char *name, int mode) const
Definition: eaccess.c:35
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)