/*
- * $Id: cache_cf.cc,v 1.203 1997/07/14 19:56:14 wessels Exp $
+ * $Id: cache_cf.cc,v 1.204 1997/07/14 21:11:00 wessels Exp $
*
* DEBUG: section 3 Configuration File Parsing
* AUTHOR: Harvest Derived
static const char *const T_YEAR_STR = "year";
static const char *const T_DECADE_STR = "decade";
+static const char *const B_BYTES_STR = "bytes";
+static const char *const B_KBYTES_STR = "KB";
+static const char *const B_MBYTES_STR = "MB";
+static const char *const B_GBYTES_STR = "GB";
+
static const char *const list_sep = ", \t\n\r";
static char fatal_str[BUFSIZ];
static void default_all _PARAMS((void));
static int parse_line _PARAMS((char *));
static cache_peer *configFindPeer _PARAMS((const char *name));
+static void parseBytesLine _PARAMS((size_t *bptr, const char *units));
+static size_t parseBytesUnits _PARAMS((const char *unit));
/* These come from cf_gen.c */
static void default_all _PARAMS((void));
-static void dump_all _PARAMS((void));
static void free_all _PARAMS((void));
static void
}
}
- /* Scale values */
- Config.maxRequestSize <<= 10; /* 1k */
- Config.Store.maxObjectSize <<= 10; /* 1k */
- Config.Mem.maxSize <<= 10; /* 1m */
-
/* Sanity checks */
if (Config.Swap.maxSize < (Config.Mem.maxSize >> 10)) {
printf("WARNING: cache_swap (%d kbytes) is less than cache_mem (%d bytes).\n", Config.Swap.maxSize, Config.Mem.maxSize);
return 0;
}
+static void
+parseBytesLine(size_t *bptr, const char *units)
+{
+ char *token;
+ double d;
+ size_t m;
+ size_t u;
+ if ((u = parseBytesUnits(units)) == 0)
+ self_destruct();
+ if ((token = strtok(NULL, w_space)) == NULL)
+ self_destruct();
+ d = atof(token);
+ m = u; /* default to 'units' if none specified */
+ if ((token = strtok(NULL, w_space)) != NULL) {
+ if ((m = parseBytesUnits(token)) == 0)
+ self_destruct();
+ }
+ *bptr = m * d / u;
+}
+
+static size_t
+parseBytesUnits(const char *unit)
+{
+ if (!strncasecmp(unit, B_BYTES_STR, strlen(B_BYTES_STR)))
+ return 1;
+ if (!strncasecmp(unit, B_KBYTES_STR, strlen(B_KBYTES_STR)))
+ return 1<<10;
+ if (!strncasecmp(unit, B_MBYTES_STR, strlen(B_MBYTES_STR)))
+ return 1<<20;
+ if (!strncasecmp(unit, B_GBYTES_STR, strlen(B_GBYTES_STR)))
+ return 1<<30;
+ debug(3, 1) ("parseBytesUnits: unknown bytes unit '%s'\n", unit);
+ return 0;
+}
+
/*****************************************************************************
* Max
*****************************************************************************/
tmp->map = file_map_create(MAX_FILES_PER_DIR);
tmp->swaplog_fd = -1;
swap->n_configured++;
+ Config.Swap.maxSize += size;
}
static void
{
*var = 0;
}
-
+
+static void
+dump_size_t(size_t var)
+{
+ printf("%d bytes", (int) var);
+}
+
+static void
+dump_kb_size_t(size_t var)
+{
+ printf("%d KB", (int) var);
+}
+
+static void
+parse_size_t(size_t *var)
+{
+ parseBytesLine(var, B_BYTES_STR);
+}
+
+static void
+parse_kb_size_t(size_t *var)
+{
+ parseBytesLine(var, B_KBYTES_STR);
+}
+
+static void
+free_size_t(size_t *var)
+{
+ *var = 0;
+}
+
+#define free_kb_size_t free_size_t
+#define free_mb_size_t free_size_t
+#define free_gb_size_t free_size_t
static void
dump_ushort(u_short var)
NAME: cache_mem
-COMMENT: (in megabytes)
-TYPE: int
-DEFAULT: 8
+COMMENT: (bytes)
+TYPE: size_t
+DEFAULT: 8 MB
LOC: Config.Mem.maxSize
DOC_START
Maximum amout of VM used to store objects in memory.
The default is 8 Megabytes.
-cache_mem 8
+cache_mem 8 MB
DOC_END
NAME: maximum_object_size
-TYPE: int
-DEFAULT: 4096
+COMMENT: (KB)
+TYPE: kb_size_t
+DEFAULT: 4096 KB
LOC: Config.Store.maxObjectSize
DOC_START
Objects larger than this size will NOT be saved on disk. The
value is specified in kilobytes, and the default is 4MB.
-maximum_object_size 4096
+maximum_object_size 4096 KB
DOC_END
NAME: request_size
-TYPE: int
-DEFAULT: 100
+COMMENT: (KB)
+TYPE: kb_size_t
+DEFAULT: 100 KB
LOC: Config.maxRequestSize
DOC_START
Maximum allowed request size in kilobytes. If people are using
POST to upload files, then set this to the largest acceptable
filesize plus a few extra kbytes.
-request_size 100
+request_size 100 KB
DOC_END
NAME: quick_abort_min
-COMMENT: (kbytes)
-TYPE: int
+COMMENT: (KB)
+TYPE: kb_size_t
DEFAULT: -1
LOC: Config.quickAbort.min
DOC_NONE
DOC_NONE
NAME: quick_abort_max
-COMMENT: (kbytes)
-TYPE: int
+COMMENT: (KB)
+TYPE: kb_size_t
DEFAULT: 0
LOC: Config.quickAbort.max
DOC_START
/*
- * $Id: cf_gen.cc,v 1.6 1997/07/14 19:56:15 wessels Exp $
+ * $Id: cf_gen.cc,v 1.7 1997/07/14 21:11:01 wessels Exp $
*
* DEBUG: section 1 Startup and Main Loop
* AUTHOR: Max Okumoto
static const char WS[] = " \t";
+static const char NS[] = "";
static int gen_default(Entry *, FILE *);
static void gen_parse(Entry *, FILE *);
static void gen_dump(Entry *, FILE *);
Entry *curr = NULL;
enum State state;
int rc = 0;
+ char *ptr = NULL;
/*-------------------------------------------------------------------*
* Parse input file
case s1:
if ((strlen(buff) == 0) || (!strncmp(buff, "#", 1))) {
/* ignore empty and comment lines */
-
} else if (!strncmp(buff, "COMMENT:", 8)) {
- char *ptr = buff+8;
- while(isspace(*ptr))
- ptr++;
+ ptr = buff + 8;
+ while (isspace(*ptr))
+ ptr++;
curr->comment = strdup(ptr);
} else if (!strncmp(buff, "DEFAULT:", 8)) {
- char *ptr;
-
- if ((ptr = strtok(buff + 8, WS)) == NULL) {
- printf("Error on line %d\n", linenum);
- exit(1);
- }
+ ptr = buff + 8;
+ while (isspace(*ptr))
+ ptr++;
curr->default_value = strdup(ptr);
-
} else if (!strncmp(buff, "LOC:", 4)) {
- char *ptr;
-
if ((ptr = strtok(buff + 4, WS)) == NULL) {
printf("Error on line %d\n", linenum);
exit(1);
}
curr->loc = strdup(ptr);
-
} else if (!strncmp(buff, "TYPE:", 5)) {
- char *ptr;
-
if ((ptr = strtok(buff + 5, WS)) == NULL) {
printf("Error on line %d\n", linenum);
exit(1);
}
curr->type = strdup(ptr);
-
} else if (!strcmp(buff, "DOC_START")) {
state = sDOC;
-
} else if (!strcmp(buff, "DOC_NONE")) {
/* add to list of entries */
curr->next = entries;
entries = curr;
-
state = sSTART;
-
} else {
printf("Error on line %d\n", linenum);
exit(1);
"default_line(const char *s)\n"
"{\n"
"\tLOCAL_ARRAY(char, tmp_line, BUFSIZ);\n"
- "\txstrncpy(tmp_line, s, BUFSIZ);\n"
- "\txstrncpy(config_input_line, s, BUFSIZ);\n"
+ "\txstrncpy(tmp_line, s, BUFSIZ);\n"
+ "\txstrncpy(config_input_line, s, BUFSIZ);\n"
"\tconfig_lineno++;\n"
- "\tparse_line(tmp_line);\n"
+ "\tparse_line(tmp_line);\n"
"}\n"
);
fprintf(fp, "# TAG: %s", entry->name);
if (entry->comment)
- fprintf(fp, "\t%s", entry->comment);
+ fprintf(fp, "\t%s", entry->comment);
fprintf(fp, "\n");
for (line = entry->doc; line != NULL; line = line->next) {
fprintf(fp, "#%s\n", line->data);
/*
- * $Id: ftp.cc,v 1.129 1997/06/26 22:41:41 wessels Exp $
+ * $Id: ftp.cc,v 1.130 1997/07/14 21:11:02 wessels Exp $
*
* DEBUG: section 9 File Transfer Protocol (FTP)
* AUTHOR: Harvest Derived
}
if (len == 0) {
debug(9, 1) ("Read 0 bytes from FTP control socket?\n");
+ assert(len);
BIT_RESET(entry->flag, ENTRY_CACHABLE);
storeReleaseRequest(entry);
storeAbort(entry, ERR_READ_ERROR, xstrerror(), 0);
extern void wordlistDestroy _PARAMS((wordlist **));
extern void configFreeMemory _PARAMS((void));
extern char *cachemgr_getpassword _PARAMS((cachemgr_passwd **, char *));
+extern void dump_all _PARAMS((void));
extern void cbdataInit _PARAMS((void));
extern void cbdataAdd _PARAMS((void *p));
/*
- * $Id: store.cc,v 1.267 1997/07/14 19:53:12 wessels Exp $
+ * $Id: store.cc,v 1.268 1997/07/14 21:11:04 wessels Exp $
*
* DEBUG: section 20 Storeage Manager
* AUTHOR: Harvest Derived
store_maintain_buckets == 1 ? null_string : "s",
store_maintain_rate,
store_maintain_rate == 1 ? null_string : "s");
+ debug(20,1)("Max Mem size: %d KB\n", Config.Mem.maxSize>>10);
+ debug(20,1)("Max Swap size: %d KB\n", Config.Swap.maxSize);
}
void
struct _SquidConfig {
struct {
- int maxSize;
+ size_t maxSize;
int highWaterMark;
int lowWaterMark;
} Mem , Swap;
u_short relayPort;
} Wais;
struct {
- int min;
+ size_t min;
int pct;
- int max;
+ size_t max;
} quickAbort;
time_t referenceAge;
time_t negativeTtl;
time_t connect;
time_t request;
} Timeout;
- int maxRequestSize;
+ size_t maxRequestSize;
struct {
ushortlist *http;
u_short icp;
struct in_addr udp_outgoing;
struct in_addr client_netmask;
} Addrs;
- int tcpRcvBufsz;
- int udpMaxHitObjsz;
+ size_t tcpRcvBufsz;
+ size_t udpMaxHitObjsz;
wordlist *cache_stoplist;
wordlist *hierarchy_stoplist;
wordlist *mcast_group_list;
cache_peer *sslProxy;
cache_peer *passProxy;
struct {
- int size;
+ size_t size;
int low;
int high;
} ipcache;
cachemgr_passwd *passwd_list;
struct {
int objectsPerBucket;
- int avgObjectSize;
- int maxObjectSize;
+ size_t avgObjectSize;
+ size_t maxObjectSize;
} Store;
struct {
int high;