Annotation of libaitwww/example/test_url.c, revision 1.2.6.3
1.2 misho 1: /*
2: * Test URL API
3: *
1.2.6.1 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: char szVal[BUFSIZ];
16: cgi_t *cgi;
1.2.6.3 ! misho 17: ait_val_t *v;
1.2 misho 18:
19: if (argc > 1) {
20: printf("URL:: Return=%x --- URL=%s\n", (ret = www_URLGet(argv[1], &URL)), argv[1]);
21:
22: printf("URL:: (%x) ***Line=%s\n", ret, URL.url_line);
23: printf("URL:: (%x) tech=%s(%d)\n", ret & 1, URL.url_tech.value, URL.url_tech.vallen);
24: printf("URL:: (%x) user=%s(%d)\n", ret & 2, URL.url_user.value, URL.url_user.vallen);
25: printf("URL:: (%x) pass=%s(%d)\n", ret & 4, URL.url_pass.value, URL.url_pass.vallen);
26: printf("URL:: (%x) host=%s(%d)\n", ret & 8, URL.url_host.value, URL.url_host.vallen);
27: printf("URL:: (%x) port=%s(%d)\n", ret & 16, URL.url_port.value, URL.url_port.vallen);
28: printf("URL:: (%x) path=%s(%d)\n", ret & 32, URL.url_path.value, URL.url_path.vallen);
29: printf("URL:: (%x) args=%s(%d)\n", ret & 64, URL.url_args.value, URL.url_args.vallen);
30: printf("URL:: (%x) +++reserved=%s\n", ret & 128, URL.url_reserved);
31:
1.2.6.1 misho 32: www_unescape(URL.url_path.value);
1.2.6.3 ! misho 33: v = www_undot(URL.url_path.value);
! 34: printf("Path:: '%s' -> ", URL.url_path.value);
! 35: printf("validated %s ", v ? "YES" : "NO");
! 36: if (v)
! 37: printf("'%s'", AIT_GET_STR(v));
! 38: printf("\n");
! 39: io_freeVar(&v);
1.2.6.1 misho 40:
1.2 misho 41: memset(szVal, 0, BUFSIZ);
42: cgi = www_parseQuery(URL.url_args.value);
43: printf("Get_url:: %s Attribute=piuk\n", www_getValue(cgi, "piuk"));
44: printf("Get_url:: %s Attribute=sg\n", www_getValue(cgi, "sg"));
45: printf("Get_url:: %s Attribute=sgg\n", www_getValue(cgi, "sgg"));
46: printf("Get_url:: %s Attribute=sfsf\n", www_getValue(cgi, "sfsf"));
47: printf("Get_url:: %s Attribute=vv\n", www_getValue(cgi, "vv"));
48: printf("Get_url:: %s Attribute=vv\n", www_getValue(cgi, "vv"));
49: www_closeCGI(&cgi);
50:
51: printf("File_url:: File=%s %d\n", szVal, www_URLGetFile(&URL, szVal, BUFSIZ));
52: }
53:
54: return 0;
55: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>