Code beautification with uncrustify
[alexxy/gromacs.git] / src / gromacs / gmxlib / gmx_system_xdr.c
index e66a59970ce22c7d931c4a8f4e5028b482ab50ec..b9ebaaf4c1101401525f98b46a6eb309971ca599 100644 (file)
@@ -1,11 +1,11 @@
 /*
- * 
+ *
  *                This source code is part of
- * 
+ *
  *                 G   R   O   M   A   C   S
- * 
+ *
  *          GROningen MAchine for Chemical Simulations
- * 
+ *
  *                        VERSION 3.2.0
  * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
- * 
+ *
  * If you want to redistribute modifications, please consider that
  * scientific software is very special. Version control is crucial -
  * bugs must be traceable. We will be happy to consider code for
  * inclusion in the official distribution, but derived work must not
  * be called official GROMACS. Details are found in the README & COPYING
  * files - if they are missing, get the official version at www.gromacs.org.
- * 
+ *
  * To help us fund GROMACS development, we humbly ask that you cite
  * the papers on the package - you can find them in the top README file.
- * 
+ *
  * For more info, check our website at http://www.gromacs.org
- * 
+ *
  * And Hey:
  * GROningen Mixture of Alchemy and Childrens' Stories
  */
 /* NB - THIS FILE IS ONLY USED ON MICROSOFT WINDOWS, since that
  * system doesn't provide any standard XDR system libraries. It will
  * most probably work on other platforms too, but make sure you
- * test that the xtc files produced are ok before using it. 
+ * test that the xtc files produced are ok before using it.
  *
- * This header file contains Gromacs versions of the definitions for 
+ * This header file contains Gromacs versions of the definitions for
  * Sun External Data Representation (XDR) headers and routines.
  *
- * On most UNIX systems this is already present as part of your 
+ * On most UNIX systems this is already present as part of your
  * system libraries, but since we want to make Gromacs portable to
  * platforms like Microsoft Windows we have created a private version
  * of the necessary routines and distribute them with the Gromacs source.
- * 
- * Although the rest of Gromacs is GPL, you can copy and use the XDR 
+ *
+ * Although the rest of Gromacs is GPL, you can copy and use the XDR
  * routines in any way you want as long as you obey Sun's license:
  *
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -88,7 +88,7 @@
  * Sun Microsystems, Inc.
  * 2550 Garcia Avenue
  * Mountain View, California  94043
- */ 
+ */
 
 
 
@@ -99,39 +99,47 @@ static char xdr_zero[BYTES_PER_XDR_UNIT] = {0, 0, 0, 0};
 
 static xdr_uint32_t xdr_swapbytes(xdr_uint32_t x)
 {
-  xdr_uint32_t y;
-  int i;
-  char *px=(char *)&x;
-  char *py=(char *)&y;
-  
-  for(i=0;i<4;i++)
-    py[i]=px[3-i];
-  
-  return y;
+    xdr_uint32_t y;
+    int          i;
+    char        *px = (char *)&x;
+    char        *py = (char *)&y;
+
+    for (i = 0; i < 4; i++)
+    {
+        py[i] = px[3-i];
+    }
+
+    return y;
 }
 
 static xdr_uint32_t xdr_htonl(xdr_uint32_t x)
 {
-  short s=0x0F00;
-  if( *((char *)&s)==(char)0x0F) {
-    /* bigendian, do nothing */
-    return x;
-  } else {
-    /* smallendian,swap bytes */
-    return xdr_swapbytes(x);
-  }
+    short s = 0x0F00;
+    if (*((char *)&s) == (char)0x0F)
+    {
+        /* bigendian, do nothing */
+        return x;
+    }
+    else
+    {
+        /* smallendian,swap bytes */
+        return xdr_swapbytes(x);
+    }
 }
 
 static xdr_uint32_t xdr_ntohl(xdr_uint32_t x)
 {
-  short s=0x0F00;
-  if( *((char *)&s)==(char)0x0F) {
-    /* bigendian, do nothing */
-    return x;
-  } else {
-    /* smallendian, swap bytes */
-    return xdr_swapbytes(x);
-  }
+    short s = 0x0F00;
+    if (*((char *)&s) == (char)0x0F)
+    {
+        /* bigendian, do nothing */
+        return x;
+    }
+    else
+    {
+        /* smallendian, swap bytes */
+        return xdr_swapbytes(x);
+    }
 }
 
 
