void onepass(u_char **a, int depth, long n, long sizes[], u_char *tr, FILE *fp) { size_t tsizes[NBINS+1]; u_char **bin[257], **top[256], ***bp, ***bpmax, ***tp; static int histo[256]; int *hp; int c; u_char **an, *t, **aj; u_char **ak, *r; memset(tsizes, 0, sizeof(tsizes)); depth += sizeof(TRECHEADER); an = &a[n]; for (ak = a; ak < an; ak++) { histo[c = tr[**ak]]++; tsizes[c] += ((RECHEADER *) (*ak -= depth))->length; } bin[0] = a; bpmax = bin + 256; tp = top, hp = histo; for (bp = bin; bp < bpmax; bp++) { *tp++ = *(bp + 1) = *bp + (c = *hp); *hp++ = 0; if (c <= 1) continue; } for (aj = a; aj < an; *aj = r, aj = bin[c + 1]) for (r = *aj; aj < (ak = --top[c = tr[r[depth]]]); ) swap(*ak, r, t); for (ak = a, c = 0; c < 256; c++) { an = bin[c + 1]; n = an - ak; tsizes[c] += n * sizeof(TRECHEADER); /* tell getnext how many elements in this bin, this segment. */ EWRITE(&tsizes[c], sizeof(size_t), 1, fp); sizes[c] += tsizes[c]; for (; ak < an; ++ak) putrec((RECHEADER *) *ak, fp); } }
/* * write dump of key to output (for -Dk) */ void putkeydump(const RECHEADER *rec, FILE *fp) { EWRITE(rec, 1, REC_ROUNDUP(offsetof(RECHEADER, data) + rec->offset), fp); }
/* * write a line to output */ void putline(const RECHEADER *rec, FILE *fp) { EWRITE(rec->data+rec->offset, 1, rec->length - rec->offset, fp); }
/* * write a key/line pair to a temporary file */ void putrec(const RECHEADER *rec, FILE *fp) { EWRITE(rec, 1, REC_ROUNDUP(offsetof(RECHEADER, data) + rec->length), fp); }