File:  [ELWIX - Embedded LightWeight unIX -] / libaitwww / example / test.c
Revision 1.1.2.3: download - view: text, annotated - select for diffs - revision graph
Fri Mar 9 10:04:16 2012 UTC (12 years, 3 months ago) by misho
Branches: www1_0
finish GET unit testing

#include <stdio.h>
#include <stdlib.h>
#include <aitwww.h>


int
main()
{
	int ret;
	cgi_t *cgi, *cgi1;

	putenv("QUERY_STRING=test1=abra+kadabra&testche=piuk%20mdaa");
	putenv("CONENT_LENGTH=390");
	putenv("REQUEST_METHOD=GET");
	cgi = www_initCGI();
	if (!cgi) {
		printf("Error:: #%d - %s\n", www_GetErrno(), www_GetError());
		return 1;
	}

	printf("%s\n%s\n", www_getValue(cgi, "testche"), www_getValue(cgi, "test1"));
	cgi1 = www_parseQuery("blahA=this is a string&blahB=this is another string");
	if (!cgi1) {
		printf("Error:: #%d - %s\n", www_GetErrno(), www_GetError());
		www_closeCGI(&cgi);
		return 2;
	}
	printf("\n%s\n%s\n", www_getValue(cgi1, "blahA"), www_getValue(cgi1, "blahB"));

	www_closeCGI(&cgi);

	www_addValue(cgi1, "oho", "boho");
	printf("\n%s\n", www_getValue(cgi1, "oho"));
	www_delPair(cgi1, "oho");
	printf("\n%s\n", www_getValue(cgi1, "oho"));
	www_delPair(cgi1, "oho");

	www_closeCGI(&cgi1);

	return 0;
}

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