/*
- * $Id: HttpHeader.cc,v 1.14 1998/03/05 00:01:07 rousskov Exp $
+ * $Id: HttpHeader.cc,v 1.15 1998/03/05 00:42:42 wessels Exp $
*
* DEBUG: section 55 HTTP Header
* AUTHOR: Alex Rousskov
* some compilers do not want to convert a type into a union which that type
* belongs to
*/
-field_store intField(int n) { field_store f; f.v_int = n; return f; }
-field_store timeField(time_t t) { field_store f; f.v_time = t; return f; }
-field_store ptrField(void *p) { field_store f; f.v_pchar = (char*)p; return f; }
+field_store
+intField(int n)
+{
+ field_store f;
+ f.v_int = n;
+ return f;
+}
+field_store
+timeField(time_t t)
+{
+ field_store f;
+ f.v_time = t;
+ return f;
+}
+field_store
+ptrField(void *p)
+{
+ field_store f;
+ f.v_pchar = (char *) p;
+ return f;
+}
/*
* Module initialization routines
{
assert(hdr && pos);
assert(*pos >= HttpHeaderInitPos && *pos < hdr->capacity);
- debug(55,8) ("searching next e in hdr %p from %d\n", hdr, *pos);
+ debug(55, 8) ("searching next e in hdr %p from %d\n", hdr, *pos);
for ((*pos)++; *pos < hdr->ucount; (*pos)++) {
HttpHeaderEntry *e = hdr->entries + *pos;
if (httpHeaderEntryIsValid(e)) {
httpHeaderGetInt(const HttpHeader * hdr, http_hdr_type id)
{
assert_eid(id);
- assert(Headers[id].type == ftInt); /* must be of an apropriate type */
+ assert(Headers[id].type == ftInt); /* must be of an apropriate type */
return httpHeaderGet(hdr, id).v_int;
}
httpHeaderGetStr(const HttpHeader * hdr, http_hdr_type id)
{
assert_eid(id);
- assert(Headers[id].type == ftPChar); /* must be of an apropriate type */
+ assert(Headers[id].type == ftPChar); /* must be of an apropriate type */
return httpHeaderGet(hdr, id).v_pchar;
}
return ptrField(NULL); /* not reached */
}
-#if 0 /* moved to HttpHdrCC.c */
+#if 0 /* moved to HttpHdrCC.c */
/*
* HttpScc (server cache control)
shortStringStatDump(StoreEntry * e)
{
storeAppendPrintf(e, "<h3>Short String Stats</h3>\n<p>");
- memPoolReport(shortStrings, e);
+ memPoolReport(shortStrings, e);
storeAppendPrintf(e, "\n</p>\n");
storeAppendPrintf(e, "<br><h3>Long String Stats</h3>\n");
storeAppendPrintf(e, "alive: %3d (%5.1f KB) high-water: %3d (%5.1f KB)\n",
/*
- * $Id: HttpReply.cc,v 1.10 1998/03/05 00:01:08 rousskov Exp $
+ * $Id: HttpReply.cc,v 1.11 1998/03/05 00:42:43 wessels Exp $
*
* DEBUG: section 58 HTTP Reply (Response)
* AUTHOR: Alex Rousskov
httpReplyCreate()
{
HttpReply *rep = memAllocate(MEM_HTTPREPLY);
- debug(58,7) ("creating rep: %p\n", rep);
+ debug(58, 7) ("creating rep: %p\n", rep);
httpReplyInit(rep);
return rep;
}
httpReplyDestroy(HttpReply * rep)
{
assert(rep);
- debug(58,7) ("destroying rep: %p\n", rep);
+ debug(58, 7) ("destroying rep: %p\n", rep);
httpReplyClean(rep);
httpReplyDoDestroy(rep);
}
/*
- * $Id: HttpStatusLine.cc,v 1.6 1998/03/03 22:17:51 rousskov Exp $
+ * $Id: HttpStatusLine.cc,v 1.7 1998/03/05 00:42:44 wessels Exp $
*
* DEBUG: section 57 HTTP Status-line
* AUTHOR: Alex Rousskov
httpStatusLinePackInto(const HttpStatusLine * sline, Packer * p)
{
assert(sline && p);
- debug(57,9) ("packing sline %p using %p:\n", sline, p);
- debug(57,9) (HttpStatusLineFormat, sline->version, sline->status,
+ debug(57, 9) ("packing sline %p using %p:\n", sline, p);
+ debug(57, 9) (HttpStatusLineFormat, sline->version, sline->status,
sline->reason ? sline->reason : httpStatusString(sline->status));
packerPrintf(p, HttpStatusLineFormat,
sline->version, sline->status,
/*
- * $Id: StatHist.cc,v 1.4 1998/03/04 06:23:28 rousskov Exp $
+ * $Id: StatHist.cc,v 1.5 1998/03/05 00:42:45 wessels Exp $
*
* DEBUG: section 62 Generic Histogram
* AUTHOR: Duane Wessels
/* a max value should go into the last bin */
assert(statHistBin(H, max) == H->capacity - 1);
/* it is hard to test val_out, here is a crude test */
- assert(((int)(0.99+statHistVal(H, 0)-min)) == 0);
+ assert(((int) (0.99 + statHistVal(H, 0) - min)) == 0);
}
void
/*
- * $Id: cachemgr.cc,v 1.74 1998/03/03 21:58:49 rousskov Exp $
+ * $Id: cachemgr.cc,v 1.75 1998/03/05 00:42:47 wessels Exp $
*
* DEBUG: section 0 CGI Cache Manager
* AUTHOR: Duane Wessels
const char *p;
char *a_url;
char *buf_copy;
- static char html[2*1024];
+ static char html[2 * 1024];
if (strlen(buf) < 1)
return buf;
if (*buf != ' ')
static const char *
munge_other_line(const char *buf, cachemgr_request * req)
{
- static const char* ttags[] = { "td", "th" };
+ static const char *ttags[] =
+ {"td", "th"};
static char html[4096];
static table_line_num = 0;
static next_is_header = 0;
}
/* start html table */
if (!table_line_num) {
- l += snprintf(html+l, sizeof(html)-l, "</pre><table border=1 cellpadding=2 cellspacing=1>\n");
+ l += snprintf(html + l, sizeof(html) - l, "</pre><table border=1 cellpadding=2 cellspacing=1>\n");
next_is_header = 0;
}
/* remove '\n' */
is_header = (!table_line_num || next_is_header) && !strchr(buf, ':') && !is_number(buf);
ttag = ttags[is_header];
/* record starts */
- l += snprintf(html+l, sizeof(html)-l, "<tr>");
+ l += snprintf(html + l, sizeof(html) - l, "<tr>");
/* substitute '\t' */
buf_copy = x = xstrdup(buf);
- if ((p = strchr(x, '\n'))) *p = '\0';
+ if ((p = strchr(x, '\n')))
+ *p = '\0';
while (x && strlen(x)) {
int column_span = 1;
const char *cell = xstrtok(&x, '\t');
- while (x && *x == '\t') { column_span++; x++; }
- l += snprintf(html+l, sizeof(html)-l, "<%s colspan=%d align=\"%s\">%s</%s>",
+ while (x && *x == '\t') {
+ column_span++;
+ x++;
+ }
+ l += snprintf(html + l, sizeof(html) - l, "<%s colspan=%d align=\"%s\">%s</%s>",
ttag, column_span,
is_header ? "center" : is_number(cell) ? "right" : "left",
cell, ttag);
}
xfree(buf_copy);
/* record ends */
- l += snprintf(html+l, sizeof(html)-l, "</tr>\n");
+ l += snprintf(html + l, sizeof(html) - l, "</tr>\n");
next_is_header = is_header && strstr(buf, "\t\t");
table_line_num++;
return html;
+
/*
- * $Id: client.cc,v 1.57 1998/02/26 18:00:39 wessels Exp $
+ * $Id: client.cc,v 1.58 1998/03/05 00:42:48 wessels Exp $
*
* DEBUG: section 0 WWW Client
* AUTHOR: Harvest Derived
#define N_COUNT_HIST (3600 / COUNT_INTERVAL) + 1
/*
* keep 3 days' (72 hours) worth of hourly readings
-*/
+ */
#define N_COUNT_HOUR_HIST (86400 * 3) / (60 * COUNT_INTERVAL)
/* were to look for errors if config path fails */
/* possible types for http header fields */
typedef enum {
- ftInvalid = HDR_ENUM_END, /* to catch nasty errors with hdr_id<->fld_type clashes */
+ ftInvalid = HDR_ENUM_END, /* to catch nasty errors with hdr_id<->fld_type clashes */
ftInt,
ftPChar,
ftDate_1123,
/*
- * $Id: fqdncache.cc,v 1.89 1998/03/03 22:17:52 rousskov Exp $
+ * $Id: fqdncache.cc,v 1.90 1998/03/05 00:42:51 wessels Exp $
*
* DEBUG: section 35 FQDN Cache
* AUTHOR: Harvest Derived
case NET_FQDN_NAME:
Answer->type = SMI_STRING;
Answer->val_len = strlen(fq->names[0]);
- Answer->val.string = (u_char *)xstrdup(fq->names[0]);
+ Answer->val.string = (u_char *) xstrdup(fq->names[0]);
break;
case NET_FQDN_IP:
Answer->type = SMI_IPADDRESS;
/*
- * $Id: ftp.cc,v 1.200 1998/03/04 23:52:39 wessels Exp $
+ * $Id: ftp.cc,v 1.201 1998/03/05 00:42:52 wessels Exp $
*
* DEBUG: section 9 File Transfer Protocol (FTP)
* AUTHOR: Harvest Derived
if (size > 0) {
fd_bytes(fd, size, FD_WRITE);
kb_incr(&Counter.server.all.kbytes_out, size);
- kb_incr(&Counter.server.ftp.kbytes_out, size);
+ kb_incr(&Counter.server.ftp.kbytes_out, size);
}
if (errflag == COMM_ERR_CLOSING)
return;
if (len > 0) {
fd_bytes(fd, len, FD_READ);
kb_incr(&Counter.server.all.kbytes_in, len);
- kb_incr(&Counter.server.ftp.kbytes_in,len);
+ kb_incr(&Counter.server.ftp.kbytes_in, len);
}
debug(9, 5) ("ftpReadControlReply: FD %d, Read %d bytes\n", fd, len);
if (len < 0) {
/*
- * $Id: gopher.cc,v 1.121 1998/03/04 23:52:41 wessels Exp $
+ * $Id: gopher.cc,v 1.122 1998/03/05 00:42:53 wessels Exp $
*
* DEBUG: section 10 Gopher
* AUTHOR: Harvest Derived
if (size > 0) {
fd_bytes(fd, size, FD_WRITE);
kb_incr(&Counter.server.all.kbytes_out, size);
- kb_incr(&Counter.server.other.kbytes_out, size);
+ kb_incr(&Counter.server.other.kbytes_out, size);
}
if (errflag) {
ErrorState *err;
/*
- * $Id: http.cc,v 1.245 1998/03/05 00:01:11 rousskov Exp $
+ * $Id: http.cc,v 1.246 1998/03/05 00:42:55 wessels Exp $
*
* DEBUG: section 11 Hypertext Transfer Protocol (HTTP)
* AUTHOR: Harvest Derived
if (size > 0) {
fd_bytes(fd, size, FD_WRITE);
kb_incr(&Counter.server.all.kbytes_out, size);
- kb_incr(&Counter.server.http.kbytes_out, size);
+ kb_incr(&Counter.server.http.kbytes_out, size);
}
if (errflag == COMM_ERR_CLOSING)
return;
/*
- * $Id: ipcache.cc,v 1.164 1998/03/03 22:17:53 rousskov Exp $
+ * $Id: ipcache.cc,v 1.165 1998/03/05 00:42:57 wessels Exp $
*
* DEBUG: section 14 IP Cache
* AUTHOR: Harvest Derived
xfree(Answer->val.integer);
Answer->type = SMI_STRING;
Answer->val_len = strlen(IPc->name);
- Answer->val.string = (u_char *)xstrdup(IPc->name);
+ Answer->val.string = (u_char *) xstrdup(IPc->name);
break;
case NET_IPC_IP:
Answer->type = SMI_IPADDRESS;
/*
- * $Id: main.cc,v 1.231 1998/03/03 00:31:08 rousskov Exp $
+ * $Id: main.cc,v 1.232 1998/03/05 00:42:58 wessels Exp $
*
* DEBUG: section 1 Startup and Main Loop
* AUTHOR: Harvest Derived
debug_log = stderr;
if (FD_SETSIZE < Squid_MaxFD)
Squid_MaxFD = FD_SETSIZE;
-
+
/* call mallopt() before anything else */
#if HAVE_MALLOPT
#ifdef M_GRAIN
}
#endif
#if MEM_GEN_TRACE
- log_trace_done();
+ log_trace_done();
#endif
debug(1, 0) ("Squid Cache (Version %s): Exiting normally.\n",
/*
- * $Id: mem.cc,v 1.10 1998/03/05 00:01:11 rousskov Exp $
+ * $Id: mem.cc,v 1.11 1998/03/05 00:42:59 wessels Exp $
*
* DEBUG: section 13 High Level Memory Pool Management
* AUTHOR: Harvest Derived
if (dirty_count)
debug(13, 2) ("memClean: %d pools are left dirty\n", dirty_count);
else
- memCleanModule(); /* will free chunks and stuff */
+ memCleanModule(); /* will free chunks and stuff */
}
extern void memInitModule();
extern void memCleanModule();
extern void memConfigure();
-#if 0 /* not used */
+#if 0 /* not used */
extern void memFreeMemory(void);
#endif
extern void *memAllocate(mem_type);
extern int memInUse(mem_type);
extern DynPool *dynPoolCreate();
-extern void dynPoolDestroy(DynPool *pool);
-extern void *dynPoolAlloc(DynPool *pool, size_t size);
-extern void dynPoolFree(DynPool *pool, void *obj, size_t size);
+extern void dynPoolDestroy(DynPool * pool);
+extern void *dynPoolAlloc(DynPool * pool, size_t size);
+extern void dynPoolFree(DynPool * pool, void *obj, size_t size);
extern MemPool *memPoolCreate(const char *label, size_t obj_size);
-extern void memPoolDestroy(MemPool *pool);
-extern void *memPoolAlloc(MemPool *pool);
-extern void memPoolFree(MemPool *pool, void *obj);
-extern int memPoolWasUsed(const MemPool *pool);
-extern int memPoolInUseCount(const MemPool *pool);
-extern size_t memPoolInUseSize(const MemPool *pool);
-extern int memPoolUsedCount(const MemPool *pool);
-extern void memPoolDescribe(const MemPool *pool);
-extern void memPoolReport(const MemPool *pool, StoreEntry *e);
-extern void memReport(StoreEntry *e);
+extern void memPoolDestroy(MemPool * pool);
+extern void *memPoolAlloc(MemPool * pool);
+extern void memPoolFree(MemPool * pool, void *obj);
+extern int memPoolWasUsed(const MemPool * pool);
+extern int memPoolInUseCount(const MemPool * pool);
+extern size_t memPoolInUseSize(const MemPool * pool);
+extern int memPoolUsedCount(const MemPool * pool);
+extern void memPoolDescribe(const MemPool * pool);
+extern void memPoolReport(const MemPool * pool, StoreEntry * e);
+extern void memReport(StoreEntry * e);
extern int stmemFreeDataUpto(mem_hdr *, int);
extern void stmemAppend(mem_hdr *, const char *, int);
extern void kb_incr(kb_t *, size_t);
extern double gb_to_double(const gb_t *);
extern const char *gb_to_str(const gb_t *);
-extern void gb_flush(gb_t *); /* internal, do not use this */
+extern void gb_flush(gb_t *); /* internal, do not use this */
/*
* prototypes for system functions missing from system includes
cbdataAdd(rq, MEM_NONE);
PDU = snmp_pdu_create(0);
Community = snmp_parse(Session, PDU, buf, len);
-
- if (!snmp_coexist_V2toV1(PDU)) { /* incompatibility */
- debug(49, 3) ("snmp_agent_parse: Incompatible V2 packet.\n");
- snmp_free_pdu(PDU);
- snmp_agent_parse_done(0, rq);
- return;
+
+ if (!snmp_coexist_V2toV1(PDU)) { /* incompatibility */
+ debug(49, 3) ("snmp_agent_parse: Incompatible V2 packet.\n");
+ snmp_free_pdu(PDU);
+ snmp_agent_parse_done(0, rq);
+ return;
}
rq->community = Community;
rq->PDU = PDU;
/*
- * $Id: stat.cc,v 1.213 1998/03/05 00:40:54 wessels Exp $
+ * $Id: stat.cc,v 1.214 1998/03/05 00:43:06 wessels Exp $
*
* DEBUG: section 18 Cache Manager Statistics
* AUTHOR: Harvest Derived
hours = N_COUNT_HOUR_HIST - 1;
l = &CountHourHist[hours];
} else {
- debug(18,1)("statAvgDump: Invalid args, minutes=%d, hours=%d\n",
- minutes, hours);
+ debug(18, 1) ("statAvgDump: Invalid args, minutes=%d, hours=%d\n",
+ minutes, hours);
return;
}
dt = tvSubDsec(l->timestamp, f->timestamp);
ct = f->cputime - l->cputime;
- storeAppendPrintf(sentry, "sample_start_time = %d.%d (%s)\n",
- f->timestamp.tv_sec,
+ storeAppendPrintf(sentry, "sample_start_time = %d.%d (%s)\n",
+ f->timestamp.tv_sec,
f->timestamp.tv_usec,
mkrfc1123(f->timestamp.tv_sec));
- storeAppendPrintf(sentry, "sample_end_time = %d.%d (%s)\n",
- l->timestamp.tv_sec,
+ storeAppendPrintf(sentry, "sample_end_time = %d.%d (%s)\n",
+ l->timestamp.tv_sec,
l->timestamp.tv_usec,
mkrfc1123(l->timestamp.tv_sec));
f->cputime = rusage_cputime(&rusage);
storeAppendPrintf(sentry, "sample_time = %d.%d (%s)\n",
- f->timestamp.tv_sec,
+ f->timestamp.tv_sec,
f->timestamp.tv_usec,
mkrfc1123(f->timestamp.tv_sec));
storeAppendPrintf(sentry, "client_http.requests = %d\n",
+
struct _acl_ip_data {
struct in_addr addr1; /* if addr2 non-zero then its a range */
struct in_addr addr2;
};
-/* http cache control header field*/
+/* http cache control header field */
struct _HttpHdrCc {
int mask;
time_t max_age;
/* per field statistics */
struct _HttpHeaderFieldStat {
- int aliveCount; /* created but not destroyed (count) */
- int parsCount; /* #parsing attempts */
- int errCount; /* #pasring errors */
- int repCount; /* #repetitons */
+ int aliveCount; /* created but not destroyed (count) */
+ int parsCount; /* #parsing attempts */
+ int errCount; /* #pasring errors */
+ int repCount; /* #repetitons */
};
int errors;
kb_t kbytes_in;
kb_t kbytes_out;
- } all,http,ftp,other;
+ } all , http, ftp, other;
} server;
struct {
int pkts_sent;
/*
- * $Id: tools.cc,v 1.150 1998/03/04 23:48:14 rousskov Exp $
+ * $Id: tools.cc,v 1.151 1998/03/05 00:43:09 wessels Exp $
*
* DEBUG: section 21 Misc Functions
* AUTHOR: Harvest Derived
static void safeunlinkComplete(void *data, int retcode, int errcode);
#endif
#if MEM_GEN_TRACE
-extern void log_trace_done();
+extern void log_trace_done();
extern void log_trace_init(char *);
-#endif
+#endif
void
releaseServerSockets(void)
}
void
-gb_flush(gb_t *g)
+gb_flush(gb_t * g)
{
g->gb += (g->bytes >> 30);
- g->bytes &= (1<<30)-1;
+ g->bytes &= (1 << 30) - 1;
}
double
-gb_to_double(const gb_t *g)
+gb_to_double(const gb_t * g)
{
- return ((double)g->gb)*((double)(1<<30)) + ((double)g->bytes);
+ return ((double) g->gb) * ((double) (1 << 30)) + ((double) g->bytes);
}
const char *
-gb_to_str(const gb_t *g)
+gb_to_str(const gb_t * g)
{
/*
* it is often convenient to call gb_to_str several times for _one_ printf
*/
- #define max_cc_calls 5
+#define max_cc_calls 5
typedef char GbBuf[32];
static GbBuf bufs[max_cc_calls];
static int call_id = 0;
char *buf = bufs[call_id++];
/* select format */
if (value < 1e9)
- snprintf(buf, sizeof(GbBuf), "%.2f MB", value/1e6);
- else
- if (value < 1e12)
- snprintf(buf, sizeof(GbBuf), "%.2f GB", value/1e9);
+ snprintf(buf, sizeof(GbBuf), "%.2f MB", value / 1e6);
+ else if (value < 1e12)
+ snprintf(buf, sizeof(GbBuf), "%.2f GB", value / 1e9);
else
- snprintf(buf, sizeof(GbBuf), "%.2f TB", value/1e12);
+ snprintf(buf, sizeof(GbBuf), "%.2f TB", value / 1e12);
return buf;
}
typedef struct _HttpHeaderExtField HttpHeaderExtField;
typedef struct _HttpHeaderEntry HttpHeaderEntry;
typedef struct _HttpHeaderFieldStat HttpHeaderFieldStat;
-typedef union _field_store field_store;
+typedef union _field_store field_store;
typedef struct _HttpBody HttpBody;
typedef struct _HttpReply HttpReply;
typedef struct _HttpStateData HttpStateData;
/*
- * $Id: wais.cc,v 1.102 1998/03/04 23:52:41 wessels Exp $
+ * $Id: wais.cc,v 1.103 1998/03/05 00:43:11 wessels Exp $
*
* DEBUG: section 24 WAIS Relay
* AUTHOR: Harvest Derived
if (size > 0) {
fd_bytes(fd, size, FD_WRITE);
kb_incr(&Counter.server.all.kbytes_out, size);
- kb_incr(&Counter.server.other.kbytes_out, size);
+ kb_incr(&Counter.server.other.kbytes_out, size);
}
if (errflag == COMM_ERR_CLOSING)
return;