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

Function mimeAddType

scheduler/type.c:81–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79 */
80
81mime_type_t * /* O - New (or existing) MIME type */
82mimeAddType(mime_t *mime, /* I - MIME database */
83 const char *super, /* I - Super-type name */
84 const char *type) /* I - Type name */
85{
86 mime_type_t *temp; /* New MIME type */
87 size_t typelen; /* Length of type name */
88
89
90 DEBUG_printf(("mimeAddType(mime=%p, super=\"%s\", type=\"%s\")", mime, super,
91 type));
92
93 /*
94 * Range check input...
95 */
96
97 if (!mime || !super || !type)
98 {
99 DEBUG_puts("1mimeAddType: Returning NULL (bad arguments).");
100 return (NULL);
101 }
102
103 /*
104 * See if the type already exists; if so, return the existing type...
105 */
106
107 if ((temp = mimeType(mime, super, type)) != NULL)
108 {
109 DEBUG_printf(("1mimeAddType: Returning %p (existing).", temp));
110 return (temp);
111 }
112
113 /*
114 * The type doesn't exist; add it...
115 */
116
117 if (!mime->types)
118 mime->types = cupsArrayNew((cups_array_func_t)mime_compare_types, NULL);
119
120 if (!mime->types)
121 {
122 DEBUG_puts("1mimeAddType: Returning NULL (no types).");
123 return (NULL);
124 }
125
126 typelen = strlen(type) + 1;
127
128 if ((temp = calloc(1, sizeof(mime_type_t) - MIME_MAX_TYPE + typelen)) == NULL)
129 {
130 DEBUG_puts("1mimeAddType: Returning NULL (out of memory).");
131 return (NULL);
132 }
133
134 strlcpy(temp->super, super, sizeof(temp->super));
135 memcpy(temp->type, type, typelen);
136 temp->priority = 100;
137
138 cupsArrayAdd(mime->types, temp);

Callers 9

mime_load_typesFunction · 0.85
add_printer_filterFunction · 0.85
add_printer_filtersFunction · 0.85
add_ppd_filterFunction · 0.85
add_ppd_filtersFunction · 0.85
cupsdAddPrinterFunction · 0.85
cupsdRenamePrinterFunction · 0.85
cupsdSetPrinterAttrsFunction · 0.85
add_printer_filterFunction · 0.85

Calls 3

mimeTypeFunction · 0.85
cupsArrayNewFunction · 0.85
cupsArrayAddFunction · 0.85

Tested by 2

add_ppd_filterFunction · 0.68
add_ppd_filtersFunction · 0.68