1 | /* |
---|
2 | * Copyright (c) 1990 The Regents of the University of California. |
---|
3 | * All rights reserved. |
---|
4 | * |
---|
5 | * Redistribution and use in source and binary forms are permitted |
---|
6 | * provided that the above copyright notice and this paragraph are |
---|
7 | * duplicated in all such forms and that any documentation, |
---|
8 | * advertising materials, and other materials related to such |
---|
9 | * distribution and use acknowledge that the software was developed |
---|
10 | * by the University of California, Berkeley. The name of the |
---|
11 | * University may not be used to endorse or promote products derived |
---|
12 | * from this software without specific prior written permission. |
---|
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR |
---|
14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED |
---|
15 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
---|
16 | */ |
---|
17 | |
---|
18 | /* |
---|
19 | FUNCTION |
---|
20 | <<clearerr>>, <<clearerr_unlocked>>---clear file or stream error indicator |
---|
21 | |
---|
22 | INDEX |
---|
23 | clearerr |
---|
24 | INDEX |
---|
25 | clearerr_unlocked |
---|
26 | |
---|
27 | SYNOPSIS |
---|
28 | #include <stdio.h> |
---|
29 | void clearerr(FILE *<[fp]>); |
---|
30 | |
---|
31 | #define _BSD_SOURCE |
---|
32 | #include <stdio.h> |
---|
33 | void clearerr_unlocked(FILE *<[fp]>); |
---|
34 | |
---|
35 | DESCRIPTION |
---|
36 | The <<stdio>> functions maintain an error indicator with each file |
---|
37 | pointer <[fp]>, to record whether any read or write errors have |
---|
38 | occurred on the associated file or stream. Similarly, it maintains an |
---|
39 | end-of-file indicator to record whether there is no more data in the |
---|
40 | file. |
---|
41 | |
---|
42 | Use <<clearerr>> to reset both of these indicators. |
---|
43 | |
---|
44 | See <<ferror>> and <<feof>> to query the two indicators. |
---|
45 | |
---|
46 | <<clearerr_unlocked>> is a non-thread-safe version of <<clearerr>>. |
---|
47 | <<clearerr_unlocked>> may only safely be used within a scope |
---|
48 | protected by flockfile() (or ftrylockfile()) and funlockfile(). This |
---|
49 | function may safely be used in a multi-threaded program if and only |
---|
50 | if they are called while the invoking thread owns the (FILE *) |
---|
51 | object, as is the case after a successful call to the flockfile() or |
---|
52 | ftrylockfile() functions. If threads are disabled, then |
---|
53 | <<clearerr_unlocked>> is equivalent to <<clearerr>>. |
---|
54 | |
---|
55 | RETURNS |
---|
56 | <<clearerr>> does not return a result. |
---|
57 | |
---|
58 | PORTABILITY |
---|
59 | ANSI C requires <<clearerr>>. |
---|
60 | |
---|
61 | <<clearerr_unlocked>> is a BSD extension also provided by GNU libc. |
---|
62 | |
---|
63 | No supporting OS subroutines are required. |
---|
64 | */ |
---|
65 | |
---|
66 | #include <_ansi.h> |
---|
67 | #include <stdio.h> |
---|
68 | #include "local.h" |
---|
69 | |
---|
70 | /* A subroutine version of the macro clearerr. */ |
---|
71 | |
---|
72 | #undef clearerr |
---|
73 | |
---|
74 | void |
---|
75 | clearerr (FILE * fp) |
---|
76 | { |
---|
77 | CHECK_INIT(_REENT, fp); |
---|
78 | _newlib_flockfile_start (fp); |
---|
79 | __sclearerr (fp); |
---|
80 | _newlib_flockfile_end (fp); |
---|
81 | } |
---|