httpd_p.c

Go to the documentation of this file.
00001 #include <string.h>
00002 #include <cfg/http.h>
00003 #include <sys/heap.h>
00004 
00005 #include "httpd_p.h"
00006 
00007 /*
00008  *  W A R N I N G
00009  *  -------------
00010  *
00011  * This file is not part of the Ethernut API.  It exists purely as an
00012  * implementation detail.  This header file may change from version to
00013  * version without notice, or even be removed.
00014  *
00015  * We mean it.
00016 */
00017 
00018 
00026 #ifndef HTTP_DEFAULT_ROOT
00027 #define HTTP_DEFAULT_ROOT   "UROM:"
00028 #endif
00029 
00030 char *http_root;
00031 
00032 char *default_files[] = {
00033     "",
00034     "/index.html",
00035     "/index.htm",
00036     "/default.html",
00037     "/default.htm",
00038     "/index.shtml",
00039     "/index.xhtml",
00040     "/index.asp",
00041     "/default.asp",
00042     NULL
00043 };
00044 
00052 char *CreateFilePath(CONST char *url, CONST char *addon)
00053 {
00054     char *root = http_root ? http_root : HTTP_DEFAULT_ROOT;
00055     size_t urll = strlen(url);
00056     char *path = NutHeapAlloc(strlen(root) + urll + strlen(addon) + 1);
00057 
00058     if (path) {
00059         strcpy(path, root);
00060         strcat(path, url);
00061         if (*addon) {
00062             strcat(path, addon + (urll == 0 || url[urll - 1] == '/'));
00063         }
00064     }
00065     return path;
00066 }
00067 
00074 void DestroyRequestInfo(REQUEST * req)
00075 {
00076     if (req) {
00077         if (req->req_url)
00078             NutHeapFree(req->req_url);
00079         if (req->req_query)
00080             NutHeapFree(req->req_query);
00081         if (req->req_type)
00082             NutHeapFree(req->req_type);
00083         if (req->req_cookie)
00084             NutHeapFree(req->req_cookie);
00085         if (req->req_auth)
00086             NutHeapFree(req->req_auth);
00087         if (req->req_agent)
00088             NutHeapFree(req->req_agent);
00089         if (req->req_qptrs)
00090             NutHeapFree(req->req_qptrs);
00091         if (req->req_referer)
00092             NutHeapFree(req->req_referer);
00093         if (req->req_host)
00094             NutHeapFree(req->req_host);
00095         NutHeapFree(req);
00096     }
00097 }

© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/