diff options
Diffstat (limited to 'cfn.c')
-rw-r--r-- | cfn.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -3,10 +3,11 @@ /* Function opens and writes the contents of a named file to stdout; * effectively a wrapper around cfd() */ int cfn(const char *fn, void *buf) { - int fd; + FILE *fp; + int cfpr; /* Open the file to get a read-only file descriptor */ - if ((fd = open(fn, O_RDONLY)) == -1) { + if ((fp = fopen(fn, "r")) == NULL) { perror(__FUNCTION__); return -1; } @@ -14,15 +15,15 @@ int cfn(const char *fn, void *buf) { /* Pass the opened descriptor to cfd() to read it; we keep going even if * there are problems, because we need the descriptor closed even if we * couldn't read it */ - cfd(fd, buf); + cfpr = cfp(fp, buf); /* Close the descriptor, since we should now be done with it */ - if (close(fd) == -1) { + if (fclose(fp) != 0) { perror(__FUNCTION__); return -1; } - /* Done, assume success */ - return 0; + /* Done, return the result of the cfp() call */ + return cfpr; } |