1 ed7c8e8d 2003-09-30 devnull #include "sam.h"
3 ed7c8e8d 2003-09-30 devnull static int inerror=FALSE;
6 ed7c8e8d 2003-09-30 devnull * A reasonable interface to the system calls
10 ed7c8e8d 2003-09-30 devnull resetsys(void)
12 ed7c8e8d 2003-09-30 devnull inerror = FALSE;
16 ed7c8e8d 2003-09-30 devnull syserror(char *a)
18 ed7c8e8d 2003-09-30 devnull char buf[ERRMAX];
20 ed7c8e8d 2003-09-30 devnull if(!inerror){
21 ed7c8e8d 2003-09-30 devnull inerror=TRUE;
22 ed7c8e8d 2003-09-30 devnull errstr(buf, sizeof buf);
23 ed7c8e8d 2003-09-30 devnull dprint("%s: ", a);
24 ed7c8e8d 2003-09-30 devnull error_s(Eio, buf);
29 ed7c8e8d 2003-09-30 devnull Read(int f, void *a, int n)
31 ed7c8e8d 2003-09-30 devnull char buf[ERRMAX];
33 ed7c8e8d 2003-09-30 devnull if(read(f, (char *)a, n)!=n) {
34 ed7c8e8d 2003-09-30 devnull if (lastfile)
35 ed7c8e8d 2003-09-30 devnull lastfile->rescuing = 1;
36 ed7c8e8d 2003-09-30 devnull errstr(buf, sizeof buf);
37 ed7c8e8d 2003-09-30 devnull if (downloaded)
38 ed7c8e8d 2003-09-30 devnull fprint(2, "read error: %s\n", buf);
39 ed7c8e8d 2003-09-30 devnull rescue();
40 ed7c8e8d 2003-09-30 devnull exits("read");
42 ed7c8e8d 2003-09-30 devnull return n;
46 ed7c8e8d 2003-09-30 devnull Write(int f, void *a, int n)
50 ed7c8e8d 2003-09-30 devnull if((m=write(f, (char *)a, n))!=n)
51 ed7c8e8d 2003-09-30 devnull syserror("write");
52 ed7c8e8d 2003-09-30 devnull return m;
56 ed7c8e8d 2003-09-30 devnull Seek(int f, long n, int w)
58 ed7c8e8d 2003-09-30 devnull if(seek(f, n, w)==-1)
59 ed7c8e8d 2003-09-30 devnull syserror("seek");