Subversion Repositories HelenOS

Rev

Rev 3756 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3756 Rev 3757
Line 213... Line 213...
213
{
213
{
214
    f->eof = 0;
214
    f->eof = 0;
215
    f->error = 0;
215
    f->error = 0;
216
}
216
}
217
 
217
 
-
 
218
/** Read character from a stream. */
-
 
219
int fgetc(FILE *f)
-
 
220
{
-
 
221
    unsigned char c;
-
 
222
    size_t n;
-
 
223
 
-
 
224
    n = fread(&c, sizeof(c), 1, f);
-
 
225
    if (n < 1) return EOF;
-
 
226
 
-
 
227
    return (int) c;
-
 
228
}
-
 
229
 
-
 
230
/** Write character to a stream. */
-
 
231
int fputc(int c, FILE *f)
-
 
232
{
-
 
233
    unsigned char cc;
-
 
234
    size_t n;
-
 
235
 
-
 
236
    cc = (unsigned char) c;
-
 
237
    n = fwrite(&cc, sizeof(cc), 1, f);
-
 
238
    if (n < 1) return EOF;
-
 
239
 
-
 
240
    return (int) cc;
-
 
241
}
-
 
242
 
-
 
243
/** Write string to a stream. */
-
 
244
int fputs(const char *s, FILE *f)
-
 
245
{
-
 
246
    int rc;
-
 
247
 
-
 
248
    rc = 0;
-
 
249
 
-
 
250
    while (*s && rc >= 0) {
-
 
251
        rc = fputc(*s++, f);
-
 
252
    }
-
 
253
 
-
 
254
    if (rc < 0) return EOF;
-
 
255
 
-
 
256
    return 0;
-
 
257
}
-
 
258
 
-
 
259
/** Seek to position in stream. */
-
 
260
int fseek(FILE *f, long offset, int origin)
-
 
261
{
-
 
262
    off_t rc;
-
 
263
 
-
 
264
    rc = lseek(f->fd, offset, origin);
-
 
265
    if (rc == (off_t) (-1)) {
-
 
266
        /* errno has been set by lseek. */
-
 
267
        return -1;
-
 
268
    }
-
 
269
 
-
 
270
    f->eof = 0;
-
 
271
 
-
 
272
    return 0;
-
 
273
}
-
 
274
 
218
/** @}
275
/** @}
219
 */
276
 */