Fix prototypes and parameters for compiling with enabled warnings.
authordrepper <drepper>
Thu, 27 Mar 1997 01:50:51 +0000 (01:50 +0000)
committerdrepper <drepper>
Thu, 27 Mar 1997 01:50:51 +0000 (01:50 +0000)
sunrpc/rpc_cmsg.c
sunrpc/rpc_dtable.c
sunrpc/rpc_prot.c
sunrpc/rpc_sample.c
sunrpc/rpc_scan.c

index a4d5ef3..5759360 100644 (file)
@@ -6,23 +6,23 @@
  * may copy or modify Sun RPC without charge, but are not authorized
  * to license or distribute it to anyone else except as part of a product or
  * program developed by the user.
- * 
+ *
  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
+ *
  * Sun RPC is provided with no support and without any obligation on the
  * part of Sun Microsystems, Inc. to assist in its use, correction,
  * modification or enhancement.
- * 
+ *
  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  * OR ANY PART THEREOF.
- * 
+ *
  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  * or profits or other special, indirect and consequential damages, even if
  * Sun has been advised of the possibility of such damages.
- * 
+ *
  * Sun Microsystems, Inc.
  * 2550 Garcia Avenue
  * Mountain View, California  94043
@@ -38,153 +38,182 @@ static char sccsid[] = "@(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro";
  *
  */
 
+#include <string.h>
 #include <sys/param.h>
-
 #include <rpc/rpc.h>
 
+extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *);
+
 /*
  * XDR a call message
  */
 bool_t
-xdr_callmsg(xdrs, cmsg)
-       register XDR *xdrs;
-       register struct rpc_msg *cmsg;
+xdr_callmsg (XDR *xdrs, struct rpc_msg *cmsg)
 {
-       register long *buf;
-       register struct opaque_auth *oa;
+  long *buf;
+  struct opaque_auth *oa;
 
-       if (xdrs->x_op == XDR_ENCODE) {
-               if (cmsg->rm_call.cb_cred.oa_length > MAX_AUTH_BYTES) {
-                       return (FALSE);
+  if (xdrs->x_op == XDR_ENCODE)
+    {
+      if (cmsg->rm_call.cb_cred.oa_length > MAX_AUTH_BYTES)
+       {
+         return (FALSE);
+       }
+      if (cmsg->rm_call.cb_verf.oa_length > MAX_AUTH_BYTES)
+       {
+         return (FALSE);
+       }
+      buf = XDR_INLINE (xdrs, 8 * BYTES_PER_XDR_UNIT
+                       + RNDUP (cmsg->rm_call.cb_cred.oa_length)
+                       + 2 * BYTES_PER_XDR_UNIT
+                       + RNDUP (cmsg->rm_call.cb_verf.oa_length));
+      if (buf != NULL)
+       {
+         IXDR_PUT_LONG (buf, cmsg->rm_xid);
+         IXDR_PUT_ENUM (buf, cmsg->rm_direction);
+         if (cmsg->rm_direction != CALL)
+           {
+             return FALSE;
+           }
+         IXDR_PUT_LONG (buf, cmsg->rm_call.cb_rpcvers);
+         if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION)
+           {
+             return FALSE;
+           }
+         IXDR_PUT_LONG (buf, cmsg->rm_call.cb_prog);
+         IXDR_PUT_LONG (buf, cmsg->rm_call.cb_vers);
+         IXDR_PUT_LONG (buf, cmsg->rm_call.cb_proc);
+         oa = &cmsg->rm_call.cb_cred;
+         IXDR_PUT_ENUM (buf, oa->oa_flavor);
+         IXDR_PUT_LONG (buf, oa->oa_length);
+         if (oa->oa_length)
+           {
+             bcopy (oa->oa_base, (caddr_t) buf, oa->oa_length);
+             buf = (long *) ((char *) buf + RNDUP (oa->oa_length));
+           }
+         oa = &cmsg->rm_call.cb_verf;
+         IXDR_PUT_ENUM (buf, oa->oa_flavor);
+         IXDR_PUT_LONG (buf, oa->oa_length);
+         if (oa->oa_length)
+           {
+             bcopy (oa->oa_base, (caddr_t) buf, oa->oa_length);
+             /* no real need....
+                buf = (long *) ((char *) buf + RNDUP(oa->oa_length));
+              */
+           }
+         return TRUE;
+       }
+    }
+  if (xdrs->x_op == XDR_DECODE)
+    {
+      buf = XDR_INLINE (xdrs, 8 * BYTES_PER_XDR_UNIT);
+      if (buf != NULL)
+       {
+         cmsg->rm_xid = IXDR_GET_LONG (buf);
+         cmsg->rm_direction = IXDR_GET_ENUM (buf, enum msg_type);
+         if (cmsg->rm_direction != CALL)
+           {
+             return FALSE;
+           }
+         cmsg->rm_call.cb_rpcvers = IXDR_GET_LONG (buf);
+         if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION)
+           {
+             return FALSE;
+           }
+         cmsg->rm_call.cb_prog = IXDR_GET_LONG (buf);
+         cmsg->rm_call.cb_vers = IXDR_GET_LONG (buf);
+         cmsg->rm_call.cb_proc = IXDR_GET_LONG (buf);
+         oa = &cmsg->rm_call.cb_cred;
+         oa->oa_flavor = IXDR_GET_ENUM (buf, enum_t);
+         oa->oa_length = IXDR_GET_LONG (buf);
+         if (oa->oa_length)
+           {
+             if (oa->oa_length > MAX_AUTH_BYTES)
+               {
+                 return FALSE;
                }
-               if (cmsg->rm_call.cb_verf.oa_length > MAX_AUTH_BYTES) {
-                       return (FALSE);
+             if (oa->oa_base == NULL)
+               {
+                 oa->oa_base = (caddr_t)
+                   mem_alloc (oa->oa_length);
                }
-               buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT
-                       + RNDUP(cmsg->rm_call.cb_cred.oa_length)
-                       + 2 * BYTES_PER_XDR_UNIT
-                       + RNDUP(cmsg->rm_call.cb_verf.oa_length));
-               if (buf != NULL) {
-                       IXDR_PUT_LONG(buf, cmsg->rm_xid);
-                       IXDR_PUT_ENUM(buf, cmsg->rm_direction);
-                       if (cmsg->rm_direction != CALL) {
-                               return (FALSE);
-                       }
-                       IXDR_PUT_LONG(buf, cmsg->rm_call.cb_rpcvers);
-                       if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) {
-                               return (FALSE);
-                       }
-                       IXDR_PUT_LONG(buf, cmsg->rm_call.cb_prog);
-                       IXDR_PUT_LONG(buf, cmsg->rm_call.cb_vers);
-                       IXDR_PUT_LONG(buf, cmsg->rm_call.cb_proc);
-                       oa = &cmsg->rm_call.cb_cred;
-                       IXDR_PUT_ENUM(buf, oa->oa_flavor);
-                       IXDR_PUT_LONG(buf, oa->oa_length);
-                       if (oa->oa_length) {
-                               bcopy(oa->oa_base, (caddr_t)buf, oa->oa_length);
-                               buf = (long *) ((char *) buf + RNDUP(oa->oa_length));
-                       }
-                       oa = &cmsg->rm_call.cb_verf;
-                       IXDR_PUT_ENUM(buf, oa->oa_flavor);
-                       IXDR_PUT_LONG(buf, oa->oa_length);
-                       if (oa->oa_length) {
-                               bcopy(oa->oa_base, (caddr_t)buf, oa->oa_length);
-                               /* no real need....
-                               buf = (long *) ((char *) buf + RNDUP(oa->oa_length));
-                               */
-                       }
-                       return (TRUE);
+             buf = XDR_INLINE (xdrs, RNDUP (oa->oa_length));
+             if (buf == NULL)
+               {
+                 if (xdr_opaque (xdrs, oa->oa_base,
+                                 oa->oa_length) == FALSE)
+                   {
+                     return FALSE;
+                   }
                }
-       }
-       if (xdrs->x_op == XDR_DECODE) {
-               buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT);
-               if (buf != NULL) {
-                       cmsg->rm_xid = IXDR_GET_LONG(buf);
-                       cmsg->rm_direction = IXDR_GET_ENUM(buf, enum msg_type);
-                       if (cmsg->rm_direction != CALL) {
-                               return (FALSE);
-                       }
-                       cmsg->rm_call.cb_rpcvers = IXDR_GET_LONG(buf);
-                       if (cmsg->rm_call.cb_rpcvers != RPC_MSG_VERSION) {
-                               return (FALSE);
-                       }
-                       cmsg->rm_call.cb_prog = IXDR_GET_LONG(buf);
-                       cmsg->rm_call.cb_vers = IXDR_GET_LONG(buf);
-                       cmsg->rm_call.cb_proc = IXDR_GET_LONG(buf);
-                       oa = &cmsg->rm_call.cb_cred;
-                       oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t);
-                       oa->oa_length = IXDR_GET_LONG(buf);
-                       if (oa->oa_length) {
-                               if (oa->oa_length > MAX_AUTH_BYTES) {
-                                       return (FALSE);
-                               }
-                               if (oa->oa_base == NULL) {
-                                       oa->oa_base = (caddr_t)
-                                               mem_alloc(oa->oa_length);
-                               }
-                               buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length));
-                               if (buf == NULL) {
-                                       if (xdr_opaque(xdrs, oa->oa_base,
-                                           oa->oa_length) == FALSE) {
-                                               return (FALSE);
-                                       }
-                               } else {
-                                       bcopy((caddr_t)buf, oa->oa_base,
-                                           oa->oa_length);
-                                       /* no real need....
-                                       buf = (long *) ((char *) buf
-                                             + RNDUP(oa->oa_length));
-                                       */
-                               }
-                       }
-                       oa = &cmsg->rm_call.cb_verf;
-                       buf = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT);
-                       if (buf == NULL) {
-                               if (xdr_enum(xdrs, &oa->oa_flavor) == FALSE ||
-                                   xdr_u_int(xdrs, &oa->oa_length) == FALSE) {
-                                       return (FALSE);
-                               }
-                       } else {
-                               oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t);
-                               oa->oa_length = IXDR_GET_LONG(buf);
-                       }
-                       if (oa->oa_length) {
-                               if (oa->oa_length > MAX_AUTH_BYTES) {
-                                       return (FALSE);
-                               }
-                               if (oa->oa_base == NULL) {
-                                       oa->oa_base = (caddr_t)
-                                               mem_alloc(oa->oa_length);
-                               }
-                               buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length));
-                               if (buf == NULL) {
-                                       if (xdr_opaque(xdrs, oa->oa_base,
-                                           oa->oa_length) == FALSE) {
-                                               return (FALSE);
-                                       }
-                               } else {
-                                       bcopy((caddr_t)buf, oa->oa_base,
-                                           oa->oa_length);
-                                       /* no real need...
-                                       buf = (long *) ((char *) buf
-                                             + RNDUP(oa->oa_length));
-                                       */
-                               }
-                       }
-                       return (TRUE);
+             else
+               {
+                 bcopy ((caddr_t) buf, oa->oa_base,
+                        oa->oa_length);
+                 /* no real need....
+                    buf = (long *) ((char *) buf
+                    + RNDUP(oa->oa_length));
+                  */
+               }
+           }
+         oa = &cmsg->rm_call.cb_verf;
+         buf = XDR_INLINE (xdrs, 2 * BYTES_PER_XDR_UNIT);
+         if (buf == NULL)
+           {
+             if (xdr_enum (xdrs, &oa->oa_flavor) == FALSE ||
+                 xdr_u_int (xdrs, &oa->oa_length) == FALSE)
+               {
+                 return FALSE;
+               }
+           }
+         else
+           {
+             oa->oa_flavor = IXDR_GET_ENUM (buf, enum_t);
+             oa->oa_length = IXDR_GET_LONG (buf);
+           }
+         if (oa->oa_length)
+           {
+             if (oa->oa_length > MAX_AUTH_BYTES)
+               {
+                 return FALSE;
                }
+             if (oa->oa_base == NULL)
+               {
+                 oa->oa_base = (caddr_t)
+                   mem_alloc (oa->oa_length);
+               }
+             buf = XDR_INLINE (xdrs, RNDUP (oa->oa_length));
+             if (buf == NULL)
+               {
+                 if (xdr_opaque (xdrs, oa->oa_base,
+                                 oa->oa_length) == FALSE)
+                   {
+                     return FALSE;
+                   }
+               }
+             else
+               {
+                 bcopy ((caddr_t) buf, oa->oa_base,
+                        oa->oa_length);
+                 /* no real need...
+                    buf = (long *) ((char *) buf
+                    + RNDUP(oa->oa_length));
+                  */
+               }
+           }
+         return TRUE;
        }
