File:  [ELWIX - Embedded LightWeight unIX -] / libaitwww / example / test_url.c
Revision 1.4: download - view: text, annotated - select for diffs - revision graph
Thu May 30 09:25:35 2013 UTC (11 years ago) by misho
Branches: MAIN
CVS tags: www3_4, www3_3, www3_2, www3_1, WWW3_3, WWW3_2, WWW3_1, WWW3_0, HEAD
version 3.0

    1: /*
    2:  * Test URL API
    3:  *
    4:  * ./test_url "http://www.elwix.org/test/mda%20a+b%20+cc.dat?ole=ss%65ss&aaa=a++a&sg=V&sgg=VV&piuk=pi3.14&vv=Mishka&z=z&sfsf=fd"
    5:  */
    6: #include <stdio.h>
    7: #include <string.h>
    8: #include <aitwww.h>
    9: 
   10: 
   11: int main(int argc, char **argv)
   12: {
   13: 	struct tagIOURL URL;
   14: 	int ret = 0;
   15: 	cgi_t *cgi;
   16: 	ait_val_t *v;
   17: 
   18: 	if (argc > 1) {
   19: 		printf("URL:: Return=%x --- URL=%s\n", (ret = www_URLGet(argv[1], &URL)), argv[1]);
   20: 
   21: 		printf("URL:: (%x) ***Line=%s\n", ret, AIT_GET_STRZ(&URL.url_line));
   22: 		printf("URL:: (%x) tech=%s(%d)\n", ret & 1, AIT_GET_STR(&URL.url_tech), AIT_LEN(&URL.url_tech));
   23: 		printf("URL:: (%x) user=%s(%d)\n", ret & 2, AIT_GET_STR(&URL.url_user), AIT_LEN(&URL.url_user));
   24: 		printf("URL:: (%x) pass=%s(%d)\n", ret & 4, AIT_GET_STR(&URL.url_pass), AIT_LEN(&URL.url_pass));
   25: 		printf("URL:: (%x) host=%s(%d)\n", ret & 8, AIT_GET_STR(&URL.url_host), AIT_LEN(&URL.url_host));
   26: 		printf("URL:: (%x) port=%s(%d)\n", ret & 16, AIT_GET_STR(&URL.url_port), AIT_LEN(&URL.url_port));
   27: 		printf("URL:: (%x) path=%s(%d)\n", ret & 32, AIT_GET_STR(&URL.url_path), AIT_LEN(&URL.url_path));
   28: 		printf("URL:: (%x) args=%s(%d)\n", ret & 64, AIT_GET_STR(&URL.url_args), AIT_LEN(&URL.url_args));
   29: 		printf("URL:: (%x) +++reserved=%s\n", ret & 128, URL.url_reserved);
   30: 
   31: 		v = www_undot(AIT_GET_STR(&URL.url_path));
   32: 		printf("Path:: '%s' -> ", AIT_GET_STR(&URL.url_path));
   33: 		printf("validated %s ", v ? "YES" : "NO");
   34: 		if (v)
   35: 			printf("'%s'", AIT_GET_STR(v));
   36: 		printf("\n");
   37: 		ait_freeVar(&v);
   38: 
   39: 		cgi = www_parseQuery(AIT_GET_STR(&URL.url_args));
   40: 		printf("Get_url:: %s Attribute=piuk\n", www_getValue(cgi, "piuk"));
   41: 		printf("Get_url:: %s Attribute=sg\n", www_getValue(cgi, "sg"));
   42: 		printf("Get_url:: %s Attribute=sgg\n", www_getValue(cgi, "sgg"));
   43: 		printf("Get_url:: %s Attribute=sfsf\n", www_getValue(cgi, "sfsf"));
   44: 		printf("Get_url:: %s Attribute=vv\n", www_getValue(cgi, "vv"));
   45: 		printf("Get_url:: %s Attribute=vv\n", www_getValue(cgi, "vv"));
   46: 		www_closeCGI(&cgi);
   47: 
   48: 		v = ait_allocVar();
   49: 		printf("File_url:: %d\n", www_URLGetFile(&URL, v));
   50: 		printf("File_url:: File=%s\n", AIT_GET_STR(v));
   51: 		ait_freeVar(&v);
   52: 
   53: 		www_URLFree(&URL);
   54: 	}
   55: 
   56: 	return 0;
   57: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>