5 /* automatically generated; do not edit. */
6 typedef struct Fibhdr Fibhdr;
20 uchar fReadOnlyRecommended;
21 uchar fWriteReservation;
31 uchar fLoadOverridePage;
32 uchar fFutureSavedUndo;
40 enum { bcFibhdr = 0x22 };
42 /* automatically generated; do not edit. */
44 readFibhdr(Fibhdr *s, uchar *v, int nv)
46 if(nv < bcFibhdr) sysfatal("not enough data for Fibhdr");
47 s->wIdent = v[0x0] | (v[0x0+1] << 8);
48 s->nFib = v[0x2] | (v[0x2+1] << 8);
49 s->nProduct = v[0x4] | (v[0x4+1] << 8);
50 s->lid = v[0x6] | (v[0x6+1] << 8);
51 s->pnNext = v[0x8] | (v[0x8+1] << 8);
52 s->fDot = ((v[0xA]) & 0x1) >> 0;
53 s->fGlsy = ((v[0xA]) & 0x2) >> 1;
54 s->fComplex = ((v[0xA]) & 0x4) >> 2;
55 s->fHasPic = ((v[0xA]) & 0x8) >> 3;
56 s->cQuickSaves = ((v[0xA]) & 0x240) >> 4;
57 s->fEncrypted = ((v[0xB]) & 0x1) >> 0;
58 s->fWhichTblStm = ((v[0xB]) & 0x2) >> 1;
59 s->fReadOnlyRecommended = ((v[0xB]) & 0x4) >> 2;
60 s->fWriteReservation = ((v[0xB]) & 0x8) >> 3;
61 s->fExtChar = ((v[0xB]) & 0x16) >> 4;
62 s->fLoadOverride = ((v[0xB]) & 0x32) >> 5;
63 s->fFarEast = ((v[0xB]) & 0x64) >> 6;
64 s->fCrypto = ((v[0xB]) & 0x128) >> 7;
65 s->nFibBack = v[0xC] | (v[0xC+1] << 8);
66 s->lKey = v[0xE] | (v[0xE+1] << 8)| (v[0xE+2] << 16) | (v[0xE+3] << 24);
68 s->fMac = ((v[0x13]) & 0x1) >> 0;
69 s->fEmptySpecial = ((v[0x13]) & 0x2) >> 1;
70 s->fLoadOverridePage = ((v[0x13]) & 0x4) >> 2;
71 s->fFutureSavedUndo = ((v[0x13]) & 0x8) >> 3;
72 s->fWord97Saved = ((v[0x13]) & 0x16) >> 4;
73 s->chs = v[0x14] | (v[0x14+1] << 8);
74 s->chsTables = v[0x16] | (v[0x16+1] << 8);
75 s->fcMin = v[0x18] | (v[0x18+1] << 8)| (v[0x18+2] << 16) | (v[0x18+3] << 24);
76 s->fcMac = v[0x1C] | (v[0x1C+1] << 8)| (v[0x1C+2] << 16) | (v[0x1C+3] << 24);
77 s->csw = v[0x20] | (v[0x20+1] << 8);
83 fprint(2, "usage: wordtext /mnt/doc/WordDocument\n");
88 main(int argc, char **argv)
104 Binit(&bout, 1, OWRITE);
105 b = Bopen(argv[0], OREAD);
107 fprint(2, "couldn't open file: %r\n");
111 n = Bread(b, buf, sizeof buf);
113 fprint(2, "short read: %r\n");
117 readFibhdr(&f, buf, sizeof buf);
120 Bseek(b, f.fcMin, 0);
122 n = f.fcMac - f.fcMin;
133 case '\\': Bprint(&bout, "\\"); break; /* field escape */
134 case 7: Bprint(&bout, "\n"); break; /* cell, row mark */
135 case 9: Bprint(&bout, "\t"); break; /* tab */
136 case 11: Bprint(&bout, "\n"); break; /* hard line break */
137 case 12: Bprint(&bout, "\n\n\n\n"); break; /* page break */
138 case 13: Bprint(&bout, "\n\n"); break; /* paragraph end */
139 case 14: break; /* column break */
140 case 19: Bprint(&bout, "<"); break; /* field begin */
141 case 20: Bprint(&bout, ":"); break; /* field sep */
142 case 21: Bprint(&bout, ">"); break; /* field end */
143 case 30: Bprint(&bout, "-"); break; /* non-breaking hyphen */
144 case 31: break; /* non-required hyphen */
145 /* case 45: Bprint(&bout, "-"); break; /* breaking hyphen */
146 case 160: Bprint(&bout, " "); break; /* non-breaking space */
149 * these are only supposed to get used when special is set, but we
150 * never see these ascii values otherwise anyway.
154 * Empirically, some documents have sections of text where
155 * every character is followed by a zero byte. Some have sections
156 * of text where there are no zero bytes. Still others have both
157 * types and alternate between them. Until we parse which
158 * characters are ``special'', page numbers lose out.
160 case 0: /* Bprint(&bout, "<pageno>"); */ break;
161 case 1: Bprint(&bout, "<picture>"); break;
162 case 2: Bprint(&bout, "<footnote>"); break;
163 case 3: Bprint(&bout, "<footnote sep>"); break;
164 case 4: Bprint(&bout, "<footnote cont>"); break;
165 case 5: Bprint(&bout, "<animation>"); break;
166 case 6: Bprint(&bout, "<lineno>"); break;
167 /* case 7: Bprint(&bout, "<hand picture>"); break; */
168 case 8: Bprint(&bout, "<drawn object>"); break;
169 case 10: Bprint(&bout, "<abbrev date>"); break;
170 /* case 11: Bprint(&bout, "<hh:mm:ss>"); break; */
171 /* case 12: Bprint(&bout, "<section no>"); break; */
172 /* case 14: Bprint(&bout, "<Thu>"); break; */
173 case 15: Bprint(&bout, "<Thursday>"); break;
174 case 16: Bprint(&bout, "<day of month>"); break;
176 case 22: Bprint(&bout, "<hour>"); break;
177 case 23: Bprint(&bout, "<hour hh>"); break;
178 case 24: Bprint(&bout, "<minute>"); break;
179 case 25: Bprint(&bout, "<minute mm>"); break;
180 case 26: Bprint(&bout, "<seconds>"); break;
181 case 27: Bprint(&bout, "<AM/PM>"); break;
182 case 28: Bprint(&bout, "<hh:mm:ss>"); break;
183 case 29: Bprint(&bout, "<date>"); break;
184 /* printable ascii begins hereish */
186 case 30: Bprint(&bout, "<mm/dd/yy>"); break;
187 case 33: Bprint(&bout, "<mm>"); break;
188 case 34: Bprint(&bout, "<yyyy>"); break;
189 case 35: Bprint(&bout, "<yy>"); break;
190 case 36: Bprint(&bout, "<Feb>"); break;
191 case 37: Bprint(&bout, "<February>"); break;
192 case 38: Bprint(&bout, "<hh:mm>"); break;
193 case 39: Bprint(&bout, "<long date>"); break;