#include "xml/from-txt.h"
#include "xml/from-xmf.h"
#include "xml/dumptree.h"
#include "xml/pcss-src.h"
#include "xml/pcss-proc.h"
#include "xml/gerror.h"
#include <string.h>

#define ___ {
#define ____ }

int
main (int argc, char** argv)
{
    xml_g_set_prgname(argv[0]); 

    if (argc < 4)
    
{
	g_printerr ("> %s outputype xmlfile cssfile [options]\n"
		    "\t the program reads a cssfile and xmlfile to\n"
		    "\t their internal format and transform the xml \n"
		    "\t according to the specs in the hCSS text.\n"
		    "\t The generation defaults are set according to\n"
		    "\t the outputtype given - often 'html' or 'xml'\n"
		    "\t or their subtypes like 'docbook'.\n"
		    "\t options: -hidden -empty\n",
		    g_get_prgname());
	return 1;
    }
___ gchar *outputtype = 0, *css_file = 0, *xml_file = 0; const gchar *styleflag = "";
{   int i ; for (i=1; i < argc ; i++) 
{
        if (argv[i][0] == '-') 
{ styleflag = argv[i]; continue; }
if (! outputtype)
{ outputtype = argv[i]; continue; }
if (! xml_file)
{ xml_file = argv[i]; continue; }
if (! css_file)
{ css_file = argv[i]; continue; }
g_warning ("extra argument on commandline, ignored: %s", argv[i]); }
}
___ xml_GNode* css_node, *xml_node; GError* error = 0; css_node = xml_tree_node_from_file (0, css_file, &error); if (error) xml_g_show_error (&error, "after parsing file:\n\t'%s'", css_file); xml_node = xml_g_parse_file (0, xml_file, &error); if (error) xml_g_show_error (&error, "after parsing file:\n\t'%s'", xml_file); css_node = xml_pcss_parse (css_node); xml_node = xml_pcss_rename_proc (xml_node, css_node, 0); ___ GString* g = g_string_new (0); if (strstr (outputtype, "html"))
{
	g_string_append (g, "<html><head><style>\n");
	g_string_append_len (g, css_node->text->str, css_node->text->len);
	g_string_append (g, "</style>\n</head><body>\n");
	xml_tree_dump_to_xml (xml_node, g, 
			      1|xml_tree_dump_to_xml_flags (styleflag));
	g_string_append (g, "</body></html>");
    }
else
{
	g_string_append (g, "<"); 
	g_string_append (g, outputtype);
	g_string_append (g, "><style><!--\n");
	g_string_append_len (g, css_node->text->str, css_node->text->len);
	g_string_append (g, "--></style>\n");
	xml_tree_dump_to_xml (xml_node, g, 
			      1|xml_tree_dump_to_xml_flags (styleflag));
	g_string_append (g, "</"); 
	g_string_append (g, outputtype);
	g_string_append (g, ">\n");
    }
xml_g_string_to_file (g, 0); g_string_free (g, 1); return 0; ____;____;____; }
/* 
   Local variables:
   c-file-style: "stroustrup"
   End:
 */