X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=bfile%2Fbfile.c;h=dd10b4fd868cd178c02ebff81005f2259c974b9b;hb=83f7d8e05b21112744575aece533b2bc62610f2a;hp=5a4d6e10a108d86e95992204f8a79cae04d7ec7d;hpb=49f85cf78262660f8b923d0d6cff9e58acac0ed9;p=idzebra-moved-to-github.git diff --git a/bfile/bfile.c b/bfile/bfile.c index 5a4d6e1..dd10b4f 100644 --- a/bfile/bfile.c +++ b/bfile/bfile.c @@ -4,8 +4,23 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: bfile.c,v $ - * Revision 1.2 1994-08-17 14:09:32 quinn - * Compiles cleanly (still only dummy. + * Revision 1.8 1994-08-23 15:03:34 quinn + * *** empty log message *** + * + * Revision 1.7 1994/08/23 14:25:45 quinn + * Added O_CREAT because some geek wanted it. Sheesh. + * + * Revision 1.6 1994/08/23 14:21:38 quinn + * Fixed call to log + * + * 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 @@ -17,6 +32,7 @@ #include #include #include +#include int bf_close (BFile bf) { @@ -29,18 +45,23 @@ 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) + if ((tmp->fd = open(name, wflag ? O_RDWR|O_CREAT : O_RDONLY, 0666)) < 0) { - log(LOG_FATAL, "open: %s"); + log(LOG_FATAL|LOG_ERRNO, "open %s", name); return(0); } + tmp->block_size = block_size; return(tmp); } 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) { + lseek(bf->fd, no * bf->block_size + offset, 0); + return(write(bf->fd, buf, num ? num : bf->block_size)); }