root/trunk/lydump.c

Revision 389, 4.4 kB (checked in by heitor.barbieri, 3 weeks ago)

essage first commit

Line 
1
2/* --------------------------- lydump.c ---------------------------- */
3
4/* ------------------------------ my.c ----------------------------- */
5
6#include <stdio.h>
7#include <string.h>
8
9#include "cisis.h"      /* dbx routines */
10#include "cirun.h"      /* runtime area and defines by AOT */
11
12
13/* ----------------------------- tlc.h ------------------------------ */
14
15typedef struct tlcleaf {
16    PUNT        pos;                    /* gdb .l0x pos */
17    UWORD         ock;                    /* gdb .l0x ock */
18    UWORD         it;                     /* gdb .l0x it */
19    PUNT        ps;                     /* gdb .l0x ps */
20    PUNT        psb;                    /* tlc gdb .l0x ps backward */
21    union {
22        struct l1xe {
23            UCHR        key[LE1] PACKED2;       /* tlc .l01 keys */
24            INFX        info1 PACKED2;          /* tlc info1 - byte addr */
25            INFO        info2 PACKED2;          /* tlc info2 - tot no of postings */
26            union {
27                INFX    info3 PACKED2;          /* tlc info3 - tot no of docs */
28                INFX    info4 PACKED2;          /* tlc info4 - posting type and etc */
29            } info3info4;
30        } l1x[TWORDF];
31        struct l2xe {
32            UCHR        key[LE2] PACKED2;       /* tlc .l02 keys */
33            INFX        info1 PACKED2;          /* tlc info1 - byte addr */
34            INFO        info2 PACKED2;          /* tlc info2 - tot no of postings */
35            union {
36                INFX    info3 PACKED2;          /* tlc info3 - tot no of docs */
37                INFX    info4 PACKED2;          /* tlc info4 - posting type and etc */
38            } info3info4;
39        } l2x[TWORDF];
40    } lx;
41} TLCLEAF;
42
43#define BITSTRING       (-1)
44#define MFNSTRING       0
45#define CNTSTRING       1
46
47/* ----------------------------------------------------------------------- */
48
49TLCLEAF tlcleaf;
50int sizeofleaf[2] = { sizeof(TLCLEAF)
51                                -sizeof(struct l2xe)*TWORDF
52                                +sizeof(struct l1xe)*TWORDF,
53                      sizeof(TLCLEAF) };
54
55
56
57void main(argc,argv)
58int argc;
59char *argv[];
60{
61    int fd,nread,i,n,treecase,szofleaf;
62
63    TLCLEAF *lp;
64    char *p;
65    LONGX count;
66
67
68    if (argc < 2)
69        fatal("parm missing");
70
71    if ((fd=OPEN(argv[1],O_RDONLY | O_BINARY)) <= 0)
72        fatal(argv[1]);
73
74    treecase=argv[1][strlen(argv[1])-1];
75    if (treecase != '1' && treecase != '2') fatal("treecase 1/2");
76    szofleaf=sizeofleaf[(treecase-='1')];
77
78
79    count=0;
80    lp= &tlcleaf;
81    if (argc>2) {
82       LONGX ld;
83       INFX skipb;
84       if (sscanf(argv[2],"%"_LD_,&ld)==1) {
85              skipb=(INFX)ld*szofleaf;
86              printf("ld,sizeofleaf,skipb=%"_LD_",%d,%lu\n",ld,szofleaf,skipb);
87              printf("lseek=%lu\n",LSEEK64(fd,skipb,SEEK_SET));
88       }
89     }
90
91
92    nread=CIREAD(fd,(char *)lp,szofleaf);
93    printf("nread,sizeofleaf=%d,%d\n",nread,szofleaf);
94
95    while (nread == szofleaf) {
96        ++count;
97        printf("%4"_LD_" pos=%4"_LD_" ock=%2d it=%d ps=%"_LD_"/%"_LD_" \'",
98            count,(LONGX)lp->pos,lp->ock,lp->it,(LONGX)lp->ps,(LONGX)lp->psb);
99                if (treecase)
100        for (p=lp->lx.l2x[0].key, n=LE2; n--; p++) printf("%c",*p);
101                else
102        for (p=lp->lx.l1x[0].key, n=LE1; n--; p++) printf("%c",*p);
103        printf("\'");
104        if (argc > 2) {
105            if (*argv[2] == '/') putchar('\n'); else getchar();
106            for (i=0; i < lp->ock; i++) {
107                printf(" %2d \'",i+1);
108                if (treecase) {
109                    for (p=lp->lx.l2x[i].key, n=LE2; n--; p++) printf("%c",*p);
110                    printf("\' info=%"P_OFF_T",%"_LD_",%"_LD_"=%"_LD_"\n",
111                        (LONG_LONG)lp->lx.l2x[i].info1,
112                        lp->lx.l2x[i].info2,
113                        lp->lx.l2x[i].info3info4.info3,
114                        lp->lx.l2x[i].info3info4.info4);
115                }
116                else {
117                    for (p=lp->lx.l1x[i].key, n=LE1; n--; p++) printf("%c",*p);
118                    printf("\' info=%lu,%"_LD_",%"_LD_"=%"_LD_"\n",
119                        lp->lx.l1x[i].info1,
120                        lp->lx.l1x[i].info2,
121                        lp->lx.l1x[i].info3info4.info3,
122                        lp->lx.l1x[i].info3info4.info4);
123                }
124            }
125        }
126        else
127            putchar('\n');
128        nread=CIREAD(fd,(char *)lp,szofleaf);
129    }
130
131    printf("count,nread=%"_LD_",%d\n",count,nread);
132    exit(0);
133}
Note: See TracBrowser for help on using the browser.