Mercurial > hg > mlmmj
changeset 379:136e5bc27f7a
Change statctrl to only return a file is not there, if stat() explicitly said so
author | mmj |
---|---|
date | Mon, 22 Nov 2004 23:25:01 +1100 |
parents | dcf35885d50d |
children | 9b73100c4258 |
files | src/mygetline.c src/statctrl.c |
diffstat | 2 files changed, 14 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/mygetline.c Thu Nov 18 22:58:27 2004 +1100 +++ b/src/mygetline.c Mon Nov 22 23:25:01 2004 +1100 @@ -33,9 +33,9 @@ char *mygetline(int fd) { size_t i = 0, res, buf_size = BUFSIZE; /* initial buffer size */ - char *buf = mymalloc(buf_size); - char ch; + char *buf, ch; + buf = mymalloc(buf_size); buf[0] = '\0'; while(1) { res = read(fd, &ch, 1);
--- a/src/statctrl.c Thu Nov 18 22:58:27 2004 +1100 +++ b/src/statctrl.c Mon Nov 22 23:25:01 2004 +1100 @@ -24,10 +24,12 @@ #include <sys/types.h> #include <sys/stat.h> #include <stdlib.h> +#include <errno.h> #include "strgen.h" #include "statctrl.h" #include "memory.h" +#include "log_error.h" int statctrl(const char *listdir, const char *ctrlstr) { @@ -38,8 +40,15 @@ res = stat(filename, &st); myfree(filename); - if(res == 0) - return 1; + if(res < 0) { + if(errno == ENOENT) { + return 0; + } else { + log_error(LOG_ARGS, "Could not stat %s/control/%s. " + "Bailing out.", listdir, ctrlstr); + exit(EXIT_FAILURE); + } + } - return 0; + return 1; }