X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=hivex%2Fhivexget.c;h=4f2419c4706d922978b8290d4efeb9ab586b3eb4;hb=d583e4dfe1322891b080db074f75b50f1d0f3f60;hp=04c854f11f9742f075761721ff11a22cdd30575b;hpb=770d1ecad2d3e46cd467b9bc3c024210ae2d8d46;p=hivex.git diff --git a/hivex/hivexget.c b/hivex/hivexget.c index 04c854f..4f2419c 100644 --- a/hivex/hivexget.c +++ b/hivex/hivexget.c @@ -27,32 +27,48 @@ #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 + +enum { EXIT_NOT_FOUND = 2 }; + int main (int argc, char *argv[]) { + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEBASEDIR); + textdomain (PACKAGE); + if (argc < 3 || argc > 4) { - fprintf (stderr, "hivexget regfile path [key]\n"); - exit (1); + fprintf (stderr, _("hivexget regfile path [key]\n")); + exit (EXIT_FAILURE); } + char *file = argv[1]; char *path = argv[2]; char *key = argv[3]; /* could be NULL */ if (path[0] != '\\') { - fprintf (stderr, "hivexget: path must start with a \\ character\n"); - exit (1); + fprintf (stderr, _("hivexget: path must start with a \\ character\n")); + exit (EXIT_FAILURE); } if (path[1] == '\\') { doubled: - fprintf (stderr, "hivexget: %s: \\ characters in path are doubled - are you escaping the path parameter correctly?\n", path); - exit (1); + fprintf (stderr, _("%s: %s: \\ characters in path are doubled - are you escaping the path parameter correctly?\n"), "hivexget", path); + exit (EXIT_FAILURE); } hive_h *h = hivex_open (file, 0); if (h == NULL) { error: perror (file); - exit (1); + exit (EXIT_FAILURE); } /* Navigate to the desired node. */ @@ -80,9 +96,9 @@ main (int argc, char *argv[]) if (errno) goto error; /* else node not found */ - fprintf (stderr, "hivexget: %s: %s: path element not found\n", + fprintf (stderr, _("hivexget: %s: %s: path element not found\n"), path, p); - exit (2); + exit (EXIT_NOT_FOUND); } p = pnext; @@ -102,8 +118,8 @@ main (int argc, char *argv[]) if (errno) goto error; /* else key not found */ - fprintf (stderr, "hivexget: %s: key not found\n", key); - exit (2); + fprintf (stderr, _("%s: %s: key not found\n"), "hivexget", key); + exit (EXIT_NOT_FOUND); } /* Print the value. */ @@ -264,5 +280,5 @@ main (int argc, char *argv[]) if (hivex_close (h) == -1) goto error; - exit (0); + exit (EXIT_SUCCESS); }