diff options
author | Mattia Rizzolo <mattia@mapreri.org> | 2014-10-03 14:04:58 +0000 |
---|---|---|
committer | Mattia Rizzolo <mattia@mapreri.org> | 2014-10-03 14:04:58 +0000 |
commit | 2d113e8792747151bf5d830f1a1485f2f951f940 (patch) | |
tree | f29e273d53fe5735cdac171504d798bf45ea2007 /xsane-convert-to-0.49.c |
Imported Upstream version 0.50upstream/0.50
Diffstat (limited to 'xsane-convert-to-0.49.c')
-rw-r--r-- | xsane-convert-to-0.49.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/xsane-convert-to-0.49.c b/xsane-convert-to-0.49.c new file mode 100644 index 0000000..59975eb --- /dev/null +++ b/xsane-convert-to-0.49.c @@ -0,0 +1,65 @@ +#include "stdio.h" + +#define MM_PER_INCH 25.4 + +main(int argc, char *argv[]) +{ + int val_in; + int val_out; + char option[255]; + char *string = 0; + char *filename = 0; + FILE *file; + int len = 0; + + if (argc != 2) /* error ? */ + { + fprintf(stderr,"USAGE: %s old-xsane.rc >new-xsane.rc\n", argv[0]); + return; + } + + filename = argv[1]; + + file = fopen(filename, "r"); + if (file == 0) /* error ? */ + { + fprintf(stderr,"Could not open %s for reading *** ABORTED ***\n", filename); + return; + } + + while (!feof(file)) + { + fgets(option, sizeof(option), file); /* get option name */ + option[strlen(option)-1] = 0; /* remove cr */ + + len = strlen(option); + + if (len) + { + if (option[len-1] == 34) + { + option[len-1] = 0; /* remove " */ + } + } + string = option+1; + + if ((!strcmp(string, "printer-width")) || + (!strcmp(string, "printer-height")) || + (!strcmp(string, "printer-left-offset")) || + (!strcmp(string, "printer-bottom-offset"))) + { + printf("\"%s\"\n", string); + fscanf(file, "%d\n", &val_in); + val_out = val_in * 65536 * MM_PER_INCH/72.0; + printf("%d\n", val_out); + } + else + { + printf("\"%s\"\n", string); + fgets(option, sizeof(option), file); /* get option name */ + option[strlen(option)-1] = 0; /* remove cr */ + printf("%s\n", option); + } + } + fclose(file); +} |