Lines Matching refs:ar
234 #define cagetbits(ar,n) ((n)<=(ar)->left? \
235 ((((ar)->buf)>>((ar)->left-=(n)))&((1L<<(n))-1)):\
236 _cagetbits((ar), (n)))
239 _cagetbits(Ar_t* ar, int nbits)
243 while (ar->left <= 8 * (sizeof(ar->buf) - 1))
245 if (ar->count-- > 0)
247 c = *ar->next++;
248 ar->buf <<= 8;
249 ar->buf |= c;
250 ar->left += 8;
252 else if (ar->left < nbits)
257 return cagetbits(ar, nbits);
263 Ar_t* ar;
265 if (ar = (Ar_t*)ap->data)
267 if (ar->cam)
268 camap_close(ar->cam);
269 if (ar->dirs)
270 free(ar->dirs);
271 free(ar);
280 register Ar_t* ar;
300 if (!(ar = newof(0, Ar_t, 1, 0)))
305 ar->imap = (ar->map = ccmap(CC_EBCDIC_O, CC_NATIVE)) ? ar->map : ccmap(0, 0);
306 ar->bufsize = casize2(&hdr[24]);
307 ar->linesize = 80;
312 n = j * ar->bufsize;
320 (*pax->errorf)(NiL, pax, 1, "blk %c%c%c%c%c%c%c%c %02x %02x %02x %02x %02x %02x %02x %02x", ccmapchr(ar->map, blk[0]), ccmapchr(ar->map, blk[1]), ccmapchr(ar->map, blk[2]), ccmapchr(ar->map, blk[3]), ccmapchr(ar->map, blk[4]), ccmapchr(ar->map, blk[5]), ccmapchr(ar->map, blk[6]), ccmapchr(ar->map, blk[7]), blk[8], blk[9], blk[10], blk[11], blk[12], blk[13], blk[14], blk[15]);
326 (*pax->errorf)(NiL, pax, 1, "dir %c%c%c%c%c%c%c%c %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x", ccmapchr(ar->map, dir[0]), ccmapchr(ar->map, dir[1]), ccmapchr(ar->map, dir[2]), ccmapchr(ar->map, dir[3]), ccmapchr(ar->map, dir[4]), ccmapchr(ar->map, dir[5]), ccmapchr(ar->map, dir[6]), ccmapchr(ar->map, dir[7]), dir[8], dir[9], dir[10], dir[11], dir[12], dir[13], dir[14], dir[15], dir[16], dir[17], dir[18], dir[19], dir[20], dir[21]);
332 free(ar);
341 dp->size = cabcd5(&dir[15]) * ar->linesize;
342 ccmapstr(ar->map, dir, sizeof(dir));
348 ar->dirs = ar->dir = db;
349 ap->data = ar;
350 if (!(ar->cam = camap_open()))
361 register Ar_t* ar = (Ar_t*)ap->data;
391 if (ar->suffix)
403 else if (ar->camap)
404 camap_init(ar->cam);
406 sequence = ar->digits && ar->increment && (ar->position + ar->digits) <= ar->linesize ? ar->sequence : -1;
410 generate = ar->flags != 0xf1;
416 version = (pax->test & 0x00400) ? -1 : ar->version;
420 while (ar->line <= ar->blocksize - ar->headsize + 1)
422 ar->next = &ar->buffer[index = ar->line];
423 hdr = ar->next;
424 flags = ar->next[1];
427 ar->line += ar->next[0];
428 ar->next += ar->headsize;
431 ar->next += 2;
433 ar->next += 1;
435 if (version >= 0 && hdr[ar->headsize - 3] != version)
437 while ((ar->count = ar->next[-1]) == 1 && ar->next[0] == 0)
438 ar->next += 2;
441 (*pax->errorf)(NiL, pax, 0, "%03d %3u %3u %5u %3u %03o %4u %4u %4u %4u %4u %4o %4o %4o %4u %4u", error_info.line, ar->count, ar->next - hdr, ar->next - ar->buffer, hdr[0], hdr[1], hdr[2], hdr[3], hdr[4], hdr[5], hdr[6], hdr[7], hdr[8], hdr[9], hdr[10], hdr[11]);
443 (*pax->errorf)(NiL, pax, 0, "%03d %3u %3u %3u %03o %04..4u %04..4u %04..4u %04..4u %04..4u %04..4u %04..4u %04..4u %04..4u %04..4u", error_info.line, ar->count, ar->next - hdr, hdr[0], hdr[1], hdr[2], hdr[3], hdr[4], hdr[5], hdr[6], hdr[7], hdr[8], hdr[9], hdr[10], hdr[11]);
447 ar->count,
448 ar->next[-1], ar->next[-1], ar->next[-1], ar->next[-1] & 0x7f,
449 ar->next[0], ar->next[0], ar->next[0], ar->next[0] & 0x7f,
450 ar->next[1], ar->next[1], ar->next[1], ar->next[1] & 0x7f,
451 ar->next[2], ar->next[2], ar->next[2], ar->next[2] & 0x7f,
452 ar->next[3], ar->next[3], ar->next[3], ar->next[3] & 0x7f,
453 ar->next[4], ar->next[4], ar->next[4], ar->next[4] & 0x7f,
454 ar->next[5], ar->next[5], ar->next[5], ar->next[5] & 0x7f);
458 m = ar->imap;
468 while (ar->count && (ar->next - ar->buffer) < ar->line)
470 if (ar->count < 64)
472 ar->left = 0;
473 while ((c = cagetbits(ar, bits)) || bits == 8 && ar->count > 0)
474 if (out < &outbuf[ar->linesize])
479 (*pax->errorf)(NiL, pax, 2, "%s: overbyte (bits=%d offset=%I*u+%I*u block=%I*u)", ap->name, bits, sizeof(off_t), paxseek(pax, ap, (off_t)0, SEEK_CUR, 0) - ar->bufsize, sizeof(index), index, sizeof(block), block);
481 if ((ar->next - ar->buffer) >= ar->line)
483 if ((c = (*ar->next ^ 64)) & 0x80)
486 ar->next++;
488 else if (ar->count & 0x80)
491 (*pax->errorf)(NiL, pax, 1, "part c=%d n=%d k=%d \"%-.*s\"", c, out - outbuf, ar->count & 0x7f, out - outbuf, outbuf);
494 else if ((c = ar->count - 64) & 0x80)
497 (*pax->errorf)(NiL, pax, 1, "part c=%d:%d:%d r=%d:%d bits=%d n=%d x=%u \"%-.*s\"", c, &outbuf[ar->linesize] - out, c ^ 64, ar->next - ar->buffer, ar->line, bits, out - outbuf, *ar->next, out - outbuf, outbuf);
498 if (c > (&outbuf[ar->linesize] - out))
500 ar->count = c ^ 64;
501 if (bits == 8 && ar->count <= (&outbuf[ar->linesize] - out))
510 while ((ar->next - ar->buffer) < ar->line && (ar->count = *ar->next++) & 0x80)
513 s = cakey[ar->count & 0x7f];
515 (*pax->errorf)(NiL, pax, 1, "%s: keyword %s (bits=%d offset=%I*u+%I*u block=%I*u)", ap->name, s, bits, sizeof(off_t), paxseek(pax, ap, (off_t)0, SEEK_CUR, 0) - ar->bufsize, sizeof(index), index, sizeof(block), block);
517 if (out < &outbuf[ar->linesize])
524 (*pax->errorf)(NiL, pax, 2, "%s: key overbyte (bits=%d offset=%I*u+%I*u block=%I*u)", ap->name, bits, sizeof(off_t), paxseek(pax, ap, (off_t)0, SEEK_CUR, 0) - ar->bufsize, sizeof(index), index, sizeof(block), block);
625 if ((b = outbuf + ar->position) >= out || *b == ' ' || isdigit(*b) || (out - outbuf) == ar->linesize && (b = out - ar->digits))
627 if ((c = ar->position - (out - outbuf)) > 0)
632 b += sfsprintf((char*)b, ar->digits+1, "%0.*lu", ar->digits, generate ? sequence : casize3(&hdr[2]));
636 sequence += ar->increment;
679 if (sfwrite(wfp, outbuf, z) != z || ar->camap && camap_write(ar->cam, outbuf, z) < 0)
700 if (--ar->nblocks <= 0)
702 if (ar->buffer[2] == 0xff)
704 n = casize2(ar->buffer + ar->blocksize + (block != 1)) * ar->bufsize;
708 if (!(ar->buffer = (unsigned char*)paxget(pax, ap, (off_t)ar->bufsize, NiL)))
710 ar->blocksize = casize2(ar->buffer);
711 ar->next = ar->buffer;
712 ar->line = 4;
718 if (sfsync(wfp) || ar->camap && camap_done(ar->cam, f->name, wfd) < 0)
727 strcpy(ar->suffix, suffix);
738 register Ar_t* ar = (Ar_t*)ap->data;
750 if (!ar->dir->offset)
752 n = ar->bufsize * ar->dir->offset;
755 ar->nblocks = ar->dir->blocks;
756 if (!(ar->buffer = (unsigned char*)paxget(pax, ap, (off_t)ar->bufsize, NiL)))
758 ar->blocksize = casize2(&ar->buffer[0]) + 1;
759 ar->headsize = 6;
760 ar->version = -1;
761 ar->next = ar->buffer;
764 for (j = 1, x = 0, h = ar->buffer + 4; !x && h < ar->buffer + ar->bufsize; j++, h += i)
796 switch (ar->flags = h[32])
799 ar->headsize = 5;
802 ar->headsize = 8;
805 ar->version = h[-3];
806 ar->position = h[33];
807 ar->digits = h[34] + 1;
808 ar->increment = casize2(&h[35]);
809 if ((ar->sequence = casize2(&h[37])) > 0x7fff)
810 ar->sequence = ar->sequence - 0x10000;
811 ar->sequence += ar->increment;
812 ccmapstr(ar->map, h, 24);
815 *(ar->suffix = s) = 0;
821 switch (ar->flags = h[32])
824 ar->headsize = 3;
829 ar->digits = 0;
830 ar->linesize = 133;
834 ar->position = h[33];
835 ar->digits = h[34] + 1;
836 ar->increment = casize2(&h[35]);
837 if ((ar->sequence = casize2(&h[37])) > 0x7fff)
838 ar->sequence = ar->sequence - 0x10000;
839 ar->sequence += ar->increment;
841 ccmapstr(ar->map, h, 32);
844 *(ar->suffix = s) = 0;
870 ccmapstr(ar->map, t, 3);
877 if (ar->linesize == 133)
880 ar->suffix = 0;
911 ar->suffix = 0;
921 ar->line = h - ar->buffer;
922 ar->camap = 0;
923 if (ar->suffix)
926 ar->line = h - ar->buffer;
927 ar->suffix = 0;
933 ar->camap = 1;
950 f->st->st_size = ar->dir->size;
951 ar->dir++;