2 * TUX - Integrated Application Protocols Layer and Object Cache
4 * Copyright (C) 2000, Ingo Molnar <mingo@redhat.com>
6 * parser.h: generic parsing routines
9 #define get_c(ptr,left) \
22 #define PARSE_TOKEN(ptr,str,left) \
28 if (sizeof(str)-1 > left) { \
29 if (memcmp(ptr, str, left)) \
34 if (memcmp(ptr, str, sizeof(str)-1)) \
37 ptr += sizeof(str)-1; \
38 left -= sizeof(str)-1; \
44 #define PARSE_METHOD(req,ptr,name,left) \
48 if (PARSE_TOKEN(ptr,#name" ",left)) { \
49 req->method = METHOD_##name; \
56 #define COPY_LINE(ptr,target,left) \
59 while (((c = get_c(ptr,left))) != '\n') \
60 *target++ = prev_c = c; \
65 #define COPY_LINE_TOLOWER(ptr,target,left,limit) \
68 while (((c = get_c(ptr,left))) != '\n') { \
69 if ((c >= 'A') && (c <= 'Z')) \
71 *target++ = prev_c = c; \
72 if (target == (limit)) \
79 #define COPY_FIELD(ptr,target,left) \
82 while ((c = get_c(ptr,left)) != ' ') \
86 #define SKIP_LINE(ptr,left) \
89 while (((c = get_c(ptr,left))) != '\n') \
95 #define SKIP_WHITESPACE(curr,left) \
97 while ((left) && (*(curr) == ' ')) \