-#ifdef HAVE_DIRENT_H
-void addfontdir(FILE*database, char* dirname, int*numfonts, char*searchpath)
-{
- if(searchpath) {
- if(searchpath[0])
- strcat(searchpath, ":");
- strcat(searchpath, dirname);
- }
- 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;
- sprintf(buf, "%s/%s", dirname,name);
- fi = fopen(buf, "rb");
- if(!fi || !fread(&a,1,1,fi)) {
- msg("<warning> Couldn't read from %s", buf);
- }
- 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)
-{
- char*last1 = strrchr(filename, '/');
- char*last2 = strrchr(filename, '\\');
- char*pos = filename;
- char*name;
- char*dot;
- if(last1>pos) pos = last1 + 1;
- if(last2>pos) pos = last2 + 1;
- name = (char*)malloc(strlen(pos)+5);
- strcpy(name, pos);
- dot = strrchr(name, '.');
- if(dot) {
- *dot = 0;
- }
- strcat(name, newext);
- return name;
-}
-