1996-05-06 18:06:24 +02:00
|
|
|
|
/*
|
|
|
|
|
* Copyright 1996 Ulrich Schmid
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include "windows.h"
|
|
|
|
|
#include "hlpfile.h"
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
const char *header1;
|
|
|
|
|
const char *header2;
|
|
|
|
|
const char *section;
|
|
|
|
|
const char *first_paragraph;
|
|
|
|
|
const char *newline;
|
|
|
|
|
const char *next_paragraph;
|
|
|
|
|
const char *special_char;
|
|
|
|
|
const char *begin_italic;
|
|
|
|
|
const char *end_italic;
|
|
|
|
|
const char *begin_boldface;
|
|
|
|
|
const char *end_boldface;
|
|
|
|
|
const char *begin_typewriter;
|
|
|
|
|
const char *end_typewriter;
|
|
|
|
|
const char *tail;
|
|
|
|
|
} FORMAT;
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
const char ch;
|
|
|
|
|
const char *subst;
|
|
|
|
|
} CHARMAP[];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FORMAT format =
|
|
|
|
|
{
|
|
|
|
|
"<!doctype linuxdoc system>\n"
|
|
|
|
|
"<article>\n"
|
|
|
|
|
"<title>\n",
|
|
|
|
|
|
|
|
|
|
"\n<author>\n%s\n"
|
|
|
|
|
"<date>\n%s\n",
|
|
|
|
|
|
|
|
|
|
"\n<sect>\n",
|
|
|
|
|
"\n<p>\n",
|
|
|
|
|
"\n<newline>\n",
|
|
|
|
|
"\n\n",
|
|
|
|
|
|
|
|
|
|
"&%s;",
|
|
|
|
|
|
|
|
|
|
"<em>",
|
|
|
|
|
"</em>",
|
|
|
|
|
"<bf>",
|
|
|
|
|
"</bf>",
|
|
|
|
|
"<tt>",
|
|
|
|
|
"</tt>",
|
|
|
|
|
|
|
|
|
|
"\n</article>\n"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
CHARMAP charmap =
|
|
|
|
|
{{'<EFBFBD>', "AElig"},
|
|
|
|
|
{'<EFBFBD>', "Aacute"},
|
|
|
|
|
{'<EFBFBD>', "Acirc"},
|
|
|
|
|
{'<EFBFBD>', "Agrave"},
|
|
|
|
|
{'<EFBFBD>', "Atilde"},
|
|
|
|
|
{'<EFBFBD>', "Ccedil"},
|
|
|
|
|
{'<EFBFBD>', "Eacute"},
|
|
|
|
|
{'<EFBFBD>', "Egrave"},
|
|
|
|
|
{'<EFBFBD>', "Euml"},
|
|
|
|
|
{'<EFBFBD>', "Iacute"},
|
|
|
|
|
{'<EFBFBD>', "Icirc"},
|
|
|
|
|
{'<EFBFBD>', "Igrave"},
|
|
|
|
|
{'<EFBFBD>', "Iuml"},
|
|
|
|
|
{'<EFBFBD>', "Ntilde"},
|
|
|
|
|
{'<EFBFBD>', "Oacute"},
|
|
|
|
|
{'<EFBFBD>', "Ocirc"},
|
|
|
|
|
{'<EFBFBD>', "Ograve"},
|
|
|
|
|
{'<EFBFBD>', "Oslash"},
|
|
|
|
|
{'<EFBFBD>', "Uacute"},
|
|
|
|
|
{'<EFBFBD>', "Ugrave"},
|
|
|
|
|
{'<EFBFBD>', "Yacute"},
|
|
|
|
|
{'<EFBFBD>', "aacute"},
|
|
|
|
|
{'<EFBFBD>', "acirc"},
|
|
|
|
|
{'<EFBFBD>', "aelig"},
|
|
|
|
|
{'<EFBFBD>', "agrave"},
|
|
|
|
|
{'<EFBFBD>', "aring"},
|
|
|
|
|
{'<EFBFBD>', "atilde"},
|
|
|
|
|
{'<EFBFBD>', "ccedil"},
|
|
|
|
|
{'<EFBFBD>', "eacute"},
|
|
|
|
|
{'<EFBFBD>', "ecirc"},
|
|
|
|
|
{'<EFBFBD>', "egrave"},
|
|
|
|
|
{'<EFBFBD>', "euml"},
|
|
|
|
|
{'<EFBFBD>', "iacute"},
|
|
|
|
|
{'<EFBFBD>', "icirc"},
|
|
|
|
|
{'<EFBFBD>', "igrave"},
|
|
|
|
|
{'<EFBFBD>', "iuml"},
|
|
|
|
|
{'<EFBFBD>', "ntilde"},
|
|
|
|
|
{'<EFBFBD>', "oacute"},
|
|
|
|
|
{'<EFBFBD>', "yuml"},
|
|
|
|
|
{'<EFBFBD>', "ocirc"},
|
|
|
|
|
{'<EFBFBD>', "ograve"},
|
|
|
|
|
{'<EFBFBD>', "oslash"},
|
|
|
|
|
{'<EFBFBD>', "otilde"},
|
|
|
|
|
{'<EFBFBD>', "uacute"},
|
|
|
|
|
{'<EFBFBD>', "ucirc"},
|
|
|
|
|
{'<EFBFBD>', "ugrave"},
|
|
|
|
|
{'<EFBFBD>', "yacute"},
|
|
|
|
|
{'<', "lt"},
|
|
|
|
|
{'&', "amp"},
|
|
|
|
|
{'"', "dquot"},
|
|
|
|
|
{'#', "num"},
|
|
|
|
|
{'%', "percnt"},
|
|
|
|
|
{'\'', "quot"},
|
|
|
|
|
#if 0
|
|
|
|
|
{'(', "lpar"},
|
|
|
|
|
{')', "rpar"},
|
|
|
|
|
{'*', "ast"},
|
|
|
|
|
{'+', "plus"},
|
|
|
|
|
{',', "comma"},
|
|
|
|
|
{'-', "hyphen"},
|
|
|
|
|
{':', "colon"},
|
|
|
|
|
{';', "semi"},
|
|
|
|
|
{'=', "equals"},
|
|
|
|
|
{'@', "commat"},
|
|
|
|
|
{'[', "lsqb"},
|
|
|
|
|
{']', "rsqb"},
|
|
|
|
|
{'^', "circ"},
|
|
|
|
|
{'_', "lowbar"},
|
|
|
|
|
{'{', "lcub"},
|
|
|
|
|
{'|', "verbar"},
|
|
|
|
|
{'}', "rcub"},
|
|
|
|
|
{'~', "tilde"},
|
|
|
|
|
#endif
|
|
|
|
|
{'\\', "bsol"},
|
|
|
|
|
{'$', "dollar"},
|
|
|
|
|
{'<EFBFBD>', "Auml"},
|
|
|
|
|
{'<EFBFBD>', "auml"},
|
|
|
|
|
{'<EFBFBD>', "Ouml"},
|
|
|
|
|
{'<EFBFBD>', "ouml"},
|
|
|
|
|
{'<EFBFBD>', "Uuml"},
|
|
|
|
|
{'<EFBFBD>', "uuml"},
|
|
|
|
|
{'<EFBFBD>', "szlig"},
|
|
|
|
|
{'>', "gt"},
|
|
|
|
|
{'<EFBFBD>', "sect"},
|
|
|
|
|
{'<EFBFBD>', "para"},
|
|
|
|
|
{'<EFBFBD>', "copy"},
|
|
|
|
|
{'<EFBFBD>', "iexcl"},
|
|
|
|
|
{'<EFBFBD>', "iquest"},
|
|
|
|
|
{'<EFBFBD>', "cent"},
|
|
|
|
|
{'<EFBFBD>', "pound"},
|
|
|
|
|
{'<EFBFBD>', "times"},
|
|
|
|
|
{'<EFBFBD>', "plusmn"},
|
|
|
|
|
{'<EFBFBD>', "divide"},
|
|
|
|
|
{'<EFBFBD>', "not"},
|
|
|
|
|
{'<EFBFBD>', "mu"},
|
|
|
|
|
{0,0}};
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
*
|
|
|
|
|
* print_text
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static void print_text(const char *p)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (; *p; p++)
|
|
|
|
|
{
|
|
|
|
|
for (i = 0; charmap[i].ch; i++)
|
|
|
|
|
if (*p == charmap[i].ch)
|
|
|
|
|
{
|
|
|
|
|
printf(format.special_char, charmap[i].subst);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (!charmap[i].ch)
|
|
|
|
|
printf("%c", *p);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
*
|
|
|
|
|
* main
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
|
{
|
|
|
|
|
HLPFILE *hlpfile;
|
|
|
|
|
HLPFILE_PAGE *page;
|
|
|
|
|
HLPFILE_PARAGRAPH *paragraph;
|
|
|
|
|
time_t t;
|
|
|
|
|
char date[50];
|
|
|
|
|
char *filename;
|
|
|
|
|
|
|
|
|
|
hlpfile = HLPFILE_ReadHlpFile(argc > 1 ? argv[1] : "");
|
|
|
|
|
|
|
|
|
|
if (!hlpfile) return(2);
|
|
|
|
|
|
|
|
|
|
time(&t);
|
|
|
|
|
strftime(date, sizeof(date), "%x", localtime(&t));
|
|
|
|
|
filename = strrchr(hlpfile->lpszPath, '/');
|
|
|
|
|
if (filename) filename++;
|
|
|
|
|
else filename = hlpfile->lpszPath;
|
|
|
|
|
|
|
|
|
|
/* Header */
|
|
|
|
|
printf(format.header1);
|
|
|
|
|
print_text(hlpfile->lpszTitle);
|
|
|
|
|
printf(format.header2, filename, date);
|
|
|
|
|
|
|
|
|
|
for (page = hlpfile->first_page; page; page = page->next)
|
|
|
|
|
{
|
|
|
|
|
paragraph = page->first_paragraph;
|
|
|
|
|
if (!paragraph) continue;
|
|
|
|
|
|
|
|
|
|
/* Section */
|
|
|
|
|
printf(format.section);
|
|
|
|
|
for (; paragraph && !paragraph->wVSpace; paragraph = paragraph->next)
|
|
|
|
|
print_text(paragraph->lpszText);
|
|
|
|
|
printf(format.first_paragraph);
|
|
|
|
|
|
|
|
|
|
for (; paragraph; paragraph = paragraph->next)
|
|
|
|
|
{
|
|
|
|
|
/* New line; new paragraph */
|
|
|
|
|
if (paragraph->wVSpace == 1)
|
|
|
|
|
printf(format.newline);
|
|
|
|
|
else if (paragraph->wVSpace > 1)
|
|
|
|
|
printf(format.next_paragraph);
|
|
|
|
|
|
|
|
|
|
if (paragraph->wFont)
|
|
|
|
|
printf(format.begin_boldface);
|
|
|
|
|
|
|
|
|
|
print_text(paragraph->lpszText);
|
|
|
|
|
|
|
|
|
|
if (paragraph->wFont)
|
|
|
|
|
printf(format.end_boldface);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf(format.tail);
|
|
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
*
|
|
|
|
|
* Substitutions for some WINELIB functions
|
|
|
|
|
*/
|
|
|
|
|
|
1996-05-21 17:01:41 +02:00
|
|
|
|
static FILE *file = 0;
|
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
|
HFILE WINAPI OpenFile( LPCSTR path, OFSTRUCT *ofs, UINT mode )
|
1996-05-06 18:06:24 +02:00
|
|
|
|
{
|
1996-05-21 17:01:41 +02:00
|
|
|
|
file = *path ? fopen(path, "r") : stdin;
|
2000-07-23 21:33:42 +02:00
|
|
|
|
return file ? (HFILE)1 : HFILE_ERROR;
|
1996-05-06 18:06:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
|
HFILE WINAPI _lclose( HFILE hFile )
|
1996-05-06 18:06:24 +02:00
|
|
|
|
{
|
1996-05-21 17:01:41 +02:00
|
|
|
|
fclose(file);
|
1996-05-06 18:06:24 +02:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
|
LONG WINAPI _hread( HFILE hFile, LPVOID buffer, LONG count )
|
1996-05-06 18:06:24 +02:00
|
|
|
|
{
|
1996-05-21 17:01:41 +02:00
|
|
|
|
return fread(buffer, 1, count, file);
|
1996-05-06 18:06:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
1999-01-30 14:06:00 +01:00
|
|
|
|
HGLOBAL WINAPI GlobalAlloc( UINT flags, DWORD size )
|
1996-05-06 18:06:24 +02:00
|
|
|
|
{
|
|
|
|
|
return (HGLOBAL) malloc(size);
|
|
|
|
|
}
|
|
|
|
|
|
1999-01-30 14:06:00 +01:00
|
|
|
|
LPVOID WINAPI GlobalLock( HGLOBAL handle )
|
1996-05-06 18:06:24 +02:00
|
|
|
|
{
|
|
|
|
|
return (LPVOID) handle;
|
|
|
|
|
}
|
|
|
|
|
|
1999-01-30 14:06:00 +01:00
|
|
|
|
HGLOBAL WINAPI GlobalFree( HGLOBAL handle )
|
1996-05-06 18:06:24 +02:00
|
|
|
|
{
|
|
|
|
|
free((VOID*) handle);
|
|
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* String functions
|
|
|
|
|
*
|
|
|
|
|
* Copyright 1993 Yngvi Sigurjonsson (yngvi@hafro.is)
|
|
|
|
|
*/
|
|
|
|
|
|
1999-01-30 14:06:00 +01:00
|
|
|
|
INT WINAPI lstrcmp(LPCSTR str1,LPCSTR str2)
|
1996-05-06 18:06:24 +02:00
|
|
|
|
{
|
|
|
|
|
return strcmp( str1, str2 );
|
|
|
|
|
}
|
|
|
|
|
|
1999-01-30 14:06:00 +01:00
|
|
|
|
INT WINAPI lstrcmpi( LPCSTR str1, LPCSTR str2 )
|
1996-05-06 18:06:24 +02:00
|
|
|
|
{
|
|
|
|
|
INT res;
|
|
|
|
|
|
|
|
|
|
while (*str1)
|
|
|
|
|
{
|
|
|
|
|
if ((res = toupper(*str1) - toupper(*str2)) != 0) return res;
|
|
|
|
|
str1++;
|
|
|
|
|
str2++;
|
|
|
|
|
}
|
|
|
|
|
return toupper(*str1) - toupper(*str2);
|
|
|
|
|
}
|
|
|
|
|
|
1999-01-30 14:06:00 +01:00
|
|
|
|
INT WINAPI lstrlen(LPCSTR str)
|
1996-05-06 18:06:24 +02:00
|
|
|
|
{
|
|
|
|
|
return strlen(str);
|
|
|
|
|
}
|
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
|
LPSTR WINAPI lstrcpyA( LPSTR dst, LPCSTR src )
|
1996-05-06 18:06:24 +02:00
|
|
|
|
{
|
1996-07-17 22:02:21 +02:00
|
|
|
|
if (!src || !dst) return NULL;
|
|
|
|
|
strcpy( dst, src );
|
|
|
|
|
return dst;
|
1996-05-06 18:06:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
|
void WINAPI hmemcpy16(LPVOID hpvDest, LPCVOID hpvSource, LONG cbCopy)
|
1996-05-06 18:06:24 +02:00
|
|
|
|
{
|
|
|
|
|
memcpy(hpvDest, hpvSource, cbCopy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Local Variables: */
|
|
|
|
|
/* c-file-style: "GNU" */
|
|
|
|
|
/* End: */
|