Print this page
oops!
getdelim.3c should list p1003.1-2008.
more ifdef cleanups, expose getline and getdelim


 198 #if !defined(_XPG6) || defined(__EXTENSIONS__)
 199 #define L_cuserid       9
 200 #endif
 201 
 202 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
 203 
 204 #if defined(__EXTENSIONS__) || \
 205         (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
 206         defined(_XOPEN_SOURCE)
 207 
 208 #define P_tmpdir        "/var/tmp/"
 209 #endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) ... */
 210 
 211 #ifndef _STDIO_ALLOCATE
 212 extern unsigned char     _sibuf[], _sobuf[];
 213 #endif
 214 
 215 /* large file compilation environment setup */
 216 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
 217 #if !defined(__PRAGMA_REDEFINE_EXTNAME)
 218 #if defined(__STDC__)
 219 extern FILE     *fopen64(const char *, const char *);
 220 extern FILE     *freopen64(const char *, const char *, FILE *);
 221 extern FILE     *tmpfile64(void);
 222 extern int      fgetpos64(FILE *, fpos_t *);
 223 extern int      fsetpos64(FILE *, const fpos_t *);
 224 #else   /* defined(__STDC__) */
 225 extern FILE     *fopen64();
 226 extern FILE     *freopen64();
 227 extern FILE     *tmpfile64();
 228 extern int      fgetpos64();
 229 extern int      fsetpos64();
 230 #endif  /* defined(__STDC__) */
 231 #define fopen                   fopen64
 232 #define freopen                 freopen64
 233 #define tmpfile                 tmpfile64
 234 #define fgetpos                 fgetpos64
 235 #define fsetpos                 fsetpos64
 236 #ifdef  _LARGEFILE_SOURCE
 237 #define fseeko                  fseeko64
 238 #define ftello                  ftello64
 239 #endif
 240 #endif  /* !__PRAGMA_REDEFINE_EXTNAME */
 241 #endif  /* !_LP64 && _FILE_OFFSET_BITS == 64 */
 242 
 243 #ifndef _LP64
 244 extern unsigned char    *_bufendtab[];
 245 extern FILE             *_lastbuf;
 246 #endif
 247 
 248 /* In the LP64 compilation environment, all APIs are already large file */
 249 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
 250 #if !defined(__PRAGMA_REDEFINE_EXTNAME)


 252 #define freopen64       freopen
 253 #define tmpfile64       tmpfile
 254 #define fgetpos64       fgetpos
 255 #define fsetpos64       fsetpos
 256 #ifdef  _LARGEFILE_SOURCE
 257 #define fseeko64        fseeko
 258 #define ftello64        ftello
 259 #endif
 260 #endif  /* !__PRAGMA_REDEFINE_EXTNAME */
 261 #endif  /* _LP64 && _LARGEFILE64_SOURCE */
 262 
 263 #ifndef _SSIZE_T
 264 #define _SSIZE_T
 265 #if defined(_LP64) || defined(_I32LPx)
 266 typedef long    ssize_t;        /* size of something in bytes or -1 */
 267 #else
 268 typedef int     ssize_t;        /* (historical version) */
 269 #endif
 270 #endif  /* !_SSIZE_T */
 271 
 272 #if defined(__STDC__)
 273 
 274 #if defined(__EXTENSIONS__) || \
 275         (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
 276         defined(_REENTRANT)
 277 extern char     *tmpnam_r(char *);
 278 #endif
 279 
 280 #if defined(__EXTENSIONS__) || \
 281         (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
 282 extern int fcloseall(void);
 283 extern void setbuffer(FILE *, char *, size_t);
 284 extern int setlinebuf(FILE *);
 285 /* PRINTFLIKE2 */
 286 extern int asprintf(char **, const char *, ...);
 287 /* PRINTFLIKE2 */
 288 extern int vasprintf(char **, const char *, __va_list);
 289 #endif
 290 
 291 #if defined(__EXTENSIONS__) || \
 292         (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
 293         /* || defined(_XPG7) */
 294 extern ssize_t getdelim(char **_RESTRICT_KYWD, size_t *_RESTRICT_KYWD,
 295         int, FILE *_RESTRICT_KYWD);
 296 extern ssize_t getline(char **_RESTRICT_KYWD, size_t *_RESTRICT_KYWD,
 297         FILE *_RESTRICT_KYWD);
 298 #endif  /* __EXTENSIONS__ ... */
 299 
 300 /*
 301  * The following are known to POSIX and XOPEN, but not to ANSI-C.
 302  */
 303 #if defined(__EXTENSIONS__) || \
 304         !defined(_STRICT_STDC) || defined(__XOPEN_OR_POSIX)
 305 
 306 extern FILE     *fdopen(int, const char *);
 307 extern char     *ctermid(char *);
 308 extern int      fileno(FILE *);

 309 
 310 #endif  /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
 311 
 312 /*
 313  * The following are known to POSIX.1c, but not to ANSI-C or XOPEN.
 314  */
 315 #if defined(__EXTENSIONS__) || defined(_REENTRANT) || \
 316         (_POSIX_C_SOURCE - 0 >= 199506L)
 317 extern void     flockfile(FILE *);
 318 extern int      ftrylockfile(FILE *);
 319 extern void     funlockfile(FILE *);
 320 extern int      getc_unlocked(FILE *);
 321 extern int      getchar_unlocked(void);
 322 extern int      putc_unlocked(int, FILE *);
 323 extern int      putchar_unlocked(int);

 324 
 325 #endif  /* defined(__EXTENSIONS__) || defined(_REENTRANT).. */
 326 
 327 /*
 328  * The following are known to XOPEN, but not to ANSI-C or POSIX.
 329  */
 330 #if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
 331         defined(_XOPEN_SOURCE)
 332 extern FILE     *popen(const char *, const char *);
 333 extern char     *tempnam(const char *, const char *);
 334 extern int      pclose(FILE *);

 335 #if !defined(_XOPEN_SOURCE)

 336 extern int      getsubopt(char **, char *const *, char **);
 337 #endif /* !defined(_XOPEN_SOURCE) */
 338 
 339 /* Marked LEGACY in SUSv2 and removed in SUSv3 */
 340 #if !defined(_XPG6) || defined(__EXTENSIONS__)
 341 extern char     *cuserid(char *);
 342 extern int      getopt(int, char *const *, const char *);
 343 extern char     *optarg;
 344 extern int      optind, opterr, optopt;
 345 extern int      getw(FILE *);
 346 extern int      putw(int, FILE *);
 347 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
 348 
 349 #endif  /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
 350 
 351 /*
 352  * The following are defined as part of the Large File Summit interfaces.
 353  */
 354 #if defined(_LARGEFILE_SOURCE) || defined(_XPG5)
 355 extern int      fseeko(FILE *, off_t, int);
 356 extern off_t    ftello(FILE *);
 357 #endif
 358 
 359 /*
 360  * The following are defined as part of the transitional Large File Summit
 361  * interfaces.
 362  */
 363 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
 364             !defined(__PRAGMA_REDEFINE_EXTNAME))
 365 extern FILE     *fopen64(const char *, const char *);
 366 extern FILE     *freopen64(const char *, const char *, FILE *);
 367 extern FILE     *tmpfile64(void);
 368 extern int      fgetpos64(FILE *, fpos64_t *);
 369 extern int      fsetpos64(FILE *, const fpos64_t *);
 370 extern int      fseeko64(FILE *, off64_t, int);
 371 extern off64_t  ftello64(FILE *);
 372 #endif
 373 
 374 #else   /* !defined __STDC__ */
 375 
 376 #ifndef _LP64
 377 #define _bufend(p)      ((fileno(p) < _NFILE) ? _bufendtab[fileno(p)] : \
 378                         (unsigned char *)_realbufend(p))
 379 #define _bufsiz(p)      (_bufend(p) - (p)->_base)
 380 #endif  /*      _LP64   */
 381 
 382 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) || \
 383         defined(_REENTRANT)
 384 extern char     *tmpnam_r();
 385 #endif
 386 
 387 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
 388 extern int fcloseall();
 389 extern void setbuffer();
 390 extern int setlinebuf();
 391 extern int asprintf();
 392 extern int vasprintf();
 393 #endif
 394 
 395 #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
 396         /* || defined(_XPG7) */
 397 extern ssize_t getdelim();
 398 extern ssize_t getline();
 399 #endif  /* __EXTENSIONS__ ... */
 400 
 401 #if defined(__EXTENSIONS__) || defined(__XOPEN_OR_POSIX)
 402 extern FILE     *fdopen();
 403 extern char     *ctermid();
 404 extern int      fileno();
 405 #endif  /* defined(__EXTENSIONS__) || defined(__XOPEN_OR_POSIX) */
 406 
 407 #if defined(__EXTENSIONS__) || defined(_REENTRANT) || \
 408             (_POSIX_C_SOURCE - 0 >= 199506L)
 409 extern void     flockfile();
 410 extern int      ftrylockfile();
 411 extern void     funlockfile();
 412 extern int      getc_unlocked();
 413 extern int      getchar_unlocked();
 414 extern int      putc_unlocked();
 415 extern int      putchar_unlocked();
 416 #endif  /* defined(__EXTENSIONS__) || defined(_REENTRANT).. */
 417 
 418 #if defined(__EXTENSIONS__) || defined(_XOPEN_SOURCE)
 419 extern FILE     *popen();
 420 extern char     *tempnam();
 421 extern int      pclose();
 422 
 423 #if !defined(_XOPEN_SOURCE)
 424 extern int      getsubopt();
 425 #endif /* !defined(_XOPEN_SOURCE) */
 426 
 427 #if !defined(_XPG6) || defined(__EXTENSIONS__)
 428 extern char     *cuserid();
 429 extern int      getopt();
 430 extern char     *optarg;
 431 extern int      optind, opterr, optopt;
 432 extern int      getw();
 433 extern int      putw();
 434 #endif /* !defined(_XPG6) || defined(__EXTENSIONS__) */
 435 
 436 #endif  /* defined(__EXTENSIONS__) || defined(_XOPEN_SOURCE) */
 437 
 438 #if defined(_LARGEFILE_SOURCE) || defined(_XPG5)
 439 extern int      fseeko();
 440 extern off_t    ftello();
 441 #endif
 442 
 443 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
 444             !defined(__PRAGMA_REDEFINE_EXTNAME))
 445 extern FILE     *fopen64();
 446 extern FILE     *freopen64();
 447 extern FILE     *tmpfile64();
 448 extern int      fgetpos64();
 449 extern int      fsetpos64();
 450 extern int      fseeko64();
 451 extern off64_t  ftello64();
 452 #endif
 453 
 454 #endif  /* __STDC__ */
 455 
 456 #if !defined(__lint)
 457 
 458 #if defined(__EXTENSIONS__) || defined(_REENTRANT) || \
 459             (_POSIX_C_SOURCE - 0 >= 199506L)
 460 #ifndef _LP64
 461 #ifdef  __STDC__
 462 #define getc_unlocked(p)        (--(p)->_cnt < 0 \
 463                                         ? __filbuf(p) \
 464                                         : (int)*(p)->_ptr++)
 465 #define putc_unlocked(x, p)     (--(p)->_cnt < 0 \
 466                                         ? __flsbuf((x), (p)) \
 467                                         : (int)(*(p)->_ptr++ = \
 468                                         (unsigned char) (x)))
 469 #else
 470 #define getc_unlocked(p)        (--(p)->_cnt < 0 \
 471                                         ? _filbuf(p) \
 472                                         : (int)*(p)->_ptr++)
 473 #define putc_unlocked(x, p)     (--(p)->_cnt < 0 \
 474                                         ? _flsbuf((x), (p)) \
 475                                         : (int)(*(p)->_ptr++ = \
 476                                         (unsigned char) (x)))
 477 #endif  /* __STDC__ */
 478 #endif  /* _LP64 */
 479 #define getchar_unlocked()      getc_unlocked(stdin)
 480 #define putchar_unlocked(x)     putc_unlocked((x), stdout)
 481 #endif  /* defined(__EXTENSIONS__) || defined(_REENTRANT).. */
 482 
 483 #endif  /* !defined(__lint) */
 484 
 485 #ifdef  __cplusplus
 486 }
 487 #endif
 488 
 489 #endif  /* _STDIO_H */


 198 #if !defined(_XPG6) || defined(__EXTENSIONS__)
 199 #define L_cuserid       9
 200 #endif
 201 
 202 #endif /* defined(__EXTENSIONS__) || !defined(_STRICT_STDC) ... */
 203 
 204 #if defined(__EXTENSIONS__) || \
 205         (!defined(_STRICT_STDC) && !defined(_POSIX_C_SOURCE)) || \
 206         defined(_XOPEN_SOURCE)
 207 
 208 #define P_tmpdir        "/var/tmp/"
 209 #endif /* defined(__EXTENSIONS__) || (!defined(_STRICT_STDC) ... */
 210 
 211 #ifndef _STDIO_ALLOCATE
 212 extern unsigned char     _sibuf[], _sobuf[];
 213 #endif
 214 
 215 /* large file compilation environment setup */
 216 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
 217 #if !defined(__PRAGMA_REDEFINE_EXTNAME)

 218 extern FILE     *fopen64(const char *, const char *);
 219 extern FILE     *freopen64(const char *, const char *, FILE *);
 220 extern FILE     *tmpfile64(void);
 221 extern int      fgetpos64(FILE *, fpos_t *);
 222 extern int      fsetpos64(FILE *, const fpos_t *);







 223 #define fopen                   fopen64
 224 #define freopen                 freopen64
 225 #define tmpfile                 tmpfile64
 226 #define fgetpos                 fgetpos64
 227 #define fsetpos                 fsetpos64
 228 #ifdef  _LARGEFILE_SOURCE
 229 #define fseeko                  fseeko64
 230 #define ftello                  ftello64
 231 #endif
 232 #endif  /* !__PRAGMA_REDEFINE_EXTNAME */
 233 #endif  /* !_LP64 && _FILE_OFFSET_BITS == 64 */
 234 
 235 #ifndef _LP64
 236 extern unsigned char    *_bufendtab[];
 237 extern FILE             *_lastbuf;
 238 #endif
 239 
 240 /* In the LP64 compilation environment, all APIs are already large file */
 241 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
 242 #if !defined(__PRAGMA_REDEFINE_EXTNAME)


 244 #define freopen64       freopen
 245 #define tmpfile64       tmpfile
 246 #define fgetpos64       fgetpos
 247 #define fsetpos64       fsetpos
 248 #ifdef  _LARGEFILE_SOURCE
 249 #define fseeko64        fseeko
 250 #define ftello64        ftello
 251 #endif
 252 #endif  /* !__PRAGMA_REDEFINE_EXTNAME */
 253 #endif  /* _LP64 && _LARGEFILE64_SOURCE */
 254 
 255 #ifndef _SSIZE_T
 256 #define _SSIZE_T
 257 #if defined(_LP64) || defined(_I32LPx)
 258 typedef long    ssize_t;        /* size of something in bytes or -1 */
 259 #else
 260 typedef int     ssize_t;        /* (historical version) */
 261 #endif
 262 #endif  /* !_SSIZE_T */
 263 
 264 #if defined(_REENTRANT) || !defined(_STRICT_SYMBOLS)




 265 extern char     *tmpnam_r(char *);
 266 #endif
 267 
 268 #if !defined(_STRICT_SYMBOLS)

 269 extern int fcloseall(void);
 270 extern void setbuffer(FILE *, char *, size_t);
 271 extern int setlinebuf(FILE *);
 272 /* PRINTFLIKE2 */
 273 extern int asprintf(char **, const char *, ...);
 274 /* PRINTFLIKE2 */
 275 extern int vasprintf(char **, const char *, __va_list);
 276 #endif
 277 
 278 #if defined(_XPG7) || !defined(_STRICT_SYMBOLS)


 279 extern ssize_t getdelim(char **_RESTRICT_KYWD, size_t *_RESTRICT_KYWD,
 280         int, FILE *_RESTRICT_KYWD);
 281 extern ssize_t getline(char **_RESTRICT_KYWD, size_t *_RESTRICT_KYWD,
 282         FILE *_RESTRICT_KYWD);
 283 #endif
 284 
 285 /*
 286  * The following are known to POSIX and XOPEN, but not to ANSI-C.
 287  */
 288 #if defined(__XOPEN_OR_POSIX) || !defined(_STRICT_SYMBOLS)


 289 extern FILE     *fdopen(int, const char *);
 290 extern char     *ctermid(char *);
 291 extern int      fileno(FILE *);
 292 #endif
 293 


 294 /*
 295  * The following are known to POSIX.1c, but not to ANSI-C or older XOPEN.
 296  */
 297 #if defined(_REENTRANT) || !defined(_STRICT_SYMBOLS) || \
 298         (_POSIX_C_SOURCE - 0 >= 199506L)
 299 extern void     flockfile(FILE *);
 300 extern int      ftrylockfile(FILE *);
 301 extern void     funlockfile(FILE *);
 302 extern int      getc_unlocked(FILE *);
 303 extern int      getchar_unlocked(void);
 304 extern int      putc_unlocked(int, FILE *);
 305 extern int      putchar_unlocked(int);
 306 #endif
 307 


 308 /*
 309  * The following are known to XOPEN, but not to ANSI-C or POSIX.
 310  */
 311 #if defined(_XOPEN_SOURCE) || !defined(_STRICT_SYMBOLS)
 312 
 313 extern FILE     *popen(const char *, const char *);
 314 extern char     *tempnam(const char *, const char *);
 315 extern int      pclose(FILE *);
 316 
 317 #if !defined(_XOPEN_SOURCE)
 318 /* XOPEN puts this in stdlib.h */
 319 extern int      getsubopt(char **, char *const *, char **);
 320 #endif
 321 
 322 /* Marked LEGACY in SUSv2 and removed in SUSv3 */
 323 #if !defined(_STRICT_XPG6)
 324 extern char     *cuserid(char *);
 325 extern int      getopt(int, char *const *, const char *);
 326 extern char     *optarg;
 327 extern int      optind, opterr, optopt;
 328 extern int      getw(FILE *);
 329 extern int      putw(int, FILE *);
 330 #endif
 331 
 332 #endif  /* defined(_XOPEN_SOURCE) || !defined(_STRICT_SYMBOLS) */
 333 
 334 /*
 335  * The following are defined as part of the Large File Summit interfaces.
 336  */
 337 #if defined(_LARGEFILE_SOURCE) || defined(_XPG5)
 338 extern int      fseeko(FILE *, off_t, int);
 339 extern off_t    ftello(FILE *);
 340 #endif
 341 
 342 /*
 343  * The following are defined as part of the transitional Large File Summit
 344  * interfaces.
 345  */
 346 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
 347             !defined(__PRAGMA_REDEFINE_EXTNAME))
 348 extern FILE     *fopen64(const char *, const char *);
 349 extern FILE     *freopen64(const char *, const char *, FILE *);
 350 extern FILE     *tmpfile64(void);
 351 extern int      fgetpos64(FILE *, fpos64_t *);
 352 extern int      fsetpos64(FILE *, const fpos64_t *);
 353 extern int      fseeko64(FILE *, off64_t, int);
 354 extern off64_t  ftello64(FILE *);
 355 #endif
 356 


















































































 357 #if !defined(__lint)
 358 
 359 #if defined(_REENTRANT) || !defined(_STRICT_SYMBOLS) || \
 360             (_POSIX_C_SOURCE - 0 >= 199506L)
 361 #ifndef _LP64

 362 #define getc_unlocked(p)        (--(p)->_cnt < 0 \
 363                                         ? __filbuf(p) \
 364                                         : (int)*(p)->_ptr++)
 365 #define putc_unlocked(x, p)     (--(p)->_cnt < 0 \
 366                                         ? __flsbuf((x), (p)) \
 367                                         : (int)(*(p)->_ptr++ = \
 368                                         (unsigned char) (x)))









 369 #endif  /* _LP64 */
 370 #define getchar_unlocked()      getc_unlocked(stdin)
 371 #define putchar_unlocked(x)     putc_unlocked((x), stdout)
 372 #endif  /* defined(_REENTRANT).. */
 373 
 374 #endif  /* !defined(__lint) */
 375 
 376 #ifdef  __cplusplus
 377 }
 378 #endif
 379 
 380 #endif  /* _STDIO_H */