| [175] | 1 | #define  LINT_ARGS                     /* argument checking enabled          */ | 
|---|
|  | 2 |  | 
|---|
|  | 3 | #define  INCL_DOS | 
|---|
|  | 4 | #define  INCL_GPI | 
|---|
|  | 5 | #undef   INCL_GPI | 
|---|
|  | 6 | #define  INCL_DEV | 
|---|
|  | 7 | #define  INCL_DOSMEMMGR                /* Include standard OS/2 support      */ | 
|---|
|  | 8 | #define  INCL_DOSMODULEMGR             /* For DosLoadModule                  */ | 
|---|
|  | 9 | #define  INCL_DOSPROCESS | 
|---|
|  | 10 | #define  INCL_GPILCIDS | 
|---|
|  | 11 | #define  INCL_WINCOMMON                /* Include Window Management support  */ | 
|---|
|  | 12 | #define  INCL_WINDOWMGR | 
|---|
|  | 13 | #define  INCL_WINSWITCHLIST | 
|---|
|  | 14 | #define  INCL_WINPROGRAMLIST | 
|---|
|  | 15 | #define  INCL_WINMENUS | 
|---|
|  | 16 | #define  INCL_WINWINDOWMGR | 
|---|
|  | 17 | #define  INCL_WINMESSAGEMGR | 
|---|
|  | 18 | #define  INCL_WINDIALOGS | 
|---|
|  | 19 | #define  INCL_WINSTATICS | 
|---|
|  | 20 | #define  INCL_WINLISTBOXES | 
|---|
|  | 21 | #define  INCL_WINMENUS | 
|---|
|  | 22 | #define  INCL_WINSYS | 
|---|
|  | 23 | #define  INCL_WINFRAMEMGR | 
|---|
|  | 24 | #define  INCL_INCLWINACCELERATORS | 
|---|
|  | 25 | #define  INCL_WINPOINTERS | 
|---|
|  | 26 | #define  INCL_WINERRORS | 
|---|
|  | 27 | #define  INCL_WINSHELLDATA | 
|---|
|  | 28 |  | 
|---|
|  | 29 | #define  INCL_WINTYPES | 
|---|
|  | 30 | #define  INCL_WINACCELERATORS | 
|---|
|  | 31 | #define  INCL_WINBUTTONS | 
|---|
|  | 32 | #define  INCL_WINENTRYFIELDS | 
|---|
|  | 33 | #define  INCL_WINRECTANGLES | 
|---|
|  | 34 | #define  INCL_WINTIMER | 
|---|
|  | 35 | #define  INCL_WINSCROLLBARS | 
|---|
|  | 36 | #define  INCL_WINHEAP | 
|---|
|  | 37 | #define  INCL_SHLERRORS | 
|---|
|  | 38 | #define  INCL_WININPUT | 
|---|
|  | 39 | #define  INCL_WINHELP | 
|---|
|  | 40 | #define  INCL_WINSTDSPIN | 
|---|
|  | 41 |  | 
|---|
|  | 42 | #define  INCL_SPL | 
|---|
|  | 43 | #define  INCL_SPLP | 
|---|
|  | 44 | #define  INCL_SPLERRORS | 
|---|
|  | 45 | #define  INCL_SHLERRORS | 
|---|
|  | 46 | #define  INCL_DOSERRORS | 
|---|
|  | 47 | #define  INCL_WINHOOKS | 
|---|
|  | 48 |  | 
|---|
|  | 49 | int acrtused=1;                      /* Define variable to say this is a DLL */ | 
|---|
|  | 50 |  | 
|---|
|  | 51 | #include    <os2.h> | 
|---|
|  | 52 |  | 
|---|
|  | 53 | #include    <stdlib.h> | 
|---|
|  | 54 | #include    <string.h> | 
|---|
|  | 55 | #include    <ctype.h> | 
|---|
|  | 56 | #include    <stdarg.h> | 
|---|
|  | 57 | #include    <stdio.h> | 
|---|
|  | 58 | #include    <stdlib.h> | 
|---|
|  | 59 | #include    <process.h> | 
|---|
|  | 60 | #include    "SMB.h" | 
|---|
|  | 61 |  | 
|---|
| [758] | 62 | #define BIDI_SET_PORTDRV    0x00000019 | 
|---|
|  | 63 | #define BIDI_Q_PORTDRV      0x00008019 | 
|---|
|  | 64 |  | 
|---|
|  | 65 |  | 
|---|
| [175] | 66 | /* Password encryption/decryption routines from ndpsmb.c */ | 
|---|
|  | 67 |  | 
|---|
|  | 68 | static unsigned char fromhex (char c) | 
|---|
|  | 69 | { | 
|---|
|  | 70 | if ('0' <= c && c <= '9') | 
|---|
|  | 71 | { | 
|---|
| [177] | 72 | return c - '0'; | 
|---|
| [175] | 73 | } | 
|---|
|  | 74 |  | 
|---|
|  | 75 | if ('A' <= c && c <= 'F') | 
|---|
|  | 76 | { | 
|---|
| [177] | 77 | return c - 'A' + 0xA; | 
|---|
| [175] | 78 | } | 
|---|
|  | 79 |  | 
|---|
|  | 80 | if ('a' <= c && c <= 'f') | 
|---|
|  | 81 | { | 
|---|
| [177] | 82 | return c - 'a' + 0xA; | 
|---|
| [175] | 83 | } | 
|---|
|  | 84 |  | 
|---|
|  | 85 | return 0; | 
|---|
|  | 86 | } | 
|---|
|  | 87 |  | 
|---|
|  | 88 | static char tohex (unsigned char b) | 
|---|
|  | 89 | { | 
|---|
|  | 90 | b &= 0xF; | 
|---|
|  | 91 |  | 
|---|
|  | 92 | if (b <= 9) | 
|---|
|  | 93 | { | 
|---|
|  | 94 | return b + '0'; | 
|---|
|  | 95 | } | 
|---|
|  | 96 |  | 
|---|
|  | 97 | return 'A' + (b - 0xA); | 
|---|
|  | 98 | } | 
|---|
|  | 99 |  | 
|---|
|  | 100 | static void decryptPassword (const char *pszCrypt, char *pszPlain) | 
|---|
|  | 101 | { | 
|---|
|  | 102 | /* A simple "decryption", character from the hex value. */ | 
|---|
|  | 103 | const char *s = pszCrypt; | 
|---|
|  | 104 | char *d = pszPlain; | 
|---|
|  | 105 |  | 
|---|
|  | 106 | while (*s) | 
|---|
|  | 107 | { | 
|---|
|  | 108 | *d++ = (char)((fromhex (*s++) << 4) + fromhex (*s++)); | 
|---|
|  | 109 | } | 
|---|
|  | 110 |  | 
|---|
|  | 111 | *d++ = 0; | 
|---|
|  | 112 | } | 
|---|
|  | 113 |  | 
|---|
|  | 114 | static void encryptPassword (const char *pszPlain, char *pszCrypt) | 
|---|
|  | 115 | { | 
|---|
|  | 116 | /* A simple "encryption" encode each character as hex value. */ | 
|---|
|  | 117 | const char *s = pszPlain; | 
|---|
|  | 118 | char *d = pszCrypt; | 
|---|
|  | 119 |  | 
|---|
|  | 120 | while (*s) | 
|---|
|  | 121 | { | 
|---|
|  | 122 | *d++ = tohex ((*s) >> 4); | 
|---|
|  | 123 | *d++ = tohex (*s); | 
|---|
|  | 124 | s++; | 
|---|
|  | 125 | } | 
|---|
|  | 126 |  | 
|---|
|  | 127 | *d++ = 0; | 
|---|
|  | 128 | } | 
|---|
|  | 129 |  | 
|---|
|  | 130 | // | 
|---|
|  | 131 | // If port driver is not defined in INI file yet | 
|---|
|  | 132 | //   assume it exists in the boot drive's \OS2\DLL directory | 
|---|
|  | 133 | // | 
|---|
|  | 134 |  | 
|---|
|  | 135 | CHAR szDefaultPortDrvPath[] = { PATH_SMB_PDR }; | 
|---|
|  | 136 |  | 
|---|
|  | 137 |  | 
|---|
|  | 138 | // | 
|---|
|  | 139 | // Below definition of PORTNAMES structure should be defined in | 
|---|
|  | 140 | // common header file pmspl.h. | 
|---|
|  | 141 | // | 
|---|
|  | 142 |  | 
|---|
|  | 143 | typedef struct _PORTNAMES | 
|---|
|  | 144 | { | 
|---|
|  | 145 | PSZ pszPortName;         /* -> name of port(ie "LPT1)                    */ | 
|---|
|  | 146 | PSZ pszPortDesc;         /* -> description of port(ie "Parallel Port 1") */ | 
|---|
|  | 147 | } PORTNAMES, *PPORTNAMES; | 
|---|
|  | 148 |  | 
|---|
| [177] | 149 | /* Alex Taylor's new version of lprtok() that can handle missing fields */ | 
|---|
| [175] | 150 | char * lprtok (char *string,char *control) | 
|---|
|  | 151 | { | 
|---|
| [177] | 152 | char *c; | 
|---|
|  | 153 | static char *next; | 
|---|
| [175] | 154 |  | 
|---|
| [177] | 155 | if ( control == NULL ) return string; | 
|---|
|  | 156 | if ( string  == NULL ) string = next; | 
|---|
|  | 157 | if ( string  == NULL ) return NULL; | 
|---|
| [175] | 158 |  | 
|---|
| [177] | 159 | if (( c = strpbrk( string, control )) == NULL ) { | 
|---|
|  | 160 | next = NULL; | 
|---|
|  | 161 | } | 
|---|
|  | 162 | else { | 
|---|
|  | 163 | next = c+1; | 
|---|
|  | 164 | *c = '\0'; | 
|---|
|  | 165 | } | 
|---|
| [175] | 166 |  | 
|---|
| [177] | 167 | return ( string ); | 
|---|
| [175] | 168 | } | 
|---|
|  | 169 | MRESULT EXPENTRY CommDlg( HWND hDlg, USHORT msg, MPARAM mp1, MPARAM mp2 ) | 
|---|
|  | 170 | { | 
|---|
|  | 171 | PLPRDATA    pLprData; | 
|---|
|  | 172 | ULONG       ulTimeOut = 0 ; | 
|---|
| [177] | 173 | CHAR        szDesc[ STR_LEN_PORTDESC ]; | 
|---|
|  | 174 | CHAR        szShareName[ STR_LEN_PORTDESC ]; | 
|---|
| [175] | 175 | CHAR        szTitle[ STR_LEN_TITLE + 1]; | 
|---|
|  | 176 | CHAR        szTemp[ STR_LEN_PORTDESC ]; | 
|---|
|  | 177 | CHAR        pwBuffer[256]; | 
|---|
|  | 178 | USHORT      i; | 
|---|
|  | 179 | ULONG       rc = 0; | 
|---|
|  | 180 | PUCHAR      token; | 
|---|
|  | 181 |  | 
|---|
|  | 182 | switch (msg) | 
|---|
|  | 183 | { | 
|---|
|  | 184 | case WM_INITDLG: | 
|---|
|  | 185 | WinSendDlgItemMsg(hDlg,ID_BINARY,BM_SETCHECK,MPFROM2SHORT(1,0),NULL); | 
|---|
|  | 186 | pLprData = (PLPRDATA)mp2; | 
|---|
|  | 187 | WinSetWindowULong (hDlg, QWL_USER, (ULONG)pLprData); | 
|---|
|  | 188 | if (PrfQueryProfileString (HINI_SYSTEMPROFILE, | 
|---|
|  | 189 | pLprData->pszAppName, | 
|---|
|  | 190 | KEY_DESCRIPTION, | 
|---|
|  | 191 | NULL, | 
|---|
|  | 192 | (PSZ)szDesc, | 
|---|
|  | 193 | STR_LEN_PORTDESC)) | 
|---|
|  | 194 | { | 
|---|
|  | 195 | WinSetWindowText (WinWindowFromID (hDlg, (USHORT)IDD_SMB),szDesc); | 
|---|
|  | 196 | rc = WinLoadString(pLprData->hAB, | 
|---|
|  | 197 | pLprData->hModule, | 
|---|
|  | 198 | PDR_ID_PROPERTIES, | 
|---|
|  | 199 | STR_LEN_PORTDESC, szTemp); | 
|---|
|  | 200 | if (rc) { | 
|---|
|  | 201 | strcpy ( szTitle, pLprData->pszPortName ); | 
|---|
|  | 202 | strcat ( szTitle, " - " ); | 
|---|
|  | 203 | strcat ( szTitle, szTemp ); | 
|---|
|  | 204 | WinSetWindowText (hDlg, szTitle); | 
|---|
|  | 205 | } | 
|---|
|  | 206 | } | 
|---|
|  | 207 | if (PrfQueryProfileString (HINI_SYSTEMPROFILE, | 
|---|
|  | 208 | pLprData->pszAppName, | 
|---|
|  | 209 | KEY_INITIALIZATION, | 
|---|
|  | 210 | NULL, | 
|---|
|  | 211 | szTemp, | 
|---|
|  | 212 | sizeof(szTemp))) | 
|---|
|  | 213 | { | 
|---|
|  | 214 | i = 0; | 
|---|
|  | 215 | token = lprtok(szTemp,"#"); | 
|---|
|  | 216 | while (token != NULL) | 
|---|
|  | 217 | { | 
|---|
|  | 218 | switch(i) | 
|---|
|  | 219 | { | 
|---|
|  | 220 | case 0: | 
|---|
|  | 221 | WinSetDlgItemText(hDlg,ID_IP,token); | 
|---|
|  | 222 | case 1: | 
|---|
|  | 223 | if (token[ strlen(token) - 1 ] == ';') | 
|---|
|  | 224 | token[ strlen(token)-1 ] = '\0'; | 
|---|
|  | 225 | WinSetDlgItemText(hDlg,ID_SMBQUEUE,token); | 
|---|
|  | 226 | break; | 
|---|
|  | 227 | case 2: | 
|---|
|  | 228 | if (token[ strlen(token) - 1 ] == ';') | 
|---|
|  | 229 | token[ strlen(token)-1 ] = '\0'; | 
|---|
|  | 230 | WinSetDlgItemText(hDlg,ID_WORKGROUP,token); | 
|---|
|  | 231 | break; | 
|---|
|  | 232 | case 3: | 
|---|
|  | 233 | if (token[ strlen(token) - 1 ] == ';') | 
|---|
|  | 234 | token[ strlen(token)-1 ] = '\0'; | 
|---|
|  | 235 | WinSetDlgItemText(hDlg,ID_USER,token); | 
|---|
|  | 236 | break; | 
|---|
|  | 237 | case 4: | 
|---|
|  | 238 | if (token[ strlen(token) - 1 ] == ';') | 
|---|
|  | 239 | token[ strlen(token)-1 ] = '\0'; | 
|---|
|  | 240 | WinSetDlgItemText(hDlg,ID_COPIES,token); | 
|---|
|  | 241 | break; | 
|---|
|  | 242 |  | 
|---|
|  | 243 | case 5: | 
|---|
|  | 244 | if (token[ strlen(token) - 1 ] == ';') | 
|---|
|  | 245 | token[ strlen(token)-1 ] = '\0'; | 
|---|
|  | 246 | strcpy(pwBuffer,token); | 
|---|
|  | 247 | decryptPassword(pwBuffer,token); | 
|---|
|  | 248 | WinSetDlgItemText(hDlg,ID_PASSWORD,token); | 
|---|
|  | 249 | break; | 
|---|
|  | 250 | } | 
|---|
|  | 251 | i++; | 
|---|
|  | 252 | token = lprtok(NULL,"#"); | 
|---|
|  | 253 | } | 
|---|
|  | 254 | } | 
|---|
|  | 255 | break; | 
|---|
|  | 256 |  | 
|---|
|  | 257 | case WM_COMMAND: | 
|---|
|  | 258 | pLprData = (PLPRDATA)WinQueryWindowULong (hDlg, QWL_USER); | 
|---|
|  | 259 | switch (SHORT1FROMMP(mp1)) | 
|---|
|  | 260 | { | 
|---|
|  | 261 | case DID_OK: | 
|---|
| [177] | 262 | sprintf(szDesc,"\\"); | 
|---|
| [175] | 263 | /* Servername | IP */ | 
|---|
|  | 264 | WinQueryDlgItemText (hDlg, ID_IP, sizeof(szTemp), szTemp ); | 
|---|
|  | 265 | sprintf(pLprData->szSaveLprSetting,"%s",szTemp); | 
|---|
| [177] | 266 | strncpy(szShareName, szTemp, STR_LEN_PORTDESC - 1); | 
|---|
| [175] | 267 | /* Printername | Queue */ | 
|---|
|  | 268 | WinQueryDlgItemText (hDlg, ID_SMBQUEUE, sizeof(szTemp), szTemp ); | 
|---|
|  | 269 | strcat(pLprData->szSaveLprSetting,"#"); | 
|---|
|  | 270 | strcat(pLprData->szSaveLprSetting,szTemp); | 
|---|
| [177] | 271 | if (strlen(szTemp) > 0) { | 
|---|
|  | 272 | strncat(szShareName, "\\", STR_LEN_PORTDESC - 1); | 
|---|
|  | 273 | strncat(szShareName, szTemp, STR_LEN_PORTDESC - 1); | 
|---|
|  | 274 | } | 
|---|
| [175] | 275 | /* Workgroup */ | 
|---|
|  | 276 | WinQueryDlgItemText (hDlg, ID_WORKGROUP, sizeof(szTemp), szTemp ); | 
|---|
|  | 277 | strcat(pLprData->szSaveLprSetting,"#"); | 
|---|
|  | 278 | strcat(pLprData->szSaveLprSetting,szTemp); | 
|---|
| [177] | 279 | if (strlen(szTemp) > 0) { | 
|---|
|  | 280 | strncat(szDesc, "\\", STR_LEN_PORTDESC - 1); | 
|---|
|  | 281 | strncat(szDesc, szTemp, STR_LEN_PORTDESC - 1); | 
|---|
|  | 282 | } | 
|---|
|  | 283 | strncat(szDesc, "\\", STR_LEN_PORTDESC - 1); | 
|---|
|  | 284 | strncat(szDesc, szShareName, STR_LEN_PORTDESC - 1); | 
|---|
| [175] | 285 | /* Username */ | 
|---|
|  | 286 | WinQueryDlgItemText (hDlg, ID_USER, sizeof(szTemp), szTemp ); | 
|---|
|  | 287 | strcat(pLprData->szSaveLprSetting,"#"); | 
|---|
|  | 288 | strcat(pLprData->szSaveLprSetting,szTemp); | 
|---|
|  | 289 | /* Number of copies */ | 
|---|
|  | 290 | WinQueryDlgItemText (hDlg, ID_COPIES, sizeof(szTemp), szTemp ); | 
|---|
|  | 291 | strcat(pLprData->szSaveLprSetting,"#"); | 
|---|
|  | 292 | strcat(pLprData->szSaveLprSetting,szTemp); | 
|---|
|  | 293 | /* Password - must be the last item! */ | 
|---|
|  | 294 | WinQueryDlgItemText (hDlg, ID_PASSWORD, sizeof(szTemp), szTemp ); | 
|---|
|  | 295 | strcat(pLprData->szSaveLprSetting,"#"); | 
|---|
|  | 296 | strcpy(pwBuffer,szTemp); | 
|---|
|  | 297 | encryptPassword(pwBuffer,szTemp); | 
|---|
|  | 298 | strcat(pLprData->szSaveLprSetting,szTemp); | 
|---|
| [177] | 299 |  | 
|---|
| [175] | 300 | if (!PrfWriteProfileString (HINI_SYSTEMPROFILE, | 
|---|
|  | 301 | pLprData->pszAppName, | 
|---|
|  | 302 | KEY_INITIALIZATION, | 
|---|
|  | 303 | pLprData->szSaveLprSetting)) | 
|---|
|  | 304 | WinDismissDlg(hDlg, MBID_CANCEL); | 
|---|
|  | 305 |  | 
|---|
|  | 306 | if (!PrfWriteProfileString (HINI_SYSTEMPROFILE, | 
|---|
|  | 307 | APPNAME_PM_SPOOLER_PORT, | 
|---|
|  | 308 | pLprData->pszPortName, | 
|---|
|  | 309 | pLprData->szSaveLprSetting)) | 
|---|
| [177] | 310 | WinDismissDlg(hDlg, MBID_CANCEL); | 
|---|
|  | 311 |  | 
|---|
|  | 312 | if (!PrfWriteProfileString (HINI_SYSTEMPROFILE, | 
|---|
|  | 313 | pLprData->pszAppName, | 
|---|
|  | 314 | KEY_DESCRIPTION, | 
|---|
|  | 315 | szDesc )) | 
|---|
|  | 316 | WinDismissDlg(hDlg, MBID_CANCEL); | 
|---|
|  | 317 |  | 
|---|
| [175] | 318 | WinDismissDlg(hDlg, TRUE); | 
|---|
|  | 319 | break; | 
|---|
|  | 320 | case DID_CANCEL: | 
|---|
|  | 321 | WinDismissDlg(hDlg, MBID_CANCEL); | 
|---|
|  | 322 | break; | 
|---|
|  | 323 | } | 
|---|
|  | 324 | break; | 
|---|
|  | 325 | default: | 
|---|
| [177] | 326 | return WinDefDlgProc(hDlg, msg, mp1, mp2) ; | 
|---|
|  | 327 | break; | 
|---|
|  | 328 | } | 
|---|
|  | 329 | return FALSE; | 
|---|
| [175] | 330 | } | 
|---|
|  | 331 | ULONG CalcStructLength ( HAB hab, | 
|---|
| [177] | 332 | HMODULE hModule, | 
|---|
|  | 333 | USHORT usID ) | 
|---|
| [175] | 334 | { | 
|---|
| [177] | 335 | ULONG cbRequired; | 
|---|
|  | 336 | CHAR  chString[STR_LEN_PORTDESC]; | 
|---|
| [175] | 337 |  | 
|---|
| [177] | 338 | cbRequired = 0; | 
|---|
| [175] | 339 |  | 
|---|
| [177] | 340 | WinLoadString(hab, hModule, usID, STR_LEN_PORTDESC, chString); | 
|---|
|  | 341 | cbRequired += strlen (chString) + 1; | 
|---|
|  | 342 | WinLoadString(hab, hModule, (USHORT)(usID + 1), STR_LEN_PORTDESC, chString); | 
|---|
|  | 343 | cbRequired += strlen (chString) + 1; | 
|---|
|  | 344 | cbRequired += sizeof (PORTNAMES); | 
|---|
|  | 345 | return(cbRequired); | 
|---|
| [175] | 346 | } | 
|---|
|  | 347 |  | 
|---|
|  | 348 | ULONG CalcBufLength ( HAB hab, | 
|---|
|  | 349 | HMODULE hModule ) | 
|---|
|  | 350 | { | 
|---|
| [177] | 351 | ULONG  cbRequired; | 
|---|
|  | 352 | USHORT usID; | 
|---|
| [175] | 353 |  | 
|---|
| [177] | 354 | cbRequired = 0; | 
|---|
| [175] | 355 |  | 
|---|
|  | 356 | /* | 
|---|
|  | 357 | ** calculate length required to fit all the port info. | 
|---|
|  | 358 | */ | 
|---|
| [177] | 359 | for (usID = PORT_ID_FIRST; usID <= PORT_ID_LAST; usID += 2) | 
|---|
|  | 360 | { | 
|---|
| [175] | 361 | cbRequired += CalcStructLength (hab, hModule, usID); | 
|---|
| [177] | 362 | } | 
|---|
| [175] | 363 |  | 
|---|
| [177] | 364 | return(cbRequired); | 
|---|
| [175] | 365 | } | 
|---|
|  | 366 |  | 
|---|
|  | 367 | ULONG NumPortsCanFit ( HAB hab, | 
|---|
|  | 368 | HMODULE hModule, | 
|---|
|  | 369 | ULONG cbBuf ) | 
|---|
|  | 370 | { | 
|---|
| [177] | 371 | ULONG  cbRequired; | 
|---|
|  | 372 | USHORT usID; | 
|---|
|  | 373 | ULONG  ulNumPort; | 
|---|
| [175] | 374 |  | 
|---|
| [177] | 375 | cbRequired = 0; | 
|---|
|  | 376 | ulNumPort = 0; | 
|---|
| [175] | 377 |  | 
|---|
|  | 378 | /* | 
|---|
|  | 379 | ** calculate how many ports we can fit in buf. | 
|---|
|  | 380 | */ | 
|---|
| [177] | 381 | for (usID = PORT_ID_FIRST; usID <= PORT_ID_LAST; usID += 2) | 
|---|
|  | 382 | { | 
|---|
| [175] | 383 | cbRequired += CalcStructLength (hab, hModule, usID); | 
|---|
|  | 384 | if (cbRequired > cbBuf) | 
|---|
|  | 385 | { | 
|---|
| [177] | 386 | return(ulNumPort); | 
|---|
| [175] | 387 | } | 
|---|
|  | 388 | ulNumPort++; | 
|---|
| [177] | 389 | } | 
|---|
| [175] | 390 |  | 
|---|
| [177] | 391 | return(ulNumPort); | 
|---|
| [175] | 392 | } | 
|---|
|  | 393 | VOID CopyStruct ( HAB hab, | 
|---|
| [177] | 394 | HMODULE hModule, | 
|---|
|  | 395 | USHORT usID, | 
|---|
|  | 396 | PCH pBuf, | 
|---|
|  | 397 | PULONG pulBeginStruct, | 
|---|
|  | 398 | PULONG pulBeginText ) | 
|---|
| [175] | 399 | { | 
|---|
| [177] | 400 | PPORTNAMES pPortNames; | 
|---|
| [175] | 401 |  | 
|---|
| [177] | 402 | pPortNames = (PPORTNAMES)(pBuf + *pulBeginStruct); | 
|---|
|  | 403 | *pulBeginStruct += sizeof (PORTNAMES); | 
|---|
| [175] | 404 |  | 
|---|
|  | 405 | /* | 
|---|
|  | 406 | ** copy port name in the structure | 
|---|
|  | 407 | */ | 
|---|
| [177] | 408 | pPortNames->pszPortName = pBuf + *pulBeginText; | 
|---|
|  | 409 | WinLoadString(hab, hModule, usID, STR_LEN_PORTDESC, pPortNames->pszPortName); | 
|---|
|  | 410 | *pulBeginText += strlen (pPortNames->pszPortName) + 1; | 
|---|
| [175] | 411 |  | 
|---|
|  | 412 | /* | 
|---|
|  | 413 | ** copy port description to the structure | 
|---|
|  | 414 | */ | 
|---|
| [177] | 415 | pPortNames->pszPortDesc = pBuf + *pulBeginText; | 
|---|
|  | 416 | WinLoadString(hab, hModule, usID, STR_LEN_PORTDESC, pPortNames->pszPortDesc); | 
|---|
|  | 417 | *pulBeginText += strlen (pPortNames->pszPortDesc) + 1; | 
|---|
| [175] | 418 | } | 
|---|
|  | 419 | VOID  CopyNPorts ( HAB hab, | 
|---|
| [177] | 420 | HMODULE hModule, | 
|---|
|  | 421 | PCH pBuf, | 
|---|
|  | 422 | ULONG ulReturned ) | 
|---|
| [175] | 423 | { | 
|---|
| [177] | 424 | USHORT usID; | 
|---|
|  | 425 | ULONG  ulBeginText; | 
|---|
|  | 426 | ULONG  ulBeginStruct; | 
|---|
| [175] | 427 |  | 
|---|
| [177] | 428 | ulBeginText = ulReturned * sizeof (PORTNAMES); | 
|---|
|  | 429 | ulBeginStruct = 0; | 
|---|
| [175] | 430 |  | 
|---|
| [177] | 431 | for (usID = PORT_ID_FIRST; | 
|---|
| [175] | 432 | usID <= PORT_ID_LAST && ulReturned; | 
|---|
|  | 433 | usID += 2, --ulReturned) | 
|---|
| [177] | 434 | { | 
|---|
| [175] | 435 | CopyStruct (hab, hModule, usID, pBuf, &ulBeginStruct, &ulBeginText); | 
|---|
| [177] | 436 | } | 
|---|
| [175] | 437 | } | 
|---|
|  | 438 |  | 
|---|
|  | 439 | ULONG OpenLprPortDlg ( HAB hab, | 
|---|
|  | 440 | HMODULE hModule, | 
|---|
|  | 441 | PSZ pszPortName, | 
|---|
|  | 442 | PSZ pszAppName ) | 
|---|
|  | 443 | { | 
|---|
| [177] | 444 | LPRDATA LprData; | 
|---|
| [175] | 445 |  | 
|---|
| [177] | 446 | memset (&LprData, 0, sizeof (LPRDATA)); | 
|---|
|  | 447 | LprData.hAB = hab; | 
|---|
|  | 448 | LprData.hModule = hModule; | 
|---|
|  | 449 | LprData.pszPortName = pszPortName; | 
|---|
|  | 450 | LprData.pszAppName = pszAppName; | 
|---|
| [175] | 451 |  | 
|---|
| [177] | 452 | WinDlgBox  (HWND_DESKTOP, | 
|---|
| [175] | 453 | HWND_DESKTOP, | 
|---|
|  | 454 | (PFNWP)CommDlg, | 
|---|
|  | 455 | (HMODULE)hModule, | 
|---|
|  | 456 | IDD_SMB, | 
|---|
|  | 457 | &LprData); | 
|---|
|  | 458 |  | 
|---|
| [177] | 459 | return LprData.lfModified; | 
|---|
| [175] | 460 | } | 
|---|
|  | 461 | BOOL GetPortDescription ( HAB hab, | 
|---|
| [177] | 462 | HMODULE hModule, | 
|---|
|  | 463 | PSZ pszPortName, | 
|---|
|  | 464 | PSZ pszPortDesc ) | 
|---|
| [175] | 465 | { | 
|---|
|  | 466 | USHORT usID; | 
|---|
| [177] | 467 | CHAR   chBuf[STR_LEN_PORTDESC] = {0}; | 
|---|
| [175] | 468 |  | 
|---|
|  | 469 | for (usID = PORT_ID_FIRST; usID <= PORT_ID_LAST; usID += 2) | 
|---|
|  | 470 | { | 
|---|
| [177] | 471 | WinLoadString(hab, hModule, usID, STR_LEN_PORTNAME, chBuf); | 
|---|
| [175] | 472 | if (!strcmp (pszPortName, chBuf)) | 
|---|
|  | 473 | { | 
|---|
| [177] | 474 | if ( WinLoadString(hab, hModule, usID+1, STR_LEN_PORTDESC, chBuf) ) { | 
|---|
| [175] | 475 | strcpy (pszPortDesc, chBuf); | 
|---|
|  | 476 | return(TRUE); | 
|---|
|  | 477 | } | 
|---|
| [177] | 478 | break; | 
|---|
|  | 479 | } | 
|---|
| [175] | 480 | } | 
|---|
|  | 481 | return(FALSE); | 
|---|
|  | 482 | } | 
|---|
| [177] | 483 | BOOL  GenerateUniquePortName( PSZ pszPortName ) | 
|---|
|  | 484 | { | 
|---|
|  | 485 | BOOL   fPortExists; | 
|---|
|  | 486 | PSZ    pszEndPortName; | 
|---|
|  | 487 | USHORT i; | 
|---|
|  | 488 | CHAR   chPortData[STR_LEN_PORTNAME]; | 
|---|
|  | 489 |  | 
|---|
|  | 490 | /* | 
|---|
|  | 491 | ** Generate a unique port name by adding numbers to the | 
|---|
|  | 492 | **   end of pszPortName | 
|---|
|  | 493 | */ | 
|---|
|  | 494 | pszEndPortName = pszPortName + strlen( pszPortName ); | 
|---|
|  | 495 | i = 1; | 
|---|
|  | 496 | fPortExists = TRUE; | 
|---|
|  | 497 | while ( (i < MAX_PORTS) && fPortExists ) | 
|---|
|  | 498 | { | 
|---|
| [758] | 499 | _itoa( i, pszEndPortName, 10); | 
|---|
| [177] | 500 | fPortExists = PrfQueryProfileString (HINI_SYSTEMPROFILE, | 
|---|
|  | 501 | APPNAME_PM_SPOOLER_PORT, | 
|---|
|  | 502 | pszPortName, | 
|---|
|  | 503 | NULL, | 
|---|
|  | 504 | chPortData, | 
|---|
|  | 505 | sizeof(chPortData) - 1); | 
|---|
|  | 506 | i++; | 
|---|
|  | 507 | } | 
|---|
|  | 508 | return(!fPortExists); | 
|---|
|  | 509 | } | 
|---|
| [175] | 510 | APIRET APIENTRY SplPdEnumPort ( HAB hab, | 
|---|
|  | 511 | PVOID pBuf, | 
|---|
|  | 512 | ULONG cbBuf, | 
|---|
|  | 513 | PULONG pulReturned, | 
|---|
|  | 514 | PULONG pulTotal, | 
|---|
|  | 515 | PULONG pcbRequired ) | 
|---|
|  | 516 |  | 
|---|
|  | 517 | { | 
|---|
|  | 518 | HMODULE hModule; | 
|---|
| [177] | 519 | ULONG   ulBootDrive; | 
|---|
|  | 520 | ULONG   rcLoadMod; | 
|---|
|  | 521 | CHAR     szPathName[260]; | 
|---|
| [175] | 522 |  | 
|---|
|  | 523 | if (!pulReturned || | 
|---|
|  | 524 | !pulTotal || | 
|---|
|  | 525 | !pcbRequired) | 
|---|
|  | 526 | { | 
|---|
|  | 527 | return(ERROR_INVALID_PARAMETER); | 
|---|
|  | 528 | } | 
|---|
|  | 529 |  | 
|---|
|  | 530 | if (!pBuf && cbBuf) | 
|---|
|  | 531 | { | 
|---|
|  | 532 | return(ERROR_INVALID_PARAMETER); | 
|---|
|  | 533 | } | 
|---|
|  | 534 |  | 
|---|
|  | 535 | DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive, | 
|---|
| [177] | 536 | sizeof (ULONG)); | 
|---|
| [175] | 537 | szDefaultPortDrvPath[0] = (CHAR)(ulBootDrive + 'A' - 1); | 
|---|
|  | 538 |  | 
|---|
|  | 539 | PrfQueryProfileString (HINI_SYSTEMPROFILE, | 
|---|
| [177] | 540 | "PM_PORT_DRIVER", | 
|---|
|  | 541 | "SMB", | 
|---|
|  | 542 | szDefaultPortDrvPath, | 
|---|
|  | 543 | szPathName, | 
|---|
|  | 544 | 256 ); | 
|---|
| [175] | 545 |  | 
|---|
|  | 546 | rcLoadMod = DosLoadModule (NULL, 0, szPathName, &hModule); | 
|---|
|  | 547 |  | 
|---|
|  | 548 | if (cbBuf == 0L) | 
|---|
|  | 549 | { | 
|---|
|  | 550 | *pulReturned = 0; | 
|---|
|  | 551 | *pcbRequired = CalcBufLength (hab, hModule); | 
|---|
| [177] | 552 | *pulTotal = MAX_PORTS; | 
|---|
| [175] | 553 | if (!rcLoadMod) | 
|---|
|  | 554 | DosFreeModule (hModule); | 
|---|
|  | 555 | return(ERROR_MORE_DATA); | 
|---|
|  | 556 | } | 
|---|
|  | 557 |  | 
|---|
|  | 558 | /* | 
|---|
|  | 559 | ** check number of ports info we can fit in supplied buffer | 
|---|
|  | 560 | */ | 
|---|
| [177] | 561 | *pulTotal    = MAX_PORTS; | 
|---|
| [175] | 562 | *pcbRequired = CalcBufLength (hab, hModule); | 
|---|
|  | 563 | *pulReturned = NumPortsCanFit (hab, hModule, cbBuf); | 
|---|
|  | 564 |  | 
|---|
|  | 565 | /* | 
|---|
|  | 566 | ** return error if we can not fit one port. | 
|---|
|  | 567 | */ | 
|---|
|  | 568 | if (!(*pulReturned)) | 
|---|
|  | 569 | { | 
|---|
|  | 570 | if (!rcLoadMod) | 
|---|
| [177] | 571 | DosFreeModule (hModule); | 
|---|
| [175] | 572 | return(ERROR_INSUFFICIENT_BUFFER); | 
|---|
|  | 573 | } | 
|---|
|  | 574 |  | 
|---|
|  | 575 | /* | 
|---|
|  | 576 | ** copy all the ports which we can store in the pBuf | 
|---|
|  | 577 | */ | 
|---|
|  | 578 | CopyNPorts (hab, hModule, (PCH)pBuf, *pulReturned); | 
|---|
|  | 579 |  | 
|---|
|  | 580 | /* | 
|---|
|  | 581 | ** Free the module - we do not need it any more. | 
|---|
|  | 582 | */ | 
|---|
|  | 583 | if (!rcLoadMod) | 
|---|
| [177] | 584 | DosFreeModule (hModule); | 
|---|
| [175] | 585 |  | 
|---|
|  | 586 | /* | 
|---|
|  | 587 | ** copy all the ports which we can store in the pBuf | 
|---|
|  | 588 | */ | 
|---|
|  | 589 | if (*pulReturned < *pulTotal) | 
|---|
|  | 590 | { | 
|---|
|  | 591 | return(ERROR_MORE_DATA); | 
|---|
|  | 592 | } | 
|---|
|  | 593 |  | 
|---|
|  | 594 | return(NO_ERROR); | 
|---|
|  | 595 | } | 
|---|
|  | 596 | APIRET APIENTRY SplPdInstallPort ( HAB hab, | 
|---|
| [177] | 597 | PSZ pszPortName ) | 
|---|
| [175] | 598 | { | 
|---|
| [177] | 599 | CHAR    chBuf[STR_LEN_PORTNAME]; | 
|---|
|  | 600 | CHAR    chPortDesc[STR_LEN_PORTDESC]; | 
|---|
|  | 601 | ULONG   ulBootDrive; | 
|---|
|  | 602 | HMODULE hModule; | 
|---|
|  | 603 | CHAR    szPathName[260];    /* will contain full path to this port driver */ | 
|---|
| [175] | 604 |  | 
|---|
| [177] | 605 | if (!pszPortName) | 
|---|
|  | 606 | { | 
|---|
| [175] | 607 | return(ERROR_INVALID_PARAMETER); | 
|---|
| [177] | 608 | } | 
|---|
|  | 609 | strcpy(szDefaultPortDrvPath,PATH_SMB_PDR); | 
|---|
|  | 610 | DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive, | 
|---|
|  | 611 | sizeof (ULONG)); | 
|---|
|  | 612 | szDefaultPortDrvPath[0] = (CHAR)(ulBootDrive + 'A' - 1); | 
|---|
|  | 613 | strcpy( szPathName, szDefaultPortDrvPath ); | 
|---|
| [175] | 614 |  | 
|---|
| [177] | 615 | /* Make sure the port driver itself is installed */ | 
|---|
|  | 616 | PrfWriteProfileString (HINI_SYSTEMPROFILE, | 
|---|
|  | 617 | "PM_PORT_DRIVER", | 
|---|
|  | 618 | "SMB", | 
|---|
|  | 619 | szDefaultPortDrvPath); | 
|---|
|  | 620 |  | 
|---|
|  | 621 | /* Generate appname for "PM_SMBx" */ | 
|---|
|  | 622 | strcpy (chBuf, APPNAME_LEAD_STR); | 
|---|
|  | 623 | strcat (chBuf, pszPortName); | 
|---|
|  | 624 |  | 
|---|
|  | 625 | /* | 
|---|
|  | 626 | ** Check for this being our default Port Name to install. | 
|---|
|  | 627 | ** If so (pszPortName == "SMB") then generate a unique | 
|---|
|  | 628 | **   port name so that we can install multiple SMB printers. | 
|---|
|  | 629 | */ | 
|---|
|  | 630 | if (!strcmp(pszPortName, DEF_PORTNAME)) | 
|---|
|  | 631 | { | 
|---|
|  | 632 | /* | 
|---|
|  | 633 | ** Use chBuf to store the new portname to install | 
|---|
|  | 634 | ** Must first increment past "PM_" in chBuf | 
|---|
|  | 635 | */ | 
|---|
|  | 636 | pszPortName = chBuf + 3; | 
|---|
|  | 637 | GenerateUniquePortName( pszPortName ); | 
|---|
|  | 638 | } | 
|---|
|  | 639 |  | 
|---|
|  | 640 | /* Get initial port description (fall back to portname if unavailable) */ | 
|---|
|  | 641 | hModule = 0L ;                            /* Init module handle to null */ | 
|---|
|  | 642 | DosLoadModule (NULL, 0, szPathName, &hModule); | 
|---|
|  | 643 | if (!GetPortDescription (hab, hModule, pszPortName, chPortDesc)) | 
|---|
|  | 644 | { | 
|---|
| [175] | 645 | strcpy( chPortDesc, pszPortName ); | 
|---|
| [177] | 646 | } | 
|---|
|  | 647 | DosFreeModule (hModule); | 
|---|
|  | 648 |  | 
|---|
|  | 649 | if (!PrfWriteProfileString (HINI_SYSTEMPROFILE, | 
|---|
| [175] | 650 | chBuf, | 
|---|
|  | 651 | KEY_DESCRIPTION, | 
|---|
|  | 652 | chPortDesc)) | 
|---|
| [177] | 653 | { | 
|---|
| [175] | 654 | return (WinGetLastError (hab)); | 
|---|
| [177] | 655 | } | 
|---|
| [175] | 656 |  | 
|---|
| [177] | 657 | if (!PrfWriteProfileString (HINI_SYSTEMPROFILE, | 
|---|
| [175] | 658 | chBuf, | 
|---|
|  | 659 | KEY_INITIALIZATION, | 
|---|
|  | 660 | DEF_INITIALIZATION)) | 
|---|
| [177] | 661 | { | 
|---|
| [175] | 662 | return (WinGetLastError (hab)); | 
|---|
| [177] | 663 | } | 
|---|
| [175] | 664 |  | 
|---|
| [177] | 665 | if (!PrfWriteProfileString (HINI_SYSTEMPROFILE, | 
|---|
| [175] | 666 | chBuf, | 
|---|
|  | 667 | KEY_TERMINATION, | 
|---|
|  | 668 | DEF_TERMINATION)) | 
|---|
| [177] | 669 | { | 
|---|
| [175] | 670 | return (WinGetLastError (hab)); | 
|---|
| [177] | 671 | } | 
|---|
| [175] | 672 |  | 
|---|
| [177] | 673 | if (!PrfWriteProfileString (HINI_SYSTEMPROFILE, | 
|---|
| [175] | 674 | chBuf, | 
|---|
|  | 675 | KEY_PORTDRIVER, | 
|---|
|  | 676 | DEF_PORTDRIVER)) | 
|---|
| [177] | 677 | { | 
|---|
| [175] | 678 | return (WinGetLastError (hab)); | 
|---|
| [177] | 679 | } | 
|---|
| [175] | 680 |  | 
|---|
| [177] | 681 | if (!PrfWriteProfileString (HINI_SYSTEMPROFILE, | 
|---|
| [175] | 682 | chBuf, | 
|---|
|  | 683 | KEY_TIMEOUT, | 
|---|
|  | 684 | DEF_TIMEOUT)) | 
|---|
| [177] | 685 | { | 
|---|
| [175] | 686 | return (WinGetLastError (hab)); | 
|---|
| [177] | 687 | } | 
|---|
|  | 688 | if (!PrfWriteProfileString (HINI_SYSTEMPROFILE, | 
|---|
| [175] | 689 | APPNAME_PM_SPOOLER_PORT, | 
|---|
|  | 690 | pszPortName, | 
|---|
|  | 691 | DEF_INITIALIZATION)) | 
|---|
| [177] | 692 | { | 
|---|
| [175] | 693 | return (WinGetLastError (hab)); | 
|---|
| [177] | 694 | } | 
|---|
|  | 695 | return(NO_ERROR); | 
|---|
| [175] | 696 | } | 
|---|
|  | 697 | BOOL   APIENTRY SplPdGetPortIcon ( HAB hab, | 
|---|
| [177] | 698 | PULONG idIcon ) | 
|---|
| [175] | 699 | { | 
|---|
| [177] | 700 | if (idIcon) | 
|---|
|  | 701 | { | 
|---|
| [175] | 702 | *idIcon = SMB_ICON; | 
|---|
| [177] | 703 | } | 
|---|
|  | 704 | return(TRUE); | 
|---|
| [175] | 705 | } | 
|---|
|  | 706 | APIRET APIENTRY SplPdQueryPort ( HAB hab, | 
|---|
| [177] | 707 | PSZ pszPortName, | 
|---|
|  | 708 | PVOID pBufIn, | 
|---|
|  | 709 | ULONG cbBuf, | 
|---|
|  | 710 | PULONG cItems ) | 
|---|
| [175] | 711 | { | 
|---|
| [177] | 712 | HMODULE hModule; | 
|---|
|  | 713 | CHAR    chString[STR_LEN_DESC]; | 
|---|
|  | 714 | USHORT  usNumLines; | 
|---|
|  | 715 | USHORT  usLineID; | 
|---|
|  | 716 | USHORT  usStrLength; | 
|---|
|  | 717 | ULONG   ulBootDrive; | 
|---|
|  | 718 | PCH     pBuf = pBufIn; | 
|---|
|  | 719 | CHAR    szPathName[260];    /* will contain full path to this port driver */ | 
|---|
| [175] | 720 |  | 
|---|
| [177] | 721 | if (!cItems) | 
|---|
|  | 722 | { | 
|---|
| [175] | 723 | return(ERROR_INVALID_PARAMETER); | 
|---|
| [177] | 724 | } | 
|---|
| [175] | 725 |  | 
|---|
| [177] | 726 | if (!pBuf || !cbBuf) | 
|---|
|  | 727 | { | 
|---|
| [175] | 728 | return(ERROR_INVALID_PARAMETER); | 
|---|
| [177] | 729 | } | 
|---|
| [175] | 730 |  | 
|---|
|  | 731 |  | 
|---|
| [177] | 732 | DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive, | 
|---|
|  | 733 | sizeof (ULONG)); | 
|---|
|  | 734 | szDefaultPortDrvPath[0] = (CHAR)(ulBootDrive + 'A' - 1); | 
|---|
| [175] | 735 |  | 
|---|
| [177] | 736 | PrfQueryProfileString (HINI_SYSTEMPROFILE, | 
|---|
|  | 737 | "PM_PORT_DRIVER", | 
|---|
|  | 738 | "SMB", | 
|---|
|  | 739 | szDefaultPortDrvPath, | 
|---|
|  | 740 | szPathName, | 
|---|
|  | 741 | 256 ); | 
|---|
| [175] | 742 |  | 
|---|
| [177] | 743 | hModule = 0L ; | 
|---|
| [175] | 744 |  | 
|---|
| [177] | 745 | DosLoadModule (NULL, 0, szPathName, &hModule); | 
|---|
| [175] | 746 |  | 
|---|
| [177] | 747 | chString[0] = '\0' ; | 
|---|
| [175] | 748 |  | 
|---|
| [177] | 749 | WinLoadString(hab, hModule, (USHORT)ID_NUMBER_OF_DESC_LINES, STR_LEN_DESC, | 
|---|
|  | 750 | chString); | 
|---|
|  | 751 | usNumLines = (USHORT)atoi (chString); | 
|---|
|  | 752 | usLineID = ID_FIRST_DESC_LINES; | 
|---|
|  | 753 | for (*cItems = 0; *cItems < usNumLines; *cItems++) | 
|---|
|  | 754 | { | 
|---|
| [175] | 755 | WinLoadString(hab, hModule, usLineID, STR_LEN_DESC, chString); | 
|---|
|  | 756 | if (cbBuf >= (usStrLength = (USHORT)(strlen (chString) + 1))) | 
|---|
|  | 757 | { | 
|---|
| [177] | 758 | strcpy (pBuf, chString); | 
|---|
|  | 759 | pBuf += usStrLength; | 
|---|
|  | 760 | cbBuf -= usStrLength; | 
|---|
| [175] | 761 | } | 
|---|
|  | 762 | else | 
|---|
|  | 763 | { | 
|---|
| [177] | 764 | DosFreeModule (hModule); | 
|---|
|  | 765 | return(ERROR_INSUFFICIENT_BUFFER); | 
|---|
| [175] | 766 | } | 
|---|
| [177] | 767 | } | 
|---|
|  | 768 | DosFreeModule (hModule); | 
|---|
|  | 769 | return(NO_ERROR); | 
|---|
| [175] | 770 | } | 
|---|
|  | 771 | APIRET APIENTRY SplPdSetPort ( HAB hab, | 
|---|
|  | 772 | PSZ pszPortName, | 
|---|
|  | 773 | PULONG flModified ) | 
|---|
|  | 774 | { | 
|---|
| [177] | 775 | CHAR    chBuf[STR_LEN_PORTNAME]; | 
|---|
|  | 776 | CHAR    chPortDriver[STR_LEN_PORTNAME]; | 
|---|
|  | 777 | ULONG   ulBootDrive; | 
|---|
|  | 778 | HMODULE hModule; | 
|---|
|  | 779 | CHAR    szPathName[260];   /* will contain full path to this port driver */ | 
|---|
| [175] | 780 |  | 
|---|
| [177] | 781 | if (!pszPortName || !flModified) | 
|---|
|  | 782 | { | 
|---|
| [175] | 783 | return(ERROR_INVALID_PARAMETER); | 
|---|
| [177] | 784 | } | 
|---|
| [175] | 785 |  | 
|---|
| [177] | 786 | strcpy (chBuf, APPNAME_LEAD_STR); | 
|---|
|  | 787 | strcat (chBuf, pszPortName); | 
|---|
| [175] | 788 |  | 
|---|
| [177] | 789 | if (!(PrfQueryProfileString (HINI_SYSTEMPROFILE, chBuf, | 
|---|
| [175] | 790 | KEY_PORTDRIVER, NULL, chPortDriver, | 
|---|
|  | 791 | STR_LEN_PORTNAME))) | 
|---|
| [177] | 792 | { | 
|---|
| [175] | 793 | return(ERROR_INVALID_PARAMETER); | 
|---|
| [177] | 794 | } | 
|---|
| [175] | 795 |  | 
|---|
| [177] | 796 | if (strcmp (chPortDriver, DEF_PORTDRIVER)) | 
|---|
|  | 797 | { | 
|---|
| [175] | 798 | return(ERROR_INVALID_PARAMETER); | 
|---|
| [177] | 799 | } | 
|---|
| [175] | 800 |  | 
|---|
| [177] | 801 | DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive, | 
|---|
|  | 802 | sizeof (ULONG)); | 
|---|
|  | 803 | szDefaultPortDrvPath[0] = (CHAR)(ulBootDrive + 'A' - 1); | 
|---|
| [175] | 804 |  | 
|---|
| [177] | 805 | PrfQueryProfileString (HINI_SYSTEMPROFILE, | 
|---|
|  | 806 | "PM_PORT_DRIVER", | 
|---|
|  | 807 | "SMB", | 
|---|
|  | 808 | szDefaultPortDrvPath, | 
|---|
|  | 809 | szPathName, | 
|---|
|  | 810 | 256 ); | 
|---|
| [175] | 811 |  | 
|---|
| [177] | 812 | hModule = 0L ;                               /* Init module handle to null */ | 
|---|
| [175] | 813 |  | 
|---|
| [177] | 814 | DosLoadModule (NULL, 0, szPathName, &hModule); | 
|---|
| [175] | 815 |  | 
|---|
| [177] | 816 | *flModified = OpenLprPortDlg (hab, hModule, pszPortName, chBuf); | 
|---|
| [175] | 817 |  | 
|---|
| [177] | 818 | DosFreeModule (hModule); | 
|---|
|  | 819 | return(NO_ERROR); | 
|---|
| [175] | 820 | } | 
|---|
|  | 821 |  | 
|---|
|  | 822 |  | 
|---|
|  | 823 | APIRET APIENTRY SplPdRemovePort ( HAB hab, | 
|---|
| [177] | 824 | PSZ pszPortName ) | 
|---|
| [175] | 825 | { | 
|---|
| [177] | 826 | CHAR chBuf[STR_LEN_PORTNAME]; | 
|---|
|  | 827 | CHAR chPortDriver[STR_LEN_PORTNAME]; | 
|---|
| [175] | 828 |  | 
|---|
| [177] | 829 | if (!pszPortName) | 
|---|
|  | 830 | { | 
|---|
| [175] | 831 | return(ERROR_INVALID_PARAMETER); | 
|---|
| [177] | 832 | } | 
|---|
| [175] | 833 |  | 
|---|
| [177] | 834 | strcpy (chBuf, APPNAME_LEAD_STR); | 
|---|
|  | 835 | strcat (chBuf, pszPortName); | 
|---|
| [175] | 836 |  | 
|---|
| [177] | 837 | if (!(PrfQueryProfileString (HINI_SYSTEMPROFILE, chBuf, | 
|---|
| [175] | 838 | KEY_PORTDRIVER, NULL, chPortDriver, | 
|---|
|  | 839 | STR_LEN_PORTNAME))) | 
|---|
| [177] | 840 | { | 
|---|
| [175] | 841 | return(ERROR_INVALID_PARAMETER); | 
|---|
| [177] | 842 | } | 
|---|
| [175] | 843 |  | 
|---|
| [177] | 844 | if (strcmp (chPortDriver, DEF_PORTDRIVER)) | 
|---|
|  | 845 | { | 
|---|
| [175] | 846 | return(ERROR_INVALID_PARAMETER); | 
|---|
| [177] | 847 | } | 
|---|
| [175] | 848 |  | 
|---|
| [177] | 849 | PrfWriteProfileString (HINI_SYSTEMPROFILE, chBuf, NULL, NULL); | 
|---|
| [175] | 850 |  | 
|---|
| [177] | 851 | PrfWriteProfileString (HINI_SYSTEMPROFILE, | 
|---|
|  | 852 | APPNAME_PM_SPOOLER_PORT, | 
|---|
|  | 853 | pszPortName, | 
|---|
|  | 854 | NULL); | 
|---|
|  | 855 | return(NO_ERROR); | 
|---|
| [175] | 856 |  | 
|---|
|  | 857 | } | 
|---|
|  | 858 | ULONG APIENTRY SplPdOpen( PSZ     pszPortName, | 
|---|
| [177] | 859 | PHFILE  phFile, | 
|---|
|  | 860 | PULONG  pDeviceFlags, | 
|---|
|  | 861 | PVOID   pPrtOpenStruct) | 
|---|
| [175] | 862 | { | 
|---|
| [177] | 863 | APIRET rc; | 
|---|
|  | 864 | ULONG  ulAction       = 0;      /* Action taken by DosOpen */ | 
|---|
|  | 865 | ULONG  ulBytesRead    = 0;      /* Number of bytes read by DosRead */ | 
|---|
|  | 866 | ULONG  ulWrote       = 0;      /* Number of bytes written by DosWrite */ | 
|---|
|  | 867 | ULONG  ulLocal       = 0;      /* File pointer position after DosSetFilePtr */ | 
|---|
|  | 868 | CHAR   szTemp[ 256]; | 
|---|
|  | 869 | UCHAR  tmp[256]; | 
|---|
|  | 870 | ULONG  pcbWritten ; | 
|---|
|  | 871 | USHORT  i; | 
|---|
|  | 872 | HFILE   control; | 
|---|
|  | 873 | UCHAR  filename[256]; | 
|---|
|  | 874 | DATETIME dt; | 
|---|
|  | 875 | UCHAR  spool_dir[256]; | 
|---|
|  | 876 | PEAOP2 pEABuf = NULL; | 
|---|
|  | 877 | /*   UCHAR       pszPSHeader[] = "%!PS-Adobe-3.0\n"; | 
|---|
|  | 878 | ULONG           cbHeader;  */ | 
|---|
| [175] | 879 |  | 
|---|
|  | 880 |  | 
|---|
| [177] | 881 | if (!phFile || !pDeviceFlags ) | 
|---|
|  | 882 | { | 
|---|
|  | 883 | return(ERROR_INVALID_PARAMETER); | 
|---|
|  | 884 | } | 
|---|
|  | 885 | DosGetDateTime(&dt); | 
|---|
|  | 886 | rc = PrfQueryProfileString (HINI_SYSTEMPROFILE, | 
|---|
|  | 887 | "PM_SPOOLER", | 
|---|
|  | 888 | "DIR", | 
|---|
|  | 889 | NULL, | 
|---|
|  | 890 | (PSZ)spool_dir, | 
|---|
|  | 891 | sizeof(spool_dir)); | 
|---|
|  | 892 | spool_dir[ strlen(spool_dir) - 1] = '\0'; | 
|---|
|  | 893 | sprintf(tmp,"%s\\SMB",spool_dir); | 
|---|
|  | 894 | DosCreateDir( tmp,pEABuf ); | 
|---|
|  | 895 | sprintf(filename,"%s\\SMB\\%02d_%02d_%02d_%02d_%s",spool_dir,dt.hours,dt.minutes,dt.seconds,dt.hundredths,pszPortName); | 
|---|
|  | 896 | rc = DosOpen(filename, | 
|---|
|  | 897 | phFile,                       /* File handle */ | 
|---|
|  | 898 | &ulAction,                     /* Action taken */ | 
|---|
|  | 899 | 100L,                           /* File primary allocation */ | 
|---|
|  | 900 | FILE_ARCHIVED | FILE_NORMAL,    /* File attribute */ | 
|---|
|  | 901 | OPEN_ACTION_CREATE_IF_NEW | | 
|---|
|  | 902 | OPEN_ACTION_OPEN_IF_EXISTS,     /* Open function type */ | 
|---|
|  | 903 | OPEN_FLAGS_NOINHERIT | | 
|---|
|  | 904 | OPEN_SHARE_DENYNONE  | | 
|---|
|  | 905 | OPEN_ACCESS_READWRITE,         /* Open mode of the file */ | 
|---|
|  | 906 | 0L);                         /* No extended attribute */ | 
|---|
|  | 907 | /*  DosWrite(*phFile,pszPSHeader,strlen(pszPSHeader),&cbHeader);  */ | 
|---|
|  | 908 | sprintf(szTemp,"PM_%s",pszPortName); | 
|---|
|  | 909 | if (PrfQueryProfileString (HINI_SYSTEMPROFILE, | 
|---|
|  | 910 | szTemp, | 
|---|
|  | 911 | KEY_INITIALIZATION, | 
|---|
|  | 912 | NULL, | 
|---|
|  | 913 | szTemp, | 
|---|
|  | 914 | sizeof(szTemp))) | 
|---|
|  | 915 | { | 
|---|
|  | 916 | sprintf(tmp   ,"%s\\SMB\\%d.control",spool_dir,*phFile); | 
|---|
|  | 917 | rc = DosOpen( tmp    , | 
|---|
|  | 918 | &control,                         /* File handle */ | 
|---|
|  | 919 | &ulAction,                     /* Action taken */ | 
|---|
|  | 920 | strlen(szTemp),              /* File primary allocation */ | 
|---|
|  | 921 | FILE_ARCHIVED | FILE_NORMAL,    /* File attribute */ | 
|---|
|  | 922 | OPEN_ACTION_CREATE_IF_NEW | | 
|---|
|  | 923 | OPEN_ACTION_OPEN_IF_EXISTS,     /* Open function type */ | 
|---|
|  | 924 | OPEN_FLAGS_NOINHERIT | | 
|---|
|  | 925 | OPEN_SHARE_DENYNONE  | | 
|---|
|  | 926 | OPEN_ACCESS_READWRITE,         /* Open mode of the file */ | 
|---|
|  | 927 | 0L);                         /* No extended attribute */ | 
|---|
|  | 928 | rc = DosWrite( control,szTemp,strlen(szTemp),&pcbWritten); | 
|---|
|  | 929 | rc = DosWrite( control,"#",1,&pcbWritten); | 
|---|
|  | 930 | rc = DosWrite( control,filename,strlen(filename),&pcbWritten); | 
|---|
|  | 931 | rc = DosWrite( control,"@",1,&pcbWritten); | 
|---|
|  | 932 | rc = DosClose(control); | 
|---|
|  | 933 | } | 
|---|
|  | 934 | return rc; | 
|---|
| [175] | 935 |  | 
|---|
|  | 936 | } | 
|---|
| [758] | 937 | #if 1 | 
|---|
|  | 938 | ULONG  APIENTRY SplPdQuery ( PSZ    pszPortName, | 
|---|
|  | 939 | ULONG  ulFlags, | 
|---|
|  | 940 | ULONG  ulCommand, | 
|---|
|  | 941 | PVOID  pInData, | 
|---|
|  | 942 | ULONG  cbInData, | 
|---|
|  | 943 | PVOID  pOutData, | 
|---|
|  | 944 | PULONG pcbOutData ) | 
|---|
|  | 945 | { | 
|---|
|  | 946 | PPORTSETTINGS pSettings; | 
|---|
|  | 947 | CHAR          szAppName[ STR_LEN_PORTNAME ]; | 
|---|
|  | 948 | ULONG         rc; | 
|---|
|  | 949 |  | 
|---|
|  | 950 | // Generate appname for "PM_SMBx" | 
|---|
|  | 951 | strcpy( szAppName, APPNAME_LEAD_STR); | 
|---|
|  | 952 | strncat( szAppName, pszPortName, STR_LEN_PORTNAME-1 ); | 
|---|
|  | 953 |  | 
|---|
|  | 954 | switch ( ulCommand ) { | 
|---|
|  | 955 |  | 
|---|
|  | 956 | case BIDI_Q_PORTDRV: | 
|---|
| [772] | 957 | // If no buffer was provided, just return the required size | 
|---|
|  | 958 | if ( !pOutData && pcbOutData ) { | 
|---|
|  | 959 | *pcbOutData = sizeof( PORTSETTINGS ); | 
|---|
|  | 960 | return ERROR_MORE_DATA; | 
|---|
|  | 961 | } | 
|---|
| [758] | 962 | // Make sure the data is valid | 
|---|
| [772] | 963 | if ( !pOutData || !pcbOutData || ( *pcbOutData < sizeof( PORTSETTINGS ))) | 
|---|
| [758] | 964 | return( ERROR_INVALID_PARAMETER ); | 
|---|
|  | 965 | pSettings = (PPORTSETTINGS) pOutData; | 
|---|
|  | 966 |  | 
|---|
|  | 967 | PrfQueryProfileString( HINI_SYSTEMPROFILE, szAppName, | 
|---|
|  | 968 | KEY_INITIALIZATION, NULL, | 
|---|
|  | 969 | pSettings->szPortData, STR_LEN_PORTDESC ); | 
|---|
|  | 970 | *pcbOutData = sizeof( PORTSETTINGS ); | 
|---|
|  | 971 | rc = NO_ERROR; | 
|---|
|  | 972 | break; | 
|---|
|  | 973 |  | 
|---|
|  | 974 | default: | 
|---|
|  | 975 | rc = ERROR_NOT_SUPPORTED; | 
|---|
|  | 976 | //rc = NO_ERROR; | 
|---|
|  | 977 | break; | 
|---|
|  | 978 | } | 
|---|
|  | 979 |  | 
|---|
|  | 980 | return ( rc ); | 
|---|
|  | 981 | } | 
|---|
|  | 982 | ULONG  APIENTRY SplPdSet   ( PSZ    pszPortName, | 
|---|
|  | 983 | ULONG  ulFlags, | 
|---|
|  | 984 | ULONG  ulCommand, | 
|---|
|  | 985 | PVOID  pInData, | 
|---|
|  | 986 | ULONG  cbInData ) | 
|---|
|  | 987 | { | 
|---|
|  | 988 | PPORTSETTINGS pSettings; | 
|---|
|  | 989 | CHAR          szIniStr[ STR_LEN_PORTDESC ] = {0}; | 
|---|
|  | 990 | CHAR          szAppName[ STR_LEN_PORTNAME ]; | 
|---|
|  | 991 | PSZ           token; | 
|---|
|  | 992 | ULONG         rc; | 
|---|
|  | 993 |  | 
|---|
|  | 994 | // Generate appname for "PM_CUPSx" | 
|---|
|  | 995 | strcpy( szAppName, APPNAME_LEAD_STR); | 
|---|
|  | 996 | strncat( szAppName, pszPortName, STR_LEN_PORTNAME-1 ); | 
|---|
|  | 997 |  | 
|---|
|  | 998 | switch ( ulCommand ) { | 
|---|
|  | 999 |  | 
|---|
|  | 1000 | case BIDI_SET_PORTDRV: | 
|---|
|  | 1001 | // Validate the data | 
|---|
|  | 1002 | if ( !pInData || cbInData < sizeof( PORTSETTINGS )) | 
|---|
|  | 1003 | return( ERROR_INVALID_PARAMETER ); | 
|---|
|  | 1004 | pSettings = (PPORTSETTINGS) pInData; | 
|---|
|  | 1005 | // Update the INITIALIZATION string | 
|---|
|  | 1006 | PrfWriteProfileString( HINI_SYSTEMPROFILE, szAppName, | 
|---|
|  | 1007 | KEY_INITIALIZATION, pSettings->szPortData ); | 
|---|
|  | 1008 | PrfWriteProfileString( HINI_SYSTEMPROFILE, APPNAME_PM_SPOOLER_PORT, | 
|---|
|  | 1009 | pszPortName, pSettings->szPortData ); | 
|---|
|  | 1010 | // Update the DESCRIPTION string | 
|---|
|  | 1011 | if (( token = lprtok( pSettings->szPortData, "#")) != NULL ) { | 
|---|
|  | 1012 | strncpy( szIniStr, token, STR_LEN_PORTDESC-1 ); | 
|---|
|  | 1013 | if (( token = lprtok( NULL, "#")) != NULL ) { | 
|---|
|  | 1014 | if ( token[ strlen(token) - 1 ] == ';') | 
|---|
|  | 1015 | token[ strlen(token) - 1 ] = '\0'; | 
|---|
|  | 1016 | strncat( szIniStr, ":", STR_LEN_PORTDESC-1 ); | 
|---|
|  | 1017 | strncat( szIniStr, token, STR_LEN_PORTDESC-1 ); | 
|---|
|  | 1018 | } | 
|---|
|  | 1019 | } | 
|---|
|  | 1020 | PrfWriteProfileString( HINI_SYSTEMPROFILE, | 
|---|
|  | 1021 | szAppName, KEY_DESCRIPTION, szIniStr ); | 
|---|
|  | 1022 | rc = NO_ERROR; | 
|---|
|  | 1023 | break; | 
|---|
|  | 1024 |  | 
|---|
|  | 1025 | default: | 
|---|
|  | 1026 | //rc = ERROR_NOT_SUPPORTED; | 
|---|
|  | 1027 | rc = NO_ERROR; | 
|---|
|  | 1028 | break; | 
|---|
|  | 1029 | } | 
|---|
|  | 1030 | return ( rc ); | 
|---|
|  | 1031 |  | 
|---|
|  | 1032 | } | 
|---|
|  | 1033 | #else | 
|---|
| [175] | 1034 | ULONG  APIENTRY SplPdQuery ( PSZ    pszDeviceName, | 
|---|
| [177] | 1035 | ULONG  ulFlags, | 
|---|
|  | 1036 | ULONG  ulCommand, | 
|---|
|  | 1037 | PVOID  pInData, | 
|---|
|  | 1038 | ULONG  cbInData, | 
|---|
|  | 1039 | PVOID  pOutData, | 
|---|
|  | 1040 | PULONG pcbOutData ) | 
|---|
| [175] | 1041 | { | 
|---|
| [177] | 1042 | /*  return ERROR_NOT_SUPPORTED; */ | 
|---|
| [175] | 1043 | return NO_ERROR; | 
|---|
|  | 1044 | } | 
|---|
|  | 1045 | ULONG APIENTRY SplPdSet ( PSZ    pszDeviceName, | 
|---|
|  | 1046 | ULONG  ulFlags, | 
|---|
|  | 1047 | ULONG  ulCommand, | 
|---|
|  | 1048 | PVOID  pInData, | 
|---|
|  | 1049 | ULONG  cbInData ) | 
|---|
|  | 1050 | { | 
|---|
|  | 1051 | /* return ERROR_NOT_SUPPORTED; */ | 
|---|
|  | 1052 | return NO_ERROR; | 
|---|
|  | 1053 | } | 
|---|
| [758] | 1054 | #endif | 
|---|
| [175] | 1055 | ULONG  APIENTRY SplPdNewPage ( HFILE  hFile, ULONG ulPageNumber ) | 
|---|
|  | 1056 | { | 
|---|
|  | 1057 | return NO_ERROR; | 
|---|
|  | 1058 | } | 
|---|
|  | 1059 | ULONG APIENTRY SplPdAbortDoc( HFILE   hFile, | 
|---|
|  | 1060 | PVOID   pchData, | 
|---|
|  | 1061 | ULONG   cbData, | 
|---|
|  | 1062 | ULONG   ulFlags ) | 
|---|
|  | 1063 | { | 
|---|
|  | 1064 | return NO_ERROR; | 
|---|
|  | 1065 | } | 
|---|
|  | 1066 | ULONG  APIENTRY SplPdClose( HFILE  hFile ) | 
|---|
|  | 1067 | { | 
|---|
|  | 1068 | APIRET      rc; | 
|---|
|  | 1069 | APIRET      resp; | 
|---|
|  | 1070 | USHORT      i; | 
|---|
|  | 1071 | USHORT      j; | 
|---|
|  | 1072 | RESULTCODES rc_child; | 
|---|
|  | 1073 | ULONG       nbr_lu; | 
|---|
|  | 1074 | ULONG       ulAction; | 
|---|
|  | 1075 | UCHAR       szTemp[256]; | 
|---|
|  | 1076 | HFILE       control; | 
|---|
|  | 1077 | UCHAR       binfile[256]; | 
|---|
|  | 1078 | UCHAR       arg[256]; | 
|---|
|  | 1079 | UCHAR       j_url[256] ; | 
|---|
|  | 1080 | UCHAR       j_id[3]; | 
|---|
|  | 1081 | UCHAR       j_user[256]; | 
|---|
|  | 1082 | UCHAR       j_title[256]; | 
|---|
|  | 1083 | UCHAR       j_copies[3]; | 
|---|
|  | 1084 | UCHAR       j_options[8]; | 
|---|
|  | 1085 | UCHAR       filename[256]; | 
|---|
|  | 1086 | UCHAR       ip_add[256]; | 
|---|
|  | 1087 | UCHAR       queue_name[256]; | 
|---|
|  | 1088 | UCHAR       workgroup[256]; | 
|---|
|  | 1089 | UCHAR       username[256]; | 
|---|
|  | 1090 | UCHAR       password_enc[256]; | 
|---|
|  | 1091 | UCHAR       password_dec[256]; | 
|---|
|  | 1092 | UCHAR       errorstr[256]; | 
|---|
|  | 1093 | USHORT      pos; | 
|---|
|  | 1094 | UCHAR       spool_dir[256]; | 
|---|
|  | 1095 | ULONG       ulBootDrive; | 
|---|
|  | 1096 |  | 
|---|
|  | 1097 | rc = PrfQueryProfileString (HINI_SYSTEMPROFILE, | 
|---|
|  | 1098 | "PM_SPOOLER", | 
|---|
|  | 1099 | "DIR", | 
|---|
|  | 1100 | NULL, | 
|---|
|  | 1101 | (PSZ)spool_dir, | 
|---|
|  | 1102 | sizeof(spool_dir)); | 
|---|
|  | 1103 | spool_dir[ strlen(spool_dir) - 1] = '\0'; | 
|---|
|  | 1104 | sprintf(szTemp,"%s\\SMB\\%d.control",spool_dir,hFile); | 
|---|
|  | 1105 | rc = DosOpen(szTemp, | 
|---|
|  | 1106 | &control, | 
|---|
|  | 1107 | &ulAction, | 
|---|
|  | 1108 | 0L, | 
|---|
|  | 1109 | FILE_ARCHIVED | FILE_NORMAL, | 
|---|
|  | 1110 | OPEN_ACTION_CREATE_IF_NEW | | 
|---|
|  | 1111 | OPEN_ACTION_OPEN_IF_EXISTS, | 
|---|
|  | 1112 | OPEN_FLAGS_NOINHERIT | | 
|---|
|  | 1113 | OPEN_SHARE_DENYNONE  | | 
|---|
|  | 1114 | OPEN_ACCESS_READWRITE, | 
|---|
|  | 1115 | 0L); | 
|---|
|  | 1116 | rc = DosRead( control,szTemp,sizeof(szTemp),&nbr_lu); | 
|---|
|  | 1117 | rc = DosClose( control ); | 
|---|
|  | 1118 | sprintf(filename,"%s\\SMB\\%d.control",spool_dir,hFile); | 
|---|
|  | 1119 | DosDelete(filename); | 
|---|
|  | 1120 |  | 
|---|
|  | 1121 | i = 0; | 
|---|
|  | 1122 | j = 0; | 
|---|
|  | 1123 | pos = 0; | 
|---|
|  | 1124 | while (szTemp[i] != '@') | 
|---|
|  | 1125 | { | 
|---|
|  | 1126 | if (szTemp[i] == '#') | 
|---|
|  | 1127 | { | 
|---|
|  | 1128 | szTemp[i] = '\0'; | 
|---|
|  | 1129 | switch(j) | 
|---|
|  | 1130 | { | 
|---|
|  | 1131 | case 0:strcpy(ip_add,&szTemp[pos]); | 
|---|
|  | 1132 | break; | 
|---|
|  | 1133 | case 1:strcpy(queue_name,&szTemp[pos]); | 
|---|
|  | 1134 | break; | 
|---|
|  | 1135 | case 2:strcpy(workgroup,&szTemp[pos]); | 
|---|
|  | 1136 | break; | 
|---|
|  | 1137 | case 3:strcpy(username,&szTemp[pos]); | 
|---|
|  | 1138 | break; | 
|---|
|  | 1139 | case 4:strcpy(j_copies,&szTemp[pos]); | 
|---|
|  | 1140 | break; | 
|---|
|  | 1141 | case 5:strcpy(password_enc,&szTemp[pos]); | 
|---|
|  | 1142 | break; | 
|---|
|  | 1143 | } | 
|---|
|  | 1144 | pos = i+1; | 
|---|
|  | 1145 | j++; | 
|---|
|  | 1146 | } | 
|---|
|  | 1147 | i++; | 
|---|
|  | 1148 | } | 
|---|
|  | 1149 | szTemp[i] = '\0'; | 
|---|
|  | 1150 | strcpy(filename,&szTemp[pos]); | 
|---|
| [177] | 1151 |  | 
|---|
| [175] | 1152 | rc = DosClose( hFile ); | 
|---|
|  | 1153 | DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive, | 
|---|
|  | 1154 | sizeof (ULONG)); | 
|---|
|  | 1155 |  | 
|---|
|  | 1156 | decryptPassword(password_enc,password_dec); | 
|---|
| [177] | 1157 |  | 
|---|
| [175] | 1158 | // Usage: smbspool [DEVICE_URI] job-id user title copies options [file] | 
|---|
|  | 1159 |  | 
|---|
|  | 1160 | sprintf(binfile, "smbspool.exe\0"); | 
|---|
|  | 1161 | sprintf(j_url,"smb://%s:%s@%s/%s/%s",username,password_dec,workgroup,ip_add,queue_name); | 
|---|
|  | 1162 | sprintf(j_id,"999"); | 
|---|
|  | 1163 | sprintf(j_user,username); | 
|---|
|  | 1164 | sprintf(j_title,"from %s",getenv("HOSTNAME")); | 
|---|
|  | 1165 | sprintf(j_options,"opt"); | 
|---|
| [177] | 1166 | rc = spawnlp(P_WAIT,binfile,binfile,j_url,j_id,j_user,j_title,j_copies,j_options,filename,NULL); | 
|---|
|  | 1167 |  | 
|---|
| [175] | 1168 | while (rc != 0) | 
|---|
|  | 1169 | { | 
|---|
| [422] | 1170 | sprintf(errorstr,"Error %d during spooling to smb://%s:****@%s/%s/%s",rc,username,workgroup,ip_add,queue_name); | 
|---|
| [177] | 1171 | resp = WinMessageBox (HWND_DESKTOP, | 
|---|
|  | 1172 | HWND_DESKTOP, | 
|---|
|  | 1173 | errorstr, | 
|---|
| [175] | 1174 | "CIFS/SMB Port driver error", | 
|---|
|  | 1175 | 0L, MB_RETRYCANCEL | MB_WARNING | MB_MOVEABLE); | 
|---|
| [177] | 1176 | if (resp != MBID_CANCEL ) | 
|---|
| [175] | 1177 | { | 
|---|
| [177] | 1178 | rc = spawnlp(P_WAIT,binfile,binfile,j_url,j_id,j_user,j_title,j_copies,j_options,filename,NULL); | 
|---|
| [175] | 1179 | } | 
|---|
|  | 1180 | else rc = 0; | 
|---|
|  | 1181 | }; | 
|---|
| [177] | 1182 |  | 
|---|
| [175] | 1183 | strcpy(filename,&szTemp[pos]); | 
|---|
|  | 1184 | DosDelete(filename); | 
|---|
|  | 1185 |  | 
|---|
|  | 1186 | /* We always have to return success to the spooler subsystem */ | 
|---|
|  | 1187 | rc = NO_ERROR; | 
|---|
|  | 1188 | return rc; | 
|---|
|  | 1189 | } | 
|---|
| [177] | 1190 | ULONG APIENTRY SplPdWrite( HFILE    hFile, | 
|---|
|  | 1191 | PVOID   pchData, | 
|---|
|  | 1192 | ULONG   cbData, | 
|---|
| [175] | 1193 | PULONG  pcbWritten ) | 
|---|
|  | 1194 | {  APIRET rc; | 
|---|
|  | 1195 |  | 
|---|
|  | 1196 | rc = DosWrite( hFile,pchData,cbData,pcbWritten); | 
|---|
|  | 1197 | rc = DosSleep(0); | 
|---|
|  | 1198 | return rc; | 
|---|
|  | 1199 | } | 
|---|
|  | 1200 |  | 
|---|