File: httpd_test_util.c

package info (click to toggle)
apache2 2.4.65-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 59,148 kB
  • sloc: ansic: 211,971; python: 13,977; perl: 11,307; sh: 7,102; php: 1,315; javascript: 1,314; awk: 749; makefile: 712; lex: 374; yacc: 161; xml: 2
file content (44 lines) | stat: -rw-r--r-- 1,062 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* poor man's optional functions
 * if we didn't need to support 1.x we could use optional functions.
 * just hack in this util functions with #define/#include/static for now.
 *
 * tho we could create our own version optional functions using
 * the 1.3/2.0 dlsym-ish function to lookup function pointers given a
 * mod_httpd_test_util.so and httpd_test_util.dynamic_load_handle
 * but thats more trouble than it is worth at the moment.
 */

#ifdef WANT_HTTPD_TEST_SPLIT_QS_NUMBERS

/* split query string in the form of GET /foo?1024,5000 */

static int httpd_test_split_qs_numbers(request_rec *r, ...)
{
    va_list va;
    char *endptr, *args = r->args;

    if (!args) {
        return 0;
    }

    va_start(va, r);

    while (1) {
        apr_size_t *s = va_arg(va, apr_size_t *);
        if (!s) {
            break;
        }
        *s = strtol(args, &endptr, 0);
        if (endptr && (*endptr == ',')) {
            ++endptr;
            args = endptr;
        }
    }

    va_end(va);

    return 1;
}

#endif /* WANT_HTTPD_TEST_SPLIT_QS_NUMBERS */