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