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, 3 months 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
/*
* Test URL API
*
* ./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"
*/
#include <stdio.h>
#include <string.h>
#include <aitwww.h>
int main(int argc, char **argv)
{
struct tagIOURL URL;
int ret = 0;
cgi_t *cgi;
ait_val_t *v;
if (argc > 1) {
printf("URL:: Return=%x --- URL=%s\n", (ret = www_URLGet(argv[1], &URL)), argv[1]);
printf("URL:: (%x) ***Line=%s\n", ret, AIT_GET_STRZ(&URL.url_line));
printf("URL:: (%x) tech=%s(%d)\n", ret & 1, AIT_GET_STR(&URL.url_tech), AIT_LEN(&URL.url_tech));
printf("URL:: (%x) user=%s(%d)\n", ret & 2, AIT_GET_STR(&URL.url_user), AIT_LEN(&URL.url_user));
printf("URL:: (%x) pass=%s(%d)\n", ret & 4, AIT_GET_STR(&URL.url_pass), AIT_LEN(&URL.url_pass));
printf("URL:: (%x) host=%s(%d)\n", ret & 8, AIT_GET_STR(&URL.url_host), AIT_LEN(&URL.url_host));
printf("URL:: (%x) port=%s(%d)\n", ret & 16, AIT_GET_STR(&URL.url_port), AIT_LEN(&URL.url_port));
printf("URL:: (%x) path=%s(%d)\n", ret & 32, AIT_GET_STR(&URL.url_path), AIT_LEN(&URL.url_path));
printf("URL:: (%x) args=%s(%d)\n", ret & 64, AIT_GET_STR(&URL.url_args), AIT_LEN(&URL.url_args));
printf("URL:: (%x) +++reserved=%s\n", ret & 128, URL.url_reserved);
v = www_undot(AIT_GET_STR(&URL.url_path));
printf("Path:: '%s' -> ", AIT_GET_STR(&URL.url_path));
printf("validated %s ", v ? "YES" : "NO");
if (v)
printf("'%s'", AIT_GET_STR(v));
printf("\n");
ait_freeVar(&v);
cgi = www_parseQuery(AIT_GET_STR(&URL.url_args));
printf("Get_url:: %s Attribute=piuk\n", www_getValue(cgi, "piuk"));
printf("Get_url:: %s Attribute=sg\n", www_getValue(cgi, "sg"));
printf("Get_url:: %s Attribute=sgg\n", www_getValue(cgi, "sgg"));
printf("Get_url:: %s Attribute=sfsf\n", www_getValue(cgi, "sfsf"));
printf("Get_url:: %s Attribute=vv\n", www_getValue(cgi, "vv"));
printf("Get_url:: %s Attribute=vv\n", www_getValue(cgi, "vv"));
www_closeCGI(&cgi);
v = ait_allocVar();
printf("File_url:: %d\n", www_URLGetFile(&URL, v));
printf("File_url:: File=%s\n", AIT_GET_STR(v));
ait_freeVar(&v);
www_URLFree(&URL);
}
return 0;
}
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>