Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/librmt convert to ANSI KNF



details:   https://anonhg.NetBSD.org/src/rev/4cb1fb20b72b
branches:  trunk
changeset: 501600:4cb1fb20b72b
user:      lukem <lukem%NetBSD.org@localhost>
date:      Thu Jan 04 15:30:15 2001 +0000

description:
convert to ANSI KNF

diffstat:

 lib/librmt/rmtlib.c |  473 ++++++++++++++++-----------------------------------
 1 files changed, 150 insertions(+), 323 deletions(-)

diffs (truncated from 968 to 300 lines):

diff -r daf71fe07d6b -r 4cb1fb20b72b lib/librmt/rmtlib.c
--- a/lib/librmt/rmtlib.c       Thu Jan 04 15:17:41 2001 +0000
+++ b/lib/librmt/rmtlib.c       Thu Jan 04 15:30:15 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rmtlib.c,v 1.13 1999/09/20 04:48:05 lukem Exp $        */
+/*     $NetBSD: rmtlib.c,v 1.14 2001/01/04 15:30:15 lukem Exp $        */
 
 /*
  *     rmt --- remote tape emulator subroutines
@@ -42,6 +42,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <signal.h>
+#include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -54,26 +55,20 @@
 #define __RMTLIB_PRIVATE
 #include <rmt.h>               /* get prototypes for remapped functions */
 
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
 #include "pathnames.h"
 
-static int     _rmt_close __P((int));
-static int     _rmt_ioctl __P((int, unsigned long, char *));
-static off_t   _rmt_lseek __P((int, off_t, int));
-static int     _rmt_open __P((const char *, int, int));
-static int     _rmt_read __P((int, char *, unsigned int));
-static int     _rmt_write __P((int, const void *, unsigned int));
-static int     command __P((int, char *));
-static int     remdev __P((const char *));
-static void    rmtabort __P((int));
-static int     status __P((int));
+static int     _rmt_close(int);
+static int     _rmt_ioctl(int, unsigned long, void *);
+static off_t   _rmt_lseek(int, off_t, int);
+static int     _rmt_open(const char *, int, int);
+static ssize_t _rmt_read(int, void *, size_t);
+static ssize_t _rmt_write(int, const void *, size_t);
+static int     command(int, char *);
+static int     remdev(const char *);
+static void    rmtabort(int);
+static int     status(int);
 
-       int     isrmt __P((int));
+       int     isrmt(int);
 
 
 #define BUFMAGIC       64      /* a magic number for buffer sizes */
@@ -89,11 +84,10 @@
 /*
  *     rmtabort --- close off a remote tape connection
  */
