* shuffle auth arround...
[citadel.git] / webcit / static.c
index 0d0eea948b23c423204d232760f887a6ba4bbdc8..7e5580b273400c188ce13bbfedd959ee3f398041 100644 (file)
 
 
 HashList *StaticFilemappings[4] = {NULL, NULL, NULL, NULL};
-
-
 /*
-  for ( a = 0; a < 9; ++a)
-  {
-  extract_token(index[a], ChrPtr(ReqLine), a + 1, '/', sizes[a]);
-  if (strstr(index[a], "?")) *strstr(index[a], "?") = 0;
-  if (strstr(index[a], "&")) *strstr(index[a], "&") = 0;
-  if (strstr(index[a], " ")) *strstr(index[a], " ") = 0;
-  if ((index[a][0] == '.') && (index[a][1] == '.'))
-  nBackDots++;
-  if (index[a][0] == '\0')
-  nEmpty++;
-  }
-*/
-
-/* TODO: staticdata
-{
-
-
-       /** Figure out the action * /
-       index[0] = action;
-       sizes[0] = sizeof action;
-       for (a=1; a<9; a++)
-       {
-               index[a] = arg[a-1];
-               sizes[a] = sizeof arg[a-1];
-       }
-       nBackDots = 0;
-       nEmpty = 0;
-
-
-       /* Static content can be sent without connecting to Citadel. * /
-       is_static = 0;
-       for (a=0; a<ndirs && ! is_static; ++a) {
-               if (!strcasecmp(action, (char*)static_content_dirs[a])) { /* map web to disk location * /
-                       is_static = 1;
-                       n_static = a;
-               }
-       }
-       if (is_static) {
-               if (nBackDots < 2)
-               {
-                       snprintf(buf, sizeof buf, "%s/%s/%s/%s/%s/%s/%s/%s",
-                                static_dirs[n_static], 
-                                index[1], index[2], index[3], index[4], index[5], index[6], index[7]);
-                       for (a=0; a<8; ++a) {
-                               if (buf[strlen(buf)-1] == '/') {
-                                       buf[strlen(buf)-1] = 0;
-                               }
-                       }
-                       for (a = 0; a < strlen(buf); ++a) {
-                               if (isspace(buf[a])) {
-                                       buf[a] = 0;
-                               }
-                       }
-                       output_static(buf);
-               }
-               else 
                {
                        lprintf(9, "Suspicious request. Ignoring.");
                        hprintf("HTTP/1.1 404 Security check failed\r\n");
@@ -85,11 +27,7 @@ HashList *StaticFilemappings[4] = {NULL, NULL, NULL, NULL};
                        wprintf("You have sent a malformed or invalid request.\r\n");
                        end_burst();
                }
-               goto SKIP_ALL_THIS_CRAP;        /* Don't try to connect * /
-       }
-       }*/
-
-
+*/
 /*
  * dump out static pages from disk
  */
@@ -148,28 +86,6 @@ void output_static(const char *what)
        }
 }
 
-       /* TODO: integrate this into the static startup logic
-
-        * While we're at it, gracefully handle requests for the
-        * robots.txt and favicon.ico files.
-        * /
-       if ((StrLength(ReqLine) >= 11) &&
-           !strncasecmp(ChrPtr(ReqLine), "/robots.txt", 11)) {
-               StrBufPlain(ReqLine, 
-                           HKEY("/static/robots.txt"
-                                "?force_close_session=yes HTTP/1.1"));
-               Hdr.eReqType = eGET;
-       }
-       else if ((StrLength(ReqLine) >= 11) &&
-                !strncasecmp(ChrPtr(ReqLine), "/favicon.ico", 12)) {
-               StrBufPlain(ReqLine, HKEY("/static/favicon.ico"));
-               Hdr.eReqType = eGET;
-       }
-
-*/
-
-
-
 
 int LoadStaticDir(const char *DirName, HashList *DirList, const char *RelDir)
 {
@@ -262,6 +178,22 @@ int LoadStaticDir(const char *DirName, HashList *DirList, const char *RelDir)
 }
 
 
+void output_flat_static(void)
+{
+       wcsession *WCC = WC;
+       void *vFile;
+       StrBuf *File;
+
+       if (GetHash(StaticFilemappings[0], SKEY(WCC->Hdr->Handler->Name), &vFile) &&
+           (vFile != NULL))
+       {
+               File = (StrBuf*) vFile;
+               output_static(ChrPtr(vFile));
+       }
+}
+
+
+
 void output_static_safe(HashList *DirList)
 {
        wcsession *WCC = WC;
@@ -324,11 +256,9 @@ InitModule_STATIC
        LoadStaticDir(static_dirs[2], StaticFilemappings[2], "");
        LoadStaticDir(static_dirs[3], StaticFilemappings[3], "");
 
-       WebcitAddUrlHandler(HKEY("robots.txt"), output_static_0, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC);
-       WebcitAddUrlHandler(HKEY("favicon.ico"), output_static_0, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC);
+       WebcitAddUrlHandler(HKEY("robots.txt"), output_flat_static, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC);
+       WebcitAddUrlHandler(HKEY("favicon.ico"), output_flat_static, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC);
        WebcitAddUrlHandler(HKEY("static"), output_static_0, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC);
        WebcitAddUrlHandler(HKEY("static.local"), output_static_1, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC);
        WebcitAddUrlHandler(HKEY("tinymce"), output_static_2, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC);
-
-
 }