@@ -142,10 +150,10 @@ static xdr_uint32_t xdr_ntohl(xdr_uint32_t x)
 void
 xdr_free (xdrproc_t proc, char *objp)
 {
-  XDR x;
+    XDR x;
 
-  x.x_op = XDR_FREE;
-  (*proc) (&x, objp);
+    x.x_op = XDR_FREE;
+    (*proc) ( &x, objp);
 }
 
 /*
@@ -154,7 +162,7 @@ xdr_free (xdrproc_t proc, char *objp)
 bool_t
 xdr_void (void)
 {
-  return TRUE;
+    return TRUE;
 }
 
 /*
@@ -163,25 +171,25 @@ xdr_void (void)
 bool_t
 xdr_int (XDR *xdrs, int *ip)
 {
-  xdr_int32_t l;
-
-  switch (xdrs->x_op)
-  {
-    case XDR_ENCODE:
-      l = (xdr_int32_t) (*ip);
-      return xdr_putint32 (xdrs, &l);
-
-    case XDR_DECODE:
-      if (!xdr_getint32 (xdrs, &l))
-         {
-           return FALSE;
-         }
-      *ip = (int) l;
-         
-    case XDR_FREE:
-      return TRUE;
-  }
-  return FALSE;
+    xdr_int32_t l;
+
+    switch (xdrs->x_op)
+    {
+        case XDR_ENCODE:
+            l = (xdr_int32_t) (*ip);
+            return xdr_putint32 (xdrs, &l);
+
+        case XDR_DECODE:
+            if (!xdr_getint32 (xdrs, &l))
+            {
+                return FALSE;
+            }
+            *ip = (int) l;
+
+        case XDR_FREE:
+            return TRUE;
+    }
+    return FALSE;
 }
 
 
@@ -191,25 +199,25 @@ xdr_int (XDR *xdrs, int *ip)
 bool_t
 xdr_u_int (XDR *xdrs, unsigned int *up)
 {
-  xdr_uint32_t l;
-
-  switch (xdrs->x_op)
-  {
-    case XDR_ENCODE:
-      l = (xdr_uint32_t) (*up);
-      return xdr_putuint32 (xdrs, &l);
-
-    case XDR_DECODE:
-      if (!xdr_getuint32 (xdrs, &l))
-         {
-           return FALSE;
-         }
-      *up = (unsigned int) l;
-         
-    case XDR_FREE:
-      return TRUE;
-  }
-  return FALSE;
+    xdr_uint32_t l;
+
+    switch (xdrs->x_op)
+    {
+        case XDR_ENCODE:
+            l = (xdr_uint32_t) (*up);
+            return xdr_putuint32 (xdrs, &l);
+
+        case XDR_DECODE:
+            if (!xdr_getuint32 (xdrs, &l))
+            {
+                return FALSE;
+            }
+            *up = (unsigned int) l;
+
+        case XDR_FREE:
+            return TRUE;
+    }
+    return FALSE;
 }
 
 
@@ -221,26 +229,26 @@ xdr_u_int (XDR *xdrs, unsigned int *up)
 bool_t
 xdr_short (XDR *xdrs, short *sp)
 {
-  xdr_int32_t l;
+    xdr_int32_t l;
 
-  switch (xdrs->x_op)
+    switch (xdrs->x_op)
     {
-    case XDR_ENCODE:
-      l = (xdr_int32_t) *sp;
-      return xdr_putint32 (xdrs, &l);
-
-    case XDR_DECODE:
-      if (!xdr_getint32 (xdrs, &l))
-       {
-         return FALSE;
-       }
-      *sp = (short) l;
-      return TRUE;
-
-    case XDR_FREE:
-      return TRUE;
+        case XDR_ENCODE:
+            l = (xdr_int32_t) *sp;
+            return xdr_putint32 (xdrs, &l);
+
+        case XDR_DECODE:
+            if (!xdr_getint32 (xdrs, &l))
+            {
+                return FALSE;
+            }
+            *sp = (short) l;
+            return TRUE;
+
+        case XDR_FREE:
+            return TRUE;
     }
-  return FALSE;
+    return FALSE;
 }
 
 
@@ -250,26 +258,26 @@ xdr_short (XDR *xdrs, short *sp)
 bool_t
 xdr_u_short (XDR *xdrs, unsigned short *usp)
 {
-  xdr_uint32_t l;
+    xdr_uint32_t l;
 
-  switch (xdrs->x_op)
+    switch (xdrs->x_op)
     {
-    case XDR_ENCODE:
-      l = (xdr_uint32_t) *usp;
-      return xdr_putuint32 (xdrs, &l);
-
-    case XDR_DECODE:
-      if (!xdr_getuint32 (xdrs, &l))
-       {
-         return FALSE;
-       }
-         *usp = (unsigned short) l;
-      return TRUE;
-
-    case XDR_FREE:
-      return TRUE;
+        case XDR_ENCODE:
+            l = (xdr_uint32_t) *usp;
+            return xdr_putuint32 (xdrs, &l);
+
+        case XDR_DECODE:
+            if (!xdr_getuint32 (xdrs, &l))
+            {
+                return FALSE;
+            }
+            *usp = (unsigned short) l;
+            return TRUE;
+
+        case XDR_FREE:
+            return TRUE;
     }
-  return FALSE;
+    return FALSE;
 }
 
 
@@ -279,15 +287,15 @@ xdr_u_short (XDR *xdrs, unsigned short *usp)
 bool_t
 xdr_char (XDR *xdrs, char *cp)
 {
-  int i;
+    int i;
 
-  i = (*cp);
-  if (!xdr_int (xdrs, &i))
+    i = (*cp);
+    if (!xdr_int (xdrs, &i))
     {
-      return FALSE;
+        return FALSE;
     }
-  *cp = i;
-  return TRUE;
+    *cp = i;
+    return TRUE;
 }
 
 /*
@@ -296,15 +304,15 @@ xdr_char (XDR *xdrs, char *cp)
 bool_t
 xdr_u_char (XDR *xdrs, unsigned char *cp)
 {
-  unsigned int u;
+    unsigned int u;
 
-  u = (*cp);
-  if (!xdr_u_int (xdrs, &u))
+    u = (*cp);
+    if (!xdr_u_int (xdrs, &u))
     {
-      return FALSE;
+        return FALSE;
     }
-  *cp = u;
-  return TRUE;
+    *cp = u;
+    return TRUE;
 }
 
 /*
@@ -313,29 +321,29 @@ xdr_u_char (XDR *xdrs, unsigned char *cp)
 bool_t
 xdr_bool (XDR *xdrs, int *bp)
 {
-#define XDR_FALSE      ((xdr_int32_t) 0)
-#define XDR_TRUE       ((xdr_int32_t) 1)
+#define XDR_FALSE   ((xdr_int32_t) 0)
+#define XDR_TRUE    ((xdr_int32_t) 1)
 
-  xdr_int32_t lb;
+    xdr_int32_t lb;
 
-  switch (xdrs->x_op)
+    switch (xdrs->x_op)
     {
-    case XDR_ENCODE:
-      lb = *bp ? XDR_TRUE : XDR_FALSE;
-      return xdr_putint32 (xdrs, &lb);
-
-    case XDR_DECODE:
-      if (!xdr_getint32 (xdrs, &lb))
-       {
-         return FALSE;
-       }
-      *bp = (lb == XDR_FALSE) ? FALSE : TRUE;
-      return TRUE;
-
-    case XDR_FREE:
-      return TRUE;
+        case XDR_ENCODE:
+            lb = *bp ? XDR_TRUE : XDR_FALSE;
+            return xdr_putint32 (xdrs, &lb);
+
+        case XDR_DECODE:
+            if (!xdr_getint32 (xdrs, &lb))
+            {
+                return FALSE;
+            }
+            *bp = (lb == XDR_FALSE) ? FALSE : TRUE;
+            return TRUE;
+
+        case XDR_FREE:
+            return TRUE;
     }
-  return FALSE;
+    return FALSE;
 #undef XDR_FALSE
 #undef XDR_TRUE
 }
@@ -350,46 +358,54 @@ xdr_bool (XDR *xdrs, int *bp)
 bool_t
 xdr_opaque (XDR *xdrs, char *cp, unsigned int cnt)
 {
-  unsigned int rndup;
-  char crud[BYTES_PER_XDR_UNIT];
+    unsigned int rndup;
+    char         crud[BYTES_PER_XDR_UNIT];
 
-  /*
-   * if no data we are done
-   */
-  if (cnt == 0)
-    return TRUE;
+    /*
+     * if no data we are done
+     */
+    if (cnt == 0)
+    {
+        return TRUE;
+    }
 
