freebsd-5-update-20030213
[openafs.git] / src / pinstall / install.c
index dd8b9de..abe38f5 100644 (file)
@@ -81,23 +81,30 @@ RCSID("$Header$");
 #include <unistd.h>
 #include <string.h>
 #include <sys/wait.h>
+#include <stdlib.h>
+#ifdef HAVE_PWD_H
+#include <pwd.h>
+#endif
+#include <stdio.h>
 
-struct stat istat, ostat;
+static struct stat istat, ostat;
+static int stripcalled = 0;
 
-extern int errno;
+#if !defined(AFS_DARWIN60_ENV) && !defined(AFS_FBSD50_ENV)
 extern int sys_nerr;
-#if !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_FBSD_ENV)
-extern char *sys_errlist[];
 #endif
-#if    defined(AFS_AIX_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_DECOSF_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
-extern struct passwd *getpwnam();
-int stripcalled = 0;
+#if !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV)
+extern char *sys_errlist[];
 #endif
 
+/* static prototypes */
+char *ErrorString(int aerrno);
+int stripName(char *aname);
+int atoo(register char *astr);
+
+
 #if defined(AFS_HPUX_ENV) && !defined(AFS_HPUX102_ENV)
-utimes(file,tvp)
-char *file;
-struct timeval tvp[2];
+int utimes(char *file, struct timeval tvp[2])
 {
        struct utimbuf times;
        
@@ -107,9 +114,7 @@ struct timeval tvp[2];
 }
 #endif
 
-static char *strrpbrk (s, set)
-  char *s;
-  char *set;
+static char *strrpbrk (char *s, char *set)
 {
     char sets[256];
     int  i;
@@ -121,8 +126,8 @@ static char *strrpbrk (s, set)
     return 0;
 }
 
