summaryrefslogtreecommitdiffstats
path: root/ipa-client/config.c
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2010-10-11 18:36:43 -0400
committerSimo Sorce <ssorce@redhat.com>2010-10-12 15:46:27 -0400
commitb735fc8d178ac32a3610f1c6e45a04ad5aa2845e (patch)
tree3614e3952d262e1a5f291403be6d055a5942a5cd /ipa-client/config.c
parentf9c0eb52224ec13f718e74413a7136ce00ed1250 (diff)
downloadfreeipa-b735fc8d178ac32a3610f1c6e45a04ad5aa2845e.tar.gz
freeipa-b735fc8d178ac32a3610f1c6e45a04ad5aa2845e.tar.xz
freeipa-b735fc8d178ac32a3610f1c6e45a04ad5aa2845e.zip
Initial gettext support for C utils
Add automatic creation of python an C file lists for potfiles Deletes useless copy of Makefile in install/po Remove duplicate maintainer-clean target Add debug target that prints file lists Unbreak update-po target, merges in patch from John
Diffstat (limited to 'ipa-client/config.c')
-rw-r--r--ipa-client/config.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/ipa-client/config.c b/ipa-client/config.c
index c32946ed6..69bd9cb33 100644
--- a/ipa-client/config.c
+++ b/ipa-client/config.c
@@ -37,6 +37,11 @@
#include <stdlib.h>
#include <ctype.h>
+#include <errno.h>
+#include "config.h"
+#include <libintl.h>
+#define _(STRING) gettext(STRING)
+
char *
read_config_file(const char *filename)
{
@@ -47,14 +52,14 @@ read_config_file(const char *filename)
fd = open(filename, O_RDONLY);
if (fd == -1) {
- fprintf(stderr, "cannot open configuration file %s\n", filename);
+ fprintf(stderr, _("cannot open configuration file %s\n"), filename);
return NULL;
}
/* stat() the file so we know the size and can pre-allocate the right
* amount of memory. */
if (fstat(fd, &st) == -1) {
- fprintf(stderr, "cannot stat() configuration file %s\n", filename);
+ fprintf(stderr, _("cannot stat() configuration file %s\n"), filename);
return NULL;
}
left = st.st_size;
@@ -67,7 +72,7 @@ read_config_file(const char *filename)
if (res == 0)
break;
if (res < 0) {
- fprintf(stderr, "read error\n");
+ fprintf(stderr, _("read error\n"));
close(fd);
free(dest);
return NULL;
@@ -159,3 +164,27 @@ get_config_entry(char * in_data, const char *section, const char *key)
free(data);
return NULL;
}
+
+int init_gettext(void)
+{
+ char *c;
+
+ c = setlocale(LC_ALL, "");
+ if (!c) {
+ return EIO;
+ }
+
+ errno = 0;
+ c = bindtextdomain(PACKAGE, LOCALEDIR);
+ if (c == NULL) {
+ return errno;
+ }
+
+ errno = 0;
+ c = textdomain(PACKAGE);
+ if (c == NULL) {
+ return errno;
+ }
+
+ return 0;
+}