-  /*
-   * round byte count to full xdr units
-   */
-  rndup = cnt % BYTES_PER_XDR_UNIT;
-  if (rndup > 0)
-    rndup = BYTES_PER_XDR_UNIT - rndup;
+    /*
+     * round byte count to full xdr units
+     */
+    rndup = cnt % BYTES_PER_XDR_UNIT;
+    if (rndup > 0)
+    {
+        rndup = BYTES_PER_XDR_UNIT - rndup;
+    }
 
-  switch (xdrs->x_op)
+    switch (xdrs->x_op)
     {
-    case XDR_DECODE:
-      if (!xdr_getbytes (xdrs, cp, cnt))
-       {
-         return FALSE;
-       }
-      if (rndup == 0)
-       return TRUE;
-      return xdr_getbytes (xdrs, (char *)crud, rndup);
-
-    case XDR_ENCODE:
-      if (!xdr_putbytes (xdrs, cp, cnt))
-       {
-         return FALSE;
-       }
-      if (rndup == 0)
-       return TRUE;
-      return xdr_putbytes (xdrs, xdr_zero, rndup);
-
-    case XDR_FREE:
-      return TRUE;
+        case XDR_DECODE:
+            if (!xdr_getbytes (xdrs, cp, cnt))
+            {
+                return FALSE;
+            }
+            if (rndup == 0)
+            {
+                return TRUE;
+            }
+            return xdr_getbytes (xdrs, (char *)crud, rndup);
+
+        case XDR_ENCODE:
+            if (!xdr_putbytes (xdrs, cp, cnt))
+            {
+                return FALSE;
+            }
+            if (rndup == 0)
+            {
+                return TRUE;
+            }
+            return xdr_putbytes (xdrs, xdr_zero, rndup);
+
+        case XDR_FREE:
+            return TRUE;
     }
