#
# 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:
#
DEFAULT_SWAP_DIR = $(localstatedir)/cache
DEFAULT_PINGER = $(libexecdir)/pinger
DEFAULT_UNLINKD = $(libexecdir)/unlinkd
+DEFAULT_ICON_DIR = $(sysconfdir)/icons
CC = @CC@
MAKEDEPEND = @MAKEDEPEND@
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 \
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
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
#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)
/*
- * $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
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);
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,
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,
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,
/*
- * $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
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)
{
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);
+}
/*
- * $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
return 1;
if (e->store_status == STORE_PENDING)
return 1;
+ if (BIT_TEST(e->flag, ENTRY_SPECIAL))
+ return 1;
return 0;
}
int n_configured;
} cacheSwap;
char *fake_ua;
+ struct {
+ char *directory;
+ char *content_type;
+ } icons;
};
struct _SquidConfig2 {