comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:cd92449fdb51
1 #include <stdio.h>
2 #include <ctype.h>
3 #include <strings.h>
4
5 extern int printsize_x, printsize_y;
6
7 struct paper_size_kwtab {
8 char *keyword;
9 int xdim;
10 int ydim;
11 } paper_sizes[] = {
12 {"letter", 792, 612},
13 {"legal", 1008, 612},
14 {"ledger", 1224, 792},
15 {"tabloid", 1224, 792},
16 {"11x17", 1224, 792},
17 {"A", 792, 612},
18 {"B", 1224, 792},
19 {"C", 1584, 1224},
20 {"D", 2448, 1584},
21 {"E", 3168, 2448},
22 {NULL, 0, 0}
23 };
24
25 set_paper_size(str)
26 char *str;
27 {
28 struct paper_size_kwtab *kwp;
29 register char *cp, *np;
30
31 for (kwp = paper_sizes; kwp->keyword; kwp++)
32 if (!strcmp(str, kwp->keyword)) {
33 printsize_x = kwp->xdim;
34 printsize_y = kwp->ydim;
35 return;
36 }
37
38 cp = str;
39 if (!isdigit(*cp)) {
40 inv: fprintf(stderr,
41 "uschem-print: -P %s: invalid paper size specification\n",
42 str);
43 exit(1);
44 }
45 for (np = cp; isdigit(*cp); cp++)
46 ;
47 if (*cp++ != 'x')
48 goto inv;
49 printsize_x = atoi(np);
50 if (!isdigit(*cp))
51 goto inv;
52 for (np = cp; isdigit(*cp); cp++)
53 ;
54 if (*cp)
55 goto inv;
56 printsize_y = atoi(np);
57 }