1 |
|
---|
2 | #include "uni.h"
|
---|
3 |
|
---|
4 | #include <stdlib.h>
|
---|
5 | #include <string.h>
|
---|
6 | #include <ctype.h>
|
---|
7 | #include <stdarg.h>
|
---|
8 | #include <stdio.h>
|
---|
9 | #include <stdlib.h>
|
---|
10 | #include <process.h>
|
---|
11 | #include "utils.h"
|
---|
12 |
|
---|
13 | //
|
---|
14 | // If port driver is not defined in INI file yet
|
---|
15 | // assume it exists in the boot drive's \OS2\DLL directory
|
---|
16 | //
|
---|
17 |
|
---|
18 | CHAR szDefaultPortDrvPath[] = { PATH_UNI_PDR };
|
---|
19 |
|
---|
20 |
|
---|
21 | APIRET APIENTRY SplPdEnumPort ( HAB hab,
|
---|
22 | PVOID pBuf,
|
---|
23 | ULONG cbBuf,
|
---|
24 | PULONG pulReturned,
|
---|
25 | PULONG pulTotal,
|
---|
26 | PULONG pcbRequired )
|
---|
27 |
|
---|
28 | {
|
---|
29 | HMODULE hModule;
|
---|
30 | ULONG ulBootDrive;
|
---|
31 | ULONG rcLoadMod;
|
---|
32 | CHAR szPathName[260];
|
---|
33 |
|
---|
34 | if (!pulReturned ||
|
---|
35 | !pulTotal ||
|
---|
36 | !pcbRequired)
|
---|
37 | {
|
---|
38 | return(ERROR_INVALID_PARAMETER);
|
---|
39 | }
|
---|
40 |
|
---|
41 | if (!pBuf && cbBuf)
|
---|
42 | {
|
---|
43 | return(ERROR_INVALID_PARAMETER);
|
---|
44 | }
|
---|
45 |
|
---|
46 | DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive,
|
---|
47 | sizeof (ULONG));
|
---|
48 | szDefaultPortDrvPath[0] = (CHAR)(ulBootDrive + 'A' - 1);
|
---|
49 |
|
---|
50 | PrfQueryProfileString (HINI_SYSTEMPROFILE,
|
---|
51 | "PM_PORT_DRIVER",
|
---|
52 | "UNI",
|
---|
53 | szDefaultPortDrvPath,
|
---|
54 | szPathName,
|
---|
55 | 256 );
|
---|
56 |
|
---|
57 | rcLoadMod = DosLoadModule (NULL, 0, szPathName, &hModule);
|
---|
58 |
|
---|
59 | if (cbBuf == 0L)
|
---|
60 | {
|
---|
61 | *pulReturned = 0;
|
---|
62 | *pcbRequired = CalcBufLength (hab, hModule);
|
---|
63 | *pulTotal = MAX_PORTS;
|
---|
64 | if (!rcLoadMod)
|
---|
65 | DosFreeModule (hModule);
|
---|
66 | return(ERROR_MORE_DATA);
|
---|
67 | }
|
---|
68 |
|
---|
69 | /*
|
---|
70 | ** check number of ports info we can fit in supplied buffer
|
---|
71 | */
|
---|
72 | *pulTotal = MAX_PORTS;
|
---|
73 | *pcbRequired = CalcBufLength (hab, hModule);
|
---|
74 | *pulReturned = NumPortsCanFit (hab, hModule, cbBuf);
|
---|
75 |
|
---|
76 | /*
|
---|
77 | ** return error if we can not fit one port.
|
---|
78 | */
|
---|
79 | if (!(*pulReturned))
|
---|
80 | {
|
---|
81 | if (!rcLoadMod)
|
---|
82 | DosFreeModule (hModule);
|
---|
83 | return(ERROR_INSUFFICIENT_BUFFER);
|
---|
84 | }
|
---|
85 |
|
---|
86 | /*
|
---|
87 | ** copy all the ports which we can store in the pBuf
|
---|
88 | */
|
---|
89 | CopyNPorts (hab, hModule, (PCH)pBuf, *pulReturned);
|
---|
90 |
|
---|
91 | /*
|
---|
92 | ** Free the module - we do not need it any more.
|
---|
93 | */
|
---|
94 | if (!rcLoadMod)
|
---|
95 | DosFreeModule (hModule);
|
---|
96 |
|
---|
97 | /*
|
---|
98 | ** copy all the ports which we can store in the pBuf
|
---|
99 | */
|
---|
100 | if (*pulReturned < *pulTotal)
|
---|
101 | {
|
---|
102 | return(ERROR_MORE_DATA);
|
---|
103 | }
|
---|
104 |
|
---|
105 | return(NO_ERROR);
|
---|
106 | }
|
---|
107 | APIRET APIENTRY SplPdInstallPort ( HAB hab,
|
---|
108 | PSZ pszPortName )
|
---|
109 | {
|
---|
110 | CHAR chBuf[STR_LEN_PORTNAME];
|
---|
111 | CHAR chPortDesc[STR_LEN_PORTDESC];
|
---|
112 | ULONG ulBootDrive;
|
---|
113 | HMODULE hModule;
|
---|
114 | CHAR szPathName[260]; /* will contain full path to this port driver */
|
---|
115 |
|
---|
116 | if (!pszPortName)
|
---|
117 | {
|
---|
118 | return(ERROR_INVALID_PARAMETER);
|
---|
119 | }
|
---|
120 | strcpy(szDefaultPortDrvPath,PATH_UNI_PDR);
|
---|
121 | DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive,
|
---|
122 | sizeof (ULONG));
|
---|
123 | szDefaultPortDrvPath[0] = (CHAR)(ulBootDrive + 'A' - 1);
|
---|
124 | strcpy( szPathName, szDefaultPortDrvPath );
|
---|
125 |
|
---|
126 | /* Make sure the port driver itself is installed */
|
---|
127 | PrfWriteProfileString (HINI_SYSTEMPROFILE,
|
---|
128 | "PM_PORT_DRIVER",
|
---|
129 | "UNI",
|
---|
130 | szDefaultPortDrvPath);
|
---|
131 |
|
---|
132 | /* Generate appname for "PM_UNIx" */
|
---|
133 | strcpy (chBuf, APPNAME_LEAD_STR);
|
---|
134 | strcat (chBuf, pszPortName);
|
---|
135 |
|
---|
136 | /*
|
---|
137 | ** Check for this being our default Port Name to install.
|
---|
138 | ** If so (pszPortName == "UNI") then generate a unique
|
---|
139 | ** port name so that we can install multiple UNI printers.
|
---|
140 | */
|
---|
141 | if (!strcmp(pszPortName, DEF_PORTNAME))
|
---|
142 | {
|
---|
143 | /*
|
---|
144 | ** Use chBuf to store the new portname to install
|
---|
145 | ** Must first increment past "PM_" in chBuf
|
---|
146 | */
|
---|
147 | pszPortName = chBuf + 3;
|
---|
148 | GenerateUniquePortName( pszPortName );
|
---|
149 | }
|
---|
150 |
|
---|
151 | /* Get initial port description (fall back to portname if unavailable) */
|
---|
152 | hModule = 0L ; /* Init module handle to null */
|
---|
153 | DosLoadModule (NULL, 0, szPathName, &hModule);
|
---|
154 | if (!GetPortDescription (hab, hModule, pszPortName, chPortDesc))
|
---|
155 | {
|
---|
156 | strcpy( chPortDesc, pszPortName );
|
---|
157 | }
|
---|
158 | DosFreeModule (hModule);
|
---|
159 |
|
---|
160 | if (!PrfWriteProfileString (HINI_SYSTEMPROFILE,
|
---|
161 | chBuf,
|
---|
162 | KEY_DESCRIPTION,
|
---|
163 | chPortDesc))
|
---|
164 | {
|
---|
165 | return (WinGetLastError (hab));
|
---|
166 | }
|
---|
167 |
|
---|
168 | if (!PrfWriteProfileString (HINI_SYSTEMPROFILE,
|
---|
169 | chBuf,
|
---|
170 | KEY_INITIALIZATION,
|
---|
171 | DEF_INITIALIZATION))
|
---|
172 | {
|
---|
173 | return (WinGetLastError (hab));
|
---|
174 | }
|
---|
175 |
|
---|
176 | if (!PrfWriteProfileString (HINI_SYSTEMPROFILE,
|
---|
177 | chBuf,
|
---|
178 | KEY_TERMINATION,
|
---|
179 | DEF_TERMINATION))
|
---|
180 | {
|
---|
181 | return (WinGetLastError (hab));
|
---|
182 | }
|
---|
183 |
|
---|
184 | if (!PrfWriteProfileString (HINI_SYSTEMPROFILE,
|
---|
185 | chBuf,
|
---|
186 | KEY_PORTDRIVER,
|
---|
187 | DEF_PORTDRIVER))
|
---|
188 | {
|
---|
189 | return (WinGetLastError (hab));
|
---|
190 | }
|
---|
191 |
|
---|
192 | if (!PrfWriteProfileString (HINI_SYSTEMPROFILE,
|
---|
193 | chBuf,
|
---|
194 | KEY_TIMEOUT,
|
---|
195 | DEF_TIMEOUT))
|
---|
196 | {
|
---|
197 | return (WinGetLastError (hab));
|
---|
198 | }
|
---|
199 | if (!PrfWriteProfileString (HINI_SYSTEMPROFILE,
|
---|
200 | APPNAME_PM_SPOOLER_PORT,
|
---|
201 | pszPortName,
|
---|
202 | DEF_INITIALIZATION))
|
---|
203 | {
|
---|
204 | return (WinGetLastError (hab));
|
---|
205 | }
|
---|
206 | return(NO_ERROR);
|
---|
207 | }
|
---|
208 | BOOL APIENTRY SplPdGetPortIcon ( HAB hab,
|
---|
209 | PULONG idIcon )
|
---|
210 | {
|
---|
211 | if (idIcon)
|
---|
212 | {
|
---|
213 | *idIcon = UNI_ICON;
|
---|
214 | }
|
---|
215 | return(TRUE);
|
---|
216 | }
|
---|
217 | APIRET APIENTRY SplPdQueryPort ( HAB hab,
|
---|
218 | PSZ pszPortName,
|
---|
219 | PVOID pBufIn,
|
---|
220 | ULONG cbBuf,
|
---|
221 | PULONG cItems )
|
---|
222 | {
|
---|
223 | HMODULE hModule;
|
---|
224 | CHAR chString[STR_LEN_DESC];
|
---|
225 | USHORT usNumLines;
|
---|
226 | USHORT usLineID;
|
---|
227 | USHORT usStrLength;
|
---|
228 | ULONG ulBootDrive;
|
---|
229 | PCH pBuf = pBufIn;
|
---|
230 | CHAR szPathName[260]; /* will contain full path to this port driver */
|
---|
231 |
|
---|
232 | if (!cItems)
|
---|
233 | {
|
---|
234 | return(ERROR_INVALID_PARAMETER);
|
---|
235 | }
|
---|
236 |
|
---|
237 | if (!pBuf || !cbBuf)
|
---|
238 | {
|
---|
239 | return(ERROR_INVALID_PARAMETER);
|
---|
240 | }
|
---|
241 |
|
---|
242 |
|
---|
243 | DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive,
|
---|
244 | sizeof (ULONG));
|
---|
245 | szDefaultPortDrvPath[0] = (CHAR)(ulBootDrive + 'A' - 1);
|
---|
246 |
|
---|
247 | PrfQueryProfileString (HINI_SYSTEMPROFILE,
|
---|
248 | "PM_PORT_DRIVER",
|
---|
249 | "UNI",
|
---|
250 | szDefaultPortDrvPath,
|
---|
251 | szPathName,
|
---|
252 | 256 );
|
---|
253 |
|
---|
254 | hModule = 0L ;
|
---|
255 |
|
---|
256 | DosLoadModule (NULL, 0, szPathName, &hModule);
|
---|
257 |
|
---|
258 | chString[0] = '\0' ;
|
---|
259 |
|
---|
260 | WinLoadString(hab, hModule, (USHORT)ID_NUMBER_OF_DESC_LINES, STR_LEN_DESC,
|
---|
261 | chString);
|
---|
262 | usNumLines = (USHORT)atoi (chString);
|
---|
263 | usLineID = ID_FIRST_DESC_LINES;
|
---|
264 | for (*cItems = 0; *cItems < usNumLines; *cItems++)
|
---|
265 | {
|
---|
266 | WinLoadString(hab, hModule, usLineID, STR_LEN_DESC, chString);
|
---|
267 | if (cbBuf >= (usStrLength = (USHORT)(strlen (chString) + 1)))
|
---|
268 | {
|
---|
269 | strcpy (pBuf, chString);
|
---|
270 | pBuf += usStrLength;
|
---|
271 | cbBuf -= usStrLength;
|
---|
272 | }
|
---|
273 | else
|
---|
274 | {
|
---|
275 | DosFreeModule (hModule);
|
---|
276 | return(ERROR_INSUFFICIENT_BUFFER);
|
---|
277 | }
|
---|
278 | }
|
---|
279 | DosFreeModule (hModule);
|
---|
280 | return(NO_ERROR);
|
---|
281 | }
|
---|
282 | APIRET APIENTRY SplPdSetPort ( HAB hab,
|
---|
283 | PSZ pszPortName,
|
---|
284 | PULONG flModified )
|
---|
285 | {
|
---|
286 | CHAR chBuf[STR_LEN_PORTNAME];
|
---|
287 | CHAR chPortDriver[STR_LEN_PORTNAME];
|
---|
288 | ULONG ulBootDrive;
|
---|
289 | HMODULE hModule;
|
---|
290 | CHAR szPathName[260]; /* will contain full path to this port driver */
|
---|
291 |
|
---|
292 | if (!pszPortName || !flModified)
|
---|
293 | {
|
---|
294 | return(ERROR_INVALID_PARAMETER);
|
---|
295 | }
|
---|
296 |
|
---|
297 | strcpy (chBuf, APPNAME_LEAD_STR);
|
---|
298 | strcat (chBuf, pszPortName);
|
---|
299 |
|
---|
300 | if (!(PrfQueryProfileString (HINI_SYSTEMPROFILE, chBuf,
|
---|
301 | KEY_PORTDRIVER, NULL, chPortDriver,
|
---|
302 | STR_LEN_PORTNAME)))
|
---|
303 | {
|
---|
304 | return(ERROR_INVALID_PARAMETER);
|
---|
305 | }
|
---|
306 |
|
---|
307 | if (strcmp (chPortDriver, DEF_PORTDRIVER))
|
---|
308 | {
|
---|
309 | return(ERROR_INVALID_PARAMETER);
|
---|
310 | }
|
---|
311 |
|
---|
312 | DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive,
|
---|
313 | sizeof (ULONG));
|
---|
314 | szDefaultPortDrvPath[0] = (CHAR)(ulBootDrive + 'A' - 1);
|
---|
315 |
|
---|
316 | PrfQueryProfileString (HINI_SYSTEMPROFILE,
|
---|
317 | "PM_PORT_DRIVER",
|
---|
318 | "UNI",
|
---|
319 | szDefaultPortDrvPath,
|
---|
320 | szPathName,
|
---|
321 | 256 );
|
---|
322 |
|
---|
323 | hModule = 0L ; /* Init module handle to null */
|
---|
324 |
|
---|
325 | DosLoadModule (NULL, 0, szPathName, &hModule);
|
---|
326 |
|
---|
327 | *flModified = OpenUniPortDlg (hab, hModule, pszPortName, chBuf);
|
---|
328 |
|
---|
329 | DosFreeModule (hModule);
|
---|
330 | return(NO_ERROR);
|
---|
331 | }
|
---|
332 |
|
---|
333 |
|
---|
334 | APIRET APIENTRY SplPdRemovePort ( HAB hab,
|
---|
335 | PSZ pszPortName )
|
---|
336 | {
|
---|
337 | CHAR chBuf[STR_LEN_PORTNAME];
|
---|
338 | CHAR chPortDriver[STR_LEN_PORTNAME];
|
---|
339 |
|
---|
340 | if (!pszPortName)
|
---|
341 | {
|
---|
342 | return(ERROR_INVALID_PARAMETER);
|
---|
343 | }
|
---|
344 |
|
---|
345 | strcpy (chBuf, APPNAME_LEAD_STR);
|
---|
346 | strcat (chBuf, pszPortName);
|
---|
347 |
|
---|
348 | if (!(PrfQueryProfileString (HINI_SYSTEMPROFILE, chBuf,
|
---|
349 | KEY_PORTDRIVER, NULL, chPortDriver,
|
---|
350 | STR_LEN_PORTNAME)))
|
---|
351 | {
|
---|
352 | return(ERROR_INVALID_PARAMETER);
|
---|
353 | }
|
---|
354 |
|
---|
355 | if (strcmp (chPortDriver, DEF_PORTDRIVER))
|
---|
356 | {
|
---|
357 | return(ERROR_INVALID_PARAMETER);
|
---|
358 | }
|
---|
359 |
|
---|
360 | PrfWriteProfileString (HINI_SYSTEMPROFILE, chBuf, NULL, NULL);
|
---|
361 |
|
---|
362 | PrfWriteProfileString (HINI_SYSTEMPROFILE,
|
---|
363 | APPNAME_PM_SPOOLER_PORT,
|
---|
364 | pszPortName,
|
---|
365 | NULL);
|
---|
366 | return(NO_ERROR);
|
---|
367 |
|
---|
368 | }
|
---|
369 | ULONG APIENTRY SplPdOpen( PSZ pszPortName,
|
---|
370 | PHFILE phFile,
|
---|
371 | PULONG pDeviceFlags,
|
---|
372 | PVOID pPrtOpenStruct)
|
---|
373 | {
|
---|
374 | APIRET rc;
|
---|
375 | ULONG ulAction = 0; /* Action taken by DosOpen */
|
---|
376 | ULONG ulBytesRead = 0; /* Number of bytes read by DosRead */
|
---|
377 | ULONG ulWrote = 0; /* Number of bytes written by DosWrite */
|
---|
378 | ULONG ulLocal = 0; /* File pointer position after DosSetFilePtr */
|
---|
379 | char szTemp[ 256];
|
---|
380 | char tmp[256];
|
---|
381 | ULONG pcbWritten ;
|
---|
382 | USHORT i;
|
---|
383 | HFILE control;
|
---|
384 | char filename[256];
|
---|
385 | DATETIME dt;
|
---|
386 | char spool_dir[256];
|
---|
387 | PEAOP2 pEABuf = NULL;
|
---|
388 |
|
---|
389 |
|
---|
390 | if (!phFile || !pDeviceFlags )
|
---|
391 | {
|
---|
392 | return(ERROR_INVALID_PARAMETER);
|
---|
393 | }
|
---|
394 | DosGetDateTime(&dt);
|
---|
395 | rc = PrfQueryProfileString (HINI_SYSTEMPROFILE,
|
---|
396 | "PM_SPOOLER",
|
---|
397 | "DIR",
|
---|
398 | NULL,
|
---|
399 | (PSZ)spool_dir,
|
---|
400 | sizeof(spool_dir));
|
---|
401 | spool_dir[ strlen(spool_dir) - 1] = '\0';
|
---|
402 | sprintf(tmp,"%s\\UNI",spool_dir);
|
---|
403 | DosCreateDir( tmp,pEABuf );
|
---|
404 | sprintf(filename,"%s\\UNI\\%02d_%02d_%02d_%02d_%s",spool_dir,dt.hours,dt.minutes,dt.seconds,dt.hundredths,pszPortName);
|
---|
405 | rc = DosOpen(filename,
|
---|
406 | phFile, /* File handle */
|
---|
407 | &ulAction, /* Action taken */
|
---|
408 | 100L, /* File primary allocation */
|
---|
409 | FILE_ARCHIVED | FILE_NORMAL, /* File attribute */
|
---|
410 | OPEN_ACTION_CREATE_IF_NEW |
|
---|
411 | OPEN_ACTION_OPEN_IF_EXISTS, /* Open function type */
|
---|
412 | OPEN_FLAGS_NOINHERIT |
|
---|
413 | OPEN_SHARE_DENYNONE |
|
---|
414 | OPEN_ACCESS_READWRITE, /* Open mode of the file */
|
---|
415 | 0L); /* No extended attribute */
|
---|
416 | /* DosWrite(*phFile,pszPSHeader,strlen(pszPSHeader),&cbHeader); */
|
---|
417 | sprintf(szTemp,"PM_%s",pszPortName);
|
---|
418 | if (PrfQueryProfileString (HINI_SYSTEMPROFILE,
|
---|
419 | szTemp,
|
---|
420 | KEY_INITIALIZATION,
|
---|
421 | NULL,
|
---|
422 | szTemp,
|
---|
423 | sizeof(szTemp)))
|
---|
424 | {
|
---|
425 | sprintf(tmp ,"%s\\UNI\\%d.control",spool_dir,*phFile);
|
---|
426 | rc = DosOpen( tmp ,
|
---|
427 | &control, /* File handle */
|
---|
428 | &ulAction, /* Action taken */
|
---|
429 | strlen(szTemp), /* File primary allocation */
|
---|
430 | FILE_ARCHIVED | FILE_NORMAL, /* File attribute */
|
---|
431 | OPEN_ACTION_CREATE_IF_NEW |
|
---|
432 | OPEN_ACTION_OPEN_IF_EXISTS, /* Open function type */
|
---|
433 | OPEN_FLAGS_NOINHERIT |
|
---|
434 | OPEN_SHARE_DENYNONE |
|
---|
435 | OPEN_ACCESS_READWRITE, /* Open mode of the file */
|
---|
436 | 0L); /* No extended attribute */
|
---|
437 | rc = DosWrite( control,szTemp,strlen(szTemp),&pcbWritten);
|
---|
438 | rc = DosWrite( control,"#",1,&pcbWritten);
|
---|
439 | rc = DosWrite( control,filename,strlen(filename),&pcbWritten);
|
---|
440 | rc = DosWrite( control,"@",1,&pcbWritten);
|
---|
441 | rc = DosClose(control);
|
---|
442 | }
|
---|
443 | return rc;
|
---|
444 |
|
---|
445 | }
|
---|
446 | ULONG APIENTRY SplPdQuery ( PSZ pszDeviceName,
|
---|
447 | ULONG ulFlags,
|
---|
448 | ULONG ulCommand,
|
---|
449 | PVOID pInData,
|
---|
450 | ULONG cbInData,
|
---|
451 | PVOID pOutData,
|
---|
452 | PULONG pcbOutData )
|
---|
453 | {
|
---|
454 | /* return ERROR_NOT_SUPPORTED; */
|
---|
455 | return NO_ERROR;
|
---|
456 | }
|
---|
457 | ULONG APIENTRY SplPdSet ( PSZ pszDeviceName,
|
---|
458 | ULONG ulFlags,
|
---|
459 | ULONG ulCommand,
|
---|
460 | PVOID pInData,
|
---|
461 | ULONG cbInData )
|
---|
462 | {
|
---|
463 | /* return ERROR_NOT_SUPPORTED; */
|
---|
464 | return NO_ERROR;
|
---|
465 | }
|
---|
466 | ULONG APIENTRY SplPdNewPage ( HFILE hFile, ULONG ulPageNumber )
|
---|
467 | {
|
---|
468 | return NO_ERROR;
|
---|
469 | }
|
---|
470 | ULONG APIENTRY SplPdAbortDoc( HFILE hFile,
|
---|
471 | PVOID pchData,
|
---|
472 | ULONG cbData,
|
---|
473 | ULONG ulFlags )
|
---|
474 | {
|
---|
475 | return NO_ERROR;
|
---|
476 | }
|
---|
477 | ULONG APIENTRY SplPdClose( HFILE hFile )
|
---|
478 | {
|
---|
479 | APIRET rc;
|
---|
480 | APIRET resp;
|
---|
481 | USHORT i;
|
---|
482 | USHORT j;
|
---|
483 | RESULTCODES rc_child;
|
---|
484 | ULONG nbr_lu;
|
---|
485 | ULONG ulAction;
|
---|
486 | char szTemp[256];
|
---|
487 | HFILE control;
|
---|
488 | char binfile[256];
|
---|
489 | char arg[256];
|
---|
490 | char *j_parms;
|
---|
491 | char j_id[3];
|
---|
492 | char parameters[256];
|
---|
493 | char workingdir[256] ;
|
---|
494 | char j_title[256];
|
---|
495 | char j_copies[3];
|
---|
496 | char j_options[8];
|
---|
497 | char filename[256];
|
---|
498 | char ip_add[256];
|
---|
499 | char queue_name[256];
|
---|
500 | char workgroup[256];
|
---|
501 | char username[256];
|
---|
502 | char password_enc[256];
|
---|
503 | char password_dec[256];
|
---|
504 | char errorstr[256];
|
---|
505 | USHORT pos;
|
---|
506 | char spool_dir[256];
|
---|
507 | ULONG ulBootDrive;
|
---|
508 |
|
---|
509 | rc = PrfQueryProfileString (HINI_SYSTEMPROFILE,
|
---|
510 | "PM_SPOOLER",
|
---|
511 | "DIR",
|
---|
512 | NULL,
|
---|
513 | (PSZ)spool_dir,
|
---|
514 | sizeof(spool_dir));
|
---|
515 | spool_dir[ strlen(spool_dir) - 1] = '\0';
|
---|
516 | sprintf(szTemp,"%s\\UNI\\%d.control",spool_dir,hFile);
|
---|
517 | rc = DosOpen(szTemp,
|
---|
518 | &control,
|
---|
519 | &ulAction,
|
---|
520 | 0L,
|
---|
521 | FILE_ARCHIVED | FILE_NORMAL,
|
---|
522 | OPEN_ACTION_CREATE_IF_NEW |
|
---|
523 | OPEN_ACTION_OPEN_IF_EXISTS,
|
---|
524 | OPEN_FLAGS_NOINHERIT |
|
---|
525 | OPEN_SHARE_DENYNONE |
|
---|
526 | OPEN_ACCESS_READWRITE,
|
---|
527 | 0L);
|
---|
528 | rc = DosRead( control,szTemp,sizeof(szTemp),&nbr_lu);
|
---|
529 | rc = DosClose( control );
|
---|
530 | sprintf(filename,"%s\\UNI\\%d.control",spool_dir,hFile);
|
---|
531 | DosDelete(filename);
|
---|
532 |
|
---|
533 | i = 0;
|
---|
534 | j = 0;
|
---|
535 | pos = 0;
|
---|
536 | while (szTemp[i] != '@')
|
---|
537 | {
|
---|
538 | if (szTemp[i] == '#')
|
---|
539 | {
|
---|
540 | szTemp[i] = '\0';
|
---|
541 | switch(j)
|
---|
542 | {
|
---|
543 | case 0:strcpy(binfile,&szTemp[pos]);
|
---|
544 | break;
|
---|
545 | case 1:strcpy(parameters,&szTemp[pos]);
|
---|
546 | break;
|
---|
547 | case 2:strcpy(workingdir,&szTemp[pos]);
|
---|
548 | break;
|
---|
549 | /* case 3:strcpy(username,&szTemp[pos]);
|
---|
550 | break;
|
---|
551 | case 4:strcpy(j_copies,&szTemp[pos]);
|
---|
552 | break;
|
---|
553 | case 5:strcpy(password_enc,&szTemp[pos]);
|
---|
554 | break; */
|
---|
555 | }
|
---|
556 | pos = i+1;
|
---|
557 | j++;
|
---|
558 | }
|
---|
559 | i++;
|
---|
560 | }
|
---|
561 | szTemp[i] = '\0';
|
---|
562 | strcpy(filename,&szTemp[pos]);
|
---|
563 |
|
---|
564 | rc = DosClose( hFile );
|
---|
565 | DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive,
|
---|
566 | sizeof (ULONG));
|
---|
567 |
|
---|
568 | // decryptPassword(password_enc,password_dec);
|
---|
569 |
|
---|
570 | j_parms = malloc((strlen(parameters) - strlen("%file%") + strlen(filename)) * sizeof(char));
|
---|
571 |
|
---|
572 | searchReplace("%file%", filename, parameters, j_parms);
|
---|
573 |
|
---|
574 | if (strlen(workingdir) > 0)
|
---|
575 | {
|
---|
576 | chdir(workingdir);
|
---|
577 | };
|
---|
578 | rc = spawnlp(P_WAIT,binfile,binfile,j_parms,NULL);
|
---|
579 |
|
---|
580 | while (rc != 0)
|
---|
581 | {
|
---|
582 | sprintf(errorstr,"Error during spooling to %s %s",binfile,j_parms);
|
---|
583 | resp = WinMessageBox (HWND_DESKTOP,
|
---|
584 | HWND_DESKTOP,
|
---|
585 | errorstr,
|
---|
586 | "Universal Port driver error",
|
---|
587 | 0L, MB_RETRYCANCEL | MB_WARNING | MB_MOVEABLE);
|
---|
588 | if (resp != MBID_CANCEL )
|
---|
589 | {
|
---|
590 | rc = spawnlp(P_WAIT,binfile,binfile,j_parms,NULL);
|
---|
591 | }
|
---|
592 | else rc = 0;
|
---|
593 | };
|
---|
594 |
|
---|
595 | free(j_parms);
|
---|
596 | strcpy(filename,&szTemp[pos]);
|
---|
597 | DosDelete(filename);
|
---|
598 |
|
---|
599 | /* We always have to return success to the spooler subsystem */
|
---|
600 | rc = NO_ERROR;
|
---|
601 | return rc;
|
---|
602 | }
|
---|
603 | ULONG APIENTRY SplPdWrite( HFILE hFile,
|
---|
604 | PVOID pchData,
|
---|
605 | ULONG cbData,
|
---|
606 | PULONG pcbWritten )
|
---|
607 | { APIRET rc;
|
---|
608 |
|
---|
609 | rc = DosWrite( hFile,pchData,cbData,pcbWritten);
|
---|
610 | rc = DosSleep(0);
|
---|
611 | return rc;
|
---|
612 | }
|
---|
613 |
|
---|