1 | /*DDK*************************************************************************/
|
---|
2 | /* */
|
---|
3 | /* COPYRIGHT Copyright (C) 1991, 2003 IBM Corporation */
|
---|
4 | /* */
|
---|
5 | /* The following IBM OS/2 source code is provided to you solely for */
|
---|
6 | /* the purpose of assisting you in your development of OS/2 device */
|
---|
7 | /* drivers. You may use this code in accordance with the IBM License */
|
---|
8 | /* Agreement provided in the IBM Developer Connection Device Driver */
|
---|
9 | /* Source Kit for OS/2. This Copyright statement may not be removed. */
|
---|
10 | /* */
|
---|
11 | /*****************************************************************************/
|
---|
12 | /**************************************************************************
|
---|
13 | *
|
---|
14 | * SOURCE FILE NAME = PINMAIN.C
|
---|
15 | *
|
---|
16 | * DESCRIPTIVE NAME = main() function of PIN program
|
---|
17 | *
|
---|
18 | *
|
---|
19 | * VERSION = V1.0
|
---|
20 | *
|
---|
21 | * DATE
|
---|
22 | *
|
---|
23 | * DESCRIPTION
|
---|
24 | *
|
---|
25 | *
|
---|
26 | * FUNCTIONS
|
---|
27 | *
|
---|
28 | *
|
---|
29 | *
|
---|
30 | * NOTES
|
---|
31 | *
|
---|
32 | *
|
---|
33 | * STRUCTURES
|
---|
34 | *
|
---|
35 | * EXTERNAL REFERENCES
|
---|
36 | *
|
---|
37 | * EXTERNAL FUNCTIONS
|
---|
38 | *
|
---|
39 | */
|
---|
40 |
|
---|
41 | // main
|
---|
42 |
|
---|
43 | #undef INTERNAL_BUILD
|
---|
44 |
|
---|
45 | #include <os2.h>
|
---|
46 | #include <stdio.h>
|
---|
47 | #include <string.h>
|
---|
48 |
|
---|
49 | #include "config.h"
|
---|
50 | #include "ppd2pak.h"
|
---|
51 | #include "afm2pak.h"
|
---|
52 | #include "ppd2ppb.h"
|
---|
53 |
|
---|
54 | //
|
---|
55 | //
|
---|
56 | //
|
---|
57 | static
|
---|
58 | int ProducePAK(void)
|
---|
59 | {
|
---|
60 | if(!PPD2PAK_Init())
|
---|
61 | goto EXIT_FAIL_INIT;
|
---|
62 | printf("READY, STARTING TO CONVERT\n");
|
---|
63 | if(!PPD2PAK_Work())
|
---|
64 | goto EXIT_FAIL_WORK;
|
---|
65 | printf("FINISHED, SHUTTING DOWN\n");
|
---|
66 |
|
---|
67 | PPD2PAK_Done(); // _Done() functions never fail
|
---|
68 | // (actually they do, if _Init() function has not been called yet)
|
---|
69 |
|
---|
70 | printf("done\n");
|
---|
71 | return TRUE;
|
---|
72 |
|
---|
73 | EXIT_FAIL_WORK:
|
---|
74 | EXIT_FAIL_INIT:
|
---|
75 | printf("fail\n");
|
---|
76 | PPD2PAK_Done();
|
---|
77 | return FALSE;
|
---|
78 | }
|
---|
79 |
|
---|
80 | //
|
---|
81 | //
|
---|
82 | //
|
---|
83 | static
|
---|
84 | int ProduceAFM(void)
|
---|
85 | {
|
---|
86 | if(!AFM2PAK_Init())
|
---|
87 | goto EXIT_FAIL_INIT;
|
---|
88 | printf("init ok\n");
|
---|
89 | if(!AFM2PAK_Work())
|
---|
90 | goto EXIT_FAIL_WORK;
|
---|
91 | printf("work ok\n");
|
---|
92 |
|
---|
93 | AFM2PAK_Done(); // _Done() functions never fail
|
---|
94 | // (actually they do, if _Init() function has not been called yet)
|
---|
95 |
|
---|
96 | printf("done ok\n");
|
---|
97 | return TRUE;
|
---|
98 |
|
---|
99 | EXIT_FAIL_WORK:
|
---|
100 | EXIT_FAIL_INIT:
|
---|
101 | printf("fail\n");
|
---|
102 | AFM2PAK_Done();
|
---|
103 | return FALSE;
|
---|
104 | }
|
---|
105 |
|
---|
106 |
|
---|
107 | #ifdef INTERNAL_BUILD
|
---|
108 | static
|
---|
109 | int ProducePPB(void)
|
---|
110 | {
|
---|
111 | if(!PPD2PPB_Init())
|
---|
112 | goto EXIT_FAIL_INIT;
|
---|
113 | printf("init ok\n");
|
---|
114 | if(!PPD2PPB_Work())
|
---|
115 | goto EXIT_FAIL_WORK;
|
---|
116 | printf("work ok\n");
|
---|
117 |
|
---|
118 | PPD2PPB_Done(); // _Done() functions never fail
|
---|
119 | // (actually they do, if _Init() function has not been called yet)
|
---|
120 |
|
---|
121 | printf("done ok\n");
|
---|
122 | return TRUE;
|
---|
123 |
|
---|
124 | EXIT_FAIL_WORK:
|
---|
125 | EXIT_FAIL_INIT:
|
---|
126 | printf("fail\n");
|
---|
127 | PPD2PPB_Done();
|
---|
128 | return FALSE;
|
---|
129 | }
|
---|
130 | #endif
|
---|
131 |
|
---|
132 | int ParseConfig(int argc, char *argv[])
|
---|
133 | {
|
---|
134 | if(argc<2) return FALSE;
|
---|
135 |
|
---|
136 | if(!strcmpi(argv[1],"ppd"))
|
---|
137 | {
|
---|
138 | return PakConfig(argc,argv);
|
---|
139 | }
|
---|
140 | #ifdef INTERNAL_BUILD
|
---|
141 | else if(!strcmpi(argv[1],"ppb"))
|
---|
142 | {
|
---|
143 | return PpbConfig(argc,argv);
|
---|
144 | }
|
---|
145 | #endif
|
---|
146 | else if(!strcmpi(argv[1],"afm"))
|
---|
147 | {
|
---|
148 | return AfmConfig(argc,argv);
|
---|
149 | }
|
---|
150 |
|
---|
151 | return FALSE;
|
---|
152 | }
|
---|
153 |
|
---|
154 |
|
---|
155 |
|
---|
156 | int main(int argc, char *argv[])
|
---|
157 | {
|
---|
158 | int rc = 1; // NMAKE takes nonzero return value for error
|
---|
159 |
|
---|
160 | // disable output buffering
|
---|
161 | setvbuf( stdout, NULL, _IONBF, 0 );
|
---|
162 |
|
---|
163 | printf("PostScript resource packaging utility version 1.01\n");
|
---|
164 | printf("Copyright (c) IBM Corp. 2000,2001. All rights reserved.\n");
|
---|
165 | printf("Modification made by Bart van Leeuwen, netlabs.org 2007.\n\n");
|
---|
166 |
|
---|
167 | // parse the command line
|
---|
168 |
|
---|
169 | if(ParseConfig(argc,argv))
|
---|
170 | {
|
---|
171 | // ok, do what we're asked to do...
|
---|
172 |
|
---|
173 | switch(iAction)
|
---|
174 | {
|
---|
175 | #ifdef INTERNAL_BUILD
|
---|
176 | case ACTION_PRODUCE_PPB:
|
---|
177 | printf("Producing PPB\n");
|
---|
178 | if( ProducePPB() ) rc = 0; // success
|
---|
179 | break;
|
---|
180 | #endif
|
---|
181 | case ACTION_PRODUCE_PAK:
|
---|
182 | printf("Producing Printer Device PAK\n");
|
---|
183 | if( ProducePAK() ) rc = 0; // success
|
---|
184 | break;
|
---|
185 | //@AFM unsupported
|
---|
186 | // case ACTION_PRODUCE_AFM:
|
---|
187 | // printf("Producing Device Font PAK\n");
|
---|
188 | // if( ProduceAFM() ) rc = 0; // success
|
---|
189 | // break;
|
---|
190 |
|
---|
191 | default:
|
---|
192 | rc = 1; // error
|
---|
193 | }
|
---|
194 | }
|
---|
195 | else
|
---|
196 | {
|
---|
197 | // some problem with command line...
|
---|
198 |
|
---|
199 | printf(
|
---|
200 | "Usage: PIN.EXE <command> <arguments>\n"
|
---|
201 | " Commands:\n"
|
---|
202 | " * 'PPD' to import devices (from PPD files)\n"
|
---|
203 | " pin.exe ppd <path_to_directory_with_ppd_files> <path_to_driver>\n"
|
---|
204 | " Example:\n"
|
---|
205 | " * to import all devices from d:\\pvt_ppd to driver located in d:\\drv:\n"
|
---|
206 | " pin.exe ppd d:\\pvt_ppd d:\\drv\\pscript.drv\n"
|
---|
207 | //@AFM unsupported
|
---|
208 | //" 'AFM' to import device font metrics (from AFM files)\n"
|
---|
209 | //" pin.exe afm <path_to_directory_with_afm_files> <path_to_driver>\n"
|
---|
210 | );
|
---|
211 | rc = 1;
|
---|
212 | }
|
---|
213 |
|
---|
214 | return rc; // nmake is picky picky picky
|
---|
215 | }
|
---|
216 |
|
---|