- while ((dir = FcStrListNext (list)))
- {
- if (!FcConfigAcceptFilename (config, dir))
- continue;
-
- /* freed below */
- file = (FcChar8 *) malloc (strlen ((char *) dir) + 1 + FC_MAX_FILE_LEN + 1);
- if (!file)
- return FcFalse;
-
- strcpy ((char *) file, (char *) dir);
- strcat ((char *) file, "/");
- base = file + strlen ((char *) file);
-
- subdirs = FcStrSetCreate ();
- if (!subdirs)
- {
- fprintf (stderr, "Can't create directory set\n");
- ret++;
- free (file);
- continue;
- }
-
- if (access ((char *) dir, X_OK) < 0)
- {
- switch (errno) {
- case ENOENT:
- case ENOTDIR:
- case EACCES:
- break;
- default:
- fprintf (stderr, "\"%s\": ", dir);
- perror ("");
- ret++;
- }
- FcStrSetDestroy (subdirs);
- free (file);
- continue;
- }
- if (stat ((char *) dir, &statb) == -1)
- {
- fprintf (stderr, "\"%s\": ", dir);
- perror ("");
- FcStrSetDestroy (subdirs);
- ret++;
- free (file);
- continue;
- }
- if (!S_ISDIR (statb.st_mode))
- {
- fprintf (stderr, "\"%s\": not a directory, skipping\n", dir);
- FcStrSetDestroy (subdirs);
- free (file);
- continue;
- }
- if (!FcDirCacheValid (dir) || !FcDirCacheRead (set, subdirs, dir))
- {
- if (FcDebug () & FC_DBG_FONTSET)
- printf ("cache scan dir %s\n", dir);
-
- FcDirScanConfig (set, subdirs, cache,
- config->blanks, dir, FcFalse, config);
- }
- sublist = FcStrListCreate (subdirs);
- FcStrSetDestroy (subdirs);
- if (!sublist)
- {
- fprintf (stderr, "Can't create subdir list in \"%s\"\n", dir);
- ret++;
- free (file);
- continue;
- }
- ret += FcCacheReadDirs (config, cache, sublist, set);
- free (file);
- }
- FcStrListDone (list);
- return ret;
-}
-
-FcFontSet *
-FcCacheRead (FcConfig *config, FcGlobalCache * cache)
-{
- FcFontSet * s = FcFontSetCreate();
- if (!s)
- return 0;
-
- if (FcCacheReadDirs (config, cache, FcConfigGetConfigDirs (config), s))
- goto bail;
-
- return s;
-
- bail:
- FcFontSetDestroy (s);
- return 0;
-}
-
-static const char bin2hex[] = { '0', '1', '2', '3',
- '4', '5', '6', '7',
- '8', '9', 'a', 'b',
- 'c', 'd', 'e', 'f' };
-
-static char *
-FcDirCacheHashName (char * cache_file, int collisions)
-{
- unsigned char hash[16], hex_hash[33];
- char *cache_hashed;
- unsigned char uscore = '_';
- int cnt, i;
- FcChar8 *tmp;
- struct MD5Context ctx;