-  return FALSE;
+    return FALSE;
 }
 
 
@@ -403,73 +419,77 @@ xdr_opaque (XDR *xdrs, char *cp, unsigned int cnt)
  */
 bool_t
 xdr_string (xdrs, cpp, maxsize)
-     XDR *xdrs;
-     char **cpp;
-     unsigned int maxsize;
+XDR *xdrs;
+char       **cpp;
+unsigned int maxsize;
 {
-  char *sp = *cpp;     /* sp is the actual string pointer */
-  unsigned int size = 0;
-  unsigned int nodesize = 0;
-
-  /*
-   * first deal with the length since xdr strings are counted-strings
-   */
-  switch (xdrs->x_op)
+    char        *sp       = *cpp; /* sp is the actual string pointer */
+    unsigned int size     = 0;
+    unsigned int nodesize = 0;
+
+    /*
+     * first deal with the length since xdr strings are counted-strings
+     */
+    switch (xdrs->x_op)
     {
-    case XDR_FREE:
-      if (sp == NULL)
-       {
-         return TRUE;          /* already free */
-       }
-      /* fall through... */
-    case XDR_ENCODE:
-      if (sp == NULL)
-           return FALSE;
-      size = strlen (sp);
-      break;
-    case XDR_DECODE:
-      break;
+        case XDR_FREE:
+            if (sp == NULL)
+            {
+                return TRUE; /* already free */
+            }
+        /* fall through... */
+        case XDR_ENCODE:
+            if (sp == NULL)
+            {
+                return FALSE;
+            }
+            size = strlen (sp);
+            break;
+        case XDR_DECODE:
+            break;
     }
-  
-  if (!xdr_u_int (xdrs, &size))
+
+    if (!xdr_u_int (xdrs, &size))
     {
-      return FALSE;
+        return FALSE;
     }
-  if (size > maxsize)
+    if (size > maxsize)
     {
-      return FALSE;
+        return FALSE;
     }
-  nodesize = size + 1;
+    nodesize = size + 1;
 
-  /*
-   * now deal with the actual bytes
-   */
-  switch (xdrs->x_op)
+    /*
+     * now deal with the actual bytes
+     */
+    switch (xdrs->x_op)
     {
-    case XDR_DECODE:
-      if (nodesize == 0)
-       {
-         return TRUE;
-       }
-      if (sp == NULL)
-       *cpp = sp = (char *) malloc (nodesize);
-      if (sp == NULL)
-       {
-         (void) fputs ("xdr_string: out of memory\n", stderr);
-         return FALSE;
-       }
-      sp[size] = 0;
-      /* fall into ... */
-
-    case XDR_ENCODE:
-      return xdr_opaque (xdrs, sp, size);
-
-    case XDR_FREE:
-      free (sp);
-      *cpp = NULL;
-      return TRUE;
+        case XDR_DECODE:
+            if (nodesize == 0)
+            {
+                return TRUE;
+            }
+            if (sp == NULL)
+            {
+                *cpp = sp = (char *) malloc (nodesize);
+            }
+            if (sp == NULL)
+            {
+                (void) fputs ("xdr_string: out of memory\n", stderr);
+                return FALSE;
+            }
+            sp[size] = 0;
+        /* fall into ... */
+
+        case XDR_ENCODE:
+            return xdr_opaque (xdrs, sp, size);
+
+        case XDR_FREE:
+            free (sp);
+            *cpp = NULL;
+            return TRUE;
     }
-  return FALSE;
+    return FALSE;
 }
 
 
