1 /* Tool for testing of cookies string parser */
11 #include "cookies/parser.h"
15 main(int argc
, char *argv
[])
17 struct cookie_str cstr
;
18 unsigned char name
[1024], value
[1024], string
[1024];
20 printf("This thing is for testing of cookies name-value pair parser.\n"
21 "You probably do not want to mess with it :).\n");
24 printf("Enter string (empty==quit): "); fflush(stdout
);
26 fgets(string
, 1024, stdin
);
28 string
[strlen(string
) - 1] = '\0'; /* Strip newline. */
29 if (!*string
) return 0;
31 if (!parse_cookie_str(&cstr
, string
)) {
32 printf("ERROR while parsing '%s'!\n", string
);
36 memcpy(name
, cstr
.str
, cstr
.nam_end
- cstr
.str
);
37 name
[cstr
.nam_end
- cstr
.str
] = '\0';
38 memcpy(value
, cstr
.val_start
, cstr
.val_end
- cstr
.val_start
);
39 value
[cstr
.val_end
- cstr
.val_start
] = '\0';
41 printf("'%s' -> '%s' :: '%s'\n", string
, name
, value
);