summaryrefslogtreecommitdiff
path: root/src/test-man-parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test-man-parser.c')
-rw-r--r--src/test-man-parser.c49
1 files changed, 30 insertions, 19 deletions
diff --git a/src/test-man-parser.c b/src/test-man-parser.c
index 3b115430..38b38497 100644
--- a/src/test-man-parser.c
+++ b/src/test-man-parser.c
@@ -19,39 +19,50 @@
* Author: Shaun McCance <shaunm@gnome.org>
*/
-#include <libgnomevfs/gnome-vfs.h>
+#include <glib.h>
+#include <libxml/tree.h>
+
#include "yelp-man-parser.h"
-#include "yelp-utils.h"
+
+static gchar **files = NULL;
+static const GOptionEntry options[] = {
+ { G_OPTION_REMAINING,
+ 0, 0, G_OPTION_ARG_FILENAME_ARRAY,
+ &files, NULL, NULL },
+ { NULL }
+};
gint
main (gint argc, gchar **argv)
{
+ GOptionContext *context;
YelpManParser *parser;
- YelpDocInfo *doc_info;
- xmlDocPtr doc;
+ xmlDocPtr doc;
+ gchar *encoding;
+ gint i;
+
+ context = g_option_context_new ("FILES...");
+ g_option_context_add_main_entries (context, options, NULL);
+ g_option_context_parse (context, &argc, &argv, NULL);
- if (argc < 2) {
- g_error ("Usage: test-man-parser file\n");
+ if (files == NULL || files[0] == NULL) {
+ g_printerr ("Usage: test-man-parser [OPTION...] FILES...\n");
return 1;
}
- gnome_vfs_init ();
-
parser = yelp_man_parser_new ();
- doc_info = yelp_doc_info_get (argv[1], FALSE);
- if (!doc_info) {
- printf ("Failed to load URI: %s\n", argv[1]);
- return -1;
- }
- doc = yelp_man_parser_parse_doc (parser, doc_info);
- yelp_man_parser_free (parser);
+ encoding = (gchar *) g_getenv("MAN_ENCODING");
+ if (encoding == NULL)
+ encoding = "ISO-8859-1";
- xmlDocDump (stdout, doc);
- xmlFreeDoc (doc);
+ for (i = 0; files[i]; i++) {
+ doc = yelp_man_parser_parse_file (parser, files[i], encoding);
+ xmlDocDump (stdout, doc);
+ xmlFreeDoc (doc);
+ }
- gnome_vfs_shutdown ();
+ yelp_man_parser_free (parser);
return 0;
}
-