@@ -478,108 +498,118 @@ xdr_string (xdrs, cpp, maxsize)
 
 bool_t
 xdr_float(xdrs, fp)
-     XDR *xdrs;
-     float *fp;
+XDR *xdrs;
+float *fp;
 {
-       xdr_int32_t tmp;
-       
-       switch (xdrs->x_op) {
+    xdr_int32_t tmp;
+
+    switch (xdrs->x_op)
+    {
 
-       case XDR_ENCODE:
-               tmp = *(xdr_int32_t *)fp;
-           return (xdr_putint32(xdrs, &tmp));
+        case XDR_ENCODE:
+            tmp = *(xdr_int32_t *)fp;
+            return (xdr_putint32(xdrs, &tmp));
 
-               break;
+            break;
 
-       case XDR_DECODE:
-                       if (xdr_getint32(xdrs, &tmp)) {
-                               *(xdr_int32_t *)fp = tmp;
-                               return (TRUE);
-                       }
+        case XDR_DECODE:
+            if (xdr_getint32(xdrs, &tmp))
+            {
+                *(xdr_int32_t *)fp = tmp;
+                return (TRUE);
+            }
 
-               break;
+            break;
 
-       case XDR_FREE:
-               return (TRUE);
-       }
-       return (FALSE);
+        case XDR_FREE:
+            return (TRUE);
+    }
+    return (FALSE);
 }
 
 
 bool_t
 xdr_double(xdrs, dp)
