Sweden-Number/programs/winhelp/hlp2sgml.c

334 lines
5.9 KiB
C
Raw Normal View History

Release 960506 Mon May 6 12:56:26 1996 Alexandre Julliard <julliard@lrc.epfl.ch> * [DEVELOPERS-HINTS] Added paragraph on naming conventions for Win16/Win32/Winelib. * [controls/menu.c] Create a default system menu that is the same for all windows instead of making a copy every time. * [include/wintypes.h] Added WINELIB_NAME and DECL_WINELIB_TYPE macros. Added xx16 and xx32 definitions for most types. General clean-up. * [memory/global.c] [memory/local.c] [*/*] Renamed Global and Local heap functions to xxx16. Added all xxx32 versions of the same functions. * [memory/selector.c] Mask out lower bits of selector in FreeSelector(). * [misc/lstr.c] Fixed wvsprintf(). * [windows/class.c] Changed the class structure to make Win32 support easier. * [windows/defwnd.c] Added handling of WM_INITMENUPOPUP for system menu to gray out invalid options. * [windows/winpos.c] Bug fix: the WINDOSPOS structure pointer in WM_NCCALCSIZE must be a SEGPTR. Sun May 5 03:51:26 1996 Huw D. M. Davies <h.davies1@physics.oxford.ac.uk> * [memory/local.c] Implementation of moveable and (rudimentary) support for discardable local memory, plus several bug fixes. Sat May 4 18:33:35 1996 Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de> * [include/windows.h] [windows/win.c] [if1632/user.spec] FindWindowEx() implemented (someone reported it was missing for FrameMaker 4.1). * [if1632/kernel32.spec] [if1632/user32.spec] [win32/memory.c] [win32/resource.c] Misc small stubs/small functions which bring win95 binaries further down the road. (IsBadCodePtr, LocalReAlloc,GetCursorPos) Small fix in WIN32_LoadAcceleratorsA. Fri May 3 19:43:12 1996 Frans van Dorsselaer <dorssel@rulhm1.LeidenUniv.nl> * [controls/edit.c] [controls/EDIT.TODO] Changed / fixed some types and typecasts. Fixed the scrollbar reset after WM_SETHANDLE / WM_SETTEXT. Added heap initialization in WM_CREATE. Fri May 3 19:30:02 1996 Greg Kreider <kreider@natlab.research.philips.com> * [controls/combo.c] [controls/listbox.c] Pass WM_[HV]SCROLL to listbox, but not combo. Don't try to redraw non-existant scroll bars (changes dwStyle flags). Combo box gets border. Combo box includes button (otherwise button won't trigger dropdown). Proper border around RectButton. Check size consistancy of combo, listbox, and button after resizing or before painting. These routines still aren't completely correct. Localize size checks in separate routines. Listboxes are white. Thu May 2 19:21:23 1996 Albrecht Kleine <kleine@ak.sax.de> * [controls/combo.c][include/commdlg.h][include/commdlg.c] [resources/sysres_De.rc][resources/sysres_En.rc] Introduced ChooseFont dialog, but needed some patches in handling of comboboxes with edit controls. Tue Apr 30 00:33:27 1996 Ulrich Schmid <uschmid@mail.hh.provi.de> * [programs/winhelp/*] Added a help viewer and a simple `.hlp' to `.sgml' converter. Mon Apr 29 14:17:57 1996 Tristan Tarrant <tst@sthinc.demon.co.uk> * [resources/sysres_*.rc] [misc/shell.c] Modified size of "About" dialog boxes. Sat Apr 27 18:10:11 Martin von Loewis <loewis@informatik.hu-berlin.de> * [if1632/Makefile.in][loader/builtin.c] crtdll.spec, ntdll.spec, wsock32.spec: new files. * [loader/pe_image.c] Fix error message if import by ordinal failed.
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
*/
HFILE OpenFile( LPCSTR path, OFSTRUCT *ofs, UINT mode )
{
FILE *file;
if (!*path) return (HFILE) stdin;
file = fopen(path, "r");
if (!file) return HFILE_ERROR;
return (HFILE) file;
}
HFILE _lclose( HFILE hFile )
{
fclose((FILE*) hFile);
return 0;
}
LONG _hread( HFILE hFile, SEGPTR buffer, LONG count )
{
return fread(buffer, 1, count, (FILE*) hFile);
}
HGLOBAL GlobalAlloc( WORD flags, DWORD size )
{
return (HGLOBAL) malloc(size);
}
LPVOID GlobalLock( HGLOBAL handle )
{
return (LPVOID) handle;
}
HGLOBAL GlobalFree( HGLOBAL handle )
{
free((VOID*) handle);
return(0);
}
/*
* String functions
*
* Copyright 1993 Yngvi Sigurjonsson (yngvi@hafro.is)
*/
INT lstrcmp(LPCSTR str1,LPCSTR str2)
{
return strcmp( str1, str2 );
}
INT lstrcmpi( LPCSTR str1, LPCSTR str2 )
{
INT res;
while (*str1)
{
if ((res = toupper(*str1) - toupper(*str2)) != 0) return res;
str1++;
str2++;
}
return toupper(*str1) - toupper(*str2);
}
INT lstrlen(LPCSTR str)
{
return strlen(str);
}
SEGPTR lstrcpy( SEGPTR target, SEGPTR source )
{
strcpy( (char *)target, (char *)source );
return target;
}
void hmemcpy(LPVOID hpvDest, LPCVOID hpvSource, LONG cbCopy)
{
memcpy(hpvDest, hpvSource, cbCopy);
}
/* Local Variables: */
/* c-file-style: "GNU" */
/* End: */