diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/graph.c | 1 | ||||
-rw-r--r-- | src/html.gram.y | 34 | ||||
-rw-r--r-- | src/html.lex.l | 10 | ||||
-rw-r--r-- | src/log.c | 16 | ||||
-rw-r--r-- | src/main.c | 77 | ||||
-rw-r--r-- | src/readconfig.c | 32 | ||||
-rw-r--r-- | src/report.c | 40 | ||||
-rw-r--r-- | src/stat.c | 65 | ||||
-rw-r--r-- | src/tagr.h | 5 |
9 files changed, 149 insertions, 131 deletions
diff --git a/src/graph.c b/src/graph.c index bfd00cb..1464e8b 100644 --- a/src/graph.c +++ b/src/graph.c @@ -55,4 +55,5 @@ int graph_h_margin[2] = { 100, 14 }; int graph_v_margin[2] = { 14, 35 }; +/* FIXME: I18N?? */ char *rate_unit = "Bytes per Second"; 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 @@ -114,5 +114,5 @@ expr : value else if ($1.type != $3.type) { - yyerror ("type mismatch in addition"); + yyerror (_("type mismatch in addition")); init_value (&$$, unspecified_value, NULL); } @@ -146,10 +146,10 @@ expr : value 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); } @@ -168,10 +168,10 @@ expr : value 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); } @@ -190,15 +190,15 @@ expr : value 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); } @@ -216,5 +216,5 @@ expr : value 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); } @@ -231,5 +231,5 @@ expr : value 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); } @@ -274,5 +274,5 @@ create_html (pp_tab_t *tab, char *file, char *dest) 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 (); @@ -287,5 +287,5 @@ create_html (pp_tab_t *tab, char *file, char *dest) 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; @@ -294,5 +294,5 @@ create_html (pp_tab_t *tab, char *file, char *dest) 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)); @@ -495,5 +495,5 @@ read_symtab (pp_tab_t **tab, const char *name) 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; @@ -504,5 +504,5 @@ read_symtab (pp_tab_t **tab, const char *name) if (!p) { - logmsg (L_ERR, "%s:%u: invalid input: %s", + logmsg (L_ERR, _("%s:%u: invalid input: %s"), name, line, buf); status = 1; @@ -524,5 +524,5 @@ read_symtab (pp_tab_t **tab, const char *name) 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; @@ -534,5 +534,5 @@ read_symtab (pp_tab_t **tab, const char *name) default: - logmsg (L_NOTICE, "%s:%u: ignoring unknown command %#03o", + logmsg (L_NOTICE, _("%s:%u: ignoring unknown command %#03o"), name, line, cmd); } 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 @@ -44,5 +44,5 @@ N [0-9]+ if (find_value (yytext+1, &yylval.value)) { - yyerror ("unknown identifier"); + yyerror (_("unknown identifier")); init_value (&yylval.value, unspecified_value, NULL); } @@ -53,5 +53,5 @@ N [0-9]+ if (find_value (yytext+2, &yylval.value)) { - yyerror ("unknown identifier"); + yyerror (_("unknown identifier")); init_value (&yylval.value, unspecified_value, NULL); } @@ -63,5 +63,5 @@ N [0-9]+ if (find_value (yytext+2, &yylval.value)) { - yyerror ("unknown identifier"); + yyerror (_("unknown identifier")); init_value (&yylval.value, unspecified_value, NULL); } @@ -78,5 +78,5 @@ N [0-9]+ if (find_value (yytext+2, &val)) { - yyerror ("unknown identifier"); + yyerror (_("unknown identifier")); init_value (&yylval.value, unspecified_value, NULL); } @@ -131,5 +131,5 @@ html_open (char *file) 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; @@ -30,5 +30,5 @@ #include <tagr.h> -int log_facility = LOGFACILITY; +int log_facility = LOG_FACILITY; char *log_tag; int log_print_severity; /* FIXME: not used */ @@ -52,10 +52,10 @@ int syslog_level[] = { char *level_str[] = { - "debug", - "info", - "notice", - "warning", - "error", - "CRITICAL", + N_("debug"), + N_("info"), + N_("notice"), + N_("warning"), + N_("error"), + N_("CRITICAL"), }; @@ -66,5 +66,5 @@ 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"); @@ -81,6 +81,6 @@ 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 { @@ -113,5 +113,5 @@ static struct argp_option options[] = { 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}, @@ -188,10 +188,10 @@ 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); } @@ -336,5 +336,5 @@ change_privs (uid_t uid, gid_t gid) 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; @@ -346,12 +346,13 @@ change_privs (uid_t uid, gid_t gid) #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 @@ -360,9 +361,9 @@ change_privs (uid_t uid, gid_t gid) { 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; @@ -386,5 +387,5 @@ change_privs (uid_t uid, gid_t gid) { logmsg (L_ERR, - "setreuid(%lu,-1) failed: %s", + _("setreuid(%lu,-1) failed: %s"), (u_long) uid, strerror (errno)); rc = 1; @@ -393,5 +394,5 @@ change_privs (uid_t uid, gid_t gid) { logmsg (L_ERR, - "second setuid(%lu) failed: %s", + _("second setuid(%lu) failed: %s"), (u_long) uid, strerror (errno)); rc = 1; @@ -401,5 +402,5 @@ change_privs (uid_t uid, gid_t gid) #endif { - logmsg (L_ERR, "setuid(%lu) failed: %s", + logmsg (L_ERR, _("setuid(%lu) failed: %s"), (u_long) uid, strerror (errno)); rc = 1; @@ -413,10 +414,10 @@ change_privs (uid_t uid, gid_t gid) 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; } @@ -435,5 +436,5 @@ change_user () if (getuid () == 0) { - logmsg (L_NOTICE, "not a superuser: ignoring the `user' statement"); + logmsg (L_NOTICE, _("not a superuser: ignoring the `user' statement")); return; } @@ -463,5 +464,6 @@ decode_buffer () 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; } @@ -472,5 +474,5 @@ decode_buffer () 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); } @@ -484,5 +486,5 @@ decode_buffer () return; else if (pid < 0) - logmsg (L_ERR, "can't fork: %s", strerror (errno)); + logmsg (L_ERR, _("cannot fork: %s"), strerror (errno)); else { @@ -498,5 +500,5 @@ decode_buffer () 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); } @@ -526,8 +528,9 @@ read_input (const char *name) 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); @@ -548,5 +551,5 @@ read_input (const char *name) { 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++; } @@ -554,10 +557,10 @@ read_input (const char *name) 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); } @@ -576,5 +579,5 @@ get_port (char *str) else { - logmsg (L_ERR, "no such service: %s", str); + logmsg (L_ERR, _("no such service: %s"), str); return 0; } @@ -595,5 +598,5 @@ 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); @@ -603,5 +606,5 @@ 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); @@ -717,5 +720,5 @@ tagr_restart (char **argv) 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) @@ -774,5 +777,5 @@ main (int argc, char **argv) if (argc != 0 && !(list_option || import_option)) - die (EX_USAGE, "Too many arguments"); + die (EX_USAGE, _("Too many arguments")); if (readconfig ()) @@ -896,5 +899,5 @@ main (int argc, char **argv) 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) @@ -905,5 +908,5 @@ main (int argc, char **argv) else { - logmsg (L_ERR, "can't write pid file %s: %s", + logmsg (L_ERR, _("cannot write pid file %s: %s"), pidfile, strerror (errno)); } diff --git a/src/readconfig.c b/src/readconfig.c index e60d335..e4e4e83 100644 --- a/src/readconfig.c +++ b/src/readconfig.c @@ -382,36 +382,40 @@ static struct grecs_keyword tagr_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 */ diff --git a/src/report.c b/src/report.c index ed8a34d..ed3a81b 100644 --- a/src/report.c +++ b/src/report.c @@ -54,5 +54,5 @@ open_db (int flag) 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); @@ -92,8 +92,9 @@ _read_db (datum key, struct traffic_record **tr) 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); } @@ -105,5 +106,5 @@ _read_db (datum key, struct traffic_record **tr) } - logmsg (L_NOTICE, "Creating record for %*.*s", + logmsg (L_NOTICE, _("creating record for %*.*s"), key.dsize, key.dsize, key.dptr); *tr = xmalloc (sizeof **tr); @@ -137,5 +138,5 @@ write_db (struct monitor *mon, struct traffic_record *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)); } @@ -148,5 +149,7 @@ print_queue (const char *title, queue_t *q) 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--) { @@ -176,18 +179,19 @@ print_tr (datum key, struct traffic_record *tr) 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); } @@ -233,5 +237,5 @@ report (Stat *stat, time_t timestamp) } else - logmsg (L_WARNING, "%s not found in config", stat->name); + logmsg (L_WARNING, _("%s not found in config"), stat->name); } @@ -274,5 +278,5 @@ rebuild (int force) time_t now = time (NULL); - verbose (1, "rebuild initiated"); + verbose (1, _("rebuild initiated")); open_db (TAGR_DB_WR); key = gdbm_firstkey (dbf); @@ -285,4 +289,4 @@ rebuild (int force) } close_db (); - verbose (1, "rebuild finished"); + verbose (1, _("rebuild finished")); } @@ -46,5 +46,5 @@ interpolate (queue_t *q, 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) @@ -59,5 +59,5 @@ interpolate (queue_t *q, 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) @@ -93,5 +93,5 @@ overflow (struct traffic_history *th, 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); } @@ -109,8 +109,9 @@ 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")); } @@ -118,8 +119,9 @@ 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")); } @@ -127,8 +129,9 @@ 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")); } @@ -145,5 +148,5 @@ update_stats (struct monitor *mon, struct traffic_sample *sample, if (interval == 0) { - logmsg (L_ERR, "Ignoring zero interval"); + logmsg (L_ERR, _("ignoring zero interval")); return; } @@ -218,5 +221,5 @@ _convert (queue_t *q, ovf_t ovf, if (interval == 0) { - logmsg (L_ERR, "Ignoring zero interval"); + logmsg (L_ERR, _("ignoring zero interval")); break; } @@ -253,9 +256,9 @@ convert_yearly (struct traffic_record *tr, struct traffic_sample *hp, size_t count) { - verbose (2, "begin convert_yearly"); + verbose (2, _("begin convert_yearly")); _convert (&tr->year_hist, NULL, tr, hp, count, YEAR_SAMPLE); compute_avg (&tr->year_avg, &tr->year_hist, &tr->last); - verbose (2, "end convert_yearly"); + verbose (2, _("end convert_yearly")); } @@ -264,5 +267,5 @@ convert_monthly (struct traffic_record *tr, struct traffic_sample *hp, size_t count) { - verbose (2, "begin convert_monthly"); + verbose (2, _("begin convert_monthly")); if (count > MONTH_COUNT+1) convert_yearly (tr, hp + MONTH_COUNT + 1, count - (MONTH_COUNT + 1)); @@ -270,5 +273,5 @@ convert_monthly (struct traffic_record *tr, struct traffic_sample *hp, hp, MONTH_COUNT + 1, MONTH_SAMPLE); compute_avg (&tr->month_avg, &tr->month_hist, &tr->last); - verbose (2, "end convert_monthly"); + verbose (2, _("end convert_monthly")); } @@ -276,5 +279,5 @@ static void convert_weekly (struct traffic_record *tr, struct traffic_sample *hp, size_t count) { - verbose (2, "begin convert_weekly"); + verbose (2, _("begin convert_weekly")); if (count > WEEK_COUNT+1) convert_monthly (tr, hp + WEEK_COUNT + 1, count - (WEEK_COUNT + 1)); @@ -282,5 +285,5 @@ convert_weekly (struct traffic_record *tr, struct traffic_sample *hp, size_t cou tr, hp, WEEK_COUNT + 1, WEEK_SAMPLE); compute_avg (&tr->week_avg, &tr->week_hist, &tr->last); - verbose (2, "end convert_weekly"); + verbose (2, _("end convert_weekly")); } @@ -288,9 +291,9 @@ static void convert_daily (struct traffic_record *tr, struct traffic_sample *hp, size_t count) { - verbose (2, "begin convert_daily"); + verbose (2, _("begin convert_daily")); if (count > DAY_COUNT+1) convert_weekly (tr, hp + DAY_COUNT + 1, count - (DAY_COUNT + 1)); _convert (&tr->day_hist, ovf_daily, tr, hp, DAY_COUNT + 1, DAY_SAMPLE); - verbose (2, "end convert_daily"); + verbose (2, _("end convert_daily")); } @@ -330,13 +333,13 @@ import_log (const char *name) if (!fp) { - logmsg (L_ERR, "cannot open `%s': %s", name, strerror (errno)); + logmsg (L_ERR, _("cannot open `%s': %s"), name, strerror (errno)); return 1; } - verbose (2, "Importing %s", name); + verbose (2, _("importing %s"), name); if (fscanf (fp, "%ld %lu %lu\n", &last.time, &last.in, &last.out) != 3) { - logmsg (L_ERR, "%s:1: Unexpected number of fields", name); + logmsg (L_ERR, _("%s:1: unexpected number of fields"), name); fclose (fp); return 1; @@ -365,5 +368,5 @@ import_log (const char *name) if (hist.time > cur) { - logmsg (L_WARNING, "%s:%lu: is corrupted", name, line); + logmsg (L_WARNING, _("%s:%lu: is corrupted"), name, line); break; } @@ -400,5 +403,5 @@ import_log (const char *name) if (!mon) { - logmsg (L_ERR, "cannot find monitor `%s'", base); + logmsg (L_ERR, _("cannot find monitor `%s'"), base); rc = 1; } @@ -417,8 +420,9 @@ import (const char *dirname) struct stat st; - verbose (2, "Examining `%s'", dirname); + verbose (2, _("examining `%s'"), dirname); if (stat (dirname, &st)) - die (EX_OSERR, "cannot stat file `%s': %s", dirname, strerror (errno)); + die (EX_OSERR, _("cannot stat file `%s': %s"), + dirname, strerror (errno)); else if (S_ISREG (st.st_mode)) { @@ -451,8 +455,9 @@ import (const char *dirname) case GLOB_NOSPACE: - die (EX_UNAVAILABLE, "cannot scan directory: %s", strerror (ENOMEM)); + die (EX_UNAVAILABLE, _("cannot scan directory: %s"), + strerror (ENOMEM)); case GLOB_ABORTED: - die (EX_UNAVAILABLE, "scanning aborted"); + die (EX_UNAVAILABLE, _("scanning aborted")); case GLOB_NOMATCH: @@ -460,9 +465,9 @@ import (const char *dirname) default: - die (EX_UNAVAILABLE, "cannot scan directory `%s'", dirname); + die (EX_UNAVAILABLE, _("cannot scan directory `%s'"), dirname); } } - verbose (1, "Number of imported log files: %d", count); + verbose (1, _("number of imported log files: %d"), count); } @@ -21,5 +21,4 @@ #include <grecs.h> -#define LOGFACILITY LOG_LOCAL5 #define TAGR_CONFIGFILE SYSCONFDIR "/tagr.conf" #define TAGR_TEMPLATE SYSCONFDIR "/tagr.tmpl" @@ -28,6 +27,8 @@ #define TAGR_DBMODE 0600 -#define _(s) s +#define _(s) gettext (s) #define N_(s) s +#define gettext(s) s +#define ngettext(s,p,c) ((c) == 1 ? (s) : (p)) struct monitor |