Diff for /libaitwww/example/test.c between versions 1.1.2.1 and 1.2

version 1.1.2.1, 2012/03/09 09:38:55 version 1.2, 2012/03/10 00:26:49
Line 3 Line 3
 #include <aitwww.h>  #include <aitwww.h>
   
   
   static int
   showPair(struct tagCGI *c, void *arg)
   {
           if (arg)
                   printf("ARG=%s ... ", arg);
   
           printf("next=%p ... ", c->cgi_node.sle_next);
           printf("name=%s value=%s\n", c->cgi_name, c->cgi_value);
           return 0;
   }
   
   
 int  int
main()main(int argc, char **argv)
 {  {
        int i;        int ret;
        cgi_t *cgi;        cgi_t *cgi, *cgi1;
   
        putenv("QUERY_STRING=test1=abra+kadabra&testche=piuk%20mdaa");        if (argc < 2) {
        putenv("CONENT_LENGTH=390");                /* GET test */
        putenv("REQUEST_METHOD=GET");                putenv("QUERY_STRING=test1=abra+kadabra&testche=piuk%20mdaa");
        cgi = www_initCGI();                putenv("CONENT_LENGTH=390");
        if (!cgi) {                putenv("REQUEST_METHOD=GET");
                printf("Error:: #%d - %s\n", www_GetErrno(), www_GetError());                cgi = www_initCGI();
                return 1;                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"));
        printf("%s\n%s\n", cgigetvalue("something"), cgigetvalue("somethingelse")); 
        cginewquerystr("blaha=this is a string&blahb=this is another string"); 
        printf("\n%s\n%s\n", cgigetvalue("blaha"), cgigetvalue("blahb")); 
   
        cgiclose();                cgi1 = www_parseQuery("blahA=this is a string&blahB=this is another string");
        cginewquerystr("tmpa=another kool string&tmpb=and again");                if (!cgi1) {
        printf("\n%s\n%s\n", cgigetvalue("tmpa"), cgigetvalue("tmpb"));                        printf("Error:: #%d - %s\n", www_GetErrno(), www_GetError());
        i=mail("John-Mark Gurney <gurney_j@resnet.uoregon.edu>", "John-Mark Gurney <gurney_j@localhost>", "Test", "this is a test, $tmpa and other junk $tmpb");                        www_closeCGI(&cgi);
        */                        return 2;
                 }
                 printf("\n%s\n%s\n", www_getValue(cgi1, "blahA"), www_getValue(cgi1, "blahB"));
   
        www_closeCGI(&cgi);                printf("cgi num pairs=%d\n", www_listPairs(cgi, showPair, ".oOo."));
 
                 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");
 
                 printf("cgi1 num pairs=%d\n", www_listPairs(cgi1, showPair, NULL));
 
                 www_closeCGI(&cgi1);
         } else {
                 /* POST test */
                 putenv("REQUEST_METHOD=POST");
                 putenv("CONTENT_LENGTH=1000");
                 if (!strcmp(argv[1], "multi"))
                         putenv("CONTENT_TYPE=multipart/form-data; boundary=012345678909876543210");
                 else
                         putenv("CONTENT_TYPE=application/x-www-form-urlencoded");
 
                 cgi = www_initCGI();
                 if (!cgi) {
                         printf("Error:: #%d - %s\n", www_GetErrno(), www_GetError());
                         return 1;
                 }
 
                 printf("blah=%s\n", www_getValue(cgi, "blah"));
 
                 printf("num pairs=%d\n", www_listPairs(cgi, showPair, argv[1]));
 
                 www_closeCGI(&cgi);
         }
         return 0;          return 0;
 }  }

Removed from v.1.1.2.1  
changed lines
  Added in v.1.2


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