|
|
1.1 root 1: #define FIO_IMP
2: #include "fio.h"
3: #include <libc.h>
4:
5: long
6: Fwrite(fd, addr, nbytes)
7: register char *addr;
8: register long nbytes;
9: {
10: register Fbuffer *f;
11: register COUNT n;
12: long nnbytes = nbytes;
13:
14: FIOSET(f, fd);
15: f->flags |= FIO_WRITING;
16: n = &f->buf[FIOBSIZE] - f->next;
17: if(nbytes < n) n = nbytes;
18: memcpy(f->next, addr, n);
19: f->end = (f->next += n);
20: f->offset += n;
21: nbytes -= n;
22: addr += n;
23: if(nbytes){
24: if(F_flush(f, fd))
25: return(-1L);
26: while(nbytes >= FIOBSIZE){
27: if(write(fd, addr, (COUNT)FIOBSIZE) != FIOBSIZE)
28: return(-1L);
29: addr += FIOBSIZE;
30: nbytes -= FIOBSIZE;
31: f->offset += FIOBSIZE;
32: }
33: memcpy(f->buf, addr, (COUNT)(n = nbytes));
34: f->end = f->next = f->buf+n;
35: f->offset += n;
36: f->flags |= FIO_WRITING;
37: }
38: return(nnbytes);
39: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.