| 2037 | */ |
| 2038 | |
| 2039 | int /* O - 0 on success, -1 on error */ |
| 2040 | cupsSetDests2(http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */ |
| 2041 | int num_dests, /* I - Number of destinations */ |
| 2042 | cups_dest_t *dests) /* I - Destinations */ |
| 2043 | { |
| 2044 | int i, j; /* Looping vars */ |
| 2045 | int wrote; /* Wrote definition? */ |
| 2046 | cups_dest_t *dest; /* Current destination */ |
| 2047 | cups_option_t *option; /* Current option */ |
| 2048 | _ipp_option_t *match; /* Matching attribute for option */ |
| 2049 | FILE *fp; /* File pointer */ |
| 2050 | char filename[1024]; /* lpoptions file */ |
| 2051 | int num_temps; /* Number of temporary destinations */ |
| 2052 | cups_dest_t *temps = NULL, /* Temporary destinations */ |
| 2053 | *temp; /* Current temporary dest */ |
| 2054 | const char *val; /* Value of temporary option */ |
| 2055 | _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */ |
| 2056 | |
| 2057 | |
| 2058 | /* |
| 2059 | * Range check the input... |
| 2060 | */ |
| 2061 | |
| 2062 | if (!num_dests || !dests) |
| 2063 | return (-1); |
| 2064 | |
| 2065 | /* |
| 2066 | * See if the default destination has a printer URI associated with it... |
| 2067 | */ |
| 2068 | |
| 2069 | if ((dest = cupsGetDest(/*name*/NULL, /*instance*/NULL, num_dests, dests)) != NULL && !cupsGetOption("printer-uri-supported", dest->num_options, dest->options)) |
| 2070 | { |
| 2071 | /* |
| 2072 | * No, try adding it... |
| 2073 | */ |
| 2074 | |
| 2075 | const char *uri; /* Device/printer URI */ |
| 2076 | |
| 2077 | if ((uri = cupsGetOption("device-uri", dest->num_options, dest->options)) != NULL) |
| 2078 | { |
| 2079 | char tempresource[1024]; /* Temporary resource path */ |
| 2080 | |
| 2081 | #ifdef HAVE_DNSSD |
| 2082 | if (strstr(uri, "._tcp")) |
| 2083 | uri = cups_dnssd_resolve(dest, uri, /*msec*/30000, /*cancel*/NULL, /*cb*/NULL, /*user_data*/NULL); |
| 2084 | #endif /* HAVE_DNSSD */ |
| 2085 | |
| 2086 | if (uri) |
| 2087 | uri = _cupsCreateDest(dest->name, cupsGetOption("printer-info", dest->num_options, dest->options), NULL, uri, tempresource, sizeof(tempresource)); |
| 2088 | |
| 2089 | if (uri) |
| 2090 | dest->num_options = cupsAddOption("printer-uri-supported", uri, dest->num_options, &dest->options); |
| 2091 | } |
| 2092 | } |
| 2093 | |
| 2094 | /* |
| 2095 | * Get the server destinations... |
| 2096 | */ |
no test coverage detected