77 lines
3.0 KiB
Plaintext
77 lines
3.0 KiB
Plaintext
|
$OpenBSD: patch-src_rtgutil_c,v 1.1.1.1 2008/07/19 13:52:22 sthen Exp $
|
||
|
--- src/rtgutil.c.orig Thu Sep 25 16:56:04 2003
|
||
|
+++ src/rtgutil.c Mon Jul 7 13:42:39 2008
|
||
|
@@ -34,6 +34,7 @@ int read_rtg_config(char *file, config_t * set)
|
||
|
else if (!strcasecmp(p1, "SNMP_Port")) set->snmp_port = atoi(p2);
|
||
|
else if (!strcasecmp(p1, "Threads")) set->threads = atoi(p2);
|
||
|
else if (!strcasecmp(p1, "DB_Host")) strncpy(set->dbhost, p2, sizeof(set->dbhost));
|
||
|
+ else if (!strcasecmp(p1, "DB_Port")) set->dbport = atoi(p2);
|
||
|
else if (!strcasecmp(p1, "DB_Database")) strncpy(set->dbdb, p2, sizeof(set->dbdb));
|
||
|
else if (!strcasecmp(p1, "DB_User")) strncpy(set->dbuser, p2, sizeof(set->dbuser));
|
||
|
else if (!strcasecmp(p1, "DB_Pass")) strncpy(set->dbpass, p2, sizeof(set->dbpass));
|
||
|
@@ -86,6 +87,7 @@ int write_rtg_config(char *file, config_t * set)
|
||
|
fprintf(fp, "SNMP_Ver\t%d\n", set->snmp_ver);
|
||
|
fprintf(fp, "SNMP_Port\t%d\n", set->snmp_port);
|
||
|
fprintf(fp, "DB_Host\t%s\n", set->dbhost);
|
||
|
+ fprintf(fp, "DB_Port\t%s\n", set->dbport);
|
||
|
fprintf(fp, "DB_Database\t%s\n", set->dbdb);
|
||
|
fprintf(fp, "DB_User\t%s\n", set->dbuser);
|
||
|
fprintf(fp, "DB_Pass\t%s\n", set->dbpass);
|
||
|
@@ -107,6 +109,7 @@ void config_defaults(config_t * set)
|
||
|
set->snmp_port = DEFAULT_SNMP_PORT;
|
||
|
set->threads = DEFAULT_THREADS;
|
||
|
strncpy(set->dbhost, DEFAULT_DB_HOST, sizeof(set->dbhost));
|
||
|
+ set->dbport = DEFAULT_DB_PORT;
|
||
|
strncpy(set->dbdb, DEFAULT_DB_DB, sizeof(set->dbhost));
|
||
|
strncpy(set->dbuser, DEFAULT_DB_USER, sizeof(set->dbhost));
|
||
|
strncpy(set->dbpass, DEFAULT_DB_PASS, sizeof(set->dbhost));
|
||
|
@@ -114,8 +117,8 @@ void config_defaults(config_t * set)
|
||
|
set->withzeros = FALSE;
|
||
|
set->verbose = OFF;
|
||
|
strncpy(config_paths[0], CONFIG_PATH_1, sizeof(config_paths[0]));
|
||
|
- snprintf(config_paths[1], sizeof(config_paths[1]), "%s/etc/", RTG_HOME);
|
||
|
strncpy(config_paths[2], CONFIG_PATH_2, sizeof(config_paths[1]));
|
||
|
+ snprintf(config_paths[1], sizeof(config_paths[1]), "%s/etc/", RTG_HOME);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
@@ -157,29 +160,27 @@ void sleepy(float sleep_time)
|
||
|
|
||
|
/* Timestamp */
|
||
|
void timestamp(char *str) {
|
||
|
- struct timeval now;
|
||
|
+ time_t clock;
|
||
|
struct tm *t;
|
||
|
|
||
|
- gettimeofday(&now, NULL);
|
||
|
- t = localtime(&now.tv_sec);
|
||
|
+ clock = time(NULL);
|
||
|
+ t = localtime(&clock);
|
||
|
printf("[%02d/%02d %02d:%02d:%02d %s]\n", t->tm_mon + 1,
|
||
|
t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, str);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
-
|
||
|
char *file_timestamp() {
|
||
|
- static char str[BUFSIZE];
|
||
|
- struct timeval now;
|
||
|
+ static char str[BUFSIZE];
|
||
|
+ time_t clock;
|
||
|
struct tm *t;
|
||
|
|
||
|
- gettimeofday(&now, NULL);
|
||
|
- t = localtime(&now.tv_sec);
|
||
|
- snprintf(str, sizeof(str), "%02d%02d_%02d:%02d:%02d", t->tm_mon + 1,
|
||
|
+ clock = time(NULL);
|
||
|
+ t = localtime(&clock);
|
||
|
+ snprintf(str, sizeof(str), "%02d%02d_%02d:%02d:%02d", t->tm_mon + 1,
|
||
|
t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
|
||
|
- return(str);
|
||
|
+ return(str);
|
||
|
}
|
||
|
-
|
||
|
|
||
|
int checkPID(char *pidfile) {
|
||
|
FILE *pidptr = NULL;
|