]> git.ozlabs.org Git - ppp.git/blobdiff - pppdump/bsd-comp.c
Merge pull request #101 from vyos/if-renaming-clean
[ppp.git] / pppdump / bsd-comp.c
index 141332665bd85a965f2540185b4e68ff23095293..9d45f0bf610d8aa3a1da7e6f0c2f254bb1745578 100644 (file)
@@ -124,15 +124,15 @@ struct bsd_db {
 #define BSD_OVHD       2               /* BSD compress overhead/packet */
 #define BSD_INIT_BITS  BSD_MIN_BITS
 
-static void    *bsd_decomp_alloc __P((u_char *options, int opt_len));
-static void    bsd_free __P((void *state));
-static int     bsd_decomp_init __P((void *state, u_char *options, int opt_len,
-                                    int unit, int hdrlen, int mru, int debug));
-static void    bsd_incomp __P((void *state, u_char *dmsg, int len));
-static int     bsd_decompress __P((void *state, u_char *cmp, int inlen,
-                                   u_char *dmp, int *outlen));
-static void    bsd_reset __P((void *state));
-static void    bsd_comp_stats __P((void *state, struct compstat *stats));
+static void    *bsd_decomp_alloc(u_char *options, int opt_len);
+static void    bsd_free(void *state);
+static int     bsd_decomp_init(void *state, u_char *options, int opt_len,
+                               int unit, int hdrlen, int mru, int debug);
+static void    bsd_incomp(void *state, u_char *dmsg, int len);
+static int     bsd_decompress(void *state, u_char *cmp, int inlen,
+                              u_char *dmp, int *outlen);
+static void    bsd_reset(void *state);
+static void    bsd_comp_stats(void *state, struct compstat *stats);
 
 /*
  * Exported procedures.
@@ -174,8 +174,7 @@ struct compressor ppp_bsd_compress = {
  * clear the dictionary
  */
 static void
-bsd_clear(db)
-    struct bsd_db *db;
+bsd_clear(struct bsd_db *db)
 {
     db->clear_count++;
     db->max_ent = FIRST-1;
@@ -200,8 +199,7 @@ bsd_clear(db)
  * must compute the same ratio.
  */
 static int                             /* 1=output CLEAR */
-bsd_check(db)
-    struct bsd_db *db;
+bsd_check(struct bsd_db *db)
 {
     u_int new_ratio;
 
@@ -241,9 +239,7 @@ bsd_check(db)
  * Return statistics.
  */
 static void
-bsd_comp_stats(state, stats)
-    void *state;
-    struct compstat *stats;
+bsd_comp_stats(void *state, struct compstat *stats)
 {
     struct bsd_db *db = (struct bsd_db *) state;
     u_int out;
@@ -268,8 +264,7 @@ bsd_comp_stats(state, stats)
  * Reset state, as on a CCP ResetReq.
  */
 static void
-bsd_reset(state)
-    void *state;
+bsd_reset(void *state)
 {
     struct bsd_db *db = (struct bsd_db *) state;
 
@@ -282,9 +277,7 @@ bsd_reset(state)
  * Allocate space for a (de) compressor.
  */
 static void *
-bsd_alloc(options, opt_len, decomp)
-    u_char *options;
-    int opt_len, decomp;
+bsd_alloc(u_char *options, int opt_len, int decomp)
 {
     int bits;
     u_int newlen, hsize, hshift, maxmaxcode;
@@ -350,8 +343,7 @@ bsd_alloc(options, opt_len, decomp)
 }
 
 static void
-bsd_free(state)
-    void *state;
+bsd_free(void *state)
 {
     struct bsd_db *db = (struct bsd_db *) state;
 
@@ -361,9 +353,7 @@ bsd_free(state)
 }
 
 static void *
-bsd_decomp_alloc(options, opt_len)
-    u_char *options;
-    int opt_len;
+bsd_decomp_alloc(u_char *options, int opt_len)
 {
     return bsd_alloc(options, opt_len, 1);
 }
@@ -372,10 +362,8 @@ bsd_decomp_alloc(options, opt_len)
  * Initialize the database.
  */
 static int
-bsd_init(db, options, opt_len, unit, hdrlen, mru, debug, decomp)
-    struct bsd_db *db;
-    u_char *options;
-    int opt_len, unit, hdrlen, mru, debug, decomp;
+bsd_init(struct bsd_db *db, u_char *options, int opt_len, int unit,
+        int hdrlen, int mru, int debug, int decomp)
 {
     int i;
 
@@ -383,7 +371,7 @@ bsd_init(db, options, opt_len, unit, hdrlen, mru, debug, decomp)
        || options[0] != CI_BSD_COMPRESS || options[1] != CILEN_BSD_COMPRESS
        || BSD_VERSION(options[2]) != BSD_CURRENT_VERSION
        || BSD_NBITS(options[2]) != db->maxbits
-       || decomp && db->lens == NULL)
+       || (decomp && db->lens == NULL))
        return 0;
 
     if (decomp) {
@@ -409,10 +397,8 @@ bsd_init(db, options, opt_len, unit, hdrlen, mru, debug, decomp)
 }
 
 static int
-bsd_decomp_init(state, options, opt_len, unit, hdrlen, mru, debug)
-    void *state;
-    u_char *options;
-    int opt_len, unit, hdrlen, mru, debug;
+bsd_decomp_init(void *state, u_char *options, int opt_len,
+               int unit, int hdrlen, int mru, int debug)
 {
     return bsd_init((struct bsd_db *) state, options, opt_len,
                    unit, hdrlen, mru, debug, 1);
@@ -424,10 +410,7 @@ bsd_decomp_init(state, options, opt_len, unit, hdrlen, mru, debug)
  * incompressible data by pretending to compress the incoming data.
  */
 static void
-bsd_incomp(state, dmsg, mlen)
-    void *state;
-    u_char *dmsg;
-    int mlen;
+bsd_incomp(void *state, u_char *dmsg, int mlen)
 {
     struct bsd_db *db = (struct bsd_db *) state;
     u_int hshift = db->hshift;
@@ -544,10 +527,7 @@ bsd_incomp(state, dmsg, mlen)
  * compression, even though they are detected by inspecting the input.
  */
 static int
-bsd_decompress(state, cmsg, inlen, dmp, outlenp)
-    void *state;
-    u_char *cmsg, *dmp;
-    int inlen, *outlenp;
+bsd_decompress(void *state, u_char *cmsg, int inlen, u_char *dmp, int *outlenp)
 {
     struct bsd_db *db = (struct bsd_db *) state;
     u_int max_ent = db->max_ent;
@@ -556,11 +536,11 @@ bsd_decompress(state, cmsg, inlen, dmp, outlenp)
     u_int n_bits = db->n_bits;
     u_int tgtbitno = 32-n_bits;        /* bitno when we have a code */
     struct bsd_dict *dictp;
-    int explen, i, seq, len;
+    int explen, seq, len;
     u_int incode, oldcode, finchar;
     u_char *p, *rptr, *wptr;
     int ilen;
-    int dlen, space, codelen, extra;
+    int codelen, extra;
 
     rptr = cmsg;
     if (*rptr == 0)
@@ -616,12 +596,12 @@ bsd_decompress(state, cmsg, inlen, dmp, outlenp)
        }
 
        if (incode > max_ent + 2 || incode > db->maxmaxcode
-           || incode > max_ent && oldcode == CLEAR) {
+           || (incode > max_ent && oldcode == CLEAR)) {
            if (db->debug) {
                printf("bsd_decomp%d: bad code 0x%x oldcode=0x%x ",
                       db->unit, incode, oldcode);
-               printf("max_ent=0x%x dlen=%d seqno=%d\n",
-                      max_ent, dlen, db->seqno);
+               printf("max_ent=0x%x seqno=%d\n",
+                      max_ent, db->seqno);
            }
            return DECOMP_FATALERROR;   /* probably a bug */
        }