1996-05-06 18:06:24 +02:00
|
|
|
|
/*
|
|
|
|
|
* Copyright 1996 Ulrich Schmid
|
2002-03-10 00:29:33 +01:00
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1996-05-06 18:06:24 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <fcntl.h>
|
2002-07-16 03:46:29 +02:00
|
|
|
|
#include <assert.h>
|
1996-05-06 18:06:24 +02:00
|
|
|
|
#include "windows.h"
|
|
|
|
|
#include "hlpfile.h"
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
2002-07-16 03:46:29 +02:00
|
|
|
|
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;
|
1996-05-06 18:06:24 +02:00
|
|
|
|
} FORMAT;
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
2002-07-16 03:46:29 +02:00
|
|
|
|
const char ch;
|
|
|
|
|
const char *subst;
|
2002-08-30 02:01:37 +02:00
|
|
|
|
} CHARMAP_ENTRY;
|
1996-05-06 18:06:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FORMAT format =
|
|
|
|
|
{
|
2002-07-16 03:46:29 +02:00
|
|
|
|
"<!doctype linuxdoc system>\n"
|
|
|
|
|
"<article>\n"
|
|
|
|
|
"<title>\n",
|
1996-05-06 18:06:24 +02:00
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
"\n<author>\n%s\n"
|
|
|
|
|
"<date>\n%s\n",
|
1996-05-06 18:06:24 +02:00
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
"\n<sect>\n",
|
|
|
|
|
"\n<p>\n",
|
|
|
|
|
"\n<newline>\n",
|
|
|
|
|
"\n\n",
|
1996-05-06 18:06:24 +02:00
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
"&%s;",
|
1996-05-06 18:06:24 +02:00
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
"<em>",
|
|
|
|
|
"</em>",
|
|
|
|
|
"<bf>",
|
|
|
|
|
"</bf>",
|
|
|
|
|
"<tt>",
|
|
|
|
|
"</tt>",
|
1996-05-06 18:06:24 +02:00
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
"\n</article>\n"
|
1996-05-06 18:06:24 +02:00
|
|
|
|
};
|
|
|
|
|
|
2002-08-30 02:01:37 +02:00
|
|
|
|
CHARMAP_ENTRY charmap[] =
|
2002-07-16 03:46:29 +02:00
|
|
|
|
{{'<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"},
|
1996-05-06 18:06:24 +02:00
|
|
|
|
#if 0
|
2002-07-16 03:46:29 +02:00
|
|
|
|
{'(', "lpar"},
|
|
|
|
|
{')', "rpar"},
|
|
|
|
|
{'*', "ast"},
|
|
|
|
|
{'+', "plus"},
|
|
|
|
|
{',', "comma"},
|
|
|
|
|
{'-', "hyphen"},
|
|
|
|
|
{':', "colon"},
|
|
|
|
|
{';', "semi"},
|
|
|
|
|
{'=', "equals"},
|
|
|
|
|
{'@', "commat"},
|
|
|
|
|
{'[', "lsqb"},
|
|
|
|
|
{']', "rsqb"},
|
|
|
|
|
{'^', "circ"},
|
|
|
|
|
{'_', "lowbar"},
|
|
|
|
|
{'{', "lcub"},
|
|
|
|
|
{'|', "verbar"},
|
|
|
|
|
{'}', "rcub"},
|
|
|
|
|
{'~', "tilde"},
|
1996-05-06 18:06:24 +02:00
|
|
|
|
#endif
|
2002-07-16 03:46:29 +02:00
|
|
|
|
{'\\', "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}};
|
1996-05-06 18:06:24 +02:00
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
*
|
|
|
|
|
* print_text
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static void print_text(const char *p)
|
|
|
|
|
{
|
2002-07-16 03:46:29 +02:00
|
|
|
|
int i;
|
1996-05-06 18:06:24 +02:00
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
for (; *p; p++)
|
1996-05-06 18:06:24 +02:00
|
|
|
|
{
|
2002-07-16 03:46:29 +02:00
|
|
|
|
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);
|
1996-05-06 18:06:24 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
*
|
|
|
|
|
* main
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
|
{
|
2002-07-16 03:46:29 +02:00
|
|
|
|
HLPFILE *hlpfile;
|
|
|
|
|
HLPFILE_PAGE *page;
|
|
|
|
|
HLPFILE_PARAGRAPH *paragraph;
|
|
|
|
|
time_t t;
|
|
|
|
|
char date[50];
|
|
|
|
|
char *filename;
|
1996-05-06 18:06:24 +02:00
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
hlpfile = HLPFILE_ReadHlpFile(argc > 1 ? argv[1] : "");
|
1996-05-06 18:06:24 +02:00
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
if (!hlpfile) return 2;
|
1996-05-06 18:06:24 +02:00
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
time(&t);
|
|
|
|
|
strftime(date, sizeof(date), "%x", localtime(&t));
|
|
|
|
|
filename = strrchr(hlpfile->lpszPath, '/');
|
|
|
|
|
if (filename) filename++;
|
|
|
|
|
else filename = hlpfile->lpszPath;
|
1996-05-06 18:06:24 +02:00
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
/* Header */
|
|
|
|
|
printf(format.header1);
|
|
|
|
|
print_text(hlpfile->lpszTitle);
|
|
|
|
|
printf(format.header2, filename, date);
|
1996-05-06 18:06:24 +02:00
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
for (page = hlpfile->first_page; page; page = page->next)
|
1996-05-06 18:06:24 +02:00
|
|
|
|
{
|
2002-07-16 03:46:29 +02:00
|
|
|
|
paragraph = page->first_paragraph;
|
|
|
|
|
if (!paragraph) continue;
|
1996-05-06 18:06:24 +02:00
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
/* Section */
|
|
|
|
|
printf(format.section);
|
|
|
|
|
for (; paragraph && !paragraph->u.text.wVSpace; paragraph = paragraph->next)
|
|
|
|
|
print_text(paragraph->u.text.lpszText);
|
|
|
|
|
printf(format.first_paragraph);
|
1996-05-06 18:06:24 +02:00
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
for (; paragraph; paragraph = paragraph->next)
|
1996-05-06 18:06:24 +02:00
|
|
|
|
{
|
2002-07-16 03:46:29 +02:00
|
|
|
|
switch (paragraph->cookie)
|
|
|
|
|
{
|
|
|
|
|
case para_normal_text:
|
|
|
|
|
case para_debug_text:
|
|
|
|
|
/* New line; new paragraph */
|
|
|
|
|
if (paragraph->u.text.wVSpace == 1)
|
|
|
|
|
printf(format.newline);
|
|
|
|
|
else if (paragraph->u.text.wVSpace > 1)
|
|
|
|
|
printf(format.next_paragraph);
|
|
|
|
|
|
|
|
|
|
if (paragraph->u.text.wFont)
|
|
|
|
|
printf(format.begin_boldface);
|
|
|
|
|
|
|
|
|
|
print_text(paragraph->u.text.lpszText);
|
|
|
|
|
|
|
|
|
|
if (paragraph->u.text.wFont)
|
|
|
|
|
printf(format.end_boldface);
|
|
|
|
|
break;
|
|
|
|
|
case para_image:
|
|
|
|
|
break;
|
|
|
|
|
}
|
1996-05-06 18:06:24 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
printf(format.tail);
|
1996-05-06 18:06:24 +02:00
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
return 0;
|
1996-05-06 18:06:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
{
|
2002-07-16 03:46:29 +02:00
|
|
|
|
file = *path ? fopen(path, "r") : stdin;
|
|
|
|
|
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
|
|
|
|
{
|
2002-07-16 03:46:29 +02:00
|
|
|
|
fclose(file);
|
|
|
|
|
return 0;
|
1996-05-06 18:06:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
{
|
2002-07-16 03:46:29 +02:00
|
|
|
|
return fread(buffer, 1, count, file);
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-17 20:29:12 +02:00
|
|
|
|
HANDLE WINAPI GetProcessHeap(void)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
void* WINAPI HeapAlloc( HANDLE heap, DWORD flags, DWORD size )
|
|
|
|
|
{
|
|
|
|
|
assert(flags == 0);
|
|
|
|
|
return malloc(size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void* WINAPI HeapReAlloc( HANDLE heap, DWORD flags, void* ptr, DWORD size)
|
|
|
|
|
{
|
|
|
|
|
assert(flags == 0);
|
|
|
|
|
return realloc(ptr, size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BOOL WINAPI HeapFree( HGLOBAL handle, DWORD flags, void* ptr )
|
|
|
|
|
{
|
|
|
|
|
free(ptr);
|
|
|
|
|
return TRUE;
|
1996-05-06 18:06:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
char __wine_dbch_winhelp[] = "\003winhelp";
|
|
|
|
|
|
|
|
|
|
static char * const debug_channels[1] =
|
|
|
|
|
{
|
|
|
|
|
__wine_dbch_winhelp
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int wine_dbg_log( int cls, const char *channel, const char *func, const char *format, ... )
|
1996-05-06 18:06:24 +02:00
|
|
|
|
{
|
2002-07-16 03:46:29 +02:00
|
|
|
|
return 1;
|
1996-05-06 18:06:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
HBITMAP WINAPI CreateDIBitmap(HDC hdc, CONST BITMAPINFOHEADER* bih, DWORD a, CONST void* ptr, CONST BITMAPINFO* bi, UINT c)
|
1996-05-06 18:06:24 +02:00
|
|
|
|
{
|
2002-07-16 03:46:29 +02:00
|
|
|
|
return 0;
|
1996-05-06 18:06:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
HDC WINAPI GetDC(HWND h)
|
1996-05-06 18:06:24 +02:00
|
|
|
|
{
|
2002-07-16 03:46:29 +02:00
|
|
|
|
return 0;
|
1996-05-06 18:06:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
BOOL WINAPI DeleteObject(HGDIOBJ h)
|
|
|
|
|
{
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
1996-05-06 18:06:24 +02:00
|
|
|
|
/*
|
|
|
|
|
* String functions
|
|
|
|
|
*
|
|
|
|
|
* Copyright 1993 Yngvi Sigurjonsson (yngvi@hafro.is)
|
|
|
|
|
*/
|
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
INT WINAPI lstrcmp( LPCSTR str1, LPCSTR str2 )
|
1996-05-06 18:06:24 +02:00
|
|
|
|
{
|
2002-07-16 03:46:29 +02:00
|
|
|
|
return strcmp( str1, str2 );
|
1996-05-06 18:06:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
1999-01-30 14:06:00 +01:00
|
|
|
|
INT WINAPI lstrcmpi( LPCSTR str1, LPCSTR str2 )
|
1996-05-06 18:06:24 +02:00
|
|
|
|
{
|
2002-07-16 03:46:29 +02:00
|
|
|
|
INT res;
|
1996-05-06 18:06:24 +02:00
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
while (*str1)
|
1996-05-06 18:06:24 +02:00
|
|
|
|
{
|
2002-07-16 03:46:29 +02:00
|
|
|
|
if ((res = toupper(*str1) - toupper(*str2)) != 0) return res;
|
|
|
|
|
str1++;
|
|
|
|
|
str2++;
|
1996-05-06 18:06:24 +02:00
|
|
|
|
}
|
2002-07-16 03:46:29 +02:00
|
|
|
|
return toupper(*str1) - toupper(*str2);
|
1996-05-06 18:06:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
2002-07-16 03:46:29 +02:00
|
|
|
|
INT WINAPI lstrlen( LPCSTR str )
|
1996-05-06 18:06:24 +02:00
|
|
|
|
{
|
2002-07-16 03:46:29 +02:00
|
|
|
|
return strlen(str);
|
1996-05-06 18:06:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
}
|