]> diplodocus.org Git - nmh/blobdiff - sbr/mime_type.c
Various IMAP protocol improvements
[nmh] / sbr / mime_type.c
index cc6b1fbf58b85da7b14d3a97da3628cc547e6cc1..4e3ebbb797c84faf630e954e55c25b2374d90fd4 100644 (file)
@@ -20,10 +20,10 @@ static char *get_file_info(const char *, const char *);
  * is responsible for free'ing returned memory.
  */
 char *
-mime_type(const char *file_name) {
+mime_type(const char *file_name)
+{
     char *content_type = NULL;  /* mime content type */
     char *p;
-    static int loaded_defaults = 0;
 
 #ifdef MIMETYPEPROC
     char *mimetype;
@@ -55,9 +55,10 @@ mime_type(const char *file_name) {
        struct node *np;                /* Content scan node pointer */
        FILE *fp;                       /* File pointer for mhn.defaults */
 
+        static bool loaded_defaults;
        if (! loaded_defaults &&
                        (fp = fopen(p = etcpath("mhn.defaults"), "r"))) {
-           loaded_defaults = 1;
+           loaded_defaults = true;
            readconfig(NULL, fp, p, 0);
            fclose(fp);
        }
@@ -80,16 +81,17 @@ mime_type(const char *file_name) {
 
        if (content_type == NULL) {
            FILE *fp;
-           int binary = 0, c;
+            int c;
 
            if (!(fp = fopen(file_name, "r"))) {
                inform("unable to access file \"%s\"", file_name);
                return NULL;
            }
 
+           bool binary = false;
            while ((c = getc(fp)) != EOF) {
                if (! isascii(c)  ||  c == 0) {
-                   binary = 1;
+                   binary = true;
                    break;
                }
            }