X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=hivex%2Fhivexml.c;h=90cb22bddfad5087d1c7d0f7992cc2ea2d898d35;hb=23e117d8cfb13647d52fa5037464936454351f0a;hp=af3de9e4746df666bdac9a1edc23440bf2021254;hpb=792c5283009ed6753239a14df9a6e9c71bea35fd;p=libguestfs.git diff --git a/hivex/hivexml.c b/hivex/hivexml.c index af3de9e..90cb22b 100644 --- a/hivex/hivexml.c +++ b/hivex/hivexml.c @@ -16,6 +16,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include + #include #include #include @@ -28,6 +30,15 @@ #include "hivex.h" +#ifdef HAVE_GETTEXT +#include "gettext.h" +#define _(str) dgettext(PACKAGE, (str)) +//#define N_(str) dgettext(PACKAGE, (str)) +#else +#define _(str) str +//#define N_(str) str +#endif + /* Callback functions. */ static int node_start (hive_h *, void *, hive_node_h, const char *name); static int node_end (hive_h *, void *, hive_node_h, const char *name); @@ -56,14 +67,18 @@ static struct hivex_visitor visitor = { #define XML_CHECK(proc, args) \ do { \ if ((proc args) == -1) { \ - fprintf (stderr, "%s: failed to write XML document\n", #proc); \ - exit (1); \ + fprintf (stderr, _("%s: failed to write XML document\n"), #proc); \ + exit (EXIT_FAILURE); \ } \ } while (0) int main (int argc, char *argv[]) { + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEBASEDIR); + textdomain (PACKAGE); + int c; int open_flags = 0; int visit_flags = 0; @@ -78,19 +93,19 @@ main (int argc, char *argv[]) break; default: fprintf (stderr, "hivexml [-dk] regfile > output.xml\n"); - exit (1); + exit (EXIT_FAILURE); } } if (optind + 1 != argc) { - fprintf (stderr, "hivexml: missing name of input file\n"); - exit (1); + fprintf (stderr, _("hivexml: missing name of input file\n")); + exit (EXIT_FAILURE); } hive_h *h = hivex_open (argv[optind], open_flags); if (h == NULL) { perror (argv[optind]); - exit (1); + exit (EXIT_FAILURE); } /* Note both this macro, and xmlTextWriterStartDocument leak memory. There @@ -102,8 +117,8 @@ main (int argc, char *argv[]) xmlTextWriterPtr writer; writer = xmlNewTextWriterFilename ("/dev/stdout", 0); if (writer == NULL) { - fprintf (stderr, "xmlNewTextWriterFilename: failed to create XML writer\n"); - exit (1); + fprintf (stderr, _("xmlNewTextWriterFilename: failed to create XML writer\n")); + exit (EXIT_FAILURE); } XML_CHECK (xmlTextWriterStartDocument, (writer, NULL, "utf-8", NULL)); @@ -111,19 +126,19 @@ main (int argc, char *argv[]) if (hivex_visit (h, &visitor, sizeof visitor, writer, visit_flags) == -1) { perror (argv[optind]); - exit (1); + exit (EXIT_FAILURE); } if (hivex_close (h) == -1) { perror (argv[optind]); - exit (1); + exit (EXIT_FAILURE); } XML_CHECK (xmlTextWriterEndElement, (writer)); XML_CHECK (xmlTextWriterEndDocument, (writer)); xmlFreeTextWriter (writer); - exit (0); + exit (EXIT_SUCCESS); } static int