Changeset 751 for trunk/server/source3/printing/print_cups.c
- Timestamp:
- Nov 29, 2012, 1:59:04 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/server/source3/printing/print_cups.c (modified) (36 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/source3/printing/print_cups.c
r745 r751 36 36 #endif 37 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 38 79 static SIG_ATOMIC_T gotalarm; 39 80 … … 172 213 bool ret_ok = false; 173 214 174 for (attr = response->attrs; attr != NULL;) {215 for (attr = ; attr != NULL;) { 175 216 /* 176 217 * Skip leading attributes until we hit a printer... 177 218 */ 178 219 179 while (attr != NULL && attr->group_tag!= IPP_TAG_PRINTER)180 attr = attr->next;220 while (attr != NULL && != IPP_TAG_PRINTER) 221 attr = ; 181 222 182 223 if (attr == NULL) … … 190 231 info = NULL; 191 232 192 while (attr != NULL && attr->group_tag== IPP_TAG_PRINTER) {233 while (attr != NULL && == IPP_TAG_PRINTER) { 193 234 size_t size; 194 if (strcmp( attr->name, "printer-name") == 0 &&195 attr->value_tag== IPP_TAG_NAME) {235 if (strcmp(, "printer-name") == 0 && 236 == IPP_TAG_NAME) { 196 237 if (!pull_utf8_talloc(mem_ctx, 197 238 &name, 198 attr->values[0].string.text,239 , 199 240 &size)) { 200 241 goto err_out; … … 202 243 } 203 244 204 if (strcmp( attr->name, "printer-info") == 0 &&205 attr->value_tag== IPP_TAG_TEXT) {245 if (strcmp(, "printer-info") == 0 && 246 == IPP_TAG_TEXT) { 206 247 if (!pull_utf8_talloc(mem_ctx, 207 248 &info, 208 attr->values[0].string.text,249 , 209 250 &size)) { 210 251 goto err_out; … … 212 253 } 213 254 214 if (strcmp( attr->name, "printer-location") == 0 &&215 attr->value_tag== IPP_TAG_TEXT) {255 if (strcmp(, "printer-location") == 0 && 256 == IPP_TAG_TEXT) { 216 257 if (!pull_utf8_talloc(mem_ctx, 217 258 &location, 218 attr->values[0].string.text,259 , 219 260 &size)) { 220 261 goto err_out; … … 222 263 } 223 264 224 attr = attr->next;265 attr = ; 225 266 } 226 267 … … 302 343 request = ippNew(); 303 344 304 request->request.op.operation_id = CUPS_GET_PRINTERS;305 request->request.op.request_id = 1;345 ; 346 ; 306 347 307 348 language = cupsLangDefault(); … … 344 385 request = ippNew(); 345 386 346 request->request.op.operation_id = CUPS_GET_CLASSES;347 request->request.op.request_id = 1;387 ; 388 ; 348 389 349 390 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, … … 608 649 request = ippNew(); 609 650 610 request->request.op.operation_id = IPP_CANCEL_JOB;611 request->request.op.request_id = 1;651 ; 652 ; 612 653 613 654 language = cupsLangDefault(); … … 635 676 636 677 if ((response = cupsDoRequest(http, request, "/jobs")) != NULL) { 637 if ( response->request.status.status_code>= IPP_OK_CONFLICT) {678 if ( >= IPP_OK_CONFLICT) { 638 679 DEBUG(0,("Unable to cancel job %d - %s\n", pjob->sysjob, 639 680 ippErrorString(cupsLastError()))); … … 705 746 request = ippNew(); 706 747 707 request->request.op.operation_id = IPP_HOLD_JOB;708 request->request.op.request_id = 1;748 ; 749 ; 709 750 710 751 language = cupsLangDefault(); … … 731 772 732 773 if ((response = cupsDoRequest(http, request, "/jobs")) != NULL) { 733 if ( response->request.status.status_code>= IPP_OK_CONFLICT) {774 if ( >= IPP_OK_CONFLICT) { 734 775 DEBUG(0,("Unable to hold job %d - %s\n", pjob->sysjob, 735 776 ippErrorString(cupsLastError()))); … … 801 842 request = ippNew(); 802 843 803 request->request.op.operation_id = IPP_RELEASE_JOB;804 request->request.op.request_id = 1;844 ; 845 ; 805 846 806 847 language = cupsLangDefault(); … … 827 868 828 869 if ((response = cupsDoRequest(http, request, "/jobs")) != NULL) { 829 if ( response->request.status.status_code>= IPP_OK_CONFLICT) {870 if ( >= IPP_OK_CONFLICT) { 830 871 DEBUG(0,("Unable to release job %d - %s\n", pjob->sysjob, 831 872 ippErrorString(cupsLastError()))); … … 857 898 */ 858 899 859 static int cups_job_submit(int snum, struct printjob *pjob) 900 static int cups_job_submit(int snum, struct printjob *pjob, 901 enum printing_types printing_type, 902 char *lpq_cmd) 860 903 { 861 904 TALLOC_CTX *frame = talloc_stackframe(); … … 876 919 char *filename = NULL; 877 920 size_t size; 878 uint32_t jobid = (uint32_t)-1;879 921 880 922 DEBUG(5,("cups_job_submit(%d, %p)\n", snum, pjob)); … … 907 949 request = ippNew(); 908 950 909 request->request.op.operation_id = IPP_PRINT_JOB;910 request->request.op.request_id = 1;951 ; 952 ; 911 953 912 954 language = cupsLangDefault(); … … 938 980 pjob->clientmachine); 939 981 940 /* Get the jobid from the filename. */941 jobid = print_parse_jobid(pjob->filename);942 if (jobid == (uint32_t)-1) {943 DEBUG(0,("cups_job_submit: failed to parse jobid from name %s\n",944 pjob->filename ));945 jobid = 0;946 }947 948 982 if (!push_utf8_talloc(frame, &jobname, pjob->jobname, &size)) { 949 983 goto out; … … 951 985 new_jobname = talloc_asprintf(frame, 952 986 "%s%.8u %s", PRINT_SPOOL_PREFIX, 953 (unsigned int)jobid, 954 jobname); 987 pjob->jobid, jobname); 955 988 if (new_jobname == NULL) { 956 989 goto out; … … 984 1017 } 985 1018 if ((response = cupsDoFileRequest(http, request, uri, pjob->filename)) != NULL) { 986 if ( response->request.status.status_code>= IPP_OK_CONFLICT) {1019 if ( >= IPP_OK_CONFLICT) { 987 1020 DEBUG(0,("Unable to print file to %s - %s\n", 988 1021 lp_printername(snum), … … 992 1025 attr_job_id = ippFindAttribute(response, "job-id", IPP_TAG_INTEGER); 993 1026 if(attr_job_id) { 994 pjob->sysjob = attr_job_id->values[0].integer;1027 pjob->sysjob = ; 995 1028 DEBUG(5,("cups_job_submit: job-id %d\n", pjob->sysjob)); 996 1029 } else { … … 1114 1147 request = ippNew(); 1115 1148 1116 request->request.op.operation_id = IPP_GET_JOBS;1117 request->request.op.request_id = 1;1149 ; 1150 ; 1118 1151 1119 1152 language = cupsLangDefault(); … … 1143 1176 } 1144 1177 1145 if ( response->request.status.status_code>= IPP_OK_CONFLICT) {1178 if ( >= IPP_OK_CONFLICT) { 1146 1179 DEBUG(0,("Unable to get jobs for %s - %s\n", uri, 1147 ippErrorString( response->request.status.status_code)));1180 ippErrorString())); 1148 1181 goto out; 1149 1182 } … … 1157 1190 queue = NULL; 1158 1191 1159 for (attr = response->attrs; attr != NULL; attr = attr->next) {1192 for (attr = ) { 1160 1193 /* 1161 1194 * Skip leading attributes until we hit a job... 1162 1195 */ 1163 1196 1164 while (attr != NULL && attr->group_tag!= IPP_TAG_JOB)1165 attr = attr->next;1197 while (attr != NULL && != IPP_TAG_JOB) 1198 ; 1166 1199 1167 1200 if (attr == NULL) … … 1198 1231 job_name = NULL; 1199 1232 1200 while (attr != NULL && attr->group_tag== IPP_TAG_JOB) {1201 if (attr->name== NULL) {1202 attr = attr->next;1233 while (attr != NULL && == IPP_TAG_JOB) { 1234 == NULL) { 1235 attr = ; 1203 1236 break; 1204 1237 } 1205 1238 1206 if (strcmp(attr->name, "job-id") == 0 &&1207 attr->value_tag== IPP_TAG_INTEGER)1208 job_id = attr->values[0].integer;1209 1210 if (strcmp(attr->name, "job-k-octets") == 0 &&1211 attr->value_tag== IPP_TAG_INTEGER)1212 job_k_octets = attr->values[0].integer;1213 1214 if (strcmp(attr->name, "job-priority") == 0 &&1215 attr->value_tag== IPP_TAG_INTEGER)1216 job_priority = attr->values[0].integer;1217 1218 if (strcmp(attr->name, "job-state") == 0 &&1219 attr->value_tag== IPP_TAG_ENUM)1220 job_status = (ipp_jstate_t) (attr->values[0].integer);1221 1222 if (strcmp(attr->name, "time-at-creation") == 0 &&1223 attr->value_tag== IPP_TAG_INTEGER)1224 job_time = attr->values[0].integer;1225 1226 if (strcmp(attr->name, "job-name") == 0 &&1227 attr->value_tag== IPP_TAG_NAME) {1239 , "job-id") == 0 && 1240 == IPP_TAG_INTEGER) 1241 job_id = ; 1242 1243 , "job-k-octets") == 0 && 1244 == IPP_TAG_INTEGER) 1245 job_k_octets = ; 1246 1247 , "job-priority") == 0 && 1248 == IPP_TAG_INTEGER) 1249 job_priority = ; 1250 1251 , "job-state") == 0 && 1252 == IPP_TAG_ENUM) 1253 job_status = (ipp_jstate_t)); 1254 1255 , "time-at-creation") == 0 && 1256 == IPP_TAG_INTEGER) 1257 job_time = ; 1258 1259 , "job-name") == 0 && 1260 == IPP_TAG_NAME) { 1228 1261 if (!pull_utf8_talloc(frame, 1229 1262 &job_name, 1230 attr->values[0].string.text,1263 , 1231 1264 &size)) { 1232 1265 goto out; … … 1234 1267 } 1235 1268 1236 if (strcmp(attr->name, "job-originating-user-name") == 0 &&1237 attr->value_tag== IPP_TAG_NAME) {1269 , "job-originating-user-name") == 0 && 1270 == IPP_TAG_NAME) { 1238 1271 if (!pull_utf8_talloc(frame, 1239 1272 &user_name, 1240 attr->values[0].string.text,1273 , 1241 1274 &size)) { 1242 1275 goto out; … … 1244 1277 } 1245 1278 1246 attr = attr->next;1279 ; 1247 1280 } 1248 1281 … … 1258 1291 } 1259 1292 1260 temp-> job= job_id;1293 temp-> = job_id; 1261 1294 temp->size = job_k_octets * 1024; 1262 1295 temp->status = job_status == IPP_JOB_PENDING ? LPQ_QUEUED : … … 1290 1323 request = ippNew(); 1291 1324 1292 request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES;1293 request->request.op.request_id = 1;1325 ; 1326 ; 1294 1327 1295 1328 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, … … 1317 1350 } 1318 1351 1319 if ( response->request.status.status_code>= IPP_OK_CONFLICT) {1352 if ( >= IPP_OK_CONFLICT) { 1320 1353 DEBUG(0,("Unable to get printer status for %s - %s\n", printername, 1321 ippErrorString( response->request.status.status_code)));1354 ippErrorString())); 1322 1355 goto out; 1323 1356 } … … 1328 1361 1329 1362 if ((attr = ippFindAttribute(response, "printer-state", IPP_TAG_ENUM)) != NULL) { 1330 if ( attr->values[0].integer== IPP_PRINTER_STOPPED)1363 if ( == IPP_PRINTER_STOPPED) 1331 1364 status->status = LPSTAT_STOPPED; 1332 1365 else … … 1338 1371 char *msg = NULL; 1339 1372 if (!pull_utf8_talloc(frame, &msg, 1340 attr->values[0].string.text,1373 , 1341 1374 &size)) { 1342 1375 SAFE_FREE(queue); … … 1414 1447 request = ippNew(); 1415 1448 1416 request->request.op.operation_id = IPP_PAUSE_PRINTER;1417 request->request.op.request_id = 1;1449 ; 1450 ; 1418 1451 1419 1452 language = cupsLangDefault(); … … 1445 1478 1446 1479 if ((response = cupsDoRequest(http, request, "/admin/")) != NULL) { 1447 if ( response->request.status.status_code>= IPP_OK_CONFLICT) {1480 if ( >= IPP_OK_CONFLICT) { 1448 1481 DEBUG(0,("Unable to pause printer %s - %s\n", 1449 1482 lp_printername(snum), … … 1518 1551 request = ippNew(); 1519 1552 1520 request->request.op.operation_id = IPP_RESUME_PRINTER;1521 request->request.op.request_id = 1;1553 ; 1554 ; 1522 1555 1523 1556 language = cupsLangDefault(); … … 1549 1582 1550 1583 if ((response = cupsDoRequest(http, request, "/admin/")) != NULL) { 1551 if ( response->request.status.status_code>= IPP_OK_CONFLICT) {1584 if ( >= IPP_OK_CONFLICT) { 1552 1585 DEBUG(0,("Unable to resume printer %s - %s\n", 1553 1586 lp_printername(snum),
Note:
See TracChangeset
for help on using the changeset viewer.
