projects
/
debian
/
amanda
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'lenny'
[debian/amanda]
/
server-src
/
logfile.c
diff --git
a/server-src/logfile.c
b/server-src/logfile.c
index de063dcfd1782f023f03e8b51f55a98cf169c5a7..488bdca5c3e05835f2a384d5f9ead82a45ffdfae 100644
(file)
--- a/
server-src/logfile.c
+++ b/
server-src/logfile.c
@@
-25,7
+25,7
@@
* University of Maryland at College Park
*/
/*
* University of Maryland at College Park
*/
/*
- * $Id: logfile.c,v 1.
29 2005/12/04 22:56:55
martinea Exp $
+ * $Id: logfile.c,v 1.
31 2006/06/01 14:54:39
martinea Exp $
*
* common log file writing routine
*/
*
* common log file writing routine
*/
@@
-42,7
+42,8
@@
char *logtype_str[] = {
"ERROR", "WARNING", "INFO", "SUMMARY", /* information messages */
"START", "FINISH", /* start/end of a run */
"DISK", /* disk */
"ERROR", "WARNING", "INFO", "SUMMARY", /* information messages */
"START", "FINISH", /* start/end of a run */
"DISK", /* disk */
- "SUCCESS", "PARTIAL", "FAIL", "STRANGE", /* the end of a dump */
+ /* the end of a dump */
+ "DONE", "PART", "PARTPARTIAL", "SUCCESS", "PARTIAL", "FAIL", "STRANGE",
"CHUNK", "CHUNKSUCCESS", /* ... continued */
"STATS", /* statistics */
"MARKER", /* marker for reporter */
"CHUNK", "CHUNKSUCCESS", /* ... continued */
"STATS", /* statistics */
"MARKER", /* marker for reporter */
@@
-51,7
+52,7
@@
char *logtype_str[] = {
char *program_str[] = {
"UNKNOWN", "planner", "driver", "amreport", "dumper", "chunker",
char *program_str[] = {
"UNKNOWN", "planner", "driver", "amreport", "dumper", "chunker",
- "taper", "amflush"
+ "taper", "amflush"
, "amdump", "amidxtaped", "amfetchdump", "amcheckdump"
};
int curlinenum;
};
int curlinenum;
@@
-73,11
+74,12
@@
static int logfd = -1;
*/
/* local functions */
*/
/* local functions */
-static void open_log
P((void)
);
-static void close_log
P((void)
);
+static void open_log
(void
);
+static void close_log
(void
);
-void logerror(msg)
-char *msg;
+void
+logerror(
+ char * msg)
{
log_add(L_FATAL, "%s", msg);
}
{
log_add(L_FATAL, "%s", msg);
}
@@
-88,7
+90,7
@@
printf_arglist_function2(char *log_genstring, logtype_t, typ, char *, pname, cha
va_list argp;
char *leader = NULL;
char linebuf[STR_SIZE];
va_list argp;
char *leader = NULL;
char linebuf[STR_SIZE];
-
+ char *xlated_fmt = dgettext("C", format);
/* format error message */
/* format error message */
@@
-101,8
+103,9
@@
printf_arglist_function2(char *log_genstring, logtype_t, typ, char *, pname, cha
}
arglist_start(argp, format);
}
arglist_start(argp, format);
-
vsnprintf(linebuf, sizeof(linebuf)-1, forma
t, argp);
+
g_vsnprintf(linebuf, SIZEOF(linebuf)-1, xlated_fm
t, argp);
/* -1 to allow for '\n' */
/* -1 to allow for '\n' */
+ arglist_end(argp);
return(vstralloc(leader, linebuf, "\n", NULL));
}
return(vstralloc(leader, linebuf, "\n", NULL));
}
@@
-111,9
+114,9
@@
printf_arglist_function1(void log_add, logtype_t, typ, char *, format)
va_list argp;
int saved_errout;
char *leader = NULL;
va_list argp;
int saved_errout;
char *leader = NULL;
+ char *xlated_fmt = gettext(format);
char linebuf[STR_SIZE];
char linebuf[STR_SIZE];
- int n;
-
+ size_t n;
/* format error message */
/* format error message */
@@
-126,7
+129,8
@@
printf_arglist_function1(void log_add, logtype_t, typ, char *, format)
}
arglist_start(argp, format);
}
arglist_start(argp, format);
- vsnprintf(linebuf, sizeof(linebuf)-1, format, argp);
+ /* use sizeof(linebuf)-2 to save space for a trailing newline */
+ g_vsnprintf(linebuf, SIZEOF(linebuf)-2, xlated_fmt, argp);
/* -1 to allow for '\n' */
arglist_end(argp);
/* -1 to allow for '\n' */
arglist_end(argp);
@@
-139,17
+143,22
@@
printf_arglist_function1(void log_add, logtype_t, typ, char *, format)
if(multiline == -1) open_log();
if(multiline == -1) open_log();
- if (fullwrite(logfd, leader, strlen(leader)) < 0)
- error("log file write error: %s", strerror(errno));
+ if (full_write(logfd, leader, strlen(leader)) < strlen(leader)) {
+ error(_("log file write error: %s"), strerror(errno));
+ /*NOTREACHED*/
+ }
amfree(leader);
amfree(leader);
+ /* add a newline if necessary */
n = strlen(linebuf);
if(n == 0 || linebuf[n-1] != '\n') linebuf[n++] = '\n';
linebuf[n] = '\0';
n = strlen(linebuf);
if(n == 0 || linebuf[n-1] != '\n') linebuf[n++] = '\n';
linebuf[n] = '\0';
- if (fullwrite(logfd, linebuf, n) < 0)
- error("log file write error: %s", strerror(errno));
+ if (full_write(logfd, linebuf, n) < n) {
+ error(_("log file write error: %s"), strerror(errno));
+ /*NOTREACHED*/
+ }
if(multiline != -1) multiline++;
else close_log();
if(multiline != -1) multiline++;
else close_log();
@@
-157,7
+166,8
@@
printf_arglist_function1(void log_add, logtype_t, typ, char *, format)
erroutput_type = saved_errout;
}
erroutput_type = saved_errout;
}
-void log_start_multiline()
+void
+log_start_multiline(void)
{
assert(multiline == -1);
{
assert(multiline == -1);
@@
-166,7
+176,8
@@
void log_start_multiline()
}
}
-void log_end_multiline()
+void
+log_end_multiline(void)
{
assert(multiline != -1);
multiline = -1;
{
assert(multiline != -1);
multiline = -1;
@@
-174,8
+185,9
@@
void log_end_multiline()
}
}
-void log_rename(datestamp)
-char *datestamp;
+void
+log_rename(
+ char * datestamp)
{
char *conf_logdir;
char *logfile;
{
char *conf_logdir;
char *logfile;
@@
-186,16
+198,11
@@
char *datestamp;
if(datestamp == NULL) datestamp = "error";
if(datestamp == NULL) datestamp = "error";
- conf_logdir = getconf_str(CNF_LOGDIR);
- if (*conf_logdir == '/') {
- conf_logdir = stralloc(conf_logdir);
- } else {
- conf_logdir = stralloc2(config_dir, conf_logdir);
- }
+ conf_logdir = config_dir_relative(getconf_str(CNF_LOGDIR));
logfile = vstralloc(conf_logdir, "/log", NULL);
for(seq = 0; 1; seq++) { /* if you've got MAXINT files in your dir... */
logfile = vstralloc(conf_logdir, "/log", NULL);
for(seq = 0; 1; seq++) { /* if you've got MAXINT files in your dir... */
-
snprintf(seq_str, sizeof(seq_str), "%d
", seq);
+
g_snprintf(seq_str, SIZEOF(seq_str), "%u
", seq);
fname = newvstralloc(fname,
logfile,
".", datestamp,
fname = newvstralloc(fname,
logfile,
".", datestamp,
@@
-204,9
+211,11
@@
char *datestamp;
if(stat(fname, &statbuf) == -1 && errno == ENOENT) break;
}
if(stat(fname, &statbuf) == -1 && errno == ENOENT) break;
}
- if(rename(logfile, fname) == -1)
- error(
"could not rename \"%s\" to \"%s\": %s"
,
+ if(rename(logfile, fname) == -1)
{
+ error(
_("could not rename \"%s\" to \"%s\": %s")
,
logfile, fname, strerror(errno));
logfile, fname, strerror(errno));
+ /*NOTREACHED*/
+ }
amfree(fname);
amfree(logfile);
amfree(fname);
amfree(logfile);
@@
-214,44
+223,56
@@
char *datestamp;
}
}
-static void open_log()
+static void
+open_log(void)
{
char *conf_logdir;
{
char *conf_logdir;
- conf_logdir = getconf_str(CNF_LOGDIR);
- if (*conf_logdir == '/') {
- conf_logdir = stralloc(conf_logdir);
- } else {
- conf_logdir = stralloc2(config_dir, conf_logdir);
- }
+ /* now that we have a logfile, let the debug module know how to write
+ * error messages to it. This is due to some rather obscure linking
+ * problems. */
+ set_logerror(logerror);
+
+ conf_logdir = config_dir_relative(getconf_str(CNF_LOGDIR));
logfile = vstralloc(conf_logdir, "/log", NULL);
amfree(conf_logdir);
logfd = open(logfile, O_WRONLY|O_CREAT|O_APPEND, 0600);
logfile = vstralloc(conf_logdir, "/log", NULL);
amfree(conf_logdir);
logfd = open(logfile, O_WRONLY|O_CREAT|O_APPEND, 0600);
- if(logfd == -1)
- error("could not open log file %s: %s", logfile, strerror(errno));
+ if(logfd == -1) {
+ error(_("could not open log file %s: %s"), logfile, strerror(errno));
+ /*NOTREACHED*/
+ }
- if(amflock(logfd, "log") == -1)
- error("could not lock log file %s: %s", logfile, strerror(errno));
+ if(amflock(logfd, "log") == -1) {
+ error(_("could not lock log file %s: %s"), logfile, strerror(errno));
+ /*NOTREACHED*/
+ }
}
}
-static void close_log()
+static void
+close_log(void)
{
{
- if(amfunlock(logfd, "log") == -1)
- error("could not unlock log file %s: %s", logfile, strerror(errno));
+ if(amfunlock(logfd, "log") == -1) {
+ error(_("could not unlock log file %s: %s"), logfile, strerror(errno));
+ /*NOTREACHED*/
+ }
- if(close(logfd) == -1)
- error("close log file: %s", strerror(errno));
+ if(close(logfd) == -1) {
+ error(_("close log file: %s"), strerror(errno));
+ /*NOTREACHED*/
+ }
logfd = -1;
amfree(logfile);
}
logfd = -1;
amfree(logfile);
}
-
-int get_logline(logf)
-FILE *logf;
+/* WARNING: Function accesses globals curstr, curlog, and curprog
+ * WARNING: Function has static member logline, returned via globals */
+int
+get_logline(
+ FILE * logf)
{
static char *logline = NULL;
char *logstr, *progstr;
{
static char *logline = NULL;
char *logstr, *progstr;
@@
-259,7
+280,12
@@
FILE *logf;
int ch;
amfree(logline);
int ch;
amfree(logline);
- if((logline = agets(logf)) == NULL) return 0;
+ while ((logline = agets(logf)) != NULL) {
+ if (logline[0] != '\0')
+ break;
+ amfree(logline);
+ }
+ if (logline == NULL) return 0;
curlinenum++;
s = logline;
ch = *s++;
curlinenum++;
s = logline;
ch = *s++;