/* * FILE: printcfg.c * PURPOSE: reading of mtpk.cfg file * VERSION: 1.0 (Nov. 1995) * AUTHOR: Piet Tutelaers */ #include /* exit() */ #include "basics.h" /* msg(), fatal(), pstat, my_stat() */ #include "filenames.h" /* extension() */ #include "cfg.h" /* cfg_value(), read_cfg() */ int debug = 0; int main(int argc, char *argv[]) { char *mode = NULL, *res = NULL; int c, done; void print_cfg(); /* get options */ while (--argc > 0 && (*++argv)[0] == '-') { done=0; while ((!done) && (c = (*++argv[0]))) switch (c) { case 'd': debug = 1; pstat = my_stat; break; default: fatal("printcfg: %c illegal option\n", c); } } /* get arguments */ if (argc > 2) fatal("Usage: printcfg [-d] [res [mode]]\n"); if (argc >= 1) res = argv[0]; if (argc == 2) mode = argv[1]; /* read configuration parameters for res and mode */ if (read_cfg(res, mode)) if (res == NULL && mode == NULL) fatal("No default printer data available in mtpk.cfg\n"); else if (mode == NULL) fatal("No data available for %s dpi in mtpk.cfg\n", res); else fatal("No data available for %s dpi and %s in mtpk.cfg\n", res, mode); print_cfg(); exit(0); } char *obligatory[] = {"mfipath", "mode", "pkpath", "res", "tfmpath"}; char *optional [] = {"checksum", "flipath", "forgedir", "gsfontmap", "logfile", "marging", "pkuser", "rendors", "tolerance", "vfpath", "xres", "yres"}; /* print obligatory and optional values */ void print_cfg() { char *p; int i; msg("Obligatory values are\n"); for (i = 0; i < sizeof(obligatory) / sizeof(char *); i++) { p = cfg_value(obligatory[i]); if (p == NULL) msg("\t%s: undefined\n", obligatory[i]); else msg("\t%s = %s\n", obligatory[i], p); } msg("Optional values are\n"); for (i = 0; i < sizeof(optional) / sizeof(char *); i++) { if ((p = cfg_value(optional[i])) == NULL) continue; msg("\t%s = %s\n", optional[i], p); } }