meta,
C++
4 Methoden:
|
/* public: */ uint MsHtm :: split_MS_htm
/* public: */ void MsHtm :: prune_MS_htm
#define static
#include mshtm.h : 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 BB
#undef BBStr
#undef bb
#undef bbStr
#undef LB_
#undef LE_
#undef LE_ret
#undef ret
#undef ret_
#undef __
#undef ___
#define BB if ( 1 < call_nr || errno )
#define bb if ( 1 < call_nr || errno )
#define BBStr( x,y,z ) { BB traceStr( x,y,z ); }
#define bbStr( x,y,z ) { bb traceStr( x,y,z ); }
#define __ { bb { printf( "\nLine %i", __LINE__ ); }}
#define ___
#define ret_ { __ return ; }
#define LE_ __ return ; }
#define LE_ret( x ) __ return( x ); }
#define ret( x ) { __ return( x ); }
#define LB_( x ) { bb printf( "\n-> %s", x ); safe_ut.showSysCalls = 1 ;
#endif
/* public: */ void MsHtm :: prune_MS_htm
/* -----------------------------------------------------------------------------
Prune Microsoft HTML style definitions
-----------------------------------------------------------------------------
*/ (
char * from
, char * to
, char * str // not beyond this str
)
LB_("MsHtm.prune_MS_htm")
str_set store ;
rBuffer B( from, "" ); rB_( B, 0, "body>", 0 )
while ( B.find( 0, "mso-list:l", 0 ) )
{
char * c = B.z + B.a + 3 ; *c = '@' ; c[5] = ' ' ;
char * e = c + 7 ; to_( e, ';' ) *e = 0 ;
if ( ! store.element( c ) ) store.insert( c );
B.a = e+1 - B.z ;
}
store.insert( "-->" );
B.open_rBuffer( from, "" ); FILE * f = create( to );
rB_( B, 1, "<title>" , f )
rB_( B, 1, "<style>" , 0 )
rB_( B, 1, "@list" , f )
B.a -= 1 ;
while ( B.find( 1, store, 0 ) )
{
if ( B.z[ B.a ] == '-' )
{
rB_( B, 1, "<body", f )
rB_( B, 1, ">" , f ) fprintf( f, ">\n" ); break ;
}
rB_( B, 1, "}" , f ) B.a += 1 ;
fprintf( f, "}\n" );
}
close( f );
LE_
/* public: */ uint MsHtm :: split_MS_htm
/* -----------------------------------------------------------------------------
Split Microsoft HTML file, trenner = str
-----------------------------------------------------------------------------
*/ (
char * from
, char * str
, char * pre
, char * section[]
, str_set & store
)
LB_("MsHtm.split_MS_htm")
char * kopf = "\n<HEAD>"
"\n<LINK REL=\"stylesheet\" TYPE=\"text/css\" href=\"j2h.css\"><LINK></HEAD>"
"\n<BODY text=\"#000000\""
"\n link=\"\"#FF3333\" vlink=\"\"#FF3333\" alink=\"\"#0000FF\">"
"\n<font face=\"Arial,Verdana\" size=2>\n"
;
char * t1 = "\n<table"
"\n id='Header' border=0 cellpadding=0 cellspacing=0 width='100%'>"
"\n <tr><td><center><font size=\"4\">"
;
char * t2 = "\n</font></center></td></tr></table>"
;
if ( ! from || ! *from ) fErr
if ( ! str || ! *str ) fErr
if not_is_file( from ) ret( 0 )
char * kop = "__k_split_MS_htm" ; prune_MS_htm( from, kop, str );
int N = strlen( str );
rBuffer B( from, "" ); path fn ; uint i = 0 ;
BOOL mit132 = substr( "", B.z + B.a )? 1 : 0 ; _1( mit132 )
while ( B.find( 0, str, 0 ) )
{
s_( fn, "%s%i.htm", pre, ++i ); FILE * f = create( fn );
rBuffer K( kop, "" );
rB_( K, 0, "<head>", f ); fprintf( f, "\n%s", kopf );
rB_( K, 0, "<meta ", 0 ); K.copy_to( f );
// -----------------------------------------------------------------------
char n = '<' ; char * e ;
while ( n == '<' )
{
rB_( B, 1, ">", 0 );
e = B.z + B.a + 1 ; skip_space( e ); n = *e ;
}
char * c = e ; to_( e, '<' ) *e = 0 ;
char * m = e-1 ; while space( *m ) *( m-- ) = 0 ;
fprintf( f, "\n<a name=top></a>"
"\n<a href=1.htm>ALL</a>"
"\n<a href=tip%i.htm>previous</a>"
"\n<a href=tip%i.htm>next</a>"
, i+1, i-1 );
fprintf( f, "\n<a name=top></a><br/>%s%s%s<pre></pre>", t1, c, t2 );
section[i] = store.take( c );
B.a = e+1 - B.z ; rB_( B, 0, "</table>", 0 )
c = B.z + B.a + 8 ; skip_space( c ); *( --c ) = '\n' ;
B.a = c - B.z ;
// -----------------------------------------------------------------------
L1: if ( ! B.find( 0, str, f ) )
then {
close( f ); Unlink( fn ); i-- ;
}
else {
if ( B.z[ B.a + N ] == '(' )
{
// HTML Einschub (...) gefunden, mache ihn zu <...>
char * c = B.z + B.a + N + 1 ;
char * e = c ; to_( e, ')' ) *e = 0 ;
fprintf( f, "<%s>", c );
B.a = e+1 - B.z ; goto L1 ;
}
fprintf( f, "</p></body></html>" );
close( f );
}
}
Unlink( kop );
LE_ret( i )
#undef static
#endif