+static void
+rmtabort(int fildes)
+{
 
-static void
-rmtabort(fildes)
-       int fildes;
-{
        close(READ(fildes));
        close(WRITE(fildes));
        READ(fildes) = -1;
@@ -101,18 +95,14 @@
 }
 
 
-
 /*
  *     command --- attempt to perform a remote tape command
  */
-
 static int
-command(fildes, buf)
-       int fildes;
-       char *buf;
+command(int fildes, char *buf)
 {
-       int blen;
-       void (*pstat) __P((int));
+       size_t blen;
+       void (*pstat)(int);
 
        _DIAGASSERT(buf != NULL);
 
@@ -122,8 +112,7 @@
 
        blen = strlen(buf);
        pstat = signal(SIGPIPE, SIG_IGN);
-       if (write(WRITE(fildes), buf, blen) == blen)
-       {
+       if (write(WRITE(fildes), buf, blen) == blen) {
                signal(SIGPIPE, pstat);
                return(0);
        }
@@ -140,14 +129,11 @@
 }
 
 
-
 /*
  *     status --- retrieve the status from the pipe
  */
-
 static int
-status(fildes)
-       int fildes;
+status(int fildes)
 {
        int i;
        char c, *cp;
@@ -157,23 +143,19 @@
  *     read the reply command line
  */
 
-       for (i = 0, cp = buffer; i < BUFMAGIC; i++, cp++)
-       {
-               if (read(READ(fildes), cp, 1) != 1)
-               {
+       for (i = 0, cp = buffer; i < BUFMAGIC; i++, cp++) {
+               if (read(READ(fildes), cp, 1) != 1) {
                        rmtabort(fildes);
                        errno = EIO;
                        return(-1);
                }
-               if (*cp == '\n')
-               {
+               if (*cp == '\n') {
                        *cp = 0;
                        break;
                }
        }
 
-       if (i == BUFMAGIC)
-       {
+       if (i == BUFMAGIC) {
                rmtabort(fildes);
                errno = EIO;
                return(-1);
@@ -187,8 +169,7 @@
                if (*cp != ' ')
                        break;
 
-       if (*cp == 'E' || *cp == 'F')
-       {
+       if (*cp == 'E' || *cp == 'F') {
                errno = atoi(cp + 1);
                while (read(READ(fildes), &c, 1) == 1)
                        if (c == '\n')
@@ -204,8 +185,7 @@
  *     check for mis-synced pipes
  */
 
-       if (*cp != 'A')
-       {
+       if (*cp != 'A') {
                rmtabort(fildes);
                errno = EIO;
                return(-1);
@@ -214,8 +194,8 @@
        return(atoi(cp + 1));
 }
 
+
 #ifdef USE_REXEC
-
 /*
  * _rmt_rexec
  *
@@ -230,12 +210,10 @@
  * with rsh are much more common on BSD systems.
  */
 
-static int     _rmt_rexec __P((const char *, const char *));
+static int     _rmt_rexec(const char *, const char *);
 
 static int
-_rmt_rexec(host, user)
-       const char *host;
-       const char *user;               /* may be NULL */
+_rmt_rexec(const char *host, const char *user)
 {
        struct servent *rexecserv;
 
@@ -244,16 +222,17 @@
 
        rexecserv = getservbyname("exec", "tcp");
        if (NULL == rexecserv) {
-               fprintf (stderr, "? exec/tcp: service not available.");
-               exit (-1);
+               fprintf(stderr, "? exec/tcp: service not available.");
+               exit(-1);
        }
        if ((user != NULL) && *user == '\0')
                user = (char *) NULL;
-       return rexec (&host, rexecserv->s_port, user, NULL,
-                       "/etc/rmt", (int *)NULL);
+       return (rexec(&host, rexecserv->s_port, user, NULL,
+                       "/etc/rmt", (int *)NULL));
 }
 #endif /* USE_REXEC */
 
+
 /*
  *     _rmt_open --- open a magtape device on system specified, as given user
  *
@@ -266,10 +245,7 @@
 #define MAXHOSTLEN     257     /* BSD allows very long host names... */
 
 static int
-_rmt_open(path, oflag, mode)
-       const char *path;
-       int oflag;
-       int mode;
+_rmt_open(const char *path, int oflag, int mode)
 {
        int i, rc;
        char buffer[BUFMAGIC];
@@ -292,8 +268,7 @@
                if (READ(i) == -1 && WRITE(i) == -1)
                        break;
 
-       if (i == MAXUNIT)
-       {
+       if (i == MAXUNIT) {
                errno = EMFILE;
                return(-1);
        }
@@ -314,8 +289,7 @@
        *sys = '\0';
        path++;
 
-       if (*(path - 1) == '@')
-       {
+       if (*(path - 1) == '@') {
                (void)strncpy(user, system, sizeof(login) - 1);
                                /* saw user part of user@host */
                sys = system;                   /* start over */
@@ -326,8 +300,7 @@
                path++;
        }
 #ifdef COMPAT
-       else if (*(path - 1) == '.')
-       {
+       else if (*(path - 1) == '.') {
                while (*path != ':') {
                        *user++ = *path++;
                }
@@ -361,8 +334,7 @@
        if ((rc = fork()) == -1)
                return(-1);
 
-       if (rc == 0)
-       {
+       if (rc == 0) {
                char    *rshpath, *rsh;
 
                close(0);
@@ -371,8 +343,8 @@
                close(1);
                dup(Ctp[i][1]);
                close(Ctp[i][0]); close(Ctp[i][1]);
-               (void) setuid (getuid ());
-               (void) setgid (getgid ());
+               (void) setuid(getuid());
+               (void) setgid(getgid());
 
                if ((rshpath = getenv("RCMD_CMD")) == NULL)
                        rshpath = _PATH_RSH;
@@ -381,13 +353,10 @@
                else
                        rsh++;
 
-               if (*login)
-               {
+               if (*login) {
                        execl(rshpath, rsh, system, "-l", login,
                                _PATH_RMT, (char *) 0);
-               }
-               else
-               {
+               } else {
                        execl(rshpath, rsh, system,
                                _PATH_RMT, (char *) 0);
                }
@@ -415,19 +384,15 @@
 }
 
 
-
 /*
  *     _rmt_close --- close a remote magtape unit and shut down
  */



Home | Main Index | Thread Index | Old Index