FreeCalypso > hg > ueda-linux
diff ueda/uschem-print/papersize.c @ 0:cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 20 Jul 2015 00:24:37 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ueda/uschem-print/papersize.c Mon Jul 20 00:24:37 2015 +0000 @@ -0,0 +1,57 @@ +#include <stdio.h> +#include <ctype.h> +#include <strings.h> + +extern int printsize_x, printsize_y; + +struct paper_size_kwtab { + char *keyword; + int xdim; + int ydim; +} paper_sizes[] = { + {"letter", 792, 612}, + {"legal", 1008, 612}, + {"ledger", 1224, 792}, + {"tabloid", 1224, 792}, + {"11x17", 1224, 792}, + {"A", 792, 612}, + {"B", 1224, 792}, + {"C", 1584, 1224}, + {"D", 2448, 1584}, + {"E", 3168, 2448}, + {NULL, 0, 0} +}; + +set_paper_size(str) + char *str; +{ + struct paper_size_kwtab *kwp; + register char *cp, *np; + + for (kwp = paper_sizes; kwp->keyword; kwp++) + if (!strcmp(str, kwp->keyword)) { + printsize_x = kwp->xdim; + printsize_y = kwp->ydim; + return; + } + + cp = str; + if (!isdigit(*cp)) { +inv: fprintf(stderr, + "uschem-print: -P %s: invalid paper size specification\n", + str); + exit(1); + } + for (np = cp; isdigit(*cp); cp++) + ; + if (*cp++ != 'x') + goto inv; + printsize_x = atoi(np); + if (!isdigit(*cp)) + goto inv; + for (np = cp; isdigit(*cp); cp++) + ; + if (*cp) + goto inv; + printsize_y = atoi(np); +}