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