]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Started internal icon support
authorwessels <>
Sat, 19 Jul 1997 07:33:53 +0000 (07:33 +0000)
committerwessels <>
Sat, 19 Jul 1997 07:33:53 +0000 (07:33 +0000)
src/Makefile.in
src/cf.data.pre
src/defines.h
src/ftp.cc
src/mime.cc
src/store.cc
src/structs.h

index c5e6f9098cd6b4e6fcf54cb56c6570ee5947c218..cc30a938f5b5d3825ee8634673567934efd5760e 100644 (file)
@@ -1,7 +1,7 @@
 #
 #  Makefile for the Squid Object Cache server
 #
-#  $Id: Makefile.in,v 1.82 1997/07/14 03:33:33 wessels Exp $
+#  $Id: Makefile.in,v 1.83 1997/07/19 01:33:53 wessels Exp $
 #
 #  Uncomment and customize the following to suit your needs:
 #
@@ -41,6 +41,7 @@ DEFAULT_PID_FILE        = $(localstatedir)/logs/squid.pid
 DEFAULT_SWAP_DIR        = $(localstatedir)/cache
 DEFAULT_PINGER         = $(libexecdir)/pinger
 DEFAULT_UNLINKD                = $(libexecdir)/unlinkd
+DEFAULT_ICON_DIR       = $(sysconfdir)/icons
 
 CC             = @CC@
 MAKEDEPEND     = @MAKEDEPEND@
@@ -178,7 +179,8 @@ cf.data: cf.data.pre Makefile
        s%@DEFAULT_ACCESS_LOG@%$(DEFAULT_ACCESS_LOG)%g;\
        s%@DEFAULT_STORE_LOG@%$(DEFAULT_STORE_LOG)%g;\
        s%@DEFAULT_PID_FILE@%$(DEFAULT_PID_FILE)%g;\
-       s%@DEFAULT_SWAP_DIR@%$(DEFAULT_SWAP_DIR)%g" < cf.data.pre >$@
+       s%@DEFAULT_SWAP_DIR@%$(DEFAULT_SWAP_DIR)%g;\
+       s%@DEFAULT_ICON_DIR@%$(DEFAULT_ICON_DIR)%g" < cf.data.pre >$@
 
 install-mkdirs:
        -@if test ! -d $(prefix); then \
index 2bbccb657117353cafc63f55a54244caa892a41e..983b2c2f79c54373c5aa542d73bb766795db40c4 100644 (file)
@@ -714,6 +714,14 @@ DOC_START
 ftp_user squid@
 DOC_END
 
+NAME: ftp_list_width
+TYPE: int
+DEFAULT: 32
+LOC: Config.Ftp.list_width
+DOC_START
+ftp_list_width 32
+DOC_END
+
 
 NAME: cache_dns_program
 TYPE: pathname_stat
@@ -1834,5 +1842,20 @@ DOC_START
 fake_user_agent none
 DOC_END
 
+NAME: icon_directory
+TYPE: pathname_stat
+LOC: Config.icons.directory
+DEFAULT: @DEFAULT_ICON_DIR@
+DOC_START
+       XXX
+DOC_END
+
+NAME: icon_content_type
+TYPE: string
+LOC: Config.icons.content_type
+DEFAULT: image/gif
+DOC_START
+       XXX
+DOC_END
 
 EOF
index 6222423b0e75547ac3213aaa7fa3dca7fda5a011..4e150497fb4f81f2350278a088cdbf3a38304401 100644 (file)
 #define DELAY_SENDING          (1<<3)
 #define ENTRY_REVALIDATE       (1<<2)
 #define DELETE_BEHIND          (1<<1)
+#define ENTRY_SPECIAL          (1<<0)
 
 #define MAX_FILES_PER_DIR (1<<20)
 
index 15733daef1f680f2eef3c5bd64d309b67284f3d5..108ece04ec4aadd2a81ca33537ce9bcb415818c3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ftp.cc,v 1.133 1997/07/16 22:57:02 wessels Exp $
+ * $Id: ftp.cc,v 1.134 1997/07/19 01:33:55 wessels Exp $
  *
  * DEBUG: section 9     File Transfer Protocol (FTP)
  * AUTHOR: Harvest Derived
