/* $Id: test_htparse.c,v 1.2 1994/05/11 22:36:51 connolly Exp $ */ #include #include #include "HTParse.h" #define SAFEFREE(x) if(x){ free(x); x = NULL; };; int main(int argc, char **argv) { char buffer[5000]; char *there, *here; char *scheme, *hostport, *port, *path, *id; while(gets(buffer)){ /* skip blank lines, comments */ if(buffer[0] == '#' || buffer[0] == 0) continue; there = buffer; if(here = strchr(buffer, '\t')){ *here++ = 0; if(scheme = strchr(here, '\t')){ *scheme++ = 0; } } printf("\n***********\n"); printf("here: %s\n", here); printf("there: %s\n", there); scheme = HTParse(there, here, PARSE_ACCESS | PARSE_PUNCTUATION); hostport = HTParse(there, here, PARSE_HOST | PARSE_PUNCTUATION); path = HTParse(there, here, PARSE_PATH | PARSE_PUNCTUATION); id = HTParse(there, here, PARSE_ANCHOR | PARSE_PUNCTUATION); if(path){ char *tmp = path; path = HTUnEscape(path); SAFEFREE(tmp); } printf("scheme: %s\n", scheme); printf("hostport: %s\n", hostport); printf("path: %s\n", path); printf("id: %s\n", id); SAFEFREE(scheme); SAFEFREE(hostport); SAFEFREE(path); SAFEFREE(id); } return 0; }