Rev 10 | Rev 8155 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 10 | Rev 6790 | ||
---|---|---|---|
Line 36... | Line 36... | ||
36 | } |
36 | } |
37 | 37 | ||
38 | /* read the content of a file */ |
38 | /* read the content of a file */ |
39 | void readfile(char *fname, char buf[], long int buflen) |
39 | void readfile(char *fname, char buf[], long int buflen) |
40 | { |
40 | { |
41 | int fd |
41 | int fd, st; |
42 | long int l, lc; |
42 | long int l, lc; |
43 |
|
43 | buf[0]=0; |
44 | st=ftest(fname); if(st!=is_file) return; |
44 | st=ftest(fname); if(st!=is_file) return; |
45 | l=ftst.st_size; if(l<=0) return; |
45 | l=ftst.st_size; if(l<=0) return; |
46 | if(l>=buflen) l=buflen-1; /* silent trancation */ |
46 | if(l>=buflen) l=buflen-1; /* silent trancation */ |
47 | fd=open(fname,O_RDONLY); if(fd==-1) return; |
47 | fd=open(fname,O_RDONLY); if(fd==-1) return; |
48 | lc=read(fd,buf,l); close(fd); |
48 | lc=read(fd,buf,l); close(fd); |