aboutsummaryrefslogtreecommitdiff
path: root/gacopyz
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2007-05-13 15:21:02 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2007-05-13 15:21:02 +0000
commit113cb4b143f63e18f2cbab9f0abec0ef453fbbd8 (patch)
tree8d8ccc1d6196e5570953033cbed3189a8111196a /gacopyz
parent06aae065b5b5ccf3ae1e4350f97d0ed0a2658501 (diff)
downloadmailfromd-113cb4b143f63e18f2cbab9f0abec0ef453fbbd8.tar.gz
mailfromd-113cb4b143f63e18f2cbab9f0abec0ef453fbbd8.tar.bz2
Mailfromd goes international
git-svn-id: file:///svnroot/mailfromd/trunk@1428 7a8a7f39-df28-0410-adc6-e0d955640f24
Diffstat (limited to 'gacopyz')
-rw-r--r--gacopyz/Makefile.am1
-rw-r--r--gacopyz/gacopyz.c204
-rw-r--r--gacopyz/gacopyz_priv.h23
-rw-r--r--gacopyz/io.c56
-rw-r--r--gacopyz/proc.c14
-rw-r--r--gacopyz/server.c136
-rw-r--r--gacopyz/smfi.c2
7 files changed, 238 insertions, 198 deletions
diff --git a/gacopyz/Makefile.am b/gacopyz/Makefile.am
index fa793e82..8747d0c6 100644
--- a/gacopyz/Makefile.am
+++ b/gacopyz/Makefile.am
@@ -33,6 +33,7 @@ libgacopyz_a_SOURCES = \
EXTRA_DIST=trans.tab trans.awk
BUILT_SOURCES=trans.h
+INCLUDES=-I$(top_srcdir)/lib
trans.h: ${top_srcdir}/gacopyz/trans.tab ${top_srcdir}/gacopyz/trans.awk
$(AWK) -f ${top_srcdir}/gacopyz/trans.awk \
diff --git a/gacopyz/gacopyz.c b/gacopyz/gacopyz.c
index 81ed394d..05a25e6f 100644
--- a/gacopyz/gacopyz.c
+++ b/gacopyz/gacopyz.c
@@ -20,10 +20,10 @@
#define TRACE(conn,cmd,size,buf) do { \
gacopyz_log(conn, SMI_LOG_DEBUG, \
- "send header: size=%lu, cmd=%c", \
+ _("send header: size=%lu, cmd=%c"),\
size, cmd); \
gacopyz_logdump(conn, SMI_LOG_DEBUG, \
- "send data", buf, size); \
+ _("send data"), buf, size); \
} while (0)
int
@@ -37,8 +37,8 @@ gacopyz_init(gacopyz_conn_t *pconn, struct smfiDesc *desc)
len = strlen(name);
if (desc->xxfi_version != SMFI_VERSION) {
gacopyz_logmsg(SMI_LOG_ERR,
- "smfi_register: %s: version mismatch; "
- "application %d != implementation %d",
+ _("smfi_register: %s: version mismatch; "
+ "application %d != implementation %d"),
name, desc->xxfi_version, SMFI_VERSION);
return MI_FAILURE;
}
@@ -47,7 +47,8 @@ gacopyz_init(gacopyz_conn_t *pconn, struct smfiDesc *desc)
if (!conn) {
gacopyz_logmsg(SMI_LOG_ERR,
- "smfi_register: %s: not enough memory", name);
+ "smfi_register: %s: %s", name,
+ strerror(errno));
return MI_FAILURE;
}
@@ -130,7 +131,7 @@ parse_connection(gacopyz_conn_t conn,
int rc = gacopyz_parse_connection(cstr, pproto, pport, ppath);
if (rc)
gacopyz_log(conn, SMI_LOG_ERR,
- "parse_connection: not enough memory");
+ "parse_connection: %s", strerror(ENOMEM));
return rc;
}
@@ -140,7 +141,7 @@ cleanup_unix_socket(gacopyz_conn_t conn, void *data)
{
if (unlink(data) && errno != ENOENT)
gacopyz_log(conn, SMI_LOG_ERR,
- "%s: %s: cannot unlink: %s",
+ _("%s: %s: cannot unlink: %s"),
conn->desc.xxfi_name, (char*)data,
strerror(errno));
free(data);
@@ -166,8 +167,8 @@ do_connect(gacopyz_conn_t conn,
if (port) {
gacopyz_log(conn, SMI_LOG_ERR,
- "%s: invalid connection type: %s; "
- "port is meaningless for UNIX sockets",
+ _("%s: invalid connection type: %s; "
+ "port is meaningless for UNIX sockets"),
conn->desc.xxfi_name, cstr);
return -1;
}
@@ -175,7 +176,7 @@ do_connect(gacopyz_conn_t conn,
if (strlen(path) > sizeof addr.sun.sun_path) {
errno = EINVAL;
gacopyz_log(conn, SMI_LOG_ERR,
- "%s: %s: UNIX socket name too long",
+ _("%s: %s: UNIX socket name too long"),
conn->desc.xxfi_name, path);
return -1;
}
@@ -190,22 +191,22 @@ do_connect(gacopyz_conn_t conn,
conn->cleanup_data = strdup(path);
} else {
gacopyz_log(conn, SMI_LOG_ERR,
- "%s: %s: cannot stat socket: %s",
- conn->desc.xxfi_name, path,
- strerror(errno));
+ _("%s: %s: cannot stat socket: %s"),
+ conn->desc.xxfi_name, path,
+ strerror(errno));
return -1;
}
} else {
/* FIXME: Check permissions? */
if (!S_ISSOCK(st.st_mode)) {
gacopyz_log(conn, SMI_LOG_ERR,
- "%s: %s: not a socket",
- conn->desc.xxfi_name, path);
+ _("%s: %s: not a socket"),
+ conn->desc.xxfi_name, path);
return -1;
}
if (rmsocket && unlink(path)) {
gacopyz_log(conn, SMI_LOG_ERR,
- "%s: %s: cannot unlink: %s",
+ _("%s: %s: cannot unlink: %s"),
conn->desc.xxfi_name, path,
strerror(errno));
return -1;
@@ -222,9 +223,9 @@ do_connect(gacopyz_conn_t conn,
if (!port) {
gacopyz_log(conn, SMI_LOG_ERR,
- "%s: invalid connection type: %s; "
- "missing port number",
- conn->desc.xxfi_name, cstr);
+ _("%s: invalid connection type: %s; "
+ "missing port number"),
+ conn->desc.xxfi_name, cstr);
return -1;
}
@@ -232,8 +233,8 @@ do_connect(gacopyz_conn_t conn,
if (*p == 0) {
if (num != pnum) {
gacopyz_log(conn, SMI_LOG_ERR,
- "%s: invalid connection type: %s; "
- "bad port number",
+ _("%s: invalid connection type: %s; "
+ "bad port number"),
conn->desc.xxfi_name, cstr);
return -1;
}
@@ -242,8 +243,8 @@ do_connect(gacopyz_conn_t conn,
struct servent *sp = getservbyname(path, "tcp");
if (!sp) {
gacopyz_log(conn, SMI_LOG_ERR,
- "%s: invalid connection type: %s; "
- "unknown port name",
+ _("%s: invalid connection type: %s; "
+ "unknown port name"),
conn->desc.xxfi_name, cstr);
return -1;
}
@@ -256,8 +257,8 @@ do_connect(gacopyz_conn_t conn,
struct hostent *hp = gethostbyname(path);
if (!hp) {
gacopyz_log(conn, SMI_LOG_ERR,
- "%s: Unknown host name %s",
- conn->desc.xxfi_name, path);
+ _("%s: Unknown host name %s"),
+ conn->desc.xxfi_name, path);
return -1;
}
addr.sa.sa_family = hp->h_addrtype;
@@ -269,15 +270,15 @@ do_connect(gacopyz_conn_t conn,
default:
gacopyz_log(conn, SMI_LOG_ERR,
- "%s: invalid connection type: %s; "
- "unsupported address family",
+ _("%s: invalid connection type: %s; "
+ "unsupported address family"),
conn->desc.xxfi_name, cstr);
return -1;
}
}
} else {
gacopyz_log(conn, SMI_LOG_ERR,
- "%s: unsupported protocol: %s",
+ _("%s: unsupported protocol: %s"),
conn->desc.xxfi_name, proto);
return -1;
}
@@ -285,16 +286,16 @@ do_connect(gacopyz_conn_t conn,
fd = socket(addr.sa.sa_family, SOCK_STREAM, 0);
if (fd == -1) {
gacopyz_log(conn, SMI_LOG_ERR,
- "%s: Unable to create new socket: %s",
- conn->desc.xxfi_name, strerror(errno));
+ _("%s: Unable to create new socket: %s"),
+ conn->desc.xxfi_name, strerror(errno));
return -1;
}
if ((flags = fcntl(fd, F_GETFD, 0)) == -1 ||
fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) {
gacopyz_log(conn, SMI_LOG_ERR,
- "%s: Cannot set close-on-exec: %s",
- conn->desc.xxfi_name, strerror(errno));
+ _("%s: Cannot set close-on-exec: %s"),
+ conn->desc.xxfi_name, strerror(errno));
close(fd);
return -1;
}
@@ -303,7 +304,7 @@ do_connect(gacopyz_conn_t conn,
&& setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *) &yes,
sizeof(yes)) == -1) {
gacopyz_log(conn, SMI_LOG_ERR,
- "%s: set reuseaddr failed (%s)",
+ _("%s: set reuseaddr failed (%s)"),
conn->desc.xxfi_name, strerror(errno));
close(fd);
return -1;
@@ -311,16 +312,16 @@ do_connect(gacopyz_conn_t conn,
if (bind(fd, &addr.sa, socklen) < 0) {
gacopyz_log(conn, SMI_LOG_ERR,
- "%s: Cannot bind to port %s: %s",
- conn->desc.xxfi_name, cstr, strerror(errno));
+ _("%s: Cannot bind to port %s: %s"),
+ conn->desc.xxfi_name, cstr, strerror(errno));
close(fd);
return -1;
}
if (listen(fd, backlog)) {
gacopyz_log(conn, SMI_LOG_ERR,
- "%s: Cannot listen on port %s: %s",
- conn->desc.xxfi_name, cstr, strerror(errno));
+ _("%s: Cannot listen on port %s: %s"),
+ conn->desc.xxfi_name, cstr, strerror(errno));
close(fd);
return -1;
}
@@ -338,14 +339,14 @@ gacopyz_open(gacopyz_conn_t conn, const char *cstr, int backlog, int rmsocket)
if (!conn) {
gacopyz_logmsg(SMI_LOG_ERR,
- "empty or missing socket information");
+ _("Empty or missing socket information"));
errno = EINVAL;
return MI_FAILURE;
}
gacopyz_log(conn, SMI_LOG_DEBUG,
- "%s: opening listen socket on %s",
- conn->desc.xxfi_name, cstr);
+ _("%s: opening listen socket on %s"),
+ conn->desc.xxfi_name, cstr);
if (parse_connection(conn, cstr, &proto, &port, &path)) {
errno = ENOENT;
return MI_FAILURE;
@@ -485,7 +486,8 @@ ctx_read(SMFICTX *ctx, char *buf, size_t size)
if (res == 0) {
gacopyz_log(ctx->conn,
SMI_LOG_ERR,
- "ctx_read: connection timed out");
+ _("%s: connection timed out"),
+ "ctx_read");
errno = ETIMEDOUT;
rc = MI_FAILURE;
break;
@@ -497,8 +499,9 @@ ctx_read(SMFICTX *ctx, char *buf, size_t size)
} else if (rc > 0) {
if (FD_ISSET(ctx->sd, &xset)) {
gacopyz_log(ctx->conn,
- SMI_LOG_ERR,
- "ctx_read: exception on control fd");
+ SMI_LOG_ERR,
+ _("%s: exception on control fd"),
+ "ctx_read");
rc = MI_FAILURE;
break;
}
@@ -508,15 +511,17 @@ ctx_read(SMFICTX *ctx, char *buf, size_t size)
res = read(ctx->sd, buf, size);
if (res == -1) {
gacopyz_log(ctx->conn,
- SMI_LOG_ERR,
- "read failed: %s",
- strerror(errno));
+ SMI_LOG_ERR,
+ _("%s: read failed: %s"),
+ "ctx_read",
+ strerror(errno));
rc = MI_FAILURE;
break;
} else if (res == 0) {
gacopyz_log(ctx->conn,
SMI_LOG_ERR,
- "ctx_read: end of file");
+ _("%s: end of file"),
+ "ctx_read");
rc = MI_FAILURE;
break;
}
@@ -549,7 +554,8 @@ ctx_write(SMFICTX *ctx, char *buf, size_t size)
if (res == 0) {
gacopyz_log(ctx->conn,
SMI_LOG_ERR,
- "ctx_write: connection timed out");
+ _("%s: connection timed out"),
+ "ctx_write");
errno = ETIMEDOUT;
rc = MI_FAILURE;
break;
@@ -561,8 +567,9 @@ ctx_write(SMFICTX *ctx, char *buf, size_t size)
} else if (rc > 0) {
if (FD_ISSET(ctx->sd, &xset)) {
gacopyz_log(ctx->conn,
- SMI_LOG_ERR,
- "ctx_write: exception on control fd");
+ SMI_LOG_ERR,
+ _("%s: exception on control fd"),
+ "ctx_write");
rc = MI_FAILURE;
break;
}
@@ -572,15 +579,17 @@ ctx_write(SMFICTX *ctx, char *buf, size_t size)
res = write(ctx->sd, buf, size);
if (res == -1) {
gacopyz_log(ctx->conn,
- SMI_LOG_ERR,
- "write failed: %s",
- strerror(errno));
+ SMI_LOG_ERR,
+ _("%s: write failed: %s"),
+ "ctx_write",
+ strerror(errno));
rc = MI_FAILURE;
break;
} else if (res == 0) {
gacopyz_log(ctx->conn,
SMI_LOG_ERR,
- "ctx_write: wrote 0 bytes");
+ _("%s: wrote 0 bytes"),
+ "ctx_write");
rc = MI_FAILURE;
break;
}
@@ -616,7 +625,7 @@ get_command(SMFICTX *ctx, unsigned char *cmd, size_t *pcount,
char *p = realloc(*pbuf, size + 1);
if (!p) {
gacopyz_log(ctx->conn,
- SMI_LOG_ERR, "not enough memory");
+ SMI_LOG_ERR, "%s", strerror(errno));
return MI_FAILURE;
}
*pbuf = p;
@@ -624,15 +633,15 @@ get_command(SMFICTX *ctx, unsigned char *cmd, size_t *pcount,
}
gacopyz_log(ctx->conn, SMI_LOG_DEBUG,
- "read header: size=%lu, cmd=%c",
- size, header.hdr.cmd);
+ _("Read header: size=%lu, cmd=%c"),
+ size, header.hdr.cmd);
if ((rc = ctx_read(ctx, *pbuf, size)) != MI_SUCCESS)
return rc;
(*pbuf)[size] = 0;
gacopyz_logdump(ctx->conn, SMI_LOG_DEBUG,
- "read data", *pbuf, size);
+ _("read data"), *pbuf, size);
*pcount = size;
*cmd = header.hdr.cmd;
return MI_SUCCESS;
@@ -888,8 +897,9 @@ shan_connect(SMFICTX *ctx, union state_arg *arg, unsigned char *cmd)
case SMFIA_UNIX:
if (len >= sizeof sockaddr.sunix.sun_path) {
gacopyz_log(ctx->conn, SMI_LOG_ERR,
- "%s: shan_connect: path too long: %lu",
+ "%s: shan_connect: %s: %lu",
ctx->conn->desc.xxfi_name,
+ _("path too long"),
(unsigned long) len);
return sret_abort;
}
@@ -901,9 +911,9 @@ shan_connect(SMFICTX *ctx, union state_arg *arg, unsigned char *cmd)
if (inet_aton(s,
(struct in_addr *) &sockaddr.sin.sin_addr) != 1) {
gacopyz_log(ctx->conn, SMI_LOG_ERR,
- "%s: shan_connect: inet_aton(%s) failed",
- ctx->conn->desc.xxfi_name,
- s);
+ _("%s: shan_connect: inet_aton(%s) failed"),
+ ctx->conn->desc.xxfi_name,
+ s);
return sret_abort;
}
sockaddr.sa.sa_family = AF_INET;
@@ -913,9 +923,9 @@ shan_connect(SMFICTX *ctx, union state_arg *arg, unsigned char *cmd)
case SMFIA_INET6:
default:
gacopyz_log(ctx->conn, SMI_LOG_ERR,
- "%s: shan_connect: unknown family %d",
- ctx->conn->desc.xxfi_name,
- family);
+ _("%s: shan_connect: unknown family %d"),
+ ctx->conn->desc.xxfi_name,
+ family);
return sret_abort;
}
}
@@ -988,10 +998,10 @@ shan_optneg(SMFICTX *ctx, union state_arg *arg, unsigned char *cmd)
if (arg->ints[0] < ctx->conn->desc.xxfi_version) {
gacopyz_log(ctx->conn, SMI_LOG_ERR,
- "%s: shan_optneg: version mismatch; "
- "MTA: %ld < milter: %d",
- ctx->conn->desc.xxfi_name,
- arg->ints[0], ctx->conn->desc.xxfi_version);
+ _("%s: shan_optneg: version mismatch; "
+ "MTA: %ld < milter: %d"),
+ ctx->conn->desc.xxfi_name,
+ arg->ints[0], ctx->conn->desc.xxfi_version);
return sret_abort;
}
@@ -1000,10 +1010,10 @@ shan_optneg(SMFICTX *ctx, union state_arg *arg, unsigned char *cmd)
val = SMFI_V1_ACTS;
if ((val & ctx->conn->desc.xxfi_flags) != ctx->conn->desc.xxfi_flags) {
gacopyz_log(ctx->conn, SMI_LOG_ERR,
- "%s: shan_optneg: flags %#x do not match "
- "actions requirements %#x",
- ctx->conn->desc.xxfi_name, val,
- ctx->conn->desc.xxfi_flags);
+ _("%s: shan_optneg: flags %#x do not match "
+ "actions requirements %#x"),
+ ctx->conn->desc.xxfi_name, val,
+ ctx->conn->desc.xxfi_flags);
return sret_abort;
}
@@ -1012,8 +1022,8 @@ shan_optneg(SMFICTX *ctx, union state_arg *arg, unsigned char *cmd)
val = SMFI_V1_PROT;
if ((val & ctx->flags) != ctx->flags) {
gacopyz_log(ctx->conn, SMI_LOG_ERR,
- "%s: shan_optneg: flags %#x do not match "
- "protocol requirement %#x",
+ _("%s: shan_optneg: flags %#x do not match "
+ "protocol requirement %#x"),
ctx->conn->desc.xxfi_name, val,
ctx->flags);
return sret_abort;
@@ -1244,7 +1254,7 @@ gacopyz_context_loop(gacopyz_conn_t conn, int fd)
transtab[st_eohs][st_skip] = !!(ctx.flags & SMFIP_NOEOH);
transtab[st_body][st_skip] = !!(ctx.flags & SMFIP_NOBODY);
- gacopyz_log(conn, SMI_LOG_DEBUG, "begin context loop");
+ gacopyz_log(conn, SMI_LOG_DEBUG, _("Begin context loop"));
while (!stop
&& (rc = get_command(&ctx, &cmd, &size, &buffer, &bufsize))
@@ -1256,11 +1266,11 @@ gacopyz_context_loop(gacopyz_conn_t conn, int fd)
if (sd == NULL) {
gacopyz_log(conn, SMI_LOG_ERR,
- "unknown command: %c",
- cmd);
+ _("Unknown command: %c"),
+ cmd);
gacopyz_logdump(conn, SMI_LOG_ERR,
- "buffer",
- buffer, size);
+ _("buffer"),
+ buffer, size);
rc = MI_FAILURE;
break;
}
@@ -1270,10 +1280,10 @@ gacopyz_context_loop(gacopyz_conn_t conn, int fd)
if (next_state != st_none && !trans_ok(state, next_state)) {
gacopyz_log(conn, SMI_LOG_DEBUG,
- "transition from state %s to %s is "
- "prohibited",
- STATE_NAME(state),
- STATE_NAME(next_state));
+ _("Transition from state %s to %s is "
+ "prohibited"),
+ STATE_NAME(state),
+ STATE_NAME(next_state));
if (ST_IN_MAIL(state) && ctx.conn->desc.xxfi_abort)
ctx.conn->desc.xxfi_abort(&ctx);
@@ -1290,9 +1300,9 @@ gacopyz_context_loop(gacopyz_conn_t conn, int fd)
if (parse_state_arg(&arg, sd->arg_type, buffer, size)) {
gacopyz_log(conn, SMI_LOG_ERR,
- "argument parsing failed");
+ _("Argument parsing failed"));
gacopyz_logdump(conn, SMI_LOG_ERR,
- "buffer",
+ _("buffer"),
buffer, size);
rc = MI_FAILURE;
break;
@@ -1322,14 +1332,14 @@ gacopyz_context_loop(gacopyz_conn_t conn, int fd)
case sret_fail:
gacopyz_log(conn, SMI_LOG_DEBUG,
- "%s handler returned failure",
- sd->name);
+ _("%s handler returned failure"),
+ sd->name);
break;
case sret_abort:
gacopyz_log(conn, SMI_LOG_DEBUG,
- "%s handler returned abort",
- sd->name);
+ _("%s handler returned abort"),
+ sd->name);
rc = MI_FAILURE;
}
@@ -1337,7 +1347,7 @@ gacopyz_context_loop(gacopyz_conn_t conn, int fd)
break;
}
- gacopyz_log(conn, SMI_LOG_DEBUG, "end context loop: %d", rc);
+ gacopyz_log(conn, SMI_LOG_DEBUG, _("End context loop: %d"), rc);
if (rc != MI_SUCCESS && ST_IN_MAIL(state)
&& ctx.conn->desc.xxfi_abort)
@@ -1365,7 +1375,7 @@ gacopyz_handle_connection(gacopyz_conn_t conn)
if (errno == EINTR)
return MI_SUCCESS;
gacopyz_log(conn, SMI_LOG_ERR,
- "accept failed: %s", strerror(errno));
+ _("accept failed: %s"), strerror(errno));
return MI_FAILURE;
}
@@ -1373,7 +1383,7 @@ gacopyz_handle_connection(gacopyz_conn_t conn)
pid_t pid = fork();
if (pid == -1) {
gacopyz_log(conn, SMI_LOG_ERR,
- "fork() failed: %s",
+ _("fork() failed: %s"),
strerror(errno));
return MI_FAILURE;
}
@@ -1395,18 +1405,18 @@ gacopyz_handle_connection(gacopyz_conn_t conn)
switch (addr.sa.sa_family) {
case AF_UNIX:
- gacopyz_log(conn, SMI_LOG_INFO, "connect from socket");
+ gacopyz_log(conn, SMI_LOG_INFO, _("Connect from socket"));
break;
case AF_INET:
- gacopyz_log(conn, SMI_LOG_INFO, "connect from %s:%u",
+ gacopyz_log(conn, SMI_LOG_INFO, _("Connect from %s:%u"),
inet_ntoa(addr.sin.sin_addr),
(unsigned) ntohs(addr.sin.sin_port));
break;
default:
gacopyz_log(conn, SMI_LOG_INFO,
- "connect from unsupported family: %d",
+ _("Connect from unsupported family: %d"),
addr.sa.sa_family);
}
@@ -1418,7 +1428,7 @@ gacopyz_handle_connection(gacopyz_conn_t conn)
if (conn->desc.xxfi_finish)
conn->desc.xxfi_finish();
- gacopyz_log(conn, SMI_LOG_INFO, "finishing connection");
+ gacopyz_log(conn, SMI_LOG_INFO, _("Finishing connection"));
if (!conn->foreground) {
exit(0);
diff --git a/gacopyz/gacopyz_priv.h b/gacopyz/gacopyz_priv.h
index 7f5bdd69..67232327 100644
--- a/gacopyz/gacopyz_priv.h
+++ b/gacopyz/gacopyz_priv.h
@@ -95,3 +95,26 @@ int gacopyz_read_command(gacopyz_iod_t iod, unsigned char *cmd,
int gacopyz_register_child(gacopyz_conn_t conn, pid_t pid);
int gacopyz_unregister_child(gacopyz_conn_t conn, pid_t pid);
+
+/* NLS */
+#undef _
+#undef N_
+#undef gettext
+#undef dgettext
+#undef ngettext
+#undef textdomain
+#undef bindtextdomain
+
+#ifdef ENABLE_NLS
+# include <gettext.h>
+# define _(String) gettext(String)
+# define N_(String) String
+#else
+# define _(String) (String)
+# define N_(String) String
+# define gettext(msgid) (msgid)
+# define dgettext(domain, msgid) (msgid)
+# define ngettext(sg,pl,cnt) (cnt == 1) ? (sg) : (pl)
+# define textdomain(Domain)
+# define bindtextdomain(Package, Directory)
+#endif /* ENABLE_NLS */
diff --git a/gacopyz/io.c b/gacopyz/io.c
index d258800c..0c03ea00 100644
--- a/gacopyz/io.c
+++ b/gacopyz/io.c
@@ -39,8 +39,9 @@ _gacopyz_read (gacopyz_iod_t iod, char *buf, size_t size)
res = select(iod->sd + 1, &rset, NULL, &xset, &to);
if (res == 0) {
gacopyz_io_log(iod,
- SMI_LOG_ERR,
- "_gacopyz_read: connection timed out");
+ SMI_LOG_ERR,
+ _("%s: connection timed out"),
+ "_gacopyz_read");
errno = ETIMEDOUT;
rc = MI_FAILURE;
break;
@@ -52,9 +53,9 @@ _gacopyz_read (gacopyz_iod_t iod, char *buf, size_t size)
} else if (rc > 0) {
if (FD_ISSET(iod->sd, &xset)) {
gacopyz_io_log(iod,
- SMI_LOG_ERR,
- "_gacopyz_read: "
- "exception on control fd");
+ SMI_LOG_ERR,
+ _("%s: exception on control fd"),
+ "_gacopyz_read");
rc = MI_FAILURE;
break;
}
@@ -64,15 +65,17 @@ _gacopyz_read (gacopyz_iod_t iod, char *buf, size_t size)
res = read(iod->sd, buf, size);
if (res == -1) {
gacopyz_io_log(iod,
- SMI_LOG_ERR,
- "_gacopyz_read: read failed: %s",
- strerror(errno));
+ SMI_LOG_ERR,
+ _("%s: read failed: %s"),
+ "_gacopyz_read",
+ strerror(errno));
rc = MI_FAILURE;
break;
} else if (res == 0) {
gacopyz_io_log(iod,
- SMI_LOG_ERR,
- "_gacopyz_read: end of file");
+ SMI_LOG_ERR,
+ _("%s: end of file"),
+ "_gacopyz_read");
rc = MI_FAILURE;
break;
}
@@ -104,8 +107,9 @@ _gacopyz_write(gacopyz_iod_t iod, const char *buf, size_t size)
res = select(iod->sd + 1, NULL, &wset, &xset, &to);
if (res == 0) {
gacopyz_io_log(iod,
- SMI_LOG_ERR,
- "_gacopyz_write: connection timed out");
+ SMI_LOG_ERR,
+ _("%s: connection timed out"),
+ "_gacopyz_write");
errno = ETIMEDOUT;
rc = MI_FAILURE;
break;
@@ -117,9 +121,9 @@ _gacopyz_write(gacopyz_iod_t iod, const char *buf, size_t size)
} else if (rc > 0) {
if (FD_ISSET(iod->sd, &xset)) {
gacopyz_io_log(iod,
- SMI_LOG_ERR,
- "_gacopyz_write: "
- "exception on control fd");
+ SMI_LOG_ERR,
+ _("%s: exception on control fd"),
+ "_gacopyz_write");
rc = MI_FAILURE;
break;
}
@@ -129,15 +133,17 @@ _gacopyz_write(gacopyz_iod_t iod, const char *buf, size_t size)
res = write(iod->sd, buf, size);
if (res == -1) {
gacopyz_io_log(iod,
- SMI_LOG_ERR,
- "_gacopyz_write: write failed: %s",
- strerror(errno));
+ SMI_LOG_ERR,
+ _("%s: write failed: %s"),
+ "_gacopyz_write",
+ strerror(errno));
rc = MI_FAILURE;
break;
} else if (res == 0) {
gacopyz_io_log(iod,
- SMI_LOG_ERR,
- "_gacopyz_write: wrote 0 bytes");
+ SMI_LOG_ERR,
+ _("%s: wrote 0 bytes"),
+ "_gacopyz_write");
rc = MI_FAILURE;
break;
}
@@ -163,11 +169,11 @@ gacopyz_send_command(gacopyz_iod_t iod, int cmd, const void *data, size_t size)
union header header;
gacopyz_io_log(iod, SMI_LOG_DEBUG,
- "send header: size=%lu, cmd=%c",
+ _("send header: size=%lu, cmd=%c"),
size, cmd);
gacopyz_io_logdump(iod, SMI_LOG_DEBUG,
- "send data", data, size);
+ _("send data"), data, size);
header.hdr.size = htonl(size + 1);
header.hdr.cmd = cmd;
rc = _gacopyz_write(iod, header.buf, sizeof header.buf);
@@ -195,7 +201,7 @@ gacopyz_read_command(gacopyz_iod_t iod, unsigned char *cmd, size_t *pcount,
char *p = realloc(*pbuf, size + 1);
if (!p) {
gacopyz_io_log(iod,
- SMI_LOG_ERR, "not enough memory");
+ SMI_LOG_ERR, "%s", strerror(errno));
return MI_FAILURE;
}
*pbuf = p;
@@ -203,7 +209,7 @@ gacopyz_read_command(gacopyz_iod_t iod, unsigned char *cmd, size_t *pcount,
}
gacopyz_io_log(iod, SMI_LOG_DEBUG,
- "read header: size=%lu, cmd=%c",
+ _("read header: size=%lu, cmd=%c"),
size, header.hdr.cmd);
if ((rc = _gacopyz_read(iod, *pbuf, size)) != MI_SUCCESS)
@@ -211,7 +217,7 @@ gacopyz_read_command(gacopyz_iod_t iod, unsigned char *cmd, size_t *pcount,
(*pbuf)[size] = 0;
gacopyz_io_logdump(iod, SMI_LOG_DEBUG,
- "read data", *pbuf, size);
+ _("read data"), *pbuf, size);
*pcount = size;
*cmd = header.hdr.cmd;
return MI_SUCCESS;
diff --git a/gacopyz/proc.c b/gacopyz/proc.c
index 7bce35f1..a92c64e0 100644
--- a/gacopyz/proc.c
+++ b/gacopyz/proc.c
@@ -62,11 +62,11 @@ print_status(gacopyz_conn_t conn, pid_t pid, int status, int expect_term)
if (WIFEXITED(status)) {
if (WEXITSTATUS(status) == 0)
gacopyz_log(conn, SMI_LOG_DEBUG,
- "child %lu exited successfully",
+ _("Child %lu exited successfully"),
(unsigned long) pid);
else
gacopyz_log(conn, SMI_LOG_ERR,
- "child %lu failed with status %d",
+ _("Child %lu failed with status %d"),
(unsigned long) pid,
WEXITSTATUS(status));
} else if (WIFSIGNALED(status)) {
@@ -76,21 +76,21 @@ print_status(gacopyz_conn_t conn, pid_t pid, int status, int expect_term)
else
prio = SMI_LOG_ERR;
gacopyz_log(conn, prio,
- "child %lu terminated on signal %d",
+ _("Child %lu terminated on signal %d"),
(unsigned long) pid, WTERMSIG(status));
} else if (WIFSTOPPED(status))
gacopyz_log(conn, SMI_LOG_ERR,
- "child %lu stopped on signal %d",
+ _("Child %lu stopped on signal %d"),
(unsigned long) pid, WSTOPSIG(status));
#ifdef WCOREDUMP
else if (WCOREDUMP(status))
gacopyz_log(conn, SMI_LOG_ERR,
- "child %lu dumped core",
+ _("Child %lu dumped core"),
(unsigned long) pid);
#endif
else
gacopyz_log(conn, SMI_LOG_ERR,
- "child %lu terminated with unrecognized status",
+ _("Child %lu terminated with unrecognized status"),
(unsigned long) pid);
}
@@ -120,7 +120,7 @@ void
gacopyz_cleanup_conn(gacopyz_conn_t conn)
{
size_t i;
- gacopyz_log(conn, SMI_LOG_DEBUG, "terminating subprocesses");
+ gacopyz_log(conn, SMI_LOG_DEBUG, _("Terminating subprocesses"));
for (i = 0; i < conn->pidcount; i++)
if (conn->pidtab[i])
diff --git a/gacopyz/server.c b/gacopyz/server.c
index 57cd90de..6db47048 100644
--- a/gacopyz/server.c
+++ b/gacopyz/server.c
@@ -62,7 +62,7 @@ void
default_memerror (gacopyz_srv_t srv, const char *file, unsigned int line)
{
gacopyz_io_log(&srv->iod, SMI_LOG_FATAL,
- "%s:%lu: Not enough memory",
+ _("%s:%lu: Not enough memory"),
file, line);
abort();
}
@@ -334,7 +334,8 @@ parse_X_spec (const char *spec, char *xspec, char **id, char **port,
p = strtok(xspec, ",");
if (!p) {
if (debug)
- gacopyz_logmsg(SMI_LOG_DEBUG, "%s: not a valid X spec",
+ gacopyz_logmsg(SMI_LOG_DEBUG,
+ _("%s: not a valid X spec"),
spec);
return MI_FAILURE;
}
@@ -344,7 +345,7 @@ parse_X_spec (const char *spec, char *xspec, char **id, char **port,
if (!p) {
if (debug)
gacopyz_logmsg(SMI_LOG_DEBUG,
- "%s: not a valid X spec",
+ _("%s: not a valid X spec"),
spec);
return MI_FAILURE;
}
@@ -358,8 +359,8 @@ parse_X_spec (const char *spec, char *xspec, char **id, char **port,
if (p[1] != '=') {
if (debug)
gacopyz_logmsg(SMI_LOG_DEBUG,
- "%s: not a valid X spec, "
- "missing = near %s",
+ _("%s: not a valid X spec, "
+ "missing = near %s"),
spec, p);
return MI_FAILURE;
}
@@ -369,8 +370,8 @@ parse_X_spec (const char *spec, char *xspec, char **id, char **port,
if (*port) {
if (debug)
gacopyz_logmsg(SMI_LOG_DEBUG,
- "%s: not a valid X spec, "
- "duplicate field %s",
+ _("%s: not a valid X spec, "
+ "duplicate field %s"),
spec, p);
return MI_FAILURE;
}
@@ -381,8 +382,8 @@ parse_X_spec (const char *spec, char *xspec, char **id, char **port,
if (havef) {
if (debug)
gacopyz_logmsg(SMI_LOG_DEBUG,
- "%s: not a valid X spec, "
- "duplicate field %s",
+ _("%s: not a valid X spec, "
+ "duplicate field %s"),
spec, p);
return MI_FAILURE;
}
@@ -390,8 +391,8 @@ parse_X_spec (const char *spec, char *xspec, char **id, char **port,
if (strlen (p) != 3) {
if (debug)
gacopyz_logmsg(SMI_LOG_DEBUG,
- "%s: not a valid X spec, "
- "invalid field %s",
+ _("%s: not a valid X spec, "
+ "invalid field %s"),
spec, p);
return MI_FAILURE;
}
@@ -407,8 +408,8 @@ parse_X_spec (const char *spec, char *xspec, char **id, char **port,
default:
if (debug)
gacopyz_logmsg(SMI_LOG_DEBUG,
- "%s: not a valid X spec, "
- "invalid field %s",
+ _("%s: not a valid X spec, "
+ "invalid field %s"),
spec, p);
return MI_FAILURE;
}
@@ -418,8 +419,8 @@ parse_X_spec (const char *spec, char *xspec, char **id, char **port,
if (havet) {
if (debug)
gacopyz_logmsg(SMI_LOG_DEBUG,
- "%s: not a valid X spec, "
- "duplicate field %s",
+ _("%s: not a valid X spec, "
+ "duplicate field %s"),
spec, p);
return MI_FAILURE;
}
@@ -450,16 +451,16 @@ parse_X_spec (const char *spec, char *xspec, char **id, char **port,
default:
if (debug)
gacopyz_logmsg(SMI_LOG_DEBUG,
- "%s: not a valid X spec, "
- "invalid T field near %s",
+ _("%s: not a valid X spec, "
+ "invalid T field near %s"),
spec, q);
return MI_FAILURE;
}
if (*++q != ':') {
if (debug)
gacopyz_logmsg(SMI_LOG_DEBUG,
- "%s: not a valid X spec, "
- "invalid T field near %s",
+ _("%s: not a valid X spec, "
+ "invalid T field near %s"),
spec, q);
return MI_FAILURE;
}
@@ -478,8 +479,8 @@ parse_X_spec (const char *spec, char *xspec, char **id, char **port,
default:
if (debug)
gacopyz_logmsg(SMI_LOG_DEBUG,
- "%s: not a valid X spec, "
- "invalid T field near %s",
+ _("%s: not a valid X spec, "
+ "invalid T field near %s"),
spec, q);
return MI_FAILURE;
}
@@ -494,8 +495,8 @@ parse_X_spec (const char *spec, char *xspec, char **id, char **port,
else if (*q != ';') {
if (debug)
gacopyz_logmsg(SMI_LOG_DEBUG,
- "%s: not a valid X spec, "
- "invalid delimiter near %s",
+ _("%s: not a valid X spec, "
+ "invalid delimiter near %s"),
spec, q);
return MI_FAILURE;
}
@@ -526,8 +527,8 @@ gacopyz_srv_create_X(gacopyz_srv_t *p, const char *spec, unsigned logmask)
if (!port) {
if (logmask & SMI_LOG_MASK(SMI_LOG_DEBUG))
gacopyz_logmsg(SMI_LOG_DEBUG,
- "%s: not a valid X spec, "
- "missing port",
+ _("%s: not a valid X spec, "
+ "missing port"),
spec);
free(xspec);
return MI_FAILURE;
@@ -662,8 +663,8 @@ srv_connect(gacopyz_srv_t srv, char *proto, char *port, char *path)
if (port) {
gacopyz_io_log(&srv->iod, SMI_LOG_ERR,
- "invalid connection type: %s; "
- "port is meaningless for UNIX sockets",
+ _("Invalid connection type: %s; "
+ "port is meaningless for UNIX sockets"),
srv->portspec);
return -1;
}
@@ -671,8 +672,8 @@ srv_connect(gacopyz_srv_t srv, char *proto, char *port, char *path)
if (strlen(path) > sizeof addr.sun.sun_path) {
errno = EINVAL;
gacopyz_io_log(&srv->iod, SMI_LOG_ERR,
- "%s: UNIX socket name too long",
- path);
+ _("%s: UNIX socket name too long"),
+ path);
return -