]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
clean bunch of stuff from lib/util.c, made xmemcpy a macro, removed strdup()
authorwessels <>
Wed, 16 Oct 1996 05:32:46 +0000 (05:32 +0000)
committerwessels <>
Wed, 16 Oct 1996 05:32:46 +0000 (05:32 +0000)
put tempnam.o into LIBOBJS.

include/autoconf.h.in
include/util.h
lib/Makefile.in
lib/util.c
src/Makefile.in
src/cachemgr.cc
src/icmp.cc
src/ipcache.cc
src/pinger.cc
src/store.cc
src/tools.cc

index 193c3a77841d0e411baf6ecdb6cc435088eec6c7..714b611f7134c85c25ca77ecd2a34d04bb246b6c 100644 (file)
 /* Define if you have <alloca.h> and it should be used (not on Ultrix).  */
 #undef HAVE_ALLOCA_H
 
+/* Define to `long' if <sys/types.h> doesn't define.  */
+#undef off_t
+
+/* Define to `int' if <sys/types.h> doesn't define.  */
+#undef pid_t
+
+/* Define to `unsigned' if <sys/types.h> 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.
 /* 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
 
 /* 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
 
index 87678b02ac22d4bc237a804afdb1339792ca5ca2..98798fcc0f2a44092fda2d7ba8c51bf1bff65b45 100644 (file)
@@ -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
  *
 #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_ */
index 0645e201c78f3f5edbcf06d3d6ce2dfee7d8dd91..0be5b094c782751fbc840e7a434a578caa7417a7 100644 (file)
@@ -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
 
index d71c9d945611f86681bf664a7b3f21036ff3c2d8..b68ca3341a6b4f91db4d77f3e2cc810825295cdc 100644 (file)
@@ -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)
 {
index a8e0048b9a570a038310dfe56ba3b40d76593be4..bbfeb9dbb6e654ca530111bdab6eaa6b51cd6677 100644 (file)
@@ -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)
index 2990ac44f08683de740c43b2e6500bdc037ff063..2d8f5b88a44d56c72518c0f83c5e55ecbc91a2ee 100644 (file)
@@ -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("<LI>Cache: <A HREF=\"%s\">%s</A><BR>",
        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);
 
index 14ac4859b87216bb8065e71dc3dec5c0deaa4ded..0d7697d6f86441fdcba369d0a0ac1c9dc919e39c 100644 (file)
@@ -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);
index 10b33f877a3d69ef9c279918f3e3e66c2d94f2ab..98ff5ca97f4063e17a831ba82657719942feaf73 100644 (file)
@@ -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;
index 4c947284e2167e16d9241f9d319fbe6397395f99..0f709b5ae463871fafb23dedb312ffe293f656c3 100644 (file)
@@ -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);
index b4a9e1619cc99388e220b8480930c1fe263926b7..006a46d2756572833c7abcb6ae482b6c896e2fff 100644 (file)
@@ -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;
index ff3e21a46b84293fd46df722cd24663e4742a24a..57690e5dbd72f89121632deae08f00b57cf84675 100644 (file)
@@ -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;
 }