Annotation of libaitwww/example/test_url.c, revision 1.3.4.2
1.2 misho 1: /*
2: * Test URL API
3: *
1.3 misho 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"
1.2 misho 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;
1.3 misho 16: ait_val_t *v;
1.2 misho 17:
18: if (argc > 1) {
19: printf("URL:: Return=%x --- URL=%s\n", (ret = www_URLGet(argv[1], &URL)), argv[1]);
20:
1.3 misho 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));
1.2 misho 29: printf("URL:: (%x) +++reserved=%s\n", ret & 128, URL.url_reserved);
30:
1.3 misho 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");
1.3.4.1 misho 37: ait_freeVar(&v);
1.3 misho 38:
39: cgi = www_parseQuery(AIT_GET_STR(&URL.url_args));
1.2 misho 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:
1.3.4.1 misho 48: v = ait_allocVar();
1.3.4.2 ! misho 49: printf("File_url:: %d\n", www_URLGetFile(&URL, v));
! 50: printf("File_url:: File=%s\n", AIT_GET_STR(v));
1.3.4.1 misho 51: ait_freeVar(&v);
1.3 misho 52:
53: www_URLFree(&URL);
1.2 misho 54: }
55:
56: return 0;
57: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>