/** * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to * license terms. Copyright © 2001 Sun Microsystems, Inc. * Some preexisting portions Copyright © 2001 Netscape Communications Corp. * All rights reserved. */ /* * htmlout.c -- routines to output HTML elements -- HTTP gateway * * Copyright (c) 1996 Netscape Communications Corp. * All rights reserved. */ #include "dsgw.h" #include "dbtdsgw.h" #define DSGW_POSTEDVARARG_NAME "name" static char* dsgw_change( char *s, dsgwsubst *changes ) { auto dsgwsubst *ch; if ( changes == NULL ) return s; for ( ch = changes; ch; ch = ch->dsgwsubst_next ) { if ( strstr( s, ch->dsgwsubst_from ) ) { break; } } if ( ch != NULL ) { auto char *cs = dsgw_ch_strdup( s ); for ( ch = changes; ch; ch = ch->dsgwsubst_next ) { auto const size_t from_len = strlen( ch->dsgwsubst_from ); auto const size_t to_len = strlen( ch->dsgwsubst_to ); auto const long change_len = to_len - from_len; auto char *p; for ( p = cs; (p = strstr( p, ch->dsgwsubst_from )) != NULL; p += to_len ) { if ( change_len ) { if ( change_len > 0 ) { /* allocate more space: */ auto const size_t offset = p - cs; cs = dsgw_ch_realloc( cs, strlen( cs ) + change_len + 1 ); p = cs + offset; } memmove( p + to_len, p + from_len, strlen( p + from_len ) + 1 ); } if ( to_len != 0 ) { memcpy( p, ch->dsgwsubst_to, to_len ); } } } return cs; } return s; } void dsgw_HTML_emits( char *s ) { auto char *sc = dsgw_change( s, gc->gc_changeHTML ); dsgw_emits( sc ); if ( sc != s ) free( sc ); } void dsgw_html_begin( char *title, int titleinbody ) { static int header_done = 0; if ( !header_done ) { dsgw_emits( "" ); dsgw_head_begin(); dsgw_emits( "\n" ); if ( title != NULL ) { dsgw_emitf( "
\n" "%s |
\n", title ); } header_done = 1; } void dsgw_html_end() { dsgw_emits( "