7 /* following for irix6 !! */
8 #define _VA_FP_SAVE_AREA 0
9 static int error_dest = ERROR_STDERR;
10 static char **error_str = NULL;
13 int errors_to(int where, char **place)
17 if (where == ERROR_STRING)
19 if (rv == ERROR_SYSLOG && where != ERROR_SYSLOG)
21 if (where == ERROR_SYSLOG && rv != ERROR_SYSLOG)
24 openlog("metad", LOG_PID, LOG_DAEMON);
32 void error(char *mesg, char *a, char *b, char *c)
36 sprintf(buf, mesg, a, b, c);
41 fprintf(stderr, "metad: %s\n", buf);
44 if (*error_str == NULL)
46 *error_str = (char*)malloc(err_str_len=(strlen(buf)+100));
47 strcpy(*error_str, buf);
49 else if (strlen(*error_str)+strlen(buf)+1 > err_str_len)
51 *error_str = (char*)realloc(*error_str, err_str_len += strlen(buf)+100);
52 strcat(*error_str, buf);
55 strcat(*error_str, buf);
58 syslog(LOG_ERR, "%s", buf);
64 void logmsg(int level,...)
75 va_start(pvar, level);
79 level = va_arg(pvar, int);
81 format = va_arg(pvar, char *);
82 vsprintf(buf, format, pvar);
86 fprintf(stderr, "metad: %s\n", buf);
89 if (*error_str == NULL)
91 *error_str = (char*)malloc(err_str_len=(strlen(buf)+100));
92 strcpy(*error_str, buf);
94 else if (strlen(*error_str)+strlen(buf)+1 > err_str_len)
96 *error_str = (char*)realloc(*error_str, err_str_len += strlen(buf)+100);
97 strcat(*error_str, buf);
100 strcat(*error_str, buf);
103 syslog(level, "%s", buf);
108 void dolog(service_t sv, proc_t p, char *buf)
110 logmsg(LOG_INFO, "%s: %d: %s\n", sv->service, p->pid, buf);