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

Function ppdxReadData

examples/ppdx.c:44–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42 */
43
44void * /* O - Data or NULL */
45ppdxReadData(ppd_file_t *ppd, /* I - PPD file */
46 const char *name, /* I - Keyword prefix */
47 size_t *datasize) /* O - Size of data or NULL for don't care */
48{
49 char keyword[PPD_MAX_NAME], /* Keyword name */
50 decoded[PPDX_MAX_CHUNK + 1];
51 /* Decoded string */
52 unsigned chunk = 0; /* Current chunk number */
53 int len; /* Length of current chunk */
54 ppd_attr_t *attr; /* Keyword/value from PPD file */
55 Bytef *data; /* Pointer to data */
56 size_t alloc_size; /* Allocated size of data buffer */
57 z_stream decomp; /* Decompressor stream */
58 int error; /* Error/status from inflate() */
59
60
61 /*
62 * Range check input...
63 */
64
65 if (datasize)
66 *datasize = 0;
67
68 if (!ppd || !name)
69 return (NULL);
70
71 /*
72 * First see if there are any instances of the named keyword in the PPD...
73 */
74
75 snprintf(keyword, sizeof(keyword), "%s%04x", name, chunk);
76 if ((attr = ppdFindAttr(ppd, keyword, NULL)) == NULL)
77 return (NULL);
78
79 /*
80 * Allocate some memory and start decoding...
81 */
82
83 data = malloc(257);
84 alloc_size = 256;
85
86 memset(&decomp, 0, sizeof(decomp));
87 decomp.next_out = data;
88 decomp.avail_out = 256;
89
90 inflateInit(&decomp);
91
92 do
93 {
94 /*
95 * Grab the data from the current attribute and decode it...
96 */
97
98 len = sizeof(decoded);
99 if (!httpDecode64_2(decoded, &len, attr->value) || len == 0)
100 break;
101

Callers 1

mainFunction · 0.85

Calls 2

ppdFindAttrFunction · 0.85
httpDecode64_2Function · 0.85

Tested by 1

mainFunction · 0.68