]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Henrik icon URL changes
authorwessels <>
Tue, 17 Mar 1998 04:59:55 +0000 (04:59 +0000)
committerwessels <>
Tue, 17 Mar 1998 04:59:55 +0000 (04:59 +0000)
src/client_side.cc
src/defines.h
src/ftp.cc
src/gopher.cc
src/mime.cc
src/protos.h
src/structs.h

index cabdd1481cdc91d0b4dca1cd935be5ba1700e8f5..e0c2a71d3325fb86493163869aaa311514b44c88 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.227 1998/03/16 17:03:25 wessels Exp $
+ * $Id: client_side.cc,v 1.228 1998/03/16 21:59:55 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -1364,7 +1364,7 @@ clientProcessMiss(clientHttpRequest * http)
     ch.src_addr = http->conn->peer.sin_addr;
     ch.request = r;
     answer = aclCheckFast(Config.accessList.miss, &ch);
-    if (answer == 0) {
+    if (answer == 0 || http->internal) {
        http->al.http.code = HTTP_FORBIDDEN;
        err = errorCon(ERR_FORWARDING_DENIED, HTTP_FORBIDDEN);
        err->request = requestLink(r);
@@ -1542,8 +1542,17 @@ parseHttpRequest(ConnStateData * conn, method_t * method_p, int *status,
     if ((t = strchr(url, '#')))        /* remove HTML anchors */
        *t = '\0';
 
+    /* handle internal objects */
+    if (*url == '/' && strncmp(url, "/squid-internal/", 16) == 0) {
+       /* prepend our name & port */
+       url_sz = 7 + strlen(getMyHostname()) + 6 + strlen(url) + 1;
+       http->uri = xcalloc(url_sz, 1);
+       snprintf(http->uri, url_sz, "http://%s:%d%s",
+           getMyHostname(), Config.Port.http->i, url);
+       http->internal = 1;
+    }
     /* see if we running in Config2.Accel.on, if so got to convert it to URL */
-    if (Config2.Accel.on && *url == '/') {
+    else if (Config2.Accel.on && *url == '/') {
        /* prepend the accel prefix */
        if (opt_accel_uses_host && (t = mime_get_header(req_hdr, "Host"))) {
            /* If a Host: header was specified, use it to build the URL 
index 50cb12349ae19fa0228887b1f56229900d90059d..02ca2430a5434f01321cfe54f5d40abdefa4760f 100644 (file)
  *  Here are some good prime number choices.  It's important not to
  *  choose a prime number that is too close to exact powers of 2.
  *
- *  HASH_SIZE 103              // prime number < 128
- *  HASH_SIZE 229              // prime number < 256
- *  HASH_SIZE 467              // prime number < 512
- *  HASH_SIZE 977              // prime number < 1024
- *  HASH_SIZE 1979             // prime number < 2048
- *  HASH_SIZE 4019             // prime number < 4096
- *  HASH_SIZE 6037             // prime number < 6144
- *  HASH_SIZE 7951             // prime number < 8192
- *  HASH_SIZE 12149            // prime number < 12288
- *  HASH_SIZE 16231            // prime number < 16384
- *  HASH_SIZE 33493            // prime number < 32768
- *  HASH_SIZE 65357            // prime number < 65536
+ *  HASH_SIZE 103               // prime number < 128
+ *  HASH_SIZE 229               // prime number < 256
+ *  HASH_SIZE 467               // prime number < 512
+ *  HASH_SIZE 977               // prime number < 1024
+ *  HASH_SIZE 1979              // prime number < 2048
+ *  HASH_SIZE 4019              // prime number < 4096
+ *  HASH_SIZE 6037              // prime number < 6144
+ *  HASH_SIZE 7951              // prime number < 8192
+ *  HASH_SIZE 12149             // prime number < 12288
+ *  HASH_SIZE 16231             // prime number < 16384
+ *  HASH_SIZE 33493             // prime number < 32768
+ *  HASH_SIZE 65357             // prime number < 65536
  */
 
 #define  DEFAULT_HASH_SIZE 7951        /* prime number < 8192 */
 #define PEER_DEAD 0
 #define PEER_ALIVE 1
 
-#define ICON_MENU      "anthony-dir.gif"
-#define ICON_DIRUP     "anthony-dirup.gif"
-#define ICON_LINK      "anthony-link.gif"
-
 #define AUTH_MSG_SZ 4096
 #define HTTP_REPLY_BUF_SZ 4096
 
index 1c1b9ca9c7a48e7f61090ac6daca91dc7b90f2e3..268ae31d8f640dd7aa14a648dbc1965ff63a93a3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ftp.cc,v 1.207 1998/03/16 18:21:41 wessels Exp $
+ * $Id: ftp.cc,v 1.208 1998/03/16 21:59:58 wessels Exp $
  *
  * DEBUG: section 9     File Transfer Protocol (FTP)
  * AUTHOR: Harvest Derived
@@ -575,10 +575,9 @@ ftpHtmlifyListEntry(char *line, FtpStateData * ftpState)
     }
     /* check .. as special case */
     if (!strcmp(parts->name, "..")) {
-       snprintf(icon, 2048, "<IMG BORDER=0 SRC=\"%s%s\" ALT=\"%-6s\">",
-           "http://internal.squid/icons/",
-           ICON_DIRUP,
-           "[DIR]");
+       snprintf(icon, 2048, "<IMG BORDER=0 SRC=\"%s\" ALT=\"%-6s\">",
+           mimeGetIconURL("internal-dirup"),
+           "[DIRUP]");
        if (!EBIT_TEST(flags, FTP_NO_DOTDOT) && !EBIT_TEST(flags, FTP_ROOT_DIR)) {
            /* Normal directory */
            snprintf(link, 2048, "<A HREF=\"%s\">%s</A>",
@@ -624,9 +623,8 @@ ftpHtmlifyListEntry(char *line, FtpStateData * ftpState)
     }
     switch (parts->type) {
     case 'd':
-       snprintf(icon, 2048, "<IMG SRC=\"%s%s\" ALT=\"%-6s\">",
-           "http://internal.squid/icons/",
-           ICON_MENU,
+       snprintf(icon, 2048, "<IMG SRC=\"%s\" ALT=\"%-6s\">",
+           mimeGetIconURL("internal-dir"),
            "[DIR]");
        snprintf(link, 2048, "<A HREF=\"%s/\">%s</A>%s",
            rfc1738_escape(parts->name),
@@ -638,9 +636,8 @@ ftpHtmlifyListEntry(char *line, FtpStateData * ftpState)
            parts->date);
        break;
     case 'l':
-       snprintf(icon, 2048, "<IMG SRC=\"%s%s\" ALT=\"%-6s\">",
-           "http://internal.squid/icons/",
-           ICON_LINK,
+       snprintf(icon, 2048, "<IMG SRC=\"%s\" ALT=\"%-6s\">",
+           mimeGetIconURL("internal-link"),
            "[LINK]");
        snprintf(link, 2048, "<A HREF=\"%s\">%s</A>%s",
            rfc1738_escape(parts->name),
@@ -656,9 +653,8 @@ ftpHtmlifyListEntry(char *line, FtpStateData * ftpState)
            link2);
        break;
     case '\0':
-       snprintf(icon, 2048, "<IMG SRC=\"%s%s\" ALT=\"%-6s\">",
-           "http://internal.squid/icons/",
-           mimeGetIcon(parts->name),
+       snprintf(icon, 2048, "<IMG SRC=\"%s\" ALT=\"%-6s\">",
+           mimeGetIconURL(parts->name),
            "[UNKNOWN]");
        snprintf(link, 2048, "<A HREF=\"%s\">%s</A>",
            rfc1738_escape(parts->name),
@@ -672,9 +668,8 @@ ftpHtmlifyListEntry(char *line, FtpStateData * ftpState)
        break;
     case '-':
     default:
-       snprintf(icon, 2048, "<IMG SRC=\"%s%s\" ALT=\"%-6s\">",
-           "http://internal.squid/icons/",
-           mimeGetIcon(parts->name),
+       snprintf(icon, 2048, "<IMG SRC=\"%s\" ALT=\"%-6s\">",
+           mimeGetIconURL(parts->name),
            "[FILE]");
        snprintf(link, 2048, "<A HREF=\"%s\">%s</A>%s",
            rfc1738_escape(parts->name),
@@ -750,8 +745,8 @@ ftpReadComplete(FtpStateData * ftpState)
     if (EBIT_TEST(ftpState->flags, FTP_HTML_HEADER_SENT))
        ftpListingFinish(ftpState);
     if (!EBIT_TEST(ftpState->flags, FTP_PUT)) {
-       storeTimestampsSet(ftpState->entry);
-       storeComplete(ftpState->entry);
+       storeTimestampsSet(ftpState->entry);
+       storeComplete(ftpState->entry);
     }
     /* expect the "transfer complete" message on the control socket */
     commSetSelect(ftpState->ctrl.fd,
@@ -936,7 +931,7 @@ ftpStart(request_t * request, StoreEntry * entry)
     EBIT_SET(ftpState->flags, FTP_PASV_SUPPORTED);
     EBIT_SET(ftpState->flags, FTP_REST_SUPPORTED);
     if (ftpState->request->method == METHOD_PUT)
-       EBIT_SET(ftpState->flags, FTP_PUT);
+       EBIT_SET(ftpState->flags, FTP_PUT);
     if (!ftpCheckAuth(ftpState, request->headers)) {
        /* This request is not fully authenticated */
        if (request->port == 21) {
@@ -1185,7 +1180,7 @@ ftpReadControlReply(int fd, void *data)
     ftpState->ctrl.last_reply = (*W)->key;
     safe_free(*W);
     ftpState->ctrl.offset = 0;
-    debug(9,8)("ftpReadControlReply: state=%d\n",ftpState->state);
+    debug(9, 8) ("ftpReadControlReply: state=%d\n", ftpState->state);
     FTP_SM_FUNCS[ftpState->state] (ftpState);
 }
 
@@ -1378,39 +1373,40 @@ ftpReadCwd(FtpStateData * ftpState)
        ftpTraverseDirectory(ftpState);
     } else {
        /* CWD FAILED */
-       if (!EBIT_TEST(ftpState->flags, FTP_PUT)) 
-               ftpFail(ftpState);
+       if (!EBIT_TEST(ftpState->flags, FTP_PUT))
+           ftpFail(ftpState);
        else
-               ftpTryMkdir(ftpState);
+           ftpTryMkdir(ftpState);
     }
 }
 
 static void
-ftpTryMkdir(FtpStateData *ftpState)
+ftpTryMkdir(FtpStateData * ftpState)
 {
-       char *path=ftpState->filepath;
-       debug(9,3)("ftpTryMkdir: with path=%s\n",path);
-       snprintf(cbuf, 1024, "MKD %s\r\n", path);
-       ftpWriteCommand(cbuf, ftpState);
-       ftpState->state = SENT_MKDIR;
+    char *path = ftpState->filepath;
+    debug(9, 3) ("ftpTryMkdir: with path=%s\n", path);
+    snprintf(cbuf, 1024, "MKD %s\r\n", path);
+    ftpWriteCommand(cbuf, ftpState);
+    ftpState->state = SENT_MKDIR;
 }
 
 static void
-ftpReadMkdir(FtpStateData *ftpState)
-{
-       char *path=ftpState->filepath;
-       int code = ftpState->ctrl.replycode;
-       
-       debug(9,3)("Here, with code %d\n",path,code);
-       if (code==257) { /* success */
-               ftpSendCwd(ftpState);   
-       } else if (code==550) { /* dir exists */
-               if (EBIT_TEST(ftpState->flags, FTP_PUT_MKDIR)) { 
-                       EBIT_SET(ftpState->flags, FTP_PUT_MKDIR);
-                       ftpSendCwd(ftpState);
-               } else 
-                       ftpSendReply(ftpState);
-       } else ftpSendReply(ftpState);
+ftpReadMkdir(FtpStateData * ftpState)
+{
+    char *path = ftpState->filepath;
+    int code = ftpState->ctrl.replycode;
+
+    debug(9, 3) ("Here, with code %d\n", path, code);
+    if (code == 257) {         /* success */
+       ftpSendCwd(ftpState);
+    } else if (code == 550) {  /* dir exists */
+       if (EBIT_TEST(ftpState->flags, FTP_PUT_MKDIR)) {
+           EBIT_SET(ftpState->flags, FTP_PUT_MKDIR);
+           ftpSendCwd(ftpState);
+       } else
+           ftpSendReply(ftpState);
+    } else
+       ftpSendReply(ftpState);
 }
 
 static void
@@ -1713,7 +1709,7 @@ ftpRestOrList(FtpStateData * ftpState)
 
     debug(9, 3) ("This is ftpRestOrList\n");
     if (EBIT_TEST(ftpState->flags, FTP_PUT)) {
-        debug(9,3)("ftpRestOrList: Sending STOR request...\n");
+       debug(9, 3) ("ftpRestOrList: Sending STOR request...\n");
        ftpSendStor(ftpState);
     } else if (ftpState->typecode == 'D') {
        /* XXX This should NOT be here */
@@ -2013,17 +2009,17 @@ static void
 ftpPutStart(FtpStateData * ftpState)
 {
     debug(9, 3) ("ftpPutStart\n");
-    pumpStart(ftpState->data.fd, ftpState->entry , 
-               ftpState->request, ftpPutTransferDone, ftpState);
+    pumpStart(ftpState->data.fd, ftpState->entry,
+       ftpState->request, ftpPutTransferDone, ftpState);
 }
 
-static void 
+static void
 ftpPutTransferDone(int fd, char *bufnotused, size_t size, int errflag, void *data)
 {
-    FtpStateData * ftpState=(FtpStateData *)data;
+    FtpStateData *ftpState = (FtpStateData *) data;
     if (ftpState->data.fd >= 0) {
-        comm_close(ftpState->data.fd);
-        ftpState->data.fd = -1;
+       comm_close(ftpState->data.fd);
+       ftpState->data.fd = -1;
     }
     ftpReadComplete(ftpState);
 }
index f8dffc78667b61d9441025bfefbe24dc6fa9c917..3496fd4ae4d037acc441c1ed7e58f0a22e6f46aa 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: gopher.cc,v 1.122 1998/03/05 00:42:53 wessels Exp $
+ * $Id: gopher.cc,v 1.123 1998/03/16 21:59:58 wessels Exp $
  *
  * DEBUG: section 10    Gopher
  * AUTHOR: Harvest Derived
@@ -357,7 +357,7 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len)
     char *host = NULL;
     char *port = NULL;
     char *escaped_selector = NULL;
-    char *icon_type = NULL;
+    char *icon_url = NULL;
     char gtype;
     StoreEntry *entry = NULL;
 
@@ -509,39 +509,39 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len)
 
                        switch (gtype) {
                        case GOPHER_DIRECTORY:
-                           icon_type = "internal-gopher-menu";
+                           icon_url = mimeGetIconURL("internal-menu");
                            break;
                        case GOPHER_FILE:
-                           icon_type = "internal-gopher-text";
+                           icon_url = mimeGetIconURL("internal-text");
                            break;
                        case GOPHER_INDEX:
                        case GOPHER_CSO:
-                           icon_type = "internal-gopher-index";
+                           icon_url = mimeGetIconURL("internal-index");
                            break;
                        case GOPHER_IMAGE:
                        case GOPHER_GIF:
                        case GOPHER_PLUS_IMAGE:
-                           icon_type = "internal-gopher-image";
+                           icon_url = mimeGetIconURL("internal-image");
                            break;
                        case GOPHER_SOUND:
                        case GOPHER_PLUS_SOUND:
-                           icon_type = "internal-gopher-sound";
+                           icon_url = mimeGetIconURL("internal-sound");
                            break;
                        case GOPHER_PLUS_MOVIE:
-                           icon_type = "internal-gopher-movie";
+                           icon_url = mimeGetIconURL("internal-movie");
                            break;
                        case GOPHER_TELNET:
                        case GOPHER_3270:
-                           icon_type = "internal-gopher-telnet";
+                           icon_url = mimeGetIconURL("internal-telnet");
                            break;
                        case GOPHER_BIN:
                        case GOPHER_MACBINHEX:
                        case GOPHER_DOSBIN:
                        case GOPHER_UUENCODED:
-                           icon_type = "internal-gopher-binary";
+                           icon_url = mimeGetIconURL("internal-binary");
                            break;
                        default:
-                           icon_type = "internal-gopher-unknown";
+                           icon_url = mimeGetIconURL("internal-unknown");
                            break;
                        }
 
@@ -550,14 +550,14 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len)
                        if ((gtype == GOPHER_TELNET) || (gtype == GOPHER_3270)) {
                            if (strlen(escaped_selector) != 0)
                                snprintf(tmpbuf, TEMP_BUF_SIZE, "<IMG BORDER=0 SRC=\"%s\"> <A HREF=\"telnet://%s@%s/\">%s</A>\n",
-                                   icon_type, escaped_selector, host, name);
+                                   icon_url, escaped_selector, host, name);
                            else
                                snprintf(tmpbuf, TEMP_BUF_SIZE, "<IMG BORDER=0 SRC=\"%s\"> <A HREF=\"telnet://%s/\">%s</A>\n",
-                                   icon_type, host, name);
+                                   icon_url, host, name);
 
                        } else {
                            snprintf(tmpbuf, TEMP_BUF_SIZE, "<IMG BORDER=0 SRC=\"%s\"> <A HREF=\"gopher://%s/%c%s\">%s</A>\n",
-                               icon_type, host, gtype, escaped_selector, name);
+                               icon_url, host, gtype, escaped_selector, name);
                        }
                        safe_free(escaped_selector);
                        strcat(outbuf, tmpbuf);
index 092ed42a24d7b9f8ea910e76484d19a24050984e..e84d76cc07a3bfe50eff37407357f3d128185cf5 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: mime.cc,v 1.54 1998/03/06 23:22:30 wessels Exp $
+ * $Id: mime.cc,v 1.55 1998/03/16 21:59:59 wessels Exp $
  *
  * DEBUG: section 25    MIME Parsing
  * AUTHOR: Harvest Derived
@@ -275,6 +275,20 @@ mimeGetIcon(const char *fn)
     return m->icon;
 }
 
+char *
+mimeGetIconURL(const char *fn)
+{
+    char *icon = mimeGetIcon(fn);
+    static char iconurl[256];
+    if (icon == NULL)
+       return NULL;
+    snprintf(iconurl, 256, "http://%s:%d/squid-internal/icons/%s",
+       getMyHostname(),
+       Config.Port.http->i,
+       icon);
+    return iconurl;
+}
+
 char *
 mimeGetContentType(const char *fn)
 {
@@ -407,9 +421,6 @@ mimeInit(char *filename)
      */
     for (m = MimeTable; m != NULL; m = m->next)
        mimeLoadIconFile(m->icon);
-    mimeLoadIconFile(ICON_MENU);
-    mimeLoadIconFile(ICON_DIRUP);
-    mimeLoadIconFile(ICON_LINK);
     debug(25, 1) ("Loaded Icons.\n");
 }
 
@@ -428,7 +439,8 @@ mimeLoadIconFile(const char *icon)
     const char *type = mimeGetContentType(icon);
     if (type == NULL)
        fatal("Unknown icon format while reading mime.conf\n");
-    snprintf(url, MAX_URL, "http://internal.squid/icons/%s", icon);
+    snprintf(url, MAX_URL, "http://%s:%d/squid-internal/icons/%s",
+       getMyHostname(), Config.Port.http->i, icon);
     key = storeKeyPublic(url, METHOD_GET);
     if (storeGet(key))
        return;
index 0076dde48304c2997dc06ed2411dd63b2eba796f..2400bcb8c7eb6ef97d9e19414b8b5e3c8d052a6d 100644 (file)
@@ -465,6 +465,7 @@ extern void mimeInit(char *filename);
 extern char *mimeGetContentEncoding(const char *fn);
 extern char *mimeGetContentType(const char *fn);
 extern char *mimeGetIcon(const char *fn);
+extern char *mimeGetIconURL(const char *fn);
 extern char mimeGetTransferMode(const char *fn);
 
 extern int mcastSetTtl(int, int);
index cdd47158fdfebc05a2501c6ad7f2668ac789a48e..64f4cb5e6b1f5b8da057f5bb1962fa7d005516c1 100644 (file)
@@ -654,6 +654,7 @@ struct _clientHttpRequest {
     log_type log_type;
     http_status http_code;
     int accel;
+    int internal;              /* Set to true on /squid-internal/ request, to prevent looping */
     struct timeval start;
     float http_ver;
     int redirect_state;