MCPcopy Create free account
hub / github.com/OpenPrinting/cups / cups_create_defaults

Function cups_create_defaults

cups/dest-options.c:1936–1973  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1934 */
1935
1936static void
1937cups_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/*

Callers 1

cupsCopyDestConflictsFunction · 0.85

Calls 8

ippFirstAttributeFunction · 0.85
ippNextAttributeFunction · 0.85
ippGetNameFunction · 0.85
ippGetGroupTagFunction · 0.85
ippGetValueTagFunction · 0.85
cups_collection_stringFunction · 0.85
ippAttributeStringFunction · 0.85
cupsAddOptionFunction · 0.85

Tested by

no test coverage detected