]> arthur.barton.de Git - netatalk.git/blobdiff - bin/megatron/updcrc.c
Spotlight: use async Tracker SPARQL API
[netatalk.git] / bin / megatron / updcrc.c
index 75079fb2bb5f8fa53b6792c75fa2a9e3f675153a..ca199c8a8d26fe87c126bda0ab2eacd0d008150e 100644 (file)
@@ -1,4 +1,6 @@
-/* updcrc(3), crc(1) - calculate crc polynomials
+/*
+ *
+ * updcrc(3), crc(1) - calculate crc polynomials
  *
  * Calculate, intelligently, the CRC of a dataset incrementally given a 
  * buffer full at a time.
  *             UUCP: ihnp4!umn-cs!hyper!mark, GEnie: mgm
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include "updcrc.h"
+
 /* The CRC polynomial.
  * These 4 values define the crc-polynomial.
  * If you change them, you must change crctab[]'s initial value to what is
     /* Value used by:                  CCITT   XMODEM  ARC     */
 #define        P        0x1021 /* the poly:    0x1021  0x1021  A001    */
 #define INIT_CRC 0L    /* init value:  -1      0       0       */
-/*#define SWAPPED      /* bit order:   undef   defined defined */
-#define W      16      /* bits in CRC:16       16      16      */
-
-    /* data type that holds a W-bit unsigned integer */
-#if W <= 16
-#  define WTYPE        unsigned short
-#else
-#  define WTYPE   u_int32_t
-#endif
-
+#if 0
+#define SWAPPED        /* bit order:   undef   defined defined */
+#endif /* 0 */
     /* the number of bits per char: don't change it. */
 #define B      8
 
@@ -82,10 +83,7 @@ static WTYPE crctab[1<<B] = /* as calculated by initcrctab() */ {
 } ;
 
 WTYPE
-updcrc( icrc, icp, icnt )
-    WTYPE icrc;
-    unsigned char *icp;
-    int icnt;
+updcrc(WTYPE icrc, unsigned char *icp, int icnt)
 {
     register WTYPE crc = icrc;
     register unsigned char *cp = icp;
@@ -94,9 +92,9 @@ updcrc( icrc, icp, icnt )
     while( cnt-- ) {
 #ifndef SWAPPED
        crc = (crc<<B) ^ crctab[(crc>>(W-B)) ^ *cp++];
-#else
+#else /* SWAPPED */
        crc = (crc>>B) ^ crctab[(crc & ((1<<B)-1)) ^ *cp++]; 
-#endif SWAPPED
+#endif /* SWAPPED */
     }
 
     return( crc );
@@ -105,12 +103,12 @@ updcrc( icrc, icp, icnt )
 #ifdef MAKETAB
 
 #include <stdio.h>
-main()
+int main(void)
 {
     initcrctab();
 }
 
-initcrctab()
+void initcrctab(void)
 {
     register  int b, i;
     WTYPE v;
@@ -133,7 +131,7 @@ initcrctab()
            printf("  ");
     }
 }
-#endif
+#endif /* MAKETAB */
 
 #ifdef TEST
 
@@ -144,8 +142,7 @@ initcrctab()
 
 
 
-main( ac, av )
-    int ac; char **av;
+main( int ac, char **av)
 {
     int fd;
     int nr;
@@ -185,7 +182,7 @@ main( ac, av )
     /* crc should now equal magic */
     buf[0] = buf[1] = buf[2] = buf[3] = 0;
     printf( "magic test: %lx =?= %lx\n", crc, updcrc(-1, buf, W/B));
-#endif MAGICCHECK
+#endif /* MAGICCHECK */
 }
 
-#endif
+#endif /* TEST */