aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac18
-rw-r--r--src/graph.c1
-rw-r--r--src/html.gram.y34
-rw-r--r--src/html.lex.l10
-rw-r--r--src/log.c16
-rw-r--r--src/main.c77
-rw-r--r--src/readconfig.c32
-rw-r--r--src/report.c40
-rw-r--r--src/stat.c65
-rw-r--r--src/tagr.h5
10 files changed, 167 insertions, 131 deletions
diff --git a/configure.ac b/configure.ac
index a622998..70e0c79 100644
--- a/configure.ac
+++ b/configure.ac
@@ -72,12 +72,30 @@ AC_CHECK_HEADERS(gdbm.h,
[AC_MSG_ERROR([gdbm.h not found])])
AC_CHECK_LIB([gdbm], [gdbm_open],
,
[AC_MSG_ERROR([libgdbm not found])])
+## Default syslog facility
+LOG_FACILITY="LOG_DAEMON"
+
+AC_ARG_VAR([LOG_FACILITY],
+ [Default syslog facility])
+if test -n "$LOG_FACILITY"; then
+ logfacility=`echo $LOG_FACILITY | tr a-z A-Z`
+ case $logfacility in
+ USER|DAEMON|AUTH|AUTHPRIV|MAIL|CRON|LOCAL[[0-7]])
+ LOG_FACILITY=LOG_$logfacility;;
+ LOG_USER|LOG_DAEMON|LOG_AUTH|LOG_AUTHPRIV|LOG_MAIL|LOG_CRON|LOG_LOCAL[[0-7]])
+ LOG_FACILITY=$logfacility;;
+ *) AC_MSG_ERROR([Invalid value of LOG_FACILITY]);;
+ esac
+fi
+AC_DEFINE_UNQUOTED([LOG_FACILITY],$LOG_FACILITY,
+ [Default syslog facility.])
+
AC_CONFIG_FILES([Makefile
gnu/Makefile
grecs/Makefile
grecs/src/Makefile
src/Makefile
etc/Makefile])
diff --git a/src/graph.c b/src/graph.c
index bfd00cb..1464e8b 100644
--- a/src/graph.c
+++ b/src/graph.c
@@ -51,12 +51,13 @@ int color_percent[3] = { 239,159,79 };
int graph_xsize = 460;
int graph_ysize = 100;
int graph_h_margin[2] = { 100, 14 };
int graph_v_margin[2] = { 14, 35 };
+/* FIXME: I18N?? */
char *rate_unit = "Bytes per Second";
#define make_color_index(g, ar) \
gdImageColorAllocate (g, (ar)[0], (ar)[1], (ar)[2])
static void
diff --git a/src/html.gram.y b/src/html.gram.y
index fae64ff..e488494 100644
--- a/src/html.gram.y
+++ b/src/html.gram.y
@@ -110,13 +110,13 @@ expr : value
{
if ($1.type == unspecified_value
|| $3.type == unspecified_value)
init_value (&$$, unspecified_value, NULL);
else if ($1.type != $3.type)
{
- yyerror ("type mismatch in addition");
+ yyerror (_("type mismatch in addition"));
init_value (&$$, unspecified_value, NULL);
}
else
{
$$.type = $1.type;
deduce_format (&$$, &$1, &$3);
@@ -142,18 +142,18 @@ expr : value
{
if ($1.type == unspecified_value
|| $3.type == unspecified_value)
init_value (&$$, unspecified_value, NULL);
else if ($1.type != $3.type)
{
- yyerror ("type mismatch in subtraction");
+ yyerror (_("type mismatch in subtraction"));
init_value (&$$, unspecified_value, NULL);
}
else if ($1.type == string_value)
{
- yyerror ("subtraction not defined for strings");
+ yyerror (_("subtraction not defined for strings"));
init_value (&$$, unspecified_value, NULL);
}
else
{
$$.type = $1.type;
deduce_format (&$$, &$1, &$3);
@@ -164,18 +164,18 @@ expr : value
{
if ($1.type == unspecified_value
|| $3.type == unspecified_value)
init_value (&$$, unspecified_value, NULL);
else if ($1.type != $3.type)
{
- yyerror ("type mismatch in multiplication");
+ yyerror (_("type mismatch in multiplication"));
init_value (&$$, unspecified_value, NULL);
}
else if ($1.type == string_value)
{
- yyerror ("multiplication not defined for strings");
+ yyerror (_("multiplication not defined for strings"));
init_value (&$$, unspecified_value, NULL);
}
else
{
$$.type = $1.type;
deduce_format (&$$, &$1, &$3);
@@ -186,23 +186,23 @@ expr : value
{
if ($1.type == unspecified_value
|| $3.type == unspecified_value)
init_value (&$$, unspecified_value, NULL);
else if ($1.type != $3.type)
{
- yyerror ("type mismatch in division");
+ yyerror (_("type mismatch in division"));
init_value (&$$, unspecified_value, NULL);
}
else if ($1.type == string_value)
{
- yyerror ("division not defined for strings");
+ yyerror (_("division not defined for strings"));
init_value (&$$, unspecified_value, NULL);
}
else if (fabs ($3.v.number) < 1.0e-5)
{
- yyerror ("division by zero");
+ yyerror (_("division by zero"));
init_value (&$$, unspecified_value, NULL);
}
else
{
$$.type = $1.type;
deduce_format (&$$, &$1, &$3);
@@ -212,13 +212,13 @@ expr : value
| '-' expr %prec UMINUS
{
if ($2.type == unspecified_value)
init_value (&$$, unspecified_value, NULL);
else if ($2.type == string_value)
{
- yyerror ("unary minus not defined for strings");
+ yyerror (_("unary minus not defined for strings"));
init_value (&$$, unspecified_value, NULL);
}
else
{
$$ = $2;
$$.v.number = - $2.v.number;
@@ -227,13 +227,13 @@ expr : value
| '+' expr %prec UMINUS
{
if ($2.type == unspecified_value)
init_value (&$$, unspecified_value, NULL);
else if ($2.type == string_value)
{
- yyerror ("unary plus not defined for strings");
+ yyerror (_("unary plus not defined for strings"));
init_value (&$$, unspecified_value, NULL);
}
else
{
$$ = $2;
}
@@ -270,33 +270,33 @@ create_html (pp_tab_t *tab, char *file, char *dest)
tmp_file_name = mkfilename (NULL, dest, ".tmp");
tmp_file = fopen (tmp_file_name, "w");
if (!tmp_file)
{
- logmsg (L_ERR, "cannot open output file `%s': %s",
+ logmsg (L_ERR, _("cannot open output file `%s': %s"),
file, strerror (errno));
html_close ();
return 1;
}
ident_tab = tab;
rc = yyparse ();
fclose (tmp_file);
if (rc == 0)
{
if (unlink (dest) && errno != ENOENT)
{
- logmsg (L_ERR, "cannot unlink file `%s': %s",
+ logmsg (L_ERR, _("cannot unlink file `%s': %s"),
dest, strerror (errno));
rc = 1;
}
if (rename (tmp_file_name, dest))
{
- logmsg (L_ERR, "cannot rename `%s' to `%s': %s",
+ logmsg (L_ERR, _("cannot rename `%s' to `%s': %s"),
tmp_file_name, dest,
strerror (errno));
rc = 1;
}
}
free (tmp_file_name);
@@ -491,22 +491,22 @@ read_symtab (pp_tab_t **tab, const char *name)
continue;
p = buf;
cmd = *p++;
if (*p != ' ' || !(isascii (*++p) && isalpha (*p)))
{
- logmsg (L_ERR, "%s:%u: invalid input: %s",
+ logmsg (L_ERR, _("%s:%u: invalid input: %s"),
name, line, buf);
status = 1;
break;
}
var = p;
p = strchr (var, ' ');
if (!p)
{
- logmsg (L_ERR, "%s:%u: invalid input: %s",
+ logmsg (L_ERR, _("%s:%u: invalid input: %s"),
name, line, buf);
status = 1;
break;
}
*p++ = 0;
value = p;
@@ -520,23 +520,23 @@ read_symtab (pp_tab_t **tab, const char *name)
case 'n':
{
char *p;
double num = strtod (value, &p);
if (*p)
{
- logmsg (L_ERR, "%s:%u: invalid numeric value: %s",
+ logmsg (L_ERR, _("%s:%u: invalid numeric value: %s"),
name, line, value);
status = 1;
}
else
add_numeric_value (tab, var, num);
}
break;
default:
- logmsg (L_NOTICE, "%s:%u: ignoring unknown command %#03o",
+ logmsg (L_NOTICE, _("%s:%u: ignoring unknown command %#03o"),
name, line, cmd);
}
}
free (buf);
fclose (fp);
diff --git a/src/html.lex.l b/src/html.lex.l
index 931bfc1..0e0d423 100644
--- a/src/html.lex.l
+++ b/src/html.lex.l
@@ -40,32 +40,32 @@ N [0-9]+
yylval.character = '$';
return CHAR;
}
\${NAME} {
if (find_value (yytext+1, &yylval.value))
{
- yyerror ("unknown identifier");
+ yyerror (_("unknown identifier"));
init_value (&yylval.value, unspecified_value, NULL);
}
return IDENT;
}
\$\({NAME}\) {
yytext[yyleng-1] = 0;
if (find_value (yytext+2, &yylval.value))
{
- yyerror ("unknown identifier");
+ yyerror (_("unknown identifier"));
init_value (&yylval.value, unspecified_value, NULL);
}
return IDENT;
}
\$\({NAME}:{N}\) {
char *p = strchr (yytext, ':');
*p = 0;
if (find_value (yytext+2, &yylval.value))
{
- yyerror ("unknown identifier");
+ yyerror (_("unknown identifier"));
init_value (&yylval.value, unspecified_value, NULL);
}
else
{
yylval.value.prec = strtoul (p+1, NULL, 10);
}
@@ -74,13 +74,13 @@ N [0-9]+
\$\({NAME}:[^)]+\) {
pp_value_t val;
char *p = strchr (yytext, ':');
*p++ = 0;
if (find_value (yytext+2, &val))
{
- yyerror ("unknown identifier");
+ yyerror (_("unknown identifier"));
init_value (&yylval.value, unspecified_value, NULL);
}
else
{
size_t len = strlen (p) - 1;
init_value (&yylval.value, val.type, &val.v);
@@ -127,13 +127,13 @@ end_eval ()
int
html_open (char *file)
{
yyin = fopen (file, "r");
if (!yyin)
{
- logmsg (L_ERR, "cannot open input file `%s': %s",
+ logmsg (L_ERR, _("cannot open input file `%s': %s"),
file, strerror (errno));
return 1;
}
html_input_file = file;
html_input_line = 1;
return 0;
diff --git a/src/log.c b/src/log.c
index de847c9..e5ae4e1 100644
--- a/src/log.c
+++ b/src/log.c
@@ -26,13 +26,13 @@
#include <sys/stat.h>
#include <errno.h>
#include <syslog.h>
#include <argp.h>
#include <tagr.h>
-int log_facility = LOGFACILITY;
+int log_facility = LOG_FACILITY;
char *log_tag;
int log_print_severity; /* FIXME: not used */
void
init_syslog (char *progname)
{
@@ -48,27 +48,27 @@ int syslog_level[] = {
LOG_WARNING,
LOG_ERR,
LOG_CRIT,
};
char *level_str[] = {
- "debug",
- "info",
- "notice",
- "warning",
- "error",
- "CRITICAL",
+ N_("debug"),
+ N_("info"),
+ N_("notice"),
+ N_("warning"),
+ N_("error"),
+ N_("CRITICAL"),
};
void
vlogmsg (int level, const char *fmt, va_list ap)
{
if (grecs_log_to_stderr)
{
- fprintf (stderr, "%s: %s: ", log_tag, level_str[level]);
+ fprintf (stderr, "%s: %s: ", log_tag, gettext (level_str[level]));
vfprintf (stderr, fmt, ap);
fprintf (stderr, "\n");
}
else
vsyslog (syslog_level[level], fmt, ap);
}
diff --git a/src/main.c b/src/main.c
index 2a20ba9..9b98ec5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -77,14 +77,14 @@ static int list_option;
static char *check_mode = 0;
static char *user_option = NULL;
static char *html_template_option = NULL;
const char *program_version = "tagr (" PACKAGE_STRING ")";
-static char doc[] = "tagr -- traffic analyzer and grapher";
-static char args_doc[] = "";
+static char doc[] = N_("tagr -- traffic analyzer and grapher");
+static char args_doc[] = "[FILES or DIRS...]";
enum {
OPT_IMPORT = 256,
OPT_TEST_TEMPLATE,
OPT_SHOW_DEFAULTS,
OPT_SYSLOG,
@@ -109,13 +109,13 @@ static struct argp_option options[] = {
{"test-template", OPT_TEST_TEMPLATE, NULL, 0,
N_("test page template file syntax"), GRID+1},
{"import", OPT_IMPORT, NULL, 0,
N_("import old (mrtg-style) log files from DIR (or the basedir, if not given)"),
GRID+1 },
{"read", OPT_READ, NULL, 0,
- N_("read statistics from the given file or standard input") },
+ N_("read statistics from given FILEs or standard input") },
{"rebuild", 'b', NULL, 0,
N_("rebuild graphs using existing statistics"), GRID+1},
{"list", 'l', NULL, 0, N_("list contents of the rate database"), GRID+1},
{"show-defaults", OPT_SHOW_DEFAULTS, NULL, 0,
N_("Show configuration default values"), GRID+1},
#undef GRID
@@ -184,18 +184,18 @@ static struct argp_option options[] = {
{NULL}
};
static void
show_defaults ()
{
- printf ("Configuration file: %s\n", TAGR_CONFIGFILE);
- printf ("Page template file: %s\n", TAGR_TEMPLATE);
- printf ("PID file: %s\n", TAGR_PIDFILE);
- printf ("DB file name: %s\n", TAGR_DBNAME);
- printf ("DB file permissions: %#o\n", TAGR_DBMODE);
- printf ("Syslog facility number: %d\n", LOGFACILITY);
+ printf (_("Configuration file: %s\n"), TAGR_CONFIGFILE);
+ printf (_("Page template file: %s\n"), TAGR_TEMPLATE);
+ printf (_("PID file: %s\n"), TAGR_PIDFILE);
+ printf (_("DB file name: %s\n"), TAGR_DBNAME);
+ printf (_("DB file permissions: %#o\n"), TAGR_DBMODE);
+ printf (_("Syslog facility number: %d\n"), LOG_FACILITY);
}
static void
add_check_mode (int c)
{
char s[2];
@@ -332,41 +332,42 @@ change_privs (uid_t uid, gid_t gid)
gid_t emptygidset[1];
/* Reset group permissions */
emptygidset[0] = gid ? gid : getegid ();
if (geteuid () == 0 && setgroups (1, emptygidset))
{
- logmsg (L_ERR, "setgroups(1, %lu) failed: %s",
+ logmsg (L_ERR, _("setgroups(1, %lu) failed: %s"),
(u_long) emptygidset[0], strerror (errno));
rc = 1;
}
/* Switch to the user's gid. On some OSes the effective gid must
be reset first */
#if defined(HAVE_SETEGID)
if ((rc = setegid (gid)) < 0)
- logmsg (L_ERR, "setegid(%lu) failed: %s", (u_long) gid, strerror (errno));
+ logmsg (L_ERR, _("setegid(%lu) failed: %s"),
+ (u_long) gid, strerror (errno));
#elif defined(HAVE_SETREGID)
if ((rc = setregid (gid, gid)) < 0)
- logmsg (L_ERR, "setregid(%lu,%lu) failed: %s",
+ logmsg (L_ERR, _("setregid(%lu,%lu) failed: %s"),
(u_long) gid, (u_long) gid, strerror (errno));
#elif defined(HAVE_SETRESGID)
if ((rc = setresgid (gid, gid, gid)) < 0)
- logmsg (L_ERR, "setresgid(%lu,%lu,%lu) failed: %s",
+ logmsg (L_ERR, _("setresgid(%lu,%lu,%lu) failed: %s"),
(u_long) gid, (u_long) gid, (u_long) gid, strerror (errno));
#endif
if (rc == 0 && gid != 0)
{
if ((rc = setgid (gid)) < 0 && getegid () != gid)
- logmsg (L_ERR, "setgid(%lu) failed: %s",
+ logmsg (L_ERR, _("setgid(%lu) failed: %s"),
(u_long) gid, strerror (errno));
if (rc == 0 && getegid () != gid)
{
- logmsg (L_ERR, "cannot set effective gid to %lu: %s",
+ logmsg (L_ERR, _("cannot set effective gid to %lu: %s"),
(u_long) gid, strerror (errno));
rc = 1;
}
}
/* now reset uid */
@@ -382,45 +383,45 @@ change_privs (uid_t uid, gid_t gid)
#if defined(HAVE_SETREUID)
if (geteuid () != uid)
{
if (setreuid (uid, -1) < 0)
{
logmsg (L_ERR,
- "setreuid(%lu,-1) failed: %s",
+ _("setreuid(%lu,-1) failed: %s"),
(u_long) uid, strerror (errno));
rc = 1;
}
if (setuid (uid) < 0)
{
logmsg (L_ERR,
- "second setuid(%lu) failed: %s",
+ _("second setuid(%lu) failed: %s"),
(u_long) uid, strerror (errno));
rc = 1;
}
}
else
#endif
{
- logmsg (L_ERR, "setuid(%lu) failed: %s",
+ logmsg (L_ERR, _("setuid(%lu) failed: %s"),
(u_long) uid, strerror (errno));
rc = 1;
}
}
if (html_template_option)
html_template = html_template_option;
euid = geteuid ();
if (uid != 0 && setuid (0) == 0)
{
- logmsg (L_ERR, "seteuid(0) succeeded when it should not");
+ logmsg (L_ERR, _("seteuid(0) succeeded when it should not"));
rc = 1;
}
else if (uid != euid && setuid (euid) == 0)
{
- logmsg (L_ERR, "cannot drop non-root setuid privileges");
+ logmsg (L_ERR, _("cannot drop non-root setuid privileges"));
rc = 1;
}
}
return rc;
}
@@ -431,13 +432,13 @@ change_user ()
if (user == NULL)
return;
if (getuid () == 0)
{
- logmsg (L_NOTICE, "not a superuser: ignoring the `user' statement");
+ logmsg (L_NOTICE, _("not a superuser: ignoring the `user' statement"));
return;
}
pwd = getpwnam (user);
if (pwd)
{
@@ -459,34 +460,35 @@ decode_buffer ()
reply = (Stat_reply *) recv_buffer;
reply->n_addr = ntohl (reply->n_addr);
if (reply->n_addr > MAXADDR)
{
- logmsg (L_NOTICE, "got invalid packet: n_addr = %d", reply->n_addr);
+ logmsg (L_NOTICE, _("got invalid packet: n_addr = %d"),
+ reply->n_addr);
return;
}
reply->timestamp = ntohl (reply->timestamp);
if (verbose_level)
{
char tbuf[sizeof("2009-04-01 00:00:00")];
strftime (tbuf, sizeof tbuf, "%Y-%m-%d %H:%M:%S",
gmtime (&reply->timestamp));
- logmsg (L_INFO, "Received packet: %d %lu - %s", reply->n_addr,
+ logmsg (L_INFO, _("Received packet: %d %lu - %s"), reply->n_addr,
(unsigned long) reply->timestamp, tbuf);
}
sp = reply->stat;
if (!single_process_option)
{
pid_t pid = fork ();
if (pid > 0)
return;
else if (pid < 0)
- logmsg (L_ERR, "can't fork: %s", strerror (errno));
+ logmsg (L_ERR, _("cannot fork: %s"), strerror (errno));
else
{
signal (SIGHUP, SIG_IGN);
signal (SIGCHLD, SIG_IGN);
child = 1;
}
@@ -494,13 +496,13 @@ decode_buffer ()
open_db (TAGR_DB_WR);
for (i = 0; i < reply->n_addr; i++, sp++)
{
sp->in = ntohl (sp->in);
sp->out = ntohl (sp->out);
- verbose (1, "Monitor %s: %lu %lu", sp->name, sp->in, sp->out);
+ verbose (1, _("Monitor %s: %lu %lu"), sp->name, sp->in, sp->out);
report (sp, reply->timestamp);
}
close_db ();
if (child)
exit (0);
@@ -522,16 +524,17 @@ read_input (const char *name)
fp = stdin;
}
else
{
fp = fopen (name, "r");
if (!fp)
- die (EX_OSERR, "cannot open file `%s': %s", name, strerror (errno));
+ die (EX_OSERR, _("cannot open file `%s': %s"),
+ name, strerror (errno));
}
- verbose (2, "Reading `%s'", name);
+ verbose (2, _("Reading `%s'"), name);
open_db (TAGR_DB_WR);
while (getline (&buf, &bufsize, fp) > 0)
{
char *p;
int i;
@@ -544,24 +547,24 @@ read_input (const char *name)
continue;
i = 0;
while (*p && !isspace (*p))
{
if (i > MAX_NAME_LENGTH)
- die (EX_DATAERR, "%s:%lu: ID too long", name, line);
+ die (EX_DATAERR, _("%s:%lu: ID too long"), name, line);
st.name[i++] = *p++;
}
st.name[i] = 0;
if (sscanf (p, " %lu %lu %lu\n", &t, &st.in, &st.out) != 3)
- die (EX_DATAERR, "%s:%lu: invalid input line", name, line);
+ die (EX_DATAERR, _("%s:%lu: invalid input line"), name, line);
report (&st, t);
}
fclose (fp);
close_db ();
- verbose (2, "Finished reading `%s'", name);
+ verbose (2, _("Finished reading `%s'"), name);
}
int
get_port (char *str)
{
int pn;
@@ -572,13 +575,13 @@ get_port (char *str)
{
struct servent *s = getservbyname (str, "udp");
if (s)
pn = s->s_port;
else
{
- logmsg (L_ERR, "no such service: %s", str);
+ logmsg (L_ERR, _("no such service: %s"), str);
return 0;
}
}
return pn;
}
@@ -591,21 +594,21 @@ enum command
enum command command;
RETSIGTYPE
sig_quit (int sig)
{
- logmsg (L_INFO, "exiting on signal %d", sig);
+ logmsg (L_INFO, _("exiting on signal %d"), sig);
unlink (pidfile);
exit (0);
}
RETSIGTYPE
sig_fatal (int sig)
{
- logmsg (L_ERR, "FATAL: exiting on signal %d", sig);
+ logmsg (L_ERR, _("FATAL: exiting on signal %d"), sig);
unlink (pidfile);
exit (EX_UNAVAILABLE);
}
RETSIGTYPE
sig_hup (int sig)
@@ -713,13 +716,13 @@ tagr_restart (char **argv)
#define CHECK_USAGE(cond, opt, mode_opt) \
do \
if (cond) \
- die (EX_USAGE, "%s is meaningless with %s", opt, mode_opt); \
+ die (EX_USAGE, _("%s is meaningless with %s"), opt, mode_opt); \
while (0)
#define CHECK_OPTION(opt, optname) \
do \
{ \
if (opt != import_option) \
@@ -770,13 +773,13 @@ main (int argc, char **argv)
html_template = html_template_option;
argc -= index;
argv += index;
if (argc != 0 && !(list_option || import_option))
- die (EX_USAGE, "Too many arguments");
+ die (EX_USAGE, _("Too many arguments"));
if (readconfig ())
exit (EX_CONFIG);
if (lint_option)
{
@@ -892,22 +895,22 @@ main (int argc, char **argv)
if (!foreground)
{
FILE *fp;
if (daemon (0, 0))
- die (EX_OSERR, "cannot become daemon: %s", strerror (errno));
+ die (EX_OSERR, _("cannot become daemon: %s"), strerror (errno));
if ((fp = fopen (pidfile, "w")) != NULL)
{
fprintf (fp, "%lu\n", (unsigned long) getpid ());
fclose (fp);
}
else
{
- logmsg (L_ERR, "can't write pid file %s: %s",
+ logmsg (L_ERR, _("cannot write pid file %s: %s"),
pidfile, strerror (errno));
}
}
logmsg (L_INFO, _("%s started"), program_version);
diff --git a/src/readconfig.c b/src/readconfig.c
index e60d335..e4e4e83 100644
--- a/src/readconfig.c
+++ b/src/readconfig.c
@@ -378,44 +378,48 @@ static struct grecs_keyword tagr_kw[] = {
{ "log", NULL, N_("Configure logging"),
grecs_type_section, NULL, 0,
NULL, NULL, log_kw },
{ "rate-units", NULL, N_("Name of rate units"),
grecs_type_string, &rate_unit },
- { "number-suffixes", N_("suffixes"), NULL /* FIXME */,
+ { "number-suffixes", N_("suffixes"),
+ N_("Not implemented") /* FIXME */,
grecs_type_string, NULL, 0, cb_number_suffixes },
{ "transparent", NULL, N_("Transparent graphs"),
grecs_type_bool, &transparent_option },
- { "percent", NULL, NULL /* FIXME: descr */,
+ { "percent", NULL,
+ N_("Draw in/out percent graph (not implemented)"), /* FIXME */
grecs_type_bool, &percent_option },
- { "zero-unknown", NULL, NULL /* FIXME: descr */,
+ { "zero-unknown", NULL,
+ N_("Zero-out missing samples (not implemented)") /* FIXME */,
grecs_type_bool, &zero_unknown_option },
- { "fill-incoming", NULL, NULL /* FIXME: descr */,
+ { "fill-incoming", NULL, N_("Fill incoming graph"),
grecs_type_bool, &fill_incoming_option },
{ "color-background", NULL, N_("Set background color"),
grecs_type_int, color_background, 0, cb_color },
- { "color-light", NULL, NULL /* FIXME: descr */,
+ { "color-light", NULL, N_("`Light' color (for the border)"),
grecs_type_int, color_light, 0, cb_color },
- { "color-dark", NULL, NULL /* FIXME: descr */,
+ { "color-dark", NULL, N_("`Dark' color (for the border)"),
grecs_type_int, color_dark, 0, cb_color },
- { "color-major", NULL, NULL /* FIXME: descr */,
+ { "color-major", NULL,
+ N_("`Major' color (boundaries, max. values, zero mark, etc.)"),
grecs_type_int, color_major, 0, cb_color },
- { "color-in", NULL, NULL /* FIXME: descr */,
+ { "color-in", NULL, N_("Color for the input graph"),
grecs_type_int, color_in, 0, cb_color },
- { "color-out", NULL, NULL /* FIXME: descr */,
+ { "color-out", NULL, N_("Color for the output graph"),
grecs_type_int, color_out, 0, cb_color },
- { "color-grid", NULL, NULL /* FIXME: descr */,
+ { "color-percent", NULL, N_("Color for the i/o percent graph"),
+ grecs_type_int, color_percent, 0, cb_color },
+ { "color-grid", NULL, N_("Grid and axes color"),
grecs_type_int, color_grid, 0, cb_color },
- { "color-in-max", NULL, NULL /* FIXME: descr */,
+ { "color-in-max", NULL, N_("Not implemented") /* FIXME */,
grecs_type_int, color_in_max, 0, cb_color },
- { "color-out-max", NULL, NULL /* FIXME: descr */,
+ { "color-out-max", NULL, N_("Not implemented") /* FIXME */,
grecs_type_int, color_out_max, 0, cb_color },
- { "color-percent", NULL, NULL /* FIXME: descr */,
- grecs_type_int, color_percent, 0, cb_color },
/* FIXME */
{ NULL }
};
void
diff --git a/src/report.c b/src/report.c
index ed8a34d..ed3a81b 100644
--- a/src/report.c
+++ b/src/report.c
@@ -50,13 +50,13 @@ open_db (int flag)
strcat (dbname, TAGR_DBNAME);
dbf = gdbm_open (dbname, 0,
flag == TAGR_DB_WR ? GDBM_WRCREAT : GDBM_READER,
TAGR_DBMODE, tagr_db_report);
if (dbf == NULL)
{
- logmsg (L_ERR, "Cannot open database %s: %s",
+ logmsg (L_ERR, _("cannot open database %s: %s"),
dbname, gdbm_strerror (gdbm_errno));
exit (1);
}
}
void
@@ -88,26 +88,27 @@ static void
_read_db (datum key, struct traffic_record **tr)
{
datum content;
content = gdbm_fetch (dbf, key);
if (content.dptr == NULL)
- logmsg (L_NOTICE, "Record for %*.*s not found", key.dsize, key.dsize, key.dptr);
+ logmsg (L_NOTICE, _("record for %*.*s not found"),
+ key.dsize, key.dsize, key.dptr);
else if (content.dsize != sizeof **tr)
{
- logmsg (L_ERR, "Wrong record size for %*.*s: %lu",
+ logmsg (L_ERR, _("wrong record size for %*.*s: %lu"),
key.dsize, key.dsize, key.dptr, content.dsize);
}
else
{
*tr = (struct traffic_record *) content.dptr;
tr_init (*tr);
return;
}
- logmsg (L_NOTICE, "Creating record for %*.*s",
+ logmsg (L_NOTICE, _("creating record for %*.*s"),
key.dsize, key.dsize, key.dptr);
*tr = xmalloc (sizeof **tr);
memset (*tr, 0, sizeof **tr);
tr_init (*tr);
}
@@ -133,24 +134,26 @@ write_db (struct monitor *mon, struct traffic_record *tr)
content.dsize = sizeof *tr;
content.dptr = (char *) tr;
if (gdbm_store (dbf, key, content, GDBM_REPLACE))
{
- logmsg (L_ERR, "Failed to write data for %s: %s",
+ logmsg (L_ERR, _("failed to write data for %s: %s"),
mon->id, gdbm_strerror (gdbm_errno));
}
}
static void
print_queue (const char *title, queue_t *q)
{
int i, count;
count = queue_count (q);
- printf ("%s (%d entries):\n", title, count);
+ printf (ngettext ("%s (%d entry):\n", "%s (%d entries):\n",
+ count),
+ title, count);
for (i = count - 1; i >= 0; i--)
{
struct traffic_history *th = queue_get_ptr (q, i);
printf("%d %g %g\n", count - i, th->inrate, th->outrate);
}
}
@@ -172,26 +175,27 @@ print_tr (datum key, struct traffic_record *tr)
struct tm *tm;
int i, count;
tm = localtime (&tr->last.time);
printf ("ID: %*.*s\n", key.dsize, key.dsize, key.dptr);
strftime (buf, sizeof buf, "%c", tm);
- printf ("Last sample: %lu (%s) %lu %lu\n",
+ printf (_("Last sample: %lu (%s) %lu %lu\n"),
tr->last.time, buf, tr->last.in, tr->last.out);
- printf ("Last rates: %g %g\n", tr->last_rates.inrate, tr->last_rates.outrate);
- print_queue ("Daily rates", &tr->day_hist);
+ printf (_("Last rates: %g %g\n"),
+ tr->last_rates.inrate, tr->last_rates.outrate);
+ print_queue (_("Daily rates"), &tr->day_hist);
- print_avg ("Weekly average", &tr->week_avg);
- print_queue ("Weekly rates", &tr->week_hist);
+ print_avg (_("Weekly average"), &tr->week_avg);
+ print_queue (_("Weekly rates"), &tr->week_hist);
- print_avg ("Monthly average", &tr->month_avg);
- print_queue ("Monthly rates", &tr->month_hist);
+ print_avg (_("Monthly average"), &tr->month_avg);
+ print_queue (_("Monthly rates"), &tr->month_hist);
- print_avg ("Yearly average", &tr->year_avg);
- print_queue ("Yearly rates", &tr->year_hist);
+ print_avg (_("Yearly average"), &tr->year_avg);
+ print_queue (_("Yearly rates"), &tr->year_hist);
}
void
list_db ()
{
datum key;
@@ -229,13 +233,13 @@ report (Stat *stat, time_t timestamp)
read_db (mon, &tr);
update_stats (mon, &s, tr);
write_db (mon, tr);
free (tr);
}
else
- logmsg (L_WARNING, "%s not found in config", stat->name);
+ logmsg (L_WARNING, _("%s not found in config"), stat->name);
}
int
update_monitor (datum key, time_t timestamp, int force)
{
char id[MAX_NAME_LENGTH+1];
@@ -270,19 +274,19 @@ void
rebuild (int force)
{
datum key;
datum content;
time_t now = time (NULL);
- verbose (1, "rebuild initiated");
+ verbose (1, _("rebuild initiated"));
open_db (TAGR_DB_WR);
key = gdbm_firstkey (dbf);
while (key.dptr)
{
datum nextkey = gdbm_nextkey ( dbf, key );
update_monitor (key, now, force);
free (key.dptr);
key = nextkey;
}
close_db ();
- verbose (1, "rebuild finished");
+ verbose (1, _("rebuild finished"));
}
diff --git a/src/stat.c b/src/stat.c
index ed4ab8e..85b76d9 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -42,26 +42,26 @@ interpolate (queue_t *q,
struct traffic_history th;
if (now - last_time <= step)
{
th.inrate = inrate;
th.outrate = outrate;
- verbose (3, "Insert %lu %g %g", next, th.inrate, th.outrate);
+ verbose (3, _("insert %lu %g %g"), next, th.inrate, th.outrate);
queue_put (q, &th);
if (ovf)
ovf (&th, tr, now);
return;
}
for (next = last_time + step; next <= now; next += step)
{
th.inrate = (inrate - last_rates->inrate) * (next - last_time)
/ interval + last_rates->inrate;
th.outrate = (outrate - last_rates->outrate) * (next - last_time)
/ interval + last_rates->outrate;
- verbose (3, "Insert %lu %g %g", next, th.inrate, th.outrate);
+ verbose (3, _("insert %lu %g %g"), next, th.inrate, th.outrate);
queue_put (q, &th);
if (ovf)
ovf (&th, tr, now);
}
}
@@ -89,13 +89,13 @@ overflow (struct traffic_history *th,
ovf, tr);
else
{
struct traffic_history tmp;
tmp.inrate = avg->inrate;
tmp.outrate = avg->outrate;
- verbose (3, "Insert %lu %g %g", now, tmp.inrate, tmp.outrate);
+ verbose (3, _("insert %lu %g %g"), now, tmp.inrate, tmp.outrate);
queue_put (q, &tmp);
}
avg->inrate = avg->outrate = 0;
avg->count = 0;
avg->time = now;
@@ -105,34 +105,37 @@ overflow (struct traffic_history *th,
avg->count++;
}
int
ovf_monthly (struct traffic_history *th, struct traffic_record *tr, time_t now)
{
- verbose (2, "begin overflow_monthly %lu %g %g", now, th->inrate, th->outrate);
+ verbose (2, _("begin overflow_monthly %lu %g %g"),
+ now, th->inrate, th->outrate);
overflow (th, tr, now, NULL, &tr->year_avg, &tr->year_hist,
YEAR_COUNT, YEAR_SAMPLE);
- verbose (2, "end overflow_monthly");
+ verbose (2, _("end overflow_monthly"));
}
int
ovf_weekly (struct traffic_history *th, struct traffic_record *tr, time_t now)
{
- verbose (2, "begin overflow_weekly %lu %g %g", now, th->inrate, th->outrate);
+ verbose (2, _("begin overflow_weekly %lu %g %g"),
+ now, th->inrate, th->outrate);
overflow (th, tr, now, ovf_monthly, &tr->month_avg, &tr->month_hist,
MONTH_COUNT, MONTH_SAMPLE);
- verbose (2, "end overflow_daily");
+ verbose (2, _("end overflow_daily"));
}
int
ovf_daily (struct traffic_history *th, struct traffic_record *tr, time_t now)
{
- verbose (2, "begin overflow_daily %lu %g %g", now, th->inrate, th->outrate);
+ verbose (2, _("begin overflow_daily %lu %g %g"),
+ now, th->inrate, th->outrate);
overflow (th, tr, now, ovf_weekly, &tr->week_avg, &tr->week_hist,
WEEK_COUNT, WEEK_SAMPLE);
- verbose (2, "end overflow_daily");
+ verbose (2, _("end overflow_daily"));
}
void
update_stats (struct monitor *mon, struct traffic_sample *sample,
struct traffic_record *tr)
{
@@ -141,13 +144,13 @@ update_stats (struct monitor *mon, struct traffic_sample *sample,
struct traffic_history *lastp = queue_get_tail (&tr->day_hist);
interval = sample->time - tr->last.time;
if (interval == 0)
{
- logmsg (L_ERR, "Ignoring zero interval");
+ logmsg (L_ERR, _("ignoring zero interval"));
return;
}
inrate = (double) sample->in / interval;
outrate = (double) sample->out / interval;
if (lastp)
{
@@ -214,13 +217,13 @@ _convert (queue_t *q, ovf_t ovf,
interval = hp->time - tr->last.time;
inr