meta,
C++
78 Methoden:
/* private: */ int Ut_htm_static :: check_htm
|
/* public: */ BOOL Ut_htm_static :: LeerZeile
/* public: */ BOOL Ut_htm_static :: mae_Umlaut
/* public: */ BOOL Ut_htm_static :: see_char
/* public: */ Ut_htm_static :: Ut_htm_static
/* public: */ char * Ut_htm_static :: ohne_secNr
/* public: */ char * Ut_htm_static :: clean
/* public: */ char * Ut_htm_static :: create_ufSurr
/* public: */ char * Ut_htm_static :: get_HText
/* public: */ char * Ut_htm_static :: skip_secNr
/* public: */ char * Ut_htm_static :: to_mae
/* public: */ char * Ut_htm_static :: trim
/* public: */ int Ut_htm_static :: check_htm_dir
/* public: */ int Ut_htm_static :: check_htm_file
/* public: */ static BOOL Ut_htm_static :: At_target_p
/* public: */ static char Ut_htm_static :: extract_pText
/* public: */ static char Ut_htm_static :: get_picName
/* public: */ static int Ut_htm_static :: word_to_htm
/* public: */ static int Ut_htm_static :: word_to_htm
/* public: */ static int Ut_htm_static :: word_to_htm
/* public: */ static void Ut_htm_static :: spalten_text
/* public: */ uint Ut_htm_static :: tage
/* public: */ uint Ut_htm_static :: unite
/* public: */ uint Ut_htm_static :: zeichAnz
/* public: */ void Ut_htm_static :: alias_for
/* public: */ void Ut_htm_static :: extract_htm
/* public: */ void Ut_htm_static :: norm_css
/* public: */ void Ut_htm_static :: add_toc
/* public: */ void Ut_htm_static :: check_nesting
/* public: */ void Ut_htm_static :: create_CSS
/* public: */ void Ut_htm_static :: erz_docstyles
/* public: */ void Ut_htm_static :: erz_j2hstyles
/* public: */ void Ut_htm_static :: escape_mae_to_htm
/* public: */ void Ut_htm_static :: escape_msHtm_to_htm
/* public: */ void Ut_htm_static :: escape_msHtm_to_htm
/* public: */ void Ut_htm_static :: get_hText_Lines
/* public: */ void Ut_htm_static :: mae_to_msHtm
/* public: */ void Ut_htm_static :: reduce_secNr
/* public: */ void Ut_htm_static :: skip_htm_space
#define static
#include ut_htmst.h : cpp
#include ut_htmst.c1 : cpp
#undef BB
#undef BBStr
#undef bb
#undef bbStr
#define BB
#define BBStr( x,y,z ) ;
#define bb
#define bbStr( x,y,z ) ;
#ifndef procNestOn
#undef LB_
#undef LE_
#undef LE_ret
#undef ret
#undef ret_
#undef __
#undef ___
#define LB_( x ) {
#define LE_ }
#define ret_ return ;
#define LE_ret( x ) return( x ); }
#define ret( x ) return( x );
#define __
#define ___
#endif
#define LB_( x ) { if ( *x == 'U' ) checkPoint = x ;
#define LB_( x ) { show_LB( 'U', x );
#define BB if ( call_nr == 0 )
#define bb if ( call_nr >= 0 )
#define __
#define __ { bb { printf( "\nLine %i", __LINE__ ); fflush(stdout); }}
#define LB_( x ) {
#define LB_( x ) { if ( *x == 'U' ) printf( "\n-> %s", x );
// #define LB_( x ) { bb printf( "\n-> %s", x );
/* public: */ Ut_htm_static :: Ut_htm_static (
// -----------------------------------------------------------------------------
)
{
auch_Umlaute = true ;
chapDepth = 0 ;
}
/* public: */ void Ut_htm_static :: check_ms_htm
/* -----------------------------------------------------------------------------
check nesting of section "<!... > ... <![endif>
-----------------------------------------------------------------------------
*/ (
char * pos
, char * htm
)
LB_("Ut_htm_static.check_ms_htm")
ret_
LE_
/* public: */ uint Ut_htm_static :: tage ( char * x
/* -----------------------------------------------------------------------------
ein Datum der Form: JJJJ.MM.TT
-----------------------------------------------------------------------------
*/ )
LB_("Ut_htm_static.tage")
if ( ! x || x[10] || digit( x[4] ) || digit( x[7] ) ) fErr1( x )
LE_ret( decNr( x ) * 365 + decNr( x+5 ) * 30 + decNr( x+8 ) )
/* public: */ char * Ut_htm_static :: ohne_secNr ( char * nam
// -----------------------------------------------------------------------------
)
LB_("Ut_htm_static.ohne_secNr")
char * k = nam ; while in_str( *k, ". 0123456789" ) k++ ;
while ( nam < k && not_space( k[-1] ) ) k-- ;
LE_ret( k )
/* public: */ void Ut_htm_static :: norm_css ( char * css
// -----------------------------------------------------------------------------
)
LB_("Ut_htm_static.norm_css")
char1000 st ;
rBuffer B( css, "" ); FILE * f = create( css ); FILE * ff = 0 ;
while ( B.find( 0, "/*?-", ff ) )
{
rB_( B, 4, "*/", 0 ); B.a += 2 ; ff = f ;
char * ee = B.z + B.e ;
char * c = B.z + B.a ;
char * e = st ;
BOOL stfound = false ;
while ( *c != '}' )
{
if space( *c )
then {
skip_space( c ) *e++ = ' ' ;
}
esif ( *c == '{' )
{
stfound = true ;
s_( e, " {\n" ); e = eos(e);
while ( not_in_name( *c ) && *c != '}' ) c++ ;
}
esif At( c, "/*" )
{
while not_At( c , "*/" ) c++ ; c += 2 ;
}
esif ( At( c, "color" )
|| At( c, "margin-" ) // c[7] != 'l' // muss sein
|| At( c, "mso-" )
|| At( c, "page-break" )
|| At( c, "font-size" )
|| At( c, "page:" )
||( At( c, "text-" ) && not_At( c, "text-indent" )
&& not_At( c, "text-align:ce" ) )
)
{
to_( c, ';' ) while ( *c == ';' ) c++ ;
}
esif At( c, "display:none" )
{
char * x = c ; while ( *x != '{' ) x-- ;
char100 none ;
while space( *( --x ) ); char * x2 = x+1 ;
while not_space( *( --x ) ); char * x1 = x+1 ;
memcpy( none, x1, x2-x1 );
strcpy( none + ( x2-x1), " " ); //_1( none )
to_( c, '}' )
}
esif At( c, ";;" ) c++ ;
esif ( *c == '}' ) break ;
else {
*e++ = *c++ ; if ( e[-1] == ',' ) *e++ = ' ' ;
}
if ( ee <= c ) break ; // for robustness
}
B.a = c - B.z ;
if ( stfound )
then {
strcpy( e, "font-size:10pt;\n" ); fprintf( f, st );
}
}
erz_docstyles( f );
close( f );
LE_
/* public: */ uint Ut_htm_static :: unite
/* -----------------------------------------------------------------------------
Let dir/pre.htm become the union of all files dir/pre_*.htm
-----------------------------------------------------------------------------
*/ (
char * dir
, char * pre
, char * ext
)
LB_("Ut_htm_static.unite")
if ( ! dir ) fErr
if ( ! pre ) fErr
char800 doc ; char * e1 ;
if is_( eos( dir ) - 7, "publish" )
then {
strcpy( doc, dir ); e1 = eos( doc ) - 7 ;
}
else ext = 0 ;
if not_is_dir( dir ) fErr1( dir )
uint anz = 0 ;
char800 nam ; s_( nam, "%s/", dir );
char * e = eos( nam );
rBuffer B ; str_set such ;
s_( e, "%s.htm", pre ); FILE * f = create( nam );
char * summe = such.take( nam );
char100 see ; s_( see, "%s/%s_*.htm", dir, pre ); dos_me( see );
_finddata_t dta ; int h = _findfirst( see, &dta );
while ( ! errno )
{
if ( ext )
then {
s_( e1, "%s", dta.name );
s_( eos( doc ) - 4, ".%s", ext );
if not_is_file( doc )
{
printf( "\nerror: document not found: %s", doc ); fErr
//
}
}
strcpy( e, dta.name ); B.open_rBuffer( nam, "" );
if ( ++anz == 1 )
then {
such.insert( "</body>" );
such.insert( "</BODY>" );
such.insert( "</Body>" );
B.find( 0, such, f );
such.insert( "<b" );
such.insert( "<B" );
}
else {
FILE * ff = 0 ;
while ( B.find( 1, such, ff ) )
{
if ( B.z[ B.a+1 ] == '/' ) break ; else ff = f ;
}
}
char * ee = eos( nam ) - 4 ; *ee = 0 ;
s_( ee, "_files" );
if is_dir( nam )
{
S_ "copy \"%s/*\" \"%s/%s_files\" > NUL", nam, dir, pre _Do
}
s_( ee, "_Dateien" );
if is_dir( nam )
{
S_ "copy \"%s/*\" \"%s/%s_Dateien\"", nam, dir, pre _Do
}
_findnext( h, &dta );
}
_findclose( h ); fprintf( f, "\n</body></html>\n" );
close( f );
if ( anz )
then {
printf( "\nok: %i documents united to %s\n", anz, summe );
if ( ext )
{
s_( e1, "%s.sum", pre ); f = create( doc ); close( f );
}
}
else {
printf( "\nW a r n i n g : There are no files %s/%s_*.htm\n", dir, pre );
Unlink( summe )
}
LE_ret( anz )
/* public: */ int Ut_htm_static :: check_htm_file ( char * htm
/* -----------------------------------------------------------------------------
Check whether all referred to files exist
Return the number of targets that do not exist.
-----------------------------------------------------------------------------
*/ )
LB_("Ut_htm_static.check_htm_file")
if ( ! htm ) fErr
printf( "\nCheck for broken links: %s\n", htm );
char * tmp = "tmp_check_htm_file" ; FILE * f = create( tmp );
fprintf( f, "\n%s\n", htm );
close( f );
int errors = check_htm( tmp, 0, 0 ); Unlink( tmp )
LE_ret( errors )
/* public: */ int Ut_htm_static :: check_htm_dir
/* -----------------------------------------------------------------------------
For each *.htm in the 'tree
Check whether all referred to files exist
Return the number of targets that do not exist.
-----------------------------------------------------------------------------
*/ (
char * tree
, char * wdes // web descriptor file name or 0
, time_t startTime
)
LB_("Ut_htm_static.check_htm_dir")
___
if ( ! tree || ! *tree ) fErr
if not_is_dir( tree ) fErr1( tree )
printf( "\nCheck for broken links: %s/*.htm\n", tree );
char * tmp = "check_htm_dir.tmp" ;
wfind( 0, tmp, tree );
int anz = check_htm( tmp, wdes, startTime );
Unlink( tmp )
LE_ret( anz )
/* private: */ int Ut_htm_static :: check_htm
/* -----------------------------------------------------------------------------
For each *.htm named in 'htm
Check whether all referred to files exist
Return the number of targets that do not exist.
-----------------------------------------------------------------------------
*/ (
char * files
, char * wdes
, time_t startTime
)
LB_("Ut_htm_static.check_htm")
_1( files )
Btree miss ;
unsigned long anzPages = 0 ;
unsigned long anz1 = 0 ;
unsigned long anz2 = 0 ;
rBuffer C ; rBuffer B( files, "" );
// while ( B.find( 1, ".htm", 0 ) )
while ( B.find( 1, ".", 0 ) )
{
__ char * n = B.z + B.a ; _1(n)
if ( not_At( n, ".htm" )
&& not_At( n, ".HTM" )
&& not_At( n, ".asp" )
// && not_At( n, ".js" )
&& not_At( n, ".css" )
&& not_At( n, ".inc" )
&& not_At( n, ".ASP" ) ) more_
anzPages++ ;
char * c = B.z + B.a ;
char * e = c + 4 ; if ( *e == 'l' ) e++ ; *e = 0 ;
if is_( e-7, "doc.htm" ) more_
if is_( e-7, "src.htm" ) more_
while ( *c != '\n' ) c-- ; c++ ;
if not_is_file( c )
then {
printf( "\nnot a file__: %s", c );
more_
}
Btree LocNames ; // wirklich erst hier !!!
C.open_rBuffer( c, "" ); C.remember( 10 );
BOOL newpic = false ;
char1000 fn ; s_( fn, "%s", c ); char * u = fn + ( e - c ) - 4 ;
while ( *u && *u != '/' ) u-- ; u++ ;
while ( C.find( 1, "=", 0 ) )
{
char * r = C.z + C.a - 4 ; char * r1 = r+1 ;
__
if ( space( r[5] ) || At( r+6, "file:///" ) )
{
_1(r) __ continue ;
}
if ( At( r , "name=" ) || At( r , "NAME=" ) )
{
r += 5 ; if ( *r == '"' ) r++ ;
char * x = r ; while not_in_str( *x, "\">" ) x++ ;
if ( x-r > 252 ) continue ;
char m = *x ; *x = 0 ;
KVStore st ;
if ( *r )
{
if ( LocNames.Get( r, st ) )
then {
if ( st.c[0] == '-' )
then {
st.c[0] = 'D' ;
LocNames.StrIns( 'e', r, st.c );
}
else printf( "\nerror: not unique: #%s : %s", r, c );
}
else LocNames.StrIns( 'e', r, "D-" );
}
*x = m ;
}
esif ( At( r , "href=" ) || At( r , "HREF=" )
|| At( r1, "src=" ) || At( r1, "SRC=" )
|| At( r1, "img=" ) || At( r1, "IMG=" )
)
{
Lr: char * e = u ; r += 5 ;
if ( *r == '\"' ) r++ ;
if ( *r == '\'' ) r++ ;
if ( *r == '"' )
{
printf( "\nerror: empty href in %s", c );
}
if ( in_str( *r, "#<\'\"" ) )
{
char * x = r ;
while ( *( ++x ) != '>' )
{
if ( At( x, "src=" ) || At( x, "SRC=" )
|| At( x, "img=" ) || At( x, "img=" ) )
{
r = x-1 ; goto Lr ;
}
}
// traceStr( "UUU", r, 40 ); more_
more_
}
if ( *r == '#' )
{
char * x = ++r ;
while not_in_str( *x, "\">" ) x++ ;
char m = *x ; *x = 0 ;
KVStore st ;
if ( ! *r ) fErr
if ( LocNames.Get( r, st ) )
then {
if ( st.c[1] == '-' )
{
st.c[1] = 'U' ;
LocNames.StrIns( 'e', st.k, st.c );
}
}
else LocNames.StrIns( 'e', r, "-U" );
*x = m ;
more_
}
if ( *r == '<' ) more_
if ( At( r, "Ftp:" )
|| At( r, "Http:" )
|| At( r, "mailto:" )
|| At( r, "javascript:" )
|| At( r, "nextPage" )
|| At( r, "<" )
|| At( r, "\\" )
|| At( r, "self.location" ) ) more_
if ( *r == '/' || r[1] == ':' ) // an absolute path
{
char * e = r+1 ;
while ( *e != '"' && *e != '>' ) e++ ; *e = 0 ;
if ( not_is_( r, "/" ) && not_path_exists( fn ) )
{
anz2++ ; printf( "\n%-13s -- %s", c+3, r );
}
more_
}
if ( not_in_str( *r, "hfm" ) || ( not_At( r, "Http:" )
&& not_At( r, "File:" )
&& not_At( r, "Mailto:" )
))
{
while not_in_str( *r, "?>#\"\'" )
{
if ( *r == '=' ) // z.B. TARGET=frame
{
e-- ; while ( fn < e && not_space( *e ) ) e-- ;
while ( fn < e && space( *e ) ) e-- ; e++ ;
break ;
}
*e++ = *r++ ;
}
*e = 0 ;
if is_( eos( fn ) - 4, ".bmp" )
{
// convert to *.png
S_ "bmp2png -9 %s && del %s", fn, fn _Do
newpic = true ;
}
if not_path_exists( fn )
if not_is_( fn + strlen( fn ) - 4, ".mso" )
if not_is_( fn + strlen( fn ) - 12, "filelist.xml" )
{
anz2++ ; printf( "\n%-13s -- %s", c, fn );
miss.StrIns( 'e', fn );
// showStr( "CCC", C.z + C.a - 4, 100 ); fErr
}
anz1++ ;
if not_is_file( fn ) printf( "\nref_? %s", fn );
__ }
}
__ }
__ if ( newpic ) replace( c, ".bmp\"", ".png\"" );
B.a = e+1 - B.z ; *e = '\n' ;
Le:; }
printf( "\n\n%8sCheck done: %u references, %u broken (see above).\n"
, "", anz1, anz2 );
if ( wdes )
then {
char * tmp = "x_check_htm" ;
FILE * f = create( tmp );
rBuffer B( wdes, "" );
rB_( B, 1, "</p></span></font></pre></body>", f );
char100 webName ; strcpy( webName, wdes + 3 );
char * x = webName ; to_( x, '/' ) *x = 0 ;
time_t now ; time( &now );
fprintf( f, "\n<br/> ----------"
"\n<br/> <a href=1/1.htm>Web %s</a> :"
" %u Pages, %u Hotspots (%u broken)"
"\n<br/> Time to create and check this web: %u sec"
"\n<br/> The Web Generator ignored lines without a - in column 1."
, webName, anzPages, anz1, anz2, now - startTime );
B.copy_to( f ); close( f );
B.open_rBuffer( tmp, "" ); f = create( wdes );
while ( B.find( 0, "<br/>\n<br/>-?", f ) ) B.a += 4 ;
close( f );
Unlink( tmp )
}
KVStore st ; Surr s = miss.GetFirst( st ); uint anz = 0 ;
while ( s )
{
if ( anz == 0 ) printf( "\n\nMissing are the following targets:\n" );
anz++ ; printf( "\n%s", st.k );
s = miss.Next( st );
}
if ( anz ) printf( "\n\nSo you see: %u targets do not exist.\n", anz );
LE_ret( anz2 )
/* public: */ void Ut_htm_static :: check_nesting
/* -----------------------------------------------------------------------------
HTML syntax check: tag nesting
-----------------------------------------------------------------------------
*/ (
char * pos
, char * htm
)
LB_("Ut_htm_static.check_nesting")
ret_
printf( "\nno htmcheck: not a dir: %s\n", htm );
__
check_ms_htm( pos, htm );
__
ret_
char * str = " "
" "
" ";
str += strlen( str );
char * sec[200] ; int i = 0 ; while ( i < 200 ) sec[i++] = "-" ;
sec[1] = "html" ;
rBuffer B( htm, "\n" ); int k = 0 ; str_set store ;
B.find( 0, "<body", 0 );
while ( B.find( 1, "<", 0 ) )
{
char * c = B.z + B.a + 1 ;
char * u = B.z + B.e ;
if ( alpha( *c ) || *c == '/' )
{
char * e = c ; to_( e, '>' )
if At( c, "br" ) more_
if At( c, "aa" ) more_
if At( c, "img" ) more_
if At( c, "hDoc" ) more_
if At( c, "/secLU" ) more_
if At( c, "/div" ) more_
if At( c, "div" ) more_
if ( *c != '/' ) k++ ;
char * x = e ;
Loop {
if ( ! *x ) fErr
if ( u <= x || *x == '\n' || *x == '<' ) break ;
if At( x, ">>" )
then {
x += 2 ; break ;
}
else x++ ;
}
char m = *x ; *x = 0 ;
if ( ! pos ) printf( "\n%-2i : %s%s", k, str-k, c-1 );
if ( *c == '/' )
then {
if not_At( c+1, sec[k] )
{
*x = m ; printf( "\n" );
showStr( "", c-1, min( 400, B.z + B.e - c+1 ) );
printf( "\nerror: erwartet wurde </%s", sec[k] ); break ;
}
}
else {
char * x = c ; while alpha( *x ) x++ ;
char m = *x ; *x = 0 ;
sec[ k ] = store.take( c ); *x = m ;
}
*x = m ;
if ( *c == '/' ) k-- ;
if ( k < 0 ) break ;
if ( k && At( c, "/html" ) )
{
if ( ! pos ) showStr( "", c-1, 20 );
break ;
}
B.a = e - B.z ;
}
}
if ( k )
{
printf( "\nHTML syntax error: pos = %s, f = %s", pos, htm ); exit(1);
}
LE_
/* public: */ void Ut_htm_static :: alias_for
/* -----------------------------------------------------------------------------
Let 'fn be a file bringing the Browser to 'dest
-----------------------------------------------------------------------------
*/ (
char * fn
, char * dest
)
LB_("Ut_htm_static.alias_for")
if ( ! dest ) fErr
if ( ! fn ) fErr
FILE * f = create( fn );
fprintf( f, "\n<html><head><meta HTTP-EQUIV=\"refresh\""
"\n content=\"0;URL=%s\"></meta></head><body></body></html>"
, dest );
close( f );
LE_
/* public: */ void Ut_htm_static :: extract_htm
/* -----------------------------------------------------------------------------
search for 'start, then extract the next section <see> ... </see>
-----------------------------------------------------------------------------
*/ (
FILE * f
, char * from
, char * start // or 0
, char * end // or 0
, char * see
, uint skip // anz to skip
, uint anz // anz to find
)
LB_("Ut_htm_static.extract_htm")
if ( ! f ) fErr
if ( ! from ) fErr
rBuffer B( from, "\n" ); B.remember( 10 );
if ( start )
{
if ( ! *start ) fErr
if At( start, "<!--" ) fprintf( f, "\n%s", start );
if ( ! B.find( 0, start, 0 ) ) anz = 0 ;
}
while ( skip-- ) if ( ! B.find( 0, see, 0 ) ) anz = 0 ;
printf( "\nanz = %i: %s", anz, from );
if ( end && anz )
{
B.find( 1, end, f ); ret_
}
if ( anz )
{
if ( ! see || ! *see ) fErr
while ( anz-- && B.find( 1, see, 0 ) ) if ( B.z[ B.a-1 ] == '<' )
{
int k = 1 ;
while ( k && B.find( 1, see, f ) )
{
if ( B.z[ B.a-1 ] == '<' ) k++ ; else
if ( B.z[ B.a-1 ] == '/' ) k-- ;
}
fprintf( f, "%s>", see );
}
}
LE_
/* public: */ static BOOL Ut_htm_static :: At_target_p
/* -----------------------------------------------------------------------------
return BOOL( this section <p> ... </p> is a target )
-----------------------------------------------------------------------------
*/ (
char * c
, char * ee
)
LB_("Ut_htm_static.At_target_p")
if At( c, "<h" ) ret(1)
strcpy( ee, "</p>" );
if At( c, "<p" )
{
while not_At( c, "</p>" )
{
c++ ; to_( c, '<' ); if At( c, "<a name=" ) ret(1)
}
}
if ( ee <= c ) fErr
LE_ret( false )
/* public: */ BOOL Ut_htm_static :: LeerZeile
/* -----------------------------------------------------------------------------
return BOOL( Text is found in front of </p> )
-----------------------------------------------------------------------------
*/ (
char * c
, char * ee
)
LB_("Ut_htm_static.LeerZeile")
char10 xx ; extract_pText( c, ee, xx, 0, 0 ); __ __ __
LE_ret(( *xx == 0 ))
/* public: */ static void Ut_htm_static :: spalten_text
/* -----------------------------------------------------------------------------
copy to 'text den Text der Spalte
-----------------------------------------------------------------------------
*/ (
char * c
, char * e1
, char * text // store text found in this buffer
, uint mx
)
LB_("Ut_htm_static.spalten_text")
if not_At( c, "<td" ) fErr
char m = *e1 ; *e1 = '>' ; // der Robustheit wegen
char * z = text ; if ( ! z ) fErr
char * e2 = z + mx ;
while not_At( c, "</t" )
{
if ( *c == '<' )
then {
to_( c, '>' ) c++ ;
}
else {
*z++ = *c++ ; if ( e2 <= z ) break ;
}
if ( e1 <= c ) break ;
}
*z = 0 ; *e1 = m ;
LE_
/* public: */ static char Ut_htm_static :: extract_pText
/* -----------------------------------------------------------------------------
extract text in front of </p>
-----------------------------------------------------------------------------
*/ (
char * c
, char * ee
, char * text // store text found in this buffer
, uint mx // 0 if we only want to see whether there is text
, char rem // or 0
)
LB_("Ut_htm_static.extract_pText")
char * ee2 = text + mx ; strcpy( ee, "</p>" );
skip_space( c ); if ( ee <= c ) ret( 0 )
char * e = c ; char * n = text ;
char * c1 = c ;
if At( e, "<p" ) { to_( e, '>' ) e++ ; skip_space( e ) }
Loop { // showStr( "TTT", e, min( 400, ee-c ) );
if ( *e == '<' )
then {
if ( ee <= e )
then {
traceStr( "EEE", c1, ee-c1 ); break; //fErr1( ee-c1 )
}
esif At( e, "<p>" ) break ; // to be robust
esif ( e[1] == '/' )
{
if At( e, "</p>" ) break ;
esif At( e, "</body>" ) break ;
esif At( e, "</BODY>" ) break ;
}
esif ( mx == 0 && At( e, "<img" ) ) ret('i')
to_( e, '>' ) e++ ; // hier ja kein skip_htm() !!!
if ( ee < e )
{
// showStr( "xxx", c1, ee-c1 ); fErr
*n = 0 ; ret( *text )
}
skip_space( e )
}
esif At( e, "..." ) break ; // dots in MS TOC Zeile
else {
if ( *e == rem ) { *e = ' ' ; rem = 0 ; }
if ( 0 < mx )
then {
*n++ = *e++ ;
if ( ee <= e ) fErr2( c, mx )
if ( ee2 <= n ) { *text = 0 ; break ; }
}
esif At( e, " " ) e += 6 ;
esif space( *e ) e += 1 ;
else ret( *e )
}
}
*n-- = 0 ; // _x( text )
while ( space( *n ) || is_( n-5, " " ) )
{
n -= ( space( *n ) )? 1 : 6 ;
if ( n < text ) n = text - 1 ; n[1] = 0 ;
}
LE_ret( *text )
/* public: */ static char Ut_htm_static :: get_picName
/* -----------------------------------------------------------------------------
assume that the following section <p> ... </p> contains text of the form
picNr: picName
-----------------------------------------------------------------------------
*/ (
char * c
, char * ee
, char * picName
)
LB_("Ut_htm_static.get_picName")
// showStr( "PPP", c, 500 );
if ( ! ee ) fErr
if ( ! c ) fErr
strcpy( ee, "EE > :" );
while ( c < ee && *c != ':' )
{
while ( *c == '<' ) { to_( c, '>' ) c++ ; }
skip_space( c );
if ( *c != '<' ) break ;
}
if in_str( *c, "FBA" )
then {
// A = Abb...
// B = Bild
// F = Figure
char * x = c ; to_( x, 'p' ) *x = 0 ;
if in_str( ':', c ) { to_( c, ':' ) c++ ; }
*x = 'p' ;
}
else {
*picName = 0 ; ret( 0 )
}
while ( *c == ' ' || is_tabulator( *c ) ) c++ ;
__ __
LE_ret( extract_pText( c, ee, picName, 250, 0 ) )
/* public: */ static int Ut_htm_static :: word_to_htm
/* -----------------------------------------------------------------------------
for each MS Word file 'x/f.doc or 'x/f.rtf listed in the 'scr file
immediately following \n
we want to create x/publish/f.htm
Create the corresponding *.js script, and then execute it.
-----------------------------------------------------------------------------
*/ (
char * scr
)
LB_("Ut_htm_static.word_to_htm")
if ( ! scr ) fErr
FILE * f = create( "tmp.js" ); int anz = 0 ;
//
fprintf( f, "\nvar app = new ActiveXObject( \"Word.Application.12\" );"
"\napp.Visible = true;\n" );
rBuffer B( scr, "\n" );
while ( B.find( 1, ".", 0 ) )
{
char * c = B.z + B.a ;
if ( At( c, ".doc" ) || At( c, ".rtf" )
|| At( c, ".DOC" ) || At( c, ".RTF" )
)
{
char m = c[4] ; *c = c[4] = 0 ; char * wc = c ;
while not_in_str( *wc, "/\\" ) wc-- ; *wc = 0 ;
char * fname = wc + 1 ;
while ( *wc != '\n' ) wc-- ; wc++ ;
char800 pu ;
if At( wc, ".." )
then {
char * currDir = getcwd( 0, 400 );
if ( ! currDir ) fErr
char * e = eos( currDir ) - 1 ;
if in_str( e[-1], "/\\" ) e[-1] = 0 ;
s_( pu, "%s/%s", currDir, wc + 3 ); free( currDir );
strcpy( wc, pu );
}
unix_me( wc ); s_( pu, "%s/publish", wc );
dir_exist( pu );
fprintf( f, "\napp.Documents.Open( \"%s/%s.%s\", 1, 1 );"
"\napp.ActiveDocument.SaveAs( \"%s/%s.htm\", 8 );"
"\napp.ActiveDocument.SaveAs( \"%s/%s.txt\", 5 );"
"\napp.ActiveDocument.Close();\n"
, wc, fname, c+1
, pu, fname
, pu, fname );
c[4] = m ;
}
}
fprintf( f, "\napp.Quit();" );
close( f );
S_ "tmp.js" _Do
LE_ret( anz )
/* public: */ static int Ut_htm_static :: word_to_htm
/* -----------------------------------------------------------------------------
for each MS Word file 'x/f.doc or 'x/f.rtf found in the given 'dir tree
we want to create x/publish/f.htm
Create the corresponding *.js script 'scr
and return the number of files to be transformed
-----------------------------------------------------------------------------
*/ (
char * scr
, char * dir
)
LB_("Ut_htm_static.word_to_htm")
if ( ! scr ) fErr
if ( ! dir ) fErr
if not_is_dir( dir )
{
m_errMess "System: no such folder: %s" m_
dir, ret_error
}
;
if not_is_( scr + strlen( scr ) - 3, ".js" ) fErr1( scr )
FILE * f = create( scr ); int anz = 0 ;
//
fprintf( f, "\nvar app = new ActiveXObject( \"Word.Application.12\" );"
"\napp.Visible = true;\n" );
anz += word_to_htm( f, dir );
fprintf( f, "\napp.Quit();" );
close( f );
LE_ret( anz )
/* public: */ static int Ut_htm_static :: word_to_htm
/* -----------------------------------------------------------------------------
for each MS Word file 'x/f.doc or 'x/f.rtf found in the given 'dir
we want to create x/publish/f.htm + f.txt
Add a corresponding commant to the open JScript 'f
and return the number of cases added
-----------------------------------------------------------------------------
*/ (
FILE * f
, char * dir
)
LB_("Ut_htm_static.word_to_htm")
int anz = 0 ;
char1000 wc ; s_( wc, "%s/*", dir ); dos_me( wc );
_finddata_t dta ; int h = _findfirst( wc, &dta );
char * e = wc + strlen( wc ) - 2 ; *e = 0 ;
while ( ! errno )
{
if ( not_is_( dta.name, "." )
&& not_is_( dta.name, ".." )
&& not_is_( dta.name, "System Volume Information" )
&& not_is_( dta.name, "publish" )
)
{
if ( dta.attrib & _A_SUBDIR )
then {
s_( e, "/%s", dta.name ); word_to_htm( f, wc );
*e = 0 ;
}
else {
char * e = dta.name + strlen( dta.name ) - 1 ;
while ( *e != '.' && dta.name < e ) *( e-- ) = lower( *e );
if ( is_( e, ".doc" ) || is_( e, ".rtf" ) )
{
char1000 pu ;
unix_me( wc ); s_( pu, "%s/publish", wc );
dir_exist( pu ); *e = 0 ;
fprintf( f, "\napp.Documents.Open( \"%s/%s.%s\", 1, 1 );"
"\napp.ActiveDocument.SaveAs( \"%s/%s.htm\", 8 );"
"\napp.ActiveDocument.SaveAs( \"%s/%s.txt\", 5 );"
"\napp.ActiveDocument.Close();\n"
, wc, dta.name, e+1
, pu, dta.name
, pu, dta.name );
anz++ ; *e = '.' ; dos_me( wc );
}
}
}
_findnext( h, &dta );
}
if ( errno != ENOENT )
{
m_errMess "System: errno %i: %s" m_
errno, wc, ret_error
}
;
ok _findclose( h ); ok
LE_ret( anz )
/* public: */ char * Ut_htm_static :: skip_secNr ( char * z
// -----------------------------------------------------------------------------
)
LB_("Ut_htm_static.skip_secNr")
// Sample 1 (secNr rot): 1.2.4. 1:n Relationen
// Sample 2 (secNr rot): . . 1:n Relationen
// Sample 3 (secNr rot): 1.2.33.1:n Relationen
char * x = z ; while in_str( *x, "0123456789. " ) x++ ;
while ( z < x && x[-1] != '.' && not_space( x[-1] ) ) x-- ;
// while ( *x == '.' ) x++ ;
LE_ret( x )
/* public: */ BOOL Ut_htm_static :: mae_Umlaut ( uchar c
// -----------------------------------------------------------------------------
)
LB_("Ut_htm_static.mae_Umlaut")
if ( c == ( uchar ) 225
|| c == ( uchar ) 220
|| c == ( uchar ) 132
|| c == ( uchar ) 148
|| c == ( uchar ) 129
|| c == ( uchar ) 142
|| c == ( uchar ) 153
|| c == ( uchar ) 154 ) ret( c )
LE_ret( 0 )
/* public: */ char * Ut_htm_static :: to_mae
// -----------------------------------------------------------------------------
(
char * s
, char * skip
)
LB_("Ut_htm_static.to_mae")
char * a = s ;
char * e = s ;
while ( *s )
{
if ( *s == '\\' )
then {
char * c = s+1 ;
if At( c, "160" ) s += 4 ; // tabulator
esif At( c, "225" ) { s += 4 ; *e++ = ( uchar )225 ; }
esif At( c, "132" ) { s += 4 ; *e++ = ( uchar )132 ; }
esif At( c, "148" ) { s += 4 ; *e++ = ( uchar )148 ; }
esif At( c, "129" ) { s += 4 ; *e++ = ( uchar )129 ; }
esif At( c, "142" ) { s += 4 ; *e++ = ( uchar )142 ; }
esif At( c, "153" ) { s += 4 ; *e++ = ( uchar )153 ; }
esif At( c, "154" ) { s += 4 ; *e++ = ( uchar )154 ; }
else *e++ = *s++ ;
}
else *e++ = *s++ ;
}
*e = 0 ;
if ( skip ) while ( *a && in_str( *a, skip ) ) a++ ;
LE_ret( a )
/* public: */ void Ut_htm_static :: mae_to_msHtm ( char * s
// -----------------------------------------------------------------------------
)
LB_("Ut_htm_static.mae_to_msHtm")
char * e = s-- ;
while ( *( ++s ) )
{
switch ( ( uchar ) *s )
{
Case ( uchar )160 : // tabulator
Case ( uchar )225 : *e++ = ( uchar )223 ; // á
Case ( uchar )228 : *e++ = ( uchar )132 ; // „
Case ( uchar )148 : *e++ = ( uchar )246 ; // ”
Case ( uchar )129 : *e++ = ( uchar )252 ; //
Case ( uchar )142 : *e++ = ( uchar )196 ; // Ž
Case ( uchar )153 : *e++ = ( uchar )214 ; //
Case ( uchar )154 : *e++ = ( uchar )220 ; // š
Else : *e++ = *s ;
}
}
*e = 0 ;
LE_
/* public: */ void Ut_htm_static :: escape_mae_to_htm
// -----------------------------------------------------------------------------
(
char * mae
, char * htm
, char * textAnf // or 0
)
LB_("Ut_htm_static.escape_mae_to_htm")
if ( textAnf && ! *textAnf ) fErr
str_set such ; char * ers = "<" ;
*ers = '<' ; such.insert( ers, "<" );
*ers = '>' ; such.insert( ers, ">" );
*ers = ( uchar ) 225 ; such.insert( ers, "β" ); // á
*ers = ( uchar ) 132 ; such.insert( ers, "ä" ); // „
*ers = ( uchar ) 148 ; such.insert( ers, "ö" ); // ”
*ers = ( uchar ) 129 ; such.insert( ers, "ü" ); //
*ers = ( uchar ) 142 ; such.insert( ers, "Ä" ); // Ž
*ers = ( uchar ) 153 ; such.insert( ers, "Ö" ); //
*ers = ( uchar ) 154 ; such.insert( ers, "Ü" ); // š
*ers = ( uchar ) 16 ; such.insert( ers, ">" ); // semi graphics
*ers = ( uchar ) 17 ; such.insert( ers, "<" ); // semi graphics
*ers = ( uchar ) 30 ; such.insert( ers, "Λ" ); // semi graphics
*ers = ( uchar ) 31 ; such.insert( ers, "V" ); // semi graphics
*ers = ( uchar ) 168 ; such.insert( ers, "+" ); // semi graphics
*ers = ( uchar ) 180 ; such.insert( ers, "+" ); // semi graphics
*ers = ( uchar ) 191 ; such.insert( ers, "+" ); // semi graphics
*ers = ( uchar ) 192 ; such.insert( ers, "+" ); // semi graphics
*ers = ( uchar ) 193 ; such.insert( ers, "+" ); // semi graphics
*ers = ( uchar ) 194 ; such.insert( ers, "+" ); // semi graphics
*ers = ( uchar ) 195 ; such.insert( ers, "+" ); // semi graphics
*ers = ( uchar ) 197 ; such.insert( ers, "+" ); // semi graphics
*ers = ( uchar ) 217 ; such.insert( ers, "+" ); // semi graphics
*ers = ( uchar ) 218 ; such.insert( ers, "+" ); // semi graphics
*ers = ( uchar ) 196 ; such.insert( ers, "-" ); // semi graphics
*ers = ( uchar ) 179 ; such.insert( ers, "|" ); // semi graphics
such.insert( "\n[?+]" );
rBuffer B( mae, "" ); FILE * f = create( htm ); match_rec * mr ;
if ( textAnf )
then {
if ( B.find( 0, textAnf, 0 ) )
then {
B.find( 0, "\n", f );
}
else B.open_rBuffer( mae, "" );
}
while ( mr = B.find( 0, such, f ) )
{
if ( B.z[ B.a ] != '\n' )
then {
B.a++ ; fprintf( f, "%s", mr -> str2 );
}
else {
rB_( B, 5, "\n[?-]", f );
}
}
close( f );
LE_
/* public: */ void Ut_htm_static :: escape_msHtm_to_htm ( char * htm
// -----------------------------------------------------------------------------
)
LB_("Ut_htm_static.escape_msHtm_to_htm")
char * tmp = "x_escape_msHtm" ;
escape_msHtm_to_htm( tmp, htm ); cp_file( htm, tmp );
Unlink( tmp )
LE_
/* public: */ void Ut_htm_static :: escape_msHtm_to_htm
// -----------------------------------------------------------------------------
(
char * htm
, char * msHtm
)
LB_("Ut_htm_static.escape_msHtm_to_htm")
str_set such ;
if (0)
then {
// Nein, MS spinnt sonst
uchar u = ( uchar )128 ; char * str = "?" ;
while ( ++u < ( uchar )255 ) if ( ! is_tabulator( u ) )
{
*str = u ; such.insert( str );
}
}
else {
such.msHtm_escape( 130 );
such.msHtm_escape( 133 );
such.msHtm_escape( 132 );
such.msHtm_escape( 147 );
such.msHtm_escape( 145 );
such.msHtm_escape( 146 );
such.msHtm_escape( 148 );
such.msHtm_escape( 150 );
such.msHtm_escape( 151 );
such.msHtm_escape( 167 );
such.msHtm_escape( 173 );
such.msHtm_escape( 183 );
if ( auch_Umlaute )
{
such.msHtm_escape( 223 ); // á
such.msHtm_escape( 228 ); // ae
such.msHtm_escape( 246 ); // oe
such.msHtm_escape( 252 ); // ue
such.msHtm_escape( 196 ); // Ae
such.msHtm_escape( 214 ); // Oe
such.msHtm_escape( 220 ); // Ue
}
}
rBuffer B( msHtm, "" ); FILE * f = create( htm ); match_rec * mr ;
while ( mr = B.find( 0, such, f ) )
{
// showStr( "UUU", B.z + B.a, 20 ); _1( mr -> str2 )
B.a++ ; fprintf( f, "%s", mr -> str2 );
}
close( f );
LE_
/* public: */ void Ut_htm_static :: erz_docstyles ( FILE * f
// -----------------------------------------------------------------------------
)
LB_("Ut_htm_static.erz_docstyles")
fprintf( f,
"\nbody {"
"\n color:#000000; background-color:#FFFFFF;"
"\n link=\"#FF3333\"; vlink=\"#FF3333\"; alink=\"#FF0000\";"
"\n font-family:Arial; font-size:10px;"
"\n margin: 0pt 0pt .0001pt 0pt;"
"\n tab-interval:.325in;"
"\n text-autospace:none;text-justify-trim:punctuation;"
"\n padding:18pt;"
"\n }"
"\n"
//
//
//
//
"\npre {"
"\n font-family:Courier New Courier; font-size:12px;"
"\n margin: 0pt 0pt .0001pt 0pt;"
"\n }"
"\n"
"\nh1,h2,h3 { font-family:Arial ; font-size:20px; }"
"\n"
"\n.bullet { font-family:Wingdings ; font-size:16px; }"
"\n.snr { font-family:Verdana ; font-size: 8px; }"
"\n"
"\n.co2 { color : #6633FF }"
"\n"
"\n.einger { padding-left : 10% }"
"\n"
"\n.0 { font-family:ARIAL; font-size:10pt; margin: 12pt 0pt 0pt 20pt; }"
"\n.1 { font-family:ARIAL; font-size:10pt; margin: 2pt 0pt 2pt 20pt; }"
"\n.2 { font-family:ARIAL; font-size:10pt; margin: 0pt 0pt 0pt 20pt; }"
);
LE_
/* public: */ void Ut_htm_static :: erz_j2hstyles
// -----------------------------------------------------------------------------
(
FILE * f
, char * str
)
LB_("Ut_htm_static.erz_j2hstyles")
if ( ! f ) fErr
if ( str && *str ) fprintf( f, str );
fprintf( f, "\nbody { background-color: #FFFFFF; }"
"\nbody { color: #000000 } /* for normal code */"
"\n#Header { color: #000000; background-color: #CCCCFF }"
"\n#Classes A:link { color: #FF3333; }"
"\n#Classes A:visited { color: #FF3333; }"
"\n#Classes PRE { color: #000000; }"
"\n#co { color: #008000; } /* for comment */"
"\n#kw { color: #0000FF; } /* for keywords */"
"\n#str { color: #FF3333; } /* for quoted text */"
"\n"
"\nh1 { font-family:ARIAL,VERDANA ; font-size:20px; }"
"\nh2 { font-family:ARIAL,VERDANA ; font-size:18px; }"
"\nh3 { font-family:ARIAL,VERDANA ; font-size:16px; }"
"\nh4 { font-family:ARIAL,VERDANA ; font-size:16px; }"
"\nh5 { font-family:ARIAL,VERDANA ; font-size:16px; }"
"\nHMenu { font-family:ARIAL,VERDANA ; font-size: 8px;"
"\n align: center; }"
"\n.snr { font-family:VERDANA ; font-size: 8px; }"
"\n.1 { font-family:ARIAL,VERDANA ; }"
);
LE_
/* public: */ void Ut_htm_static :: create_CSS
// -----------------------------------------------------------------------------
(
char * dir
, char * css
)
LB_("Ut_htm_static.create_CSS")
char1000 fn ; s_( fn, "%s/%s.css", dir, css );
if is_file( fn ) ret_
FILE * f = create( fn );
if is_( css, "j2h" ) erz_j2hstyles( f, "" ); else fErr1( css )
close( f );
LE_
/* public: */ void Ut_htm_static :: reduce_secNr
// -----------------------------------------------------------------------------
(
char * rsn // reduced 1.2
, char * sn // secNr such as 1001.1002
)
LB_("Ut_htm_static.reduce_secNr")
// if ( ! sn || *sn && ! digit( *sn ) ) fErr1( sn ) else *rsn = 0 ;
if ( ! sn ) fErr1( sn ) else *rsn = 0 ;
while ( *sn && digit( *sn ) )
{
if not_in_str( *sn, "0123456789" ) { _x( *sn ) break ; }
char * nr = sn ;
while in_str( *sn, "0123456789" ) sn++ ;
if in_name( *sn ) break ; esif ( *sn == '.' ) sn++ ;
s_( rsn, "%i.", decNr( nr ) % 1000 );
rsn += strlen( rsn );
}
rsn[ -1 ] = 0 ;
LE_
/* public: */ void Ut_htm_static :: get_hText_Lines
/* -----------------------------------------------------------------------------
Schreibe nach 'hds die Menge aller in 'htm gefundener šberschriften
-----------------------------------------------------------------------------
*/ (
char * htm
, char * hds
)
LB_("Ut_htm_static.get_hText_Lines")
char * dots = ". . . . . . . . . . " ; dots = eos( dots );
Btree headers ; int anz = 0 ;
char4000 header ;
rBuffer B( htm, "\n" ); FILE * f = create( hds );
while ( B.find( 1, "<h", 0 ) )
{
B.getmore( 4000 );
char n = B.z[ B.a + 2 ] ;
if not_in_str( n, "123456789" ) more_
char * deep = dots - ( n - '0' ) * 3 ;
get_HText( B.z + B.a, header, 0, B.z + B.e, header + 400, 0, 0 );
char * h = header ;
while ( *h && in_str( *h, ".0123456789" ) ) h++ ;
if ( h[1] == ')' ) { h += 2 ; skip_space( h ); }
char * x = h-1 ; h = header ;
while ( *( ++x ) )
{
if ( *x == '[' ) *h++ = ' ' ;
if At( x, """ )
then {
x += 5 ; *h++ = '"' ;
}
else {
if ( *x == '[' ) *h++ = ' ' ;
*h++ = *x ;
}
}
*h = 0 ;
if ( *header ) fprintf( f, "\n%s%s", dots - ( n - '0' ) * 3, header );
char10 spot ; s_( spot, "%i", ++anz );
headers.StrIns( 'e', header, spot );
}
close( f );
// if ( neu )
then {
char500 neu ; s_( neu, "%s.htm", htm );
add_toc( htm, neu, headers );
}
LE_
/* public: */ void Ut_htm_static :: add_toc
/* -----------------------------------------------------------------------------
ensure neu = htm with a table of contents
-----------------------------------------------------------------------------
*/ (
char * htm
, char * neu
, Btree toc
)
LB_("Ut_htm_static.add_toc")
str_set such ; KVStore st ; Surr s = toc.GetFirst( st );
rBuffer B( htm, "" ); FILE * f = create( neu );
while ( B.find( 1, "<", f ) )
{
char * c = B.z + B.a ;
if ( At( c, "<BODY" ) || At( c, "<body" ) )
{
B.find( 1, ">", f ); B.a += 1 ; break ;
}
}
fprintf( f, "\n<BODY>" );
while ( s )
{
such.insert( st.k, st.c );
fprintf( f, "\n<br/><a href=\"#%s\">%s</a>", st.c, st.k );
s = toc.Next( st );
}
match_rec * mr ;
while ( mr = B.find( 1, such, f ) )
{
fprintf( f, "\n<a name=%s></a>", mr -> str2 );
}
close( f );
LE_
/* public: */ char * Ut_htm_static :: get_HText
/* -----------------------------------------------------------------------------
feed the text between 'such and </h> to 'hText
such == 0 implies ( such == "<h" && At( c, "<h" ) )
-----------------------------------------------------------------------------
*/ (
char * c
, char * hText
, char * such // or 0
, char * ee // or 0
, char * name // buffer
, char * page // docNr/fNr
, Btree * msoRefs
)
LB_("Ut_htm_static.get_HText")
char * c1 = c ;
if ( ! name ) fErr *name = 0 ;
if ( ! ee ) fErr
if ( ! hText ) fErr
char * cm = c ;
if ( such )
then {
char m = *such ; *ee = m ;
Loop {
to_( c, m ); if ( ee <= c || At( c, such ) ) break ; else c++ ;
}
}
esif ( ! c || not_At( c, "<h" ) ) fErr
if ( ee <= c ) { *hText = 0 ; ret( c1 ) }
BOOL norm = 0 ;
char1000 header ; char * n = header ; skip_space( c )
char * e = ( norm )? n : hText ;
char * msoRef = 0 ;
char * noh = hText + 250 ;
// traceStr( "CCC",c,1200 );
Loop {
// section title, possibly with a section number:
while ( *c == '<' )
{
__ if ( c[1] == 'a' )
{
__ char * x = c ; to_( x, '>' ) *x = 0 ; c = x+1 ;
msoRef = substr( "_Ref", c );
if ( msoRef )
{
char * e = msoRef + 5 ; to_space( e ) *e = 0 ;
}
__ }
if ( At( c, "</" ) && in_str( c[2], "hH" ) ) goto L1 ;
__ to_( c, '>' ) c++ ;
while ( space( *c ) && space( c[1] ) ) c++ ;
__ }
if ( ee <= c )
then {
traceStr( "sss", c1, ee - c1 + 11 ); fErr1( such )
}
esif ( *c == '&' && ( At( c, " " )
|| At( c, "" )
|| At( c, "§" ) ) ) c += 6 ;
esif ( space( *c ) && space( e[-1] ) || *c == '>' ) c++ ;
esif ( 32 <= uchar( *c ) && uchar( *c ) <= 159 ) *e++ = *c++ ;
esif ( see_char( *c ) ) *e++ = *c++ ;
else c++ ;
if ( e[-1] == '[' && not_space( e[-2] ) )
then {
memcpy( e-1, " [", 2 );
e++ ;
}
if ( noh <= e )
then {
// Header longer than 250 bytes, or no header found. Daher:
__ printf( "\nHeader too long ???" );
*hText = 0 ;
ret( c1 )
}
__ }
if ( ee <= c ) fErr
__
L1: *e = 0 ; while ( hText < e && space( e[-1] ) ) *( --e ) = 0 ;
__
if space( *hText )
{
char * x = hText ; while ( *x && space( *x ) ) x++ ; x-- ;
int s = x+1 - hText ;
while ( *( ++x ) ) x[-s] = *x ; x[-s] = 0 ;
}
// -----------------------------------------------------------------------------
if ( *hText == '>' ) fErr
if ( norm )
{
char * h = hText ; char m = *header ; if ( n != header ) fErr
while digit( m )
{
__ char * nr = n ;
while not_in_str( *n, ". " ) n++ ; *n = 0 ; m = *( ++n );
int i = 1000 + decNr( nr );
s_( h, "%i.", i ); h += 5 ;
}
__
if ( hText < h ) h[-1] = ' ' ;
skip_space( n ); strcpy( h, n );
// Damit sind die Header nun normiert um unter lexikographischer Ordnung
// die Reihenfolge aufzuweisen, in der sie TOC zu zeigen hat (norm = 0
// bedeutet: wie kriegen den TOC auch anders hin.
}
//
// Nun noch nachsehen, ob die eben gefundene KapNr plausibel ist - sie
// wurde erzeugt in doc_des :: register_Cards() durch eben diesen Code hier:
uint zA = zeichAnz( '.', "1234567890", c );
if ( zA <= chapDepth + 1 ) chapDepth = zA ; else fErr1( c )
c1 = c ; c = hText ;
e = eos( c );
while ( c < e && is_( e-6, " " ) ) { e -= 6 ; *e = 0 ; }
if (1)
{{
char * x = c ;
char * z = c ;
while ( *x ) {
if At( x, " " )
then {
x += 6 ;
if ( c < z && not_space( z[-1] ) ) then *z++ = ' ' ;
}
esif space( *x )
{
x += 1 ;
if ( c < z && not_space( z[-1] ) ) then *z++ = ' ' ;
}
else {
if ( c < z && not_space( z[-1] ) )
{
if ( *x == '[' ) then *z++ = ' ' ;
}
*z++ = *x++ ;
}
}
*z = 0 ;
if ( 250 < z-c ) fErr
}}
if ( msoRefs && msoRef && page )
{
char500 zz ; s_( zz, "%s~%s", page, hText );
msoRefs -> StrIns( 'e', msoRef, zz );
}
_1(hText+0+0)
// if ( in_str( ']', hText ) && not_in_str( '[', hText ) ) fErr1( hText)
LE_ret( c1 )
/* public: */ uint Ut_htm_static :: zeichAnz
// -----------------------------------------------------------------------------
(
char m
, char * str
, char * s
)
LB_("Ut_htm_static.zeichAnz")
uint anz = 0 ; s-- ;
while in_str( *(++s), str ) if ( *s == m ) anz++ ;
LE_ret( anz )
/* public: */ BOOL Ut_htm_static :: see_char( char c
// -----------------------------------------------------------------------------
)
LB_("Ut_htm_static.see_char(")
BOOL see = 1 ;
switch ( uchar( c ) )
{
case 228 : ;
case 246 : ;
case 252 : ;
case 196 : ;
case 214 : ;
case 220 : ;
case 223 : ;
Else : see = ( 32 <= uchar( c ) && uchar( c ) <= 159
&& uchar( c ) != 133 );
}
LE_ret( see )
/* public: */ char * Ut_htm_static :: trim ( char * & e
// -----------------------------------------------------------------------------
)
LB_("Ut_htm_static.trim")
if ( ! e ) fErr
// if ( ! *e ) ret( e )
to_( e, '\n' ) char * ee = e ;
while space( e[-1] ) e-- ; *e = 0 ;
LE_ret( ee )
/* public: */ char * Ut_htm_static :: create_ufSurr
// -----------------------------------------------------------------------------
(
char * ufSurr
, char * doc
)
LB_("Ut_htm_static.create_ufSurr")
if ( ! doc ) fErr
if ( ! ufSurr ) fErr
char * zaun = in_str( '#', doc ); if ( zaun ) *zaun = 0 ;
if not_is_file( doc ) fErr1( doc )
s_( ufSurr, "%u.%u", file_Surr( doc ), file_len( doc ) );
if ( zaun ) *zaun = '#' ;
LE_ret( ufSurr )
/* public: */ char * Ut_htm_static :: clean ( char * sec
/* -----------------------------------------------------------------------------
Replace space sequences by one ' ' space
-----------------------------------------------------------------------------
*/ )
LB_("Ut_htm_static.clean")
//
BOOL anz = 0 ;
char * s = sec - 1 ;
char * z = sec ;
while ( *( ++s ) )
{
if ( *s == '\n' )
then {
anz++ ; *z++ = ' ' ;
while ( s[1] && space( s[1] ) ) s++ ;
}
else *z++ = *s ;
// uchar( *s ) == 160, das Tabulatorzeichen also,
// muss stehen gelassen werden - nur in šberschriften darf und sollte
// man es ausblenden.
}
*z = 0 ;
LE_ret( sec );
/* public: */ void Ut_htm_static :: skip_htm_space
// -----------------------------------------------------------------------------
(
char * & c
)
{
L1: skip_space( c )
while At( c, " " ) { c += 6 ; skip_space( c ) }
while ( (uchar)*c > 128 ) { ++c ; goto L1 ; }
}
/* public: */ char Ut_htm_static :: skip_htm
// -----------------------------------------------------------------------------
(
char * & c
, char * ee
)
LB_("Ut_htm_static.skip_htm")
L1:
if ( ee < c ) fErr2( c, ee-c )
while ( *c != '<' )
{
if At( c, " " ) c += 6 ; else c++ ;
skip_space( c ) if ( int( *c ) == -96 ) c++ ;
}
while ( *c == '<' )
{
to_( c, '>' ) c++ ; skip_space( c )
while At( c, " " ) c += 6 ; skip_space( c )
}
if ( int( *c ) == -96 ) { c++ ; goto L1 ; }
if ( ee <= c ) ret( 0 )
LE_ret( *c )
#undef static
#endif