| 1934 | */ |
| 1935 | |
| 1936 | static void |
| 1937 | cups_create_defaults( |
| 1938 | cups_dinfo_t *dinfo) /* I - Destination information */ |
| 1939 | { |
| 1940 | ipp_attribute_t *attr; /* Current attribute */ |
| 1941 | char name[IPP_MAX_NAME + 1], |
| 1942 | /* Current name */ |
| 1943 | *nameptr, /* Pointer into current name */ |
| 1944 | value[2048]; /* Current value */ |
| 1945 | |
| 1946 | |
| 1947 | /* |
| 1948 | * Iterate through the printer attributes looking for xxx-default and adding |
| 1949 | * xxx=value to the defaults option array. |
| 1950 | */ |
| 1951 | |
| 1952 | for (attr = ippFirstAttribute(dinfo->attrs); attr; attr = ippNextAttribute(dinfo->attrs)) |
| 1953 | { |
| 1954 | if (!ippGetName(attr) || ippGetGroupTag(attr) != IPP_TAG_PRINTER) |
| 1955 | continue; |
| 1956 | |
| 1957 | strlcpy(name, ippGetName(attr), sizeof(name)); |
| 1958 | if ((nameptr = name + strlen(name) - 8) <= name || strcmp(nameptr, "-default")) |
| 1959 | continue; |
| 1960 | |
| 1961 | *nameptr = '\0'; |
| 1962 | |
| 1963 | if (ippGetValueTag(attr) == IPP_TAG_BEGIN_COLLECTION) |
| 1964 | { |
| 1965 | if (cups_collection_string(attr, value, sizeof(value)) >= sizeof(value)) |
| 1966 | continue; |
| 1967 | } |
| 1968 | else if (ippAttributeString(attr, value, sizeof(value)) >= sizeof(value)) |
| 1969 | continue; |
| 1970 | |
| 1971 | dinfo->num_defaults = cupsAddOption(name, value, dinfo->num_defaults, &dinfo->defaults); |
| 1972 | } |
| 1973 | } |
| 1974 | |
| 1975 | |
| 1976 | /* |
no test coverage detected