]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
Change statctrl to only return a file is not there, if stat() explicitly said so
authormmj <none@none>
Mon, 22 Nov 2004 12:25:01 +0000 (23:25 +1100)
committermmj <none@none>
Mon, 22 Nov 2004 12:25:01 +0000 (23:25 +1100)
src/mygetline.c
src/statctrl.c

index 84bb3002cbc9bf9c34b4bcc0b999c6eb034796db..2959713e076483a42549eded3d8259e519d3672c 100644 (file)
@@ -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);
index 99c1b042e36bab73872200ebba2441839816dfa3..137132d09076cb9de96225f5f003bb25acae4977 100644 (file)
 #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 @@ int statctrl(const char *listdir, const char *ctrlstr)
        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;
 }