int
main (int argc, char** argv)
{
xml_g_set_prgname (argv[0]);
if (argc < 4)
{
g_printerr ("> %s filename markupname offsetnumber [offsetnumber2]\n"
"\t add a markup in the given textarray positions.\n"
"\t if that would make for an invalid nesting then the\n"
"\t request will be rejected\n",
g_get_prgname());
return 1;
} |
___ gchar *filename = 0;
const gchar *markup = 0, *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 (! markup) { markup = 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);
if (! offset2) offset2 = offset1;
___ gsize off1, off2;
off1 = strtol (offset1, 0, 0);
off2 = strtol (offset2, 0, 0);
if (strstr (styleflag, "-outer"))
{
if (! xml_tree_adds (tree, markup, off1, off2))
{
g_printerr ("# impossible!\n");
return 2;
} |
} | else
{
if (! xml_tree_add (tree, markup, off1, off2))
{
g_printerr ("# impossible!\n");
return 2;
} |
} |
___ GString* dump = xml_tree_node_to_xml (tree, 0);
if (! dump || ! dump->str) {
g_warning ("could not dump tree from internals");
return 2;
} |
xml_g_string_to_file (dump, 0);
g_string_free (dump, 1);
return 0;
____;____;____;____;
} |
|