1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
/* _______ ____ __ ___ ___
* \ _ \ \ / \ / \ \ / / ' ' '
* | | \ \ | | || | \/ | . .
* | | | | | | || ||\ /| |
* | | | | | | || || \/ | | ' ' '
* | | | | | | || || | | . .
* | |_/ / \ \__// || | |
* /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque
* / \
* / . \
* stdfile.c - stdio file input module. / / \ \
* | < / \_
* By entheh. | \/ /\ /
* \_ / > /
* | \ / /
* | ' /
* \__/
*/
#include <stdio.h>
#include "dumb.h"
static void *dumb_stdfile_open(const char *filename)
{
return fopen(filename, "rb");
}
static int dumb_stdfile_skip(void *f, long n)
{
return fseek(f, n, SEEK_CUR);
}
static int dumb_stdfile_getc(void *f)
{
return fgetc(f);
}
static long dumb_stdfile_getnc(char *ptr, long n, void *f)
{
return fread(ptr, 1, n, f);
}
static void dumb_stdfile_close(void *f)
{
fclose(f);
}
static DUMBFILE_SYSTEM stdfile_dfs = {
&dumb_stdfile_open,
&dumb_stdfile_skip,
&dumb_stdfile_getc,
&dumb_stdfile_getnc,
&dumb_stdfile_close
};
void dumb_register_stdfiles(void)
{
register_dumbfile_system(&stdfile_dfs);
}
static DUMBFILE_SYSTEM stdfile_dfs_leave_open = {
NULL,
&dumb_stdfile_skip,
&dumb_stdfile_getc,
&dumb_stdfile_getnc,
NULL
};
DUMBFILE *dumbfile_open_stdfile(FILE *p)
{
DUMBFILE *d = dumbfile_open_ex(p, &stdfile_dfs_leave_open);
return d;
}
|