Changeset 7 for rxprtutl/trunk/rxprtutl.c
- Timestamp:
- Apr 5, 2013, 5:29:49 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
rxprtutl/trunk/rxprtutl.c
r6 r7 104 104 "RPUPortSet", 105 105 "RPUPrinterCreate", 106 "RPUPrinterDelete", 106 107 "RPUPrinterQuery", 107 108 "RPUVersion" … … 124 125 RexxFunctionHandler RPUPortSet; 125 126 RexxFunctionHandler RPUPrinterCreate; 127 RexxFunctionHandler RPUPrinterDelete; 126 128 RexxFunctionHandler RPUPrinterQuery; 127 129 RexxFunctionHandler RPUQueueDefault; … … 1015 1017 * been installed already. * 1016 1018 * * 1017 * The WPS object is created with default settings, other than those which * 1018 * are specified here. * 1019 * * 1020 * This function will not create a LAN printer object. Use the function * 1021 * RPUPrinterCreateRemote (not yet implemented) for that purpose. * 1019 * The WPS object is created with default settings (other than those which * 1020 * are specified here). It will be assigned an object-ID automatically. * 1021 * * 1022 * This function will not create a remote (LAN) printer object. * 1022 1023 * * 1023 1024 * REXX ARGUMENTS: * … … 1027 1028 * 4. The default printer driver.model to be associated with * 1028 1029 * the device. If specified, this must be installed in the * 1029 * system already. If NOT specified, IBMNULL will be assumed*1030 * if the specified printer device does not already exist. (OPTIONAL) *1030 * system already. If not specified, and the named printer * 1031 * device does not already exist, IBMNULL will be assumed. (OPTIONAL) * 1031 1032 * 5. The printer object title (i.e. human-readable name). If * 1032 1033 * not specified, the physical name will be used. (OPTIONAL) * … … 1046 1047 pszModel = NULL, 1047 1048 pszTitle = NULL; 1048 // pszOID = NULL;1049 // CHAR szSetup[ US_SS_MAXZ ] = {0};1050 1049 SPLERR rc; 1051 1050 … … 1062 1061 if (( argc > 4 ) && ( ! RXVALIDSTRING( argv[4] ))) 1063 1062 return ( 40 ); 1064 // if (( argc > 5 ) && ( ! RXVALIDSTRING( argv[5] )))1065 // return ( 40 );1066 1063 1067 1064 pszQueueName = argv[0].strptr; … … 1070 1067 if ( argc > 3 ) pszModel = argv[3].strptr; 1071 1068 pszTitle = ( argc > 4 ) ? argv[4].strptr : pszDeviceName; 1072 // if ( argc > 5 ) pszOID = argv[5].strptr;1073 1069 1074 1070 // Find out if device exists already … … 1078 1074 // Nope, create it now 1079 1075 devinfo.pszPrinterName = pszDeviceName; 1080 devinfo.pszUserName = NULL;1081 devinfo.pszLogAddr = pszPortName;1082 devinfo.pszComment = pszTitle;1083 devinfo.pszDrivers = pszModel ? pszModel : "IBMNULL";1084 devinfo.usTimeOut = 45;1076 devinfo.pszUserName = NULL; 1077 devinfo.pszLogAddr = pszPortName; 1078 devinfo.pszComment = pszTitle; 1079 devinfo.pszDrivers = pszModel ? pszModel : "IBMNULL"; 1080 devinfo.usTimeOut = 45; 1085 1081 rc = SplCreateDevice( NULL, 3, &devinfo, sizeof( devinfo )); 1086 1082 if ( rc != NO_ERROR ) { … … 1102 1098 1103 1099 // Nope, create it now 1104 qinfo.pszName = pszQueueName;1105 qinfo.uPriority = PRQ_DEF_PRIORITY;1106 qinfo.fsType = PRQ3_TYPE_RAW;1107 qinfo.pszPrProc = "PMPRINT";1108 qinfo.pszComment = pszTitle;1109 qinfo.pszPrinters = pszDeviceName;1100 qinfo.pszName = pszQueueName; 1101 qinfo.uPriority = PRQ_DEF_PRIORITY; 1102 qinfo.fsType = PRQ3_TYPE_RAW; 1103 qinfo.pszPrProc = "PMPRINT"; 1104 qinfo.pszComment = pszTitle; 1105 qinfo.pszPrinters = pszDeviceName; 1110 1106 qinfo.pszDriverName = pszModel ? pszModel : "IBMNULL"; 1111 //qinfo.pDriverData = NULL;1112 1107 rc = SplCreateQueue( NULL, 3, &qinfo, sizeof( qinfo )); 1113 1108 if ( rc != NO_ERROR ) { 1114 1109 WriteErrorCode( rc, "SplCreateQueue"); 1115 1110 MAKERXSTRING( *prsResult, "0", 1 ); 1116 if ( fNewD ) ; // TODO delete device1111 if ( fNewD ) SplDeleteDevice( NULL, pszDeviceName ); 1117 1112 return ( 0 ); 1118 1113 } … … 1121 1116 WriteErrorCode( rc, "SplQueryQueue"); 1122 1117 MAKERXSTRING( *prsResult, "0", 1 ); 1123 if ( fNewD ) ; // TODO delete device1118 if ( fNewD ) SplDeleteDevice( NULL, pszDeviceName ); 1124 1119 return ( 0 ); 1125 1120 } 1126 1121 1127 /* Actually, this doesn't seem to be necessary... 1128 1129 sprintf( szSetup, "QUEUENAME=%s;TAKEDEFAULTS=YES;", pszQueueName); // TODO verify length 1130 if ( pszOID ) { 1131 strncat( szSetup, "OBJECTID=", US_SS_MAXZ-1 ); 1132 strncat( szSetup, pszOID, US_SS_MAXZ-1 ); 1133 strncat( szSetup, ";", US_SS_MAXZ-1 ); 1134 } 1135 if ( WinCreateObject("WPPrinter", pszTitle, szSetup, 1136 "<WP_DESKTOP>", CO_FAILIFEXISTS ) == NULLHANDLE ) 1137 { 1138 WriteErrorCode( 0, "WinCreateObject"); 1139 MAKERXSTRING( *prsResult, "0", 1 ); 1140 if ( fNewD ); // TODO delete device 1141 if ( fNewQ ); // TODO delete queue 1122 MAKERXSTRING( *prsResult, "1", 1 ); 1123 return ( 0 ); 1124 } 1125 1126 1127 /* ------------------------------------------------------------------------- * 1128 * RPUPrinterDelete * 1129 * * 1130 * Deletes a local printer queue and its associated print device definition. * 1131 * * 1132 * REXX ARGUMENTS: * 1133 * 1. The name of the printer queue to be deleted. (REQUIRED) * 1134 * * 1135 * REXX RETURN VALUE: * 1136 * 1 on success, or 0 if an error occurred. (1 will be returned even if * 1137 * the WPS printer object could not be deleted, so long as the queue and * 1138 * device were dstroyed successfully.) * 1139 * ------------------------------------------------------------------------- */ 1140 ULONG APIENTRY RPUPrinterDelete( PSZ pszName, ULONG argc, RXSTRING argv[], PSZ pszQueue, PRXSTRING prsResult ) 1141 { 1142 PPRQINFO3 pInfo = NULL; 1143 ULONG cbBuf = 0; 1144 PSZ pszQueueName = NULL, 1145 pszDeviceName = NULL; 1146 HOBJECT hObj; 1147 SPLERR rc; 1148 1149 1150 // Reset the error indicator 1151 WriteErrorCode( 0, NULL ); 1152 1153 // Validate the REXX arguments 1154 if (( argc != 1 ) || ( ! RXVALIDSTRING( argv[0] ))) 1155 return ( 40 ); 1156 1157 pszQueueName = argv[0].strptr; 1158 hObj = PrinterObjectHandle( pszQueueName ); 1159 1160 rc = SplQueryQueue( NULL, pszQueueName, 3, NULL, 0, &cbBuf ); 1161 if (( rc != NO_ERROR ) && ( rc != NERR_BufTooSmall )) { 1162 WriteErrorCode( rc, "SplQueryQueue"); 1163 MAKERXSTRING( *prsResult, "0", 1 ); 1142 1164 return ( 0 ); 1143 1165 } 1144 */ 1166 pInfo = (PPRQINFO3) malloc( cbBuf ); 1167 if ( !pInfo ) { 1168 WriteErrorCode( ERROR_NOT_ENOUGH_MEMORY, "malloc"); 1169 MAKERXSTRING( *prsResult, "0", 1 ); 1170 return ( 0 ); 1171 } 1172 rc = SplQueryQueue( NULL, pszQueueName, 3, pInfo, cbBuf, &cbBuf ); 1173 if ( rc != NO_ERROR ) { 1174 WriteErrorCode( rc, "SplQueryQueue"); 1175 MAKERXSTRING( *prsResult, "0", 1 ); 1176 goto cleanup; 1177 } 1178 pszDeviceName = strtok( pInfo->pszPrinters, ","); 1179 rc = SplDeleteDevice( NULL, pszDeviceName ); 1180 if ( rc != NO_ERROR ) { 1181 WriteErrorCode( rc, "SplDeleteDevice"); 1182 MAKERXSTRING( *prsResult, "0", 1 ); 1183 goto cleanup; 1184 } 1185 1186 // Try and destroy the WPS object 1187 if ( hObj != NULLHANDLE ) WinDestroyObject( hObj ); 1188 1189 MAKERXSTRING( *prsResult, "1", 1 ); 1190 cleanup: 1191 free( pInfo ); 1145 1192 return ( 0 ); 1146 1193 }
Note:
See TracChangeset
for help on using the changeset viewer.