From: wessels <> Date: Wed, 16 Oct 1996 05:32:46 +0000 (+0000) Subject: clean bunch of stuff from lib/util.c, made xmemcpy a macro, removed strdup() X-Git-Tag: SQUID_3_0_PRE1~5639 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3c0117c9bd609d180f73094353b26cf80d0713d2;p=thirdparty%2Fsquid.git clean bunch of stuff from lib/util.c, made xmemcpy a macro, removed strdup() put tempnam.o into LIBOBJS. --- diff --git a/include/autoconf.h.in b/include/autoconf.h.in index 193c3a7784..714b611f71 100644 --- a/include/autoconf.h.in +++ b/include/autoconf.h.in @@ -13,6 +13,15 @@ /* Define if you have and it should be used (not on Ultrix). */ #undef HAVE_ALLOCA_H +/* Define to `long' if doesn't define. */ +#undef off_t + +/* Define to `int' if doesn't define. */ +#undef pid_t + +/* Define to `unsigned' if doesn't define. */ +#undef size_t + /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be automatically deduced at run-time. @@ -130,9 +139,6 @@ /* Define if you have the srand48 function. */ #undef HAVE_SRAND48 -/* Define if you have the strdup function. */ -#undef HAVE_STRDUP - /* Define if you have the strerror function. */ #undef HAVE_STRERROR @@ -142,9 +148,6 @@ /* Define if you have the syslog function. */ #undef HAVE_SYSLOG -/* Define if you have the tempnam function. */ -#undef HAVE_TEMPNAM - /* Define if you have the timegm function. */ #undef HAVE_TIMEGM diff --git a/include/util.h b/include/util.h index 87678b02ac..98798fcc0f 100644 --- a/include/util.h +++ b/include/util.h @@ -1,5 +1,5 @@ /* - * $Id: util.h,v 1.22 1996/10/09 15:34:15 wessels Exp $ + * $Id: util.h,v 1.23 1996/10/15 23:32:47 wessels Exp $ * * AUTHOR: Harvest Derived * @@ -127,79 +127,25 @@ #endif #endif -#if !HAVE_STRDUP -extern char *strdup _PARAMS((char *)); -#endif +extern char *getfullhostname _PARAMS((void)); +extern char *mkhttpdlogtime _PARAMS((time_t *)); +extern char *mkrfc850 _PARAMS((time_t)); +extern char *uudecode _PARAMS((char *)); extern char *xstrdup _PARAMS((char *)); - -/* from xmalloc.c */ +extern char *xstrdup _PARAMS((char *)); +extern char *xstrerror _PARAMS((void)); +extern int tvSubMsec _PARAMS((struct timeval, struct timeval)); +extern time_t parse_rfc850 _PARAMS((char *str)); +extern void *xcalloc _PARAMS((int, size_t)); extern void *xmalloc _PARAMS((size_t)); extern void *xrealloc _PARAMS((void *, size_t)); -extern void *xcalloc _PARAMS((int, size_t)); +extern void Tolower _PARAMS((char *)); extern void xfree _PARAMS((void *)); -extern void xxfree _PARAMS((void *)); -extern char *xstrdup _PARAMS((char *)); -extern char *xstrerror _PARAMS((void)); -extern char *getfullhostname _PARAMS((void)); extern void xmemcpy _PARAMS((void *, void *, int)); - -extern int tvSubMsec _PARAMS((struct timeval, struct timeval)); - +extern void xxfree _PARAMS((void *)); #if XMALLOC_STATISTICS void malloc_statistics _PARAMS((void (*)_PARAMS((int, int, void *)), void *)); #endif -/* from debug.c */ -#ifndef MAX_DEBUG_LEVELS -#define MAX_DEBUG_LEVELS 256 -#endif /* MAX_DEBUG_LEVELS */ - -#ifndef MAIN -extern int Harvest_do_debug; -extern int Harvest_debug_levels[]; -#endif /* MAIN */ - -#undef debug_ok_fast -#if USE_NO_DEBUGGING -#define debug_ok_fast(S,L) 0 -#else -#define debug_ok_fast(S,L) \ - ( \ - (Harvest_do_debug) && \ - ((Harvest_debug_levels[S] == -2) || \ - ((Harvest_debug_levels[S] != -1) && \ - ((L) <= Harvest_debug_levels[S]))) \ - ) -#endif /* USE_NO_DEBUGGING */ - -#undef Debug -#if USE_NO_DEBUGGING -#define Debug(section, level, X) /* empty */; -#else -#define Debug(section, level, X) \ - {if (debug_ok_fast((section),(level))) {Log X;}} -#endif - -void debug_flag _PARAMS((char *)); - -char *mkhttpdlogtime _PARAMS((time_t *)); -extern char *mkrfc850 _PARAMS((time_t)); -extern time_t parse_rfc850 _PARAMS((char *str)); -extern void init_log3 _PARAMS((char *pn, FILE * a, FILE * b)); -extern void debug_init _PARAMS((void)); -extern void log_errno2 _PARAMS((char *, int, char *)); - -#ifdef __STDC__ -extern void Log _PARAMS((char *,...)); -extern void errorlog _PARAMS((char *,...)); -#else -extern void Log _PARAMS(()); -extern void errorlog _PARAMS(()); -#endif /* __STDC__ */ - -extern void Tolower _PARAMS((char *)); - -extern char *uudecode _PARAMS((char *)); - #endif /* ndef _UTIL_H_ */ diff --git a/lib/Makefile.in b/lib/Makefile.in index 0645e201c7..0be5b094c7 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -3,7 +3,7 @@ # # Darren Hardy, hardy@cs.colorado.edu, April 1994 # -# $Id: Makefile.in,v 1.15 1996/10/13 10:04:20 wessels Exp $ +# $Id: Makefile.in,v 1.16 1996/10/15 23:32:48 wessels Exp $ # prefix = @prefix@ srcdir = @srcdir@ @@ -19,15 +19,16 @@ AC_CFLAGS = @CFLAGS@ LDFLAGS = @LDFLAGS@ XTRA_LIBS = @XTRA_LIBS@ RM = @RM@ +LIBOBJS = @LIBOBJS@ INCLUDE = -I../include -I$(srcdir)/../include UTILOBJS = rfc850.o \ rfc1738.o \ util.o \ getfullhostname.o \ - tempnam.o \ base64.o \ - uudecode.o + uudecode.o \ + $(LIBOBJS) REGEXOBJS = GNUregex.o LIBS = libmiscutil.a libregex.a diff --git a/lib/util.c b/lib/util.c index d71c9d9456..b68ca3341a 100644 --- a/lib/util.c +++ b/lib/util.c @@ -1,5 +1,5 @@ /* - * $Id: util.c,v 1.21 1996/09/24 20:17:26 wessels Exp $ + * $Id: util.c,v 1.22 1996/10/15 23:32:48 wessels Exp $ * * DEBUG: * AUTHOR: Harvest Derived @@ -449,27 +449,6 @@ xstrerror(void) return xstrerror_buf; } -#if !HAVE_STRDUP -/* define for systems that don't have strdup */ -char * -strdup(char *s) -{ - return (xstrdup(s)); -} -#endif - -void -xmemcpy(void *from, void *to, int len) -{ -#if HAVE_MEMMOVE - (void) memmove(from, to, len); -#elif HAVE_BCOPY - bcopy(to, from, len); -#else - (void) memcpy(from, to, len); -#endif -} - void Tolower(char *q) { diff --git a/src/Makefile.in b/src/Makefile.in index a8e0048b9a..bbfeb9dbb6 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.in,v 1.47 1996/10/14 23:45:24 wessels Exp $ +# $Id: Makefile.in,v 1.48 1996/10/15 23:32:50 wessels Exp $ # # Uncomment and customize the following to suit your needs: # @@ -10,7 +10,7 @@ AIO_OPT = # -DUSE_ASYNC_IO=1 AIO_LIBS = # @AIO_LIBS@ AUTH_OPT = # -DUSE_PROXY_AUTH=1 LOG_HDRS_OPT = # -DLOG_FULL_HEADERS=1 -ICMP_OPT = # -DUSE_ICMP=1 +ICMP_OPT = -DUSE_ICMP=1 DELAY_HACK = # -DDELAY_HACK=1 DEFINES = $(HOST_OPT) $(AIO_OPT) $(AUTH_OPT) $(LOG_HDRS_OPT) $(ICMP_OPT) \ $(DELAY_HACK) diff --git a/src/cachemgr.cc b/src/cachemgr.cc index 2990ac44f0..2d8f5b88a4 100644 --- a/src/cachemgr.cc +++ b/src/cachemgr.cc @@ -1,6 +1,6 @@ /* - * $Id: cachemgr.cc,v 1.36 1996/10/14 23:50:49 wessels Exp $ + * $Id: cachemgr.cc,v 1.37 1996/10/15 23:32:51 wessels Exp $ * * DEBUG: Section 0 CGI Cache Manager * AUTHOR: Harvest Derived @@ -517,16 +517,16 @@ parse_object(char *string) sscanf(token, "%d", &obj_size); token = strtok(tmp_line, w_space); - store_time = strdup(token); + store_time = xstrdup(token); token = strtok(tmp_line, w_space); - obj_status = strdup(token); + obj_status = xstrdup(token); token = strtok(tmp_line, w_space); - last_ref = strdup(token); + last_ref = xstrdup(token); token = strtok(tmp_line, w_space); - ttl = strdup(token); + ttl = xstrdup(token); token = strtok(tmp_line, w_space); /* Active */ @@ -535,10 +535,10 @@ parse_object(char *string) sscanf(token, "%d", &ref_cnt); token = strtok(tmp_line, w_space); - sto = strdup(token); + sto = xstrdup(token); token = strtok(tmp_line, w_space); - status = strdup(token); + status = xstrdup(token); printf("
  • Cache: %s
    ", url, url); @@ -589,11 +589,11 @@ main(int argc, char *argv[]) time_t time_val; if ((s = strrchr(argv[0], '/'))) - progname = strdup(s + 1); + progname = xstrdup(s + 1); else - progname = strdup(argv[0]); + progname = xstrdup(argv[0]); if ((s = getenv("SCRIPT_NAME")) != NULL) { - script_name = strdup(s); + script_name = xstrdup(s); } strcpy(hostname, CACHEMGR_HOSTNAME); diff --git a/src/icmp.cc b/src/icmp.cc index 14ac4859b8..0d7697d6f8 100644 --- a/src/icmp.cc +++ b/src/icmp.cc @@ -1,6 +1,6 @@ /* - * $Id: icmp.cc,v 1.21 1996/10/15 04:57:52 wessels Exp $ + * $Id: icmp.cc,v 1.22 1996/10/15 23:32:51 wessels Exp $ * * DEBUG: section 37 ICMP Routines * AUTHOR: Duane Wessels @@ -66,7 +66,7 @@ icmpSendEcho(struct in_addr to, int opcode, char *payload, int len) pecho->to = to; pecho->opcode = (unsigned char) opcode; pecho->psize = len; - memcpy(pecho->payload, payload, len); + xmemcpy(pecho->payload, payload, len); icmpQueueSend(pecho, sizeof(pingerEchoData) - 8192 + len, xfree); } @@ -177,7 +177,7 @@ icmpHandleSourcePing(struct sockaddr_in *from, char *buf) StoreEntry *entry; icp_common_t header; char *url; - memcpy(&header, buf, sizeof(icp_common_t)); + xmemcpy(&header, buf, sizeof(icp_common_t)); url = buf + sizeof(icp_common_t); if (neighbors_do_private_keys && header.reqnum) { key = storeGeneratePrivateKey(url, METHOD_GET, header.reqnum); @@ -222,7 +222,7 @@ icmpSourcePing(struct in_addr to, icp_common_t * header, char *url) return; payload = get_free_8k_page(); len = sizeof(icp_common_t); - memcpy(payload, header, len); + xmemcpy(payload, header, len); strcpy(payload + len, url); len += ulen + 1; icmpSendEcho(to, S_ICMP_ICP, payload, len); diff --git a/src/ipcache.cc b/src/ipcache.cc index 10b33f877a..98ff5ca97f 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -1,5 +1,5 @@ /* - * $Id: ipcache.cc,v 1.74 1996/10/15 18:06:24 wessels Exp $ + * $Id: ipcache.cc,v 1.75 1996/10/15 23:32:53 wessels Exp $ * * DEBUG: section 14 IP Cache * AUTHOR: Harvest Derived @@ -418,7 +418,7 @@ ipcacheAddHostent(ipcache_entry * i, struct hostent *hp) i->addrs.count = (unsigned char) addr_count; i->addrs.in_addrs = xcalloc(addr_count, sizeof(struct in_addr)); for (k = 0; k < addr_count; k++) - memcpy(&i->addrs.in_addrs[k].s_addr, + xmemcpy(&i->addrs.in_addrs[k].s_addr, *(hp->h_addr_list + k), hp->h_length); i->status = IP_CACHED; diff --git a/src/pinger.cc b/src/pinger.cc index 4c947284e2..0f709b5ae4 100644 --- a/src/pinger.cc +++ b/src/pinger.cc @@ -1,6 +1,6 @@ /* - * $Id: pinger.cc,v 1.8 1996/10/15 18:06:25 wessels Exp $ + * $Id: pinger.cc,v 1.9 1996/10/15 23:32:54 wessels Exp $ * * DEBUG: section 37 ICMP Routines * AUTHOR: Duane Wessels @@ -164,7 +164,7 @@ pingerSendEcho(struct in_addr to, int opcode, char *payload, int len) if (payload) { if (len > MAX_PAYLOAD) len = MAX_PAYLOAD; - memcpy(echo->payload, payload, len); + xmemcpy(echo->payload, payload, len); icmp_pktsize += len; } icmp->icmp_cksum = in_cksum((u_short *) icmp, icmp_pktsize); diff --git a/src/store.cc b/src/store.cc index b4a9e1619c..006a46d275 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.130 1996/10/10 22:19:36 wessels Exp $ + * $Id: store.cc,v 1.131 1996/10/15 23:32:55 wessels Exp $ * * DEBUG: section 20 Storeage Manager * AUTHOR: Harvest Derived @@ -835,7 +835,7 @@ storeAddDiskRestore(char *url, int file_number, int size, time_t expires, time_t e->lock_count = 0; BIT_RESET(e->flag, CLIENT_ABORT_REQUEST); e->refcount = 0; - e->lastref = squid_curtime; + e->lastref = timestamp; e->timestamp = timestamp; e->expires = expires; e->lastmod = lastmod; diff --git a/src/tools.cc b/src/tools.cc index ff3e21a46b..57690e5dbd 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -1,6 +1,6 @@ /* - * $Id: tools.cc,v 1.73 1996/10/15 04:57:58 wessels Exp $ + * $Id: tools.cc,v 1.74 1996/10/15 23:32:55 wessels Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -622,6 +622,6 @@ struct in_addr inaddrFromHostent(struct hostent *hp) { struct in_addr s; - memcpy(&s.s_addr, hp->h_addr, sizeof(s.s_addr)); + xmemcpy(&s.s_addr, hp->h_addr, sizeof(s.s_addr)); return s; }