str-fixup-20030214
[openafs.git] / src / afs / afs_util.c
index b0812b2..751423a 100644 (file)
@@ -1,35 +1,46 @@
-/* Copyright (C) 1995, 1989, 1998 Transarc Corporation - All rights reserved */
 /*
- * (C) COPYRIGHT IBM CORPORATION 1987, 1988
- * LICENSED MATERIALS - PROPERTY OF IBM
+ * Copyright 2000, International Business Machines Corporation and others.
+ * All Rights Reserved.
+ * 
+ * This software has been released under the terms of the IBM Public
+ * License.  For details, see the LICENSE file in the top-level source
+ * directory or online at http://www.openafs.org/dl/license10.html
  */
+
 /*
  * afs_util.c - miscellaneous AFS client utility functions
  *
  * Implements:
  */
-#include "../afs/param.h"      /* Should be always first */
-#include "../afs/stds.h"
-#include "../afs/sysincludes.h"        /* Standard vendor system headers */
+#include <afsconfig.h>
+#include "afs/param.h"
+
+RCSID("$Header$");
+
+#include "afs/stds.h"
+#include "afs/sysincludes.h"   /* Standard vendor system headers */
 
 #if !defined(UKERNEL)
 #include <net/if.h>
 #include <netinet/in.h>
 
 #ifdef AFS_SGI62_ENV
-#include "../h/hashing.h"
+#include "h/hashing.h"
 #endif
-#if !defined(AFS_HPUX110_ENV) && !defined(AFS_LINUX20_ENV)
+#if !defined(AFS_HPUX110_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN60_ENV)
 #include <netinet/in_var.h>
 #endif /* ! AFS_HPUX110_ENV */
 #endif /* !defined(UKERNEL) */
 
-#include "../afs/afsincludes.h"        /* Afs-based standard headers */
-#include "../afs/afs_stats.h"   /* afs statistics */
+#include "afsincludes.h"       /* Afs-based standard headers */
+#include "afs/afs_stats.h"   /* afs statistics */
 
 #if    defined(AFS_SUN56_ENV)
 #include <inet/led.h>
 #include <inet/common.h>
+#if     defined(AFS_SUN58_ENV)
+#include <netinet/ip6.h>
+#endif
 #include <inet/ip.h>
 #endif
 
@@ -37,8 +48,7 @@
 #include <sys/fp_io.h>
 #endif
 
-extern struct volume *afs_volumes[NVOLS];
-
+#ifndef afs_cv2string
 char *afs_cv2string(char *ttp, afs_uint32 aval)
 {
     register char *tp = ttp;
@@ -59,6 +69,65 @@ char *afs_cv2string(char *ttp, afs_uint32 aval)
     return tp;
 
 } /*afs_cv2string*/
+#endif
+
+#ifndef afs_strcasecmp
+int afs_strcasecmp(char *s1, char *s2)
+{
+    while (*s1 && *s2) {
+       char c1, c2;
+
+       c1 = *s1++;
+       c2 = *s2++;
+       if (c1 >= 'A' && c1 <= 'Z') c1 += 0x20;
+       if (c2 >= 'A' && c2 <= 'Z') c2 += 0x20;
+       if (c1 != c2)
+           return c1-c2;
+    }
+
+    return *s1 - *s2;
+}
+#endif
+
+#ifndef afs_strcat
+char *afs_strcat(char *s1, char *s2)
+{
+    char *os1;
+
+    os1 = s1;
+    while (*s1++)
+       ;
+    --s1;
+    while ((*s1++ = *s2++))
+       ;
+    return (os1);
+}
+#endif
+
+#ifndef afs_strchr
+char *afs_strchr(char *s, int c)
+{
+    char *p;
+
+    for (p = s; *p; p++)
+       if (*p == c)
+           return p;
+    return NULL;
+}
+#endif
+
+char *afs_strdup(char *s)
+{
+    char *n;
+    int cc;
+
+    cc = strlen(s) + 1;
+    n = (char *) afs_osi_Alloc(cc);
+    if (n)
+       memcpy(n, s, cc);
+
+    return n;
+}
 
 void print_internet_address(char *preamble, struct srvAddr *sa,
                            char *postamble, int flag)
