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

Function cgi_copy

cgi-bin/template.c:205–636  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203 */
204
205static void
206cgi_copy(FILE *out, /* I - Output file */
207 FILE *in, /* I - Input file */
208 int element, /* I - Element number (0 to N) */
209 char term, /* I - Terminating character */
210 int indent) /* I - Debug info indentation */
211{
212 int ch; /* Character from file */
213 char op; /* Operation */
214 char name[255], /* Name of variable */
215 *nameptr, /* Pointer into name */
216 innername[255], /* Inner comparison name */
217 *innerptr, /* Pointer into inner name */
218 *s; /* String pointer */
219 const char *value; /* Value of variable */
220 const char *innerval; /* Inner value */
221 const char *outptr; /* Output string pointer */
222 char outval[1024], /* Formatted output string */
223 compare[1024]; /* Comparison string */
224 int result; /* Result of comparison */
225 int uriencode; /* Encode as URI */
226 regex_t re; /* Regular expression to match */
227
228
229 fprintf(stderr, "DEBUG2: %*sStarting at file position %ld...\n", indent, "",
230 ftell(in));
231
232 /*
233 * Parse the file to the end...
234 */
235
236 while ((ch = getc(in)) != EOF)
237 if (ch == term)
238 break;
239 else if (ch == '{')
240 {
241 /*
242 * Get a variable name...
243 */
244
245 uriencode = 0;
246
247 for (s = name; (ch = getc(in)) != EOF;)
248 if (strchr("}]<>=!~ \t\n", ch))
249 break;
250 else if (s == name && ch == '%')
251 uriencode = 1;
252 else if (s > name && ch == '?')
253 break;
254 else if (s < (name + sizeof(name) - 1))
255 *s++ = (char)ch;
256
257 *s = '\0';
258
259 if (s == name && isspace(ch & 255))
260 {
261 fprintf(stderr, "DEBUG2: %*sLone { at %ld...\n", indent, "", ftell(in));
262

Callers 2

cgiCopyTemplateFileFunction · 0.85
cgiCopyTemplateLangFunction · 0.85

Calls 10

cgiGetArrayFunction · 0.85
cgiGetSizeFunction · 0.85
cgiGetCookieFunction · 0.85
cgi_puturiFunction · 0.85
_cups_strcasecmpFunction · 0.85
cgi_putsFunction · 0.85
cgiGetVariableFunction · 0.85
regcompFunction · 0.85
regexecFunction · 0.85
regfreeFunction · 0.85

Tested by

no test coverage detected