Lines 43-49
short GetIPCData(LPIPCU pipc, char *sname)
Link Here
|
43 |
struct sockaddr_un sun; |
43 |
struct sockaddr_un sun; |
44 |
int s, c; |
44 |
int s, c; |
45 |
char buf[128]; |
45 |
char buf[128]; |
46 |
size_t adrlen; |
46 |
socklen_t adrlen; |
47 |
short ret = RET_ERROR; |
47 |
short ret = RET_ERROR; |
48 |
|
48 |
|
49 |
if ((s = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) |
49 |
if ((s = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) |
Lines 214-221
Link Here
|
214 |
else { |
215 |
else { |
215 |
pRequest = ippNew(); |
216 |
pRequest = ippNew(); |
216 |
|
217 |
|
217 |
pRequest->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES; |
218 |
ippSetOperation(pRequest, IPP_GET_PRINTER_ATTRIBUTES); |
218 |
pRequest->request.op.request_id = 1; |
219 |
ippSetRequestId(pRequest, 1); |
219 |
|
220 |
|
220 |
pLanguage = bjcupsLangDefault(); // cupsLangDefault() -> bjcupsLangDefault() for cups-1.1.19 |
221 |
pLanguage = bjcupsLangDefault(); // cupsLangDefault() -> bjcupsLangDefault() for cups-1.1.19 |
221 |
|
222 |
|
Lines 224-235
Link Here
|
224 |
ippAddString(pRequest, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, pURI); |
225 |
ippAddString(pRequest, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, pURI); |
225 |
|
226 |
|
226 |
if ((pResponse = cupsDoRequest(pHTTP, pRequest, "/")) != NULL) { |
227 |
if ((pResponse = cupsDoRequest(pHTTP, pRequest, "/")) != NULL) { |
227 |
if (pResponse->request.status.status_code > IPP_OK_CONFLICT) { |
228 |
if (ippGetStatusCode(pResponse) > IPP_OK_CONFLICT) { |
228 |
retVal = ID_ERR_CUPS_API_FAILED; |
229 |
retVal = ID_ERR_CUPS_API_FAILED; |
229 |
} |
230 |
} |
230 |
else { |
231 |
else { |
231 |
if ((pAttribute = ippFindAttribute(pResponse, "printer-state", IPP_TAG_ENUM)) != NULL) { |
232 |
if ((pAttribute = ippFindAttribute(pResponse, "printer-state", IPP_TAG_ENUM)) != NULL) { |
232 |
printerState = (ipp_state_t)pAttribute->values[0].integer; |
233 |
printerState = ippGetInteger(pAttribute, 0); |
233 |
} |
234 |
} |
234 |
} |
235 |
} |
235 |
|
236 |
|
Lines 287-294
Link Here
|
287 |
else { |
288 |
else { |
288 |
pRequest = ippNew(); |
289 |
pRequest = ippNew(); |
289 |
|
290 |
|
290 |
pRequest->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES; |
291 |
ippSetOperation(pRequest, IPP_GET_PRINTER_ATTRIBUTES); |
291 |
pRequest->request.op.request_id = 1; |
292 |
ippSetRequestId(pRequest, 1); |
292 |
|
293 |
|
293 |
pLanguage = bjcupsLangDefault(); // cupsLangDefault() -> bjcupsLangDefault() for cups-1.1.19 |
294 |
pLanguage = bjcupsLangDefault(); // cupsLangDefault() -> bjcupsLangDefault() for cups-1.1.19 |
294 |
|
295 |
|
Lines 297-303
Link Here
|
297 |
ippAddString(pRequest, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, printerURI); |
298 |
ippAddString(pRequest, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, printerURI); |
298 |
|
299 |
|
299 |
if ((pResponse = cupsDoRequest(pHTTP, pRequest, "/")) != NULL) { |
300 |
if ((pResponse = cupsDoRequest(pHTTP, pRequest, "/")) != NULL) { |
300 |
if (pResponse->request.status.status_code > IPP_OK_CONFLICT) { |
301 |
if (ippGetStatusCode(pResponse) > IPP_OK_CONFLICT) { |
301 |
retVal = ID_ERR_CUPS_API_FAILED; |
302 |
retVal = ID_ERR_CUPS_API_FAILED; |
302 |
} |
303 |
} |
303 |
else { |
304 |
else { |
Lines 309-315
Link Here
|
309 |
//} |
310 |
//} |
310 |
pAttribute = ippFindAttribute(pResponse, "printer-state-message", IPP_TAG_TEXT); |
311 |
pAttribute = ippFindAttribute(pResponse, "printer-state-message", IPP_TAG_TEXT); |
311 |
if (pAttribute != NULL) { |
312 |
if (pAttribute != NULL) { |
312 |
strncpy(pStatus, pAttribute->values[0].string.text, bufSize); |
313 |
strncpy(pStatus, ippGetString(pAttribute, 0, NULL), bufSize); |
313 |
} |
314 |
} |
314 |
} |
315 |
} |
315 |
ippDelete(pResponse); |
316 |
ippDelete(pResponse); |
Lines 368-375
Link Here
|
368 |
else { |
369 |
else { |
369 |
pRequest = ippNew(); |
370 |
pRequest = ippNew(); |
370 |
|
371 |
|
371 |
pRequest->request.op.operation_id = IPP_CANCEL_JOB; |
372 |
ippSetOperation(pRequest, IPP_CANCEL_JOB); |
372 |
pRequest->request.op.request_id = 1; |
373 |
ippSetRequestId(pRequest, 1); |
373 |
|
374 |
|
374 |
pLanguage = bjcupsLangDefault(); // cupsLangDefault() -> bjcupsLangDefault() for cups-1.1.19 |
375 |
pLanguage = bjcupsLangDefault(); // cupsLangDefault() -> bjcupsLangDefault() for cups-1.1.19 |
375 |
|
376 |
|
Lines 380-386
Link Here
|
380 |
ippAddString(pRequest, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser()); |
381 |
ippAddString(pRequest, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser()); |
381 |
|
382 |
|
382 |
if ((pResponse = cupsDoRequest(pHTTP, pRequest, "/jobs/")) != NULL) { |
383 |
if ((pResponse = cupsDoRequest(pHTTP, pRequest, "/jobs/")) != NULL) { |
383 |
if (pResponse->request.status.status_code > IPP_OK_CONFLICT) { |
384 |
if (ippGetStatusCode(pResponse) > IPP_OK_CONFLICT) { |
384 |
retVal = ID_ERR_CUPS_API_FAILED; |
385 |
retVal = ID_ERR_CUPS_API_FAILED; |
385 |
} |
386 |
} |
386 |
ippDelete(pResponse); |
387 |
ippDelete(pResponse); |
Lines 443-450
Link Here
|
443 |
else { |
444 |
else { |
444 |
pRequest = ippNew(); |
445 |
pRequest = ippNew(); |
445 |
|
446 |
|
446 |
pRequest->request.op.operation_id = IPP_GET_JOBS; |
447 |
ippSetOperation(pRequest, IPP_GET_JOBS); |
447 |
pRequest->request.op.request_id = 1; |
448 |
ippSetRequestId(pRequest, 1); |
448 |
|
449 |
|
449 |
pLanguage = bjcupsLangDefault(); // cupsLangDefault() -> bjcupsLangDefault() for cups-1.1.19 |
450 |
pLanguage = bjcupsLangDefault(); // cupsLangDefault() -> bjcupsLangDefault() for cups-1.1.19 |
450 |
|
451 |
|
Lines 455-485
Link Here
|
455 |
ippAddStrings(pRequest, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes",(int)(sizeof(jobattrs) / sizeof(jobattrs[0])), NULL, jobattrs); |
456 |
ippAddStrings(pRequest, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes",(int)(sizeof(jobattrs) / sizeof(jobattrs[0])), NULL, jobattrs); |
456 |
|
457 |
|
457 |
if ((pResponse = cupsDoRequest(pHTTP, pRequest, "/")) != NULL) { |
458 |
if ((pResponse = cupsDoRequest(pHTTP, pRequest, "/")) != NULL) { |
458 |
if (pResponse->request.status.status_code > IPP_OK_CONFLICT) { |
459 |
if (ippGetStatusCode(pResponse) > IPP_OK_CONFLICT) { |
459 |
retVal = ID_ERR_CUPS_API_FAILED; |
460 |
retVal = ID_ERR_CUPS_API_FAILED; |
460 |
} |
461 |
} |
461 |
else { |
462 |
else { |
462 |
pAttribute = pResponse->attrs; |
463 |
pAttribute = ippFirstAttribute(pResponse); |
463 |
|
464 |
|
464 |
while (pAttribute != NULL) { |
465 |
while (pAttribute != NULL) { |
465 |
while (pAttribute != NULL && pAttribute->group_tag != IPP_TAG_JOB) { |
466 |
while (pAttribute != NULL && ippGetGroupTag(pAttribute) != IPP_TAG_PRINTER) { |
466 |
pAttribute = pAttribute->next; |
467 |
pAttribute = ippNextAttribute(pResponse); |
467 |
} |
468 |
} |
468 |
if (pAttribute == NULL) { |
469 |
if (pAttribute == NULL) { |
469 |
break; |
470 |
break; |
470 |
} |
471 |
} |
471 |
|
472 |
|
472 |
while (pAttribute != NULL && pAttribute->group_tag == IPP_TAG_JOB) { |
473 |
while (pAttribute != NULL && ippGetGroupTag(pAttribute) == IPP_TAG_JOB) { |
473 |
if (strcmp(pAttribute->name, "job-id") == 0 && pAttribute->value_tag == IPP_TAG_INTEGER) { |
474 |
if (strcmp(ippGetName(pAttribute), "job-id") == 0 && ippGetValueTag(pAttribute) == IPP_TAG_INTEGER) { |
474 |
jobID = pAttribute->values[0].integer; |
475 |
jobID = ippGetInteger(pAttribute, 0); |
475 |
} |
476 |
} |
476 |
if (strcmp(pAttribute->name, "job-state") == 0 && pAttribute->value_tag == IPP_TAG_ENUM) { |
477 |
if (strcmp(ippGetName(pAttribute), "job-state") == 0 && ippGetValueTag(pAttribute) == IPP_TAG_ENUM) { |
477 |
jobState = (ipp_jstate_t)pAttribute->values[0].integer; |
478 |
jobState = (ipp_jstate_t)ippGetInteger(pAttribute, 0); |
478 |
} |
479 |
} |
479 |
if (strcmp(pAttribute->name, "job-originating-user-name") == 0 && pAttribute->value_tag == IPP_TAG_NAME) { |
480 |
if (strcmp(ippGetName(pAttribute), "job-originating-user-name") == 0 && ippGetValueTag(pAttribute) == IPP_TAG_NAME) { |
480 |
pJobUserName = pAttribute->values[0].string.text; |
481 |
pJobUserName = ippGetString(pAttribute, 0, NULL); |
481 |
} |
482 |
} |
482 |
pAttribute = pAttribute->next; |
483 |
pAttribute = ippNextAttribute(pResponse); |
483 |
} |
484 |
} |
484 |
if (jobState == IPP_JOB_PROCESSING) { |
485 |
if (jobState == IPP_JOB_PROCESSING) { |
485 |
if (pJobUserName != NULL) { |
486 |
if (pJobUserName != NULL) { |
Lines 496-502
Link Here
|
496 |
} |
497 |
} |
497 |
|
498 |
|
498 |
if (pAttribute != NULL) |
499 |
if (pAttribute != NULL) |
499 |
pAttribute = pAttribute->next; |
500 |
pAttribute = ippNextAttribute(pResponse); |
500 |
} |
501 |
} |
501 |
} |
502 |
} |
502 |
|
503 |
|
Lines 554-561
Link Here
|
554 |
else { |
555 |
else { |
555 |
pRequest = ippNew(); |
556 |
pRequest = ippNew(); |
556 |
|
557 |
|
557 |
pRequest->request.op.operation_id = CUPS_GET_PRINTERS; |
558 |
ippSetOperation(pRequest, CUPS_GET_PRINTERS); |
558 |
pRequest->request.op.request_id = 1; |
559 |
ippSetRequestId(pRequest, 1); |
559 |
|
560 |
|
560 |
pLanguage = bjcupsLangDefault(); // cupsLangDefault() -> bjcupsLangDefault() for cups-1.1.19 |
561 |
pLanguage = bjcupsLangDefault(); // cupsLangDefault() -> bjcupsLangDefault() for cups-1.1.19 |
561 |
|
562 |
|
Lines 564-591
Link Here
|
564 |
ippAddStrings(pRequest, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", sizeof(attributes) / sizeof(attributes[0]), NULL, attributes); |
565 |
ippAddStrings(pRequest, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", sizeof(attributes) / sizeof(attributes[0]), NULL, attributes); |
565 |
|
566 |
|
566 |
if ((pResponse = cupsDoRequest(pHTTP, pRequest, "/")) != NULL) { |
567 |
if ((pResponse = cupsDoRequest(pHTTP, pRequest, "/")) != NULL) { |
567 |
if (pResponse->request.status.status_code > IPP_OK_CONFLICT) { |
568 |
if (ippGetStatusCode(pResponse) > IPP_OK_CONFLICT) { |
568 |
retVal = ID_ERR_CUPS_API_FAILED; |
569 |
retVal = ID_ERR_CUPS_API_FAILED; |
569 |
} |
570 |
} |
570 |
else { |
571 |
else { |
571 |
pAttribute = pResponse->attrs; |
572 |
pAttribute = ippFirstAttribute(pResponse); |
572 |
|
573 |
|
573 |
while (pAttribute != NULL) { |
574 |
while (pAttribute != NULL) { |
574 |
while (pAttribute != NULL && pAttribute->group_tag != IPP_TAG_PRINTER) { |
575 |
while (pAttribute != NULL && ippGetGroupTag(pAttribute) != IPP_TAG_PRINTER) { |
575 |
pAttribute = pAttribute->next; |
576 |
pAttribute = ippNextAttribute(pResponse); |
576 |
} |
577 |
} |
577 |
if (pAttribute == NULL) { |
578 |
if (pAttribute == NULL) { |
578 |
break; |
579 |
break; |
579 |
} |
580 |
} |
580 |
|
581 |
|
581 |
while (pAttribute != NULL && pAttribute->group_tag == IPP_TAG_PRINTER) { |
582 |
while (pAttribute != NULL && ippGetGroupTag(pAttribute) == IPP_TAG_PRINTER) { |
582 |
if (strcmp(pAttribute->name, "printer-name") == 0 && pAttribute->value_tag == IPP_TAG_NAME) { |
583 |
if (strcmp(ippGetName(pAttribute), "printer-name") == 0 && ippGetValueTag(pAttribute) == IPP_TAG_NAME) { |
583 |
pPrinter = pAttribute->values[0].string.text; |
584 |
pPrinter = ippGetString(pAttribute, 0, NULL); |
584 |
} |
585 |
} |
585 |
if (strcmp(pAttribute->name, "printer-uri-supported") == 0 && pAttribute->value_tag == IPP_TAG_URI) { |
586 |
if (strcmp(ippGetName(pAttribute), "device-uri") == 0 && ippGetValueTag(pAttribute) == IPP_TAG_URI) { |
586 |
pUri = pAttribute->values[0].string.text; |
587 |
pURI = ippGetString(pAttribute, 0, NULL); |
587 |
} |
588 |
} |
588 |
pAttribute = pAttribute->next; |
589 |
pAttribute = ippNextAttribute(pResponse); |
589 |
} |
590 |
} |
590 |
|
591 |
|
591 |
// Tora 020418: Compare two printer names ignoring the character case. |
592 |
// Tora 020418: Compare two printer names ignoring the character case. |
Lines 602-608
Link Here
|
602 |
} |
603 |
} |
603 |
|
604 |
|
604 |
if (pAttribute != NULL) |
605 |
if (pAttribute != NULL) |
605 |
pAttribute = pAttribute->next; |
606 |
pAttribute = ippNextAttribute(pResponse); |
606 |
} |
607 |
} |
607 |
} |
608 |
} |
608 |
|
609 |
|
Lines 657-664
Link Here
|
657 |
else { |
658 |
else { |
658 |
pRequest = ippNew(); |
659 |
pRequest = ippNew(); |
659 |
|
660 |
|
660 |
pRequest->request.op.operation_id = CUPS_GET_PRINTERS; |
661 |
ippSetOperation(pRequest, CUPS_GET_PRINTERS); |
661 |
pRequest->request.op.request_id = 1; |
662 |
ippSetRequestId(pRequest, 1); |
662 |
|
663 |
|
663 |
pLanguage = bjcupsLangDefault(); // cupsLangDefault() -> bjcupsLangDefault() for cups-1.1.19 |
664 |
pLanguage = bjcupsLangDefault(); // cupsLangDefault() -> bjcupsLangDefault() for cups-1.1.19 |
664 |
|
665 |
|
Lines 667-694
Link Here
|
667 |
ippAddString(pRequest, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, NULL); |
668 |
ippAddString(pRequest, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, NULL); |
668 |
|
669 |
|
669 |
if ((pResponse = cupsDoRequest(pHTTP, pRequest, "/")) != NULL) { |
670 |
if ((pResponse = cupsDoRequest(pHTTP, pRequest, "/")) != NULL) { |
670 |
if (pResponse->request.status.status_code > IPP_OK_CONFLICT) { |
671 |
if (ippGetStatusCode(pResponse) > IPP_OK_CONFLICT) { |
671 |
retVal = ID_ERR_CUPS_API_FAILED; |
672 |
retVal = ID_ERR_CUPS_API_FAILED; |
672 |
} |
673 |
} |
673 |
else { |
674 |
else { |
674 |
pAttribute = pResponse->attrs; |
675 |
pAttribute = ippFirstAttribute(pResponse); |
675 |
|
676 |
|
676 |
while (pAttribute != NULL) { |
677 |
while (pAttribute != NULL) { |
677 |
while (pAttribute != NULL && pAttribute->group_tag != IPP_TAG_PRINTER) { |
678 |
while (pAttribute != NULL && ippGetGroupTag(pAttribute) != IPP_TAG_PRINTER) { |
678 |
pAttribute = pAttribute->next; |
679 |
pAttribute = ippNextAttribute(pResponse); |
679 |
} |
680 |
} |
680 |
if (pAttribute == NULL) { |
681 |
if (pAttribute == NULL) { |
681 |
break; |
682 |
break; |
682 |
} |
683 |
} |
683 |
|
684 |
|
684 |
while (pAttribute != NULL && pAttribute->group_tag == IPP_TAG_PRINTER) { |
685 |
while (pAttribute != NULL && ippGetGroupTag(pAttribute) == IPP_TAG_PRINTER) { |
685 |
if (strcmp(pAttribute->name, "printer-name") == 0 && pAttribute->value_tag == IPP_TAG_NAME) { |
686 |
if (strcmp(ippGetName(pAttribute), "printer-name") == 0 && ippGetValueTag(pAttribute) == IPP_TAG_NAME) { |
686 |
pPrinter = pAttribute->values[0].string.text; |
687 |
pPrinter = ippGetString(pAttribute, 0, NULL); |
687 |
} |
688 |
} |
688 |
if (strcmp(pAttribute->name, "device-uri") == 0 && pAttribute->value_tag == IPP_TAG_URI) { |
689 |
if (strcmp(ippGetName(pAttribute), "device-uri") == 0 && ippGetValueTag(pAttribute) == IPP_TAG_URI) { |
689 |
pDUri = pAttribute->values[0].string.text; |
690 |
pDUri = ippGetString(pAttribute, 0, NULL); |
690 |
} |
691 |
} |
691 |
pAttribute = pAttribute->next; |
692 |
pAttribute = ippNextAttribute(pResponse); |
692 |
} |
693 |
} |
693 |
|
694 |
|
694 |
if (strcasecmp(pDestName, pPrinter) == 0) { |
695 |
if (strcasecmp(pDestName, pPrinter) == 0) { |
Lines 697-703
Link Here
|
697 |
} |
698 |
} |
698 |
|
699 |
|
699 |
if (pAttribute != NULL) |
700 |
if (pAttribute != NULL) |
700 |
pAttribute = pAttribute->next; |
701 |
pAttribute = ippNextAttribute(pResponse); |
701 |
} |
702 |
} |
702 |
} |
703 |
} |
703 |
|
704 |
|