-     XDR *xdrs;
-     double *dp;
+XDR *xdrs;
+double *dp;
 {
 
-  /* Windows and some other systems dont define double-precision
-   * word order in the header files, so unfortunately we have
-   * to calculate it!
-   *
-   * For thread safety, we calculate it every time: locking this would
-   * be more expensive.
-   */
-  /*static int LSW=-1;*/ /* Least significant fp word */
-  int LSW=-1; /* Least significant fp word */
-  
-
-  int *ip;
-  xdr_int32_t tmp[2];
-
-  if(LSW<0) {
-    double x=0.987654321; /* Just a number */
-
-    /* Possible representations in IEEE double precision: 
-     * (S=small endian, B=big endian)
-     * 
-     * Byte order, Word order, Hex
-     *     S           S       b8 56 0e 3c dd 9a ef 3f    
-     *     B           S       3c 0e 56 b8 3f ef 9a dd
-     *     S           B       dd 9a ef 3f b8 56 0e 3c
-     *     B           B       3f ef 9a dd 3c 0e 56 b8
-     */ 
-    
-    unsigned char ix = *((char *)&x);
-    
-    if(ix==0xdd || ix==0x3f)
-      LSW=1;  /* Big endian word order */
-    else if(ix==0xb8 || ix==0x3c)
-      LSW=0;  /* Small endian word order */
-    else { /* Catch strange errors */
-      printf("Error when detecting floating-point word order.\n"
-            "Do you have a non-IEEE system?\n"
-            "If possible, use the XDR libraries provided with your system,\n"
-            "instead of the Gromacs fallback XDR source.\n");
-      exit(0);
-    }
-  }  
-  
-  switch (xdrs->x_op) {
-    
-  case XDR_ENCODE:
-    ip = (int *)dp;
-    tmp[0] = ip[!LSW];
-    tmp[1] = ip[LSW];
-    return (xdr_putint32(xdrs, tmp) &&
-             xdr_putint32(xdrs, tmp+1));
-    break;
-    
-  case XDR_DECODE:
-    ip = (int *)dp;
-    if (xdr_getint32(xdrs, tmp+!LSW) &&
-         xdr_getint32(xdrs, tmp+LSW)) {
-       ip[0] = tmp[0];
-       ip[1] = tmp[1];
-       return (TRUE);
+    /* Windows and some other systems dont define double-precision
+     * word order in the header files, so unfortunately we have
+     * to calculate it!
+     *
+     * For thread safety, we calculate it every time: locking this would
+     * be more expensive.
+     */
+    /*static int LSW=-1;*/ /* Least significant fp word */
+    int LSW = -1; /* Least significant fp word */
+
+
+    int        *ip;
+    xdr_int32_t tmp[2];
+
+    if (LSW < 0)
+    {
+        double x = 0.987654321; /* Just a number */
+
+        /* Possible representations in IEEE double precision:
+         * (S=small endian, B=big endian)
+         *
+         * Byte order, Word order, Hex
+         *     S           S       b8 56 0e 3c dd 9a ef 3f
+         *     B           S       3c 0e 56 b8 3f ef 9a dd
+         *     S           B       dd 9a ef 3f b8 56 0e 3c
+         *     B           B       3f ef 9a dd 3c 0e 56 b8
+         */
+
+        unsigned char ix = *((char *)&x);
+
+        if (ix == 0xdd || ix == 0x3f)
+        {
+            LSW = 1; /* Big endian word order */
+        }
+        else if (ix == 0xb8 || ix == 0x3c)
+        {
+            LSW = 0; /* Small endian word order */
+        }
+        else         /* Catch strange errors */
+        {
+            printf("Error when detecting floating-point word order.\n"
+                   "Do you have a non-IEEE system?\n"
+                   "If possible, use the XDR libraries provided with your system,\n"
+                   "instead of the Gromacs fallback XDR source.\n");
+            exit(0);
+        }
     }
 
-    break;
-    
-  case XDR_FREE:
-    return (TRUE);
-  }
-  return (FALSE);
+    switch (xdrs->x_op)
+    {
+
+        case XDR_ENCODE:
+            ip     = (int *)dp;
+            tmp[0] = ip[!LSW];
+            tmp[1] = ip[LSW];
+            return (xdr_putint32(xdrs, tmp) &&
+                    xdr_putint32(xdrs, tmp+1));
+
+            break;
+
+        case XDR_DECODE:
+            ip = (int *)dp;
+            if (xdr_getint32(xdrs, tmp+!LSW) &&
+                xdr_getint32(xdrs, tmp+LSW))
+            {
+                ip[0] = tmp[0];
+                ip[1] = tmp[1];
+                return (TRUE);
+            }
+
+            break;
+
+        case XDR_FREE:
+            return (TRUE);
+    }
+    return (FALSE);
 }
 
 
@@ -597,26 +627,26 @@ xdr_double(xdrs, dp)
  */
 bool_t
 xdr_vector (xdrs, basep, nelem, elemsize, xdr_elem)
-     XDR *xdrs;
-     char *basep;
-     unsigned int nelem;
-     unsigned int elemsize;
-     xdrproc_t xdr_elem;
+XDR *xdrs;
+char        *basep;
+unsigned int nelem;
+unsigned int elemsize;
+xdrproc_t    xdr_elem;
 {
-#define LASTUNSIGNED   ((unsigned int)0-1)
-  unsigned int i;
-  char *elptr;
+#define LASTUNSIGNED    ((unsigned int)0-1)
+    unsigned int i;
+    char        *elptr;
 
-  elptr = basep;
-  for (i = 0; i < nelem; i++)
+    elptr = basep;
+    for (i = 0; i < nelem; i++)
     {
-      if (!(*xdr_elem) (xdrs, elptr, LASTUNSIGNED))
-       {
-         return FALSE;
-       }
-      elptr += elemsize;
+        if (!(*xdr_elem) (xdrs, elptr, LASTUNSIGNED))
+        {
+            return FALSE;
+        }
+        elptr += elemsize;
     }
-  return TRUE;
+    return TRUE;
 #undef LASTUNSIGNED
 }
 
@@ -638,16 +668,16 @@ static bool_t xdrstdio_putuint32 (XDR *, xdr_uint32_t *);
  */
 static const struct xdr_ops xdrstdio_ops =
 {
-  xdrstdio_getbytes,           /* deserialize counted bytes */
-  xdrstdio_putbytes,           /* serialize counted bytes */
-  xdrstdio_getpos,             /* get offset in the stream */
-  xdrstdio_setpos,             /* set offset in the stream */
-  xdrstdio_inline,             /* prime stream for inline macros */
-  xdrstdio_destroy,            /* destroy stream */
-  xdrstdio_getint32,   /* deserialize a int */
-  xdrstdio_putint32,   /* serialize a int */
-  xdrstdio_getuint32,  /* deserialize a int */
-  xdrstdio_putuint32           /* serialize a int */
+    xdrstdio_getbytes,  /* deserialize counted bytes */
+    xdrstdio_putbytes,  /* serialize counted bytes */
+    xdrstdio_getpos,    /* get offset in the stream */
+    xdrstdio_setpos,    /* set offset in the stream */
+    xdrstdio_inline,    /* prime stream for inline macros */
+    xdrstdio_destroy,   /* destroy stream */
+    xdrstdio_getint32,  /* deserialize a int */
+    xdrstdio_putint32,  /* serialize a int */
+    xdrstdio_getuint32, /* deserialize a int */
+    xdrstdio_putuint32  /* serialize a int */
 };
 
 /*
@@ -658,13 +688,13 @@ static const struct xdr_ops xdrstdio_ops =
 void
 xdrstdio_create (XDR *xdrs, FILE *file, enum xdr_op op)
 {
-  xdrs->x_op = op;
-  /* We have to add the const since the `struct xdr_ops' in `struct XDR'
-     is not `const'.  */
-  xdrs->x_ops = (struct xdr_ops *) &xdrstdio_ops;
-  xdrs->x_private = (char *) file;
-  xdrs->x_handy = 0;
-  xdrs->x_base = 0;
+    xdrs->x_op = op;
+    /* We have to add the const since the `struct xdr_ops' in `struct XDR'
+       is not `const'.  */
+    xdrs->x_ops     = (struct xdr_ops *) &xdrstdio_ops;
+    xdrs->x_private = (char *) file;
+    xdrs->x_handy   = 0;
+    xdrs->x_base    = 0;
 }
 
 /*
@@ -674,101 +704,113 @@ xdrstdio_create (XDR *xdrs, FILE *file, enum xdr_op op)
 static void
 xdrstdio_destroy (XDR *xdrs)
 {
-  (void) fflush ((FILE *) xdrs->x_private);
-  /* xx should we close the file ?? */
+    (void) fflush ((FILE *) xdrs->x_private);
+    /* xx should we close the file ?? */
 }
 
 
 static bool_t
 xdrstdio_getbytes (XDR *xdrs, char *addr, unsigned int len)
 {
-  if ((len != 0) && (fread (addr, (int) len, 1,
-                           (FILE *) xdrs->x_private) != 1))
-    return FALSE;
-  return TRUE;
+    if ((len != 0) && (fread (addr, (int) len, 1,
+                              (FILE *) xdrs->x_private) != 1))
+    {
+        return FALSE;
+    }
+    return TRUE;
 }
 
 static bool_t
 xdrstdio_putbytes (XDR *xdrs, char *addr, unsigned int len)
 {
-  if ((len != 0) && (fwrite (addr, (int) len, 1,
-                            (FILE *) xdrs->x_private) != 1))
-    return FALSE;
-  return TRUE;
+    if ((len != 0) && (fwrite (addr, (int) len, 1,
+                               (FILE *) xdrs->x_private) != 1))
+    {
+        return FALSE;
+    }
+    return TRUE;
 }
 
 static unsigned int
 xdrstdio_getpos (XDR *xdrs)
 {
-  return (unsigned int) ftell ((FILE *) xdrs->x_private);
+    return (unsigned int) ftell ((FILE *) xdrs->x_private);
 }
 
 static bool_t
 xdrstdio_setpos (XDR *xdrs, unsigned int pos)
 {
-  return fseek ((FILE *) xdrs->x_private, (xdr_int32_t) pos, 0) < 0 ? FALSE : TRUE;
+    return fseek ((FILE *) xdrs->x_private, (xdr_int32_t) pos, 0) < 0 ? FALSE : TRUE;
 }
 
 static xdr_int32_t *
 xdrstdio_inline (XDR *xdrs, int len)
 {
-  /*
-   * Must do some work to implement this: must insure
-   * enough data in the underlying stdio buffer,
-   * that the buffer is aligned so that we can indirect through a
-   * long *, and stuff this pointer in xdrs->x_buf.  Doing
-   * a fread or fwrite to a scratch buffer would defeat
-   * most of the gains to be had here and require storage
-   * management on this buffer, so we don't do this.
-   */
-  return NULL;
+    /*
+     * Must do some work to implement this: must insure
+     * enough data in the underlying stdio buffer,
+     * that the buffer is aligned so that we can indirect through a
+     * long *, and stuff this pointer in xdrs->x_buf.  Doing
+     * a fread or fwrite to a scratch buffer would defeat
+     * most of the gains to be had here and require storage
+     * management on this buffer, so we don't do this.
+     */
+    return NULL;
 }
 
 static bool_t
 xdrstdio_getint32 (XDR *xdrs, xdr_int32_t *ip)
 {
-  xdr_int32_t mycopy;
+    xdr_int32_t mycopy;
 
-  if (fread ((char *) &mycopy, 4, 1, (FILE *) xdrs->x_private) != 1)
-    return FALSE;
-  *ip = xdr_ntohl (mycopy);
-  return TRUE;
+    if (fread ((char *) &mycopy, 4, 1, (FILE *) xdrs->x_private) != 1)
+    {
+        return FALSE;
+    }
+    *ip = xdr_ntohl (mycopy);
+    return TRUE;
 }
 
 static bool_t
 xdrstdio_putint32 (XDR *xdrs, xdr_int32_t *ip)
 {
-  xdr_int32_t mycopy = xdr_htonl (*ip);
+    xdr_int32_t mycopy = xdr_htonl (*ip);
 
-  ip = &mycopy;
-  if (fwrite ((char *) ip, 4, 1, (FILE *) xdrs->x_private) != 1)
-    return FALSE;
-  return TRUE;
+    ip = &mycopy;
+    if (fwrite ((char *) ip, 4, 1, (FILE *) xdrs->x_private) != 1)
+    {
+        return FALSE;
+    }
+    return TRUE;
 }
 
 static bool_t
 xdrstdio_getuint32 (XDR *xdrs, xdr_uint32_t *ip)
 {
-       xdr_uint32_t mycopy;
-       
-       if (fread ((char *) &mycopy, 4, 1, (FILE *) xdrs->x_private) != 1)
-               return FALSE;
-       *ip = xdr_ntohl (mycopy);
-       return TRUE;
+    xdr_uint32_t mycopy;
+
+    if (fread ((char *) &mycopy, 4, 1, (FILE *) xdrs->x_private) != 1)
+    {
+        return FALSE;
+    }
+    *ip = xdr_ntohl (mycopy);
+    return TRUE;
 }
 
 static bool_t
 xdrstdio_putuint32 (XDR *xdrs, xdr_uint32_t *ip)
 {
-       xdr_uint32_t mycopy = xdr_htonl (*ip);
-       
-       ip = &mycopy;
-       if (fwrite ((char *) ip, 4, 1, (FILE *) xdrs->x_private) != 1)
-               return FALSE;
-       return TRUE;
+    xdr_uint32_t mycopy = xdr_htonl (*ip);
+
+    ip = &mycopy;
+    if (fwrite ((char *) ip, 4, 1, (FILE *) xdrs->x_private) != 1)
+    {
+        return FALSE;
+    }
+    return TRUE;
 }
 
 #else
 int
-gmx_system_xdr_empty;
+    gmx_system_xdr_empty;
 #endif /* GMX_SYSTEM_XDR */