Changeset 751 for trunk/server/source3/printing/print_iprint.c
- Timestamp:
- Nov 29, 2012, 1:59:04 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/source3/printing/print_iprint.c
r745 r751 35 35 #define NOVELL_SERVER_VERSION_OES_SP1 33554432 36 36 37 #if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5) 38 #define HAVE_CUPS_1_6 1 39 #endif 40 41 #ifndef HAVE_CUPS_1_6 42 #define ippGetCount(attr) attr->num_values 43 #define ippGetGroupTag(attr) attr->group_tag 44 #define ippGetName(attr) attr->name 45 #define ippGetValueTag(attr) attr->value_tag 46 #define ippGetStatusCode(ipp) ipp->request.status.status_code 47 #define ippGetBoolean(attr, element) attr->values[element].boolean 48 #define ippGetInteger(attr, element) attr->values[element].integer 49 #define ippGetString(attr, element, language) attr->values[element].string.text 50 51 static ipp_attribute_t * 52 ippFirstAttribute(ipp_t *ipp) 53 { 54 if (!ipp) 55 return (NULL); 56 return (ipp->current = ipp->attrs); 57 } 58 59 static ipp_attribute_t * 60 ippNextAttribute(ipp_t *ipp) 61 { 62 if (!ipp || !ipp->current) 63 return (NULL); 64 return (ipp->current = ipp->current->next); 65 } 66 67 static int ippSetOperation(ipp_t *ipp, ipp_op_t op) 68 { 69 ipp->request.op.operation_id = op; 70 return (1); 71 } 72 73 static int ippSetRequestId(ipp_t *ipp, int request_id) 74 { 75 ipp->request.any.request_id = request_id; 76 return (1); 77 } 78 #endif 79 37 80 /* 38 81 * 'iprint_passwd_cb()' - The iPrint password callback... … … 93 136 request = ippNew(); 94 137 95 request->request.op.operation_id = (ipp_op_t)OPERATION_NOVELL_MGMT;96 request->request.op.request_id = 1;138 ippSetOperation(request, (ipp_op_t)OPERATION_NOVELL_MGMT); 139 ippSetRequestId(request, 1); 97 140 98 141 language = cupsLangDefault(); … … 115 158 116 159 if (((response = cupsDoRequest(http, request, "/ipp/")) == NULL) || 117 ( response->request.status.status_code>= IPP_OK_CONFLICT))160 (ippGetStatusCode(response) >= IPP_OK_CONFLICT)) 118 161 goto out; 119 162 120 163 if (((attr = ippFindAttribute(response, "server-version", 121 164 IPP_TAG_STRING)) != NULL)) { 122 if ((ver = strstr( attr->values[0].string.text,165 if ((ver = strstr(ippGetString(attr, 0, NULL), 123 166 NOVELL_SERVER_VERSION_STRING)) != NULL) { 124 167 ver += strlen(NOVELL_SERVER_VERSION_STRING); … … 136 179 } 137 180 138 if ((os = strstr( attr->values[0].string.text,181 if ((os = strstr(ippGetString(attr, 0, NULL), 139 182 NOVELL_SERVER_SYSNAME)) != NULL) { 140 183 os += strlen(NOVELL_SERVER_SYSNAME); … … 185 228 request = ippNew(); 186 229 187 request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES;188 request->request.op.request_id = reqId;230 ippSetOperation(request, IPP_GET_PRINTER_ATTRIBUTES); 231 ippSetRequestId(request, reqId); 189 232 190 233 language = cupsLangDefault(); … … 231 274 } 232 275 233 for (attr = response->attrs; attr != NULL;) {276 for (attr = ippFirstAttribute(response); attr != NULL;) { 234 277 /* 235 278 * Skip leading attributes until we hit a printer... 236 279 */ 237 280 238 while (attr != NULL && attr->group_tag!= IPP_TAG_PRINTER)239 attr = attr->next;281 while (attr != NULL && ippGetGroupTag(attr) != IPP_TAG_PRINTER) 282 attr = ippNextAttribute(response); 240 283 241 284 if (attr == NULL) … … 251 294 secure = 0; 252 295 253 while (attr != NULL && attr->group_tag== IPP_TAG_PRINTER) {254 if (strcmp( attr->name, "printer-name") == 0 &&255 attr->value_tag== IPP_TAG_NAME)256 name = attr->values[0].string.text;257 258 if (strcmp( attr->name, "printer-info") == 0 &&259 ( attr->value_tag== IPP_TAG_TEXT ||260 attr->value_tag== IPP_TAG_TEXTLANG))261 info = attr->values[0].string.text;296 while (attr != NULL && ippGetGroupTag(attr) == IPP_TAG_PRINTER) { 297 if (strcmp(ippGetName(attr), "printer-name") == 0 && 298 ippGetValueTag(attr) == IPP_TAG_NAME) 299 name = ippGetString(attr, 0, NULL); 300 301 if (strcmp(ippGetName(attr), "printer-info") == 0 && 302 (ippGetValueTag(attr) == IPP_TAG_TEXT || 303 ippGetValueTag(attr) == IPP_TAG_TEXTLANG)) 304 info = ippGetString(attr, 0, NULL); 262 305 263 306 /* … … 267 310 * printer should show up 268 311 */ 269 if (!strcmp( attr->name, "smb-enabled") &&270 (( attr->value_tag== IPP_TAG_INTEGER &&271 ! attr->values[0].integer) ||272 ( attr->value_tag== IPP_TAG_BOOLEAN &&273 ! attr->values[0].boolean)))312 if (!strcmp(ippGetName(attr), "smb-enabled") && 313 ((ippGetValueTag(attr) == IPP_TAG_INTEGER && 314 !ippGetInteger(attr, 0)) || 315 (ippGetValueTag(attr) == IPP_TAG_BOOLEAN && 316 !ippGetBoolean(attr, 0)))) 274 317 smb_enabled = 0; 275 318 … … 280 323 * printer should show up 281 324 */ 282 if (!strcmp( attr->name, "security-enabled") &&283 (( attr->value_tag== IPP_TAG_INTEGER &&284 attr->values[0].integer) ||285 ( attr->value_tag== IPP_TAG_BOOLEAN &&286 attr->values[0].boolean)))325 if (!strcmp(ippGetName(attr), "security-enabled") && 326 ((ippGetValueTag(attr) == IPP_TAG_INTEGER && 327 ippGetInteger(attr, 0)) || 328 (ippGetValueTag(attr) == IPP_TAG_BOOLEAN && 329 ippGetBoolean(attr, 0)))) 287 330 secure = 1; 288 331 289 attr = attr->next;332 attr = ippNextAttribute(response); 290 333 } 291 334 … … 344 387 request = ippNew(); 345 388 346 request->request.op.operation_id = 347 (ipp_op_t)OPERATION_NOVELL_LIST_PRINTERS; 348 request->request.op.request_id = 1; 389 ippSetOperation(request, (ipp_op_t)OPERATION_NOVELL_LIST_PRINTERS); 390 ippSetRequestId(request, 1); 349 391 350 392 language = cupsLangDefault(); … … 369 411 } 370 412 371 for (attr = response->attrs; attr != NULL;) {413 for (attr = ippFirstAttribute(response); attr != NULL;) { 372 414 /* 373 415 * Skip leading attributes until we hit a printer... 374 416 */ 375 417 376 while (attr != NULL && attr->group_tag!= IPP_TAG_PRINTER)377 attr = attr->next;418 while (attr != NULL && ippGetGroupTag(attr) != IPP_TAG_PRINTER) 419 attr = ippNextAttribute(response); 378 420 379 421 if (attr == NULL) … … 384 426 */ 385 427 386 while (attr != NULL && attr->group_tag== IPP_TAG_PRINTER)428 while (attr != NULL && ippGetGroupTag(attr) == IPP_TAG_PRINTER) 387 429 { 388 if (strcmp( attr->name, "printer-name") == 0 &&389 ( attr->value_tag== IPP_TAG_URI ||390 attr->value_tag== IPP_TAG_NAME ||391 attr->value_tag== IPP_TAG_TEXT ||392 attr->value_tag== IPP_TAG_NAMELANG ||393 attr->value_tag== IPP_TAG_TEXTLANG))430 if (strcmp(ippGetName(attr), "printer-name") == 0 && 431 (ippGetValueTag(attr) == IPP_TAG_URI || 432 ippGetValueTag(attr) == IPP_TAG_NAME || 433 ippGetValueTag(attr) == IPP_TAG_TEXT || 434 ippGetValueTag(attr) == IPP_TAG_NAMELANG || 435 ippGetValueTag(attr) == IPP_TAG_TEXTLANG)) 394 436 { 395 for (i = 0; i< attr->num_values; i++)437 for (i = 0; i<ippGetCount(attr); i++) 396 438 { 397 char *url = attr->values[i].string.text;439 char *url = ippGetString(attr, i, NULL); 398 440 if (!url || !strlen(url)) 399 441 continue; … … 401 443 } 402 444 } 403 attr = attr->next;445 attr = ippNextAttribute(response); 404 446 } 405 447 } … … 467 509 request = ippNew(); 468 510 469 request->request.op.operation_id = IPP_CANCEL_JOB;470 request->request.op.request_id = 1;511 ippSetOperation(request, IPP_CANCEL_JOB); 512 ippSetRequestId(request, 1); 471 513 472 514 language = cupsLangDefault(); … … 494 536 495 537 if ((response = cupsDoRequest(http, request, httpPath)) != NULL) { 496 if ( response->request.status.status_code>= IPP_OK_CONFLICT) {538 if (ippGetStatusCode(response) >= IPP_OK_CONFLICT) { 497 539 DEBUG(0,("Unable to cancel job %d - %s\n", pjob->sysjob, 498 540 ippErrorString(cupsLastError()))); … … 565 607 request = ippNew(); 566 608 567 request->request.op.operation_id = IPP_HOLD_JOB;568 request->request.op.request_id = 1;609 ippSetOperation(request, IPP_HOLD_JOB); 610 ippSetRequestId(request, 1); 569 611 570 612 language = cupsLangDefault(); … … 594 636 595 637 if ((response = cupsDoRequest(http, request, httpPath)) != NULL) { 596 if ( response->request.status.status_code>= IPP_OK_CONFLICT) {638 if (ippGetStatusCode(response) >= IPP_OK_CONFLICT) { 597 639 DEBUG(0,("Unable to hold job %d - %s\n", pjob->sysjob, 598 640 ippErrorString(cupsLastError()))); … … 665 707 request = ippNew(); 666 708 667 request->request.op.operation_id = IPP_RELEASE_JOB;668 request->request.op.request_id = 1;709 ippSetOperation(request, IPP_RELEASE_JOB); 710 ippSetRequestId(request, 1); 669 711 670 712 language = cupsLangDefault(); … … 694 736 695 737 if ((response = cupsDoRequest(http, request, httpPath)) != NULL) { 696 if ( response->request.status.status_code>= IPP_OK_CONFLICT) {738 if (ippGetStatusCode(response) >= IPP_OK_CONFLICT) { 697 739 DEBUG(0,("Unable to release job %d - %s\n", pjob->sysjob, 698 740 ippErrorString(cupsLastError()))); … … 723 765 */ 724 766 725 static int iprint_job_submit(int snum, struct printjob *pjob) 767 static int iprint_job_submit(int snum, struct printjob *pjob, 768 enum printing_types printing_type, 769 char *lpq_cmd) 726 770 { 727 771 int ret = 1; /* Return value */ … … 764 808 request = ippNew(); 765 809 766 request->request.op.operation_id = IPP_PRINT_JOB;767 request->request.op.request_id = 1;810 ippSetOperation(request, IPP_PRINT_JOB); 811 ippSetRequestId(request, 1); 768 812 769 813 language = cupsLangDefault(); … … 798 842 799 843 if ((response = cupsDoFileRequest(http, request, uri, pjob->filename)) != NULL) { 800 if ( response->request.status.status_code>= IPP_OK_CONFLICT) {844 if (ippGetStatusCode(response) >= IPP_OK_CONFLICT) { 801 845 DEBUG(0,("Unable to print file to %s - %s\n", 802 846 lp_printername(snum), … … 818 862 819 863 attr = ippFindAttribute(response, "job-id", IPP_TAG_INTEGER); 820 if (attr != NULL && attr->group_tag== IPP_TAG_JOB)864 if (attr != NULL && ippGetGroupTag(attr) == IPP_TAG_JOB) 821 865 { 822 pjob->sysjob = attr->values[0].integer;866 pjob->sysjob = ippGetInteger(attr, 0); 823 867 } 824 868 } … … 867 911 int job_k_octets; /* job-k-octets attribute */ 868 912 time_t job_time; /* time-at-creation attribute */ 869 time_t printer_current_time = 0; /* printer's current time */870 913 time_t printer_up_time = 0; /* printer's uptime */ 871 914 ipp_jstate_t job_status; /* job-status attribute */ … … 940 983 request = ippNew(); 941 984 942 request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES;943 request->request.op.request_id = 2;985 ippSetOperation(request, IPP_GET_PRINTER_ATTRIBUTES); 986 ippSetRequestId(request, 2); 944 987 945 988 language = cupsLangDefault(); … … 972 1015 } 973 1016 974 if ( response->request.status.status_code>= IPP_OK_CONFLICT) {1017 if (ippGetStatusCode(response) >= IPP_OK_CONFLICT) { 975 1018 DEBUG(0,("Unable to get printer status for %s - %s\n", printername, 976 ippErrorString( response->request.status.status_code)));1019 ippErrorString(ippGetStatusCode(response)))); 977 1020 *q = queue; 978 1021 goto out; … … 984 1027 985 1028 if ((attr = ippFindAttribute(response, "printer-state", IPP_TAG_ENUM)) != NULL) { 986 if ( attr->values[0].integer== IPP_PRINTER_STOPPED)1029 if (ippGetInteger(attr, 0) == IPP_PRINTER_STOPPED) 987 1030 status->status = LPSTAT_STOPPED; 988 1031 else … … 992 1035 if ((attr = ippFindAttribute(response, "printer-state-message", 993 1036 IPP_TAG_TEXT)) != NULL) 994 fstrcpy(status->message, attr->values[0].string.text); 995 996 if ((attr = ippFindAttribute(response, "printer-current-time", 997 IPP_TAG_DATE)) != NULL) 998 printer_current_time = ippDateToTime(attr->values[0].date); 1037 fstrcpy(status->message, ippGetString(attr, 0, NULL)); 999 1038 1000 1039 if ((attr = ippFindAttribute(response, "printer-up-time", 1001 1040 IPP_TAG_INTEGER)) != NULL) 1002 printer_up_time = attr->values[0].integer;1041 printer_up_time = ippGetInteger(attr, 0); 1003 1042 1004 1043 ippDelete(response); … … 1017 1056 request = ippNew(); 1018 1057 1019 request->request.op.operation_id = IPP_GET_JOBS;1020 request->request.op.request_id = 3;1058 ippSetOperation(request, IPP_GET_JOBS); 1059 ippSetRequestId(request, 3); 1021 1060 1022 1061 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET, … … 1046 1085 } 1047 1086 1048 if ( response->request.status.status_code>= IPP_OK_CONFLICT) {1087 if (ippGetStatusCode(response) >= IPP_OK_CONFLICT) { 1049 1088 DEBUG(0,("Unable to get jobs for %s - %s\n", uri, 1050 ippErrorString( response->request.status.status_code)));1089 ippErrorString(ippGetStatusCode(response)))); 1051 1090 goto out; 1052 1091 } … … 1060 1099 queue = NULL; 1061 1100 1062 for (attr = response->attrs; attr != NULL; attr = attr->next) {1101 for (attr = ippFirstAttribute(response); attr != NULL; attr = ippNextAttribute(response)) { 1063 1102 /* 1064 1103 * Skip leading attributes until we hit a job... 1065 1104 */ 1066 1105 1067 while (attr != NULL && attr->group_tag!= IPP_TAG_JOB)1068 attr = attr->next;1106 while (attr != NULL && ippGetGroupTag(attr) != IPP_TAG_JOB) 1107 attr = ippNextAttribute(response); 1069 1108 1070 1109 if (attr == NULL) … … 1101 1140 job_name = NULL; 1102 1141 1103 while (attr != NULL && attr->group_tag== IPP_TAG_JOB) {1104 if ( attr->name== NULL) {1105 attr = attr->next;1142 while (attr != NULL && ippGetGroupTag(attr) == IPP_TAG_JOB) { 1143 if (ippGetName(attr) == NULL) { 1144 attr = ippNextAttribute(response); 1106 1145 break; 1107 1146 } 1108 1147 1109 if (strcmp( attr->name, "job-id") == 0 &&1110 attr->value_tag== IPP_TAG_INTEGER)1111 job_id = attr->values[0].integer;1112 1113 if (strcmp( attr->name, "job-k-octets") == 0 &&1114 attr->value_tag== IPP_TAG_INTEGER)1115 job_k_octets = attr->values[0].integer;1116 1117 if (strcmp( attr->name, "job-priority") == 0 &&1118 attr->value_tag== IPP_TAG_INTEGER)1119 job_priority = attr->values[0].integer;1120 1121 if (strcmp( attr->name, "job-state") == 0 &&1122 attr->value_tag== IPP_TAG_ENUM)1123 job_status = (ipp_jstate_t) (attr->values[0].integer);1124 1125 if (strcmp( attr->name, "time-at-creation") == 0 &&1126 attr->value_tag== IPP_TAG_INTEGER)1148 if (strcmp(ippGetName(attr), "job-id") == 0 && 1149 ippGetValueTag(attr) == IPP_TAG_INTEGER) 1150 job_id = ippGetInteger(attr, 0); 1151 1152 if (strcmp(ippGetName(attr), "job-k-octets") == 0 && 1153 ippGetValueTag(attr) == IPP_TAG_INTEGER) 1154 job_k_octets = ippGetInteger(attr, 0); 1155 1156 if (strcmp(ippGetName(attr), "job-priority") == 0 && 1157 ippGetValueTag(attr) == IPP_TAG_INTEGER) 1158 job_priority = ippGetInteger(attr, 0); 1159 1160 if (strcmp(ippGetName(attr), "job-state") == 0 && 1161 ippGetValueTag(attr) == IPP_TAG_ENUM) 1162 job_status = (ipp_jstate_t)ippGetInteger(attr, 0); 1163 1164 if (strcmp(ippGetName(attr), "time-at-creation") == 0 && 1165 ippGetValueTag(attr) == IPP_TAG_INTEGER) 1127 1166 { 1128 1167 /* … … 1134 1173 1135 1174 if (jobUseUnixTime) 1136 job_time = attr->values[0].integer;1175 job_time = ippGetInteger(attr, 0); 1137 1176 else 1138 job_time = time(NULL) - printer_up_time + attr->values[0].integer;1177 job_time = time(NULL) - printer_up_time + ippGetInteger(attr, 0); 1139 1178 } 1140 1179 1141 if (strcmp( attr->name, "job-name") == 0 &&1142 ( attr->value_tag== IPP_TAG_NAMELANG ||1143 attr->value_tag== IPP_TAG_NAME))1144 job_name = attr->values[0].string.text;1145 1146 if (strcmp( attr->name, "job-originating-user-name") == 0 &&1147 ( attr->value_tag== IPP_TAG_NAMELANG ||1148 attr->value_tag== IPP_TAG_NAME))1149 user_name = attr->values[0].string.text;1150 1151 attr = attr->next;1180 if (strcmp(ippGetName(attr), "job-name") == 0 && 1181 (ippGetValueTag(attr) == IPP_TAG_NAMELANG || 1182 ippGetValueTag(attr) == IPP_TAG_NAME)) 1183 job_name = ippGetString(attr, 0, NULL); 1184 1185 if (strcmp(ippGetName(attr), "job-originating-user-name") == 0 && 1186 (ippGetValueTag(attr) == IPP_TAG_NAMELANG || 1187 ippGetValueTag(attr) == IPP_TAG_NAME)) 1188 user_name = ippGetString(attr, 0, NULL); 1189 1190 attr = ippNextAttribute(response); 1152 1191 } 1153 1192 … … 1163 1202 } 1164 1203 1165 temp-> job= job_id;1204 temp->sysjob = job_id; 1166 1205 temp->size = job_k_octets * 1024; 1167 1206 temp->status = job_status == IPP_JOB_PENDING ? LPQ_QUEUED :
Note:
See TracChangeset
for help on using the changeset viewer.