-       if (
-           xdr_u_long(xdrs, &(cmsg->rm_xid)) &&
-           xdr_enum(xdrs, (enum_t *)&(cmsg->rm_direction)) &&
-           (cmsg->rm_direction == CALL) &&
-           xdr_u_long(xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
-           (cmsg->rm_call.cb_rpcvers == RPC_MSG_VERSION) &&
-           xdr_u_long(xdrs, &(cmsg->rm_call.cb_prog)) &&
-           xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers)) &&
-           xdr_u_long(xdrs, &(cmsg->rm_call.cb_proc)) &&
-           xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_cred)) )
-           return (xdr_opaque_auth(xdrs, &(cmsg->rm_call.cb_verf)));
-       return (FALSE);
+    }
+  if (
+       xdr_u_long (xdrs, &(cmsg->rm_xid)) &&
+       xdr_enum (xdrs, (enum_t *) & (cmsg->rm_direction)) &&
+       (cmsg->rm_direction == CALL) &&
+       xdr_u_long (xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
+       (cmsg->rm_call.cb_rpcvers == RPC_MSG_VERSION) &&
+       xdr_u_long (xdrs, &(cmsg->rm_call.cb_prog)) &&
+       xdr_u_long (xdrs, &(cmsg->rm_call.cb_vers)) &&
+       xdr_u_long (xdrs, &(cmsg->rm_call.cb_proc)) &&
+       xdr_opaque_auth (xdrs, &(cmsg->rm_call.cb_cred)))
+    return xdr_opaque_auth (xdrs, &(cmsg->rm_call.cb_verf));
+  return FALSE;
 }
-
index a848817..26bf1a2 100644 (file)
 static char sccsid[] = "@(#)rpc_dtablesize.c 1.2 87/08/11 Copyr 1987 Sun Micro";
 #endif
 
+#include <unistd.h>
+
 /*
  * Cache the result of getdtablesize(), so we don't have to do an
  * expensive system call every time.
  */
-_rpc_dtablesize()
+int
+_rpc_dtablesize (void)
 {
-       static int size;
-       
-       if (size == 0) {
-               size = getdtablesize();
-       }
-       return (size);
+  static int size;
+
+  if (size == 0)
+    size = getdtablesize ();
+
+  return size;
 }
index 8da20c6..79a58c2 100644 (file)
@@ -55,26 +55,22 @@ static char sccsid[] = "@(#)rpc_prot.c 1.36 87/08/11 Copyr 1984 Sun Micro";
  * (see auth.h)
  */
 bool_t
-xdr_opaque_auth(xdrs, ap)
-       register XDR *xdrs;
-       register struct opaque_auth *ap;
+xdr_opaque_auth (XDR *xdrs, struct opaque_auth *ap)
 {
 
-       if (xdr_enum(xdrs, &(ap->oa_flavor)))
-               return (xdr_bytes(xdrs, &ap->oa_base,
-                       &ap->oa_length, MAX_AUTH_BYTES));
-       return (FALSE);
+  if (xdr_enum (xdrs, &(ap->oa_flavor)))
+    return xdr_bytes (xdrs, &ap->oa_base,
+                     &ap->oa_length, MAX_AUTH_BYTES);
+  return FALSE;
 }
 
 /*
  * XDR a DES block
  */
 bool_t
-xdr_des_block(xdrs, blkp)
-       register XDR *xdrs;
-       register des_block *blkp;
+xdr_des_block (XDR *xdrs, des_block *blkp)
 {
-       return (xdr_opaque(xdrs, (caddr_t)blkp, sizeof(des_block)));
+  return xdr_opaque (xdrs, (caddr_t) blkp, sizeof (des_block));
 }
 
 /* * * * * * * * * * * * * * XDR RPC MESSAGE * * * * * * * * * * * * * * * */
