find correct mime type of files with no suffix, e.g. Makefile
[claws.git] / src / procmime.c
index e15738d0c1170b8aa97ca0bd69e27a142d4e389b..cce1695800896b3cf792c5893728ce915753f343 100644 (file)
@@ -314,7 +314,7 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
        gint readend;
        gchar *tmpfilename;
        FILE *outfp, *infp;
-       struct stat statbuf;
+       GStatBuf statbuf;
        gboolean tmp_file = FALSE;
        gboolean flowed = FALSE;
        gboolean delsp = FALSE; 
@@ -428,7 +428,7 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
                        }
                        starting = FALSE;
                        if (((inread != inlen) || len < 0) && !got_error) {
-                               g_warning("Bad BASE64 content.\n");
+                               g_warning("Bad BASE64 content.");
                                if (SC_FWRITE(_("[Error decoding BASE64]\n"),
                                        sizeof(gchar),
                                        strlen(_("[Error decoding BASE64]\n")),
@@ -472,7 +472,7 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
                                len = fromuutobits(outbuf, buf);
                                if (len <= 0) {
                                        if (len < 0) 
-                                               g_warning("Bad UUENCODE content(%d)\n", len);
+                                               g_warning("Bad UUENCODE content (%d)", len);
                                        break;
                                }
                                if (SC_FWRITE(outbuf, sizeof(gchar), len, outfp) < len)
@@ -527,7 +527,7 @@ gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding)
        FILE *infp = NULL, *outfp;
        gint len;
        gchar *tmpfilename;
-       struct stat statbuf;
+       GStatBuf statbuf;
        gboolean err = FALSE;
 
        if (mimeinfo->content == MIMECONTENT_EMPTY)
@@ -551,7 +551,7 @@ gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding)
 
        if (mimeinfo->content == MIMECONTENT_FILE && mimeinfo->data.filename) {
                if ((infp = procmime_fopen(mimeinfo->data.filename, "rb")) == NULL) {
-                       g_warning("Can't open file %s\n", mimeinfo->data.filename);
+                       g_warning("Can't open file %s", mimeinfo->data.filename);
                        procmime_fclose(outfp);
                        return FALSE;
                }
@@ -837,7 +837,7 @@ gboolean procmime_scan_text_content(MimeInfo *mimeinfo,
        }
 
        if (conv_fail)
-               g_warning("procmime_get_text_content(): Code conversion failed.\n");
+               g_warning("procmime_get_text_content(): Code conversion failed.");
 
        procmime_fclose(tmpfp);
        claws_unlink(tmpfile);
@@ -1104,6 +1104,8 @@ gchar *procmime_get_mime_type(const gchar *filename)
        base = g_path_get_basename(filename);
        if ((p = strrchr(base, '.')) != NULL)
                ext = g_utf8_strdown(p + 1, -1);
+       else
+               ext = g_utf8_strdown(base, -1);
        g_free(base);
 
 #ifndef G_OS_WIN32
@@ -1255,7 +1257,7 @@ GList *procmime_get_mime_type_list(void)
        procmime_fclose(fp);
 
        if (!list)
-               g_warning("Can't read mime.types\n");
+               g_warning("Can't read mime.types");
 
        return list;
 }
@@ -2167,7 +2169,7 @@ static void output_mime_structure(MimeInfo *mimeinfo, int indent)
 static MimeInfo *procmime_scan_file_with_offset(const gchar *filename, int offset, gboolean short_scan)
 {
        MimeInfo *mimeinfo;
-       struct stat buf;
+       GStatBuf buf;
 
        if (g_stat(filename, &buf) < 0) {
                FILE_OP_ERROR(filename, "stat");