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 | /* */
|
---|
15 | /* */
|
---|
16 | /* */
|
---|
17 | /* */
|
---|
18 | /****************************************************************************/
|
---|
19 |
|
---|
20 | // need full audit!
|
---|
21 | // must eliminate RepWarning and RepError
|
---|
22 | // declare all internal functions and variables static
|
---|
23 | // remove outdated comments and code
|
---|
24 |
|
---|
25 | /**************************************************************************
|
---|
26 | *
|
---|
27 | * SOURCE FILE NAME = PPD2BIN.C
|
---|
28 | *
|
---|
29 | * DESCRIPTIVE NAME = PPD Formatter
|
---|
30 | *
|
---|
31 | * VERSION = V2.0
|
---|
32 | *
|
---|
33 | * DATE
|
---|
34 | *
|
---|
35 | * DESCRIPTION Parses a PPD files and puts the information in an
|
---|
36 | * output file
|
---|
37 | *
|
---|
38 | *
|
---|
39 | * FUNCTIONS
|
---|
40 | * AmbFilename
|
---|
41 | * atoRound
|
---|
42 | * RepWarning
|
---|
43 | * RepError
|
---|
44 | * SkipNumber
|
---|
45 | * SkipBlank
|
---|
46 | * MovePast
|
---|
47 | * CopyString
|
---|
48 | * CopyInQuote
|
---|
49 | * Openppd
|
---|
50 | * ScanParam
|
---|
51 | * ScanProcedure
|
---|
52 | * AddExtension
|
---|
53 | * FreeAll
|
---|
54 | * RemoveExtension
|
---|
55 | * GetArgs
|
---|
56 | * SaveCommand
|
---|
57 | * SaveProcedure
|
---|
58 | * SaveString
|
---|
59 | * FormPpd
|
---|
60 | * bld_compare
|
---|
61 | * CntInpFiles
|
---|
62 | * WriteRCFile
|
---|
63 | * main
|
---|
64 | *
|
---|
65 | *
|
---|
66 | * NOTES Uses the following format for output file:
|
---|
67 | * The output file consists of following segments:
|
---|
68 | *
|
---|
69 | * 1. Signature
|
---|
70 | * 2. Printer directory segment
|
---|
71 | * 3. One or more printer information segments
|
---|
72 | *
|
---|
73 | * Signature has got the following structure:
|
---|
74 | * Identifying name 40 bytes,
|
---|
75 | * Total no of entries in dir 2 bytes,
|
---|
76 | * Present no of entries in dir 2 bytes,
|
---|
77 | * free 4 bytes.
|
---|
78 | *
|
---|
79 | * Each entry in Printer directory segment has got the
|
---|
80 | * following structure:
|
---|
81 | * Printer name 40 bytes,
|
---|
82 | * Offset of printer segment 4 bytes,
|
---|
83 | * free 4 bytes.
|
---|
84 | *
|
---|
85 | * Each printer information segment has got the structure
|
---|
86 | * stored in format DESPPD. Towards the end of printer info
|
---|
87 | * segment lies the list buffer of length specified by the
|
---|
88 | * first two bytes of DESPPD structure. The buffer contains
|
---|
89 | * various command string lists and dimension lists.
|
---|
90 | *
|
---|
91 | * STRUCTURES
|
---|
92 | *
|
---|
93 | * EXTERNAL REFERENCES
|
---|
94 | *
|
---|
95 | * EXTERNAL FUNCTIONS
|
---|
96 | *
|
---|
97 | */
|
---|
98 | //#define INCL_GENPLIB_LAYOUT
|
---|
99 | #include <os2.h>
|
---|
100 | #include <stdio.h>
|
---|
101 | #include <stdlib.h>
|
---|
102 | #include <string.h>
|
---|
103 | #include <ctype.h>
|
---|
104 | #include <builtin.h>
|
---|
105 |
|
---|
106 | //#include <genplib.h>
|
---|
107 | #include "ppd2bin.h"
|
---|
108 | //#include "ppdialog.h"
|
---|
109 | #include "struct.h"
|
---|
110 | #include "fontres.h"
|
---|
111 | // #define IBUFFSIZE 2048
|
---|
112 | #define IBUFFSIZE (1024 * 35) // upped from 11 [wgs]
|
---|
113 | #define MAX_ESC_STR_LEN 256L
|
---|
114 | #define COMPRESS TRUE
|
---|
115 | #define NOCOMPRESS FALSE
|
---|
116 |
|
---|
117 | #define CSTR_NORMAL 0
|
---|
118 | #define CSTR_INCLUDE_SLASH 1
|
---|
119 | #define CSTR_HEX2CHAR 2
|
---|
120 | #define CSTR_EXCLUDE_DQUOTE 4
|
---|
121 |
|
---|
122 | /**************************************************************************
|
---|
123 | * The headers #def INT as int. Just following this, there is a #define int SHORT
|
---|
124 | * This will cause trouble with using PINTs since it expects a 32 bit value
|
---|
125 | * to be pointed to. And that definintion will not be affected by the #define int SHORT
|
---|
126 | * To avoid the problem, I undef INT and the use typedef to reassign it.
|
---|
127 | * [wgs] 1/17/98
|
---|
128 | ***********************************************************************/
|
---|
129 | #ifdef INT
|
---|
130 | #undef INT
|
---|
131 | typedef int INT;
|
---|
132 | #endif
|
---|
133 |
|
---|
134 | #define int SHORT
|
---|
135 | #define unsigned USHORT
|
---|
136 |
|
---|
137 | int SkipBlank(char *);
|
---|
138 |
|
---|
139 | //FILE *ppdOut;
|
---|
140 | //BOOL fWriteWords = FALSE;
|
---|
141 | long test_prefix = 0x12345678;
|
---|
142 | //FILE *fhOut = NULL;
|
---|
143 |
|
---|
144 | typedef struct
|
---|
145 | {
|
---|
146 | FILE *fhFile;
|
---|
147 | long lFileLen;
|
---|
148 | long lCurPos;
|
---|
149 | char *pbBuffer;
|
---|
150 | } FILEBUFFER, *PFILEBUFFER;
|
---|
151 |
|
---|
152 | FILEBUFFER fbIn;
|
---|
153 |
|
---|
154 |
|
---|
155 | long test_post = 0x12345678;
|
---|
156 | char abBuffin[IBUFFSIZE]; /* buffer required for reading input */
|
---|
157 | /* the following appears only to be used in processing the current file and not stored */
|
---|
158 | /* [wgs] and since the input file is might be over 64k(esp. the hp8000_6.ppd) */
|
---|
159 | struct
|
---|
160 | {
|
---|
161 | long usFileStart;
|
---|
162 | long usFileEnd;
|
---|
163 | } UIFileGroup;
|
---|
164 |
|
---|
165 | char acDefFont[] = "Courier";
|
---|
166 | int cbBuffout = 0; /* number of bytes filled in output
|
---|
167 | buffer */
|
---|
168 | DESPPD desPpd; /* printer descriptor segments */
|
---|
169 |
|
---|
170 |
|
---|
171 | //char *pbDirBuffer; /* pointer to directory buffer tobe
|
---|
172 | // allocated */
|
---|
173 | PBYTE pbItemsBuffer; /* pointer to items */
|
---|
174 | // static char pbPrBuffer[1024 * 4];
|
---|
175 | static char pbPrBuffer[ IBUFFSIZE ];
|
---|
176 | USHORT USBlockHeader[ 150 ]; // www.fcuk.lv
|
---|
177 |
|
---|
178 | BOOL BUI = FALSE;
|
---|
179 |
|
---|
180 | #define MAX_FORM_SIZE 127
|
---|
181 | SHORT sFormCount;
|
---|
182 | PCH pFormTable[64]; /* allow 64 forms */
|
---|
183 |
|
---|
184 | UINT nErrorLogLevel=2;
|
---|
185 | //
|
---|
186 | // log levels:
|
---|
187 | // 5 : very quiet
|
---|
188 | // 4 : errors
|
---|
189 | // 3 : serious warning
|
---|
190 | // 2 : warnings
|
---|
191 | // 1 : predictable and handled quirks
|
---|
192 | // 0 : log entrance and exit from function
|
---|
193 | // log how many times function is called
|
---|
194 | //
|
---|
195 |
|
---|
196 | /*
|
---|
197 | ** D74609
|
---|
198 | */
|
---|
199 | #define TRUNCATE_FLOAT (float) 0.0
|
---|
200 | #define ROUND_FLOAT (float) 0.9999
|
---|
201 |
|
---|
202 | int MovePast( char *, char );
|
---|
203 | VOID roundImgAreaVals(int *, float, CHAR );
|
---|
204 |
|
---|
205 | BOOL VerifyPPDLineSize( PCHAR );
|
---|
206 | BOOL BErrorWasDisplayed = FALSE;
|
---|
207 |
|
---|
208 | VOID ProcessUIList( VOID );
|
---|
209 | UINT ProcessUIBlock( PUI_LIST, PUI_BLOCK, UINT, PUSHORT );
|
---|
210 | int CopyString( char *, char *, int, UINT );
|
---|
211 |
|
---|
212 | /*** This is a new section for compression
|
---|
213 | */
|
---|
214 | #include "ppdtable.h"
|
---|
215 | #define HASHSLOTS 251
|
---|
216 |
|
---|
217 | typedef struct _WORDELEMENT
|
---|
218 | {
|
---|
219 | PSZ pszWord; //Pointer to keyword
|
---|
220 | SHORT sIndex; //0 based index plus adjustment
|
---|
221 | SHORT sList; //0 based list
|
---|
222 | struct _WORDELEMENT *pNext;
|
---|
223 | } WORDELEMENT, *PWORDELEMENT;
|
---|
224 |
|
---|
225 | PWORDELEMENT pPSKeyWords;
|
---|
226 | PWORDELEMENT aHashTable[ HASHSLOTS ];
|
---|
227 | INT iShrinkage; //When the ppb is expanded this is the diff between
|
---|
228 | //compressed and uncompressed size
|
---|
229 |
|
---|
230 | INT MatchKeywords( PBYTE, PUI_LIST, PBYTE, BOOL );
|
---|
231 | PUI_BLOCK QueryBlockFromKeyword( PUI_LIST, PBYTE, PBYTE, PINT );
|
---|
232 | PUI_ENTRY QueryEntryFromOption( PBYTE, PUI_BLOCK, PBYTE, PINT );
|
---|
233 | VOID ProcessCmdsAsUIs( VOID );
|
---|
234 | INT ProcessUIConstraints( VOID );
|
---|
235 | INT CopyWord( PCHAR, PCHAR );
|
---|
236 | VOID VerifyUICList( VOID );
|
---|
237 | PCHAR SearchKeySubst( PCHAR );
|
---|
238 |
|
---|
239 | BOOL ParsePPDLang( PSZ, PSZ );
|
---|
240 | FILE *MRILangFile;
|
---|
241 | CHAR MRIPathString[ CCHMAXPATH ];
|
---|
242 |
|
---|
243 |
|
---|
244 | #include "buffers.ch"
|
---|
245 |
|
---|
246 | #include "p2phash.ch"
|
---|
247 |
|
---|
248 | #include "p2putil.ch"
|
---|
249 |
|
---|
250 |
|
---|
251 | /***************************************************************************
|
---|
252 | *
|
---|
253 | * FUNCTION NAME = Openppd
|
---|
254 | *
|
---|
255 | * DESCRIPTION = Opens the file specified in read only text mode and
|
---|
256 | * returns True if open successful ,else FALSE. The
|
---|
257 | * file handle is stored in fhIn
|
---|
258 | *
|
---|
259 | * INPUT = szFileName - filename
|
---|
260 | *
|
---|
261 | * OUTPUT = NONE.
|
---|
262 | *
|
---|
263 | * RETURN-NORMAL = NONE.
|
---|
264 | * RETURN-ERROR = NONE.
|
---|
265 | *
|
---|
266 | ************************************************************************* */
|
---|
267 |
|
---|
268 | BOOL Openppd( char *szFilename )
|
---|
269 | {
|
---|
270 | //long i; NOTUSED
|
---|
271 |
|
---|
272 |
|
---|
273 | fbIn.fhFile = fopen( szFilename, "rb" );
|
---|
274 |
|
---|
275 |
|
---|
276 | if (!fbIn.fhFile)
|
---|
277 | {
|
---|
278 | /*
|
---|
279 | ** Previously, if a file couldn't be found, then the compiler would stop.
|
---|
280 | ** However, confidential OEM PPD files will not be out on the DDK.
|
---|
281 | ** Therefore, change to simply ignore files that aren't found. However,
|
---|
282 | ** do display it for build purposes.
|
---|
283 | */
|
---|
284 | // RepWarning( err_cantopen, szFilename );
|
---|
285 | printf( "[INFO: %s - File not found. Ignore and continue.]\n",
|
---|
286 | szFilename );
|
---|
287 | *szFilename = 0;
|
---|
288 | return( FALSE );
|
---|
289 | }
|
---|
290 |
|
---|
291 |
|
---|
292 | fseek( fbIn.fhFile, 0L, SEEK_END);
|
---|
293 | fbIn.lFileLen = ftell( fbIn.fhFile );
|
---|
294 | fseek( fbIn.fhFile, 0L, SEEK_SET);
|
---|
295 |
|
---|
296 | fbIn.pbBuffer = (char *)malloc( fbIn.lFileLen * sizeof( char ) );
|
---|
297 | fread( fbIn.pbBuffer, sizeof( char ), fbIn.lFileLen, fbIn.fhFile );
|
---|
298 |
|
---|
299 |
|
---|
300 | fbseek(&fbIn, 0L, SEEK_SET);
|
---|
301 | // printf( "Converting %s\n", szFilename );
|
---|
302 | return( TRUE );
|
---|
303 | }
|
---|
304 |
|
---|
305 | /***************************************************************************
|
---|
306 | *
|
---|
307 | * FUNCTION NAME = ScanParam
|
---|
308 | *
|
---|
309 | * DESCRIPTION = This routine scans the szSrchstring in the input
|
---|
310 | * file and provides the remaining parameter in the
|
---|
311 | * return buffer provided. If szSrchstring is found
|
---|
312 | * this routine returns TRUE else FALSE.
|
---|
313 | *
|
---|
314 | * INPUT = szSrchstring - search string address
|
---|
315 | *
|
---|
316 | * OUTPUT = pbBufaddress - return buffer address
|
---|
317 | *
|
---|
318 | * RETURN-NORMAL = NONE.
|
---|
319 | * RETURN-ERROR = NONE.
|
---|
320 | *
|
---|
321 | ************************************************************************* */
|
---|
322 |
|
---|
323 | BOOL ScanParam( char *szSrchstring, char *pbBufreturn )
|
---|
324 | {
|
---|
325 | BOOL fIseof, fIsFound;
|
---|
326 |
|
---|
327 | INT j = 0, k;
|
---|
328 | INT i;
|
---|
329 | long li, lc;
|
---|
330 | UINT uiStrLen = strlen( szSrchstring );
|
---|
331 |
|
---|
332 | long uiCurrFileLoc;
|
---|
333 | INT x;
|
---|
334 |
|
---|
335 | fIseof = FALSE;
|
---|
336 |
|
---|
337 | /*
|
---|
338 | ** search for parameter till token found or file eof encountered
|
---|
339 | */
|
---|
340 | while (!fIseof)
|
---|
341 | {
|
---|
342 | if ((lc = fbtell(&fbIn)) == -1L)
|
---|
343 | {
|
---|
344 | return( FALSE );
|
---|
345 | }
|
---|
346 |
|
---|
347 | /*
|
---|
348 | **
|
---|
349 | */
|
---|
350 | uiCurrFileLoc = fbtell( &fbIn );
|
---|
351 |
|
---|
352 | if ((i = fbread(abBuffin,1,IBUFFSIZE,&fbIn)) != IBUFFSIZE)
|
---|
353 | {
|
---|
354 | fIseof = TRUE;
|
---|
355 | }
|
---|
356 |
|
---|
357 | /*
|
---|
358 | ** Verify that the line size does not exceed IBUFFSIZE bytes.
|
---|
359 | ** Report an error and skip the command if this exists.
|
---|
360 | */
|
---|
361 | if (VerifyPPDLineSize( abBuffin ) == TRUE)
|
---|
362 | {
|
---|
363 | if (i <= 1)
|
---|
364 | {
|
---|
365 | break;
|
---|
366 | }
|
---|
367 |
|
---|
368 | /*
|
---|
369 | ** Ignore the last partially read line
|
---|
370 | */
|
---|
371 | if (!fIseof) /* didn't hit end of file, then don't need do adjust */
|
---|
372 | { /* ignore the partially read line */
|
---|
373 | if (i > 3)
|
---|
374 | i--;
|
---|
375 | for (li = 1;i;li++, i--)
|
---|
376 | {
|
---|
377 | if ((abBuffin[i] == '*') && (abBuffin[i - 1] == '\n'))
|
---|
378 | {
|
---|
379 | break;
|
---|
380 | }
|
---|
381 | } /* for */
|
---|
382 |
|
---|
383 | /*
|
---|
384 | ** shift back the current access pointer of the file
|
---|
385 | ** make it point to the beginning of the partially read line
|
---|
386 | */
|
---|
387 | if (li > 1 && li < IBUFFSIZE)
|
---|
388 | {
|
---|
389 | if (fbseek( &fbIn, -(li-1), SEEK_CUR) == -1L) /* oops, something */
|
---|
390 | {
|
---|
391 | return( FALSE );
|
---|
392 | }
|
---|
393 | } /* check for reasonable backup values */
|
---|
394 | } /* if (!fIseof) */
|
---|
395 |
|
---|
396 | j = 0;
|
---|
397 | fIsFound = FALSE;
|
---|
398 | while (j < i)
|
---|
399 | {
|
---|
400 | if (!strncmp( abBuffin+j, szSrchstring, uiStrLen ))
|
---|
401 | {
|
---|
402 | /* @COOK */
|
---|
403 | if (isspace( *(abBuffin + j + uiStrLen) ) ||
|
---|
404 | *(abBuffin + j + uiStrLen) == ':')
|
---|
405 | {
|
---|
406 | fIsFound = TRUE;
|
---|
407 | }
|
---|
408 | }
|
---|
409 | k = j;
|
---|
410 |
|
---|
411 | for (;;j++)
|
---|
412 | {
|
---|
413 | /*
|
---|
414 | ** Check to see if a comment is on the next line. This will
|
---|
415 | ** prevent a trap if the compiler finds a comment immediately
|
---|
416 | ** following a command line. The compiler won't read the
|
---|
417 | ** comment and possibly exceed buffer space.
|
---|
418 | */
|
---|
419 | if ((abBuffin[j] == 0xA) && (abBuffin[j+1] == 0x2A ||
|
---|
420 | abBuffin[j+1] == '%'))
|
---|
421 | {
|
---|
422 | j++;
|
---|
423 | break;
|
---|
424 | }
|
---|
425 |
|
---|
426 | if (j == i)
|
---|
427 | {
|
---|
428 | break;
|
---|
429 | }
|
---|
430 | }
|
---|
431 |
|
---|
432 | if (fIsFound)
|
---|
433 | {
|
---|
434 | /*
|
---|
435 | */
|
---|
436 | if (BUI == TRUE)
|
---|
437 | {
|
---|
438 | fbseek( &fbIn, uiCurrFileLoc + k, SEEK_SET );
|
---|
439 | lc = fbtell( &fbIn );
|
---|
440 |
|
---|
441 | /*
|
---|
442 | ** Change '1024 * 4' to IBUFFSIZE.
|
---|
443 | */
|
---|
444 | // fread( abBuffin, 1, 1024 * 4, fhIn );
|
---|
445 | fbread( abBuffin, 1, IBUFFSIZE, &fbIn );
|
---|
446 | j = MovePast( abBuffin, ' ' );
|
---|
447 | memset( pbBufreturn, 0, IBUFFSIZE );
|
---|
448 | memcpy( pbBufreturn, abBuffin + j, IBUFFSIZE - j );
|
---|
449 | fbseek( &fbIn, lc + 10, SEEK_SET );
|
---|
450 | }
|
---|
451 | else
|
---|
452 | {
|
---|
453 | k += uiStrLen;
|
---|
454 | k += SkipBlank( abBuffin + k );
|
---|
455 |
|
---|
456 | if (j >= k)
|
---|
457 | {
|
---|
458 | x = j - k;
|
---|
459 | }
|
---|
460 | else
|
---|
461 | {
|
---|
462 | x = 0;
|
---|
463 | while (abBuffin[ k + x ] != 0x0A)
|
---|
464 | {
|
---|
465 | x++;
|
---|
466 | }
|
---|
467 | }
|
---|
468 |
|
---|
469 | memcpy( pbBufreturn, abBuffin + k, x );
|
---|
470 | }
|
---|
471 | break;
|
---|
472 | }
|
---|
473 | }
|
---|
474 |
|
---|
475 | /*
|
---|
476 | ** set the access pointer so that in next access the current
|
---|
477 | ** token is not reencountered
|
---|
478 | */
|
---|
479 | if (fIsFound)
|
---|
480 | {
|
---|
481 | fbseek( &fbIn, lc+(long)j, SEEK_SET );
|
---|
482 | break;
|
---|
483 | }
|
---|
484 | }
|
---|
485 | }
|
---|
486 | return( fIsFound );
|
---|
487 | } /* ScanParam */
|
---|
488 |
|
---|
489 | /***************************************************************************
|
---|
490 | *
|
---|
491 | * FUNCTION NAME = ScanProcedure
|
---|
492 | *
|
---|
493 | * DESCRIPTION = This routine scans the szSrchstring in the input
|
---|
494 | * file and provides the remaining parameter in the
|
---|
495 | * return buffer provided. If szSrchstring is found
|
---|
496 | * this routine returns TRUE else FALSE.
|
---|
497 | *
|
---|
498 | * INPUT = szSrchstring - search string address
|
---|
499 | *
|
---|
500 | * OUTPUT = pbBufaddress - return buffer address
|
---|
501 | *
|
---|
502 | * RETURN-NORMAL = NONE.
|
---|
503 | * RETURN-ERROR = NONE.
|
---|
504 | *
|
---|
505 | ************************************************************************* */
|
---|
506 |
|
---|
507 | BOOL ScanProcedure( char *szSrchstring,char *pbBufreturn )
|
---|
508 | {
|
---|
509 | BOOL fIseof, fIsFound;
|
---|
510 | INT i, j, k, iStrlen;
|
---|
511 | long li;
|
---|
512 |
|
---|
513 | fIsFound = FALSE;
|
---|
514 | fIseof = FALSE;
|
---|
515 |
|
---|
516 | /*
|
---|
517 | ** search for parameter till token found or file eof encountered
|
---|
518 | */
|
---|
519 | while (!fIseof)
|
---|
520 | {
|
---|
521 | if (fbseek( &fbIn, 0L, SEEK_CUR ) == -1L)
|
---|
522 | {
|
---|
523 | return (FALSE);
|
---|
524 | }
|
---|
525 |
|
---|
526 | if ((i = fbread( abBuffin, 1, IBUFFSIZE, &fbIn )) != IBUFFSIZE)
|
---|
527 | {
|
---|
528 | fIseof = TRUE;
|
---|
529 | }
|
---|
530 |
|
---|
531 | if (i <= 0)
|
---|
532 | {
|
---|
533 | break;
|
---|
534 | }
|
---|
535 |
|
---|
536 | /* Ignore the last partially read line */
|
---|
537 | for (li = 1;i;li++, i--)
|
---|
538 | {
|
---|
539 | if ((abBuffin[IBUFFSIZE - li] == 0x2A) &&
|
---|
540 | (abBuffin[IBUFFSIZE - li - 1] == 0xA))
|
---|
541 | {
|
---|
542 | break;
|
---|
543 | }
|
---|
544 | }
|
---|
545 |
|
---|
546 | i--;
|
---|
547 |
|
---|
548 | /* shift back the current access pointer of the file */
|
---|
549 | if (li > 1 && li < IBUFFSIZE)
|
---|
550 | {
|
---|
551 | if (fbseek( &fbIn, -li, SEEK_CUR ) == -1L)
|
---|
552 | {
|
---|
553 | return (FALSE);
|
---|
554 | }
|
---|
555 | }
|
---|
556 |
|
---|
557 | j = 0;
|
---|
558 | fIsFound = FALSE;
|
---|
559 | iStrlen = 0;
|
---|
560 |
|
---|
561 | while (*(szSrchstring + iStrlen) != '\0')
|
---|
562 | {
|
---|
563 | iStrlen++;
|
---|
564 | }
|
---|
565 |
|
---|
566 | while (j < i)
|
---|
567 | {
|
---|
568 | if (!strncmp(abBuffin+j, szSrchstring, iStrlen))
|
---|
569 | {
|
---|
570 | if (*(abBuffin+j+iStrlen) == ' ' || *(abBuffin+j+iStrlen) == ':')
|
---|
571 | {
|
---|
572 | fIsFound = TRUE;
|
---|
573 | }
|
---|
574 | }
|
---|
575 | k = j;
|
---|
576 |
|
---|
577 | for (;;j++)
|
---|
578 | {
|
---|
579 | if ((abBuffin[j] == 0xA) && (abBuffin[j+1] == 0x2A))
|
---|
580 | {
|
---|
581 | j++;
|
---|
582 | break;
|
---|
583 | }
|
---|
584 | if (j == i)
|
---|
585 | {
|
---|
586 | break;
|
---|
587 | }
|
---|
588 | }
|
---|
589 |
|
---|
590 | if (fIsFound)
|
---|
591 | {
|
---|
592 | /*
|
---|
593 | ** now reset the file to start of where the token has been
|
---|
594 | ** encountered and read a large block so that entire procedure
|
---|
595 | ** might be covered.
|
---|
596 | */
|
---|
597 | if (fbseek( &fbIn, (long) - (i - k), SEEK_CUR) == -1L)
|
---|
598 | {
|
---|
599 | return( FALSE );
|
---|
600 | }
|
---|
601 |
|
---|
602 | if ((i = fbread( abBuffin, 1, IBUFFSIZE, &fbIn)) <= 0)
|
---|
603 | {
|
---|
604 | return( FALSE );
|
---|
605 | }
|
---|
606 | k = iStrlen;
|
---|
607 | k += MovePast( abBuffin+k, '"' );
|
---|
608 | j = 0;
|
---|
609 |
|
---|
610 | while (abBuffin[k] != '"' && k < i)
|
---|
611 | {
|
---|
612 | if (abBuffin[k] != '\r')
|
---|
613 | {
|
---|
614 | *(pbBufreturn + 2 + j++) = abBuffin[k++];
|
---|
615 | }
|
---|
616 | else
|
---|
617 | {
|
---|
618 | k++;
|
---|
619 | }
|
---|
620 | }
|
---|
621 | *(pbBufreturn+2+j) = '\0';
|
---|
622 | *(int *)pbBufreturn = (1+j);
|
---|
623 | return (TRUE);
|
---|
624 | }
|
---|
625 | }
|
---|
626 | }
|
---|
627 | return (fIsFound);
|
---|
628 | }
|
---|
629 |
|
---|
630 |
|
---|
631 | /***************************************************************************
|
---|
632 | *
|
---|
633 | * FUNCTION NAME = SaveCommand
|
---|
634 | *
|
---|
635 | * DESCRIPTION = This routine scans the parameter buffer and saves
|
---|
636 | * the command within quotes in pbItemsBuffer .This
|
---|
637 | * routine is written to save code.
|
---|
638 | *
|
---|
639 | * INPUT = szString - pointer to string to be searched
|
---|
640 | *
|
---|
641 | * OUTPUT = piOffset - pointer to variable where offset is to be
|
---|
642 | * stored
|
---|
643 | *
|
---|
644 | * RETURN-NORMAL = NONE.
|
---|
645 | * RETURN-ERROR = NONE.
|
---|
646 | *
|
---|
647 | ************************************************************************* */
|
---|
648 |
|
---|
649 | VOID SaveCommand(char *szString,short *piOffset,BOOL CompressFlag)
|
---|
650 | {
|
---|
651 | int i, j;
|
---|
652 | BOOL fPrnName;
|
---|
653 |
|
---|
654 | fbseek( &fbIn, (long)0, SEEK_SET );
|
---|
655 |
|
---|
656 | if (ScanParam(szString, pbPrBuffer))
|
---|
657 | {
|
---|
658 | /*
|
---|
659 | ** skip the " character
|
---|
660 | */
|
---|
661 | i = MovePast( pbPrBuffer, '"' );
|
---|
662 | fPrnName = (strcmp( szString, "*NickName" ) == 0) |
|
---|
663 | (strcmp( szString, "*ShortNickName" ) == 0);
|
---|
664 | *piOffset = cbBuffout;
|
---|
665 |
|
---|
666 | /* The data within quotes is NULL */
|
---|
667 | if (pbPrBuffer[i-1] == '"' && pbPrBuffer[i-2] == '"')
|
---|
668 | {
|
---|
669 | *piOffset = 0;
|
---|
670 | return;
|
---|
671 | }
|
---|
672 |
|
---|
673 | /*
|
---|
674 | ** copies the string delimited by quote with ist byte as length.
|
---|
675 | */
|
---|
676 | j = CopyInQuote( pbItemsBuffer + cbBuffout, pbPrBuffer + i, fPrnName,
|
---|
677 | CompressFlag);
|
---|
678 | cbBuffout += j;
|
---|
679 | }
|
---|
680 | else
|
---|
681 | {
|
---|
682 | /*
|
---|
683 | ** Null pointer
|
---|
684 | */
|
---|
685 | *piOffset = -1;
|
---|
686 | }
|
---|
687 | }
|
---|
688 |
|
---|
689 | /***************************************************************************
|
---|
690 | *
|
---|
691 | * FUNCTION NAME = SaveProcedure
|
---|
692 | *
|
---|
693 | * DESCRIPTION = This routine scans the parameter buffer and saves
|
---|
694 | * the procedure within quotes in pbItemsBuffer .This
|
---|
695 | * routine is written to save code.
|
---|
696 | *
|
---|
697 | * INPUT = szString - pointer to string to be searched.
|
---|
698 | *
|
---|
699 | * OUTPUT = piOffset - pointer to variable where offset is to be
|
---|
700 | * stored.
|
---|
701 | *
|
---|
702 | * RETURN-NORMAL = NONE.
|
---|
703 | * RETURN-ERROR = NONE.
|
---|
704 | *
|
---|
705 | ************************************************************************* */
|
---|
706 |
|
---|
707 | VOID SaveProcedure( char *szString, short *piOffset )
|
---|
708 | {
|
---|
709 | int j;
|
---|
710 |
|
---|
711 | fbseek( &fbIn, (long) 0, SEEK_SET );
|
---|
712 |
|
---|
713 | if (ScanProcedure( szString, pbItemsBuffer + cbBuffout ))
|
---|
714 | {
|
---|
715 | *piOffset = cbBuffout;
|
---|
716 | j = *(int *)(pbItemsBuffer + cbBuffout );
|
---|
717 |
|
---|
718 | /*
|
---|
719 | ** 2 bytes extra to take care of length
|
---|
720 | */
|
---|
721 | cbBuffout += ( j + 2 );
|
---|
722 | }
|
---|
723 | else
|
---|
724 | {
|
---|
725 | /*
|
---|
726 | ** Null pointer
|
---|
727 | */
|
---|
728 | *piOffset = -1;
|
---|
729 | }
|
---|
730 | }
|
---|
731 |
|
---|
732 | /***************************************************************************
|
---|
733 | *
|
---|
734 | * FUNCTION NAME = SaveString
|
---|
735 | *
|
---|
736 | * DESCRIPTION = This routine scans the parameter buffer and saves
|
---|
737 | * the keyword following colon in pbItemsBuffer . This
|
---|
738 | * routine is written to save code/
|
---|
739 | *
|
---|
740 | * INPUT = szString - pointer to string to be searched.
|
---|
741 | *
|
---|
742 | * OUTPUT = piOffset - pointer to variable where offset is to be
|
---|
743 | * stored.
|
---|
744 | *
|
---|
745 | * RETURN-NORMAL = NONE.
|
---|
746 | * RETURN-ERROR = NONE.
|
---|
747 | *
|
---|
748 | ************************************************************************* */
|
---|
749 |
|
---|
750 | VOID SaveString( char *szString, short *piOffset )
|
---|
751 | {
|
---|
752 | int i, j;
|
---|
753 |
|
---|
754 | fbseek( &fbIn, (long) 0, SEEK_SET );
|
---|
755 |
|
---|
756 | if (ScanParam( szString, pbPrBuffer ))
|
---|
757 | {
|
---|
758 | /*
|
---|
759 | ** skip the " character
|
---|
760 | */
|
---|
761 |
|
---|
762 | i = MovePast( pbPrBuffer, ':' );
|
---|
763 | *piOffset = cbBuffout;
|
---|
764 | i += SkipBlank(pbPrBuffer+i );
|
---|
765 |
|
---|
766 | /*
|
---|
767 | ** copies the string delimited by a blank with ist byte as length.
|
---|
768 | ** Strings are not null terminated
|
---|
769 | */
|
---|
770 | if (strncmp( pbPrBuffer + i, "Unknown", 7 ))
|
---|
771 | {
|
---|
772 |
|
---|
773 | j = CopyString( pbItemsBuffer + cbBuffout,
|
---|
774 | pbPrBuffer + i,
|
---|
775 | 80,
|
---|
776 | CSTR_NORMAL );
|
---|
777 | cbBuffout += j;
|
---|
778 | }
|
---|
779 | else
|
---|
780 | {
|
---|
781 | *piOffset = -1;
|
---|
782 | }
|
---|
783 | }
|
---|
784 | else
|
---|
785 | {
|
---|
786 | /*
|
---|
787 | ** Null pointer
|
---|
788 | */
|
---|
789 | *piOffset = -1;
|
---|
790 | }
|
---|
791 | }
|
---|
792 |
|
---|
793 | /*****************************************************************************\
|
---|
794 | **
|
---|
795 | ** FUNCTION TrimString
|
---|
796 | **
|
---|
797 | ** Delete trailing whitespace of string
|
---|
798 | **
|
---|
799 | \*****************************************************************************/
|
---|
800 |
|
---|
801 | static
|
---|
802 | void TrimString ( PSZ str )
|
---|
803 | {
|
---|
804 | if( str == NULL || *str == 0 ) return;
|
---|
805 |
|
---|
806 | while( (*str) !=0 ) str++; // find the end of the string
|
---|
807 | str--; // get to last character (step over 0)
|
---|
808 | while( isblank(*str) ) str--; // see if the character is blank, keep backstepping
|
---|
809 | str++; // step over non-blank, get to last blank
|
---|
810 | *str = 0; // cut the whitespace off
|
---|
811 | }
|
---|
812 |
|
---|
813 | /*****************************************************************************\
|
---|
814 | **
|
---|
815 | ** FUNCTION NameToIndex
|
---|
816 | **
|
---|
817 | ** Will look up form in table and put index in PPB. Adds form if not there
|
---|
818 | **
|
---|
819 | \*****************************************************************************/
|
---|
820 |
|
---|
821 | SHORT NameToIndex( VOID )
|
---|
822 | {
|
---|
823 | SHORT i;
|
---|
824 | SHORT sNameLen;
|
---|
825 | CHAR acFormName[MAX_FORM_SIZE+1]; /* Buffer for found form name */
|
---|
826 | PCH pFormName;
|
---|
827 |
|
---|
828 | /*
|
---|
829 | */
|
---|
830 |
|
---|
831 | sNameLen = CopyString( acFormName,
|
---|
832 | pbPrBuffer,
|
---|
833 | MAX_FORM_SIZE,
|
---|
834 | CSTR_NORMAL );
|
---|
835 | acFormName[MAX_PSIZE-1] = '\0'; /* For now limit to 64 char */
|
---|
836 | pFormName = acFormName;
|
---|
837 |
|
---|
838 |
|
---|
839 | /* find form in table */
|
---|
840 |
|
---|
841 | for ( i = 0; i < sFormCount; i++ )
|
---|
842 | {
|
---|
843 | if ( !strcmp( pFormName, pFormTable[i] ) )
|
---|
844 | break ; /* Found - stop loop */
|
---|
845 | }
|
---|
846 |
|
---|
847 | /* Warn if about to overflow table */
|
---|
848 | if ( sFormCount == 63 )
|
---|
849 | {
|
---|
850 | printf( "[WARNING: Too many form names]\n" );
|
---|
851 | i = 0; /* set to first form */
|
---|
852 | }
|
---|
853 |
|
---|
854 | if ( i >= sFormCount )
|
---|
855 | { /* Couldn't find it so add to table */
|
---|
856 | pFormTable[ sFormCount ] = (PCH)malloc( strlen( pFormName ) + 1 );
|
---|
857 | strcpy( pFormTable[ sFormCount ], pFormName );
|
---|
858 | i = sFormCount++;
|
---|
859 | }
|
---|
860 |
|
---|
861 | *(PSHORT)(pbItemsBuffer+cbBuffout) = i;
|
---|
862 |
|
---|
863 | cbBuffout += sizeof(SHORT);
|
---|
864 |
|
---|
865 | return sNameLen;
|
---|
866 | }
|
---|
867 |
|
---|
868 | /*****************************************************************************\
|
---|
869 | **
|
---|
870 | ** FUNCTION ProcessFormTable
|
---|
871 | **
|
---|
872 | ** Writes out the form table and index
|
---|
873 | **
|
---|
874 | \*****************************************************************************/
|
---|
875 |
|
---|
876 | VOID ProcessFormTable( VOID )
|
---|
877 | {
|
---|
878 | SHORT i;
|
---|
879 | LONG lIndexTable[64];
|
---|
880 | //PUI_BLOCK pBlock;NOTUSED
|
---|
881 | //INT iNumOfPages; NOTUSED
|
---|
882 | //INT iNumOfPageRegions; NOTUSED
|
---|
883 |
|
---|
884 | #if 0
|
---|
885 | ///*
|
---|
886 | //** Do a sanity check
|
---|
887 | //*/
|
---|
888 | //if ( desPpd.desPage.iCmpgpairs != sFormCount ||
|
---|
889 | // desPpd.desPage.iDmpgpairs != sFormCount ||
|
---|
890 | // desPpd.desPage.iImgpgpairs != sFormCount )
|
---|
891 | //{
|
---|
892 | // printf( "WARNING - Mismatched forms counts: PageRegion %d, PaperDim %d, "
|
---|
893 | // "ImageableArea %d, Total Count %d\n", desPpd.desPage.iCmpgpairs,
|
---|
894 | // desPpd.desPage.iDmpgpairs, desPpd.desPage.iImgpgpairs, sFormCount );
|
---|
895 | //}
|
---|
896 | #endif
|
---|
897 |
|
---|
898 | desPpd.desForms.usFormCount = sFormCount; /* store form count */
|
---|
899 | desPpd.desForms.ofsFormTable = cbBuffout; /* store start of form table */
|
---|
900 |
|
---|
901 | /* Write out the table - it's regular null term strings */
|
---|
902 | for ( i = 0; i < sFormCount; i++ )
|
---|
903 | {
|
---|
904 | PCHAR p;
|
---|
905 | INT j;
|
---|
906 | INT iLen;
|
---|
907 |
|
---|
908 | lIndexTable[i] = cbBuffout; /* Keep track of where each form goes */
|
---|
909 | // strcpy( pbItemsBuffer + cbBuffout, pFormTable[ i ] );
|
---|
910 | p = pFormTable[i];
|
---|
911 | iLen = strlen( p );
|
---|
912 | *(p + iLen) = '"'; //Replace null term with quote
|
---|
913 | j = CopyInQuote( pbItemsBuffer + cbBuffout, p, FALSE, COMPRESS);
|
---|
914 | iShrinkage += ( iLen + 1 ) - j; //J includes null term
|
---|
915 |
|
---|
916 |
|
---|
917 | free( pFormTable[ i ] );
|
---|
918 | // cbBuffout += strlen( pFormTable[ i ] ) + 1;
|
---|
919 | cbBuffout += j;
|
---|
920 | }
|
---|
921 |
|
---|
922 | desPpd.desForms.ofsFormIndex = cbBuffout; /* store start of index table */
|
---|
923 |
|
---|
924 | for ( i = 0; i < sFormCount; i++ )
|
---|
925 | {
|
---|
926 | *(PLONG)(pbItemsBuffer+cbBuffout) = lIndexTable[ i ];
|
---|
927 | cbBuffout += sizeof(LONG);
|
---|
928 | }
|
---|
929 |
|
---|
930 | }
|
---|
931 |
|
---|
932 | /*****************************************************************************\
|
---|
933 | **
|
---|
934 | ** FUNCTION DoDefaultForm
|
---|
935 | **
|
---|
936 | ** Converts the default string found by the old method to the index of a form.
|
---|
937 | ** This means that desPpd.desPage.ofsDfpgsz is NOT an offset but an index value
|
---|
938 | **
|
---|
939 | \*****************************************************************************/
|
---|
940 |
|
---|
941 | VOID DoDefaultForm( VOID )
|
---|
942 | {
|
---|
943 | PBYTE ptr;
|
---|
944 | PBYTE pImageableArea;
|
---|
945 | SHORT sLen;
|
---|
946 | SHORT i;
|
---|
947 | SHORT j;
|
---|
948 | PCH pchSlash;
|
---|
949 | SHORT sFirstForm;
|
---|
950 |
|
---|
951 |
|
---|
952 | /* if value -1 no default form so use the first form */
|
---|
953 | if ( desPpd.desPage.ofsDfpgsz == -1 )
|
---|
954 | {
|
---|
955 | desPpd.desPage.ofsDfpgsz = 0;
|
---|
956 | printf( "[INFO: No default form]\n" );
|
---|
957 | return;
|
---|
958 | }
|
---|
959 |
|
---|
960 | ptr = pbItemsBuffer + desPpd.desPage.ofsDfpgsz;
|
---|
961 | sLen = strlen( ptr );
|
---|
962 |
|
---|
963 | /* Point to imageable area */
|
---|
964 | pImageableArea = pbItemsBuffer + desPpd.desPage.ofsImgblPgsz;
|
---|
965 | sFirstForm = *((PSHORT)pImageableArea);
|
---|
966 |
|
---|
967 | for ( j = 0; j < desPpd.desPage.iImgpgpairs; j++ )
|
---|
968 | {
|
---|
969 |
|
---|
970 | i = *((PSHORT)pImageableArea);
|
---|
971 | pImageableArea += sizeof( SHORT ) * 5;
|
---|
972 |
|
---|
973 | /*
|
---|
974 | ** If Xlate string, block it by temp replacing slash with zero
|
---|
975 | */
|
---|
976 | if ( ( pchSlash = strchr( pFormTable[i], '/' ) ) != 0 )
|
---|
977 | {
|
---|
978 | *pchSlash = 0;
|
---|
979 | }
|
---|
980 |
|
---|
981 | if ( !strcmp( (PCH)ptr, pFormTable[i] ) )
|
---|
982 | {
|
---|
983 | if ( pchSlash )
|
---|
984 | {
|
---|
985 | *pchSlash = '/';
|
---|
986 | }
|
---|
987 | break;
|
---|
988 | }
|
---|
989 | if ( pchSlash )
|
---|
990 | {
|
---|
991 | *pchSlash = '/';
|
---|
992 | }
|
---|
993 | }
|
---|
994 |
|
---|
995 | if ( j >= desPpd.desPage.iImgpgpairs ) /* Not found, make it zero */
|
---|
996 | {
|
---|
997 | i = sFirstForm;
|
---|
998 | printf( "[INFO: Default form is %s]\n", ptr );
|
---|
999 | }
|
---|
1000 |
|
---|
1001 | desPpd.desPage.ofsDfpgsz = i;
|
---|
1002 |
|
---|
1003 | cbBuffout -= sLen + 1; /* Erase the name */
|
---|
1004 |
|
---|
1005 | return;
|
---|
1006 | }
|
---|
1007 |
|
---|
1008 |
|
---|
1009 | /***************************************************************************
|
---|
1010 | *
|
---|
1011 | * FUNCTION NAME = FormPpd
|
---|
1012 | *
|
---|
1013 | * DESCRIPTION = To form a binary output segment out of ppd file.
|
---|
1014 | * Returns false if any error encountered in input
|
---|
1015 | * file format else returns True.
|
---|
1016 | *
|
---|
1017 | * INPUT = NONE.
|
---|
1018 | * OUTPUT = NONE.
|
---|
1019 | *
|
---|
1020 | * RETURN-NORMAL = NONE.
|
---|
1021 | * RETURN-ERROR = NONE.
|
---|
1022 | *
|
---|
1023 | ************************************************************************* */
|
---|
1024 |
|
---|
1025 | BOOL FormPpd(void)
|
---|
1026 | {
|
---|
1027 | #define NOT_SELECTED -1
|
---|
1028 | /*
|
---|
1029 | ** D74609
|
---|
1030 | */
|
---|
1031 | /* register int i; */
|
---|
1032 | int i;
|
---|
1033 | int j, k;
|
---|
1034 | char *p, *q;
|
---|
1035 | char *px;
|
---|
1036 | char scratch[64 + 1];
|
---|
1037 | //int iResType; /* QMS fix */
|
---|
1038 |
|
---|
1039 | PUI_BLOCK pBlock;
|
---|
1040 | PUI_BLOCK pTempBlock;
|
---|
1041 | INT y;
|
---|
1042 |
|
---|
1043 | /*
|
---|
1044 | ** Zero out structure
|
---|
1045 | */
|
---|
1046 |
|
---|
1047 | p = (char *) desPpd.stUIList.pBlockList;
|
---|
1048 | q = (char *) desPpd.stUICList.puicBlockList;
|
---|
1049 | memset( &desPpd, 0, sizeof( desPpd ) );
|
---|
1050 | desPpd.stUIList.pBlockList = (PUI_BLOCK) p;
|
---|
1051 | desPpd.stUICList.puicBlockList = (PUIC_BLOCK) q;
|
---|
1052 | memset( desPpd.stUIList.pBlockList, 0, 4000 );
|
---|
1053 |
|
---|
1054 | desPpd.desItems.ofsPswrd = -1;
|
---|
1055 |
|
---|
1056 | /*
|
---|
1057 | */
|
---|
1058 | /*
|
---|
1059 | ** For v4.2 PPDs, JCLBegin and JCLToPSInterpreter replaces
|
---|
1060 | ** InitPostScriptMode.
|
---|
1061 | */
|
---|
1062 | SaveCommand( szSearch[initstring], (short *) &desPpd.desItems.ofsInitString,
|
---|
1063 | COMPRESS);
|
---|
1064 | if (desPpd.desItems.ofsInitString == -1)
|
---|
1065 | {
|
---|
1066 | SaveCommand (szSearch[ JCLBegin ], (short *) &desPpd.desItems.ofsInitString,
|
---|
1067 | COMPRESS);
|
---|
1068 | /*
|
---|
1069 | ** Add a separate offset for the JCL to PS interpreter command. Do not
|
---|
1070 | ** append it to the *JCLBegin command. This is needed so if JCLResolution
|
---|
1071 | ** is used, this command converts the device back to Postscript.
|
---|
1072 | ** JCLResolution must be inserted between the JCLBegin and the
|
---|
1073 | ** JCL-to-PS commands.
|
---|
1074 | */
|
---|
1075 | SaveCommand( szSearch[ JCLToPSInterpreter ],
|
---|
1076 | (short *) &desPpd.desItems.ofsJCLToPS, COMPRESS);
|
---|
1077 | }
|
---|
1078 |
|
---|
1079 | /*
|
---|
1080 | */
|
---|
1081 | /*
|
---|
1082 | ** For v4.2PPDs, JCLEnd is the command that replaces TermPostScriptMode.
|
---|
1083 | */
|
---|
1084 | SaveCommand( szSearch[termstring], (short *) &desPpd.desItems.ofsTermString,
|
---|
1085 | COMPRESS);
|
---|
1086 | if (desPpd.desItems.ofsTermString == -1)
|
---|
1087 | {
|
---|
1088 | SaveCommand( szSearch[ JCLEnd ], (short *) &desPpd.desItems.ofsTermString,
|
---|
1089 | COMPRESS);
|
---|
1090 | }
|
---|
1091 |
|
---|
1092 | /*
|
---|
1093 | ** scan and read the throughput parameter
|
---|
1094 | */
|
---|
1095 | fbseek( &fbIn, (long)0, SEEK_SET );
|
---|
1096 |
|
---|
1097 | if (ScanParam( szSearch[throughput], pbPrBuffer ))
|
---|
1098 | {
|
---|
1099 | /*
|
---|
1100 | ** skip the " character
|
---|
1101 | */
|
---|
1102 |
|
---|
1103 | i = MovePast( pbPrBuffer, '"' );
|
---|
1104 | desPpd.desItems.iPpm = (short) atoi( pbPrBuffer + i );
|
---|
1105 | }
|
---|
1106 | else
|
---|
1107 | {
|
---|
1108 | /*
|
---|
1109 | ** Null value
|
---|
1110 | */
|
---|
1111 | desPpd.desItems.iPpm = -1;
|
---|
1112 | }
|
---|
1113 |
|
---|
1114 | /*
|
---|
1115 | ** scan and read the printer memory parameter
|
---|
1116 | */
|
---|
1117 | fbseek( &fbIn, (long)0, SEEK_SET );
|
---|
1118 |
|
---|
1119 | if (ScanParam( szSearch[freevm], pbPrBuffer ))
|
---|
1120 | {
|
---|
1121 | /*
|
---|
1122 | ** skip the " character
|
---|
1123 | */
|
---|
1124 | i = MovePast( pbPrBuffer, '"' );
|
---|
1125 | desPpd.desItems.lFreeVM = atol( pbPrBuffer + i );
|
---|
1126 | }
|
---|
1127 | else
|
---|
1128 | {
|
---|
1129 | /*
|
---|
1130 | ** Null value
|
---|
1131 | */
|
---|
1132 | desPpd.desItems.lFreeVM = (long) -1;
|
---|
1133 | }
|
---|
1134 |
|
---|
1135 | /*
|
---|
1136 | ** scan and read the PCFileName
|
---|
1137 | */
|
---|
1138 | desPpd.desItems.ofsPCFileName = cbBuffout;
|
---|
1139 | SaveCommand( szSearch[PCFileName], (short *) &desPpd.desItems.ofsPCFileName,
|
---|
1140 | NOCOMPRESS);
|
---|
1141 |
|
---|
1142 | /*
|
---|
1143 | ** scan and read printer type classified under product name
|
---|
1144 | */
|
---|
1145 |
|
---|
1146 | desPpd.desItems.ofsPrType = cbBuffout;
|
---|
1147 | desPpd.desItems.ofsPrType = -1;
|
---|
1148 |
|
---|
1149 | /*
|
---|
1150 | ** scan and read printer name
|
---|
1151 | ** Try ShortNickName first
|
---|
1152 | */
|
---|
1153 | desPpd.desItems.ofsPrName = cbBuffout;
|
---|
1154 | SaveCommand( szSearch[shortnickname], (short *) &desPpd.desItems.ofsPrName,
|
---|
1155 | NOCOMPRESS);
|
---|
1156 |
|
---|
1157 | if ( desPpd.desItems.ofsPrName == -1 )
|
---|
1158 | {
|
---|
1159 | /*
|
---|
1160 | ** scan and read printer name
|
---|
1161 | ** Use NickName
|
---|
1162 | */
|
---|
1163 | desPpd.desItems.ofsPrName = cbBuffout;
|
---|
1164 | SaveCommand( szSearch[printername], (short *) &desPpd.desItems.ofsPrName,
|
---|
1165 | NOCOMPRESS);
|
---|
1166 | }
|
---|
1167 |
|
---|
1168 | TrimString( pbItemsBuffer + desPpd.desItems.ofsPrName );
|
---|
1169 |
|
---|
1170 | /*
|
---|
1171 | ** Make sure name is not too long
|
---|
1172 | */
|
---|
1173 | /*
|
---|
1174 | */
|
---|
1175 | if (strlen( pbItemsBuffer + desPpd.desItems.ofsPrName ) > NAME_LEN - 1)
|
---|
1176 | {
|
---|
1177 | printf( "[WARNING: Nickname too long, truncated]\n" );
|
---|
1178 | *(pbItemsBuffer + desPpd.desItems.ofsPrName + NAME_LEN - 1) = 0; // terminate the string
|
---|
1179 | }
|
---|
1180 |
|
---|
1181 | /*
|
---|
1182 | ** Move the Default resolution processing after the standard resolution
|
---|
1183 | ** processing. If no default resolution is provided, assign the default
|
---|
1184 | ** to the first resolution found.
|
---|
1185 | */
|
---|
1186 | /*
|
---|
1187 | ** scan and read default resolution
|
---|
1188 | */
|
---|
1189 | fbseek( &fbIn, (long)0, SEEK_SET );
|
---|
1190 |
|
---|
1191 | if (ScanParam( szSearch[defaultres], pbPrBuffer ))
|
---|
1192 | {
|
---|
1193 | /*
|
---|
1194 | ** skip the : character
|
---|
1195 | */
|
---|
1196 | i = MovePast( pbPrBuffer, ':' );
|
---|
1197 | desPpd.desItems.iResDpi = (short) atoi( pbPrBuffer + i );
|
---|
1198 | }
|
---|
1199 |
|
---|
1200 | /* If no default found try default JCL */
|
---|
1201 | if ( desPpd.desItems.iResDpi == 0 )
|
---|
1202 | {
|
---|
1203 | fbseek( &fbIn, (long)0, SEEK_SET );
|
---|
1204 | if (ScanParam( szSearch[defaultJCLRes], pbPrBuffer ))
|
---|
1205 | {
|
---|
1206 | i = MovePast( pbPrBuffer, ':' );
|
---|
1207 | desPpd.desItems.iResDpi = (short) atoi( pbPrBuffer + i );
|
---|
1208 | }
|
---|
1209 | }
|
---|
1210 |
|
---|
1211 | // beef up resolution
|
---|
1212 | if (desPpd.desItems.iResDpi == 0)
|
---|
1213 | {
|
---|
1214 | desPpd.desItems.iResDpi = 300;
|
---|
1215 | }
|
---|
1216 |
|
---|
1217 | /*
|
---|
1218 | ** scan and read screen frequency
|
---|
1219 | */
|
---|
1220 | fbseek( &fbIn, (long)0, SEEK_SET );
|
---|
1221 |
|
---|
1222 | if (ScanParam(szSearch[screenfreq], pbPrBuffer))
|
---|
1223 | {
|
---|
1224 | /*
|
---|
1225 | ** skip the : character
|
---|
1226 | */
|
---|
1227 |
|
---|
1228 | i = MovePast( pbPrBuffer, '"' );
|
---|
1229 | desPpd.desItems.lScrFreq = (long)(atof( pbPrBuffer + i) * 100.00 );
|
---|
1230 | }
|
---|
1231 | else
|
---|
1232 | {
|
---|
1233 | /*
|
---|
1234 | ** Null value
|
---|
1235 | */
|
---|
1236 | desPpd.desItems.lScrFreq = -1L;
|
---|
1237 | }
|
---|
1238 |
|
---|
1239 | /*
|
---|
1240 | ** To read the flag that indicates whether the device supports
|
---|
1241 | ** colour or not.
|
---|
1242 | */
|
---|
1243 | fbseek( &fbIn, (long)0, SEEK_SET );
|
---|
1244 |
|
---|
1245 | if (ScanParam( szSearch[colordevice], pbPrBuffer ))
|
---|
1246 | {
|
---|
1247 | /*
|
---|
1248 | ** skip the " character
|
---|
1249 | */
|
---|
1250 | i = MovePast( pbPrBuffer, ':' );
|
---|
1251 | i += SkipBlank( pbPrBuffer + i );
|
---|
1252 |
|
---|
1253 | if (!strnicmp("TRUE", pbPrBuffer+i, 4))
|
---|
1254 | {
|
---|
1255 | desPpd.desItems.fIsColorDevice = TRUE;
|
---|
1256 | }
|
---|
1257 | else
|
---|
1258 | {
|
---|
1259 | desPpd.desItems.fIsColorDevice = NONE;
|
---|
1260 | }
|
---|
1261 | }
|
---|
1262 | else
|
---|
1263 | {
|
---|
1264 | desPpd.desItems.fIsColorDevice = NONE;
|
---|
1265 | }
|
---|
1266 |
|
---|
1267 | /*
|
---|
1268 | ** To read the True or False value indicating whether the Postscript
|
---|
1269 | ** device has a built in file system.
|
---|
1270 | */
|
---|
1271 | fbseek( &fbIn, (long)0, SEEK_SET );
|
---|
1272 |
|
---|
1273 | if (ScanParam( szSearch[filesystem], pbPrBuffer ))
|
---|
1274 | {
|
---|
1275 | /*
|
---|
1276 | ** skip the " character
|
---|
1277 | */
|
---|
1278 | i = MovePast( pbPrBuffer, ':' );
|
---|
1279 | i += SkipBlank(pbPrBuffer + i );
|
---|
1280 |
|
---|
1281 | if (!strnicmp( "TRUE", pbPrBuffer + i, 4 ))
|
---|
1282 | {
|
---|
1283 | desPpd.desItems.fIsFileSystem = TRUE;
|
---|
1284 | }
|
---|
1285 | else
|
---|
1286 | {
|
---|
1287 | desPpd.desItems.fIsFileSystem = FALSE;
|
---|
1288 | }
|
---|
1289 | }
|
---|
1290 | else
|
---|
1291 | {
|
---|
1292 | desPpd.desItems.fIsFileSystem = FALSE;
|
---|
1293 | }
|
---|
1294 |
|
---|
1295 | /*
|
---|
1296 | ** To read the Postscript sequence that will perform a soft
|
---|
1297 | ** restart of the printer.
|
---|
1298 | */
|
---|
1299 | desPpd.desItems.ofsReset = -1;
|
---|
1300 |
|
---|
1301 | /*
|
---|
1302 | ** Read the appropriate postscript sequence to exit the job server loop
|
---|
1303 | */
|
---|
1304 | desPpd.desItems.ofsExitserver = -1;
|
---|
1305 |
|
---|
1306 | /*
|
---|
1307 | ** Read the halftone screen angle
|
---|
1308 | */
|
---|
1309 | fbseek( &fbIn, (long)0, SEEK_SET );
|
---|
1310 |
|
---|
1311 | if (ScanParam( szSearch[screenangle], pbPrBuffer ))
|
---|
1312 | {
|
---|
1313 | /*
|
---|
1314 | ** skip the : character
|
---|
1315 | */
|
---|
1316 | i = MovePast( pbPrBuffer, '"' );
|
---|
1317 | desPpd.desItems.iScreenAngle = (long)(atof( pbPrBuffer + i) * 100.0 );
|
---|
1318 | }
|
---|
1319 | else
|
---|
1320 | {
|
---|
1321 | /*
|
---|
1322 | ** Null value
|
---|
1323 | */
|
---|
1324 | desPpd.desItems.iScreenAngle = -1L;
|
---|
1325 | }
|
---|
1326 |
|
---|
1327 | /*
|
---|
1328 | ** Read the values indicating whether the device supports
|
---|
1329 | ** infinitely variable paper sizes
|
---|
1330 | */
|
---|
1331 |
|
---|
1332 |
|
---|
1333 | /* */
|
---|
1334 |
|
---|
1335 | desPpd.desPage.ofsCustomPageSize = -1;
|
---|
1336 | //
|
---|
1337 | fbseek( &fbIn, (long)0, SEEK_SET );
|
---|
1338 | if (ScanParam( szSearch[CustomPageSize], pbPrBuffer ))
|
---|
1339 | {
|
---|
1340 | if (!strnicmp( "TRUE", pbPrBuffer, strlen("TRUE") ))
|
---|
1341 | {
|
---|
1342 | desPpd.desPage.ofsCustomPageSize = cbBuffout;
|
---|
1343 | i = MovePast( pbPrBuffer, '"' );
|
---|
1344 | j = CopyInQuote( pbItemsBuffer+cbBuffout, pbPrBuffer+i, FALSE, COMPRESS );
|
---|
1345 | cbBuffout += j;
|
---|
1346 | }
|
---|
1347 | }
|
---|
1348 | //
|
---|
1349 | ///
|
---|
1350 | desPpd.desPage.iCustomPageSizeMinWidth = NOT_SELECTED;
|
---|
1351 | desPpd.desPage.iCustomPageSizeMaxWidth = NOT_SELECTED;
|
---|
1352 | desPpd.desPage.iCustomPageSizeMinHeight = NOT_SELECTED;
|
---|
1353 | desPpd.desPage.iCustomPageSizeMaxHeight = NOT_SELECTED;
|
---|
1354 | ///
|
---|
1355 | fbseek( &fbIn, (long)0, SEEK_SET );
|
---|
1356 | while(ScanParam(szSearch[ParamCustomPageSize],pbPrBuffer))
|
---|
1357 | {
|
---|
1358 | if(!strnicmp("Width",pbPrBuffer,strlen("Width")))
|
---|
1359 | {
|
---|
1360 | if(strstr(pbPrBuffer,"points") != NULL)
|
---|
1361 | {
|
---|
1362 | px = strstr(pbPrBuffer,"points") + strlen("points");
|
---|
1363 | i = SkipBlank(px);
|
---|
1364 | px += i;
|
---|
1365 | desPpd.desPage.iCustomPageSizeMinWidth = (SHORT)atoi(px);
|
---|
1366 | i = MovePast( px, ' ' );
|
---|
1367 | px += i;
|
---|
1368 | desPpd.desPage.iCustomPageSizeMaxWidth = (SHORT)atoi(px);
|
---|
1369 | }
|
---|
1370 | }
|
---|
1371 | if(!strnicmp("Height",pbPrBuffer,strlen("Height")))
|
---|
1372 | {
|
---|
1373 | if(strstr(pbPrBuffer,"points") != NULL)
|
---|
1374 | {
|
---|
1375 | px = strstr(pbPrBuffer,"points") + strlen("points");
|
---|
1376 | i = SkipBlank(px);
|
---|
1377 | px += i;
|
---|
1378 | desPpd.desPage.iCustomPageSizeMinHeight = atoi(px);
|
---|
1379 | i = MovePast( px, ' ' );
|
---|
1380 | px += i;
|
---|
1381 | desPpd.desPage.iCustomPageSizeMaxHeight = atoi(px);
|
---|
1382 | }
|
---|
1383 | }
|
---|
1384 | if(desPpd.desPage.iCustomPageSizeMinWidth != NOT_SELECTED &&
|
---|
1385 | desPpd.desPage.iCustomPageSizeMinHeight != NOT_SELECTED )break;
|
---|
1386 | }
|
---|
1387 | if (
|
---|
1388 | desPpd.desPage.ofsCustomPageSize != NOT_SELECTED &&
|
---|
1389 | desPpd.desPage.iCustomPageSizeMinWidth != NOT_SELECTED &&
|
---|
1390 | desPpd.desPage.iCustomPageSizeMaxWidth != NOT_SELECTED &&
|
---|
1391 | desPpd.desPage.iCustomPageSizeMinHeight != NOT_SELECTED &&
|
---|
1392 | desPpd.desPage.iCustomPageSizeMaxHeight != NOT_SELECTED
|
---|
1393 | )
|
---|
1394 | {
|
---|
1395 | desPpd.desPage.fIsVariablePaper = FALSE;
|
---|
1396 | fbseek( &fbIn, (long)0, SEEK_SET );
|
---|
1397 |
|
---|
1398 | if (ScanParam( szSearch[variablepaper], pbPrBuffer ))
|
---|
1399 | {
|
---|
1400 | /*
|
---|
1401 | ** skip the " character
|
---|
1402 | */
|
---|
1403 | i = MovePast( pbPrBuffer, ':' );
|
---|
1404 | i += SkipBlank( pbPrBuffer + i );
|
---|
1405 |
|
---|
1406 | if (!strnicmp( "TRUE", pbPrBuffer + i, 4 ))
|
---|
1407 | {
|
---|
1408 | desPpd.desPage.fIsVariablePaper = TRUE;
|
---|
1409 | }
|
---|
1410 | else
|
---|
1411 | {
|
---|
1412 | desPpd.desPage.fIsVariablePaper = FALSE;
|
---|
1413 | }
|
---|
1414 | }
|
---|
1415 | else
|
---|
1416 | {
|
---|
1417 | desPpd.desPage.fIsVariablePaper = TRUE;
|
---|
1418 | }
|
---|
1419 | }
|
---|
1420 | else
|
---|
1421 | {
|
---|
1422 | desPpd.desPage.fIsVariablePaper = FALSE;
|
---|
1423 | }
|
---|
1424 |
|
---|
1425 | fbseek( &fbIn, (long)0, SEEK_SET );
|
---|
1426 |
|
---|
1427 |
|
---|
1428 |
|
---|
1429 |
|
---|
1430 |
|
---|
1431 |
|
---|
1432 | /*
|
---|
1433 | ** Read the default imageable area paper type .
|
---|
1434 | */
|
---|
1435 | desPpd.desPage.ofsDefimagearea = -1;
|
---|
1436 |
|
---|
1437 | /*
|
---|
1438 | ** Read the keyword for the Default paper dimension.
|
---|
1439 | ** This value should always be letter
|
---|
1440 | */
|
---|
1441 | desPpd.desPage.ofsDefpaperdim = -1;
|
---|
1442 |
|
---|
1443 | /*
|
---|
1444 | ** This gives the font name which is the default font provided by
|
---|
1445 | ** findfont if the requested font is not available
|
---|
1446 | */
|
---|
1447 | SaveString( szSearch[defaultfont], (short *)&desPpd.desFonts.ofsDeffont );
|
---|
1448 |
|
---|
1449 | /*
|
---|
1450 | ** If no default font provided make it Courier
|
---|
1451 | */
|
---|
1452 | if (desPpd.desFonts.ofsDeffont == -1)
|
---|
1453 | {
|
---|
1454 | /*
|
---|
1455 | ** Copy the default font (no ending null)
|
---|
1456 | */
|
---|
1457 | desPpd.desFonts.ofsDeffont = cbBuffout;
|
---|
1458 | *(pbItemsBuffer + cbBuffout) = sizeof( acDefFont ) - 1;
|
---|
1459 | cbBuffout++;
|
---|
1460 |
|
---|
1461 | for (i = 0; i < sizeof( acDefFont )-1; i++, cbBuffout++)
|
---|
1462 | {
|
---|
1463 | *(pbItemsBuffer + cbBuffout) = acDefFont[i];
|
---|
1464 | }
|
---|
1465 | }
|
---|
1466 |
|
---|
1467 | /*
|
---|
1468 | ** Read the keyword for the default output order which can be normal
|
---|
1469 | ** or reverse
|
---|
1470 | */
|
---|
1471 |
|
---|
1472 | fbseek( &fbIn, (long)0, SEEK_SET );
|
---|
1473 |
|
---|
1474 | if (ScanParam( szSearch[defoutputorder], pbPrBuffer))
|
---|
1475 | {
|
---|
1476 | /*
|
---|
1477 | ** skip the " character
|
---|
1478 | */
|
---|
1479 | i = MovePast( pbPrBuffer, ':' );
|
---|
1480 | i += SkipBlank( pbPrBuffer + i );
|
---|
1481 |
|
---|
1482 | if (!strnicmp( "NORMAL", pbPrBuffer + i, 6))
|
---|
1483 | {
|
---|
1484 | desPpd.desOutbins.fIsDefoutorder = NORMAL;
|
---|
1485 | }
|
---|
1486 | else
|
---|
1487 | {
|
---|
1488 | desPpd.desOutbins.fIsDefoutorder = REVERSE;
|
---|
1489 | }
|
---|
1490 | }
|
---|
1491 | else
|
---|
1492 | {
|
---|
1493 | desPpd.desOutbins.fIsDefoutorder = REVERSE;
|
---|
1494 | }
|
---|
1495 |
|
---|
1496 | /*
|
---|
1497 | ** Read the invocation strings for selecting normal or
|
---|
1498 | ** reverse output order
|
---|
1499 | */
|
---|
1500 | desPpd.desOutbins.ofsOrdernormal = -1;
|
---|
1501 | desPpd.desOutbins.ofsOrderreverse = -1;
|
---|
1502 | fbseek( &fbIn, (long)0, SEEK_SET );
|
---|
1503 |
|
---|
1504 | while (ScanParam( szSearch[outputorder], pbPrBuffer))
|
---|
1505 | {
|
---|
1506 | if (!strnicmp( "NORMAL", pbPrBuffer, 4))
|
---|
1507 | {
|
---|
1508 | desPpd.desOutbins.ofsOrdernormal = cbBuffout;
|
---|
1509 | }
|
---|
1510 | else
|
---|
1511 | {
|
---|
1512 | desPpd.desOutbins.ofsOrderreverse = cbBuffout;
|
---|
1513 | }
|
---|
1514 |
|
---|
1515 | /*
|
---|
1516 | ** skip the " character
|
---|
1517 | */
|
---|
1518 | i = MovePast( pbPrBuffer, '"' );
|
---|
1519 |
|
---|
1520 | /*
|
---|
1521 | ** copies the string delimited by a blank or quote with ist byte
|
---|
1522 | ** as length. Strings are not null terminated
|
---|
1523 | */
|
---|
1524 | j = CopyInQuote( pbItemsBuffer+cbBuffout, pbPrBuffer+i, FALSE,
|
---|
1525 | COMPRESS );
|
---|
1526 | cbBuffout += j;
|
---|
1527 | }
|
---|
1528 |
|
---|
1529 | /*
|
---|
1530 | ** Read the complete procedure of Transfer Normalized & inverse
|
---|
1531 | */
|
---|
1532 | SaveProcedure( szSearch[transfernor], (short *)&desPpd.desItems.ofsTransferNor );
|
---|
1533 | SaveProcedure( szSearch[transferinv], (short *)&desPpd.desItems.ofsTransferInv );
|
---|
1534 |
|
---|
1535 | /*
|
---|
1536 | ** Read the invocation strings for various output bins
|
---|
1537 | */
|
---|
1538 | fbseek( &fbIn, (long)0, SEEK_SET );
|
---|
1539 | k = 0;
|
---|
1540 |
|
---|
1541 | desPpd.desOutbins.iOutbinpairs = k;
|
---|
1542 | desPpd.desOutbins.ofsCmOutbins = -1;
|
---|
1543 |
|
---|
1544 | /*
|
---|
1545 | ** Insert the section of code that searches for the "*LanguageLevel"
|
---|
1546 | ** PostScript command.
|
---|
1547 | */
|
---|
1548 | fbseek( &fbIn, (long)0, SEEK_SET );
|
---|
1549 |
|
---|
1550 | if (ScanParam( szSearch[LanguageLevel], pbPrBuffer ))
|
---|
1551 | {
|
---|
1552 | /*
|
---|
1553 | ** Skip past the colon, spaces, and the first quote, until a numeric
|
---|
1554 | ** character is found. The reason for the loop below is, even though
|
---|
1555 | ** the PPD specs require the PS level to be in quotes, this is not the
|
---|
1556 | ** case for all PPDs. Since this compiler cannot assume that the
|
---|
1557 | ** level number is in quotes, it will have to continue to increment
|
---|
1558 | ** the offset until the first numeric character is found.
|
---|
1559 | */
|
---|
1560 | i = 0;
|
---|
1561 | while (*(pbPrBuffer + i) < '0' || *(pbPrBuffer + i) > '9')
|
---|
1562 | {
|
---|
1563 | i++;
|
---|
1564 | }
|
---|
1565 |
|
---|
1566 | /*
|
---|
1567 | ** Save the language level offset.
|
---|
1568 | */
|
---|
1569 | desPpd.desItems.usLanguageLevel = atoi( pbPrBuffer + i );
|
---|
1570 | }
|
---|
1571 | else
|
---|
1572 | {
|
---|
1573 | desPpd.desItems.usLanguageLevel = 1;
|
---|
1574 | }
|
---|
1575 | /*
|
---|
1576 | */
|
---|
1577 |
|
---|
1578 |
|
---|
1579 | fbseek( &fbIn, (long)0, SEEK_SET );
|
---|
1580 | memset( &UIFileGroup, 0, sizeof( UIFileGroup ) );
|
---|
1581 | while (ScanParam( szSearch[ OpenGroup ], pbPrBuffer ))
|
---|
1582 | {
|
---|
1583 | i = MovePast( pbPrBuffer, ' ' );
|
---|
1584 | if (!strnicmp( "InstallableOptions", pbPrBuffer + i, 18))
|
---|
1585 | {
|
---|
1586 | UIFileGroup.usFileStart = fbtell( &fbIn ); /* took out the cast, since it's the same size */
|
---|
1587 |
|
---|
1588 | if (ScanParam( szSearch[ CloseGroup ], pbPrBuffer ))
|
---|
1589 | {
|
---|
1590 | UIFileGroup.usFileEnd = fbtell( &fbIn ); /* took out the cast, since it's the same size */
|
---|
1591 | }
|
---|
1592 | }
|
---|
1593 | }
|
---|
1594 | ProcessUIList( );
|
---|
1595 | ProcessCmdsAsUIs( );
|
---|
1596 |
|
---|
1597 | /*
|
---|
1598 | ** count of pairs formed
|
---|
1599 | */
|
---|
1600 | k = 0;
|
---|
1601 | desPpd.desPage.ofsDimxyPgsz = cbBuffout;
|
---|
1602 |
|
---|
1603 | fbseek( &fbIn, (long)0, SEEK_SET );
|
---|
1604 | if ((pBlock = QueryBlockFromKeyword( &desPpd.stUIList, pbItemsBuffer,
|
---|
1605 | UINAME_PAGESIZE, NULL )) != NULL)
|
---|
1606 | {
|
---|
1607 | while (ScanParam( szSearch[pagesizelist], pbPrBuffer ))
|
---|
1608 | {
|
---|
1609 | y = 0;
|
---|
1610 | i = 0;
|
---|
1611 | while (*(pbPrBuffer + i) != ' ' && *(pbPrBuffer + i) != ':' &&
|
---|
1612 | *(pbPrBuffer + i) != '/')
|
---|
1613 | {
|
---|
1614 | scratch[ y++ ] = *(pbPrBuffer + i++);
|
---|
1615 | }
|
---|
1616 | scratch[ y ] = 0;
|
---|
1617 |
|
---|
1618 | pTempBlock = pBlock;
|
---|
1619 | QueryEntryFromOption( (PBYTE) pbItemsBuffer, pTempBlock,
|
---|
1620 | (PBYTE) scratch, (PINT) &y );
|
---|
1621 | *((PSHORT) (pbItemsBuffer + cbBuffout)) = (SHORT) y;
|
---|
1622 | cbBuffout += 2;
|
---|
1623 |
|
---|
1624 | /*
|
---|
1625 | ** warn if formname longer than 31
|
---|
1626 | */
|
---|
1627 | if (i > MAX_PSIZE - 1)
|
---|
1628 | {
|
---|
1629 | strncpy( scratch, pbItemsBuffer + cbBuffout - i, i );
|
---|
1630 | scratch[i] = (char) 0;
|
---|
1631 | printf( "[WARNING: %s, Formname > MaxPaperSize (%d)]\n", scratch, i );
|
---|
1632 | }
|
---|
1633 |
|
---|
1634 | if ( *(pbPrBuffer + i) == '/' )
|
---|
1635 | {
|
---|
1636 | i += MovePast( pbPrBuffer+i, ':' );
|
---|
1637 | }
|
---|
1638 | /*
|
---|
1639 | ** skip the " character
|
---|
1640 | */
|
---|
1641 | i += MovePast( pbPrBuffer+i, '"' );
|
---|
1642 | j = atoRound( pbPrBuffer + i );
|
---|
1643 |
|
---|
1644 | /*
|
---|
1645 | ** copies the x-size into items buffer
|
---|
1646 | */
|
---|
1647 | memcpy( (pbItemsBuffer + cbBuffout), (char *) &j, sizeof( SHORT ) );
|
---|
1648 | cbBuffout += sizeof(SHORT );
|
---|
1649 | i += SkipNumber( pbPrBuffer + i );
|
---|
1650 | j = atoRound( pbPrBuffer + i );
|
---|
1651 |
|
---|
1652 | /*
|
---|
1653 | ** copies the y-size into items buffer
|
---|
1654 | */
|
---|
1655 | memcpy( (pbItemsBuffer + cbBuffout), (char *) &j, sizeof( SHORT ) );
|
---|
1656 | cbBuffout += sizeof( SHORT );
|
---|
1657 | k++;
|
---|
1658 | }
|
---|
1659 | desPpd.desPage.iDmpgpairs = k;
|
---|
1660 |
|
---|
1661 | /*
|
---|
1662 | ** count of pairs formed
|
---|
1663 | */
|
---|
1664 | fbseek( &fbIn, (long)0, SEEK_SET );
|
---|
1665 | k = 0;
|
---|
1666 | desPpd.desPage.ofsImgblPgsz = cbBuffout;
|
---|
1667 |
|
---|
1668 | /*
|
---|
1669 | ** D74609
|
---|
1670 | ** *ImageableArea: value1, value2, value3, value4
|
---|
1671 | ** value1 and value2 must be rounded up.
|
---|
1672 | ** value3 and value4 must be truncated.
|
---|
1673 | */
|
---|
1674 | while (ScanParam( szSearch[imageablearea], pbPrBuffer))
|
---|
1675 | {
|
---|
1676 | CHAR achOldSuffix[ 64 + 1 ];
|
---|
1677 | PCHAR pcSlash;
|
---|
1678 |
|
---|
1679 | j = 0;
|
---|
1680 | y = 0;
|
---|
1681 | i = 0;
|
---|
1682 | while (*(pbPrBuffer + i) != ':' && *(pbPrBuffer + i) != '/')
|
---|
1683 | {
|
---|
1684 | scratch[ y++ ] = *(pbPrBuffer + i++);
|
---|
1685 | }
|
---|
1686 | scratch[ y ] = 0;
|
---|
1687 |
|
---|
1688 | /* See if there is a translation string */
|
---|
1689 |
|
---|
1690 | if ( *( pbPrBuffer + i ) == '/' )
|
---|
1691 | {
|
---|
1692 | pcSlash = pbPrBuffer + (i++) + 1; /* don't need slash */
|
---|
1693 | while( *pcSlash != ':' ) /* There is so copy it over */
|
---|
1694 | {
|
---|
1695 | achOldSuffix[ j++ ] = *(pcSlash++);
|
---|
1696 | i++;
|
---|
1697 | }
|
---|
1698 | }
|
---|
1699 | achOldSuffix[ j ] = '\0'; /* If no slash OldSuffix will be null */
|
---|
1700 |
|
---|
1701 | pTempBlock = pBlock;
|
---|
1702 | QueryEntryFromOption( (PBYTE) pbItemsBuffer, pTempBlock,
|
---|
1703 | (PBYTE) scratch, (PINT) &y );
|
---|
1704 | *((PSHORT) (pbItemsBuffer + cbBuffout)) = (SHORT) y;
|
---|
1705 | cbBuffout += 2;
|
---|
1706 | /*
|
---|
1707 | ** Bottom left X corner.
|
---|
1708 | ** Round up to nearest integer.
|
---|
1709 | */
|
---|
1710 | roundImgAreaVals( &i, ROUND_FLOAT, '"' );
|
---|
1711 |
|
---|
1712 | /*
|
---|
1713 | ** Bottom left y corner.
|
---|
1714 | ** Round up to nearest integer.
|
---|
1715 | */
|
---|
1716 | roundImgAreaVals( &i, ROUND_FLOAT, ' ' );
|
---|
1717 |
|
---|
1718 | /*
|
---|
1719 | ** Top right x corner.
|
---|
1720 | ** Truncate floating point value.
|
---|
1721 | */
|
---|
1722 | roundImgAreaVals( &i, TRUNCATE_FLOAT, ' ' );
|
---|
1723 |
|
---|
1724 | /*
|
---|
1725 | ** Top right y corner.
|
---|
1726 | ** Truncate floating point value.
|
---|
1727 | */
|
---|
1728 | roundImgAreaVals( &i, TRUNCATE_FLOAT, ' ' );
|
---|
1729 |
|
---|
1730 | /* Copy the old name out into resource */
|
---|
1731 | strcpy( pbItemsBuffer + cbBuffout, achOldSuffix );
|
---|
1732 | cbBuffout += strlen( achOldSuffix ) + 1;
|
---|
1733 |
|
---|
1734 | k++;
|
---|
1735 | }
|
---|
1736 | desPpd.desPage.iImgpgpairs = k;
|
---|
1737 | }
|
---|
1738 | else
|
---|
1739 | {
|
---|
1740 | desPpd.desPage.iDmpgpairs = 0;
|
---|
1741 | desPpd.desPage.ofsDimxyPgsz = 0;
|
---|
1742 |
|
---|
1743 | desPpd.desPage.iImgpgpairs = 0;
|
---|
1744 | desPpd.desPage.ofsImgblPgsz = 0;
|
---|
1745 | }
|
---|
1746 |
|
---|
1747 | ProcessUIConstraints( );
|
---|
1748 | VerifyUICList( );
|
---|
1749 |
|
---|
1750 | /*
|
---|
1751 | ** Read the fonts name list supported by printer
|
---|
1752 | */
|
---|
1753 |
|
---|
1754 | fbseek( &fbIn, (long)0, SEEK_SET );
|
---|
1755 |
|
---|
1756 | /*
|
---|
1757 | ** count of pairs formed
|
---|
1758 | */
|
---|
1759 |
|
---|
1760 | k = 0;
|
---|
1761 | desPpd.desFonts.ofsFontnames = cbBuffout;
|
---|
1762 |
|
---|
1763 | /*
|
---|
1764 | */
|
---|
1765 | while (ScanParam( szSearch[fontnamelist], pbPrBuffer))
|
---|
1766 | {
|
---|
1767 | for (j = 0 ; j < 32 ; j++)
|
---|
1768 | {
|
---|
1769 |
|
---|
1770 | if (isspace( pbPrBuffer[ j ] ) || pbPrBuffer[ j ] == ':' ||
|
---|
1771 | pbPrBuffer[ j ] == 0)
|
---|
1772 | {
|
---|
1773 | pbPrBuffer[ j ] = 0;
|
---|
1774 | break;
|
---|
1775 | }
|
---|
1776 | }
|
---|
1777 |
|
---|
1778 | if(j) // just checking...
|
---|
1779 | {
|
---|
1780 | strcpy(pbItemsBuffer + cbBuffout,pbPrBuffer);
|
---|
1781 | cbBuffout += strlen(pbPrBuffer) + 1; // terminator too
|
---|
1782 |
|
---|
1783 | k++;
|
---|
1784 | }
|
---|
1785 | }
|
---|
1786 | desPpd.desFonts.iFonts = k;
|
---|
1787 | ProcessFormTable();
|
---|
1788 |
|
---|
1789 | fbclose( &fbIn );
|
---|
1790 | //desPpd.desItems.iSizeBuffer = cbBuffout;
|
---|
1791 | desPpd.desItems.iSizeBuffer = cbBuffout + iShrinkage;
|
---|
1792 | return( TRUE );
|
---|
1793 | }
|
---|
1794 |
|
---|
1795 |
|
---|
1796 |
|
---|
1797 | /*
|
---|
1798 | ** V2.191412
|
---|
1799 | ** New function.
|
---|
1800 | */
|
---|
1801 | /***************************************************************************
|
---|
1802 | *
|
---|
1803 | * FUNCTION NAME = VerifyPPDLineSize
|
---|
1804 | *
|
---|
1805 | * DESCRIPTION = Since a PPD line with a quoted value may exceed one
|
---|
1806 | * physical file line, it is important to verify that the
|
---|
1807 | * current PPD line that is being read does not exceed the
|
---|
1808 | * buffer. If the PPD line does exceed the buffer, the
|
---|
1809 | * compiler is not equipped to handle oversized lines, so the
|
---|
1810 | * specific command must be ignored.
|
---|
1811 | * This function verifies that the line does not exceed the
|
---|
1812 | * buffer by searching for both starting and ending quotes of
|
---|
1813 | * the quoted value. If the starting quote exists, the value
|
---|
1814 | * is a quoted value and the function searches for the ending
|
---|
1815 | * quote. If an ending quote is found, the line does not
|
---|
1816 | * exceed the buffer. If an ending quote is not found, the
|
---|
1817 | * line exceeds the buffer and the function returns an error.
|
---|
1818 | *
|
---|
1819 | * INPUT = pBuffer - Pointer to buffer containing current PPD line.
|
---|
1820 | * OUTPUT = NONE.
|
---|
1821 | *
|
---|
1822 | * RETURN-NORMAL = TRUE - Buffer does not exceed IBUFFSIZE bytes.
|
---|
1823 | * RETURN-ERROR = FALSE - Buffer exceeds IBUFFSIZE bytes.
|
---|
1824 | *
|
---|
1825 | ************************************************************************* */
|
---|
1826 | BOOL VerifyPPDLineSize( PCHAR pBuffer )
|
---|
1827 | {
|
---|
1828 | UINT uiLoop1;
|
---|
1829 | UINT uiLoop2;
|
---|
1830 | BOOL bRC = TRUE;
|
---|
1831 |
|
---|
1832 | /*
|
---|
1833 | ** Search for the first quote.
|
---|
1834 | */
|
---|
1835 | for (uiLoop1 = 0 ; uiLoop1 < IBUFFSIZE ; uiLoop1++)
|
---|
1836 | {
|
---|
1837 | if (*(pBuffer + uiLoop1) == '"')
|
---|
1838 | {
|
---|
1839 | break;
|
---|
1840 | }
|
---|
1841 | }
|
---|
1842 |
|
---|
1843 | /*
|
---|
1844 | ** In the above loop, if uiLoop1 is IBUFFSIZE, it could not find a starting
|
---|
1845 | ** quote. Otherwise, a starting quote was found so find the ending quote.
|
---|
1846 | */
|
---|
1847 | // there have been occurances of statistically very unprobable event when
|
---|
1848 | // quote occurs JUST BEFORE end of the buffer. then the closing brace is
|
---|
1849 | // out of range and invisible! which would cause all the buffer to be discarded...
|
---|
1850 | // so, if the string starts very close to end of buffer, ignore it.
|
---|
1851 | if (uiLoop1 < IBUFFSIZE - 100 )
|
---|
1852 | {
|
---|
1853 | for (uiLoop2 = uiLoop1 + 1 ; uiLoop2 < IBUFFSIZE ; uiLoop2++)
|
---|
1854 | {
|
---|
1855 | if (*(pBuffer + uiLoop2) == '"')
|
---|
1856 | {
|
---|
1857 | break;
|
---|
1858 | }
|
---|
1859 | }
|
---|
1860 |
|
---|
1861 | /*
|
---|
1862 | ** If uiLoop2 equals IBUFFSIZE, no ending quote was found. The buffer
|
---|
1863 | ** was exceeded.
|
---|
1864 | */
|
---|
1865 | if (uiLoop2 == IBUFFSIZE)
|
---|
1866 | {
|
---|
1867 | /*
|
---|
1868 | ** Since this compiler passes the PPD file for each command, if a
|
---|
1869 | ** specific command exceeded the buffer, an error will be generated for
|
---|
1870 | ** each pass. Rather than display the same error for each pass, display
|
---|
1871 | ** the error for the first pass only.
|
---|
1872 | */
|
---|
1873 | if (BErrorWasDisplayed == FALSE)
|
---|
1874 | {
|
---|
1875 | //print all buffer
|
---|
1876 | // strtok( pBuffer, " " );
|
---|
1877 | /*
|
---|
1878 | ** Change "ERROR" to "INFO". This was confusing the build group.
|
---|
1879 | ** They were thinking that an error occurred and that the build was
|
---|
1880 | ** not successful.
|
---|
1881 | */
|
---|
1882 | printf( "[WARNING: Command %s, line exceeds maximum buffer size of %u bytes.\nThis line is ignored.]\n",
|
---|
1883 | pBuffer, IBUFFSIZE );
|
---|
1884 | }
|
---|
1885 | BErrorWasDisplayed = TRUE;
|
---|
1886 | bRC = FALSE;
|
---|
1887 | }
|
---|
1888 | }
|
---|
1889 |
|
---|
1890 | return( bRC );
|
---|
1891 | }
|
---|
1892 |
|
---|
1893 |
|
---|
1894 | #define PUIB_IGNORE_MEDIA 0x00
|
---|
1895 | #define PUIB_SEARCH_MEDIA 0x01
|
---|
1896 | #define PUIB_MEDIA_FOUND 0x02
|
---|
1897 | #define PUIB_CREATE_MEDIA 0x04
|
---|
1898 | #define PUIB_MEDIA_CREATED 0x08
|
---|
1899 |
|
---|
1900 | /*
|
---|
1901 | */
|
---|
1902 | VOID ProcessUIList( )
|
---|
1903 | {
|
---|
1904 | PCHAR pUICurrBlock;
|
---|
1905 | PCHAR pEndToken;
|
---|
1906 | UINT uiStrLen;
|
---|
1907 | SHORT sDisplayOrder;
|
---|
1908 | UINT uiLoop, uiLoop2;
|
---|
1909 | long usFileLoc;
|
---|
1910 | PUI_BLOCK pUIBlock1, pUIBlock2;
|
---|
1911 | PUI_LIST pUIList = &desPpd.stUIList;
|
---|
1912 |
|
---|
1913 | PCHAR pTemp;
|
---|
1914 | INT ofsTemp;
|
---|
1915 | PSZ pUICmd;
|
---|
1916 | USHORT usCMDLoop;
|
---|
1917 | USHORT usFlags = PUIB_SEARCH_MEDIA;
|
---|
1918 |
|
---|
1919 | BUI = TRUE;
|
---|
1920 | memset( USBlockHeader, 0, sizeof( USBlockHeader ) );
|
---|
1921 |
|
---|
1922 |
|
---|
1923 | if (pUIList->pBlockList != NULL)
|
---|
1924 | {
|
---|
1925 | pUICmd = (PSZ) szSearch[ OpenUI ];
|
---|
1926 | for (usCMDLoop = 0 ; usCMDLoop <= 1 ; usCMDLoop++)
|
---|
1927 | {
|
---|
1928 | pUICurrBlock = (PCHAR) pUIList->pBlockList;
|
---|
1929 | fbseek( &fbIn, (long) 0, SEEK_SET );
|
---|
1930 |
|
---|
1931 | while (ScanParam( pUICmd, pbPrBuffer ))
|
---|
1932 | {
|
---|
1933 | pEndToken = pbPrBuffer;
|
---|
1934 | while (*pEndToken != '/' && *pEndToken != ':')
|
---|
1935 | {
|
---|
1936 | pEndToken++;
|
---|
1937 | }
|
---|
1938 | uiStrLen = (UINT) (pEndToken - pbPrBuffer);
|
---|
1939 |
|
---|
1940 | /*
|
---|
1941 | ** Query the UI string list to see if the name already exists.
|
---|
1942 | ** Process the UI if the string does not exist.
|
---|
1943 | */
|
---|
1944 | for (uiLoop = 0 ; uiLoop < maximum ; uiLoop++)
|
---|
1945 | {
|
---|
1946 | printf("%s\n",szSearch[uiLoop]);
|
---|
1947 | if (!strncmp( pbPrBuffer, szSearch[ uiLoop ], uiStrLen ))
|
---|
1948 | {
|
---|
1949 | break;
|
---|
1950 | }
|
---|
1951 | }
|
---|
1952 |
|
---|
1953 | /*
|
---|
1954 | ** If uiLoop = maximum, then no matching strings were found in the
|
---|
1955 | ** above IF statement.
|
---|
1956 | */
|
---|
1957 | /*
|
---|
1958 | ** *IMPORTANT
|
---|
1959 | ** 'ColorAdjust' is used by Brother HS-1PS2. The problem with this
|
---|
1960 | ** command is that the command string is more than 2K in size.
|
---|
1961 | ** Incrementing the buffer more than 2K broke other parts of the
|
---|
1962 | ** compiler. Ignore this command, just for the time being.
|
---|
1963 | */
|
---|
1964 | if (uiLoop == maximum /*&& strncmp( pbPrBuffer, "*ColorAdjust", 12 )*/)
|
---|
1965 | {
|
---|
1966 | USBlockHeader[ pUIList->usNumOfBlocks++ ] =
|
---|
1967 | pUIList->usBlockListSize;
|
---|
1968 | pUIBlock1 = (PUI_BLOCK) (pUICurrBlock + pUIList->usBlockListSize);
|
---|
1969 |
|
---|
1970 | usFileLoc = fbtell( &fbIn );
|
---|
1971 | if (usFileLoc > UIFileGroup.usFileStart &&
|
---|
1972 | usFileLoc < UIFileGroup.usFileEnd)
|
---|
1973 | {
|
---|
1974 | pUIBlock1->ucGroupType = UIGT_INSTALLABLEOPTION;
|
---|
1975 | }
|
---|
1976 | else
|
---|
1977 | {
|
---|
1978 | pUIBlock1->ucGroupType = UIGT_DEFAULTOPTION;
|
---|
1979 | }
|
---|
1980 |
|
---|
1981 | pUIList->usBlockListSize += (USHORT) ProcessUIBlock( pUIList,
|
---|
1982 | pUIBlock1,
|
---|
1983 | uiStrLen,
|
---|
1984 | &usFlags );
|
---|
1985 |
|
---|
1986 |
|
---|
1987 | /* ** If last UI Block was InputSlot and there are MediaType
|
---|
1988 | ** simulate new UI Block MediaType
|
---|
1989 | */
|
---|
1990 | if ( usFlags & PUIB_MEDIA_FOUND )
|
---|
1991 | {
|
---|
1992 | if ( nErrorLogLevel<2 )
|
---|
1993 | printf("[INFO: MediaType Simulation]\n");
|
---|
1994 | usFlags = PUIB_CREATE_MEDIA;
|
---|
1995 |
|
---|
1996 | USBlockHeader[ pUIList->usNumOfBlocks++ ] =
|
---|
1997 | pUIList->usBlockListSize;
|
---|
1998 |
|
---|
1999 | pUIBlock1 = (PUI_BLOCK) (pUICurrBlock + pUIList->usBlockListSize);
|
---|
2000 | pUIBlock1->ucGroupType = UIGT_DEFAULTOPTION;
|
---|
2001 |
|
---|
2002 | pUIList->usBlockListSize += (USHORT) ProcessUIBlock( pUIList,
|
---|
2003 | pUIBlock1,
|
---|
2004 | uiStrLen,
|
---|
2005 | &usFlags );
|
---|
2006 | usFlags = PUIB_MEDIA_CREATED;
|
---|
2007 | }
|
---|
2008 |
|
---|
2009 | }
|
---|
2010 | }
|
---|
2011 |
|
---|
2012 | pUICmd = (PSZ) szSearch[ JCLOpenUI ];
|
---|
2013 | }
|
---|
2014 |
|
---|
2015 | /*
|
---|
2016 | ** Now that the UI's have been processed, it is time to sort them.
|
---|
2017 | ** They will be sorted in order, from low to high value, taken from
|
---|
2018 | ** the "*OrderDependency" command in the UI block. Each command
|
---|
2019 | ** is followed by a numeric value.
|
---|
2020 | */
|
---|
2021 |
|
---|
2022 | if (pUIList->usNumOfBlocks > 0)
|
---|
2023 | {
|
---|
2024 | sDisplayOrder = 0;
|
---|
2025 | for (uiLoop = 0 ; uiLoop < pUIList->usNumOfBlocks ; uiLoop++)
|
---|
2026 | {
|
---|
2027 | pUIBlock1 = (PUI_BLOCK) ((PCHAR) pUIList->pBlockList +
|
---|
2028 | USBlockHeader[ uiLoop ]);
|
---|
2029 | pUIBlock1->usDisplayOrder = (USHORT) sDisplayOrder++;
|
---|
2030 |
|
---|
2031 | /*
|
---|
2032 | ** If "JCLResolution" is found, then treat it as a standard
|
---|
2033 | ** resolution. Do this by converting the offset to point to
|
---|
2034 | ** "Resolution", rather than "JCLResoluton".
|
---|
2035 | */
|
---|
2036 | pTemp = (PCHAR) (pbItemsBuffer + pUIBlock1->ofsUIName);
|
---|
2037 | if (!strcmp( pTemp, "JCLResolution" ))
|
---|
2038 | {
|
---|
2039 | // Increment by 3 to skip past "JCL".
|
---|
2040 | pUIBlock1->ofsUIName += 3;
|
---|
2041 | }
|
---|
2042 |
|
---|
2043 |
|
---|
2044 | if (pUIBlock1->usUILocation == 0)
|
---|
2045 | {
|
---|
2046 | pUIBlock1->usUILocation = UI_ORDER_PROLOGSETUP;
|
---|
2047 | }
|
---|
2048 | }
|
---|
2049 |
|
---|
2050 | DosAllocMem( (PPVOID) &pTemp, 12288,//8192,
|
---|
2051 | PAG_READ | PAG_WRITE | PAG_COMMIT );
|
---|
2052 | ofsTemp = 0;
|
---|
2053 |
|
---|
2054 | for (uiLoop = 0 ; uiLoop < pUIList->usNumOfBlocks ; uiLoop++)
|
---|
2055 | {
|
---|
2056 | for (uiLoop2 = 0 ; uiLoop2 < pUIList->usNumOfBlocks - 1 ; uiLoop2++)
|
---|
2057 | {
|
---|
2058 | pUIBlock1 = (PUI_BLOCK) ((PCHAR) pUIList->pBlockList +
|
---|
2059 | USBlockHeader[ uiLoop2 ]);
|
---|
2060 | pEndToken = (PCHAR) (pUIBlock1->ofsUIName + pbItemsBuffer);
|
---|
2061 |
|
---|
2062 | pUIBlock2 = (PUI_BLOCK) ((PCHAR) pUIList->pBlockList +
|
---|
2063 | USBlockHeader[ uiLoop2 + 1 ]);
|
---|
2064 | pEndToken = (PCHAR) (pUIBlock2->ofsUIName + pbItemsBuffer);
|
---|
2065 |
|
---|
2066 | if (pUIBlock1->usOrderDep > pUIBlock2->usOrderDep)
|
---|
2067 | {
|
---|
2068 | ofsTemp = USBlockHeader[ uiLoop2 ];
|
---|
2069 | USBlockHeader[ uiLoop2 ] = USBlockHeader[ uiLoop2 + 1 ];
|
---|
2070 | USBlockHeader[ uiLoop2 + 1 ] = ofsTemp;
|
---|
2071 | }
|
---|
2072 | }
|
---|
2073 | }
|
---|
2074 |
|
---|
2075 | ofsTemp = 0;
|
---|
2076 | for (uiLoop = 0 ; uiLoop < pUIList->usNumOfBlocks ; uiLoop++)
|
---|
2077 | {
|
---|
2078 | pUIBlock1 = (PUI_BLOCK) ((PCHAR) pUIList->pBlockList +
|
---|
2079 | USBlockHeader[ uiLoop ]);
|
---|
2080 | pUIBlock1->usOrderDep = (USHORT) uiLoop;
|
---|
2081 | pEndToken = (PCHAR) (pUIBlock1->ofsUIName + pbItemsBuffer);
|
---|
2082 | memcpy( pTemp + ofsTemp, pUIBlock1, QUERY_BLOCK_SIZE( pUIBlock1 ) );
|
---|
2083 | ofsTemp += QUERY_BLOCK_SIZE( pUIBlock1 );
|
---|
2084 | }
|
---|
2085 |
|
---|
2086 | memcpy( pUIList->pBlockList, pTemp, pUIList->usBlockListSize );
|
---|
2087 |
|
---|
2088 | DosFreeMem( pTemp );
|
---|
2089 | }
|
---|
2090 |
|
---|
2091 | pbPrBuffer[ 0 ] = 0;
|
---|
2092 | }
|
---|
2093 |
|
---|
2094 | // DosFreeMem( pUIList->pBlockList );
|
---|
2095 | BUI = FALSE;
|
---|
2096 | }
|
---|
2097 |
|
---|
2098 |
|
---|
2099 |
|
---|
2100 | UINT ProcessUIBlock( PUI_LIST pUIList, PUI_BLOCK pUIBlock, UINT uiStrLen, PUSHORT pusFlags )
|
---|
2101 | {
|
---|
2102 | CHAR aTempDefName[ 31 ];
|
---|
2103 | INT iLoop;
|
---|
2104 | INT iCounter;
|
---|
2105 | UINT uiEndOfString;
|
---|
2106 | PCHAR pTransString;
|
---|
2107 | #ifdef DEBUG
|
---|
2108 | PCHAR pStorage = pbItemsBuffer + cbBuffout;
|
---|
2109 | PCHAR pLine = pbPrBuffer + uiStrLen;
|
---|
2110 | #endif
|
---|
2111 | PCHAR pCompare;
|
---|
2112 | CHAR cGroupType;
|
---|
2113 | PCHAR pKeyword;
|
---|
2114 |
|
---|
2115 | //PSZ pTemp; NOTUSED
|
---|
2116 | BOOL bInputSlot = FALSE;
|
---|
2117 | BOOL bSkipEntry;
|
---|
2118 |
|
---|
2119 | cGroupType = pUIBlock->ucGroupType;
|
---|
2120 | memset( pUIBlock, 0, sizeof( UI_BLOCK ) - sizeof( UI_ENTRY ) );
|
---|
2121 | pUIBlock->ucGroupType = cGroupType;
|
---|
2122 |
|
---|
2123 | /* ** If PUIB_CREATE_MEDIA then simulating Media type
|
---|
2124 | */
|
---|
2125 | if ( *pusFlags & PUIB_CREATE_MEDIA )
|
---|
2126 | {
|
---|
2127 | bInputSlot = TRUE;
|
---|
2128 | if ((pUIBlock->ofsUIName = (USHORT) MatchKeywords( UINAME_MEDIATYPE, pUIList,
|
---|
2129 | pbItemsBuffer, TRUE )) == (USHORT) -1)
|
---|
2130 | {
|
---|
2131 | pUIBlock->ofsUIName = cbBuffout;
|
---|
2132 | cbBuffout += CopyString( pbItemsBuffer + cbBuffout,
|
---|
2133 | UINAME_MEDIATYPE,
|
---|
2134 | 255,
|
---|
2135 | CSTR_INCLUDE_SLASH );
|
---|
2136 | }
|
---|
2137 |
|
---|
2138 | pUIBlock->ucPanelID = UIP_PREDEF_FEATURE;
|
---|
2139 | }
|
---|
2140 | else
|
---|
2141 | {
|
---|
2142 |
|
---|
2143 | // Search for keyword to replace current UI block keyword
|
---|
2144 | pKeyword = SearchKeySubst( pbPrBuffer + 1 );
|
---|
2145 |
|
---|
2146 | if ((pUIBlock->ofsUIName = (USHORT) MatchKeywords( pKeyword, pUIList,
|
---|
2147 | pbItemsBuffer, TRUE )) == (USHORT) -1)
|
---|
2148 | {
|
---|
2149 | pUIBlock->ofsUIName = cbBuffout;
|
---|
2150 | pCompare = pbItemsBuffer + cbBuffout;
|
---|
2151 | cbBuffout += CopyString( pbItemsBuffer + cbBuffout,
|
---|
2152 | pKeyword,
|
---|
2153 | 255,
|
---|
2154 | CSTR_INCLUDE_SLASH );
|
---|
2155 | }
|
---|
2156 | /*
|
---|
2157 | ** If a name already exists, we still need to extract it to verify if it
|
---|
2158 | ** is a predefined UI or not.
|
---|
2159 | */
|
---|
2160 | else
|
---|
2161 | {
|
---|
2162 | pCompare = aTempDefName;
|
---|
2163 | pTransString = pbPrBuffer + 1;
|
---|
2164 | iLoop = 0;
|
---|
2165 |
|
---|
2166 | while (*pTransString != ' ' && *pTransString != ':')
|
---|
2167 | {
|
---|
2168 | aTempDefName[ iLoop ] = *pTransString;
|
---|
2169 | pTransString++;
|
---|
2170 | iLoop++;
|
---|
2171 | }
|
---|
2172 | aTempDefName[ iLoop ] = 0;
|
---|
2173 | pCompare = SearchKeySubst( aTempDefName );
|
---|
2174 |
|
---|
2175 | }
|
---|
2176 |
|
---|
2177 | /* ** Search for UI Block=InputSlot if PUIB_SEARCH_MEDIA
|
---|
2178 | */
|
---|
2179 | if( ( *pusFlags & PUIB_SEARCH_MEDIA ) &&
|
---|
2180 | !strcmpi( UINAME_INPUTSLOT, pCompare ))
|
---|
2181 | {
|
---|
2182 | bInputSlot = TRUE;
|
---|
2183 | }
|
---|
2184 |
|
---|
2185 |
|
---|
2186 | // see if this is a predefined feature
|
---|
2187 | pUIBlock->ucPanelID = UIP_OS2_FEATURE;
|
---|
2188 | for( iLoop = 0; iLoop < MAX_PREDEFINED ; iLoop++ )
|
---|
2189 | {
|
---|
2190 |
|
---|
2191 | // if( !strcmp( szPredefined[iLoop], pCompare ))
|
---|
2192 | if( !strcmpi( szPredefined[iLoop], pCompare ))
|
---|
2193 | pUIBlock->ucPanelID = UIP_PREDEF_FEATURE;
|
---|
2194 | }
|
---|
2195 |
|
---|
2196 | }
|
---|
2197 |
|
---|
2198 | /*
|
---|
2199 | ** Copy the translation string.
|
---|
2200 | */
|
---|
2201 | if (*(pbPrBuffer + uiStrLen) == '/' && pUIBlock->ucPanelID !=
|
---|
2202 | UIP_PREDEF_FEATURE)
|
---|
2203 | {
|
---|
2204 | if ((pUIBlock->ofsUITransString =
|
---|
2205 | (USHORT) MatchKeywords( pbPrBuffer + ++uiStrLen, pUIList,
|
---|
2206 | pbItemsBuffer, TRUE )) == (USHORT) -1)
|
---|
2207 | {
|
---|
2208 | pUIBlock->ofsUITransString = cbBuffout;
|
---|
2209 | cbBuffout += CopyString( pbItemsBuffer + cbBuffout,
|
---|
2210 | pbPrBuffer + uiStrLen,
|
---|
2211 | 255,
|
---|
2212 | CSTR_INCLUDE_SLASH | CSTR_HEX2CHAR);
|
---|
2213 | }
|
---|
2214 | }
|
---|
2215 | else
|
---|
2216 | {
|
---|
2217 | /*
|
---|
2218 | ** Assign the UI name as the Translation string since a Translation
|
---|
2219 | ** string wasn't provided. Ignore the asterisk ('*') for the
|
---|
2220 | ** Translation string.
|
---|
2221 | */
|
---|
2222 |
|
---|
2223 | // adding 1 caused the first character of the UI name
|
---|
2224 | // to be chopped of in cases where the PPD had a variable
|
---|
2225 | // number of spaces before the '*'. MovePast has been
|
---|
2226 | // changed to handle this.
|
---|
2227 | // pUIBlock->ofsUITransString = pUIBlock->ofsUIName + 1;
|
---|
2228 | pUIBlock->ofsUITransString = pUIBlock->ofsUIName;
|
---|
2229 | }
|
---|
2230 |
|
---|
2231 | uiStrLen += MovePast( pbPrBuffer + uiStrLen, ':' );
|
---|
2232 | uiStrLen += SkipBlank( pbPrBuffer + uiStrLen );
|
---|
2233 | uiEndOfString = MovePast( pbPrBuffer + uiStrLen, '\n' );
|
---|
2234 |
|
---|
2235 | #ifdef DEBUG
|
---|
2236 | pStorage = pbItemsBuffer + cbBuffout;
|
---|
2237 | pLine = pbPrBuffer + uiStrLen;
|
---|
2238 | #endif
|
---|
2239 |
|
---|
2240 | /*
|
---|
2241 | ** The UI has three types of selections: BOOLEAN, PICK ONE, and
|
---|
2242 | ** PICK MANY.
|
---|
2243 | */
|
---|
2244 | if (!strncmp( pbPrBuffer + uiStrLen, "Boolean", 7 ))
|
---|
2245 | {
|
---|
2246 | pUIBlock->usSelectType = (UCHAR) UI_SELECT_BOOLEAN;
|
---|
2247 | }
|
---|
2248 | else if (!strncmp( pbPrBuffer + uiStrLen, "PickMany", 8 ))
|
---|
2249 | {
|
---|
2250 | printf( "[WARNING: UI type PickMany will cause problems]\n" );
|
---|
2251 |
|
---|
2252 | pUIBlock->usSelectType = (UCHAR) UI_SELECT_PICKMANY;
|
---|
2253 | }
|
---|
2254 | else
|
---|
2255 | {
|
---|
2256 | pUIBlock->usSelectType = (UCHAR) UI_SELECT_PICKONE;
|
---|
2257 | }
|
---|
2258 |
|
---|
2259 | /*
|
---|
2260 | ** Go to the next line.
|
---|
2261 | */
|
---|
2262 |
|
---|
2263 | uiStrLen += uiEndOfString;
|
---|
2264 |
|
---|
2265 | /*
|
---|
2266 | ** Run through the loop until a CLOSEUI is encountered.
|
---|
2267 | */
|
---|
2268 | while (TRUE)
|
---|
2269 | {
|
---|
2270 | #ifdef DEBUG
|
---|
2271 | pStorage = pbItemsBuffer + cbBuffout;
|
---|
2272 | pLine = pbPrBuffer + uiStrLen;
|
---|
2273 | #endif
|
---|
2274 |
|
---|
2275 | if (*(pbPrBuffer + uiStrLen) == 0 &&
|
---|
2276 | *(pbPrBuffer + uiStrLen + 1) == 0)
|
---|
2277 | {
|
---|
2278 | fbread( pbPrBuffer, 1, IBUFFSIZE, &fbIn );
|
---|
2279 | uiStrLen = 0;
|
---|
2280 | }
|
---|
2281 |
|
---|
2282 | /*
|
---|
2283 | ** Parse the appropriate key.
|
---|
2284 | */
|
---|
2285 | if (!strncmp( pbPrBuffer + uiStrLen, "*Default", 8 ))
|
---|
2286 | {
|
---|
2287 | uiStrLen += MovePast( pbPrBuffer + uiStrLen, ':' );
|
---|
2288 | uiStrLen += SkipBlank( pbPrBuffer + uiStrLen );
|
---|
2289 |
|
---|
2290 | CopyString( aTempDefName,
|
---|
2291 | pbPrBuffer + uiStrLen,
|
---|
2292 | 31,
|
---|
2293 | CSTR_NORMAL );
|
---|
2294 | /* ** Tektronic printers have Transparent medias in InputSlot block.
|
---|
2295 | ** Parser should ignore them. Search for DefaultInputSlot: Papar or AutoSelect
|
---|
2296 | ** FYI - Kyocera printers DefaultInputSlot: Internal or PF30A
|
---|
2297 | */
|
---|
2298 | if( ( bInputSlot ) &&
|
---|
2299 | ( *pusFlags & PUIB_SEARCH_MEDIA ) &&
|
---|
2300 | ( ( !strcmp( aTempDefName, "Paper") ) ||
|
---|
2301 | ( !strcmp( aTempDefName, "AutoSelect") ) ) )
|
---|
2302 | {
|
---|
2303 | *pusFlags = PUIB_IGNORE_MEDIA;
|
---|
2304 | bInputSlot = FALSE;
|
---|
2305 | }
|
---|
2306 |
|
---|
2307 | }
|
---|
2308 | else if (!strncmp( pbPrBuffer + uiStrLen, "*OrderDependency", 16 ) ||
|
---|
2309 | !strncmp( pbPrBuffer + uiStrLen, "OrderDependency", 15 ))
|
---|
2310 | {
|
---|
2311 | uiStrLen += MovePast( pbPrBuffer + uiStrLen, ':' );
|
---|
2312 | uiStrLen += SkipBlank( pbPrBuffer + uiStrLen );
|
---|
2313 |
|
---|
2314 | pUIBlock->usOrderDep = atoi( pbPrBuffer + uiStrLen );
|
---|
2315 |
|
---|
2316 | uiStrLen += MovePast( pbPrBuffer + uiStrLen, ' ' );
|
---|
2317 | uiStrLen += SkipBlank( pbPrBuffer + uiStrLen );
|
---|
2318 | uiEndOfString = MovePast( pbPrBuffer + uiStrLen, ' ' );
|
---|
2319 |
|
---|
2320 | if (!strncmp( pbPrBuffer + uiStrLen, "ExitServer", 10 ))
|
---|
2321 | {
|
---|
2322 | pUIBlock->usUILocation = UI_ORDER_EXITSERVER;
|
---|
2323 | }
|
---|
2324 | else if (!strncmp( pbPrBuffer + uiStrLen, "DocumentSetup", 13 ))
|
---|
2325 | {
|
---|
2326 | pUIBlock->usUILocation = UI_ORDER_DOCSETUP;
|
---|
2327 | }
|
---|
2328 | else if (!strncmp( pbPrBuffer + uiStrLen, "PageSetup", 9 ))
|
---|
2329 | {
|
---|
2330 | pUIBlock->usUILocation = UI_ORDER_PAGESETUP;
|
---|
2331 | }
|
---|
2332 | else if (!strncmp( pbPrBuffer + uiStrLen, "JCLSetup", 8 ))
|
---|
2333 | {
|
---|
2334 | pUIBlock->usUILocation = UI_ORDER_JCLSETUP;
|
---|
2335 | }
|
---|
2336 | else
|
---|
2337 | {
|
---|
2338 | pUIBlock->usUILocation = UI_ORDER_PROLOGSETUP;
|
---|
2339 | }
|
---|
2340 | }
|
---|
2341 | else if (!strncmp( pbPrBuffer + uiStrLen, "*CloseUI", 8 ) ||
|
---|
2342 | !strncmp( pbPrBuffer + uiStrLen, "*JCLCloseUI", 11 ) ||
|
---|
2343 | pUIBlock->usNumOfEntries >= 100 ) // bvl: Increased to 100 from 30 ( can't we just skip this in total if the buffer is large enough ?? )
|
---|
2344 | {
|
---|
2345 | break;
|
---|
2346 | }
|
---|
2347 | else if (*(pbPrBuffer + uiStrLen) == '*' &&
|
---|
2348 | *(pbPrBuffer + uiStrLen + 1) != '?' &&
|
---|
2349 | *(pbPrBuffer + uiStrLen + 1) != '%' &&
|
---|
2350 | strncmp( pbPrBuffer + uiStrLen, "*End", 4 ))
|
---|
2351 | {
|
---|
2352 | uiStrLen += MovePast( pbPrBuffer + uiStrLen, ' ' );
|
---|
2353 | bSkipEntry = FALSE;
|
---|
2354 |
|
---|
2355 | // bvl: if we are in resolution, we need to check the whole string for "" this is invalid
|
---|
2356 |
|
---|
2357 | if(stricmp(pCompare,"Resolution")==0)
|
---|
2358 | {
|
---|
2359 | ULONG uiResStr;
|
---|
2360 | // we are in resolution processing
|
---|
2361 | uiResStr = uiStrLen + MovePast( pbPrBuffer + uiStrLen, ':' );
|
---|
2362 | uiResStr += SkipBlank( pbPrBuffer + uiResStr );
|
---|
2363 | if(strnicmp(pbPrBuffer+uiResStr,"\"\"",2)==0)
|
---|
2364 | {
|
---|
2365 | // we found a empty resolution string so skip this one
|
---|
2366 | bSkipEntry = TRUE;
|
---|
2367 | }
|
---|
2368 | }
|
---|
2369 |
|
---|
2370 | /* */
|
---|
2371 |
|
---|
2372 | if ( bInputSlot )
|
---|
2373 | {
|
---|
2374 | if ( *pusFlags & PUIB_CREATE_MEDIA )
|
---|
2375 | bSkipEntry = TRUE;
|
---|
2376 | for(iCounter = 0; iCounter < 100; iCounter++ )
|
---|
2377 | {
|
---|
2378 | if ((*(pbPrBuffer + uiStrLen + iCounter) == '>') &&
|
---|
2379 | (*(pbPrBuffer + uiStrLen + (iCounter+1)) == '>'))break;
|
---|
2380 | if(!strncmp( pbPrBuffer + uiStrLen + iCounter ,
|
---|
2381 | "MediaType ()" , strlen("MediaType (")))
|
---|
2382 | {
|
---|
2383 | *pusFlags |= PUIB_MEDIA_FOUND;
|
---|
2384 | bSkipEntry = !bSkipEntry;
|
---|
2385 | break;
|
---|
2386 | }
|
---|
2387 | if(!strncmp( pbPrBuffer + uiStrLen + iCounter , "*End" , strlen("*End"))) break;
|
---|
2388 | }
|
---|
2389 | }
|
---|
2390 |
|
---|
2391 | if ( bSkipEntry )
|
---|
2392 | {
|
---|
2393 | goto SkipEntry;
|
---|
2394 | }
|
---|
2395 |
|
---|
2396 | if ((pUIBlock->uiEntry[ pUIBlock->usNumOfEntries ].ofsOption =
|
---|
2397 | (USHORT) MatchKeywords( pbPrBuffer + uiStrLen, pUIList,
|
---|
2398 | pbItemsBuffer, TRUE )) == (USHORT) -1)
|
---|
2399 | {
|
---|
2400 | pUIBlock->uiEntry[ pUIBlock->usNumOfEntries ].ofsOption = cbBuffout;
|
---|
2401 | cbBuffout += CopyString( pbItemsBuffer + cbBuffout,
|
---|
2402 | pbPrBuffer + uiStrLen,
|
---|
2403 | 31,
|
---|
2404 | CSTR_INCLUDE_SLASH );
|
---|
2405 | }
|
---|
2406 |
|
---|
2407 | pTransString = pbPrBuffer + uiStrLen;
|
---|
2408 | while (*pTransString != '/' && *pTransString != ':')
|
---|
2409 | {
|
---|
2410 | pTransString++;
|
---|
2411 | }
|
---|
2412 |
|
---|
2413 | if (*pTransString == '/')
|
---|
2414 | {
|
---|
2415 | if ((pUIBlock->uiEntry[ pUIBlock->usNumOfEntries ].ofsTransString =
|
---|
2416 | (USHORT) MatchKeywords( ++pTransString, pUIList, pbItemsBuffer,
|
---|
2417 | TRUE )) == (USHORT) -1)
|
---|
2418 | {
|
---|
2419 | pUIBlock->uiEntry[ pUIBlock->usNumOfEntries ].ofsTransString =
|
---|
2420 | cbBuffout;
|
---|
2421 | cbBuffout += CopyString( pbItemsBuffer + cbBuffout,
|
---|
2422 | pTransString,
|
---|
2423 |
|
---|
2424 | 64,
|
---|
2425 | CSTR_NORMAL | CSTR_HEX2CHAR | CSTR_EXCLUDE_DQUOTE );
|
---|
2426 | }
|
---|
2427 | }
|
---|
2428 | else
|
---|
2429 | {
|
---|
2430 | pUIBlock->uiEntry[ pUIBlock->usNumOfEntries ].ofsTransString =
|
---|
2431 | pUIBlock->uiEntry[ pUIBlock->usNumOfEntries ].ofsOption;
|
---|
2432 | }
|
---|
2433 | uiStrLen += MovePast( pbPrBuffer + uiStrLen, ':' );
|
---|
2434 | uiStrLen += SkipBlank( pbPrBuffer + uiStrLen );
|
---|
2435 | //// No needed that hex strings are done
|
---|
2436 | //// if (pUIBlock->usUILocation == UI_ORDER_JCLSETUP)
|
---|
2437 | //// {
|
---|
2438 | //// pTemp = (PSZ) (pbPrBuffer + uiStrLen + 2);
|
---|
2439 | ////
|
---|
2440 | //// while (*pTemp != '"')
|
---|
2441 | //// {
|
---|
2442 | //// pTemp++;
|
---|
2443 | //// }
|
---|
2444 | ////
|
---|
2445 | //// if (*(pTemp - 1) == '>')
|
---|
2446 | //// {
|
---|
2447 | //// *pTemp = ' ';
|
---|
2448 | //// while (*pTemp != '<')
|
---|
2449 | //// {
|
---|
2450 | //// pTemp--;
|
---|
2451 | //// }
|
---|
2452 | //// *pTemp = '"';
|
---|
2453 | //// }
|
---|
2454 | //// }
|
---|
2455 |
|
---|
2456 | pUIBlock->uiEntry[ pUIBlock->usNumOfEntries ].ofsValue = cbBuffout;
|
---|
2457 | iLoop = CopyInQuote( pbItemsBuffer + cbBuffout, pbPrBuffer +
|
---|
2458 | ++uiStrLen, FALSE, COMPRESS );
|
---|
2459 | cbBuffout += iLoop;
|
---|
2460 |
|
---|
2461 | if (pUIBlock->usUILocation == UI_ORDER_JCLSETUP)
|
---|
2462 | {
|
---|
2463 | *(pbItemsBuffer + cbBuffout - 1) = '\n';
|
---|
2464 | *(pbItemsBuffer + cbBuffout++) = 0;
|
---|
2465 | }
|
---|
2466 |
|
---|
2467 | if (*(pbPrBuffer + uiStrLen - 1) == '"')
|
---|
2468 | {
|
---|
2469 | while (*(pbPrBuffer + uiStrLen) != '"')
|
---|
2470 | {
|
---|
2471 | uiStrLen++;
|
---|
2472 | }
|
---|
2473 | uiStrLen++;
|
---|
2474 | }
|
---|
2475 | else
|
---|
2476 | {
|
---|
2477 | uiStrLen += iLoop;
|
---|
2478 | }
|
---|
2479 |
|
---|
2480 | pUIBlock->usNumOfEntries++;
|
---|
2481 | }
|
---|
2482 |
|
---|
2483 | SkipEntry:
|
---|
2484 | if (*(pbPrBuffer + uiStrLen) != '\n')
|
---|
2485 | {
|
---|
2486 | uiStrLen += MovePast( pbPrBuffer + uiStrLen, '\n' );
|
---|
2487 | }
|
---|
2488 | else
|
---|
2489 | {
|
---|
2490 | uiStrLen++;
|
---|
2491 | }
|
---|
2492 | }
|
---|
2493 |
|
---|
2494 | /*
|
---|
2495 | ** Run through the list of entries in the current block and find
|
---|
2496 | ** the default entry name. The reason the list starts at the
|
---|
2497 | ** bottom is so if no matching names are found, the default is assigned
|
---|
2498 | ** to the first entry, which is the last one to be encountered in
|
---|
2499 | ** this loop.
|
---|
2500 | */
|
---|
2501 | for (iLoop = pUIBlock->usNumOfEntries - 1 ; iLoop >= 0 ; iLoop--)
|
---|
2502 | {
|
---|
2503 | /*
|
---|
2504 | ** If a match is found, get out of the loop.
|
---|
2505 | */
|
---|
2506 | if (iLoop == 0 ||
|
---|
2507 | !strcmp( pbItemsBuffer + pUIBlock->uiEntry[ iLoop ].ofsOption,
|
---|
2508 | aTempDefName ) )
|
---|
2509 | {
|
---|
2510 | // pUIBlock->usDefaultEntry = (USHORT) (1 << iLoop);
|
---|
2511 | pUIBlock->usDefaultEntry = (USHORT) iLoop;
|
---|
2512 | break;
|
---|
2513 | }
|
---|
2514 | }
|
---|
2515 |
|
---|
2516 | if (pUIBlock->usNumOfEntries > 0)
|
---|
2517 | {
|
---|
2518 | iLoop = (INT) pUIBlock->usNumOfEntries - 1;
|
---|
2519 | }
|
---|
2520 | else
|
---|
2521 | {
|
---|
2522 | iLoop = 0;
|
---|
2523 | }
|
---|
2524 |
|
---|
2525 | return( sizeof( UI_BLOCK ) + (sizeof( UI_ENTRY ) * iLoop) );
|
---|
2526 | }
|
---|
2527 |
|
---|
2528 | /*
|
---|
2529 | ** Function SearchKeySubst
|
---|
2530 | ** This function search pKeyToSearch in SRKeywords massive
|
---|
2531 | ** If founds returns Keyword need to replace with
|
---|
2532 | ** If not returns pKeyToSearch
|
---|
2533 | */
|
---|
2534 | PCHAR SearchKeySubst( PCHAR pKeyToSearch )
|
---|
2535 | {
|
---|
2536 | INT iLoop;
|
---|
2537 | CHAR aKey[ MAX_PSIZE ]; // Key string to compare
|
---|
2538 |
|
---|
2539 | CopyString( aKey, pKeyToSearch, MAX_PSIZE, CSTR_INCLUDE_SLASH );
|
---|
2540 |
|
---|
2541 | for ( iLoop = 0; SRKeywords[ iLoop ].szSearch ; iLoop++ )
|
---|
2542 | {
|
---|
2543 | if ( !strcmp( aKey, SRKeywords[ iLoop ].szSearch ) )
|
---|
2544 | {
|
---|
2545 | return SRKeywords[ iLoop ].szReplace;
|
---|
2546 | }
|
---|
2547 | }
|
---|
2548 |
|
---|
2549 | return pKeyToSearch;
|
---|
2550 | }
|
---|
2551 |
|
---|
2552 |
|
---|
2553 |
|
---|
2554 |
|
---|
2555 | INT MatchKeywords( PBYTE pKeyToMatch, PUI_LIST pUIList, PBYTE pPPBBuff,
|
---|
2556 | BOOL bCompareEntries )
|
---|
2557 | {
|
---|
2558 | CHAR aKey[ MAX_PSIZE ]; // Key string to compare
|
---|
2559 | INT iListIndex; // List Index counter
|
---|
2560 | INT iBlockIndex; // Block index counter
|
---|
2561 | PBYTE pKeyword; // Current UI keyword/T.S.
|
---|
2562 | PUI_ENTRY pUIEntry; // UI entry pointer
|
---|
2563 | PUI_BLOCK pUIBlock = pUIList->pBlockList; // UI Block pointer
|
---|
2564 | INT iRC = -1; // Return code
|
---|
2565 |
|
---|
2566 | /*
|
---|
2567 | ** At this point, pKeyToMatch points to the current keyword, but it is not
|
---|
2568 | ** NULL-terminated. Copy the keyword to a temporary buffer so that it is
|
---|
2569 | ** NULL-terminated. It is not recommended to insert a 0 in pKeyToMatch since
|
---|
2570 | ** that pointer points to the actual PPD string data.
|
---|
2571 | */
|
---|
2572 | CopyString( aKey, pKeyToMatch, MAX_PSIZE, CSTR_INCLUDE_SLASH );
|
---|
2573 |
|
---|
2574 | /*
|
---|
2575 | ** Run through the UI list.
|
---|
2576 | */
|
---|
2577 | for (iListIndex = 0 ; iListIndex < (INT) pUIList->usNumOfBlocks - 1 ;
|
---|
2578 | iListIndex++)
|
---|
2579 | {
|
---|
2580 | pKeyword = (PBYTE) (pUIBlock->ofsUIName + pPPBBuff);
|
---|
2581 |
|
---|
2582 | /*
|
---|
2583 | ** Compare the current keyword with the string to match.
|
---|
2584 | ** Set the return code to the offset if a match is found.
|
---|
2585 | */
|
---|
2586 | if (!strcmp( pKeyword, aKey ))
|
---|
2587 | {
|
---|
2588 | iRC = (INT) pUIBlock->ofsUIName;
|
---|
2589 | break;
|
---|
2590 | }
|
---|
2591 |
|
---|
2592 | /*
|
---|
2593 | ** Compare the Translation String only if the T.S. is not the same as
|
---|
2594 | ** as the keyword for this has already been done above.
|
---|
2595 | */
|
---|
2596 | if (pUIBlock->ofsUIName != pUIBlock->ofsUITransString)
|
---|
2597 | {
|
---|
2598 | pKeyword = (PBYTE) (pUIBlock->ofsUITransString + pPPBBuff);
|
---|
2599 | if (!strcmp( pKeyword, aKey ))
|
---|
2600 | {
|
---|
2601 | /*
|
---|
2602 | ** Copy T.S. offset, not UI name offset.
|
---|
2603 | */
|
---|
2604 | // iRC = (INT) pUIBlock->ofsUIName;
|
---|
2605 | iRC = (INT) pUIBlock->ofsUITransString;
|
---|
2606 | break;
|
---|
2607 | }
|
---|
2608 | }
|
---|
2609 |
|
---|
2610 | /*
|
---|
2611 | ** Compare entries, only if requested.
|
---|
2612 | */
|
---|
2613 | if (bCompareEntries == TRUE)
|
---|
2614 | {
|
---|
2615 | /*
|
---|
2616 | ** At this point, no match has been found. At this time, compare the
|
---|
2617 | ** keywords and the Translation Strings for each entry in the current
|
---|
2618 | ** block.
|
---|
2619 | */
|
---|
2620 | for (iBlockIndex = 0 ; iBlockIndex < (INT) pUIBlock->usNumOfEntries ;
|
---|
2621 | iBlockIndex++)
|
---|
2622 | {
|
---|
2623 | pUIEntry = &pUIBlock->uiEntry[ iBlockIndex ];
|
---|
2624 |
|
---|
2625 | /*
|
---|
2626 | ** Compare the entry's keyword.
|
---|
2627 | */
|
---|
2628 | pKeyword = (PBYTE) (pUIEntry->ofsOption + pPPBBuff);
|
---|
2629 | if (!strcmp( pKeyword, aKey ))
|
---|
2630 | {
|
---|
2631 | iRC = (INT) pUIEntry->ofsOption;
|
---|
2632 | break;
|
---|
2633 | }
|
---|
2634 |
|
---|
2635 | /*
|
---|
2636 | ** Compare the entry's Translation String, provided that the offset to
|
---|
2637 | ** the T.S. is not the same as the keyword.
|
---|
2638 | */
|
---|
2639 | if (pUIEntry->ofsTransString != pUIEntry->ofsOption)
|
---|
2640 | {
|
---|
2641 | pKeyword = (PBYTE) (pUIEntry->ofsTransString + pPPBBuff);
|
---|
2642 | if (!strcmp( pKeyword, aKey ))
|
---|
2643 | {
|
---|
2644 | iRC = (INT) pUIEntry->ofsTransString;
|
---|
2645 | break;
|
---|
2646 | }
|
---|
2647 | }
|
---|
2648 | }
|
---|
2649 | }
|
---|
2650 |
|
---|
2651 | INCREMENT_BLOCK_PTR( pUIBlock );
|
---|
2652 | }
|
---|
2653 |
|
---|
2654 | return( iRC );
|
---|
2655 | }
|
---|
2656 |
|
---|
2657 |
|
---|
2658 |
|
---|
2659 | //
|
---|
2660 | // WORK MORE MAGIC pt.1
|
---|
2661 | //
|
---|
2662 |
|
---|
2663 | INT ProcessUIConstraints( )
|
---|
2664 | {
|
---|
2665 | LONG ofsBlock1 = 0;
|
---|
2666 | LONG ofsBlock2 = 0;
|
---|
2667 | CHAR aKeyword1[ MAX_PSIZE ];
|
---|
2668 | CHAR aOption1[ MAX_PSIZE ];
|
---|
2669 | CHAR aKeyword2[ MAX_PSIZE ];
|
---|
2670 | CHAR aOption2[ MAX_PSIZE ];
|
---|
2671 | ULONG uOptionBit1, uOptionBit2;
|
---|
2672 | PUI_BLOCK pBlock1;
|
---|
2673 | PUI_BLOCK pBlock2;
|
---|
2674 | //PUIC_ENTRY pUICEntry1; NOTUSED
|
---|
2675 | //PUIC_ENTRY pUICEntry2; NOTUESD
|
---|
2676 | INT ofsOption = 0;
|
---|
2677 | PUIC_LIST pUICList;
|
---|
2678 | PUIC_BLOCK pUICCompare;
|
---|
2679 | UINT uiStrLen;
|
---|
2680 | INT iUICIndex;
|
---|
2681 | PUI_LIST pUIList = &desPpd.stUIList;
|
---|
2682 | PUIC_BLOCK pUICBlock = desPpd.stUICList.puicBlockList;
|
---|
2683 | INT iRC = cbBuffout;
|
---|
2684 |
|
---|
2685 | //PUIC_BLOCK pUICTemp; NOTUSED
|
---|
2686 |
|
---|
2687 | pUICList = &desPpd.stUICList;
|
---|
2688 | pUICList->puicBlockList = pUICList->puicBlockList;
|
---|
2689 |
|
---|
2690 | fbseek( &fbIn, (LONG) 0, SEEK_SET );
|
---|
2691 |
|
---|
2692 | while (ScanParam( szSearch[ UIConstraints ], pbPrBuffer ))
|
---|
2693 | {
|
---|
2694 | /*
|
---|
2695 | ** Set all arrays to NULL.
|
---|
2696 | */
|
---|
2697 | aKeyword1[ 0 ] = aKeyword2[ 0 ] = aOption1[ 0 ] = aOption2[ 0 ] = 0;
|
---|
2698 |
|
---|
2699 | /*
|
---|
2700 | ** Retrieve the first keyword string. The first keyword is required.
|
---|
2701 | */
|
---|
2702 | uiStrLen = MovePast( pbPrBuffer, ' ' );
|
---|
2703 | CopyWord( aKeyword1, pbPrBuffer + uiStrLen + 1 );
|
---|
2704 |
|
---|
2705 | /*
|
---|
2706 | ** Retrieve the first option string. The option string is optioal. An
|
---|
2707 | ** option string can be determined if the string does not begin with a '*'.
|
---|
2708 | */
|
---|
2709 | uiStrLen += MovePast( pbPrBuffer + uiStrLen, ' ' );
|
---|
2710 | if (*(pbPrBuffer + uiStrLen) != '*')
|
---|
2711 | {
|
---|
2712 | CopyWord( aOption1, pbPrBuffer + uiStrLen );
|
---|
2713 | }
|
---|
2714 |
|
---|
2715 | /*
|
---|
2716 | ** Retrieve the second keyword string. This string is also required.
|
---|
2717 | */
|
---|
2718 | uiStrLen += MovePast( pbPrBuffer + uiStrLen, ' ' );
|
---|
2719 | if (*(pbPrBuffer + uiStrLen) != 0x0D && *(pbPrBuffer + uiStrLen) == '*')
|
---|
2720 | {
|
---|
2721 | CopyWord( aKeyword2, pbPrBuffer + uiStrLen + 1 );
|
---|
2722 | }
|
---|
2723 |
|
---|
2724 | /*
|
---|
2725 | ** Retrieve the second option string. The option string is optioal. An
|
---|
2726 | ** option string can be determined if the string does not begin with a '*'.
|
---|
2727 | */
|
---|
2728 | uiStrLen += MovePast( pbPrBuffer + uiStrLen, ' ' );
|
---|
2729 | if (*(pbPrBuffer + uiStrLen) != 0x0D)
|
---|
2730 | {
|
---|
2731 | CopyWord( aOption2, pbPrBuffer + uiStrLen );
|
---|
2732 | }
|
---|
2733 |
|
---|
2734 | /*
|
---|
2735 | ** From the keywords extracted above, query the respective UI blocks.
|
---|
2736 | */
|
---|
2737 | pBlock1 = QueryBlockFromKeyword( pUIList, pbItemsBuffer,
|
---|
2738 | SearchKeySubst ( aKeyword1 ),
|
---|
2739 | (PINT) &ofsBlock1 );
|
---|
2740 | pBlock2 = QueryBlockFromKeyword( pUIList, pbItemsBuffer,
|
---|
2741 | SearchKeySubst ( aKeyword2 ),
|
---|
2742 | (PINT) &ofsBlock2 );
|
---|
2743 |
|
---|
2744 | /*
|
---|
2745 | ** If at least one block is NULL, then the keyword string is invalid. No
|
---|
2746 | ** processing needs to be done for invalid strings.
|
---|
2747 | */
|
---|
2748 | /*
|
---|
2749 | ** Do not include PageRegion in with the constraints. Constraints are
|
---|
2750 | ** reserved for UI blocks that have matching controls in either Printer
|
---|
2751 | ** or Job Properties, while PageRegion has no matching control (the form
|
---|
2752 | ** listbox is managed by PageSize).
|
---|
2753 | */
|
---|
2754 | if (pBlock1 != NULL && pBlock2 != NULL &&
|
---|
2755 | strcmp( aKeyword1, "PageRegion" ) && strcmp( aKeyword2, "PageRegion" ) )
|
---|
2756 | {
|
---|
2757 | /*
|
---|
2758 | ** If a valid option string is provided for the first and second
|
---|
2759 | ** keywords, then query the zero-based offset (ofsOption) of that entry.
|
---|
2760 | ** From that offset, set the appropriate zero-based bit (uOptionBit). If
|
---|
2761 | ** no option string exists for the appropriate keyword, then set all of
|
---|
2762 | ** the bits in uOptionBit to 1. This is because the lack of an option
|
---|
2763 | ** string for a keyword means that *ALL* options apply. Therefore, set
|
---|
2764 | ** all bits to 1.
|
---|
2765 | ** Again, this applies to both the first and second option (aOption1 and
|
---|
2766 | ** aOption2).
|
---|
2767 | */
|
---|
2768 | if (aOption1[ 0 ] != 0)
|
---|
2769 | {
|
---|
2770 | /*
|
---|
2771 | ** If the option string is invalid (no matching entry), then set
|
---|
2772 | ** the option bit to 0.
|
---|
2773 | */
|
---|
2774 | if (QueryEntryFromOption( pbItemsBuffer, pBlock1, aOption1,
|
---|
2775 | (PINT) &ofsOption ) != NULL)
|
---|
2776 | {
|
---|
2777 | uOptionBit1 = 1 << ofsOption;
|
---|
2778 | }
|
---|
2779 | else
|
---|
2780 | {
|
---|
2781 | uOptionBit1 = 0;
|
---|
2782 | }
|
---|
2783 | }
|
---|
2784 | else
|
---|
2785 | {
|
---|
2786 | /*
|
---|
2787 | ** The default value should never be a constraint.
|
---|
2788 | */
|
---|
2789 | // uOptionBit1 = (ULONG) -1;
|
---|
2790 | uOptionBit1 = (ULONG) ~(1 << pBlock1->usDefaultEntry);
|
---|
2791 | }
|
---|
2792 |
|
---|
2793 | if (aOption2[ 0 ] != 0)
|
---|
2794 | {
|
---|
2795 | /*
|
---|
2796 | ** If the option string is invalid (no matching entry), then set
|
---|
2797 | ** the option bit to 0.
|
---|
2798 | */
|
---|
2799 | if (QueryEntryFromOption( pbItemsBuffer, pBlock2, aOption2,
|
---|
2800 | (PINT) &ofsOption ) != NULL)
|
---|
2801 | {
|
---|
2802 | uOptionBit2 = 1 << ofsOption;
|
---|
2803 | }
|
---|
2804 | else
|
---|
2805 | {
|
---|
2806 | uOptionBit2 = 0;
|
---|
2807 | }
|
---|
2808 | }
|
---|
2809 | else
|
---|
2810 | {
|
---|
2811 | /*
|
---|
2812 | ** The default value should never be a constraint.
|
---|
2813 | */
|
---|
2814 | // uOptionBit2 = (ULONG) -1;
|
---|
2815 | uOptionBit2 = (ULONG) ~(1 << pBlock2->usDefaultEntry);
|
---|
2816 | }
|
---|
2817 |
|
---|
2818 | /*
|
---|
2819 | ** Just like the IF statement above for blocks, verify that the option
|
---|
2820 | ** selections are valid (not 0). If any option is invalid, then the
|
---|
2821 | ** constraint does not apply.
|
---|
2822 | */
|
---|
2823 | if (uOptionBit1 != 0 && uOptionBit2 != 0)
|
---|
2824 | {
|
---|
2825 | pUICCompare = pUICList->puicBlockList;
|
---|
2826 | for (iUICIndex = 0 ; iUICIndex < (INT) pUICList->usNumOfUICs ;
|
---|
2827 | iUICIndex++)
|
---|
2828 | {
|
---|
2829 | if (pUICCompare->uicEntry1.ofsUIBlock == ofsBlock1 &&
|
---|
2830 | pUICCompare->uicEntry2.ofsUIBlock == ofsBlock2)
|
---|
2831 | {
|
---|
2832 | if (pUICCompare->uicEntry1.bOption == uOptionBit1)
|
---|
2833 | {
|
---|
2834 | pUICCompare->uicEntry2.bOption |= uOptionBit2;
|
---|
2835 | break;
|
---|
2836 | }
|
---|
2837 | else if (pUICCompare->uicEntry2.bOption == uOptionBit2)
|
---|
2838 | {
|
---|
2839 | pUICCompare->uicEntry1.bOption |= uOptionBit1;
|
---|
2840 | break;
|
---|
2841 | }
|
---|
2842 | }
|
---|
2843 | else if (pUICCompare->uicEntry1.ofsUIBlock == ofsBlock2 &&
|
---|
2844 | pUICCompare->uicEntry2.ofsUIBlock == ofsBlock1)
|
---|
2845 | {
|
---|
2846 | if (pUICCompare->uicEntry1.bOption == uOptionBit2)
|
---|
2847 | {
|
---|
2848 | pUICCompare->uicEntry2.bOption |= uOptionBit1;
|
---|
2849 | break;
|
---|
2850 | }
|
---|
2851 | else if (pUICCompare->uicEntry2.bOption == uOptionBit1)
|
---|
2852 | {
|
---|
2853 | pUICCompare->uicEntry1.bOption |= uOptionBit2;
|
---|
2854 | break;
|
---|
2855 | }
|
---|
2856 | }
|
---|
2857 | pUICCompare++;
|
---|
2858 | }
|
---|
2859 |
|
---|
2860 | if (iUICIndex >= (INT) pUICList->usNumOfUICs ||
|
---|
2861 | pUICList->usNumOfUICs == 0)
|
---|
2862 | {
|
---|
2863 | pUICBlock = pUICList->puicBlockList + pUICList->usNumOfUICs++;
|
---|
2864 |
|
---|
2865 | pUICBlock->uicEntry1.ofsUIBlock = (USHORT) ofsBlock1;
|
---|
2866 | pUICBlock->uicEntry1.bOption = uOptionBit1;
|
---|
2867 |
|
---|
2868 | pUICBlock->uicEntry2.ofsUIBlock = (USHORT) ofsBlock2;
|
---|
2869 | pUICBlock->uicEntry2.bOption = uOptionBit2;
|
---|
2870 | }
|
---|
2871 | }
|
---|
2872 | }
|
---|
2873 | }
|
---|
2874 |
|
---|
2875 | return( iRC );
|
---|
2876 | }
|
---|
2877 |
|
---|
2878 |
|
---|
2879 |
|
---|
2880 |
|
---|
2881 |
|
---|
2882 | PUI_BLOCK QueryBlockFromKeyword( PUI_LIST pUIList, PBYTE pPSStringBuff,
|
---|
2883 | PBYTE pKeyword, PINT pofsBlock )
|
---|
2884 | {
|
---|
2885 | UINT uiLoop; // Local loop counter
|
---|
2886 | PBYTE pBlockName; // Name of current block
|
---|
2887 | PUI_BLOCK pInBlock = pUIList->pBlockList; // Input block pointer
|
---|
2888 | PUI_BLOCK pUIBlockRC = NULL; // Block return code
|
---|
2889 |
|
---|
2890 | if (pofsBlock != NULL)
|
---|
2891 | {
|
---|
2892 | *pofsBlock = -1;
|
---|
2893 | }
|
---|
2894 |
|
---|
2895 | for (uiLoop = 0 ; uiLoop < pUIList->usNumOfBlocks ; uiLoop++)
|
---|
2896 | {
|
---|
2897 | pBlockName = pInBlock->ofsUIName + pPSStringBuff;
|
---|
2898 |
|
---|
2899 | if (!stricmp( pBlockName, pKeyword ))
|
---|
2900 | {
|
---|
2901 | pUIBlockRC = pInBlock;
|
---|
2902 |
|
---|
2903 | if (pofsBlock != NULL)
|
---|
2904 | {
|
---|
2905 | *pofsBlock = (INT) uiLoop;
|
---|
2906 | }
|
---|
2907 |
|
---|
2908 | break;
|
---|
2909 | }
|
---|
2910 |
|
---|
2911 | INCREMENT_BLOCK_PTR( pInBlock );
|
---|
2912 | }
|
---|
2913 |
|
---|
2914 | return( pUIBlockRC );
|
---|
2915 | }
|
---|
2916 |
|
---|
2917 |
|
---|
2918 |
|
---|
2919 |
|
---|
2920 |
|
---|
2921 | PUI_ENTRY QueryEntryFromOption( PBYTE pPSStringBuff, PUI_BLOCK pUIBlock,
|
---|
2922 | PBYTE pOption, PINT pofsEntry )
|
---|
2923 | {
|
---|
2924 | UINT uiLoop; // Local loop counter
|
---|
2925 | PBYTE pEntryName; // Current UI Entry name
|
---|
2926 | PUI_ENTRY pEntryRC = NULL; // Current entry return code
|
---|
2927 |
|
---|
2928 | if (pofsEntry != NULL)
|
---|
2929 | {
|
---|
2930 | *pofsEntry = -1;
|
---|
2931 | }
|
---|
2932 |
|
---|
2933 | for (uiLoop = 0 ; uiLoop < pUIBlock->usNumOfEntries ; uiLoop++)
|
---|
2934 | {
|
---|
2935 | pEntryName = pUIBlock->uiEntry[ uiLoop ].ofsOption + pPSStringBuff;
|
---|
2936 |
|
---|
2937 | if (!strcmp( pOption, pEntryName ))
|
---|
2938 | {
|
---|
2939 | pEntryRC = &pUIBlock->uiEntry[ uiLoop ];
|
---|
2940 |
|
---|
2941 | if (pofsEntry != NULL)
|
---|
2942 | {
|
---|
2943 | *pofsEntry = (INT) uiLoop;
|
---|
2944 | }
|
---|
2945 |
|
---|
2946 | break;
|
---|
2947 | }
|
---|
2948 | }
|
---|
2949 |
|
---|
2950 | return( pEntryRC );
|
---|
2951 | }
|
---|
2952 |
|
---|
2953 |
|
---|
2954 |
|
---|
2955 |
|
---|
2956 |
|
---|
2957 | VOID ProcessCmdsAsUIs( )
|
---|
2958 | {
|
---|
2959 | CHAR aUIString[ MAX_PSIZE ];
|
---|
2960 | CHAR aTempString[ MAX_PSIZE ];
|
---|
2961 | CHAR aUIDefString[ MAX_PSIZE ];
|
---|
2962 | BOOL bBlockProcessed;
|
---|
2963 | INT iBlockIndex;
|
---|
2964 | INT iStrLen;
|
---|
2965 | INT iCurrEntry;
|
---|
2966 | INT iIndex;
|
---|
2967 | PSZ pTransString;
|
---|
2968 | INT iVar;
|
---|
2969 | BOOL fMatchFound;
|
---|
2970 | BOOL fKeywordFound;
|
---|
2971 | PUI_BLOCK pUIBlock = desPpd.stUIList.pBlockList;
|
---|
2972 | //USHORT usOrderDep = 0; NOTUSED
|
---|
2973 |
|
---|
2974 | for (iIndex = 0 ; iIndex < (INT) desPpd.stUIList.usNumOfBlocks ; iIndex++)
|
---|
2975 | {
|
---|
2976 | INCREMENT_BLOCK_PTR( pUIBlock );
|
---|
2977 | }
|
---|
2978 |
|
---|
2979 | strcpy( aUIDefString, "*Default" );
|
---|
2980 | for (iIndex = 0 ; iIndex < MAX_PREDEFINED ; iIndex++)
|
---|
2981 | {
|
---|
2982 | fMatchFound = FALSE;
|
---|
2983 | if (!strcmp( szPredefined[ iIndex ], "JCLResolution" ))
|
---|
2984 | {
|
---|
2985 | if (QueryBlockFromKeyword( &desPpd.stUIList, pbItemsBuffer,
|
---|
2986 | UINAME_RESOLUTION, NULL ) != NULL)
|
---|
2987 | {
|
---|
2988 | fMatchFound = TRUE;
|
---|
2989 | }
|
---|
2990 | }
|
---|
2991 |
|
---|
2992 | if (QueryBlockFromKeyword( &desPpd.stUIList, pbItemsBuffer,
|
---|
2993 | szPredefined[ iIndex ], NULL ) == NULL &&
|
---|
2994 | fMatchFound == FALSE)
|
---|
2995 | {
|
---|
2996 | iCurrEntry = 0;
|
---|
2997 | aUIString[ 0 ] = '*';
|
---|
2998 | strcpy( &aUIString[ 1 ], szPredefined[ iIndex ] );
|
---|
2999 |
|
---|
3000 | bBlockProcessed = FALSE;
|
---|
3001 | fKeywordFound = FALSE;
|
---|
3002 | fbseek( &fbIn, (long) 0, SEEK_SET );
|
---|
3003 | while (ScanParam( aUIString, pbPrBuffer ))
|
---|
3004 | {
|
---|
3005 | fKeywordFound = TRUE;
|
---|
3006 | iStrLen = 0;
|
---|
3007 | if (pUIBlock->ofsUIName == 0)
|
---|
3008 | {
|
---|
3009 | iBlockIndex = (INT) MatchKeywords( pbPrBuffer + 1, &desPpd.stUIList,
|
---|
3010 | pbItemsBuffer, TRUE );
|
---|
3011 |
|
---|
3012 | if (iBlockIndex == -1)
|
---|
3013 | {
|
---|
3014 | pUIBlock->ofsUIName = pUIBlock->ofsUITransString = cbBuffout;
|
---|
3015 |
|
---|
3016 | /*
|
---|
3017 | ** The default location is Document Setup. If not inserted,
|
---|
3018 | ** then the string is never sent out with the job.
|
---|
3019 | */
|
---|
3020 | pUIBlock->usUILocation = UI_ORDER_DOCSETUP;
|
---|
3021 |
|
---|
3022 | /*
|
---|
3023 | ** If found, then this is a pre-defined feature (do not display
|
---|
3024 | ** in "Features" page).
|
---|
3025 | */
|
---|
3026 | pUIBlock->ucPanelID = UIP_PREDEF_FEATURE;
|
---|
3027 |
|
---|
3028 | if (strcmp( szPredefined[ iIndex ], "SetResolution" ))
|
---|
3029 | {
|
---|
3030 | cbBuffout += CopyString( pbItemsBuffer + cbBuffout,
|
---|
3031 | szPredefined[ iIndex ],
|
---|
3032 | MAX_PSIZE,
|
---|
3033 | CSTR_INCLUDE_SLASH );
|
---|
3034 | }
|
---|
3035 | else
|
---|
3036 | {
|
---|
3037 | cbBuffout += CopyString( pbItemsBuffer + cbBuffout,
|
---|
3038 | &szPredefined[ iIndex ][ 3 ],
|
---|
3039 | MAX_PSIZE,
|
---|
3040 | CSTR_INCLUDE_SLASH );
|
---|
3041 | }
|
---|
3042 | }
|
---|
3043 | else
|
---|
3044 | {
|
---|
3045 | pUIBlock->ofsUIName = pUIBlock->ofsUITransString = iBlockIndex;
|
---|
3046 | }
|
---|
3047 | }
|
---|
3048 |
|
---|
3049 | pTransString = (PSZ) pbPrBuffer;
|
---|
3050 | while (*pTransString != ' ' && *pTransString != '/')
|
---|
3051 | {
|
---|
3052 | pTransString++;
|
---|
3053 | }
|
---|
3054 |
|
---|
3055 | if (*pTransString == '/')
|
---|
3056 | {
|
---|
3057 | *pTransString = 0;
|
---|
3058 | }
|
---|
3059 | else
|
---|
3060 | {
|
---|
3061 | pTransString = NULL;
|
---|
3062 | }
|
---|
3063 |
|
---|
3064 | /*
|
---|
3065 | ** Copy the Option.
|
---|
3066 | */
|
---|
3067 | iStrLen = CopyString( pbItemsBuffer + cbBuffout,
|
---|
3068 | pbPrBuffer,
|
---|
3069 | 80,
|
---|
3070 | CSTR_NORMAL );
|
---|
3071 | pUIBlock->uiEntry[ iCurrEntry ].ofsOption = cbBuffout;
|
---|
3072 |
|
---|
3073 | cbBuffout += iStrLen;
|
---|
3074 |
|
---|
3075 | if (pTransString != NULL)
|
---|
3076 | {
|
---|
3077 | iVar = CopyString( pbItemsBuffer + cbBuffout,
|
---|
3078 | pbPrBuffer + iStrLen,
|
---|
3079 | 80,
|
---|
3080 | CSTR_NORMAL );
|
---|
3081 | pUIBlock->uiEntry[ iCurrEntry ].ofsTransString = cbBuffout;
|
---|
3082 | cbBuffout += iVar;
|
---|
3083 | iStrLen += iVar;
|
---|
3084 | }
|
---|
3085 | else
|
---|
3086 | {
|
---|
3087 | pUIBlock->uiEntry[ iCurrEntry ].ofsTransString =
|
---|
3088 | pUIBlock->uiEntry[ iCurrEntry ].ofsOption;
|
---|
3089 | }
|
---|
3090 |
|
---|
3091 | /*
|
---|
3092 | ** skip the " character
|
---|
3093 | */
|
---|
3094 | do
|
---|
3095 | {
|
---|
3096 | iStrLen++;
|
---|
3097 | } while (*(pbPrBuffer + iStrLen - 1) != '"');
|
---|
3098 |
|
---|
3099 | /*
|
---|
3100 | ** copies the string delimited by a blank or quote.
|
---|
3101 | */
|
---|
3102 | iStrLen = CopyInQuote( pbItemsBuffer + cbBuffout,
|
---|
3103 | pbPrBuffer + iStrLen, FALSE, NOCOMPRESS );
|
---|
3104 | pUIBlock->uiEntry[ iCurrEntry++ ].ofsValue = cbBuffout;
|
---|
3105 | cbBuffout += iStrLen;
|
---|
3106 |
|
---|
3107 | pUIBlock->usNumOfEntries++;
|
---|
3108 | bBlockProcessed = TRUE;
|
---|
3109 | }
|
---|
3110 |
|
---|
3111 | if (fKeywordFound == TRUE)
|
---|
3112 | {
|
---|
3113 | strcpy( &aUIDefString[ 8 ], szPredefined[ iIndex ] );
|
---|
3114 | fbseek( &fbIn, (long) 0, SEEK_SET );
|
---|
3115 |
|
---|
3116 | if (ScanParam( aUIDefString, pbPrBuffer ))
|
---|
3117 | {
|
---|
3118 | iStrLen = 0;
|
---|
3119 | while (*(pbPrBuffer + iStrLen) == ':' ||
|
---|
3120 | *(pbPrBuffer + iStrLen) == ' ')
|
---|
3121 | {
|
---|
3122 | iStrLen++;
|
---|
3123 | }
|
---|
3124 |
|
---|
3125 | CopyWord( aTempString, pbPrBuffer + iStrLen );
|
---|
3126 |
|
---|
3127 | for (iBlockIndex = 0 ; iBlockIndex < pUIBlock->usNumOfEntries ;
|
---|
3128 | iBlockIndex++)
|
---|
3129 | {
|
---|
3130 | if (!strcmp( pUIBlock->uiEntry[ iBlockIndex ].ofsOption +
|
---|
3131 | pbItemsBuffer, aTempString ))
|
---|
3132 | {
|
---|
3133 | pUIBlock->usDefaultEntry = (USHORT) iBlockIndex;
|
---|
3134 | break;
|
---|
3135 | }
|
---|
3136 | }
|
---|
3137 | }
|
---|
3138 |
|
---|
3139 | if (bBlockProcessed == TRUE)
|
---|
3140 | {
|
---|
3141 | desPpd.stUIList.usBlockListSize += QUERY_BLOCK_SIZE( pUIBlock );
|
---|
3142 | desPpd.stUIList.usNumOfBlocks++;
|
---|
3143 | INCREMENT_BLOCK_PTR( pUIBlock );
|
---|
3144 | }
|
---|
3145 | }
|
---|
3146 | }
|
---|
3147 | }
|
---|
3148 |
|
---|
3149 | pUIBlock = desPpd.stUIList.pBlockList;
|
---|
3150 | for (iVar = 0 ; iVar < desPpd.stUIList.usNumOfBlocks ; iVar++)
|
---|
3151 | {
|
---|
3152 | pUIBlock->usOrderDep = (USHORT) iVar;
|
---|
3153 | INCREMENT_BLOCK_PTR( pUIBlock );
|
---|
3154 | }
|
---|
3155 | }
|
---|
3156 |
|
---|
3157 |
|
---|
3158 |
|
---|
3159 |
|
---|
3160 | INT CopyWord( PCHAR pDestn, PCHAR pSource )
|
---|
3161 | {
|
---|
3162 | INT iStrLen = 0;
|
---|
3163 |
|
---|
3164 | while (!isspace( *pSource ) && *pSource != ':')
|
---|
3165 | {
|
---|
3166 | *(pDestn++) = *(pSource++);
|
---|
3167 | iStrLen = 0;
|
---|
3168 | }
|
---|
3169 | *pDestn = 0;
|
---|
3170 |
|
---|
3171 | return( iStrLen );
|
---|
3172 | }
|
---|
3173 |
|
---|
3174 |
|
---|
3175 | BOOL ParsePPDLang( PSZ pFileLine,
|
---|
3176 | PSZ pOutString
|
---|
3177 | )
|
---|
3178 | {
|
---|
3179 | PSZ pColonChar;
|
---|
3180 | PSZ pParseChar;
|
---|
3181 | BOOL fRC = FALSE;
|
---|
3182 |
|
---|
3183 | *pOutString = 0;
|
---|
3184 |
|
---|
3185 | if ((pColonChar = strchr( pFileLine, ':' )) != NULL)
|
---|
3186 | {
|
---|
3187 | pParseChar = pColonChar + 1;
|
---|
3188 | while (*pParseChar == ' ')
|
---|
3189 | {
|
---|
3190 | pParseChar++;
|
---|
3191 | }
|
---|
3192 |
|
---|
3193 | while (*pParseChar != '\n' && *pParseChar != ' ' && *pParseChar != 0)
|
---|
3194 | {
|
---|
3195 | *(pOutString++) = *(pParseChar++);
|
---|
3196 | }
|
---|
3197 | *pOutString = 0;
|
---|
3198 |
|
---|
3199 | while (*pColonChar != 'L' && pColonChar >= pFileLine)
|
---|
3200 | {
|
---|
3201 | pColonChar--;
|
---|
3202 | }
|
---|
3203 | *pColonChar = 0;
|
---|
3204 |
|
---|
3205 | fRC = TRUE;
|
---|
3206 | }
|
---|
3207 |
|
---|
3208 | return( fRC );
|
---|
3209 | }
|
---|
3210 |
|
---|
3211 |
|
---|
3212 |
|
---|
3213 | VOID VerifyUICList( )
|
---|
3214 | {
|
---|
3215 | LONG lLoop;
|
---|
3216 | PUIC_BLOCK pUICBlock = desPpd.stUICList.puicBlockList;
|
---|
3217 |
|
---|
3218 | for (lLoop = 0 ; lLoop < (LONG) desPpd.stUICList.usNumOfUICs ; lLoop++)
|
---|
3219 | {
|
---|
3220 | if (pUICBlock->uicEntry1.bOption == (UI_SEL) -1)
|
---|
3221 | {
|
---|
3222 | pUICBlock->uicEntry1.bOption = 0;
|
---|
3223 | }
|
---|
3224 |
|
---|
3225 | if (pUICBlock->uicEntry2.bOption == (UI_SEL) -1)
|
---|
3226 | {
|
---|
3227 | pUICBlock->uicEntry2.bOption = 0;
|
---|
3228 | }
|
---|
3229 |
|
---|
3230 | pUICBlock++;
|
---|
3231 | }
|
---|
3232 | }
|
---|
3233 |
|
---|
3234 |
|
---|
3235 |
|
---|
3236 |
|
---|
3237 |
|
---|
3238 |
|
---|
3239 |
|
---|
3240 | //
|
---|
3241 | // THE PUBLIC INTERFACE
|
---|
3242 | //
|
---|
3243 |
|
---|
3244 | int Conv_PPD_Init(void)
|
---|
3245 | {
|
---|
3246 | PUI_LIST pUIList = &desPpd.stUIList;
|
---|
3247 |
|
---|
3248 | printf("initalize converter\n");
|
---|
3249 |
|
---|
3250 | /*
|
---|
3251 | */
|
---|
3252 | memset( pUIList, 0, sizeof( UI_LIST ) );
|
---|
3253 | DosAllocMem( (PPVOID) &pUIList->pBlockList, 12288, /*4096,*/
|
---|
3254 | PAG_READ | PAG_WRITE | PAG_COMMIT );
|
---|
3255 | memset( pUIList->pBlockList, 0, 4096 );
|
---|
3256 |
|
---|
3257 | memset( &desPpd.stUICList, 0, sizeof( UIC_LIST ) );
|
---|
3258 | DosAllocMem( (PPVOID) &desPpd.stUICList.puicBlockList, 12288,/*4096,*/
|
---|
3259 | PAG_READ | PAG_WRITE | PAG_COMMIT );
|
---|
3260 |
|
---|
3261 |
|
---|
3262 | BuildHashTable();
|
---|
3263 |
|
---|
3264 | /*
|
---|
3265 | ** allocate memory for items buffer
|
---|
3266 | */
|
---|
3267 | if ((pbItemsBuffer = malloc(PRBUFSZ * 24)) == NULL)
|
---|
3268 | {
|
---|
3269 | RepError( err_cantopen, NULL );
|
---|
3270 | }
|
---|
3271 |
|
---|
3272 | return 1;
|
---|
3273 | }
|
---|
3274 |
|
---|
3275 |
|
---|
3276 | /***************************************************************************
|
---|
3277 | *
|
---|
3278 | * FUNCTION NAME =
|
---|
3279 | *
|
---|
3280 | * DESCRIPTION = Function Mainline
|
---|
3281 | *
|
---|
3282 | *
|
---|
3283 | * INPUT =
|
---|
3284 | *
|
---|
3285 | * OUTPUT = NONE.
|
---|
3286 | *
|
---|
3287 | * RETURN-NORMAL = NONE.
|
---|
3288 | * RETURN-ERROR = NONE.
|
---|
3289 | *
|
---|
3290 | ************************************************************************* */
|
---|
3291 |
|
---|
3292 | int Conv_PPD_WritePPB( PSZ pszInFile, FILE *fhOut, PSZ pszDeviceName)
|
---|
3293 | {
|
---|
3294 | int i;
|
---|
3295 | int iPPBCount;
|
---|
3296 | char *pc;
|
---|
3297 | UINT uiOutDirLen;
|
---|
3298 | CHAR szOutFile[CCHMAXPATH];
|
---|
3299 |
|
---|
3300 | PUI_LIST pUIList = &desPpd.stUIList;
|
---|
3301 |
|
---|
3302 | printf(".");
|
---|
3303 |
|
---|
3304 | // check parameters
|
---|
3305 | if(pszInFile == NULL ||
|
---|
3306 | fhOut == NULL ||
|
---|
3307 | pszDeviceName == NULL)
|
---|
3308 | {
|
---|
3309 | return FALSE; // fail if not good
|
---|
3310 | }
|
---|
3311 |
|
---|
3312 |
|
---|
3313 | /*
|
---|
3314 | */
|
---|
3315 |
|
---|
3316 | cbBuffout = 0;
|
---|
3317 |
|
---|
3318 | if (!Openppd(pszInFile))
|
---|
3319 | {
|
---|
3320 | // Ignore PPD files that aren't found.
|
---|
3321 | RepWarning(err_cantopen,"ppd");
|
---|
3322 | return FALSE;
|
---|
3323 | }
|
---|
3324 |
|
---|
3325 | printf(".");
|
---|
3326 |
|
---|
3327 | sFormCount = 0; /* init for each ppd */
|
---|
3328 | /*
|
---|
3329 | ** Parse and create the PPD segment
|
---|
3330 | */
|
---|
3331 | BErrorWasDisplayed = FALSE;
|
---|
3332 | iShrinkage = 0;
|
---|
3333 | if (FormPpd())
|
---|
3334 | {
|
---|
3335 | strcpy( pszDeviceName, pbItemsBuffer + desPpd.desItems.ofsPrName );
|
---|
3336 |
|
---|
3337 | printf(".");
|
---|
3338 |
|
---|
3339 | if (!fhOut)
|
---|
3340 | {
|
---|
3341 | RepError( err_cantcreate, "ppb" );
|
---|
3342 | }
|
---|
3343 |
|
---|
3344 | printf(".");
|
---|
3345 |
|
---|
3346 | /*
|
---|
3347 | ** write the printer descriptor segment onto output file
|
---|
3348 | */
|
---|
3349 | if (fwrite( (char *) &desPpd,1,sizeof( desPpd ),fhOut) != sizeof(desPpd))
|
---|
3350 | {
|
---|
3351 | RepError( err_output, NULL );
|
---|
3352 | }
|
---|
3353 |
|
---|
3354 | printf(".");
|
---|
3355 |
|
---|
3356 | /*
|
---|
3357 | */
|
---|
3358 | if (pUIList->pBlockList != NULL)
|
---|
3359 | {
|
---|
3360 | fwrite( pUIList->pBlockList, 1, desPpd.stUIList.usBlockListSize,
|
---|
3361 | fhOut );
|
---|
3362 | memset( pUIList->pBlockList, 0, 4096 );
|
---|
3363 | }
|
---|
3364 | pUIList->usNumOfBlocks = 0;
|
---|
3365 | pUIList->usBlockListSize = 0;
|
---|
3366 |
|
---|
3367 | if (desPpd.stUICList.usNumOfUICs > 0)
|
---|
3368 | {
|
---|
3369 | fwrite( desPpd.stUICList.puicBlockList, 1,
|
---|
3370 | desPpd.stUICList.usNumOfUICs * sizeof( UIC_BLOCK ), fhOut );
|
---|
3371 | memset( desPpd.stUICList.puicBlockList, 0, 4096 );
|
---|
3372 | }
|
---|
3373 |
|
---|
3374 | printf(".");
|
---|
3375 |
|
---|
3376 | /*
|
---|
3377 | ** write the items buffer which contain various names ,commands and
|
---|
3378 | ** dimensions lists
|
---|
3379 | */
|
---|
3380 | /* ftell( fhOut ); debug */
|
---|
3381 | if (fwrite( pbItemsBuffer, 1, cbBuffout, fhOut) != cbBuffout)
|
---|
3382 | {
|
---|
3383 | RepError( err_output1, NULL );
|
---|
3384 | }
|
---|
3385 | cbBuffout = 0;
|
---|
3386 | printf(".");
|
---|
3387 |
|
---|
3388 | /*
|
---|
3389 | */
|
---|
3390 |
|
---|
3391 | /*
|
---|
3392 | ** Close the ppb
|
---|
3393 | */
|
---|
3394 | }
|
---|
3395 | else
|
---|
3396 | return FALSE;
|
---|
3397 |
|
---|
3398 | printf(".");
|
---|
3399 |
|
---|
3400 | return TRUE;
|
---|
3401 | }
|
---|
3402 |
|
---|
3403 |
|
---|
3404 | void Conv_PPD_Done()
|
---|
3405 | {
|
---|
3406 | // destroy
|
---|
3407 | /*
|
---|
3408 | ** Free the block list
|
---|
3409 | */
|
---|
3410 | DosFreeMem( desPpd.stUIList.pBlockList );
|
---|
3411 | DosFreeMem( desPpd.stUICList.puicBlockList );
|
---|
3412 | }
|
---|
3413 |
|
---|