aboutsummaryrefslogtreecommitdiff
path: root/gacopyz/gacopyz.c
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/gacopyz.c
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/gacopyz.c')
-rw-r--r--gacopyz/gacopyz.c204
1 files changed, 107 insertions, 97 deletions
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);

Return to:

Send suggestions and report system problems to the System administrator.