@@ -83,74 +79,70 @@ xdr_des_block(xdrs, blkp)
  * XDR the MSG_ACCEPTED part of a reply message union
  */
 bool_t
-xdr_accepted_reply(xdrs, ar)
-       register XDR *xdrs;
-       register struct accepted_reply *ar;
+xdr_accepted_reply (XDR *xdrs, struct accepted_reply *ar)
 {
-
-       /* personalized union, rather than calling xdr_union */
-       if (! xdr_opaque_auth(xdrs, &(ar->ar_verf)))
-               return (FALSE);
-       if (! xdr_enum(xdrs, (enum_t *)&(ar->ar_stat)))
-               return (FALSE);
-       switch (ar->ar_stat) {
-
-       case SUCCESS:
-               return ((*(ar->ar_results.proc))(xdrs, ar->ar_results.where));
-
-       case PROG_MISMATCH:
-               if (! xdr_u_long(xdrs, &(ar->ar_vers.low)))
-                       return (FALSE);
-               return (xdr_u_long(xdrs, &(ar->ar_vers.high)));
-       }
-       return (TRUE);  /* TRUE => open ended set of problems */
+  /* personalized union, rather than calling xdr_union */
+  if (!xdr_opaque_auth (xdrs, &(ar->ar_verf)))
+    return FALSE;
+  if (!xdr_enum (xdrs, (enum_t *) & (ar->ar_stat)))
+    return FALSE;
+  switch (ar->ar_stat)
+    {
+    case SUCCESS:
+      return ((*(ar->ar_results.proc)) (xdrs, ar->ar_results.where));
+    case PROG_MISMATCH:
+      if (!xdr_u_long (xdrs, &(ar->ar_vers.low)))
+       return FALSE;
+      return (xdr_u_long (xdrs, &(ar->ar_vers.high)));
+    default:
+      return TRUE;
+    }
+  return TRUE;         /* TRUE => open ended set of problems */
 }
 
 /*
  * XDR the MSG_DENIED part of a reply message union
  */
 bool_t
-xdr_rejected_reply(xdrs, rr)
-       register XDR *xdrs;
-       register struct rejected_reply *rr;
+xdr_rejected_reply (XDR *xdrs, struct rejected_reply *rr)
 {
-
-       /* personalized union, rather than calling xdr_union */
-       if (! xdr_enum(xdrs, (enum_t *)&(rr->rj_stat)))
-               return (FALSE);
-       switch (rr->rj_stat) {
-
-       case RPC_MISMATCH:
-               if (! xdr_u_long(xdrs, &(rr->rj_vers.low)))
-                       return (FALSE);
-               return (xdr_u_long(xdrs, &(rr->rj_vers.high)));
-
-       case AUTH_ERROR:
-               return (xdr_enum(xdrs, (enum_t *)&(rr->rj_why)));
-       }
-       return (FALSE);
+  /* personalized union, rather than calling xdr_union */
+  if (!xdr_enum (xdrs, (enum_t *) & (rr->rj_stat)))
+    return FALSE;
+  switch (rr->rj_stat)
+    {
+    case RPC_MISMATCH:
+      if (!xdr_u_long (xdrs, &(rr->rj_vers.low)))
+       return FALSE;
+      return xdr_u_long (xdrs, &(rr->rj_vers.high));
+
+    case AUTH_ERROR:
+      return xdr_enum (xdrs, (enum_t *) & (rr->rj_why));
+    }
+  return FALSE;
 }
 
-static struct xdr_discrim reply_dscrm[3] = {
-       { (int)MSG_ACCEPTED, xdr_accepted_reply },
-       { (int)MSG_DENIED, xdr_rejected_reply },
-       { __dontcare__, NULL_xdrproc_t } };
+static const struct xdr_discrim reply_dscrm[3] =
+{
+  {(int) MSG_ACCEPTED, (xdrproc_t) xdr_accepted_reply},
+  {(int) MSG_DENIED, (xdrproc_t) xdr_rejected_reply},
+  {__dontcare__, NULL_xdrproc_t}};
 
 /*
  * XDR a reply message
  */
 bool_t
-xdr_replymsg(xdrs, rmsg)
-       register XDR *xdrs;
-       register struct rpc_msg *rmsg;
+xdr_replymsg (xdrs, rmsg)
+     XDR *xdrs;
+     struct rpc_msg *rmsg;
 {
-       if (
-           xdr_u_long(xdrs, &(rmsg->rm_xid)) &&
-           xdr_enum(xdrs, (enum_t *)&(rmsg->rm_direction)) &&
-           (rmsg->rm_direction == REPLY) )
-               return (xdr_union(xdrs, (enum_t *)&(rmsg->rm_reply.rp_stat),
-                  (caddr_t)&(rmsg->rm_reply.ru), reply_dscrm, NULL_xdrproc_t));
-       return (FALSE);
+  if (xdr_u_long (xdrs, &(rmsg->rm_xid)) &&
+      xdr_enum (xdrs, (enum_t *) & (rmsg->rm_direction)) &&
+      (rmsg->rm_direction == REPLY))
+    return xdr_union (xdrs, (enum_t *) & (rmsg->rm_reply.rp_stat),
+                     (caddr_t) & (rmsg->rm_reply.ru), reply_dscrm,
+                     NULL_xdrproc_t);
+  return FALSE;
 }
 
 
@@ -160,128 +152,128 @@ xdr_replymsg(xdrs, rmsg)
  * The rm_xid is not really static, but the user can easily munge on the fly.
  */
 bool_t
-xdr_callhdr(xdrs, cmsg)
-       register XDR *xdrs;
-       register struct rpc_msg *cmsg;
+xdr_callhdr (xdrs, cmsg)
+     XDR *xdrs;
+     struct rpc_msg *cmsg;
 {
 
-       cmsg->rm_direction = CALL;
-       cmsg->rm_call.cb_rpcvers = RPC_MSG_VERSION;
-       if (
-           (xdrs->x_op == XDR_ENCODE) &&
-           xdr_u_long(xdrs, &(cmsg->rm_xid)) &&
-           xdr_enum(xdrs, (enum_t *)&(cmsg->rm_direction)) &&
-           xdr_u_long(xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
-           xdr_u_long(xdrs, &(cmsg->rm_call.cb_prog)) )
-           return (xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers)));
-       return (FALSE);
+  cmsg->rm_direction = CALL;
+  cmsg->rm_call.cb_rpcvers = RPC_MSG_VERSION;
+  if (
+       (xdrs->x_op == XDR_ENCODE) &&
+       xdr_u_long (xdrs, &(cmsg->rm_xid)) &&
+       xdr_enum (xdrs, (enum_t *) & (cmsg->rm_direction)) &&
+       xdr_u_long (xdrs, &(cmsg->rm_call.cb_rpcvers)) &&
+       xdr_u_long (xdrs, &(cmsg->rm_call.cb_prog)))
+    return xdr_u_long (xdrs, &(cmsg->rm_call.cb_vers));
+  return FALSE;
 }
 
 /* ************************** Client utility routine ************* */
 
 static void
-accepted(acpt_stat, error)
-       register enum accept_stat acpt_stat;
-       register struct rpc_err *error;
+accepted (enum accept_stat acpt_stat,
+         struct rpc_err *error)
 {
-
-       switch (acpt_stat) {
-
-       case PROG_UNAVAIL:
-               error->re_status = RPC_PROGUNAVAIL;
-               return;
-
-       case PROG_MISMATCH:
-               error->re_status = RPC_PROGVERSMISMATCH;
-               return;
-
-       case PROC_UNAVAIL:
-               error->re_status = RPC_PROCUNAVAIL;
-               return;
-
-       case GARBAGE_ARGS:
-               error->re_status = RPC_CANTDECODEARGS;
-               return;
-
-       case SYSTEM_ERR:
-               error->re_status = RPC_SYSTEMERROR;
-               return;
-
-       case SUCCESS:
-               error->re_status = RPC_SUCCESS;
-               return;
-       }
-       /* something's wrong, but we don't know what ... */
-       error->re_status = RPC_FAILED;
-       error->re_lb.s1 = (long)MSG_ACCEPTED;
-       error->re_lb.s2 = (long)acpt_stat;
+  switch (acpt_stat)
+    {
+
+    case PROG_UNAVAIL:
+      error->re_status = RPC_PROGUNAVAIL;
+      return;
+
+    case PROG_MISMATCH:
+      error->re_status = RPC_PROGVERSMISMATCH;
+      return;
+
+    case PROC_UNAVAIL:
+      error->re_status = RPC_PROCUNAVAIL;
+      return;
+
+    case GARBAGE_ARGS:
+      error->re_status = RPC_CANTDECODEARGS;
+      return;
+
+    case SYSTEM_ERR:
+      error->re_status = RPC_SYSTEMERROR;
+      return;
+
+    case SUCCESS:
+      error->re_status = RPC_SUCCESS;
+      return;
+    }
+  /* something's wrong, but we don't know what ... */
+  error->re_status = RPC_FAILED;
+  error->re_lb.s1 = (long) MSG_ACCEPTED;
+  error->re_lb.s2 = (long) acpt_stat;
 }
 
 static void
