/*
* 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:: File=%s %d\n", AIT_GET_STR(v), www_URLGetFile(&URL, v));
ait_freeVar(&v);
www_URLFree(&URL);
}
return 0;
}
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>