示例#1
0
 int main(int argc, char *argv[])
 {
     bstring url = NULL;
     bstring route = NULL;
     TSTree *routes = NULL;

     check(argc == 2, "USAGE: urlor <urlfile>");

     routes = load_routes(argv[1]);
     check(routes != NULL, "Your route file has an error.");

     while (1) {
         url = read_line("URL> ");
         check_debug(url != NULL, "goodbye.");

         route = match_url(routes, url);

         if (route) {
             printf("MATCH: %s == %s\n", bdata(url), bdata(route));
         } else {
             printf("FAIL: %s\n", bdata(url));
         }

         bdestroy(url);
     }

     destroy_routes(routes);
     return 0;

 error:
     destroy_routes(routes);
     return 1;
 }
示例#2
0
int main(int argc , char *argv[])
{
/*just echo the prompt and wait for a line to be enterred in
 *then search the url as the key to find data
 * then output
 */
	bstring url = NULL ;
	bstring route = NULL;
	check(argc == 2 , "usage: urlor <urlfile>");

	TSTree *routes = load_routes(argv[1]);
	check(routes != NULL , "your route file has an errro.");

	while(1){
		url = read_line("URL>");
		check_debug(url != NULL , "goodbye");
		route = match_url(routes , url);

		if(route) {
			printf("match %s == %s\n" , bdata(url) , bdata(route));
		} else{
			printf("fail;%s \n" , bdata(url));
		}
		
		bdestroy(url);
	}

	destroy_routes(routes);
	return 0;
error:
	destroy_routes(routes);
	return 1;
}