| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: stdio.h,v 1.72 2008/08/04 17:08:49 matt Exp $ */ | | 1 | /* $NetBSD: stdio.h,v 1.73 2008/09/21 16:59:46 christos Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1990, 1993 | | 4 | * Copyright (c) 1990, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to Berkeley by | | 7 | * This code is derived from software contributed to Berkeley by |
8 | * Chris Torek. | | 8 | * Chris Torek. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -211,61 +211,70 @@ __END_DECLS | | | @@ -211,61 +211,70 @@ __END_DECLS |
211 | /* | | 211 | /* |
212 | * Functions defined in ANSI C standard. | | 212 | * Functions defined in ANSI C standard. |
213 | */ | | 213 | */ |
214 | __BEGIN_DECLS | | 214 | __BEGIN_DECLS |
215 | void clearerr(FILE *); | | 215 | void clearerr(FILE *); |
216 | int fclose(FILE *); | | 216 | int fclose(FILE *); |
217 | int feof(FILE *); | | 217 | int feof(FILE *); |
218 | int ferror(FILE *); | | 218 | int ferror(FILE *); |
219 | int fflush(FILE *); | | 219 | int fflush(FILE *); |
220 | int fgetc(FILE *); | | 220 | int fgetc(FILE *); |
221 | int fgetpos(FILE * __restrict, fpos_t * __restrict); | | 221 | int fgetpos(FILE * __restrict, fpos_t * __restrict); |
222 | char *fgets(char * __restrict, int, FILE * __restrict); | | 222 | char *fgets(char * __restrict, int, FILE * __restrict); |
223 | FILE *fopen(const char * __restrict , const char * __restrict); | | 223 | FILE *fopen(const char * __restrict , const char * __restrict); |
224 | int fprintf(FILE * __restrict , const char * __restrict, ...); | | 224 | int fprintf(FILE * __restrict , const char * __restrict, ...) |
| | | 225 | __attribute__((__format__(__printf__, 2, 3))); |
225 | int fputc(int, FILE *); | | 226 | int fputc(int, FILE *); |
226 | int fputs(const char * __restrict, FILE * __restrict); | | 227 | int fputs(const char * __restrict, FILE * __restrict); |
227 | size_t fread(void * __restrict, size_t, size_t, FILE * __restrict); | | 228 | size_t fread(void * __restrict, size_t, size_t, FILE * __restrict); |
228 | FILE *freopen(const char * __restrict, const char * __restrict, | | 229 | FILE *freopen(const char * __restrict, const char * __restrict, |
229 | FILE * __restrict); | | 230 | FILE * __restrict); |
230 | int fscanf(FILE * __restrict, const char * __restrict, ...); | | 231 | int fscanf(FILE * __restrict, const char * __restrict, ...) |
| | | 232 | __attribute__((__format__(__scanf__, 2, 3))); |
231 | int fseek(FILE *, long, int); | | 233 | int fseek(FILE *, long, int); |
232 | int fsetpos(FILE *, const fpos_t *); | | 234 | int fsetpos(FILE *, const fpos_t *); |
233 | long ftell(FILE *); | | 235 | long ftell(FILE *); |
234 | size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict); | | 236 | size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict); |
235 | int getc(FILE *); | | 237 | int getc(FILE *); |
236 | int getchar(void); | | 238 | int getchar(void); |
237 | void perror(const char *); | | 239 | void perror(const char *); |
238 | int printf(const char * __restrict, ...); | | 240 | int printf(const char * __restrict, ...) |
| | | 241 | __attribute__((__format__(__printf__, 1, 2))); |
239 | int putc(int, FILE *); | | 242 | int putc(int, FILE *); |
240 | int putchar(int); | | 243 | int putchar(int); |
241 | int puts(const char *); | | 244 | int puts(const char *); |
242 | int remove(const char *); | | 245 | int remove(const char *); |
243 | void rewind(FILE *); | | 246 | void rewind(FILE *); |
244 | int scanf(const char * __restrict, ...); | | 247 | int scanf(const char * __restrict, ...) |
| | | 248 | __attribute__((__format__(__scanf__, 1, 2))); |
245 | void setbuf(FILE * __restrict, char * __restrict); | | 249 | void setbuf(FILE * __restrict, char * __restrict); |
246 | int setvbuf(FILE * __restrict, char * __restrict, int, size_t); | | 250 | int setvbuf(FILE * __restrict, char * __restrict, int, size_t); |
247 | int sscanf(const char * __restrict, const char * __restrict, ...); | | 251 | int sscanf(const char * __restrict, const char * __restrict, ...) |
| | | 252 | __attribute__((__format__(__scanf__, 2, 3))); |
248 | FILE *tmpfile(void); | | 253 | FILE *tmpfile(void); |
249 | int ungetc(int, FILE *); | | 254 | int ungetc(int, FILE *); |
250 | int vfprintf(FILE * __restrict, const char * __restrict, _BSD_VA_LIST_); | | 255 | int vfprintf(FILE * __restrict, const char * __restrict, _BSD_VA_LIST_) |
251 | int vprintf(const char * __restrict, _BSD_VA_LIST_); | | 256 | __attribute__((__format__(__printf__, 2, 0))); |
| | | 257 | int vprintf(const char * __restrict, _BSD_VA_LIST_) |
| | | 258 | __attribute__((__format__(__printf__, 1, 0))); |
252 | | | 259 | |
253 | #ifndef __AUDIT__ | | 260 | #ifndef __AUDIT__ |
254 | char *gets(char *); | | 261 | char *gets(char *); |
255 | int sprintf(char * __restrict, const char * __restrict, ...); | | 262 | int sprintf(char * __restrict, const char * __restrict, ...) |
| | | 263 | __attribute__((__format__(__printf__, 2, 3))); |
256 | char *tmpnam(char *); | | 264 | char *tmpnam(char *); |
257 | int vsprintf(char * __restrict, const char * __restrict, | | 265 | int vsprintf(char * __restrict, const char * __restrict, |
258 | _BSD_VA_LIST_); | | 266 | _BSD_VA_LIST_) |
| | | 267 | __attribute__((__format__(__printf__, 2, 0))); |
259 | #endif | | 268 | #endif |
260 | | | 269 | |
261 | #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) | | 270 | #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) |
262 | int rename (const char *, const char *) __RENAME(__posix_rename); | | 271 | int rename (const char *, const char *) __RENAME(__posix_rename); |
263 | #else | | 272 | #else |
264 | int rename (const char *, const char *); | | 273 | int rename (const char *, const char *); |
265 | #endif | | 274 | #endif |
266 | __END_DECLS | | 275 | __END_DECLS |
267 | | | 276 | |
268 | /* | | 277 | /* |
269 | * IEEE Std 1003.1-90 | | 278 | * IEEE Std 1003.1-90 |
270 | */ | | 279 | */ |
271 | #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ | | 280 | #if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ |
| @@ -312,30 +321,30 @@ FILE *popen(const char *, const char *); | | | @@ -312,30 +321,30 @@ FILE *popen(const char *, const char *); |
312 | __END_DECLS | | 321 | __END_DECLS |
313 | #endif | | 322 | #endif |
314 | | | 323 | |
315 | /* | | 324 | /* |
316 | * Functions defined in ISO XPG4.2, ISO C99, POSIX 1003.1-2001 or later. | | 325 | * Functions defined in ISO XPG4.2, ISO C99, POSIX 1003.1-2001 or later. |
317 | */ | | 326 | */ |
318 | #if ((__STDC_VERSION__ - 0) >= 199901L) || \ | | 327 | #if ((__STDC_VERSION__ - 0) >= 199901L) || \ |
319 | ((_POSIX_C_SOURCE - 0) >= 200112L) || \ | | 328 | ((_POSIX_C_SOURCE - 0) >= 200112L) || \ |
320 | (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ | | 329 | (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ |
321 | ((_XOPEN_SOURCE - 0) >= 500) || \ | | 330 | ((_XOPEN_SOURCE - 0) >= 500) || \ |
322 | defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) | | 331 | defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) |
323 | __BEGIN_DECLS | | 332 | __BEGIN_DECLS |
324 | int snprintf(char * __restrict, size_t, const char * __restrict, ...) | | 333 | int snprintf(char * __restrict, size_t, const char * __restrict, ...) |
325 | __attribute__((__format__(__printf__, 3, 4))); | | 334 | __attribute__((__format__(__printf__, 3, 4))); |
326 | int vsnprintf(char * __restrict, size_t, const char * __restrict, | | 335 | int vsnprintf(char * __restrict, size_t, const char * __restrict, |
327 | _BSD_VA_LIST_) | | 336 | _BSD_VA_LIST_) |
328 | __attribute__((__format__(__printf__, 3, 0))); | | 337 | __attribute__((__format__(__printf__, 3, 0))); |
329 | __END_DECLS | | 338 | __END_DECLS |
330 | #endif | | 339 | #endif |
331 | | | 340 | |
332 | /* | | 341 | /* |
333 | * Functions defined in XPG4.2. | | 342 | * Functions defined in XPG4.2. |
334 | */ | | 343 | */ |
335 | #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) | | 344 | #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) |
336 | __BEGIN_DECLS | | 345 | __BEGIN_DECLS |
337 | int getw(FILE *); | | 346 | int getw(FILE *); |
338 | int putw(int, FILE *); | | 347 | int putw(int, FILE *); |
339 | | | 348 | |
340 | #ifndef __AUDIT__ | | 349 | #ifndef __AUDIT__ |
341 | char *tempnam(const char *, const char *); | | 350 | char *tempnam(const char *, const char *); |
| @@ -356,59 +365,59 @@ typedef __off_t off_t; | | | @@ -356,59 +365,59 @@ typedef __off_t off_t; |
356 | __BEGIN_DECLS | | 365 | __BEGIN_DECLS |
357 | int fseeko(FILE *, off_t, int); | | 366 | int fseeko(FILE *, off_t, int); |
358 | off_t ftello(FILE *); | | 367 | off_t ftello(FILE *); |
359 | __END_DECLS | | 368 | __END_DECLS |
360 | #endif /* _XOPEN_SOURCE >= 500 || _LARGEFILE_SOURCE || _NETBSD_SOURCE */ | | 369 | #endif /* _XOPEN_SOURCE >= 500 || _LARGEFILE_SOURCE || _NETBSD_SOURCE */ |
361 | | | 370 | |
362 | /* | | 371 | /* |
363 | * Functions defined in ISO C99. Still put under _NETBSD_SOURCE due to | | 372 | * Functions defined in ISO C99. Still put under _NETBSD_SOURCE due to |
364 | * backward compatible. | | 373 | * backward compatible. |
365 | */ | | 374 | */ |
366 | #if defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) | | 375 | #if defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) |
367 | __BEGIN_DECLS | | 376 | __BEGIN_DECLS |
368 | int vscanf(const char * __restrict, _BSD_VA_LIST_) | | 377 | int vscanf(const char * __restrict, _BSD_VA_LIST_) |
369 | __attribute__((__format__(__scanf__, 1, 0))); | | 378 | __attribute__((__format__(__scanf__, 1, 0))); |
370 | int vfscanf(FILE * __restrict, const char * __restrict, _BSD_VA_LIST_) | | 379 | int vfscanf(FILE * __restrict, const char * __restrict, _BSD_VA_LIST_) |
371 | __attribute__((__format__(__scanf__, 2, 0))); | | 380 | __attribute__((__format__(__scanf__, 2, 0))); |
372 | int vsscanf(const char * __restrict, const char * __restrict, | | 381 | int vsscanf(const char * __restrict, const char * __restrict, |
373 | _BSD_VA_LIST_) | | 382 | _BSD_VA_LIST_) |
374 | __attribute__((__format__(__scanf__, 2, 0))); | | 383 | __attribute__((__format__(__scanf__, 2, 0))); |
375 | __END_DECLS | | 384 | __END_DECLS |
376 | #endif /* _ISOC99_SOURCE || _NETBSD_SOURCE */ | | 385 | #endif /* _ISOC99_SOURCE || _NETBSD_SOURCE */ |
377 | | | 386 | |
378 | /* | | 387 | /* |
379 | * Routines that are purely local. | | 388 | * Routines that are purely local. |
380 | */ | | 389 | */ |
381 | #if defined(_NETBSD_SOURCE) | | 390 | #if defined(_NETBSD_SOURCE) |
382 | | | 391 | |
383 | #define FPARSELN_UNESCESC 0x01 | | 392 | #define FPARSELN_UNESCESC 0x01 |
384 | #define FPARSELN_UNESCCONT 0x02 | | 393 | #define FPARSELN_UNESCCONT 0x02 |
385 | #define FPARSELN_UNESCCOMM 0x04 | | 394 | #define FPARSELN_UNESCCOMM 0x04 |
386 | #define FPARSELN_UNESCREST 0x08 | | 395 | #define FPARSELN_UNESCREST 0x08 |
387 | #define FPARSELN_UNESCALL 0x0f | | 396 | #define FPARSELN_UNESCALL 0x0f |
388 | | | 397 | |
389 | __BEGIN_DECLS | | 398 | __BEGIN_DECLS |
390 | int asprintf(char ** __restrict, const char * __restrict, ...) | | 399 | int asprintf(char ** __restrict, const char * __restrict, ...) |
391 | __attribute__((__format__(__printf__, 2, 3))); | | 400 | __attribute__((__format__(__printf__, 2, 3))); |
392 | char *fgetln(FILE * __restrict, size_t * __restrict); | | 401 | char *fgetln(FILE * __restrict, size_t * __restrict); |
393 | char *fparseln(FILE *, size_t *, size_t *, const char[3], int); | | 402 | char *fparseln(FILE *, size_t *, size_t *, const char[3], int); |
394 | int fpurge(FILE *); | | 403 | int fpurge(FILE *); |
395 | void setbuffer(FILE *, char *, int); | | 404 | void setbuffer(FILE *, char *, int); |
396 | int setlinebuf(FILE *); | | 405 | int setlinebuf(FILE *); |
397 | int vasprintf(char ** __restrict, const char * __restrict, | | 406 | int vasprintf(char ** __restrict, const char * __restrict, |
398 | _BSD_VA_LIST_) | | 407 | _BSD_VA_LIST_) |
399 | __attribute__((__format__(__printf__, 2, 0))); | | 408 | __attribute__((__format__(__printf__, 2, 0))); |
400 | const char *fmtcheck(const char *, const char *) | | 409 | const char *fmtcheck(const char *, const char *) |
401 | __attribute__((__format_arg__(2))); | | 410 | __attribute__((__format_arg__(2))); |
402 | __END_DECLS | | 411 | __END_DECLS |
403 | | | 412 | |
404 | /* | | 413 | /* |
405 | * Stdio function-access interface. | | 414 | * Stdio function-access interface. |
406 | */ | | 415 | */ |
407 | __BEGIN_DECLS | | 416 | __BEGIN_DECLS |
408 | FILE *funopen(const void *, | | 417 | FILE *funopen(const void *, |
409 | int (*)(void *, char *, int), | | 418 | int (*)(void *, char *, int), |
410 | int (*)(void *, const char *, int), | | 419 | int (*)(void *, const char *, int), |
411 | fpos_t (*)(void *, fpos_t, int), | | 420 | fpos_t (*)(void *, fpos_t, int), |
412 | int (*)(void *)); | | 421 | int (*)(void *)); |
413 | __END_DECLS | | 422 | __END_DECLS |
414 | #define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0) | | 423 | #define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0) |