-rejected(rjct_stat, error)
-       register enum reject_stat rjct_stat;
-       register struct rpc_err *error;
+rejected (enum reject_stat rjct_stat,
+         struct rpc_err *error)
 {
-
-       switch (rjct_stat) {
-
-       case RPC_VERSMISMATCH:
-               error->re_status = RPC_VERSMISMATCH;
-               return;
-
-       case AUTH_ERROR:
-               error->re_status = RPC_AUTHERROR;
-               return;
-       }
-       /* something's wrong, but we don't know what ... */
-       error->re_status = RPC_FAILED;
-       error->re_lb.s1 = (long)MSG_DENIED;
-       error->re_lb.s2 = (long)rjct_stat;
+  switch (rjct_stat)
+    {
+    case RPC_VERSMISMATCH:
+      error->re_status = RPC_VERSMISMATCH;
+      return;
+    case AUTH_ERROR:
+      error->re_status = RPC_AUTHERROR;
+      return;
+    default:
+      /* something's wrong, but we don't know what ... */
+      error->re_status = RPC_FAILED;
+      error->re_lb.s1 = (long) MSG_DENIED;
+      error->re_lb.s2 = (long) rjct_stat;
+      return;
+    }
 }
 
 /*
  * given a reply message, fills in the error
  */
 void
-_seterr_reply(msg, error)
-       register struct rpc_msg *msg;
-       register struct rpc_err *error;
+_seterr_reply (struct rpc_msg *msg,
+              struct rpc_err *error)
 {
-
-       /* optimized for normal, SUCCESSful case */
-       switch (msg->rm_reply.rp_stat) {
-
-       case MSG_ACCEPTED:
-               if (msg->acpted_rply.ar_stat == SUCCESS) {
-                       error->re_status = RPC_SUCCESS;
-                       return;
-               };
-               accepted(msg->acpted_rply.ar_stat, error);
-               break;
-
-       case MSG_DENIED:
-               rejected(msg->rjcted_rply.rj_stat, error);
-               break;
-
-       default:
-               error->re_status = RPC_FAILED;
-               error->re_lb.s1 = (long)(msg->rm_reply.rp_stat);
-               break;
-       }
-       switch (error->re_status) {
-
-       case RPC_VERSMISMATCH:
-               error->re_vers.low = msg->rjcted_rply.rj_vers.low;
-               error->re_vers.high = msg->rjcted_rply.rj_vers.high;
-               break;
-
-       case RPC_AUTHERROR:
-               error->re_why = msg->rjcted_rply.rj_why;
-               break;
-
-       case RPC_PROGVERSMISMATCH:
-               error->re_vers.low = msg->acpted_rply.ar_vers.low;
-               error->re_vers.high = msg->acpted_rply.ar_vers.high;
-               break;
-       }
+  /* optimized for normal, SUCCESSful case */
+  switch (msg->rm_reply.rp_stat)
+    {
+    case MSG_ACCEPTED:
+      if (msg->acpted_rply.ar_stat == SUCCESS)
+       {
+         error->re_status = RPC_SUCCESS;
+         return;
+       };
+      accepted (msg->acpted_rply.ar_stat, error);
+      break;
+
+    case MSG_DENIED:
+      rejected (msg->rjcted_rply.rj_stat, error);
+      break;
+
+    default:
+      error->re_status = RPC_FAILED;
+      error->re_lb.s1 = (long) (msg->rm_reply.rp_stat);
+      break;
+    }
+  switch (error->re_status)
+    {
+
+    case RPC_VERSMISMATCH:
+      error->re_vers.low = msg->rjcted_rply.rj_vers.low;
+      error->re_vers.high = msg->rjcted_rply.rj_vers.high;
+      break;
+
+    case RPC_AUTHERROR:
+      error->re_why = msg->rjcted_rply.rj_why;
+      break;
+
+    case RPC_PROGVERSMISMATCH:
+      error->re_vers.low = msg->acpted_rply.ar_vers.low;
+      error->re_vers.high = msg->acpted_rply.ar_vers.high;
+      break;
+    default:
+      break;
+    }
 }
index a5551d9..d1e1277 100644 (file)
  * Mountain View, California  94043
  */
 
-/* 
+/*
  * From: @(#)rpc_sample.c  1.1  90/08/30  (C) 1987 SMI
  */
-char sample_rcsid[] = 
+char sample_rcsid[] =
   "$Id$";
 
 /*
@@ -45,209 +45,226 @@ char sample_rcsid[] =
 #include "proto.h"
 
 
-static char RQSTP[] = "rqstp";
+static const char RQSTP[] = "rqstp";
 
-static void write_sample_client(const char *program_name, version_list *vp);
-static void write_sample_server(definition *def);
-static void return_type(proc_list *plist);
+static void write_sample_client (const char *program_name, version_list * vp);
+static void write_sample_server (definition * def);
+static void return_type (proc_list * plist);
 
 
 void
-write_sample_svc(definition *def)
+write_sample_svc (definition * def)
 {
 
-       if (def->def_kind != DEF_PROGRAM) 
-         return;
-       write_sample_server(def);
+  if (def->def_kind != DEF_PROGRAM)
+    return;
+  write_sample_server (def);
 }
 
 
 int
-write_sample_clnt(definition *def)
+write_sample_clnt (definition * def)
 {
-        version_list *vp;
-       int count = 0;
-
-       if (def->def_kind != DEF_PROGRAM) 
-         return( 0 );
-       /* generate sample code for each version */
-       for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
-         write_sample_client(def->def_name, vp );
-         ++count;
-       }
-       return( count );
+  version_list *vp;
+  int count = 0;
+
+  if (def->def_kind != DEF_PROGRAM)
+    return (0);
+  /* generate sample code for each version */
+  for (vp = def->def.pr.versions; vp != NULL; vp = vp->next)
+    {
+      write_sample_client (def->def_name, vp);
+      ++count;
+    }
+  return (count);
 }
 
 
 static void
