[iwhd] maint: prohibit any use of atoi/atof
by Jim Meyering
commit 25936ccada783142c4a1036a8abe35b6aa8f8346
Author: Jim Meyering <meyering(a)redhat.com>
Date: Wed Mar 23 18:55:47 2011 +0100
maint: prohibit any use of atoi/atof
* cfg.mk (skip_low_priority): Now that the final use of atoi
is removed, enable the rule to prohibit new uses.
cfg.mk | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
---
diff --git a/cfg.mk b/cfg.mk
index 99261d4..0089d61 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -21,7 +21,6 @@ manual_title = GNU Grep: Print lines matching a pattern
skip_low_priority = \
sc_bindtextdomain \
sc_texinfo_acronym \
- sc_prohibit_atoi_atof \
sc_prohibit_tab_based_indentation \
sc_prohibit_strcmp \
sc_error_message_uppercase \
13 years, 1 month
[iwhd] iwhd: reject a provider that's specified with an invalid port number
by Jim Meyering
commit 9e91f71e071eee73620e288aa7eba0c2f8089bdc
Author: Jim Meyering <meyering(a)redhat.com>
Date: Wed Mar 23 18:54:42 2011 +0100
iwhd: reject a provider that's specified with an invalid port number
Before, due to our use of atoi, we would accept e.g., 2^32,
and treat it like 0. Similarly, 2^32+1 would be treated as 1.
* setup.c: Include "xstrtol.h".
(add_provider): Do not accept bogus port numbers.
Use xstrtol instead.
setup.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/setup.c b/setup.c
index 5a9144e..5e32387 100644
--- a/setup.c
+++ b/setup.c
@@ -35,6 +35,7 @@
#include "query.h"
#include "meta.h"
#include "xalloc.h"
+#include "xstrtol.h"
/*
* A config consists of a JSON array of objects, where each object includes:
@@ -398,7 +399,18 @@ add_provider (Hash_table *h)
goto fail;
prov->host = kv_hash_lookup(h,"host");
- prov->port = atoi(kv_hash_lookup(h,"port"));
+
+ char *port_str = kv_hash_lookup (h, "port");
+ if (port_str == NULL)
+ goto fail;
+
+ long int port;
+ if ( ! (xstrtol (port_str, NULL, 10, &port, "") == LONGINT_OK
+ && 0 < port && port <= INT_MAX))
+ goto fail;
+
+ prov->port = port;
+
/* TBD: change key/secret field names to username/password */
prov->username = kv_hash_lookup(h,"key");
prov->password = kv_hash_lookup(h,"secret");
13 years, 1 month
[iwhd] tests: plug long-standing leak in test-only parsing code
by Jim Meyering
commit 5e22c670786c5e8b6c03e3f160b892c23bd3a124
Author: Jim Meyering <meyering(a)redhat.com>
Date: Wed Mar 23 18:34:03 2011 +0100
tests: plug long-standing leak in test-only parsing code
* qparser.y [PARSER_UNIT_TEST] (unit_oget_func): Don't xstrdup
the returned value.
qparser.y | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/qparser.y b/qparser.y
index b6efb83..dbc6ce4 100644
--- a/qparser.y
+++ b/qparser.y
@@ -275,7 +275,7 @@ unit_oget_func (void * notused, const char *text)
for (i = 0; hacked_obj_fields[i].name; ++i) {
if (!strcmp(hacked_obj_fields[i].name,text)) {
- return xstrdup(hacked_obj_fields[i].value);
+ return hacked_obj_fields[i].value;
}
}
13 years, 1 month
[iwhd] maint: enable more compiler warnings
by Jim Meyering
commit a43cabcc703cad4d9b7b805e806b92dc7aebdd79
Author: Jim Meyering <meyering(a)redhat.com>
Date: Wed Mar 23 18:21:54 2011 +0100
maint: enable more compiler warnings
* configure.ac: Enable a few more warnings.
* qparser.y: Add missing initializers.
* rest.c (prov_fmt): Add a cast to avoid a compiler warning.
* template.c (tmpl_prov_entry): Likewise.
configure.ac | 4 +---
qparser.y | 13 +++++++------
rest.c | 2 +-
template.c | 2 +-
4 files changed, 10 insertions(+), 11 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 4513e4b..4f65407 100644
--- a/configure.ac
+++ b/configure.ac
@@ -134,9 +134,7 @@ if test "$gl_gcc_warnings" = yes; then
for w in $ws; do
gl_WARN_ADD([$w])
done
- gl_WARN_ADD([-Wno-unused])
- gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
- gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now
+ gl_WARN_ADD([-Wno-unused-function])
gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
# In spite of excluding -Wlogical-op above, it is enabled, as of
diff --git a/qparser.y b/qparser.y
index 1622f4a..b6efb83 100644
--- a/qparser.y
+++ b/qparser.y
@@ -259,11 +259,12 @@ paren_expr:
static const struct { char *name; char *value; } hacked_obj_fields[] = {
/* Fake object fields for generic unit testing. */
- { (char*) "a", (char*) "2" }, { (char*) "b", (char*) "7" },
+ { (char*) "a", (char*) "2" },
+ { (char*) "b", (char*) "7" },
{ (char*) "c", (char*) "11" },
/* This one's here to test links (e.g. $template.owner.name). */
{ (char*) "template", (char*) "templates/the_tmpl" },
- { NULL }
+ { NULL, NULL }
};
/* Fake out the eval code for unit testing. */
@@ -280,7 +281,7 @@ unit_oget_func (void * notused, const char *text)
return NULL;
}
-static const getter_t unit_oget = { unit_oget_func };
+static const getter_t unit_oget = { unit_oget_func, NULL };
/*
* Same as above, but the site-field stuff is so similar to the object-field
@@ -291,14 +292,14 @@ unit_sget_func (void * notused, const char *text)
{
return "never";
}
-static const getter_t unit_sget = { unit_sget_func };
+static const getter_t unit_sget = { unit_sget_func, NULL };
/* Fake links from an object/key tuple to an object/key string. */
static const struct { char *obj; char *key; char *value; } hacked_links[] = {
{ (char*) "templates/the_tmpl", (char*) "owner",
(char*) "users/the_user" },
{ (char*) "users/the_user", (char*) "name", (char*) "Jeff Darcy" },
- { NULL }
+ { NULL, NULL, NULL }
};
static char *
@@ -611,7 +612,7 @@ int
main (int argc, char **argv)
{
int fail = 0;
- unsigned int i;
+ int i;
GC_INIT ();
for (i = 1; i < argc; ++i)
{
diff --git a/rest.c b/rest.c
index 5932cf9..3dfea2b 100644
--- a/rest.c
+++ b/rest.c
@@ -1647,7 +1647,7 @@ prov_fmt (provider_t *prov, void *ms_v)
if (len < 0)
return 0; // tell iterator we've failed
- if (len < n_remaining) {
+ if ((size_t) len < n_remaining) {
ms->buf_n_used += len;
return 1;
}
diff --git a/template.c b/template.c
index 57e52ab..5eb51ed 100644
--- a/template.c
+++ b/template.c
@@ -286,7 +286,7 @@ tmpl_prov_entry (char *buf, size_t buf_len,
fmt += ctx->format->z_offset;
int size = snprintf(buf, buf_len, fmt,
name, type, host, port, user, pass);
- if (0 < size && size < buf_len)
+ if (0 < size && (size_t) size < buf_len)
ctx->index++;
return size;
13 years, 1 month
[iwhd] maint: remove now-unused definitions
by Jim Meyering
commit 6a2990e8902fcf795b1d2e978ca2c878b2ef2aa9
Author: Jim Meyering <meyering(a)redhat.com>
Date: Wed Mar 23 17:45:32 2011 +0100
maint: remove now-unused definitions
* state_defs.h (CLEANUP_AQUERY, CLEANUP_BUF_PTR): Remove definition.
(CLEANUP_CURL, CLEANUP_DICT, CLEANUP_POST, CLEANUP_QUERY): Likewise.
(CLEANUP_TMPL, CLEANUP_URL): Likewise.
state_defs.h | 9 ---------
1 files changed, 0 insertions(+), 9 deletions(-)
---
diff --git a/state_defs.h b/state_defs.h
index 70c62a9..77163a4 100644
--- a/state_defs.h
+++ b/state_defs.h
@@ -79,15 +79,6 @@ typedef struct _my_state {
int be_flags;
} my_state;
-#define CLEANUP_CURL 0x01 /* no longer needed */
-#define CLEANUP_BUF_PTR 0x02
-#define CLEANUP_POST 0x04
-#define CLEANUP_DICT 0x08
-#define CLEANUP_QUERY 0x10
-#define CLEANUP_TMPL 0x20
-#define CLEANUP_URL 0x40
-#define CLEANUP_AQUERY 0x80
-
#define BACKEND_GET_SIZE 0x01 /* used in put_child_func */
#endif
13 years, 1 month
[iwhd] make iwhd --version print copyright information
by Jim Meyering
commit c7f7127198e9f643d0065acb8a6d7c04d7361d28
Author: Jim Meyering <meyering(a)redhat.com>
Date: Tue Mar 22 14:06:58 2011 +0100
make iwhd --version print copyright information
* bootstrap.conf (gnulib_modules): Add propername.
Use version-etc, not version-etc-fsf.
* rest.c: Include "propername.h" and "version-etc.h".
(AUTHORS): Define.
(main): Use version_etc.
bootstrap.conf | 3 ++-
gnulib-tests/.gitignore | 14 ++++++++++++++
lib/.gitignore | 43 +++++++++++++++++++++++++++++++++++++++++++
rest.c | 16 +++++++++++++++-
4 files changed, 74 insertions(+), 2 deletions(-)
---
diff --git a/bootstrap.conf b/bootstrap.conf
index fa2ee98..f752c95 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -49,6 +49,7 @@ manywarnings
mkstemp
pipe-posix
progname
+propername
quote
quotearg
realloc-gnu
@@ -69,7 +70,7 @@ unlink
unlocked-io
update-copyright
useless-if-before-free
-version-etc-fsf
+version-etc
xalloc
xstrtoumax
'
diff --git a/gnulib-tests/.gitignore b/gnulib-tests/.gitignore
index aa44de9..4cad9b7 100644
--- a/gnulib-tests/.gitignore
+++ b/gnulib-tests/.gitignore
@@ -66,6 +66,9 @@
/test-btowc1.sh
/test-btowc2.sh
/test-c-ctype.c
+/test-c-strcase.sh
+/test-c-strcasecmp.c
+/test-c-strncasecmp.c
/test-copy-acl.c
/test-copy-acl.sh
/test-copy-file.c
@@ -88,9 +91,12 @@
/test-getopt_long.h
/test-gettimeofday.c
/test-hash.c
+/test-iconv-h.c
+/test-iconv.c
/test-ignore-value.c
/test-inttostr.c
/test-inttypes.c
+/test-iswblank.c
/test-locale.c
/test-localename.c
/test-lock.c
@@ -113,6 +119,11 @@
/test-mbrtowc4.sh
/test-mbsinit.c
/test-mbsinit.sh
+/test-mbsstr1.c
+/test-mbsstr2.c
+/test-mbsstr2.sh
+/test-mbsstr3.c
+/test-mbsstr3.sh
/test-memchr.c
/test-open.c
/test-open.h
@@ -139,6 +150,7 @@
/test-stdio.c
/test-stdlib.c
/test-strerror.c
+/test-striconv.c
/test-string.c
/test-strnlen.c
/test-strstr.c
@@ -171,6 +183,7 @@
/test-wcrtomb.sh
/test-wctype-h.c
/test-wctype.c
+/test-wcwidth.c
/test-xalloc-die.c
/test-xalloc-die.sh
/test-xstrtol.c
@@ -187,6 +200,7 @@
/unsetenv.c
/vasnprintf.c
/vasnprintf.h
+/version-etc-fsf.c
/wcrtomb.c
/wctob.c
/wctomb-impl.h
diff --git a/lib/.gitignore b/lib/.gitignore
index 157d3ba..46bb4a3 100644
--- a/lib/.gitignore
+++ b/lib/.gitignore
@@ -1,6 +1,8 @@
/acl-internal.h
/acl.h
/acl_entries.c
+/alloca.h
+/alloca.in.h
/arg-nonnull.h
/base64.c
/base64.h
@@ -11,6 +13,9 @@
/c++defs.h
/c-ctype.c
/c-ctype.h
+/c-strcase.h
+/c-strcasecmp.c
+/c-strncasecmp.c
/calloc.c
/charset.alias
/close-hook.c
@@ -56,6 +61,19 @@
/hash-pjw.h
/hash.c
/hash.h
+/iconv.h
+/iconv.in.h
+/iconv_open-aix.gperf
+/iconv_open-aix.h
+/iconv_open-hpux.gperf
+/iconv_open-hpux.h
+/iconv_open-irix.gperf
+/iconv_open-irix.h
+/iconv_open-osf.gperf
+/iconv_open-osf.h
+/iconv_open-solaris.gperf
+/iconv_open-solaris.h
+/iconv_open.c
/ignore-value.h
/intprops.h
/inttypes.h
@@ -66,8 +84,17 @@
/localcharset.h
/lstat.c
/malloc.c
+/malloca.c
+/malloca.h
+/malloca.valgrind
+/mbchar.c
+/mbchar.h
+/mbiter.h
/mbrtowc.c
/mbsinit.c
+/mbslen.c
+/mbsstr.c
+/mbuiter.h
/memchr.c
/memchr.valgrind
/mkstemp.c
@@ -75,6 +102,8 @@
/pipe.c
/progname.c
/progname.h
+/propername.c
+/propername.h
/quote.c
/quote.h
/quotearg.c
@@ -104,14 +133,19 @@
/stdlib.h
/stdlib.in.h
/stpcpy.c
+/str-kmp.h
/str-two-way.h
/streq.h
/strerror.c
+/striconv.c
+/striconv.h
/string.h
/string.in.h
/stripslash.c
/strndup.c
/strnlen.c
+/strnlen1.c
+/strnlen1.h
/strstr.c
/strtoimax.c
/strtok_r.c
@@ -130,8 +164,14 @@
/tempname.h
/time.h
/time.in.h
+/trim.c
+/trim.h
/unistd.h
/unistd.in.h
+/unitypes.h
+/unitypes.in.h
+/uniwidth.h
+/uniwidth.in.h
/unlink.c
/unlocked-io.h
/verify.h
@@ -143,10 +183,13 @@
/wchar.in.h
/wctype.h
/wctype.in.h
+/wcwidth.c
/write.c
/xalloc-die.c
/xalloc.h
/xmalloc.c
+/xstriconv.c
+/xstriconv.h
/xstrndup.c
/xstrndup.h
/xstrtol-error.c
diff --git a/rest.c b/rest.c
index be2f4f7..5932cf9 100644
--- a/rest.c
+++ b/rest.c
@@ -43,11 +43,19 @@
#include "meta.h"
#include "backend.h"
#include "setup.h"
+#include "propername.h"
#include "quote.h"
#include "replica.h"
#include "template.h"
#include "mpipe.h"
#include "state_defs.h"
+#include "version-etc.h"
+
+const char version_etc_copyright[] =
+ /* Do *not* mark this string for translation. %s is a copyright
+ symbol suitable for this locale, and %d is the copyright
+ year. */
+ "Copyright %s %d Red Hat, Inc.";
#if defined(DEBUG)
#define MY_MHD_FLAGS MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG
@@ -56,6 +64,11 @@
#define MY_MHD_FLAGS MHD_USE_THREAD_PER_CONNECTION
#endif
+#define AUTHORS \
+ proper_name ("Jeff Darcy"), \
+ proper_name ("Jim Meyering"), \
+ proper_name ("Pete Zaitcev")
+
/* Buffer size for MHD_create_post_processor, used to buffer and parse keys. */
enum { POST_BUF_SIZE = 4096 };
@@ -2320,7 +2333,8 @@ main (int argc, char **argv)
usage(EXIT_SUCCESS);
break;
case GETOPT_VERSION_CHAR:
- printf ("%s version %s\n", program_name, PACKAGE_VERSION);
+ version_etc (stdout, program_name, PACKAGE_NAME,
+ PACKAGE_VERSION, AUTHORS, (char *) NULL);
exit (EXIT_SUCCESS);
break;
13 years, 1 month
[iwhd] add internationalization
by Jim Meyering
commit a6731564f50feb7b40ee78fbc99c12e051fca981
Author: Jim Meyering <meyering(a)redhat.com>
Date: Mon Mar 21 18:19:11 2011 +0100
add internationalization
* configure.ac: Arrange to use gettext.
* Makefile.am (SUBDIRS): Add po.
* cfg.mk (skip_low_priority): Remove sc_unmarked_diagnostics.
This enables check for unmarked diagnostics.
* rest.c: Include "configmake.h".
(_): Remove temporary definition.
(main): Call setlocale, bindtextdomain and textdomain.
* iwh.h: Include <locale.h> and "gettext.h".
(textdomain, bindtextdomain) [! ENABLE_NLS]: Define away.
(_, N_): Define.
* po/POTFILES.in: New file.
* bootstrap.conf (buildreq): Record new build-from-clone
requirement: gettext version 0.17 or greater.
For now, don't try to download PO files from translationproject.org,
since there are none.
In all .c files and qparser.y:
Convert most uses like this:
error(0,0,"path too long in %s",__func__);
to this:
error(0,0,_("path too long in %s"),__func__);
Run this command:
perl -pi -e 's/(error ?\(.*, ?)("[^"]+")([,)])/${1}_($2)$3/' FILE ...
.gitignore | 7 ++--
Makefile.am | 4 +-
auto.c | 26 +++++++-------
backend.c | 110 ++++++++++++++++++++++++++++----------------------------
bootstrap.conf | 6 +++-
cfg.mk | 1 -
configure.ac | 4 ++
iwh.h | 12 ++++++
po/POTFILES.in | 16 ++++++++
qparser.y | 2 +-
replica.c | 18 +++++-----
rest.c | 25 +++++++------
setup.c | 66 +++++++++++++++++----------------
13 files changed, 169 insertions(+), 128 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index b64386c..fb871d5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@
*~
.\#*
.deps
+/ABOUT-NLS
/GNUmakefile
/aclocal.m4
/autom4te.cache/
@@ -18,12 +19,10 @@
/gnulib-tests
/iwhd
/iwhd-*.tar.gz
-/iwhd-*.tar.xz
/iwhd-*.tar.gz.sig
+/iwhd-*.tar.xz
/iwhd-*.tar.xz.sig
/iwhd-conf.js
-/qparser.c
-/qparser.h
/iwhd.init
/iwhd.spec
/m4/.gitignore
@@ -32,6 +31,8 @@
/parser-test
/parser-test.c
/qlexer.c
+/qparser.c
+/qparser.h
/stamp-h1
/t/*.log
ChangeLog
diff --git a/Makefile.am b/Makefile.am
index 099f3fc..8fe1f88 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -17,7 +17,7 @@ AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
AM_YFLAGS = -d
-SUBDIRS = lib . gnulib-tests t man
+SUBDIRS = lib . gnulib-tests t man po
ACLOCAL_AMFLAGS = -I m4
# iwhd is short for Image WareHouse Daemon.
@@ -131,7 +131,7 @@ uninstall-local:
$(DESTDIR)$(sysconfdir)/iwhd/conf.js
rmdir $(DESTDIR)$(DEFAULT_FS_DIR)
-AM_CPPFLAGS = $(HAIL_CFLAGS) -I$(top_srcdir)/lib
+AM_CPPFLAGS = $(HAIL_CFLAGS) -Ilib -I$(top_srcdir)/lib
iwhd_LDADD = \
lib/libiwhd.a \
-lgc -lpthread \
diff --git a/auto.c b/auto.c
index 50eb1c5..5e0f0c0 100644
--- a/auto.c
+++ b/auto.c
@@ -55,16 +55,16 @@ auto_mkdir (const char *name)
if (mkdir(name, 0777) < 0) {
if (errno == EEXIST) {
if (stat(name, &statb) < 0) {
- error (0, errno, "stat %s failed", name);
+ error (0, errno, _("stat %s failed"), name);
return -1;
}
if (!S_ISDIR(statb.st_mode)) {
- error (0, 0, "path %s is not a directory",name);
+ error (0, 0, _("path %s is not a directory"),name);
return -1;
}
return 0;
}
- error(0, errno, "Cannot create %s", name);
+ error(0, errno, _("Cannot create %s"), name);
return -1;
}
return 0;
@@ -103,23 +103,23 @@ auto_spawn (const char *prog, char *argv[])
* This serves no security purpose but only makes stderr more tidy.
*/
if (stat(prog, &statb) < 0) {
- error (0, errno, "stat %s failed", prog);
+ error (0, errno, _("stat %s failed"), prog);
return -1;
}
if (!S_ISREG(statb.st_mode)) {
- error (0, 0, "path %s is not a regular file", prog);
+ error (0, 0, _("path %s is not a regular file"), prog);
return -1;
}
pid = fork();
if (pid < 0) {
- error (0, errno, "fork failed");
+ error (0, errno, _("fork failed"));
return -1;
}
if (pid == 0) {
execvp(prog, argv);
- error (EXIT_FAILURE, errno, "failed to run command %s", prog);
+ error (EXIT_FAILURE, errno, _("failed to run command %s"), prog);
}
/*
@@ -156,7 +156,7 @@ auto_test_mongod(void)
sfd = socket(addr.a.sa_family, SOCK_STREAM, 0);
if (sfd < 0) {
- error(0, errno, "socket");
+ error(0, errno, _("socket"));
return -1;
}
@@ -184,7 +184,7 @@ auto_wait_mongod(void)
if (rc == 0)
break;
if (time(NULL) >= start_time + 20) {
- error(0, 0, "failed to verify mongod using port %s",
+ error(0, 0, _("failed to verify mongod using port %s"),
auto_arg_port);
return -1;
}
@@ -228,7 +228,7 @@ auto_set_sig (void)
sigaction(SIGFPE, &actb, NULL) ||
sigaction(SIGBUS, &actb, NULL) ||
sigaction(SIGABRT, &actb, NULL)) {
- error(0, errno, "sigaction");
+ error(0, errno, _("sigaction"));
return -1;
}
return 0;
@@ -264,8 +264,8 @@ auto_start (int dbport)
* We abort because we do not want anyone listening there.
*/
if (rc == 0) {
- error (0, 0, "something is listening on port %s,"
- " not auto-starting Mongo", auto_arg_port);
+ error (0, 0, _("something is listening on port %s,"
+ " not auto-starting Mongo"), auto_arg_port);
return -1;
}
@@ -287,7 +287,7 @@ auto_start (int dbport)
return -1;
}
if (atexit(auto_stop) != 0) {
- error (0, 0, "atexit failed for auto_stop");
+ error (0, 0, _("atexit failed for auto_stop"));
auto_kill_mongod(SIGTERM);
return -1;
}
diff --git a/backend.c b/backend.c
index c3a91a9..ad6da01 100644
--- a/backend.c
+++ b/backend.c
@@ -220,7 +220,7 @@ s3_init (provider_t *prov)
chars = snprintf(svc_acc,sizeof(svc_acc),"%s:%u",prov->host,prov->port);
if (chars >= (int)sizeof(svc_acc)) {
- error(0,0,"hostname %s too long in %s",prov->host,__func__);
+ error(0,0,_("hostname %s too long in %s"),prov->host,__func__);
return;
}
hstor = hstor_new(svc_acc,prov->host,prov->username,prov->password);
@@ -272,7 +272,7 @@ s3_put_child (void * ctx)
llen = strtoll(clen,NULL,10);
}
else {
- error (0, 0, "missing Content-Length");
+ error (0, 0, _("missing Content-Length"));
}
}
@@ -334,7 +334,7 @@ s3_init_tmpfile (const char *value)
fd = mkstemp(path);
if (fd < 0) {
- error (0, errno, "%s: failed to create file from template", path);
+ error (0, errno, _("%s: failed to create file from template"), path);
free(path);
return NULL;
}
@@ -345,7 +345,7 @@ s3_init_tmpfile (const char *value)
close(fd);
if (written != (ssize_t)len) {
if (written < 0) {
- error (0, errno, "failed to write to %s", path);
+ error (0, errno, _("failed to write to %s"), path);
}
else {
error (0, errno,
@@ -409,7 +409,7 @@ s3_register (my_state *ms, const provider_t *prov, const char *next,
if (!api_key) {
api_key = (char *)prov->username;
if (!api_key) {
- error (0, 0, "missing EC2 API key");
+ error (0, 0, _("missing EC2 API key"));
goto cleanup;
}
}
@@ -418,7 +418,7 @@ s3_register (my_state *ms, const provider_t *prov, const char *next,
if (!api_secret) {
api_secret = (char *)prov->password;
if (!prov->password) {
- error (0, 0, "missing EC2 API secret");
+ error (0, 0, _("missing EC2 API secret"));
goto cleanup;
}
}
@@ -433,7 +433,7 @@ s3_register (my_state *ms, const provider_t *prov, const char *next,
else {
ami_cert = get_provider_value(prov,"ami-cert");
if (!ami_cert) {
- error (0, 0, "missing EC2 AMI cert");
+ error (0, 0, _("missing EC2 AMI cert"));
goto cleanup;
}
}
@@ -448,7 +448,7 @@ s3_register (my_state *ms, const provider_t *prov, const char *next,
else {
ami_key = get_provider_value(prov,"ami-key");
if (!ami_key) {
- error (0, 0, "missing EC2 AMI key");
+ error (0, 0, _("missing EC2 AMI key"));
goto cleanup;
}
}
@@ -457,7 +457,7 @@ s3_register (my_state *ms, const provider_t *prov, const char *next,
if (!ami_uid) {
ami_uid = get_provider_value(prov,"ami-uid");
if (!ami_uid) {
- error (0, 0, "missing EC2 AMI uid");
+ error (0, 0, _("missing EC2 AMI uid"));
goto cleanup;
}
}
@@ -501,13 +501,13 @@ s3_register (my_state *ms, const provider_t *prov, const char *next,
DPRINTF("ami-bkt = %s\n",ami_bkt);
if (pipe(organ) < 0) {
- error (0, errno, "pipe creation failed");
+ error (0, errno, _("pipe creation failed"));
goto cleanup;
}
pid = fork();
if (pid < 0) {
- error (0, errno, "fork failed");
+ error (0, errno, _("fork failed"));
close(organ[0]);
close(organ[1]);
goto cleanup;
@@ -517,13 +517,13 @@ s3_register (my_state *ms, const provider_t *prov, const char *next,
(void)dup2(organ[1],STDOUT_FILENO);
(void)dup2(organ[1],STDERR_FILENO);
execvp(cmd, (char* const*)argv);
- error (EXIT_FAILURE, errno, "failed to run command %s", cmd);
+ error (EXIT_FAILURE, errno, _("failed to run command %s"), cmd);
}
close(organ[1]);
fp = fdopen(organ[0],"r");
if (!fp) {
- error (0, 0, "could not open parent pipe stream");
+ error (0, 0, _("could not open parent pipe stream"));
close(organ[0]);
goto cleanup;
}
@@ -550,15 +550,15 @@ s3_register (my_state *ms, const provider_t *prov, const char *next,
DPRINTF("waiting for child...\n");
if (waitpid(pid,&wstat,0) < 0) {
- error (0, errno, "waitpid failed");
+ error (0, errno, _("waitpid failed"));
goto cleanup;
}
if (!WIFEXITED(wstat)) {
- error (0, 0, "%s is killed (status 0x%x)", cmd, wstat);
+ error (0, 0, _("%s is killed (status 0x%x)"), cmd, wstat);
goto cleanup;
}
if (WEXITSTATUS(wstat)) {
- error (0, 0, "%s exited with code %d",
+ error (0, 0, _("%s exited with code %d"),
cmd, WEXITSTATUS(wstat));
goto cleanup;
}
@@ -620,7 +620,7 @@ curl_get_child (void * ctx)
prov->host, prov->port, ms->url);
}
if (chars >= (int)sizeof(fixed)) {
- error(0,0,"path too long in %s",__func__);
+ error(0,0,_("path too long in %s"),__func__);
return NULL;
}
curl_easy_setopt(curl,CURLOPT_URL,fixed);
@@ -660,7 +660,7 @@ curl_put_child (void * ctx)
llen = strtoll(clen,NULL,10);
}
else {
- error (0, 0, "missing Content-Length");
+ error (0, 0, _("missing Content-Length"));
}
}
@@ -680,7 +680,7 @@ curl_put_child (void * ctx)
chars = snprintf(fixed,sizeof(fixed),
"http://%s:%u/%s/%s",prov->host,prov->port,ms->bucket,ms->key);
if (chars >= (int)sizeof(fixed)) {
- error(0,0,"path too long in %s",__func__);
+ error(0,0,_("path too long in %s"),__func__);
return NULL;
}
curl_easy_setopt(curl,CURLOPT_URL,fixed);
@@ -726,7 +726,7 @@ curl_cache_child (void * ctx)
chars = snprintf(fixed,sizeof(fixed),
"http://%s:%u%s",prov->host,prov->port,ms->url);
if (chars >= (int)sizeof(fixed)) {
- error(0,0,"path too long in %s",__func__);
+ error(0,0,_("path too long in %s"),__func__);
return NULL;
}
curl_easy_setopt(curl,CURLOPT_URL,fixed);
@@ -767,7 +767,7 @@ curl_delete (const provider_t *prov, const char *bucket, const char *key,
chars = snprintf(fixed,sizeof(fixed),
"http://%s:%u%s",prov->host,prov->port,url);
if (chars >= (int)sizeof(fixed)) {
- error(0,0,"path too long in %s",__func__);
+ error(0,0,_("path too long in %s"),__func__);
return MHD_HTTP_INTERNAL_SERVER_ERROR;
}
curl_easy_setopt(curl,CURLOPT_URL,fixed);
@@ -788,13 +788,13 @@ curl_bcreate (const provider_t *prov, const char *bucket)
chars = snprintf(addr,sizeof(addr),"http://%s:%d/%s",
prov->host,prov->port,bucket);
if (chars >= (int)sizeof(addr)) {
- error(0,0,"path too long in %s",__func__);
+ error(0,0,_("path too long in %s"),__func__);
return MHD_HTTP_INTERNAL_SERVER_ERROR;
}
curl = curl_easy_init();
if (!curl) {
- error(0,errno,"no memory in %s",__func__);
+ error(0,errno,_("no memory in %s"),__func__);
return MHD_HTTP_INTERNAL_SERVER_ERROR;
}
curl_easy_setopt(curl,CURLOPT_URL,addr);
@@ -836,7 +836,7 @@ curl_register (my_state *ms, const provider_t *prov, const char *next,
chars = snprintf(fixed,sizeof(fixed),"http://%s:%d/%s/%s",
prov->host,prov->port, ms->bucket, ms->key);
if (chars >= (int)sizeof(fixed)) {
- error(0,0,"path too long in %s",__func__);
+ error(0,0,_("path too long in %s"),__func__);
return MHD_HTTP_INTERNAL_SERVER_ERROR;
}
curl_easy_setopt(curl,CURLOPT_URL,fixed);
@@ -932,7 +932,7 @@ cf_add_token (struct curl_slist *in_slist, const char *token)
chars = snprintf(auth_hdr,sizeof(auth_hdr),"X-Auth-Token: %s",token);
if (chars >= (int)sizeof(auth_hdr)) {
- error(0,0,"auth_hdr too long");
+ error(0,0,_("auth_hdr too long"));
return in_slist;
}
@@ -956,21 +956,21 @@ cf_init (provider_t *prov)
chars = snprintf(addr,sizeof(addr),"https://%s:%u/v1.0",
prov->host, prov->port);
if (chars >= (int)sizeof(addr)) {
- error(0,0,"API URL too long in %s",__func__);
+ error(0,0,_("API URL too long in %s"),__func__);
return;
}
chars = snprintf(auth_user,sizeof(auth_user),"X-Auth-User: %s",
prov->username);
if (chars >= (int)sizeof(auth_user)) {
- error(0,0,"auth_user too long in %s",__func__);
+ error(0,0,_("auth_user too long in %s"),__func__);
return;
}
chars = snprintf(auth_key,sizeof(auth_key),"X-Auth-Key: %s",
prov->password);
if (chars >= (int)sizeof(auth_key)) {
- error(0,0,"auth_key too long in %s",__func__);
+ error(0,0,_("auth_key too long in %s"),__func__);
return;
}
@@ -1020,7 +1020,7 @@ cf_get_child (void * ctx)
}
chars = snprintf(fixed,sizeof(fixed),"%s%s", prov->host, ms->url);
if (chars >= (int)sizeof(fixed)) {
- error(0,0,"path too long in %s",__func__);
+ error(0,0,_("path too long in %s"),__func__);
return NULL;
}
curl_easy_setopt(curl,CURLOPT_URL,fixed);
@@ -1067,7 +1067,7 @@ cf_put_child (void * ctx)
llen = strtoll(clen,NULL,10);
}
else {
- error (0, 0, "missing Content-Length");
+ error (0, 0, _("missing Content-Length"));
}
}
@@ -1081,7 +1081,7 @@ cf_put_child (void * ctx)
chars = snprintf(fixed,sizeof(fixed),
"%s/%s/%s",prov->host,ms->bucket,ms->key);
if (chars >= (int)sizeof(fixed)) {
- error(0,0,"path too long in %s",__func__);
+ error(0,0,_("path too long in %s"),__func__);
return NULL;
}
curl_easy_setopt(curl,CURLOPT_URL,fixed);
@@ -1127,7 +1127,7 @@ cf_delete (const provider_t *prov,
chars = snprintf(fixed,sizeof(fixed),"%s%s",prov->host,url);
if (chars >= (int)sizeof(fixed)) {
- error(0,0,"path too long in %s",__func__);
+ error(0,0,_("path too long in %s"),__func__);
return MHD_HTTP_INTERNAL_SERVER_ERROR;
}
curl_easy_setopt(curl,CURLOPT_URL,fixed);
@@ -1174,7 +1174,7 @@ cf_bcreate (const provider_t *prov, const char *bucket)
}
chars = snprintf(fixed,sizeof(fixed),"%s/%s",prov->host,bucket);
if (chars >= (int)sizeof(fixed)) {
- error(0,0,"path too long in %s",__func__);
+ error(0,0,_("path too long in %s"),__func__);
return MHD_HTTP_INTERNAL_SERVER_ERROR;
}
curl_easy_setopt(curl,CURLOPT_URL,fixed);
@@ -1201,7 +1201,7 @@ fs_init (provider_t *prov)
{
DPRINTF("changing directory to %s\n",prov->path);
if (chdir(prov->path) < 0) {
- error(0,errno,"chdir failed, unsafe to continue");
+ error(0,errno,_("chdir failed, unsafe to continue"));
exit(!0); /* Value doesn't matter, as long as it's not zero. */
}
}
@@ -1230,7 +1230,7 @@ fs_get_child (void * ctx)
bytes = read(fd,buf,sizeof(buf));
if (bytes <= 0) {
if (bytes < 0) {
- error (0, errno, "%s: read failed", file);
+ error (0, errno, _("%s: read failed"), file);
}
break;
}
@@ -1259,11 +1259,11 @@ fs_put_child (void * ctx)
chars = snprintf(fixed,sizeof(fixed),"%s/%s",ms->bucket,ms->key);
if (chars >= (int)sizeof(fixed)) {
- error(0,0,"path too long in %s",__func__);
+ error(0,0,_("path too long in %s"),__func__);
return NULL;
}
if (unlink(fixed) < 0) {
- error(0,errno,"unlink failed for %s (non-fatal)",fixed);
+ error(0,errno,_("unlink failed for %s (non-fatal)"),fixed);
}
fd = open(fixed,O_WRONLY|O_CREAT|O_EXCL,0666);
if (fd < 0) {
@@ -1281,7 +1281,7 @@ fs_put_child (void * ctx)
ps->data_len-offset);
if (bytes <= 0) {
if (bytes < 0) {
- error (0, errno, "%s: write failed",
+ error (0, errno, _("%s: write failed"),
fixed);
pipe_cons_signal(pp, errno);
}
@@ -1310,7 +1310,7 @@ fs_delete (const provider_t *prov, const char *bucket, const char *key,
(void)key;
if (unlink(url+1) < 0) {
- error (0, errno, "%s: failed to unlink", url+1);
+ error (0, errno, _("%s: failed to unlink"), url+1);
return MHD_HTTP_NOT_FOUND;
}
@@ -1325,7 +1325,7 @@ fs_bcreate (const provider_t *prov, const char *bucket)
DPRINTF("creating bucket %s\n",bucket);
if (mkdir(bucket,0750) < 0) {
- error (0, errno, "%s: failed to create directory", bucket);
+ error (0, errno, _("%s: failed to create directory"), bucket);
return MHD_HTTP_INTERNAL_SERVER_ERROR;
}
/*
@@ -1392,7 +1392,7 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
api_url = kv_hash_lookup(args,"api-url");
if (!api_url) {
/* TBD: This has to have a defined field in provider, too. */
- error (0, 0, "missing RHEV-M API URL (api-url)");
+ error (0, 0, _("missing RHEV-M API URL (api-url)"));
goto cleanup;
}
@@ -1400,7 +1400,7 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
if (!api_user) {
api_user = (char *)prov->username;
if (!api_user) {
- error (0, 0, "missing RHEV-M API username (api-key)");
+ error (0, 0, _("missing RHEV-M API username (api-key)"));
goto cleanup;
}
}
@@ -1409,7 +1409,7 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
if (!api_secret) {
api_secret = (char *)prov->password;
if (!prov->password) {
- error (0, 0, "missing RHEV-M API secret (api-secret)");
+ error (0, 0, _("missing RHEV-M API secret (api-secret)"));
goto cleanup;
}
}
@@ -1427,15 +1427,15 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
nfs_path = kv_hash_lookup(args,"nfs-path");
nfs_dir = kv_hash_lookup(args,"nfs-dir");
if (!nfs_host) {
- error (0, 0, "missing export domain's host (nfs-host)");
+ error (0, 0, _("missing export domain's host (nfs-host)"));
goto cleanup;
}
if (!nfs_path) {
- error (0, 0, "missing export domain's path (nfs-path)");
+ error (0, 0, _("missing export domain's path (nfs-path)"));
goto cleanup;
}
if (!nfs_dir) {
- error (0, 0, "missing target directory (nfs-dir)");
+ error (0, 0, _("missing target directory (nfs-dir)"));
goto cleanup;
}
@@ -1454,12 +1454,12 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
nfs_host, nfs_path, nfs_dir
);
if (rc < 0) {
- error (0, 0, "no core");
+ error (0, 0, _("no core"));
goto cleanup;
}
conf_name = s3_init_tmpfile(conf_text);
if (!conf_name) {
- error (0, 0, "cannot create a temporary file");
+ error (0, 0, _("cannot create a temporary file"));
goto cleanup;
}
@@ -1474,13 +1474,13 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
argv[argc] = NULL;
if (pipe(organ) < 0) {
- error (0, errno, "pipe creation failed");
+ error (0, errno, _("pipe creation failed"));
goto cleanup;
}
pid = fork();
if (pid < 0) {
- error (0, errno, "fork failed");
+ error (0, errno, _("fork failed"));
close(organ[0]);
close(organ[1]);
goto cleanup;
@@ -1490,13 +1490,13 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
(void)dup2(organ[1],STDOUT_FILENO);
(void)dup2(organ[1],STDERR_FILENO);
execvp(cmd, (char* const*)argv);
- error (EXIT_FAILURE, errno, "failed to run command %s", cmd);
+ error (EXIT_FAILURE, errno, _("failed to run command %s"), cmd);
}
close(organ[1]);
fp = fdopen(organ[0],"r");
if (!fp) {
- error (0, 0, "could not open parent pipe stream");
+ error (0, 0, _("could not open parent pipe stream"));
close(organ[0]);
goto cleanup;
}
@@ -1522,15 +1522,15 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
DPRINTF("waiting for child...\n");
if (waitpid(pid,&wstat,0) < 0) {
- error (0, errno, "waitpid failed");
+ error (0, errno, _("waitpid failed"));
goto cleanup;
}
if (!WIFEXITED(wstat)) {
- error (0, 0, "%s is killed (status 0x%x)", cmd, wstat);
+ error (0, 0, _("%s is killed (status 0x%x)"), cmd, wstat);
goto cleanup;
}
if (WEXITSTATUS(wstat)) {
- error (0, 0, "%s exited with code %d",
+ error (0, 0, _("%s exited with code %d"),
cmd, WEXITSTATUS(wstat));
goto cleanup;
}
diff --git a/bootstrap.conf b/bootstrap.conf
index 930ebda..fa2ee98 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -99,7 +99,7 @@ autoconf 2.62
automake 1.11.1
autopoint -
bison -
-gettext -
+gettext 0.17
git 1.4.4
gzip -
rsync -
@@ -113,3 +113,7 @@ bootstrap_epilogue()
sed 's,\.\./\.\.,..,g' $m > $m-t
mv -f $m-t $m
}
+
+# FIXME: this is just temporary
+# Tell bootstrap not to download PO files from translationproject.org.
+SKIP_PO=t
diff --git a/cfg.mk b/cfg.mk
index 93dfc5d..99261d4 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -24,7 +24,6 @@ skip_low_priority = \
sc_prohibit_atoi_atof \
sc_prohibit_tab_based_indentation \
sc_prohibit_strcmp \
- sc_unmarked_diagnostics \
sc_error_message_uppercase \
sc_cast_of_argument_to_free \
sc_file_system
diff --git a/configure.ac b/configure.ac
index e00e6b5..4513e4b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -170,11 +170,15 @@ if test "$gl_gcc_warnings" = yes; then
AC_SUBST([GNULIB_TEST_WARN_CFLAGS])
fi
+AM_GNU_GETTEXT([external], [need-ngettext])
+AM_GNU_GETTEXT_VERSION([0.17])
+
AC_CONFIG_FILES([
Makefile
gnulib-tests/Makefile
lib/Makefile
man/Makefile
t/Makefile
+po/Makefile.in
])
AC_OUTPUT
diff --git a/iwh.h b/iwh.h
index e8cf710..565cf4f 100644
--- a/iwh.h
+++ b/iwh.h
@@ -70,4 +70,16 @@ GLOBAL(const char *, me, "here");
int auto_start (int dbport);
+#include <locale.h>
+#include "gettext.h"
+#if ! ENABLE_NLS
+# undef textdomain
+# define textdomain(Domainname) /* empty */
+# undef bindtextdomain
+# define bindtextdomain(Domainname, Dirname) /* empty */
+#endif
+
+#define _(msgid) gettext (msgid)
+#define N_(msgid) msgid
+
#include "gc-wrap.h"
diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644
index 0000000..24f87a8
--- /dev/null
+++ b/po/POTFILES.in
@@ -0,0 +1,16 @@
+auto.c
+backend.c
+lib/closeout.c
+lib/copy-acl.c
+lib/copy-file.c
+lib/error.c
+lib/getopt.c
+lib/quotearg.c
+lib/set-mode-acl.c
+lib/version-etc.c
+lib/xalloc-die.c
+lib/xstrtol-error.c
+qparser.y
+replica.c
+rest.c
+setup.c
diff --git a/qparser.y b/qparser.y
index bd82f07..1622f4a 100644
--- a/qparser.y
+++ b/qparser.y
@@ -396,7 +396,7 @@ parse (const char *text)
{
yyscan_t scanner;
if (yylex_init (&scanner))
- error (0, errno, "failed to initialize query parser");
+ error (0, errno, _("failed to initialize query parser"));
YY_BUFFER_STATE buf = yy_scan_string (text, scanner);
value_t *result = NULL;
value_t *r = yyparse (scanner, &result) == 0 ? result : NULL;
diff --git a/replica.c b/replica.c
index c7bcff6..40d6355 100644
--- a/replica.c
+++ b/replica.c
@@ -111,14 +111,14 @@ repl_worker_del (const repl_item *item)
bucket = strdup(item->path);
if (!bucket) {
- error(0,errno,"ran out of memory replicating delete for %s",
+ error(0,errno,_("ran out of memory replicating delete for %s"),
item->path);
return;
}
key = strchr(bucket,'/');
if (!key) {
- error(0,0,"invalid path replicating delete for %s",item->path);
+ error(0,0,_("invalid path replicating delete for %s"),item->path);
return;
}
++key;
@@ -126,7 +126,7 @@ repl_worker_del (const repl_item *item)
rc = item->server->func_tbl->delete_func(item->server,
bucket, key, item->path);
if (rc != MHD_HTTP_OK) {
- error(0,0,"got status %d replicating delete for %s",
+ error(0,0,_("got status %d replicating delete for %s"),
rc, item->path);
}
@@ -140,7 +140,7 @@ repl_worker_bcreate (repl_item *item)
rc = item->server->func_tbl->bcreate_func(item->server,item->path);
if (rc != MHD_HTTP_OK) {
- error(0,0,"got status %d replicating bcreate for %s",
+ error(0,0,_("got status %d replicating bcreate for %s"),
rc, item->path);
}
@@ -199,7 +199,7 @@ repl_worker (void *notused ATTRIBUTE_UNUSED)
repl_worker_bcreate(item);
break;
default:
- error(0,0,"bad repl type %d (url=%s) skipped",
+ error(0,0,_("bad repl type %d (url=%s) skipped"),
item->type, item->path);
}
@@ -274,7 +274,7 @@ replicate (const char *url, size_t size, const char *policy, my_state *ms)
url2 = strdup(url);
if (!url2) {
- error(0,0,"could not parse url %s",url);
+ error(0,0,_("could not parse url %s"),url);
return;
}
qctx.cur_bucket = strtok_r(url2,"/",&stctx);
@@ -325,14 +325,14 @@ replicate (const char *url, size_t size, const char *policy, my_state *ms)
DPRINTF("REPLICATING %s to %s\n",url,prov->name);
item = malloc(sizeof(*item));
if (!item) {
- error(0,errno,"could not create repl_item for %s",
+ error(0,errno,_("could not create repl_item for %s"),
url);
break;
}
item->type = REPL_PUT;
item->path = strdup(url);
if (!item->path) {
- error(0,errno,"could not create repl_item for %s",
+ error(0,errno,_("could not create repl_item for %s"),
url);
break;
}
@@ -376,7 +376,7 @@ replicate_namespace_action (const char *name, repl_t action, my_state *ms)
name, prov->name);
repl_item *item = malloc(sizeof(*item));
if (!item) {
- error(0,errno,"could not create repl_item for %s",
+ error(0,errno,_("could not create repl_item for %s"),
name);
return;
}
diff --git a/rest.c b/rest.c
index 9a55428..be2f4f7 100644
--- a/rest.c
+++ b/rest.c
@@ -34,6 +34,7 @@
#include <hstor.h> /* only for ARRAY_SIZE at this point */
#include <curl/curl.h>
+#include "configmake.h" /* for LOCALEDIR */
#include "dirname.h"
#include "iwh.h"
#include "closeout.h"
@@ -48,9 +49,6 @@
#include "mpipe.h"
#include "state_defs.h"
-/* Define-away for now. Eventually, define to gettext. */
-#define _(msgid) (msgid)
-
#if defined(DEBUG)
#define MY_MHD_FLAGS MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG
//#define MY_MHD_FLAGS MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG
@@ -1830,7 +1828,7 @@ proxy_primary_prov (void *cctx, struct MHD_Connection *conn, const char *url,
bool valid = strcmp (url, "/_providers/_primary") == 0;
unsigned int rc = (valid ? MHD_HTTP_OK : MHD_HTTP_BAD_REQUEST);
if (!valid)
- error (0, 0, "invalid request: %s", url);
+ error (0, 0, _("invalid request: %s"), url);
const char *name = get_main_provider()->name;
struct MHD_Response *resp;
@@ -1865,18 +1863,18 @@ proxy_set_primary (void *cctx, struct MHD_Connection *conn, const char *url,
Extract NAME: */
bool valid = memcmp (url, "/_providers/", strlen("/_providers/")) == 0;
if (!valid) {
- error (0, 0, "invalid request: %s", url);
+ error (0, 0, _("invalid request: %s"), url);
goto bad_set;
}
const char *start = url + strlen("/_providers/");
const char *slash = strchr (start, '/');
if (slash == NULL) {
- error (0, 0, "invalid request: %s", url);
+ error (0, 0, _("invalid request: %s"), url);
goto bad_set;
}
name = strndup (start, slash - start);
if (name == NULL) {
- error (0, errno, "failed to extract provider name: %s", url);
+ error (0, errno, _("failed to extract provider name: %s"), url);
goto bad_set;
}
@@ -2281,7 +2279,12 @@ main (int argc, char **argv)
bool autostart = false;
set_program_name (argv[0]);
+ setlocale (LC_ALL, "");
+ bindtextdomain (PACKAGE, LOCALEDIR);
+ textdomain (PACKAGE);
+
atexit (close_stdout);
+
GC_INIT ();
for (;;) switch (getopt_long(argc,argv,"ac:d:m:p:v",my_options,NULL)) {
@@ -2339,7 +2342,7 @@ args_done:
}
if (autostart && cfg_file) {
- error(0,0,"do not use -c and -a simultaneously");
+ error(0,0,_("do not use -c and -a simultaneously"));
return !0;
}
else if (autostart && !cfg_file) {
@@ -2352,12 +2355,12 @@ args_done:
else if (!autostart && cfg_file) {
me = parse_config(cfg_file);
if (!me) {
- error(0,0,"could not parse %s",cfg_file);
+ error(0,0,_("could not parse %s"),cfg_file);
return !0;
}
}
else {
- error(0,0,"specify at least -c or -a");
+ error(0,0,_("specify at least -c or -a"));
usage (EXIT_FAILURE);
}
@@ -2374,7 +2377,7 @@ args_done:
printf("will listen on port %u\n",my_port);
printf("my location is \"%s\"\n",me);
if (fflush(stdout) || ferror(stdout))
- error(EXIT_FAILURE, 0, "write failed");
+ error(EXIT_FAILURE, 0, _("write failed"));
}
backend_init();
diff --git a/setup.c b/setup.c
index c1791f7..5a9144e 100644
--- a/setup.c
+++ b/setup.c
@@ -117,7 +117,7 @@ validate_provider (Hash_table *h)
assert (name);
const char *type = kv_hash_lookup (h, "type");
if (type == NULL) {
- error (0, 0, "provider %s has no type", name);
+ error (0, 0, _("provider %s has no type"), name);
return 0;
}
@@ -129,7 +129,7 @@ validate_provider (Hash_table *h)
} else if (!strcasecmp(type,"fs")) {
needs = NEED_PATH;
} else {
- error (0, 0, "provider %s has invalid type: %s", name, type);
+ error (0, 0, _("provider %s has invalid type: %s"), name, type);
return 0;
}
@@ -137,17 +137,18 @@ validate_provider (Hash_table *h)
if (needs & NEED_SERVER) {
const char *host = kv_hash_lookup (h, "host");
if (!host) {
- error (0, 0, "%s: %s-provider requires a host", name, type);
+ error (0, 0, _("%s: %s-provider requires a host"), name, type);
ok = 0;
}
const char *port = kv_hash_lookup (h, "port");
if (!port) {
- error (0, 0, "%s: %s-provider requires a port", name, type);
+ error (0, 0, _("%s: %s-provider requires a port"), name, type);
ok = 0;
}
// ensure port is a positive integer with 5 or fewer digits
if (5 < strlen (port) || strcspn (port, "0123456789")) {
- error (0, 0, "%s: %s-provider: invalid port: %s", name, type, port);
+ error (0, 0, _("%s: %s-provider: invalid port: %s"),
+ name, type, port);
ok = 0;
}
}
@@ -155,12 +156,12 @@ validate_provider (Hash_table *h)
if (needs & NEED_CREDS) {
const char *key = kv_hash_lookup (h, "key");
if (!key) {
- error (0, 0, "%s: %s-provider requires a key", name, type);
+ error (0, 0, _("%s: %s-provider requires a key"), name, type);
ok = 0;
}
const char *secret = kv_hash_lookup (h, "secret");
if (!secret) {
- error (0, 0, "%s: %s-provider requires a secret", name, type);
+ error (0, 0, _("%s: %s-provider requires a secret"), name, type);
ok = 0;
}
}
@@ -168,7 +169,7 @@ validate_provider (Hash_table *h)
if (needs & NEED_PATH) {
const char *path = kv_hash_lookup (h, "path");
if (!path) {
- error (0, 0, "%s: %s-provider requires a path", name, type);
+ error (0, 0, _("%s: %s-provider requires a path"), name, type);
ok = 0;
}
}
@@ -187,20 +188,20 @@ json_validate_server (unsigned int i)
server = json_array_get(config,i);
if (!json_is_object(server)) {
- error(0,0,"config elem %u: missing object",i);
+ error(0,0,_("config elem %u: missing object"),i);
return 0;
}
elem = json_object_get(server,"name");
if (!json_is_string(elem)) {
- error(0,0,"config elem %u: missing name",i);
+ error(0,0,_("config elem %u: missing name"),i);
return 0;
}
name = json_string_value(elem);
elem = json_object_get(server,"type");
if (!json_is_string(elem)) {
- error(0,0,"config elem %u (%s): missing type",i,name);
+ error(0,0,_("config elem %u (%s): missing type"),i,name);
return 0;
}
type = json_string_value(elem);
@@ -215,20 +216,20 @@ json_validate_server (unsigned int i)
needs = NEED_PATH;
}
else {
- error(0,0,"config elem %u (%s): bad type",i,name);
+ error(0,0,_("config elem %u (%s): bad type"),i,name);
return 0;
}
if (needs & NEED_SERVER) {
elem = json_object_get(server,"host");
if (!json_is_string(elem)) {
- error(0,0,"config elem %u (%s): missing host",
+ error(0,0,_("config elem %u (%s): missing host"),
i,name);
return 0;
}
elem = json_object_get(server,"port");
if (!json_is_integer(elem)) {
- error(0,0,"config elem %u (%s): missing port",
+ error(0,0,_("config elem %u (%s): missing port"),
i,name);
return 0;
}
@@ -237,13 +238,13 @@ json_validate_server (unsigned int i)
if (needs & NEED_CREDS) {
elem = json_object_get(server,"key");
if (!json_is_string(elem)) {
- error(0,0,"config elem %u (%s): missing key",
+ error(0,0,_("config elem %u (%s): missing key"),
i, name);
return 0;
}
elem = json_object_get(server,"secret");
if (!json_is_string(elem)) {
- error(0,0, "config elem %u (%s): missing secret",
+ error(0,0, _("config elem %u (%s): missing secret"),
i, name);
return 0;
}
@@ -252,7 +253,7 @@ json_validate_server (unsigned int i)
if (needs & NEED_PATH) {
elem = json_object_get(server,"path");
if (!json_is_string(elem)) {
- error(0,0,"config elem %u (%s): missing path",
+ error(0,0,_("config elem %u (%s): missing path"),
i, name);
return 0;
}
@@ -341,7 +342,7 @@ convert_provider (int i, provider_t *out)
iter = json_object_iter(server);
while (iter) {
key = json_object_iter_key(iter);
- error(0,0,"convert-provider: ITER key: %s",key);
+ error(0,0,_("convert-provider: ITER key: %s"),key);
if (!is_reserved_attr(key)) {
value = json_string_value(json_object_iter_value(iter));
if (value) {
@@ -352,12 +353,12 @@ convert_provider (int i, provider_t *out)
if (!kv_hash_insert_new (out->attrs,
xstrdup((char *)key),
(char *)value)) {
- error (0, 0, "exhausted virtual memory");
+ error (0, 0, _("exhausted virtual memory"));
return 0;
}
}
else {
- error(0,0,"could not extract %u.%s",i,key);
+ error(0,0,_("could not extract %u.%s"),i,key);
}
}
iter = json_object_iter_next(server,iter);
@@ -438,12 +439,12 @@ add_provider (Hash_table *h)
if (!is_reserved_attr(key)) {
if (val) {
- error(0,0,"no value for %s", key);
+ error(0,0,_("no value for %s"), key);
continue;
}
DPRINTF("%p.%s = %s\n",prov, key, val);
if (!kv_hash_insert_new (prov->attrs, xstrdup(key), xstrdup(val)))
- error (0, 0, "exhausted virtual memory");
+ error (0, 0, _("exhausted virtual memory"));
goto fail;
}
}
@@ -469,7 +470,7 @@ parse_config_inner (void)
const char *primary = NULL;
if (json_typeof(config) != JSON_ARRAY) {
- error(0,0,"config should be a JSON array");
+ error(0,0,_("config should be a JSON array"));
goto err;
}
@@ -490,27 +491,27 @@ parse_config_inner (void)
prov_hash = hash_initialize (SMALL_PRIME, NULL, hash_provider,
compare_providers, NULL);
if (!prov_hash) {
- error(0,0,"could not allocate provider hash");
+ error(0,0,_("could not allocate provider hash"));
goto err;
}
for (i = 0; i < nservers; ++i) {
server = json_array_get(config,i);
if (!server) {
- error(0,0,"could not get pointer to provider %u",i);
+ error(0,0,_("could not get pointer to provider %u"),i);
goto err_free_hash;
}
new_key = dup_json_string(server,"name");
if (!new_key) {
- error(0,errno,"could not copy key %u",i);
+ error(0,errno,_("could not copy key %u"),i);
goto err_free_hash;
}
new_prov = (provider_t *)malloc(sizeof(*new_prov));
if (!new_prov) {
- error(0,errno,"could not allocate provider %u",i);
+ error(0,errno,_("could not allocate provider %u"),i);
goto err_free_hash;
}
if (!convert_provider(i,new_prov)) {
- error(0,0,"could not add provider %u",i);
+ error(0,0,_("could not add provider %u"),i);
}
assert (STREQ (new_key, new_prov->name));
hash_insert_new(prov_hash, new_prov);
@@ -552,13 +553,13 @@ parse_config (char *cfg_file)
}
if (access(cfg_file,R_OK) < 0) {
- error(0,errno,"failed to open %s for reading", cfg_file);
+ error(0,errno,_("failed to open %s for reading"), cfg_file);
return NULL;
}
config = json_load_file(cfg_file,&err);
if (!config) {
- error(0,0,"JSON error on line %d: %s",err.line,err.text);
+ error(0,0,_("JSON error on line %d: %s"),err.line,err.text);
return NULL;
}
@@ -589,7 +590,7 @@ auto_config(void)
config = json_loads(auto_json,&err);
if (!config) {
- error(0, 0, "JSON error on line %d: %s", err.line, err.text);
+ error(0, 0, _("JSON error on line %d: %s"), err.line, err.text);
return NULL;
}
@@ -598,7 +599,8 @@ auto_config(void)
printf("auto-start in effect\n");
}
else {
- error(0, 0, "invalid autostart configuration (internal error)");
+ error(0, 0,
+ _("invalid autostart configuration (internal error)"));
}
json_decref(config);
13 years, 1 month
[iwhd] build: avoid spurious syntax-check failure
by Jim Meyering
commit f6eb514d72eb655f52262eb72706ba4153fa5e96
Author: Jim Meyering <meyering(a)redhat.com>
Date: Mon Mar 21 17:43:41 2011 +0100
build: avoid spurious syntax-check failure
* cfg.mk (exclude_file_name_regexp--sc_prohibit_test_double_equal):
Exempt use of "==" in t/parse-test from otherwise-failing syntax check.
cfg.mk | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
---
diff --git a/cfg.mk b/cfg.mk
index dfa067b..93dfc5d 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -64,6 +64,7 @@ sc_prohibit_emacs__indent_tabs_mode__setting:
odt = ^doc/image_repo\.odt$
exclude_file_name_regexp--sc_trailing_blank = $(odt)
exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF = $(odt)
+exclude_file_name_regexp--sc_prohibit_test_double_equal = ^t/parse-test$$
update-copyright-env = \
UPDATE_COPYRIGHT_USE_INTERVALS=1 \
13 years, 1 month
[iwhd] enable #if-0'd asprintf-using code to avoid snprintf truncation risk
by Jim Meyering
commit 9584be5a22320649e0fe55fe80d663baf81d6247
Author: Jim Meyering <meyering(a)redhat.com>
Date: Mon Mar 21 10:08:08 2011 +0100
enable #if-0'd asprintf-using code to avoid snprintf truncation risk
* backend.c (fs_rhevm_register): Don't initialize "conf_text"
to NULL or set it to NULL after a failed asprintf call.
Neither is needed with garbage collection.
Remove #if-0, to use asprintf, not snprintf.
Remove explicit free of conf_text. GC will take care of it.
backend.c | 26 +-------------------------
1 files changed, 1 insertions(+), 25 deletions(-)
---
diff --git a/backend.c b/backend.c
index 5b2fd40..c3a91a9 100644
--- a/backend.c
+++ b/backend.c
@@ -1349,7 +1349,7 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
char *nfs_path;
char *nfs_dir;
const char *conf_name = NULL;
- char *conf_text = NULL;
+ char *conf_text;
int ret = MHD_HTTP_BAD_REQUEST;
int rc;
const char *argv[12];
@@ -1439,7 +1439,6 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
goto cleanup;
}
-#if 0 /* The GC library crashes on free() in this case. */
rc = asprintf(&conf_text,
"{\n"
" \"image\" : \"%s/%s\",\n"
@@ -1455,31 +1454,9 @@ fs_rhevm_register (my_state *ms, const provider_t *prov, const char *next,
nfs_host, nfs_path, nfs_dir
);
if (rc < 0) {
- conf_text = NULL;
error (0, 0, "no core");
goto cleanup;
}
-#else
- conf_text = malloc(1000);
- if (!conf_text) {
- error (0, 0, "no core");
- goto cleanup;
- }
- snprintf(conf_text, 1000,
- "{\n"
- " \"image\" : \"%s/%s\",\n"
- " \"apiurl\" : \"%s\",\n"
- " \"apiuser\" : \"%s\",\n"
- " \"apipass\" : \"%s\",\n"
- " \"nfshost\" : \"%s\",\n"
- " \"nfspath\" : \"%s\",\n"
- " \"nfsdir\" : \"%s\"\n"
- "}\n",
- ms->bucket, ms->key,
- api_url, api_user, api_secret,
- nfs_host, nfs_path, nfs_dir
- );
-#endif
conf_name = s3_init_tmpfile(conf_text);
if (!conf_name) {
error (0, 0, "cannot create a temporary file");
@@ -1568,7 +1545,6 @@ cleanup:
if (conf_name)
unlink(conf_name);
free((char *)conf_name);
- free(conf_text);
(void)meta_set_value(ms->bucket,ms->key,"ami-id",ami_id_buf);
return ret;
13 years, 1 month
[iwhd] tests: skip annoyingly long gnulib lock tests
by Jim Meyering
commit 8aa5b7111e46db425414ae33d5c07cef411e4630
Author: Jim Meyering <meyering(a)redhat.com>
Date: Mon Mar 21 09:45:01 2011 +0100
tests: skip annoyingly long gnulib lock tests
* bootstrap.conf (avoided_gnulib_modules): Skip the lock tests.
They take too long.
bootstrap.conf | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/bootstrap.conf b/bootstrap.conf
index c64c7ac..930ebda 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -15,6 +15,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# The lock test takes too long for my taste.
+avoided_gnulib_modules='
+ --avoid=lock-tests
+ --avoid=dummy
+'
+
# gnulib modules used by this package.
gnulib_modules='
announce-gen
13 years, 1 month