Enlightenment CVS committal Author : devilhorns Project : e17 Module : apps/e
Dir : e17/apps/e/src/bin Modified Files: e_int_config_mime.c Log Message: Fix the mime.type parsing that was recently added. =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_int_config_mime.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -3 -r1.16 -r1.17 --- e_int_config_mime.c 23 Nov 2006 00:57:18 -0000 1.16 +++ e_int_config_mime.c 25 Nov 2006 20:03:13 -0000 1.17 @@ -37,6 +37,7 @@ static void _fill_list (E_Config_Dialog_Data *cfdata, char *mtype); static void _fill_tlist (E_Config_Dialog_Data *cfdata); static void _load_mimes (E_Config_Dialog_Data *cfdata, char *file); +static void _load_globs (E_Config_Dialog_Data *cfdata, char *file); static void _fill_types (E_Config_Dialog_Data *cfdata); static void _tlist_cb_change (void *data); static int _sort_mimes (void *data1, void *data2); @@ -95,11 +96,11 @@ snprintf(buf, sizeof(buf), "/usr/local/share/mime/globs"); if (ecore_file_exists(buf)) - _load_mimes(cfdata, buf); + _load_globs(cfdata, buf); snprintf(buf, sizeof(buf), "/usr/share/mime/globs"); if (ecore_file_exists(buf)) - _load_mimes(cfdata, buf); + _load_globs(cfdata, buf); snprintf(buf, sizeof(buf), "%s/.mime.types", homedir); if (ecore_file_exists(buf)) @@ -107,7 +108,7 @@ snprintf(buf, sizeof(buf), "%s/.local/share/mime/globs", homedir); if (ecore_file_exists(buf)) - _load_mimes(cfdata, buf); + _load_globs(cfdata, buf); if (cfdata->mimes) cfdata->mimes = evas_list_sort(cfdata->mimes, @@ -296,6 +297,63 @@ static void _load_mimes(E_Config_Dialog_Data *cfdata, char *file) +{ + FILE *f; + char buf[4096], mimetype[4096], ext[4096]; + char *p, *pp; + Config_Mime *mime; + Config_Glob *glob; + + if (!cfdata) return; + + f = fopen(file, "rb"); + if (!f) return; + while (fgets(buf, sizeof(buf), f)) + { + p = buf; + while (isblank(*p) && (*p != 0) && (*p != '\n')) p++; + if (*p == '#') continue; + if ((*p == '\n') || (*p == 0)) continue; + pp = p; + while (!isblank(*p) && (*p != 0) && (*p != '\n')) p++; +// while ((*p != ':') && (*p != 0) && (*p != '\n')) p++; + if ((*p == '\n') || (*p == 0)) continue; + strncpy(mimetype, pp, (p - pp)); + mimetype[p - pp] = 0; + do + { + while (isblank(*p) && (*p != 0) && (*p != '\n')) p++; + if ((*p == '\n') || (*p == 0)) continue; + pp = p; + while (!isblank(*p) && (*p != 0) && (*p != '\n')) p++; + strncpy(ext, pp, (p - pp)); + ext[p - pp] = 0; + mime = _find_mime(cfdata, mimetype); + if (!mime) + { + mime = E_NEW(Config_Mime, 1); + if (mime) + { + mime->mime = evas_stringshare_add(mimetype); + if (!mime->mime) + free(mime); + else + { + glob = E_NEW(Config_Glob, 1); + glob->name = evas_stringshare_add(ext); + mime->globs = evas_list_append(mime->globs, glob); + cfdata->mimes = evas_list_append(cfdata->mimes, mime); + } + } + } + } + while ((*p != '\n') && (*p != 0)); + } + fclose(f); +} + +static void +_load_globs(E_Config_Dialog_Data *cfdata, char *file) { FILE *f; char buf[4096], mimetype[4096], ext[4096]; ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs