X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=bfile%2Fbfile.c;h=ece60e64ef165895e3f10871e30449bcf8a751f4;hb=9f518dd2725fcb7447e1b38c05c4693e31da850c;hp=983929cfafde629375ed3eaa19e1f2d426be97ab;hpb=461e9d67822f7f6ae72a0522cb6e9960dedae501;p=idzebra-moved-to-github.git diff --git a/bfile/bfile.c b/bfile/bfile.c index 983929c..ece60e6 100644 --- a/bfile/bfile.c +++ b/bfile/bfile.c @@ -4,15 +4,26 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: bfile.c,v $ - * Revision 1.1 1994-08-17 13:55:08 quinn - * Deleted + * Revision 1.5 1994-08-18 08:10:08 quinn + * Minimal changes + * + * Revision 1.4 1994/08/17 14:27:32 quinn + * last mods + * + * Revision 1.2 1994/08/17 14:09:32 quinn + * Compiles cleanly (still only dummy). + * + * Revision 1.1 1994/08/17 13:55:08 quinn + * New blocksystem. dummy only * */ #include +#include #include #include #include +#include int bf_close (BFile bf) { @@ -21,20 +32,27 @@ int bf_close (BFile bf) return(0); } -BFile bf_open (const char *name, int block_size, int cache, wflag) +BFile bf_open (const char *name, int block_size, int wflag) { BFile tmp = xmalloc(sizeof(BFile_struct)); if ((tmp->fd = open(name, wflag ? O_RDWR : O_RDONLY, 0666)) < 0) { log(LOG_FATAL, "open: %s"); - return(-1); + return(0); } + tmp->block_size = block_size; return(tmp); } -int bf_read (BFile bf, int no, int offset, int no, void *buf); +int bf_read (BFile bf, int no, int offset, int num, void *buf) +{ + lseek(bf->fd, no * bf->block_size + offset, 0); + return(read(bf->fd, buf, num ? num : bf->block_size)); +} + +int bf_write (BFile bf, int no, int offset, int num, const void *buf) { - if (seek + lseek(bf->fd, no * bf->block_size + offset, 0); + return(write(bf->fd, buf, num ? num : bf->block_size)); } -int bf_write (BFile bf, int no, int offset, int no, const void *buf);