Rev 4921 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4349 | Serge | 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 |
||
6099 | serge | 20 | < |
4349 | Serge | 21 | |
22 | INDEX |
||
23 | fputc |
||
24 | INDEX |
||
6099 | serge | 25 | fputc_unlocked |
26 | INDEX |
||
4349 | Serge | 27 | _fputc_r |
6099 | serge | 28 | INDEX |
29 | _fputc_unlocked_r |
||
4349 | Serge | 30 | |
31 | ANSI_SYNOPSIS |
||
32 | #include |
||
33 | int fputc(int <[ch]>, FILE *<[fp]>); |
||
34 | |||
6099 | serge | 35 | #define _BSD_SOURCE |
4349 | Serge | 36 | #include |
6099 | serge | 37 | int fputc_unlocked(int <[ch]>, FILE *<[fp]>); |
38 | |||
39 | #include |
||
4349 | Serge | 40 | int _fputc_r(struct _rent *<[ptr]>, int <[ch]>, FILE *<[fp]>); |
41 | |||
6099 | serge | 42 | #include |
43 | int _fputc_unlocked_r(struct _rent *<[ptr]>, int <[ch]>, FILE *<[fp]>); |
||
44 | |||
4349 | Serge | 45 | TRAD_SYNOPSIS |
46 | #include |
||
47 | int fputc(<[ch]>, <[fp]>) |
||
48 | int <[ch]>; |
||
49 | FILE *<[fp]>; |
||
50 | |||
6099 | serge | 51 | #define _BSD_SOURCE |
4349 | Serge | 52 | #include |
6099 | serge | 53 | int fputc_unlocked(<[ch]>, <[fp]>) |
54 | int <[ch]>; |
||
55 | FILE *<[fp]>; |
||
56 | |||
57 | #include |
||
4349 | Serge | 58 | int _fputc_r(<[ptr]>, <[ch]>, <[fp]>) |
59 | struct _reent *<[ptr]>; |
||
60 | int <[ch]>; |
||
61 | FILE *<[fp]>; |
||
62 | |||
6099 | serge | 63 | #include |
64 | int _fputc_unlocked_r(<[ptr]>, <[ch]>, <[fp]>) |
||
65 | struct _reent *<[ptr]>; |
||
66 | int <[ch]>; |
||
67 | FILE *<[fp]>; |
||
68 | |||
4349 | Serge | 69 | DESCRIPTION |
70 | < |
||
71 | < |
||
72 | <[fp]>. |
||
73 | |||
74 | If the file was opened with append mode (or if the stream cannot |
||
75 | support positioning), then the new character goes at the end of the |
||
76 | file or stream. Otherwise, the new character is written at the |
||
77 | current value of the position indicator, and the position indicator |
||
78 | oadvances by one. |
||
79 | |||
80 | For a macro version of this function, see < |
||
81 | |||
6099 | serge | 82 | < |
83 | < |
||
84 | protected by flockfile() (or ftrylockfile()) and funlockfile(). This |
||
85 | function may safely be used in a multi-threaded program if and only |
||
86 | if they are called while the invoking thread owns the (FILE *) |
||
87 | object, as is the case after a successful call to the flockfile() or |
||
88 | ftrylockfile() functions. If threads are disabled, then |
||
89 | < |
||
4349 | Serge | 90 | |
6099 | serge | 91 | The <<_fputc_r>> and <<_fputc_unlocked_r>> functions are simply reentrant |
92 | versions of the above that take an additional reentrant structure |
||
93 | argument: <[ptr]>. |
||
94 | |||
4349 | Serge | 95 | RETURNS |
96 | If successful, < |
||
97 | intervenes, the result is < |
||
98 | query for errors. |
||
99 | |||
100 | PORTABILITY |
||
101 | < |
||
102 | |||
6099 | serge | 103 | < |
104 | |||
4349 | Serge | 105 | Supporting OS subroutines required: < |
106 | < |
||
107 | */ |
||
108 | |||
109 | #include <_ansi.h> |
||
110 | #include |
||
111 | #include "local.h" |
||
112 | |||
113 | int |
||
114 | _DEFUN(_fputc_r, (ptr, ch, file), |
||
115 | struct _reent *ptr _AND |
||
116 | int ch _AND |
||
117 | FILE * file) |
||
118 | { |
||
119 | int result; |
||
120 | CHECK_INIT(ptr, file); |
||
4921 | Serge | 121 | _newlib_flockfile_start (file); |
4349 | Serge | 122 | result = _putc_r (ptr, ch, file); |
4921 | Serge | 123 | _newlib_flockfile_end (file); |
4349 | Serge | 124 | return result; |
125 | } |
||
126 | |||
127 | #ifndef _REENT_ONLY |
||
128 | int |
||
129 | _DEFUN(fputc, (ch, file), |
||
130 | int ch _AND |
||
131 | FILE * file) |
||
132 | { |
||
133 | #if !defined(__OPTIMIZE_SIZE__) && !defined(PREFER_SIZE_OVER_SPEED) |
||
134 | int result; |
||
4921 | Serge | 135 | struct _reent *reent = _REENT; |
136 | |||
137 | CHECK_INIT(reent, file); |
||
138 | _newlib_flockfile_start (file); |
||
139 | result = _putc_r (reent, ch, file); |
||
140 | _newlib_flockfile_end (file); |
||
4349 | Serge | 141 | return result; |
142 | #else |
||
143 | return _fputc_r (_REENT, ch, file); |
||
144 | #endif |
||
145 | } |
||
146 | #endif /* !_REENT_ONLY */ |