-write_sample_client(const char *program_name, version_list *vp)
+write_sample_client (const char *program_name, version_list * vp)
 {
   proc_list *proc;
   int i;
   decl_list *l;
 
-  f_print(fout, "\n\nvoid\n" );
-  pvname( program_name, vp->vers_num );
-  if( Cflag )
-    f_print(fout,"( char* host )\n{\n" );
+  f_print (fout, "\n\nvoid\n");
+  pvname (program_name, vp->vers_num);
+  if (Cflag)
+    f_print (fout, "( char* host )\n{\n");
   else
-    f_print(fout, "(host)\nchar *host;\n{\n" );
-  f_print(fout, "\tCLIENT *clnt;\n");
+    f_print (fout, "(host)\nchar *host;\n{\n");
+  f_print (fout, "\tCLIENT *clnt;\n");
 
   i = 0;
-  for (proc = vp->procs; proc != NULL; proc = proc->next) {
-      f_print(fout, "\t");
-      ptype(proc->res_prefix, proc->res_type, 1);
-      f_print(fout, " *result_%d;\n",++i);
+  for (proc = vp->procs; proc != NULL; proc = proc->next)
+    {
+      f_print (fout, "\t");
+      ptype (proc->res_prefix, proc->res_type, 1);
+      f_print (fout, " *result_%d;\n", ++i);
       /* print out declarations for arguments */
-      if( proc->arg_num < 2 && !newstyle) {
-       f_print( fout, "\t" );
-       if( !streq( proc->args.decls->decl.type, "void") )
-         ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
-       else
-         f_print(fout, "char* ");  /* cannot have "void" type */
-       f_print(fout, " ");
-       pvname( proc->proc_name, vp->vers_num );
-       f_print(fout, "_arg;\n");
-      } else if (!streq( proc->args.decls->decl.type, "void")) {
-       for (l = proc->args.decls; l != NULL; l = l->next) {
-         f_print( fout, "\t" );
-         ptype(l->decl.prefix, l->decl.type, 1);
-         f_print( fout, " ");
-         pvname( proc->proc_name, vp->vers_num );
-         f_print(fout, "_%s;\n", l->decl.name );
-/*       pdeclaration(proc->args.argname, &l->decl, 1, ";\n" );*/
+      if (proc->arg_num < 2 && !newstyle)
+       {
+         f_print (fout, "\t");
+         if (!streq (proc->args.decls->decl.type, "void"))
+           ptype (proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
+         else
+           f_print (fout, "char* ");   /* cannot have "void" type */
+         f_print (fout, " ");
+         pvname (proc->proc_name, vp->vers_num);
+         f_print (fout, "_arg;\n");
+       }
+      else if (!streq (proc->args.decls->decl.type, "void"))
+       {
+         for (l = proc->args.decls; l != NULL; l = l->next)
+           {
+             f_print (fout, "\t");
+             ptype (l->decl.prefix, l->decl.type, 1);
+             f_print (fout, " ");
+             pvname (proc->proc_name, vp->vers_num);
+             f_print (fout, "_%s;\n", l->decl.name);
+/*        pdeclaration(proc->args.argname, &l->decl, 1, ";\n" ); */
+           }
        }
-      }
     }
 
   /* generate creation of client handle */
-  f_print(fout, "\tclnt = clnt_create(host, %s, %s, \"%s\");\n", 
-         program_name, vp->vers_name, tirpcflag? "netpath" : "udp");
-  f_print(fout, "\tif (clnt == NULL) {\n");
-  f_print(fout, "\t\tclnt_pcreateerror(host);\n");
-  f_print(fout, "\t\texit(1);\n\t}\n");
+  f_print (fout, "\tclnt = clnt_create(host, %s, %s, \"%s\");\n",
+          program_name, vp->vers_name, tirpcflag ? "netpath" : "udp");
+  f_print (fout, "\tif (clnt == NULL) {\n");
+  f_print (fout, "\t\tclnt_pcreateerror(host);\n");
+  f_print (fout, "\t\texit(1);\n\t}\n");
 
   /* generate calls to procedures */
   i = 0;
-  for (proc = vp->procs; proc != NULL; proc = proc->next) {
-      f_print(fout, "\tresult_%d = ",++i);      
-      pvname(proc->proc_name, vp->vers_num);
-      if (proc->arg_num < 2 && !newstyle) {
-       f_print(fout, "(" );
-       if( streq( proc->args.decls->decl.type, "void") )  /* cast to void* */
-         f_print(fout, "(void*)");
-       f_print(fout, "&" );
-       pvname(proc->proc_name, vp->vers_num );
-       f_print(fout, "_arg, clnt);\n");
-      } else if (streq( proc->args.decls->decl.type, "void")) {
-           f_print(fout, "(clnt);\n");
-         }
-      else {
-       f_print(fout, "(");
-       for (l = proc->args.decls;  l != NULL; l = l->next) {
-         pvname( proc->proc_name, vp->vers_num );
-         f_print(fout, "_%s, ", l->decl.name);
+  for (proc = vp->procs; proc != NULL; proc = proc->next)
+    {
+      f_print (fout, "\tresult_%d = ", ++i);
+      pvname (proc->proc_name, vp->vers_num);
+      if (proc->arg_num < 2 && !newstyle)
+       {
+         f_print (fout, "(");
+         if (streq (proc->args.decls->decl.type, "void"))      /* cast to void* */
+           f_print (fout, "(void*)");
+         f_print (fout, "&");
+         pvname (proc->proc_name, vp->vers_num);
+         f_print (fout, "_arg, clnt);\n");
        }
-       f_print(fout, "clnt);\n");
-      }
-      f_print(fout, "\tif (result_%d == NULL) {\n", i);
-      f_print(fout, "\t\tclnt_perror(clnt, \"call failed:\");\n");
-      f_print(fout, "\t}\n");
+      else if (streq (proc->args.decls->decl.type, "void"))
+       {
+         f_print (fout, "(clnt);\n");
+       }
+      else
+       {
+         f_print (fout, "(");
+         for (l = proc->args.decls; l != NULL; l = l->next)
+           {
+             pvname (proc->proc_name, vp->vers_num);
+             f_print (fout, "_%s, ", l->decl.name);
+           }
+         f_print (fout, "clnt);\n");
+       }
+      f_print (fout, "\tif (result_%d == NULL) {\n", i);
+      f_print (fout, "\t\tclnt_perror(clnt, \"call failed:\");\n");
+      f_print (fout, "\t}\n");
     }
 
-  f_print(fout, "\tclnt_destroy( clnt );\n" );
-  f_print(fout, "}\n");
+  f_print (fout, "\tclnt_destroy( clnt );\n");
+  f_print (fout, "}\n");
 }
 
 static void
-write_sample_server(definition *def)
+write_sample_server (definition * def)
 {
-       version_list *vp;
-       proc_list *proc;
-
-       for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
-               for (proc = vp->procs; proc != NULL; proc = proc->next) {
-                       f_print(fout, "\n");
-/*                     if( Cflag )
-                         f_print( fout, "extern \"C\"{\n");
-*/
-                       return_type(proc);
-                       f_print(fout, "* \n");
-                       if( Cflag )
-                         pvname_svc(proc->proc_name, vp->vers_num);
-                       else
-                         pvname(proc->proc_name, vp->vers_num);
-                       printarglist( proc, RQSTP, "struct svc_req *" );
-
-                       f_print(fout, "{\n");
-                       f_print(fout, "\n\tstatic ");
-                       if( !streq( proc->res_type, "void") )
-                         return_type(proc);
-                       else
-                         f_print(fout, "char*" );  /* cannot have void type */
-                       f_print(fout, " result;\n" /*, proc->res_type*/ /*?*/);
-                       f_print(fout, 
-                               "\n\t/*\n\t * insert server code here\n\t */\n\n");
-                       if( !streq( proc->res_type, "void") )
-                         f_print(fout, "\treturn(&result);\n}\n");
-                       else  /* cast back to void * */
-                         f_print(fout, "\treturn((void*) &result);\n}\n"); 
-/*                     if( Cflag)
-                         f_print( fout, "};\n");
-*/
-
-               }               
+  version_list *vp;
+  proc_list *proc;
+
+  for (vp = def->def.pr.versions; vp != NULL; vp = vp->next)
+    {
+      for (proc = vp->procs; proc != NULL; proc = proc->next)
+       {
+         f_print (fout, "\n");
+/*                      if( Cflag )
+   f_print( fout, "extern \"C\"{\n");
+ */
+         return_type (proc);
+         f_print (fout, "* \n");
+         if (Cflag)
+           pvname_svc (proc->proc_name, vp->vers_num);
+         else
+           pvname (proc->proc_name, vp->vers_num);
+         printarglist (proc, RQSTP, "struct svc_req *");
+
+         f_print (fout, "{\n");
+         f_print (fout, "\n\tstatic ");
+         if (!streq (proc->res_type, "void"))
+           return_type (proc);
+         else
+           f_print (fout, "char*");    /* cannot have void type */
+         f_print (fout, " result;\n" /*, proc->res_type *//*? */ );
+         f_print (fout,
+                  "\n\t/*\n\t * insert server code here\n\t */\n\n");
+         if (!streq (proc->res_type, "void"))
+           f_print (fout, "\treturn(&result);\n}\n");
+         else                  /* cast back to void * */
+           f_print (fout, "\treturn((void*) &result);\n}\n");
+/*                      if( Cflag)
+   f_print( fout, "};\n");
+ */
+
        }
+    }
 }
 
 
 
 static void
-return_type(proc_list *plist)
+return_type (proc_list * plist)
 {
-  ptype( plist->res_prefix, plist->res_type, 1 );
+  ptype (plist->res_prefix, plist->res_type, 1);
 }
 
 void
-add_sample_msg(void)
+add_sample_msg (void)
 {
-       f_print(fout, "/*\n");
-       f_print(fout, " * This is sample code generated by rpcgen.\n");
-       f_print(fout, " * These are only templates and you can use them\n");
-       f_print(fout, " * as a guideline for developing your own functions.\n");
-       f_print(fout, " */\n\n");
+  f_print (fout, "/*\n");
+  f_print (fout, " * This is sample code generated by rpcgen.\n");
+  f_print (fout, " * These are only templates and you can use them\n");
+  f_print (fout, " * as a guideline for developing your own functions.\n");
+  f_print (fout, " */\n\n");
 }
 
 void
-write_sample_clnt_main(void)
+write_sample_clnt_main (void)
 {
   list *l;
   definition *def;
   version_list *vp;
 
-  f_print(fout, "\n\n" );
-  if( Cflag )
-    f_print(fout,"main( int argc, char* argv[] )\n{\n" );
+  f_print (fout, "\n\n");
+  if (Cflag)
+    f_print (fout, "main( int argc, char* argv[] )\n{\n");
   else
-    f_print(fout, "main(argc, argv)\nint argc;\nchar *argv[];\n{\n" );
-
-  f_print(fout, "\tchar *host;");
-  f_print(fout, "\n\n\tif(argc < 2) {");
-  f_print(fout, "\n\t\tprintf(\"usage: %%s server_host\\n\", argv[0]);\n" );
-  f_print(fout, "\t\texit(1);\n\t}");
-  f_print(fout, "\n\thost = argv[1];\n");
-
-  for (l = defined; l != NULL; l = l->next) {
-               def = l->val;
-               if (def->def_kind != DEF_PROGRAM) {
-                       continue;
-               }
-               for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
-                       f_print( fout, "\t" );
-                       pvname(def->def_name, vp->vers_num);
-                       f_print( fout, "( host );\n" );
-                     }
-               }
-  f_print(fout, "}\n");
+    f_print (fout, "main(argc, argv)\nint argc;\nchar *argv[];\n{\n");
+
+  f_print (fout, "\tchar *host;");
+  f_print (fout, "\n\n\tif(argc < 2) {");
+  f_print (fout, "\n\t\tprintf(\"usage: %%s server_host\\n\", argv[0]);\n");
+  f_print (fout, "\t\texit(1);\n\t}");
+  f_print (fout, "\n\thost = argv[1];\n");
+
+  for (l = defined; l != NULL; l = l->next)
+    {
+      def = l->val;
+      if (def->def_kind != DEF_PROGRAM)
+       {
+         continue;
+       }
+      for (vp = def->def.pr.versions; vp != NULL; vp = vp->next)
+       {
+         f_print (fout, "\t");
+         pvname (def->def_name, vp->vers_num);
+         f_print (fout, "( host );\n");
+       }
+    }
+  f_print (fout, "}\n");
 }
index c0293a3..acffab2 100644 (file)
 /*
  * From: @(#)rpc_scan.c 1.11 89/02/22 (C) 1987 SMI
  */
-char scan_rcsid[] = 
+char scan_rcsid[] =
   "$Id$";
 
 /*
- * rpc_scan.c, Scanner for the RPC protocol compiler 
- * Copyright (C) 1987, Sun Microsystems, Inc. 
+ * rpc_scan.c, Scanner for the RPC protocol compiler
+ * Copyright (C) 1987, Sun Microsystems, Inc.
  */
 #include <stdio.h>
 #include <ctype.h>
@@ -49,439 +49,499 @@ char scan_rcsid[] =
 #define startcomment(where) (where[0] == '/' && where[1] == '*')
 #define endcomment(where) (where[-1] == '*' && where[0] == '/')
 
-static int pushed = 0; /* is a token pushed */
-static token lasttok;  /* last token, if pushed */
+static int pushed = 0;         /* is a token pushed */
+static token lasttok;          /* last token, if pushed */
 
-static void unget_token(token *tokp);
-static void findstrconst(const char **str, const char **val);
-static void findchrconst(const char **str, const char **val);
-static void findconst(const char **str, const char **val);
-static void findkind(const char **mark, token *tokp);
-static int cppline(const char *line);
-static int directive(const char *line);
-static void printdirective(const char *line);
-static void docppline(const char *line, int *lineno, const char **fname);
+static void unget_token (token * tokp);
+static void findstrconst (const char **str, const char **val);
+static void findchrconst (const char **str, const char **val);
+static void findconst (const char **str, const char **val);
+static void findkind (const char **mark, token * tokp);
+static int cppline (const char *line);
+static int directive (const char *line);
+static void printdirective (const char *line);
+static void docppline (const char *line, int *lineno, const char **fname);
 
 /*
- * scan expecting 1 given token 
+ * scan expecting 1 given token
  */
 void
-scan(tok_kind expect, token *tokp)
+scan (tok_kind expect, token * tokp)
 {
-       get_token(tokp);
-       if (tokp->kind != expect) {
-               expected1(expect);
-       }
+  get_token (tokp);
+  if (tokp->kind != expect)
+    {
+      expected1 (expect);
+    }
 }
 
 /*
- * scan expecting any of the 2 given tokens 
+ * scan expecting any of the 2 given tokens
  */
 void
-scan2(tok_kind expect1, tok_kind expect2, token *tokp)
+scan2 (tok_kind expect1, tok_kind expect2, token * tokp)
 {
-       get_token(tokp);
-       if (tokp->kind != expect1 && tokp->kind != expect2) {
-               expected2(expect1, expect2);
-       }
+  get_token (tokp);
+  if (tokp->kind != expect1 && tokp->kind != expect2)
+    {
+      expected2 (expect1, expect2);
+    }
 }
 
 /*
- * scan expecting any of the 3 given token 
+ * scan expecting any of the 3 given token
  */
 void
-scan3(tok_kind expect1, tok_kind expect2, tok_kind expect3, token *tokp)
+scan3 (tok_kind expect1, tok_kind expect2, tok_kind expect3, token * tokp)
 {
-       get_token(tokp);
-       if (tokp->kind != expect1 && tokp->kind != expect2
-           && tokp->kind != expect3) {
-               expected3(expect1, expect2, expect3);
-       }
+  get_token (tokp);
+  if (tokp->kind != expect1 && tokp->kind != expect2
+      && tokp->kind != expect3)
+    {
+      expected3 (expect1, expect2, expect3);
+    }
 }
 
 /*
- * scan expecting a constant, possibly symbolic 
+ * scan expecting a constant, possibly symbolic
  */
 void
-scan_num(token *tokp)
+scan_num (token * tokp)
 {
-       get_token(tokp);
-       switch (tokp->kind) {
-       case TOK_IDENT:
-               break;
-       default:
-               error("constant or identifier expected");
-       }
+  get_token (tokp);
+  switch (tokp->kind)
+    {
+    case TOK_IDENT:
+      break;
+    default:
+      error ("constant or identifier expected");
+    }
 }
 
 /*
- * Peek at the next token 
+ * Peek at the next token
  */
 void
-peek(token *tokp)
+peek (token * tokp)
 {
-       get_token(tokp);
-       unget_token(tokp);
+  get_token (tokp);
+  unget_token (tokp);
 }
 
 /*
- * Peek at the next token and scan it if it matches what you expect 
+ * Peek at the next token and scan it if it matches what you expect
  */
 int
-peekscan(tok_kind expect, token *tokp)
+peekscan (tok_kind expect, token * tokp)
 {
-       peek(tokp);
-       if (tokp->kind == expect) {
-               get_token(tokp);
-               return (1);
-       }
-       return (0);
+  peek (tokp);
+  if (tokp->kind == expect)
+    {
+      get_token (tokp);
+      return (1);
+    }
+  return (0);
 }
 
 /*
- * Get the next token, printing out any directive that are encountered. 
+ * Get the next token, printing out any directive that are encountered.
  */
 void
-get_token(token *tokp)
+get_token (token * tokp)
 {
-       int commenting;
-
-       if (pushed) {
-               pushed = 0;
-               *tokp = lasttok;
-               return;
-       }
-       commenting = 0;
-       for (;;) {
-               if (*where == 0) {
-                       for (;;) {
-                               if (!fgets(curline, MAXLINESIZE, fin)) {
-                                       tokp->kind = TOK_EOF;
-                                       *curline = 0;
-                                       where = curline;
-                                       return;
-                               }
-                               linenum++;
-                               if (commenting) {
-                                       break;
-                               } else if (cppline(curline)) {
-                                       docppline(curline, &linenum, 
-                                                 &infilename);
-                               } else if (directive(curline)) {
-                                       printdirective(curline);
-                               } else {
-                                       break;
-                               }
-                       }
-                       where = curline;
-               } else if (isspace(*where)) {
-                       while (isspace(*where)) {
-                               where++;        /* eat */
-                       }
-               } else if (commenting) {
-                       for (where++; *where; where++) {
-                               if (endcomment(where)) {
-                                       where++;
-                                       commenting--;
-                                       break;
-                               }
-                       }
-               } else if (startcomment(where)) {
-                       where += 2;
-                       commenting++;
-               } else {
-                       break;
+  int commenting;
+
+  if (pushed)
+    {
+      pushed = 0;
+      *tokp = lasttok;
+      return;
+    }
+  commenting = 0;
+  for (;;)
+    {
+      if (*where == 0)
+       {
+         for (;;)
+           {
+             if (!fgets (curline, MAXLINESIZE, fin))
+               {
+                 tokp->kind = TOK_EOF;
+                 *curline = 0;
+                 where = curline;
+                 return;
+               }
+             linenum++;
+             if (commenting)
+               {
+                 break;
                }
+             else if (cppline (curline))
+               {
+                 docppline (curline, &linenum,
+                            &infilename);
+               }
+             else if (directive (curline))
+               {
+                 printdirective (curline);
+               }
+             else
+               {
+                 break;
+               }
+           }
+         where = curline;
        }
-
-       /*
-        * 'where' is not whitespace, comment or directive Must be a token! 
-        */
-       switch (*where) {
-       case ':':
-               tokp->kind = TOK_COLON;
-               where++;
-               break;
-       case ';':
-               tokp->kind = TOK_SEMICOLON;
-               where++;
-               break;
-       case ',':
-               tokp->kind = TOK_COMMA;
-               where++;
-               break;
-       case '=':
-               tokp->kind = TOK_EQUAL;
-               where++;
-               break;
-       case '*':
-               tokp->kind = TOK_STAR;
-               where++;
-               break;
-       case '[':
-               tokp->kind = TOK_LBRACKET;
-               where++;
-               break;
-       case ']':
-               tokp->kind = TOK_RBRACKET;
-               where++;
-               break;
-       case '{':
-               tokp->kind = TOK_LBRACE;
-               where++;
-               break;
-       case '}':
-               tokp->kind = TOK_RBRACE;
-               where++;
-               break;
-       case '(':
-               tokp->kind = TOK_LPAREN;
-               where++;
-               break;
-       case ')':
-               tokp->kind = TOK_RPAREN;
-               where++;
-               break;
-       case '<':
-               tokp->kind = TOK_LANGLE;
-               where++;
-               break;
-       case '>':
-               tokp->kind = TOK_RANGLE;
-               where++;
-               break;
-
-       case '"':
-               tokp->kind = TOK_STRCONST;
-               findstrconst(&where, &tokp->str);
-               break;
-       case '\'':
-               tokp->kind = TOK_CHARCONST;
-               findchrconst(&where, &tokp->str);
-               break;
-
-       case '-':
-       case '0':
-       case '1':
-       case '2':
-       case '3':
-       case '4':
-       case '5':
-       case '6':
-       case '7':
-       case '8':
-       case '9':
-               tokp->kind = TOK_IDENT;
-               findconst(&where, &tokp->str);
-               break;
-
-       default:
-               if (!(isalpha(*where) || *where == '_')) {
-                       char buf[100];
-                       char *p;
-
-                       s_print(buf, "illegal character in file: ");
-                       p = buf + strlen(buf);
-                       if (isprint(*where)) {
-                               s_print(p, "%c", *where);
-                       } else {
-                               s_print(p, "%d", *where);
-                       }
-                       error(buf);
+      else if (isspace (*where))
+       {
+         while (isspace (*where))
+           {
+             where++;          /* eat */
+           }
+       }
+      else if (commenting)
+       {
+         for (where++; *where; where++)
+           {
+             if (endcomment (where))
+               {
+                 where++;
+                 commenting--;
+                 break;
                }
-               findkind(&where, tokp);
-               break;
+           }
+       }
+      else if (startcomment (where))
+       {
+         where += 2;
+         commenting++;
+       }
+      else
+       {
+         break;
        }
+    }
+
+  /*
+   * 'where' is not whitespace, comment or directive Must be a token!
+   */
+  switch (*where)
+    {
+    case ':':
+      tokp->kind = TOK_COLON;
+      where++;
+      break;
+    case ';':
+      tokp->kind = TOK_SEMICOLON;
+      where++;
+      break;
+    case ',':
+      tokp->kind = TOK_COMMA;
+      where++;
+      break;
+    case '=':
+      tokp->kind = TOK_EQUAL;
+      where++;
+      break;
+    case '*':
+      tokp->kind = TOK_STAR;
+      where++;
+      break;
+    case '[':
+      tokp->kind = TOK_LBRACKET;
+      where++;
+      break;
+    case ']':
+      tokp->kind = TOK_RBRACKET;
+      where++;
+      break;
+    case '{':
+      tokp->kind = TOK_LBRACE;
+      where++;
+      break;
+    case '}':
+      tokp->kind = TOK_RBRACE;
+      where++;
+      break;
+    case '(':
+      tokp->kind = TOK_LPAREN;
+      where++;
+      break;
+    case ')':
+      tokp->kind = TOK_RPAREN;
+      where++;
+      break;
+    case '<':
+      tokp->kind = TOK_LANGLE;
+      where++;
+      break;
+    case '>':
+      tokp->kind = TOK_RANGLE;
+      where++;
+      break;
+
+    case '"':
+      tokp->kind = TOK_STRCONST;
+      findstrconst (&where, &tokp->str);
+      break;
+    case '\'':
+      tokp->kind = TOK_CHARCONST;
+      findchrconst (&where, &tokp->str);
+      break;
+
+    case '-':
+    case '0':
+    case '1':
+    case '2':
+    case '3':
+    case '4':
+    case '5':
+    case '6':
+    case '7':
+    case '8':
+    case '9':
+      tokp->kind = TOK_IDENT;
+      findconst (&where, &tokp->str);
+      break;
+
+    default:
+      if (!(isalpha (*where) || *where == '_'))
+       {
+         char buf[100];
+         char *p;
+
+         s_print (buf, _("illegal character in file: "));
+         p = buf + strlen (buf);
+         if (isprint (*where))
+           {
+             s_print (p, "%c", *where);
+           }
+         else
+           {
+             s_print (p, "%d", *where);
+           }
+         error (buf);
+       }
+      findkind (&where, tokp);
+      break;
+    }
 }
 
 static void
-unget_token(token *tokp)
+unget_token (token * tokp)
 {
-       lasttok = *tokp;
-       pushed = 1;
+  lasttok = *tokp;
+  pushed = 1;
 }
 
 static void
-findstrconst(const char **str, const char **val)
+findstrconst (const char **str, const char **val)
 {
-       const char *p;
-       char *tmp;
-       int size;
-
-       p = *str;
-       do {
-               p++;
-       } while (*p && *p != '"');
-       if (*p == 0) {
-               error("unterminated string constant");
-       }
-       p++;
-       size = p - *str;
-       tmp = alloc(size + 1);
-       strncpy(tmp, *str, size);
-       tmp[size] = 0;
-       *val = tmp;
-       *str = p;
+  const char *p;
+  char *tmp;
+  int size;
+
+  p = *str;
+  do
+    {
+      p++;
+    }
+  while (*p && *p != '"');
+  if (*p == 0)
+    {
+      error (_("unterminated string constant"));
+    }
+  p++;
+  size = p - *str;
+  tmp = alloc (size + 1);
+  strncpy (tmp, *str, size);
+  tmp[size] = 0;
+  *val = tmp;
+  *str = p;
 }
 
 static void
-findchrconst(const char **str, const char **val)
+findchrconst (const char **str, const char **val)
 {
-       const char *p;
-       char *tmp;
-       int size;
-
-       p = *str;
-       do {
-               p++;
-       } while (*p && *p != '\'');
-       if (*p == 0) {
-               error("unterminated string constant");
-       }
-       p++;
-       size = p - *str;
-       if (size != 3) {
-               error("empty char string");
-       }
-       tmp = alloc(size + 1);
-       strncpy(tmp, *str, size);
-       tmp[size] = 0;
-       *val = tmp;
-       *str = p;
+  const char *p;
+  char *tmp;
+  int size;
+
+  p = *str;
+  do
+    {
+      p++;
+    }
+  while (*p && *p != '\'');
+  if (*p == 0)
+    {
+      error (_("unterminated string constant"));
+    }
+  p++;
+  size = p - *str;
+  if (size != 3)
+    {
+      error (_("empty char string"));
+    }
+  tmp = alloc (size + 1);
+  strncpy (tmp, *str, size);
+  tmp[size] = 0;
+  *val = tmp;
+  *str = p;
 }
 
 static void
-findconst(const char **str, const char **val)
+findconst (const char **str, const char **val)
 {
-       const char *p;
-       char *tmp;
-       int size;
-
-       p = *str;
-       if (*p == '0' && *(p + 1) == 'x') {
-               p++;
-               do {
-                       p++;
-               } while (isxdigit(*p));
-       } else {
-               do {
-                       p++;
-               } while (isdigit(*p));
+  const char *p;
+  char *tmp;
+  int size;
+
+  p = *str;
+  if (*p == '0' && *(p + 1) == 'x')
+    {
+      p++;
+      do
+       {
+         p++;
        }
-       size = p - *str;
-       tmp = alloc(size + 1);
-       strncpy(tmp, *str, size);
-       tmp[size] = 0;
-       *val = tmp;
-       *str = p;
+      while (isxdigit (*p));
+    }
+  else
+    {
+      do
+       {
+         p++;
+       }
+      while (isdigit (*p));
+    }
+  size = p - *str;
+  tmp = alloc (size + 1);
+  strncpy (tmp, *str, size);
+  tmp[size] = 0;
+  *val = tmp;
+  *str = p;
 }
 
-static token symbols[] = {
-                         {TOK_CONST, "const"},
-                         {TOK_UNION, "union"},
-                         {TOK_SWITCH, "switch"},
-                         {TOK_CASE, "case"},
-                         {TOK_DEFAULT, "default"},
-                         {TOK_STRUCT, "struct"},
-                         {TOK_TYPEDEF, "typedef"},
-                         {TOK_ENUM, "enum"},
-                         {TOK_OPAQUE, "opaque"},
-                         {TOK_BOOL, "bool"},
-                         {TOK_VOID, "void"},
-                         {TOK_CHAR, "char"},
-                         {TOK_INT, "int"},
-                         {TOK_UNSIGNED, "unsigned"},
-                         {TOK_SHORT, "short"},
-                         {TOK_LONG, "long"},
-                         {TOK_FLOAT, "float"},
-                         {TOK_DOUBLE, "double"},
-                         {TOK_STRING, "string"},
-                         {TOK_PROGRAM, "program"},
-                         {TOK_VERSION, "version"},
-                         {TOK_EOF, "??????"},
+static const token symbols[] =
+{
+  {TOK_CONST, "const"},
+  {TOK_UNION, "union"},
+  {TOK_SWITCH, "switch"},
+  {TOK_CASE, "case"},
+  {TOK_DEFAULT, "default"},
+  {TOK_STRUCT, "struct"},
+  {TOK_TYPEDEF, "typedef"},
+  {TOK_ENUM, "enum"},
+  {TOK_OPAQUE, "opaque"},
+  {TOK_BOOL, "bool"},
+  {TOK_VOID, "void"},
+  {TOK_CHAR, "char"},
+  {TOK_INT, "int"},
+  {TOK_UNSIGNED, "unsigned"},
+  {TOK_SHORT, "short"},
+  {TOK_LONG, "long"},
+  {TOK_FLOAT, "float"},
+  {TOK_DOUBLE, "double"},
+  {TOK_STRING, "string"},
+  {TOK_PROGRAM, "program"},
+  {TOK_VERSION, "version"},
+  {TOK_EOF, "??????"},
 };
 
 static void
-findkind(const char **mark, token *tokp)
+findkind (const char **mark, token * tokp)
 {
-       int len;
-       token *s;
-       const char *str;
-       char *tmp;
-
-       str = *mark;
-       for (s = symbols; s->kind != TOK_EOF; s++) {
-               len = strlen(s->str);
-               if (strncmp(str, s->str, len) == 0) {
-                       if (!isalnum(str[len]) && str[len] != '_') {
-                               tokp->kind = s->kind;
-                               tokp->str = s->str;
-                               *mark = str + len;
-                               return;
-                       }
-               }
+  int len;
+  token *s;
+  const char *str;
+  char *tmp;
+
+  str = *mark;
+  for (s = symbols; s->kind != TOK_EOF; s++)
+    {
+      len = strlen (s->str);
+      if (strncmp (str, s->str, len) == 0)
+       {
+         if (!isalnum (str[len]) && str[len] != '_')
+           {
+             tokp->kind = s->kind;
+             tokp->str = s->str;
+             *mark = str + len;
+             return;
+           }
        }
-       tokp->kind = TOK_IDENT;
-       for (len = 0; isalnum(str[len]) || str[len] == '_'; len++);
-       tmp = alloc(len + 1);
-       strncpy(tmp, str, len);
-       tmp[len] = 0;
-       tokp->str = tmp;
-       *mark = str + len;
+    }
+  tokp->kind = TOK_IDENT;
+  for (len = 0; isalnum (str[len]) || str[len] == '_'; len++);
+  tmp = alloc (len + 1);
+  strncpy (tmp, str, len);
+  tmp[len] = 0;
+  tokp->str = tmp;
+  *mark = str + len;
 }
 
 static int
-cppline(const char *line)
+cppline (const char *line)
 {
-       return (line == curline && *line == '#');
+  return line == curline && *line == '#';
 }
 
 static int
-directive(const char *line)
+directive (const char *line)
 {
-       return (line == curline && *line == '%');
+  return line == curline && *line == '%';
 }
 
 static void
-printdirective(const char *line)
+printdirective (const char *line)
 {
-       f_print(fout, "%s", line + 1);
+  f_print (fout, "%s", line + 1);
 }
 
 static void
-docppline(const char *line, int *lineno, const char **fname)
+docppline (const char *line, int *lineno, const char **fname)
 {
-       char *file;
-       int num;
-       char *p;
-
-       line++;
-       while (isspace(*line)) {
-               line++;
-       }
-       num = atoi(line);
-       while (isdigit(*line)) {
-               line++;
-       }
-       while (isspace(*line)) {
-               line++;
-       }
-       if (*line != '"') {
-               error("preprocessor error");
-       }
-       line++;
-       p = file = alloc(strlen(line) + 1);
-       while (*line && *line != '"') {
-               *p++ = *line++;
-       }
-       if (*line == 0) {
-               error("preprocessor error");
-       }
-       *p = 0;
-       if (*file == 0) {
-               *fname = NULL;
-       } else {
-               *fname = file;
-       }
-       *lineno = num - 1;
+  char *file;
+  int num;
+  char *p;
+
+  line++;
+  while (isspace (*line))
+    {
+      line++;
+    }
+  num = atoi (line);
+  while (isdigit (*line))
+    {
+      line++;
+    }
+  while (isspace (*line))
+    {
+      line++;
+    }
+  if (*line != '"')
+    {
+      error (_("preprocessor error"));
+    }
+  line++;
+  p = file = alloc (strlen (line) + 1);
+  while (*line && *line != '"')
+    {
+      *p++ = *line++;
+    }
+  if (*line == 0)
+    {
+      error (_("preprocessor error"));
+    }
+  *p = 0;
+  if (*file == 0)
+    {
+      *fname = NULL;
+    }
+  else
+    {
+      *fname = file;
+    }
+  *lineno = num - 1;
 }