-char *ErrorString(aerrno)
-    int aerrno; {
+char *ErrorString(int aerrno)
+{
     static char tbuffer[100];
     if (aerrno < 0 || aerrno >= sys_nerr) {
        sprintf(tbuffer, "undefined error code %d", aerrno);
@@ -132,17 +137,15 @@ char *ErrorString(aerrno)
     return tbuffer;
 }
 
-int
-stripName(aname)
-    char *aname;
-    {if (strrchr(aname, '.') == 0) return 1;
+int stripName(char *aname)
+{
+    if (strrchr(aname, '.') == 0) return 1;
     else return 0;
-    }
+}
 
-int
-atoo(astr)
-    register char *astr;
-    {register afs_int32 value;
+int atoo(register char *astr)
+{
+    register afs_int32 value;
     register char tc;
     value = 0;
     while ((tc = *astr++))
@@ -150,16 +153,15 @@ atoo(astr)
        value += tc-'0';
        }
     return value;
-    }
+}
 
-#if    defined(AFS_HPUX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_DECOSF_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_OBSD_ENV)
+#if    defined(AFS_HPUX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_DECOSF_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_OBSD_ENV) || defined(AFS_NBSD_ENV)
 /*
  * Implementation lifted from that for AIX 3.1, since there didn't seem to be any
  * reason why it wouldn't work.
  */
-static int
-quickStrip (iname, oname, ignored, copy_only)
-char *iname, *oname; {
+static int quickStrip (char *iname, char *oname, int ignored, int copy_only)
+{
        int pid, status;
        static char *strip[] = {
                "strip", 0, 0,
@@ -179,7 +181,7 @@ char *iname, *oname; {
            case 0:                     /* child        */
                copy[1] = iname;
                copy[2] = oname;
-               execve("/bin/cp", copy, (char **)0);
+               execve("/bin/cp", copy, NULL);
                perror("/bin/cp");
                exit(1);
 
@@ -204,7 +206,7 @@ char *iname, *oname; {
                return -1;
        }
 
-#ifndef AFS_OBSD_ENV
+#if !defined(AFS_OBSD_ENV) && !defined(AFS_NBSD_ENV)
        /*
         * done the copy, now strip if desired.
         */
@@ -225,7 +227,7 @@ char *iname, *oname; {
 #else
 #define        STRIP_BIN       "/bin/strip"
 #endif
-               execve(STRIP_BIN, strip, (char **)0);
+               execve(STRIP_BIN, strip, NULL);
                perror(STRIP_BIN);
                exit(1);
 
@@ -240,25 +242,6 @@ char *iname, *oname; {
        return status;
 }
 
-/*
- * AIXobject - lie about file type
- *
- * Input:
- *     ignored
- *
- * Returns:
- *     !0 indicating that the file in question is an XCOFF type file.
- *
- * Note:
- *     Since /bin/strip will make that call for us, we will lie so that
- *     it has a chance.
- */
-int
-AIXobject(ignored) {
-
-       return !0;
-}
-
 #else
 #ifdef AFS_AIX_ENV
 #ifdef AFS_AIX32_ENV
@@ -266,9 +249,8 @@ AIXobject(ignored) {
  * whoa! back up and be a little more rational (every little bit helps in
  * aix_31).
  */
-static
-quickStrip (iname, oname, ignored, copy_only)
-char *iname, *oname; {
+static int quickStrip (char *iname, char *oname, int ignored, int copy_only)
+{
        int pid, status;
        static char *strip[] = {
                "strip", 0, 0,
@@ -340,31 +322,12 @@ char *iname, *oname; {
        return status;
 }
 
-/*
- * AIXobject - lie about file type
- *
- * Input:
- *     ignored
- *
- * Returns:
- *     !0 indicating that the file in question is an XCOFF type file.
- *
- * Note:
- *     Since /bin/strip will make that call for us, we will lie so that
- *     it has a chance.
- */
-AIXobject(ignored) {
-
-       return !0;
-}
 #endif /* AFS_AIX32_ENV        */
 #else  /* !AFS_AIX_ENV         */
 
 #ifdef mips
 #include "sex.h"
-int quickStrip(fd, asize)
-int fd;        /* file descriptor */
-afs_int32 asize; /* ignored */
+int quickStrip(int fd, afs_int32 asize)
 {
     FILHDR fheader;
     int dum, newlen;
@@ -416,10 +379,8 @@ afs_int32 asize; /* ignored */
     return 0;
 }
 #else /* !mips */
-static int quickStrip (afd, asize)
-    int afd;
-    afs_int32 asize; {
-
+static int quickStrip (int afd, afs_int32 asize)
+{
     int n, bytesLeft;
     struct exec buf;
     struct exec *head;
@@ -457,10 +418,7 @@ static int quickStrip (afd, asize)
 
 #include "AFS_component_version_number.c"
 
-int
-main (argc, argv)
-    int argc;
-    char **argv;
+int main (int argc, char *argv[])
 {
     int setOwner, setMode, setGroup, ifd, ofd;
     afs_int32 mode=0, owner, group;
@@ -475,10 +433,8 @@ main (argc, argv)
 #endif /* AFS_HPUX_ENV */
     char pnametmp[1024];
     int pnamelen;
-#if defined (AFS_AIX_ENV) || defined(AFS_XBSD_ENV)
     afs_int32 newcode;
     static char diskBuffer[BUFSIZE];   /* must be static to avoid compiler bugs for large stuff */
-#endif
     char myHostName[100];
     struct timeval tvp[2];
     int isDir;
@@ -686,10 +642,10 @@ main (argc, argv)
                continue;
            }
        }
-#if    defined(AFS_AIX_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_DECOSF_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_OBSD_ENV)
+#if    defined(AFS_AIX_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_DECOSF_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_OBSD_ENV) || defined(AFS_NBSD_ENV)
        stripcalled = 0;
        if (strip == 1 ||
-           ((strip == -1 && ((istat.st_mode & 0111) == 0111) && stripName(newNames[i])) && AIXobject(fnames[i])))
+           ((strip == -1 && ((istat.st_mode & 0111) == 0111) && stripName(newNames[i]))))
            stripcalled = 1;
        if (!stripcalled) {
            /* Simply copy target to dest */
@@ -837,4 +793,4 @@ main (argc, argv)
       }
     /* all done now */
     exit(rcode);
-    }
+}