| 673 | */ |
| 674 | |
| 675 | cups_dinfo_t * /* O - Destination information */ |
| 676 | cupsCopyDestInfo( |
| 677 | http_t *http, /* I - Connection to destination */ |
| 678 | cups_dest_t *dest) /* I - Destination */ |
| 679 | { |
| 680 | cups_dinfo_t *dinfo; /* Destination information */ |
| 681 | unsigned dflags; /* Destination flags */ |
| 682 | ipp_t *request, /* Get-Printer-Attributes request */ |
| 683 | *response; /* Supported attributes */ |
| 684 | int tries, /* Number of tries so far */ |
| 685 | delay, /* Current retry delay */ |
| 686 | prev_delay; /* Next retry delay */ |
| 687 | const char *uri; /* Printer URI */ |
| 688 | char resource[1024]; /* URI resource path */ |
| 689 | int version; /* IPP version */ |
| 690 | ipp_status_t status; /* Status of request */ |
| 691 | _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */ |
| 692 | static const char * const requested_attrs[] = |
| 693 | { /* Requested attributes */ |
| 694 | "job-template", |
| 695 | "media-col-database", |
| 696 | "printer-description" |
| 697 | }; |
| 698 | |
| 699 | |
| 700 | DEBUG_printf(("cupsCopyDestInfo(http=%p, dest=%p(%s))", (void *)http, (void *)dest, dest ? dest->name : "")); |
| 701 | |
| 702 | /* |
| 703 | * Range check input... |
| 704 | */ |
| 705 | |
| 706 | if (!dest) |
| 707 | return (NULL); |
| 708 | |
| 709 | /* |
| 710 | * Get the default connection as needed... |
| 711 | */ |
| 712 | |
| 713 | if (!http) |
| 714 | { |
| 715 | DEBUG_puts("1cupsCopyDestInfo: Default server connection."); |
| 716 | http = _cupsConnect(); |
| 717 | dflags = CUPS_DEST_FLAGS_NONE; |
| 718 | |
| 719 | if (!http) |
| 720 | return (NULL); |
| 721 | } |
| 722 | #ifdef AF_LOCAL |
| 723 | else if (httpAddrFamily(http->hostaddr) == AF_LOCAL) |
| 724 | { |
| 725 | DEBUG_puts("1cupsCopyDestInfo: Connection to server (domain socket)."); |
| 726 | dflags = CUPS_DEST_FLAGS_NONE; |
| 727 | } |
| 728 | #endif /* AF_LOCAL */ |
| 729 | else |
| 730 | { |
| 731 | // Guess the destination flags based on the printer URI's host and port... |
| 732 | char scheme[32], /* URI scheme */ |