cgi.c

00001 /*
00002  * Copyright (c) 2005-2012 by KoanLogic s.r.l. <http://www.koanlogic.com>
00003  * All rights reserved.
00004  *
00005  * This file is part of KLone, and as such it is subject to the license stated
00006  * in the LICENSE file which you have received as part of this distribution.
00007  *
00008  * $Id: cgi.c,v 1.8 2006/01/09 12:38:38 tat Exp $
00009  */
00010 
00011 #include "klone_conf.h"
00012 #include <u/libu.h>
00013 #include <stdlib.h>
00014 #include <klone/cgi.h>
00015 #include <klone/request.h>
00016 
00017 int cgi_set_request(request_t *rq)
00018 {
00019     char *ev;
00020 
00021     /* clear uri-related request fields */
00022     request_clear_uri(rq);
00023 
00024     dbg_err_if (rq == NULL);
00025 
00026     /* dbg_err_if(request_set_filename(rq, getenv("SCRIPT_NAME"))); */
00027 
00028     /* use PATH_INFO as script name i.e. 
00029         http://site/cgi-bin/kloned/path/to/script.kl1 */
00030     if((ev = getenv("PATH_INFO")) != NULL)
00031         dbg_err_if(request_set_filename(rq, ev));
00032     else
00033         dbg_err_if(request_set_filename(rq, "/"));
00034 
00035     if((ev = getenv("PATH_INFO")) != NULL)
00036         dbg_err_if(request_set_path_info(rq, ev));
00037 
00038     if((ev = getenv("QUERY_STRING")) != NULL)
00039         dbg_err_if(request_set_query_string(rq, ev));
00040 
00041     if((ev = getenv("REQUEST_METHOD")) != NULL)
00042         dbg_err_if(request_set_method(rq, ev));
00043 
00044     if((ev = getenv("CONTENT_TYPE")) != NULL)
00045         dbg_err_if(request_set_field(rq, "Content-Type", ev));
00046 
00047     if((ev = getenv("CONTENT_LENGTH")) != NULL)
00048         dbg_err_if(request_set_field(rq, "Content-Length", ev));
00049 
00050     return 0;
00051 err:
00052     return ~0;
00053 }

←Products
Copyright © 2005-2012 - KoanLogic S.r.l. - All rights reserved