source: toilet/trunk/src/io.c @ 1202

Last change on this file since 1202 was 1202, checked in by Sam Hocevar, 14 years ago
  • Add feof() to the list of I/O functions.
  • Property svn:keywords set to Id
File size: 1012 bytes
Line 
1/*
2 *  TOIlet        The Other Implementation’s letters
3 *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id: io.c 1202 2006-10-13 13:38:50Z sam $
7 *
8 *  This program is free software; you can redistribute it and/or
9 *  modify it under the terms of the Do What The Fuck You Want To
10 *  Public License, Version 2, as published by Sam Hocevar. See
11 *  http://sam.zoy.org/wtfpl/COPYING for more details.
12 */
13
14/*
15 * This file contains functions for compressed file I/O.
16 */
17
18#include "config.h"
19
20#include <stdio.h>
21#include <stdlib.h>
22
23#include "io.h"
24
25TOIFILE *toiopen(const char *path, const char *mode)
26{
27    TOIFILE *toif;
28    FILE *f = fopen(path, mode);
29
30    if(!f)
31        return NULL;
32
33    toif = malloc(sizeof(*toif));
34    toif->f = f;
35
36    return toif;
37}
38
39int toiclose(TOIFILE *toif)
40{
41    FILE *f = toif->f;
42    free(toif);
43    return fclose(f);
44}
45
46int toieof(TOIFILE *toif)
47{
48    return feof(toif->f);
49}
50
51char *toigets(char *s, int size, TOIFILE *toif)
52{
53    return fgets(s, size, toif->f);
54}
55
Note: See TracBrowser for help on using the repository browser.