#include "xml/from-txt.h"
#include "xml/pathnode.h"
#include "xml/gerror.h"
#include <stdlib.h>
#include <string.h>

#define ___ {
#define ____ }

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

    if (argc < 3)
    
{
	g_printerr ("> %s filename offsetnumber [offsetnumber2] [options]\n"
		   "\t print the xpath corresponding to the position index\n"
		   "\t in the textarray as parsed from the xml file.\n"
		   "\t style-options: -strict | -canon | -match\n",
		   g_get_prgname());
	return 1;
    }
___ gchar *filename = 0; const gchar *offset1 = 0, *offset2 = 0, *styleflag = "";
{   int i ; for (i=1; i < argc ; i++) 
{
	if (argv[i][0] == '-') 
{ styleflag = argv[i]; continue; }
if (! filename)
{ filename = argv[i]; continue; }
if (! offset1)
{ offset1 = argv[i]; continue; }
if (! offset2)
{ offset2 = argv[i]; continue; }
g_warning ("extra argument on commandline, ignored: %s", argv[i]); }
}
___ xml_GNode* tree; GError* error = 0; tree = xml_g_markup_parse_file (0, filename, &error); if (error) xml_g_show_error (&error, "after parsing file:\n\t'%s'", filename); ___ gsize off = strtol (offset1, 0, 0); ___ xml_GNode* node = xml_tree_find_node (tree, off); if (! node) g_error ("[%i] (not found)\n", off); if (offset2)
{
	gsize off2 = strtol (offset2, 0, 0);
	if (off2 > off)
	    node = xml_tree_find_node2 (tree, off, off2);
	if (! node)
	    g_error ("[%i] (not found)\n", off);
    }
___ int style = 0; if (strstr (styleflag, "-match")) style = xml_path_MATCH; if (strstr (styleflag, "-strict")) style = xml_path_STRICT; if (strstr (styleflag, "-canon")) style = xml_path_CANON; ___ gchar* xpath = xml_path_strdup (tree, node, style); if (! xpath) g_error ("[%i] unable make it an xpath (a bug!)\n", off); g_print ("[%i] %s\n", off, xpath); g_free (xpath); return 0; ____;____;____;____;____;____; }
/* 
   Local variables:
   c-file-style: "stroustrup"
   End:
 */