Changeset 15
- Timestamp:
- Sep 18, 2013, 1:36:17 AM (12 years ago)
- Location:
- rxprtutl/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
rxprtutl/trunk/rxprtutl.c
r14 r15 60 60 #define SZ_LIBRARY_NAME "RXPRTUTL" // Name of this library 61 61 #define SZ_ERROR_NAME "RPUERROR" // REXX variable used to store error codes 62 #define SZ_VERSION "0.2. 2" // Current version of this library62 #define SZ_VERSION "0.2.4" // Current version of this library 63 63 64 64 #define APPNAME_LEAD_STR "PM_" … … 123 123 static PSZ RxFunctionTbl[] = { 124 124 "RPUDropFuncs", 125 "RPUDeviceDelete", 125 126 "RPUEnumModels", 126 127 "RPUEnumDrivers", … … 149 150 RexxFunctionHandler RPUDropFuncs; 150 151 RexxFunctionHandler RPUVersion; 152 RexxFunctionHandler RPUDeviceDelete; 151 153 RexxFunctionHandler RPUEnumModels; 152 154 RexxFunctionHandler RPUEnumDrivers; … … 260 262 261 263 /* ------------------------------------------------------------------------- * 264 * RPUDeviceDelete * 265 * * 266 * Deletes a local print device which lacks a printer queue. Can be useful * 267 * for cleaning up bad or corrupted printer definitions. * 268 * * 269 * REXX ARGUMENTS: * 270 * 1. The name of the print device to be deleted. (REQUIRED) * 271 * * 272 * REXX RETURN VALUE: * 273 * 1 on success, or 0 if an error occurred. * 274 * ------------------------------------------------------------------------- */ 275 ULONG APIENTRY RPUDeviceDelete( PSZ pszName, ULONG argc, RXSTRING argv[], PSZ pszQueue, PRXSTRING prsResult ) 276 { 277 PSZ pszDeviceName = NULL; 278 SPLERR rc; 279 280 281 // Reset the error indicator 282 WriteErrorCode( 0, NULL ); 283 284 // Validate the REXX arguments 285 if (( argc != 1 ) || ( ! RXVALIDSTRING( argv[0] ))) 286 return ( 40 ); 287 288 pszDeviceName = argv[0].strptr; 289 290 rc = SplDeleteDevice( NULL, pszDeviceName ); 291 if ( rc != NO_ERROR ) { 292 WriteErrorCode( rc, "SplDeleteDevice"); 293 MAKERXSTRING( *prsResult, "0", 1 ); 294 return 0; 295 } 296 297 MAKERXSTRING( *prsResult, "1", 1 ); 298 return ( 0 ); 299 } 300 301 302 /* ------------------------------------------------------------------------- * 262 303 * RPUEnumModels * 263 304 * * … … 285 326 pldt = 0L, // number of data types 286 327 i; 287 328 APIRET rc = 0; 288 329 289 330 // Reset the error indicator … … 318 359 319 360 // Now get the actual data 361 #if 1 362 rc = DosAllocMem( (PVOID) &aDeviceName, (ULONG) pldn * sizeof( STR32 ), PAG_WRITE | PAG_COMMIT ); 363 if ( rc != NO_ERROR ) { 364 WriteErrorCode( rc, "DosAllocMem"); 365 MAKERXSTRING( *prsResult, "0", 1 ); 366 goto cleanup; 367 } 368 rc = DosAllocMem( (PVOID) &aDeviceDesc, (ULONG) pldn * sizeof( STR64 ), PAG_WRITE | PAG_COMMIT ); 369 if ( rc != NO_ERROR ) { 370 WriteErrorCode( rc, "DosAllocMem"); 371 MAKERXSTRING( *prsResult, "0", 1 ); 372 DosFreeMem( aDeviceName ); 373 goto cleanup; 374 } 375 rc = DosAllocMem( (PVOID) &aDataType, (ULONG) pldt * sizeof( STR16 ), PAG_WRITE | PAG_COMMIT ); 376 if ( rc != NO_ERROR ) { 377 WriteErrorCode( rc, "DosAllocMem"); 378 MAKERXSTRING( *prsResult, "0", 1 ); 379 DosFreeMem( aDeviceName ); 380 DosFreeMem( aDeviceDesc ); 381 goto cleanup; 382 } 383 #else 320 384 aDeviceName = malloc( pldn * sizeof( STR32 )); 385 if ( !aDeviceName ) { 386 WriteErrorCode( ERROR_NOT_ENOUGH_MEMORY, "malloc"); 387 MAKERXSTRING( *prsResult, "0", 1 ); 388 goto cleanup; 389 } 321 390 aDeviceDesc = malloc( pldn * sizeof( STR64 )); 322 aDataType = malloc( pldt * sizeof( STR16 )); 323 if ( !aDeviceName || !aDeviceDesc || ! aDataType ) { 391 if ( !aDeviceDesc ) { 324 392 WriteErrorCode( ERROR_NOT_ENOUGH_MEMORY, "malloc"); 325 393 MAKERXSTRING( *prsResult, "0", 1 ); 394 free( aDeviceName ); 326 395 goto cleanup; 327 396 } 397 aDataType = malloc( pldt * sizeof( STR16 )); 398 if ( !aDataType ) { 399 WriteErrorCode( ERROR_NOT_ENOUGH_MEMORY, "malloc"); 400 MAKERXSTRING( *prsResult, "0", 1 ); 401 free( aDeviceName ); 402 free( aDeviceDesc ); 403 goto cleanup; 404 } 405 #endif 328 406 fSuccess = DevQueryDeviceNames( hab, pszDriver, &pldn, aDeviceName, 329 407 aDeviceDesc, &pldt, aDataType ); … … 337 415 MAKERXSTRING( *prsResult, "1", 1 ); 338 416 417 #if 1 418 DosFreeMem( aDeviceName ); 419 DosFreeMem( aDeviceDesc ); 420 DosFreeMem( aDataType ); 421 #else 339 422 free( aDeviceName ); 340 423 free( aDeviceDesc ); 341 424 free( aDataType ); 425 #endif 342 426 343 427 cleanup: … … 785 869 * (stem).!driver The name of the port driver * 786 870 * (stem).!converter The name of the protocol converter used * 871 * TODO * 872 * (stem).!printer The device name of the printer(s) using this * 873 * port, if any ('' if not in use) * 787 874 * * 788 875 * REXX RETURN VALUE: * … … 1466 1553 * Gets information about the specified printer device. * 1467 1554 * * 1468 * (stem). i.!description Printer description (name of WPS object)*1469 * (stem). i.!port Name of the port the printer is using*1470 * (stem). i.!driver List of the drivers used by this printer*1471 * (stem). i.!jobflags Zero or more of the following flags (any order):*1555 * (stem).!description Printer description (name of WPS object) * 1556 * (stem).!port Name of the port the printer is using * 1557 * (stem).!driver2 List of the drivers used by this printer * 1558 * (stem).!jobflags Zero or more of the following flags (any order): * 1472 1559 * E A printer error has occurred * 1473 1560 * H Printer destination is paused (held) * -
rxprtutl/trunk/rxprtutl.def
r14 r15 1 1 LIBRARY RXPRTUTL INITINSTANCE TERMINSTANCE 2 2 DATA MULTIPLE NONSHARED 3 DESCRIPTION '@#Alex Taylor:0.2. 2#@##1## 3 May 2013 12:46:17REINFORCE::::::@@REXX Printer Management Utilities'3 DESCRIPTION '@#Alex Taylor:0.2.4#@##1## 8 Sep 2013 20:30:22 REINFORCE::::::@@REXX Printer Management Utilities' 4 4 5 5 EXPORTS RPULoadFuncs 6 6 RPUDropFuncs 7 7 RPUVersion 8 RPUDeviceDelete 8 9 RPUEnumModels 9 10 RPUEnumDrivers -
rxprtutl/trunk/testlib.cmd
r13 r15 74 74 */ 75 75 76 77 rc = RPUEnumModels(test_driver_file, 'models.') 78 IF rc == 0 THEN SAY RPUERROR 79 ELSE DO 80 SAY models.0 'models found in driver' test_driver_file 81 DROP models. 82 76 83 CALL RPUDropFuncs 77 84 RETURN 0
Note:
See TracChangeset
for help on using the changeset viewer.