1: #ifndef lint
   2: static char *sccsid = "@(#)inv6.c	4.2 (Berkeley) 1/9/85";
   3: #endif
   4: 
   5: #include <stdio.h>
   6: #include <assert.h>
   7: 
   8: whash(ft, fa, fb, nhash, iflong, ptotct, phused)
   9: FILE *fa, *fb, *ft;
  10: int nhash, *phused;
  11: long *ptotct;
  12: {
  13:     char line[100];
  14:     int hash = 0, hused = 0;
  15:     long totct = 0L;
  16:     int ct = 0;
  17:     long point;
  18:     long opoint = -1;
  19:     int m;
  20:     int k;
  21:     long lp;
  22:     long *hpt;
  23:     int *hfreq;
  24: 
  25:     hpt = (long *) calloc (nhash+1, sizeof(*hpt));
  26:     _assert (hpt != NULL);
  27:     hfreq = (int *) calloc (nhash, sizeof(*hfreq));
  28:     _assert (hfreq != NULL);
  29:     hpt[0] = 0;
  30:     lp= 0;
  31:     while (fgets(line, 100, ft))
  32:     {
  33:         totct++;
  34:         sscanf(line, "%d %ld", &k, &point);
  35:         if (hash < k)
  36:         {
  37:             hused++;
  38:             if (iflong) putl(-1L, fb);
  39:             else putw(-1, fb);
  40:             hfreq[hash]=ct;
  41:             while (hash<k)
  42:             {
  43:                 hpt[++hash] = lp;
  44:                 hfreq[hash] = 0;
  45:             }
  46:             hpt[hash] = lp += iflong? sizeof(long) : sizeof(int);
  47:             opoint= -1;
  48:             ct=0;
  49:         }
  50:         if (point!=opoint)
  51:         {
  52:             if (iflong)
  53:                 putl(opoint=point, fb);
  54:             else
  55:                 putw( (int)(opoint=point), fb);
  56:             lp += iflong? sizeof(long) : sizeof(int);
  57:             ct++;
  58:         }
  59:     }
  60:     if (iflong) putl(-1L, fb);
  61:     else putw(-1,fb);
  62:     while (hash<nhash)
  63:         hpt[++hash]=lp;
  64:     fwrite(&nhash, sizeof(nhash), 1, fa);
  65:     fwrite(&iflong, sizeof(iflong), 1, fa);
  66:     fwrite(hpt, sizeof(*hpt), nhash, fa);
  67:     fwrite (hfreq, sizeof(*hfreq), nhash, fa);
  68:     *ptotct = totct;
  69:     *phused = hused;
  70: }
  71: 
  72: putl(ll, f)
  73: long ll;
  74: FILE *f;
  75: {
  76:     putw(ll, f);
  77: }
  78: 
  79: long
  80: getl(f)
  81: FILE *f;
  82: {
  83:     return(getw(f));
  84: }

Defined functions

getl defined in line 79; used 3 times
putl defined in line 72; used 3 times
whash defined in line 8; used 1 times

Defined variables

sccsid defined in line 2; never used
Last modified: 1987-02-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 816
Valid CSS Valid XHTML 1.0 Strict