int
main (int argc, char** argv)
{
xml_g_set_prgname(argv[0]);
if (argc < 3)
{
g_printerr ("> %s filename xpath [options]\n"
"\t print the start/end offsets of the textarray\n"
"\t corresponding to the node referenced by the\n"
"\t given xpath argument (abbrivated form)\n",
g_get_prgname());
return 1;
} |
___ gchar *filename = 0;
const gchar *xpath = 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 (! xpath) { xpath = 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);
___ xml_GNode* node = xml_path_node (tree, xpath);
if (! node)
g_error ("node not found: %s\n", xpath);
___ int style = 0;
if (strstr (styleflag, "-text")) style = 1;
g_print ("%i/%i\n", node->off, node->end);
return 0;
____;____;____;____;
} |
|