| 203 | */ |
| 204 | |
| 205 | static void |
| 206 | cgi_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 |
no test coverage detected