diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2014-11-20 12:13:02 -0600 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2015-12-23 02:22:56 +0100 |
commit | 3051002fc6c543f7c1bb5403ada3a3d5a31c4023 (patch) | |
tree | 9d88b7a288e8ce305f9b03d91c1fddac0d39718b /kdeprint/driverparse.c | |
parent | 94067b20f46444eed62778026fd4cb532a8c263c (diff) | |
download | tdelibs-3051002fc6c543f7c1bb5403ada3a3d5a31c4023.tar.gz tdelibs-3051002fc6c543f7c1bb5403ada3a3d5a31c4023.zip |
Greatly increase database generation speed from compressed PPDs where possible
(cherry picked from commit 880fec09182a500b7e19b5b1c73189040cf3421a)
Diffstat (limited to 'kdeprint/driverparse.c')
-rw-r--r-- | kdeprint/driverparse.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/kdeprint/driverparse.c b/kdeprint/driverparse.c index c52134325..49f3a5ad5 100644 --- a/kdeprint/driverparse.c +++ b/kdeprint/driverparse.c @@ -30,13 +30,14 @@ char **files = NULL; char **fileorigins = NULL; +char **filemetadata = NULL; int nfiles = 0, maxfiles = 0; int nhandlers = 0, maxhandlers = 0; int nlibs = 0, maxlibs = 0; typedef struct { void (*init)(const char*); - int (*parse)(const char*, const char*, FILE*); + int (*parse)(const char*, const char*, const char*, FILE*); char *name; int namelen; } handler; @@ -60,7 +61,7 @@ void freeHandlers(void) free(handlers); } -void registerHandler(const char *name, void(*initf)(const char*), int(*parsef)(const char*, const char*, FILE*)) +void registerHandler(const char *name, void(*initf)(const char*), int(*parsef)(const char*, const char*, const char*, FILE*)) { handler *h = (handler*)malloc(sizeof(handler)); h->init = initf; @@ -110,6 +111,7 @@ void initFiles(void) maxfiles = 100; files = (char**)malloc(sizeof(char*) * maxfiles); fileorigins = (char**)malloc(sizeof(char*) * maxfiles); + filemetadata = (char**)malloc(sizeof(char*) * maxfiles); } void freeFiles(void) @@ -118,8 +120,10 @@ void freeFiles(void) for (i=0; i<nfiles; i++) free(files[i]); free(fileorigins[i]); + free(filemetadata[i]); free(files); free(fileorigins); + free(filemetadata); } void checkSize(void) @@ -129,16 +133,18 @@ void checkSize(void) maxfiles += 100; files = (char**)realloc(files, sizeof(char*) * maxfiles); fileorigins = (char**)realloc(fileorigins, sizeof(char*) * maxfiles); + filemetadata = (char**)realloc(filemetadata, sizeof(char*) * maxfiles); } } -void addFile(const char *filename, const char *origin) +void addFile(const char *filename, const char *origin, const char *metadata) { if (maxfiles == 0) initFiles(); checkSize(); files[nfiles] = strdup(filename); fileorigins[nfiles] = strdup(origin); + filemetadata[nfiles] = strdup(metadata); nfiles++; } @@ -273,7 +279,7 @@ int getMaticPrinterInfos(const char *base, const char *id, char *make, char *mod return 1; } -int parseMaticFile(const char *driver, const char *origin, FILE *output) +int parseMaticFile(const char *driver, const char *origin, const char *metadata, FILE *output) { FILE *drFile; char name[32] = {0}, @@ -377,7 +383,7 @@ void initMatic(const char *base) continue; else if (!S_ISREG(st.st_mode)) continue; - addFile(drFile, ""); + addFile(drFile, "", ""); } closedir(foodir); } @@ -443,7 +449,7 @@ int execute(int argc, char *argv[]) for (hi=0; hi<nhandlers; hi++) if (strncmp(files[i], handlers[hi]->name, handlers[hi]->namelen) == 0) { - handlers[hi]->parse(files[i]+handlers[hi]->namelen, fileorigins[i], dbFile); + handlers[hi]->parse(files[i]+handlers[hi]->namelen, fileorigins[i], filemetadata[i], dbFile); break; } fprintf(stdout, "%d\n", i); |