-#ifdef HAVE_DIRENT_H
-void addfontdir(FILE*database, char* dirname, int*numfonts, char*searchpath)
-{
- if(searchpath) {
- if(searchpath[0])
- strcat(searchpath, ":");
- strcat(searchpath, dirname);
- }
- if(!numfonts)
- msg("<verbose> Adding %s to search path\n", dirname);
-
- DIR*dir = opendir(dirname);
- if(!dir) {
- msg("<warning> Couldn't open directory %s\n", dirname);
- return;
- }
- dirent*ent;
- while(1) {
- ent = readdir (dir);
- if (!ent)
- break;
- int l;
- char*name = ent->d_name;
- char type = 0;
- if(!name) continue;
- l=strlen(name);
- if(l<4)
- continue;
- if(!strncasecmp(&name[l-4], ".afm", 4))
- type=1;
- if(!strncasecmp(&name[l-4], ".ttf", 4))
- type=2;
- if(type)
- {
- if(database && type==1) {
- char buf[256],a;
- FILE*fi;
-#ifdef WIN32
- sprintf(buf, "%s\\%s", dirname,name);
-#else
- sprintf(buf, "%s/%s", dirname,name);
-#endif
- fi = fopen(buf, "rb");
- if(!fi || !fread(&a,1,1,fi)) {
- msg("<warning> Couldn't read from %s", buf);
- }
-
-#ifdef WIN32
-/* might also work for all other systems, but we *need* it for win32 */
- if(!strncmp(buf, FONTDIR, strlen(FONTDIR)))
- fprintf(database, "%s\n", buf+strlen(FONTDIR));
- else
-#endif
- fprintf(database, "%s\n", buf);
-
- msg("<verbose> Found font %s\n", buf);
- fclose(fi);
- }
- if(numfonts)
- (*numfonts)++;
- }
- }
- closedir(dir);
-}
-#endif
-
-char* stripfilename(char*filename, char*newext)