@@ -461,10 +461,9 @@ ftpHtmlifyListEntry(char *line, int flags)
     ftpListParts *parts;
     /* check .. as special case */
     if (!strcmp(line, "..")) {
-       sprintf(icon, "<IMG BORDER=0 SRC=\"%s%s%s\" ALT=\"%-6s\">",
-           Config.Ftp.icon_prefix,
-           "gopher-menu",
-           Config.Ftp.icon_suffix,
+       sprintf(icon, "<IMG BORDER=0 SRC=\"%s%s\" ALT=\"%-6s\">",
+           "http://internal.squid/icons/",
+           "menu",
            "[DIR]");
        sprintf(link, "<A HREF=\"%s\">%s</A>", "../", "Parent Directory");
        sprintf(html, "%s %s\n", icon, link);
@@ -495,10 +494,9 @@ ftpHtmlifyListEntry(char *line, int flags)
     ename = xstrdup(rfc1738_escape(parts->name));
     switch (parts->type) {
     case 'd':
-       sprintf(icon, "<IMG SRC=\"%sgopher-%s%s\" ALT=\"%-6s\">",
-           Config.Ftp.icon_prefix,
+       sprintf(icon, "<IMG SRC=\"%s%s\" ALT=\"%-6s\">",
+           "http://internal.squid/icons/",
            "menu",
-           Config.Ftp.icon_suffix,
            "[DIR]");
        sprintf(link, "<A HREF=\"%s/\">%s</A>%s",
            ename,
@@ -510,10 +508,9 @@ ftpHtmlifyListEntry(char *line, int flags)
            parts->date);
        break;
     case 'l':
-       sprintf(icon, "<IMG SRC=\"%sgopher-%s%s\" ALT=\"%-6s\">",
-           Config.Ftp.icon_prefix,
+       sprintf(icon, "<IMG SRC=\"%s%s\" ALT=\"%-6s\">",
+           "http://internal.squid/icons/",
            mimeGetIcon(parts->link),
-           Config.Ftp.icon_suffix,
            "[LINK]");
        sprintf(link, "<A HREF=\"%s\">%s</A>%s",
            ename,
@@ -526,10 +523,9 @@ ftpHtmlifyListEntry(char *line, int flags)
        break;
     case '-':
     default:
-       sprintf(icon, "<IMG SRC=\"%sgopher-%s%s\" ALT=\"%-6s\">",
-           Config.Ftp.icon_prefix,
+       sprintf(icon, "<IMG SRC=\"%s%s\" ALT=\"%-6s\">",
+           "http://internal.squid/icons/",
            mimeGetIcon(parts->name),
-           Config.Ftp.icon_suffix,
            "[FILE]");
        sprintf(link, "<A HREF=\"%s\">%s</A>%s",
            ename,
index a0a279fac3a6f2a65e2e7a230448328db61f3095..8938ca60e4f52d2658c4eb4a8d6db841f3369538 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: mime.cc,v 1.32 1997/07/16 22:57:42 wessels Exp $
+ * $Id: mime.cc,v 1.33 1997/07/19 01:33:57 wessels Exp $
  *
  * DEBUG: section 25    MIME Parsing
  * AUTHOR: Harvest Derived
@@ -120,6 +120,8 @@ typedef struct _mime_entry {
 static mimeEntry *MimeTable = NULL;
 static mimeEntry **MimeTableTail = NULL;
 
+static void mimeLoadIconFile _PARAMS((const char *icon));
+
 char *
 mime_get_header(const char *mime, const char *name)
 {
@@ -368,9 +370,63 @@ mimeInit(char *filename)
            m->transfer_mode = 'A';
        else
            m->transfer_mode = 'I';
+       mimeLoadIconFile(m->icon);
        debug(25, 5) ("mimeInit: added '%s'\n", buf);
        *MimeTableTail = m;
        MimeTableTail = &m->next;
     }
     fclose(fp);
 }
+
+static void
+mimeLoadIconFile(const char *icon)
+{
+       int fd;
+       int n;
+       int l;
+       struct stat sb;
+       StoreEntry *e;
+       LOCAL_ARRAY(char, path, MAXPATHLEN);
+       LOCAL_ARRAY(char, url, MAX_URL);
+       char *buf;
+       snprintf(url, MAX_URL, "http://internal.squid/icons/%s", icon);
+       if (storeGet(url))
+               return;
+       snprintf(path, MAXPATHLEN, "%s/%s", Config.icons.directory, icon);
+       fd = file_open(path, O_RDONLY, NULL, NULL);
+       if (fd < 0) {
+               debug(25,0)("mimeLoadIconFile: %s: %s\n", path, xstrerror());
+               return;
+       }
+       if (fstat(fd, &sb) < 0) {
+               debug(50,0)("mimeLoadIconFile: FD %d: fstat: %s\n", fd, xstrerror());
+               return;
+       }
+       e = storeCreateEntry(url,
+               url,
+               REQ_CACHABLE,
+               METHOD_GET);
+       assert(e != NULL);
+       e->mem_obj->request = requestLink(urlParse(METHOD_GET, url));
+       buf = get_free_4k_page();
+       l = 0;
+       l += snprintf(buf+l, SM_PAGE_SIZE-l, "HTTP/1.0 200 OK\r\n");
+       l += snprintf(buf+l, SM_PAGE_SIZE-l, "Date: %s\r\n", mkrfc1123(squid_curtime));
+       l += snprintf(buf+l, SM_PAGE_SIZE-l, "Server: Squid/%s\r\n", version_string);
+       l += snprintf(buf+l, SM_PAGE_SIZE-l, "Content-Type: %s\r\n", Config.icons.content_type);
+       l += snprintf(buf+l, SM_PAGE_SIZE-l, "Content-Length: %d\r\n", (int) sb.st_size);
+       l += snprintf(buf+l, SM_PAGE_SIZE-l, "Last-Modified: %s\r\n", mkrfc1123(sb.st_mtime));
+       l += snprintf(buf+l, SM_PAGE_SIZE-l, "Expires: %s\r\n", mkrfc1123(squid_curtime + 86400));
+       l += snprintf(buf+l, SM_PAGE_SIZE-l, "\r\n");
+       httpParseReplyHeaders(buf, e->mem_obj->reply);
+       storeAppend(e, buf, l);
+       while ((n = read(fd, buf, SM_PAGE_SIZE)) > 0)
+               storeAppend(e, buf, n);
+       file_close(fd);
+       storeSetPublicKey(e);
+       storeComplete(e);
+       storeTimestampsSet(e);
+       BIT_SET(e->flag, ENTRY_SPECIAL);
+       debug(25,1)("Loaded icon %s\n", url);
+       put_free_4k_page(buf);
+}
index df99bc28e86372f7652546bf883e5b80aa2d63d4..349d4ba862abdfe343096b5a8e881aec9392a46d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.276 1997/07/16 22:58:25 wessels Exp $
+ * $Id: store.cc,v 1.277 1997/07/19 01:33:58 wessels Exp $
  *
  * DEBUG: section 20    Storeage Manager
  * AUTHOR: Harvest Derived
@@ -2065,6 +2065,8 @@ storeEntryLocked(const StoreEntry * e)
        return 1;
     if (e->store_status == STORE_PENDING)
        return 1;
+    if (BIT_TEST(e->flag, ENTRY_SPECIAL))
+       return 1;
     return 0;
 }
 
index 7470c0c273b7ddde41d56832956939b03ff4e88e..5205f52737d5b9281e3ee8c69ae0684f57eb0203 100644 (file)
@@ -232,6 +232,10 @@ struct _SquidConfig {
        int n_configured;
     } cacheSwap;
     char *fake_ua;
+    struct {
+       char *directory;
+       char *content_type;
+    } icons;
 };
 
 struct _SquidConfig2 {