1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
|
$NetBSD: patch-ad,v 1.1.1.1 2001/05/23 15:47:45 agc Exp $
--- helpdeco.c.orig Tue Jan 28 00:57:48 1997
+++ helpdeco.c Mon May 21 14:35:47 2001
@@ -383,7 +383,7 @@
char *extension;
int extensions=0;
/* index into bmpext: bit 0=multiresolution bit 1=bitmap, bit 2=metafile, bit 3=hotspot data, bit 4=embedded, bit 5=transparent */
-char *bmpext[]={"???","MRB","BMP","MRB","WMF","MRB","MRB","MRB","SHG","MRB","SHG","MRB","SHG","MRB","SHG","MRB"};
+char *bmpext[]={"???","mrb","bmp","mrb","wmf","mrb","mrb","mrb","shg","mrb","shg","mrb","shg","mrb","shg","mrb"};
char **stopwordfilename;
int stopwordfiles;
char **fontname;
@@ -473,7 +473,7 @@
result=0UL;
for(mask=0x80000000UL;mask;mask>>=1)
{
- if(hashhi>divhi||hashhi==divhi&&hashlo>=divlo)
+ if(hashhi>divhi||(hashhi==divhi&&hashlo>=divlo))
{
result|=mask;
hashhi-=divhi;
@@ -908,8 +908,8 @@
_splitpath(a,NULL,NULL,aname,aext);
_splitpath(b,NULL,NULL,bname,bext);
- if(aext[0]=='\0') strcpy(aext,".HLP");
- if(bext[0]=='\0') strcpy(bext,".HLP");
+ if(aext[0]=='\0') strcpy(aext,".hlp");
+ if(bext[0]=='\0') strcpy(bext,".hlp");
i=strcmpi(aname,bname);
if(i) return i;
return strcmpi(aext,bext);
@@ -1346,7 +1346,7 @@
f->seek(f,FileStart+dwOffsBitmap);
byType=f->get(f); /* type of picture: 5=DDB, 6=DIB, 8=METAFILE */
byPacked=f->get(f); /* packing method: 0=unpacked, 1=RunLen, 2=LZ77, 3=both */
- if(byType==6&&byPacked<4||byType==5&&byPacked<2)
+ if((byType==6&&byPacked<4)||(byType==5&&byPacked<2))
{
type|=2; /* contains bitmap */
memset(&bmfh,0,sizeof(bmfh));
@@ -1370,10 +1370,10 @@
dwHotspotSize=GetCDWord(f);
dwPictureOffset=GetDWord(f);
dwHotspotOffset=GetDWord(f);
- if(exportplain||n==1&&(dwHotspotOffset==0L||dwHotspotSize==0L))
+ if((exportplain||n==1)&&(dwHotspotOffset==0L||dwHotspotSize==0L))
{
if(checkexternal) break;
- strcat(szFilename,".BMP");
+ strcat(szFilename,".bmp");
fTarget=my_fopen(szFilename,"wb");
if(fTarget)
{
@@ -1450,14 +1450,14 @@
dwHotspotSize=GetCDWord(f);
dwPictureOffset=GetDWord(f);
dwHotspotOffset=GetDWord(f);
- if(exportplain||n==1&&(dwHotspotOffset==0L||dwHotspotSize==0L))
+ if((exportplain||n==1)&&(dwHotspotOffset==0L||dwHotspotSize==0L))
{
if(checkexternal) break;
afh.dwKey=0x9AC6CDD7L;
afh.wInch=2540;
wp=(unsigned short *)&afh;
for(i=0;i<10;i++) afh.wChecksum^=*wp++;
- strcat(szFilename,".WMF");
+ strcat(szFilename,".wmf");
fTarget=my_fopen(szFilename,"wb");
if(fTarget)
{
@@ -1589,7 +1589,7 @@
case 0xEB: /* topic jump into external file / secondary window */
case 0xEE: /* popup jump into external file without font change */
case 0xEF: /* topic jump into external file / secondary window without font change */
- if(hotspot[n].id1!=0&&hotspot[n].id1!=1&&hotspot[n].id1!=4&&hotspot[n].id1!=6||hotspot[n].id2!=0)
+ if((hotspot[n].id1!=0&&hotspot[n].id1!=1&&hotspot[n].id1!=4&&hotspot[n].id1!=6)||(hotspot[n].id2!=0))
{
}
else
@@ -1631,8 +1631,8 @@
return type;
}
/****************************************************************************
-// END OF GRAPHICS STUFF
-//**************************************************************************/
+END OF GRAPHICS STUFF
+**************************************************************************/
char *getbitmapname(unsigned int n) /* retrieve extension of exported bitmap n */
{
@@ -2018,7 +2018,7 @@
}
putc('\n',hpj);
}
- if(groups||multi&&browsenums>1)
+ if((groups||multi)&&(browsenums>1))
{
group=my_malloc(groups*sizeof(GROUP));
fputs("[GROUPS]\n",hpj);
@@ -2320,6 +2320,7 @@
void FontLoad(FILE *HelpFile,FILE *rtf,FILE *hpj)
{
static char *BestFonts[]={"Arial","Times New Roman","MS Sans Serif","MS Serif","Helv","TmsRmn","MS Sans Serif","Helvetica","Times Roman","Times"};
+ int default_font = 0;
CHARMAPHEADER CharmapHeader;
FONTHEADER FontHdr;
FILE *f;
@@ -2355,6 +2356,9 @@
fseek(HelpFile,FontStart+FontHdr.FacenamesOffset+len*i,SEEK_SET);
my_fread(FontName,len,HelpFile);
FontName[len]='\0';
+ if (FontName[0] == '\000') {
+ strcpy(FontName, BestFonts[default_font]);
+ }
ptr=strchr(FontName,',');
if(ptr&&FontHdr.FacenamesOffset>=16)
{
@@ -2586,14 +2590,14 @@
if(m->font.expndtw!=n->font.expndtw) fprintf(rtf,"\\expndtw%d",m->font.expndtw);
if(m->font.FGRGB[0]!=n->font.FGRGB[0]) fprintf(rtf,"\\cf%d",m->font.FGRGB[0]);
if(m->font.BGRGB[0]!=n->font.BGRGB[0]) fprintf(rtf,"\\cb%d",m->font.BGRGB[0]);
- if(m->font.Height!=n->font.Height) fprintf(rtf,"\\fs%d",-2L*m->font.Height);
+ if(m->font.Height!=n->font.Height) fprintf(rtf,"\\fs%ld",-2L*m->font.Height);
if((m->font.Weight>500)!=(n->font.Weight>500)) fprintf(rtf,"\\b%d",m->font.Weight>500);
if(m->font.Italic!=n->font.Italic) fprintf(rtf,"\\i%d",m->font.Italic);
if(m->font.Underline!=n->font.Underline) fprintf(rtf,"\\ul%d",m->font.Underline);
if(m->font.StrikeOut!=n->font.StrikeOut) fprintf(rtf,"\\strike%d",m->font.StrikeOut);
if(m->font.DoubleUnderline!=n->font.DoubleUnderline) fprintf(rtf,"\\uldb%d",m->font.DoubleUnderline);
if(m->font.SmallCaps!=n->font.SmallCaps) fprintf(rtf,"\\scaps%d",m->font.SmallCaps);
- if(m->font.up!=n->font.up) if(m->font.up>0) fprintf(rtf,"\\up%d",m->font.up); else fprintf(rtf,"\\dn%d",-m->font.up);
+ if(m->font.up!=n->font.up) fprintf(rtf,"\\up%d",abs(m->font.up));
fprintf(rtf," \\sbasedon%u",m->BasedOn+9);
}
else
@@ -2608,7 +2612,7 @@
if(m->font.expndtw) fprintf(rtf,"\\expndtw%d",m->font.expndtw);
if(m->font.up>0) fprintf(rtf,"\\up%d",m->font.up);
else if(m->font.up<0) fprintf(rtf,"\\dn%d",-m->font.up);
- fprintf(rtf,"\\fs%d",-2*m->font.Height);
+ fprintf(rtf,"\\fs%ld",-2*m->font.Height);
if(m->font.FGRGB[0]) fprintf(rtf,"\\cf%d",m->font.FGRGB[0]);
if(m->font.BGRGB[0]) fprintf(rtf,"\\cb%d",m->font.BGRGB[0]);
}
@@ -2630,7 +2634,7 @@
if(m->font.FontName!=n->font.FontName) fprintf(rtf,"\\f%d",m->font.FontName);
if(m->font.FGRGB[0]!=n->font.FGRGB[0]) fprintf(rtf,"\\cf%d",m->font.FGRGB[0]);
if(m->font.BGRGB[0]!=n->font.BGRGB[0]) fprintf(rtf,"\\cb%d",m->font.BGRGB[0]);
- if(m->font.Height!=n->font.Height) fprintf(rtf,"\\fs%d",-2L*m->font.Height);
+ if(m->font.Height!=n->font.Height) fprintf(rtf,"\\fs%ld",-2L*m->font.Height);
if((m->font.Weight>500)!=(n->font.Weight>500)) fprintf(rtf,"\\b%d",m->font.Weight>500);
if(m->font.Italic!=n->font.Italic) fprintf(rtf,"\\i%d",m->font.Italic);
if(m->font.Underline!=n->font.Underline) fprintf(rtf,"\\ul%d",m->font.Underline);
@@ -2648,7 +2652,7 @@
if(m->font.StrikeOut) fputs("\\strike",rtf);
if(m->font.DoubleUnderline) fputs("\\uldb",rtf);
if(m->font.SmallCaps) fputs("\\scaps",rtf);
- fprintf(rtf,"\\fs%d",-2*m->font.Height);
+ fprintf(rtf,"\\fs%ld",-2*m->font.Height);
if(m->font.FGRGB[0]) fprintf(rtf,"\\cf%d",m->font.FGRGB[0]);
if(m->font.BGRGB[0]) fprintf(rtf,"\\cb%d",m->font.BGRGB[0]);
}
@@ -2800,10 +2804,12 @@
{
char *buffer;
long BytesRead;
+ long i;
if(Length<=NumBytes) /* no phrase compression in this case */
{
BytesRead=TopicRead(HelpFile,TopicPos,dest,Length);
+ for (i = BytesRead; i <= Length; i++) dest[i] = '\0';
if(BytesRead==Length&&Length<NumBytes) /* some trailing bytes are not used (bug in HCRTF ?) */
{
buffer=my_malloc(NumBytes-Length);
@@ -3325,14 +3331,14 @@
strcpy(buffer,name);
if(i)
{
- itoa(i,num,10);
+ snprintf(num, 7, "%d", i);
if(strlen(buffer)+strlen(num)>8)
{
buffer[8-strlen(num)]='\0';
}
strcat(buffer,num);
}
- strcat(buffer,".RTF");
+ strcat(buffer,".rtf");
}
/* emit rtf commands to change to font i.
@@ -3354,17 +3360,17 @@
else
{
/* HC30 can't reset, so reset using \plain */
- if(CurrentFont.Bold&&!f->Bold
- || CurrentFont.Italic&&!f->Italic
- || CurrentFont.Underline&&!(!uldb&&(ul||f->Underline))
- || CurrentFont.StrikeOut&&!f->StrikeOut
- || CurrentFont.DoubleUnderline&&!(uldb||f->DoubleUnderline)
- || CurrentFont.SmallCaps&&!f->SmallCaps
- || CurrentFont.FontName&&!f->FontName
- || CurrentFont.textcolor&&!f->textcolor
- || CurrentFont.backcolor&&!f->backcolor
- || CurrentFont.up&&!f->up
- || CurrentFont.style&&!f->style)
+ if((CurrentFont.Bold&&!f->Bold)
+ || (CurrentFont.Italic&&!f->Italic)
+ || (CurrentFont.Underline&&!(!uldb&&(ul||f->Underline)))
+ || (CurrentFont.StrikeOut&&!f->StrikeOut)
+ || (CurrentFont.DoubleUnderline&&!(uldb||f->DoubleUnderline))
+ || (CurrentFont.SmallCaps&&!f->SmallCaps)
+ || (CurrentFont.FontName&&!f->FontName)
+ || (CurrentFont.textcolor&&!f->textcolor)
+ || (CurrentFont.backcolor&&!f->backcolor)
+ || (CurrentFont.up&&!f->up)
+ || (CurrentFont.style&&!f->style))
{
fputs("\\plain",rtf);
memset(&CurrentFont,0,sizeof(CurrentFont));
@@ -3408,7 +3414,7 @@
grouplisted=FALSE;
for(i=0;i<groups;i++) if(group[i].GroupHeader.GroupType==1||group[i].GroupHeader.GroupType==2)
{
- if(TopicNum>=group[i].GroupHeader.FirstTopic&&TopicNum<=group[i].GroupHeader.LastTopic&&(group[i].GroupHeader.GroupType==1||group[i].GroupHeader.GroupType==2&&(group[i].Bitmap[TopicNum>>3]&(1<<(TopicNum&7)))))
+ if((TopicNum>=group[i].GroupHeader.FirstTopic&&TopicNum<=group[i].GroupHeader.LastTopic)&&((group[i].GroupHeader.GroupType==1||group[i].GroupHeader.GroupType==2)&&(group[i].Bitmap[TopicNum>>3]&(1<<(TopicNum&7)))))
{
if(!grouplisted)
{
@@ -3544,9 +3550,9 @@
fprintf(rtf,"{\\up #}{\\footnote\\pard\\plain{\\up #} TOPIC%ld}\n",TopicNum);
if(resolvebrowse)
{
- if(TopicHdr30->NextTopicNum>TopicNum&&TopicHdr30->PrevTopicNum>TopicNum
- || TopicHdr30->NextTopicNum==-1&&TopicHdr30->PrevTopicNum>TopicNum
- || TopicHdr30->NextTopicNum>TopicNum&&TopicHdr30->PrevTopicNum==-1)
+ if((TopicHdr30->NextTopicNum>TopicNum&&TopicHdr30->PrevTopicNum>TopicNum)
+ || (TopicHdr30->NextTopicNum==-1&&TopicHdr30->PrevTopicNum>TopicNum)
+ || (TopicHdr30->NextTopicNum>TopicNum&&TopicHdr30->PrevTopicNum==-1))
{
BrowseNum=AddLink(TopicNum,TopicHdr30->NextTopicNum,TopicHdr30->PrevTopicNum);
}
@@ -3579,9 +3585,9 @@
}
if(resolvebrowse)
{
- if(TopicHdr->BrowseFor>TopicOffset&&TopicHdr->BrowseBck>TopicOffset
- || TopicHdr->BrowseFor==-1L&&TopicHdr->BrowseBck>TopicOffset
- || TopicHdr->BrowseFor>TopicOffset&&TopicHdr->BrowseBck==-1L)
+ if((TopicHdr->BrowseFor>TopicOffset&&TopicHdr->BrowseBck>TopicOffset)
+ || (TopicHdr->BrowseFor==-1L&&TopicHdr->BrowseBck>TopicOffset)
+ || (TopicHdr->BrowseFor>TopicOffset&&TopicHdr->BrowseBck==-1L))
{
BrowseNum=AddLink(TopicOffset,TopicHdr->BrowseFor,TopicHdr->BrowseBck);
}
@@ -3635,7 +3641,7 @@
}
TopicNum++;
}
- else if(LinkData1&&LinkData2&&TopicLink.RecordType==TL_DISPLAY30||TopicLink.RecordType==TL_DISPLAY||TopicLink.RecordType==TL_TABLE)
+ else if(LinkData1&&LinkData2&&(TopicLink.RecordType==TL_DISPLAY30||TopicLink.RecordType==TL_DISPLAY||TopicLink.RecordType==TL_TABLE))
{
if(AnnoFile) Annotate(TopicPos,rtf);
ptr=LinkData1;
@@ -3738,7 +3744,7 @@
break;
}
}
- fprintf(rtf,"\\tx%d",(x1&0x3FFF)*scaling-rounderr);
+ fprintf(rtf,"\\tx%ld",(x1&0x3FFF)*scaling-rounderr);
}
}
putc(' ',rtf);
@@ -4100,7 +4106,7 @@
return rtf;
}
-int _cdecl ContextRecCmp(const void *a,const void *b)
+int ContextRecCmp(const void *a,const void *b)
{
if(((const CONTEXTREC *)a)->TopicOffset<((const CONTEXTREC *)b)->TopicOffset) return -1;
if(((const CONTEXTREC *)a)->TopicOffset>((const CONTEXTREC *)b)->TopicOffset) return 1;
@@ -5154,9 +5160,9 @@
TopicHdr30=(TOPICHEADER30 *)LinkData1;
if(resolvebrowse)
{
- if(TopicHdr30->NextTopicNum>TopicNum&&TopicHdr30->PrevTopicNum>TopicNum
- || TopicHdr30->NextTopicNum==-1&&TopicHdr30->PrevTopicNum>TopicNum
- || TopicHdr30->NextTopicNum>TopicNum&&TopicHdr30->PrevTopicNum==-1)
+ if((TopicHdr30->NextTopicNum>TopicNum&&TopicHdr30->PrevTopicNum>TopicNum)
+ || (TopicHdr30->NextTopicNum==-1&&TopicHdr30->PrevTopicNum>TopicNum)
+ || (TopicHdr30->NextTopicNum>TopicNum&&TopicHdr30->PrevTopicNum==-1))
{
AddBrowse(TopicNum,TopicHdr30->NextTopicNum,TopicHdr30->PrevTopicNum);
}
@@ -5187,9 +5193,9 @@
TopicHdr=(TOPICHEADER *)LinkData1;
if(resolvebrowse)
{
- if(TopicHdr->BrowseFor>TopicOffset&&TopicHdr->BrowseBck>TopicOffset
- || TopicHdr->BrowseFor==-1L&&TopicHdr->BrowseBck>TopicOffset
- || TopicHdr->BrowseFor>TopicOffset&&TopicHdr->BrowseBck==-1L)
+ if((TopicHdr->BrowseFor>TopicOffset&&TopicHdr->BrowseBck>TopicOffset)
+ || (TopicHdr->BrowseFor==-1L&&TopicHdr->BrowseBck>TopicOffset)
+ || (TopicHdr->BrowseFor>TopicOffset&&TopicHdr->BrowseBck==-1L))
{
AddBrowse(TopicOffset,TopicHdr->BrowseFor,TopicHdr->BrowseBck);
}
@@ -5394,7 +5400,7 @@
}
}
-int _cdecl CTXOMAPRecCmp(const void *a,const void *b)
+int CTXOMAPRecCmp(const void *a,const void *b)
{
if(((CTXOMAPREC *)a)->TopicOffset<((CTXOMAPREC *)b)->TopicOffset) return -1;
if(((CTXOMAPREC *)a)->TopicOffset>((CTXOMAPREC *)b)->TopicOffset) return 1;
@@ -5577,22 +5583,22 @@
strcpy(hpjfilename,name);
if(mvp)
{
- strcat(hpjfilename,".MVP");
+ strcat(hpjfilename,".mvp");
}
else
{
- strcat(hpjfilename,".HPJ");
+ strcat(hpjfilename,".hpj");
}
hpj=my_fopen(hpjfilename,"wt");
if(hpj)
{
strcpy(filename,name);
- strcat(filename,".ICO");
+ strcat(filename,".ico");
SysList(HelpFile,hpj,filename); /* after ContextLoad */
ListBaggage(HelpFile,hpj,before31);
if(!mvp) AliasList(hpj); /* after ContextLoad, before TopicDump */
strcpy(filename,name);
- strcat(filename,".PH");
+ strcat(filename,".ph");
PhraseList(filename); /* after PhraseLoad */
BuildName(filename,TopicsPerRTF>0);
rtf=my_fopen(filename,"wt");
@@ -5672,7 +5678,7 @@
putc('\n',stderr);
if(!before31&&guessing) GuessFromKeywords(HelpFile); /* after FirstPass, before SysList */
strcpy(filename,name);
- strcat(filename,".CNT");
+ strcat(filename,".cnt");
rtf=my_fopen(filename,"wt");
if(rtf)
{
@@ -5752,7 +5758,7 @@
PhraseLoad(HelpFile);
DumpTopic(HelpFile,offset);
}
- else if(strcmp(dumpfile+strlen(dumpfile)-4,".GRP")==0)
+ else if(strcmp(dumpfile+strlen(dumpfile)-4,".grp")==0)
{
GroupDump(HelpFile);
}
@@ -5882,7 +5888,7 @@
return TRUE;
}
-int _cdecl main(int argc,char *argv[])
+int main(int argc,char *argv[])
{
char AnnoFileName[81];
char drive[_MAX_DRIVE];
@@ -6036,9 +6042,8 @@
}
if(filename)
{
- strupr(filename);
_splitpath(filename,drive,dir,name,ext);
- if(ext[0]=='\0') strcpy(ext,".HLP");
+ if(ext[0]=='\0') strcpy(ext,".hlp");
mvp=ext[1]=='M';
_makepath(HelpFileName,drive,dir,name,ext);
f=fopen(HelpFileName,"rb");
@@ -6046,7 +6051,7 @@
{
if(annotate)
{
- if(AnnoFileName[0]=='\0') _makepath(AnnoFileName,drive,dir,name,".ANN");
+ if(AnnoFileName[0]=='\0') _makepath(AnnoFileName,drive,dir,name,".ann");
AnnoFile=fopen(AnnoFileName,"rb");
if(!AnnoFile)
{
@@ -6096,7 +6101,6 @@
"work like the original. This program is Freeware. Use at your own risk. No\n"
"part of it may be used commercially. No fees may be charged on distributing.\n"
#ifndef _WIN32
- "Launch from Windows 95/Windows NT command line to handle larger helpfiles."
#endif
,sizeof(int)*8);
}
|