@@ -94,11 +163,18 @@ void print_internet_address(char *preamble, struct srvAddr *sa,
  * this code badly needs to be cleaned up...  too many ugly ifdefs.
  * XXX
  */
-extern afs_int32 afs_showflags;
-
-afs_warn(a,b,c,d,e,f,g,h,i,j)
+#if 0
+void afs_warn(char *a, long b, long c, long d, long e, long f, 
+       long g, long h, long i, long j)
+#else
+void afs_warn(a,b,c,d,e,f,g,h,i,j)
 char *a;
+#if defined( AFS_USE_VOID_PTR)
+void *b, *c, *d, *e, *f, *g, *h, *i, *j;
+#else
 long b,c,d,e,f,g,h,i,j;
+#endif
+#endif
 {
     AFS_STATCNT(afs_warn);
     
@@ -125,9 +201,14 @@ long b,c,d,e,f,g,h,i,j;
     }
 }
 
-afs_warnuser(a,b,c,d,e,f,g,h,i,j)
+#if 0
+void afs_warnuser(char *a, long b, long c, long d, long e, long f, 
+       long g, long h, long i, long j)
+#else
+void afs_warnuser(a,b,c,d,e,f,g,h,i,j)
 char *a;
 long b,c,d,e,f,g,h,i,j;
+#endif
 {
     AFS_STATCNT(afs_warnuser);
     if (afs_showflags & GAGUSER)
@@ -149,14 +230,8 @@ long b,c,d,e,f,g,h,i,j;
 
 
 /* run everywhere, checking locks */
-void afs_CheckLocks()
-
+void afs_CheckLocks(void)
 {
-    extern afs_rwlock_t afs_xconn, afs_xvolume, afs_xuser, afs_xcell;
-    extern afs_rwlock_t afs_xserver;
-    extern struct server *afs_servers[NSERVERS];
-    extern struct unixuser *afs_users[NUSERS];
-    extern unsigned char *afs_indexFlags;
     register int i;
 
     afs_warn("Looking for locked data structures.\n");
@@ -169,9 +244,9 @@ void afs_CheckLocks()
        for(i=0;i<VCSIZE;i++) {
            for(tvc = afs_vhashT[i]; tvc; tvc=tvc->hnext) {
 #ifdef AFS_OSF_ENV
-               if (tvc->vrefCount > 1)
+               if (VREFCOUNT(tvc) > 1)
 #else  /* AFS_OSF_ENV */
-               if (tvc->vrefCount)
+               if (VREFCOUNT(tvc))
 #endif
                    afs_warn("Stat cache entry at %x is held\n", tvc);
                if (CheckLock(&tvc->lock))
@@ -232,7 +307,8 @@ void afs_CheckLocks()
 }
 
 
-int afs_noop() {
+int afs_noop(void)
+{
     AFS_STATCNT(afs_noop);
 #ifdef AFS_OSF30_ENV
     return (EOPNOTSUPP);
@@ -241,10 +317,11 @@ int afs_noop() {
 #endif
 }
 
-int afs_badop() {
+int afs_badop(void)
+{
     AFS_STATCNT(afs_badop);
     osi_Panic("afs bad vnode op");
-    return 0;                  /* make SGI C compiler happy */
+    return 0;
 }
 
 /*
@@ -255,8 +332,7 @@ int afs_badop() {
  * larger than an afs_int32.
  */
 
-afs_int32
-afs_data_pointer_to_int32(const void *p)
+afs_int32 afs_data_pointer_to_int32(const void *p)
 {
        union {
                afs_int32  i32[sizeof(void *)/sizeof(afs_int32)];