1 | /*
|
---|
2 | =============================================================================
|
---|
3 | setpr.c -- send printer setup strings to the Citizen HSP-500/550
|
---|
4 | Version 15 -- 1989-11-16 -- D.N. Lynx Crowe
|
---|
5 |
|
---|
6 | Atari GEMDOS version.
|
---|
7 | =============================================================================
|
---|
8 | */
|
---|
9 |
|
---|
10 | #include "stdio.h"
|
---|
11 | #include "stddefs.h"
|
---|
12 | #include "getopt.h"
|
---|
13 |
|
---|
14 | extern int atoi();
|
---|
15 |
|
---|
16 | #define MSGFILE stdout
|
---|
17 | #define OPTARGS "c:i:v:m:p:s:f:dqtr"
|
---|
18 |
|
---|
19 | Usage()
|
---|
20 | {
|
---|
21 | fprintf(MSGFILE, "Usage: setpr [-cn] [-in] [-vn] [-mn] [-pn] [-sn] [-fn] [-dqrt]\n");
|
---|
22 | fprintf(MSGFILE, " where:\n");
|
---|
23 | fprintf(MSGFILE, " -cn set Configuration: 0 = Epson FX/EX, 1 = IBM Proprinter XL\n");
|
---|
24 | fprintf(MSGFILE, " -in set International character set (Epson only):\n");
|
---|
25 | fprintf(MSGFILE, " 0 USA 4 Denmark-1 8 Japan 12 Latin Amer.\n");
|
---|
26 | fprintf(MSGFILE, " 1 France 5 Sweden 9 Norway\n");
|
---|
27 | fprintf(MSGFILE, " 2 Germany 6 Italy 10 Denark-2\n");
|
---|
28 | fprintf(MSGFILE, " 3 England 7 Spain-1 11 Spain-2\n");
|
---|
29 | fprintf(MSGFILE, " -vn set Vertical spacing (Epson only):\n");
|
---|
30 | fprintf(MSGFILE, " 0 8 lines/inch 1 7 dots/line 2 6 lines/inch\n");
|
---|
31 | fprintf(MSGFILE, " -mn set master print Mode:\n");
|
---|
32 | fprintf(MSGFILE, " 1 elite 4 compressed 16 doublestrike 64 italics\n");
|
---|
33 | fprintf(MSGFILE, " 2 proportional 8 emphasized 32 expanded 128 underscore\n");
|
---|
34 | fprintf(MSGFILE, " -pn set master Pitch:\n");
|
---|
35 | fprintf(MSGFILE, " 0 10 CPI (Pica) 2 17 CPI (Pica Compr.) 6 15 CPI \n");
|
---|
36 | fprintf(MSGFILE, " 1 12 CPI (Elite) 5 13.3 CPI 7 20 CPI\n");
|
---|
37 | fprintf(MSGFILE, " -sn set print Speed: 0 normal, 1 high speed\n");
|
---|
38 | fprintf(MSGFILE, " -fn set Font number (NLQ only): 0 Roman 1 Sans Serif 2..6 External\n");
|
---|
39 | fprintf(MSGFILE, " -d Draft print mode\n");
|
---|
40 | fprintf(MSGFILE, " -q NLQ print mode\n");
|
---|
41 | fprintf(MSGFILE, " -r master Reset\n");
|
---|
42 | fprintf(MSGFILE, " -t Top of form\n");
|
---|
43 |
|
---|
44 | exit(1);
|
---|
45 | }
|
---|
46 |
|
---|
47 | /*
|
---|
48 | =============================================================================
|
---|
49 | setpr -- send printer setup strings to the Citizen HSP-500/550
|
---|
50 | =============================================================================
|
---|
51 | */
|
---|
52 |
|
---|
53 | main(argc, argv)
|
---|
54 | int argc;
|
---|
55 | char *argv[];
|
---|
56 | {
|
---|
57 | int option; /* option "letter" */
|
---|
58 | int n; /* argument value */
|
---|
59 | int optused; /* option present flag */
|
---|
60 |
|
---|
61 | FILE *stdprn;
|
---|
62 |
|
---|
63 | if ((FILE *)NULL EQ (stdprn = fopenb("LST:", "w"))) {
|
---|
64 |
|
---|
65 | fprintf(MSGFILE, "ERROR: Unable to open PRN:\n");
|
---|
66 | exit(2);
|
---|
67 | }
|
---|
68 |
|
---|
69 | optused = FALSE;
|
---|
70 |
|
---|
71 | while ((option = getopt (argc, argv, OPTARGS)) != EOF) {
|
---|
72 |
|
---|
73 | optused = TRUE;
|
---|
74 |
|
---|
75 | switch (option) {
|
---|
76 |
|
---|
77 | case 'c': /* c -- configuration, 0 = std, 1 = IBM */
|
---|
78 |
|
---|
79 | n = atoi(optarg);
|
---|
80 |
|
---|
81 | if (n > 1) {
|
---|
82 |
|
---|
83 | fprintf(MSGFILE, "ERROR: bad configuration\n");
|
---|
84 | Usage();
|
---|
85 | }
|
---|
86 |
|
---|
87 | fprintf(stdprn, "\033~5%d", n);
|
---|
88 | break;
|
---|
89 |
|
---|
90 | case 'i': /* i -- international char set, 0 = US */
|
---|
91 |
|
---|
92 | n = atoi(optarg);
|
---|
93 |
|
---|
94 | if (n > 12) {
|
---|
95 |
|
---|
96 | fprintf(MSGFILE, "ERROR: bad character set number\n");
|
---|
97 | Usage();
|
---|
98 | }
|
---|
99 |
|
---|
100 | fprintf(stdprn, "\033R%c", n);
|
---|
101 | break;
|
---|
102 |
|
---|
103 | case 'v': /* v -- vertical line spacing */
|
---|
104 |
|
---|
105 | n = atoi(optarg);
|
---|
106 |
|
---|
107 | if (n > 2) {
|
---|
108 |
|
---|
109 | fprintf(MSGFILE, "ERROR: bad line spacing number\n");
|
---|
110 | Usage();
|
---|
111 | }
|
---|
112 |
|
---|
113 | fprintf(stdprn, "\033%d", n);
|
---|
114 | break;
|
---|
115 |
|
---|
116 | case 'm': /* m -- master print mode */
|
---|
117 |
|
---|
118 | n = atoi(optarg);
|
---|
119 |
|
---|
120 | if (n > 255) {
|
---|
121 |
|
---|
122 | fprintf(MSGFILE, "ERROR: bad master print mode\n");
|
---|
123 | Usage();
|
---|
124 | }
|
---|
125 |
|
---|
126 | fprintf(stdprn, "\033!%c", n);
|
---|
127 | break;
|
---|
128 |
|
---|
129 | case 'p': /* p -- master pitch */
|
---|
130 |
|
---|
131 | n = atoi(optarg);
|
---|
132 |
|
---|
133 | switch (n) {
|
---|
134 |
|
---|
135 | case 0:
|
---|
136 | case 1:
|
---|
137 | case 2:
|
---|
138 | case 5:
|
---|
139 | case 6:
|
---|
140 | case 7:
|
---|
141 |
|
---|
142 | fprintf(stdprn, "\033~3%c", n);
|
---|
143 | break;
|
---|
144 |
|
---|
145 | default:
|
---|
146 |
|
---|
147 | fprintf(MSGFILE, "ERROR: bad master pitch\n");
|
---|
148 | Usage();
|
---|
149 | }
|
---|
150 |
|
---|
151 | break;
|
---|
152 |
|
---|
153 | case 's': /* s -- print speed */
|
---|
154 |
|
---|
155 | n = atoi(optarg);
|
---|
156 |
|
---|
157 | if (n > 1) {
|
---|
158 |
|
---|
159 | fprintf(MSGFILE, "ERROR: bad print speed\n");
|
---|
160 | Usage();
|
---|
161 | }
|
---|
162 |
|
---|
163 | fprintf(stdprn, "\033~8%d", n);
|
---|
164 | break;
|
---|
165 |
|
---|
166 | case 'f': /* f -- NLQ font number */
|
---|
167 |
|
---|
168 | n = atoi(optarg);
|
---|
169 |
|
---|
170 | if (n > 6) {
|
---|
171 |
|
---|
172 | fprintf(MSGFILE, "ERROR: bad font number\n");
|
---|
173 | Usage();
|
---|
174 | }
|
---|
175 |
|
---|
176 | fprintf(stdprn, "\033k%c", n);
|
---|
177 | break;
|
---|
178 |
|
---|
179 | case 't': /* t -- top of form */
|
---|
180 |
|
---|
181 | fprintf(stdprn, "\f");
|
---|
182 | break;
|
---|
183 |
|
---|
184 | case 'd': /* d -- draft print mode */
|
---|
185 |
|
---|
186 | fprintf(stdprn, "\033x0");
|
---|
187 | break;
|
---|
188 |
|
---|
189 | case 'q': /* q -- NLQ print mode */
|
---|
190 |
|
---|
191 | fprintf(stdprn, "\033x1");
|
---|
192 | break;
|
---|
193 |
|
---|
194 | case 'r': /* r -- master reset */
|
---|
195 |
|
---|
196 | fprintf(stdprn, "\033@");
|
---|
197 | break;
|
---|
198 |
|
---|
199 | default: /* unrecognized option */
|
---|
200 |
|
---|
201 | fprintf(MSGFILE, "ERROR: unrecognized option\n");
|
---|
202 | Usage();
|
---|
203 | }
|
---|
204 | }
|
---|
205 |
|
---|
206 | if (NOT optused)
|
---|
207 | Usage();
|
---|
208 | else
|
---|
209 | exit(0);
|
---|
210 | }
|
---|