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 */ 417