* University of Maryland at College Park
*/
/*
- * $Id: infofile.c,v 1.44.4.4.8.5 2005/09/30 19:13:36 martinea Exp $
+ * $Id: infofile.c,v 1.57 2006/03/10 11:56:06 martinea Exp $
*
* manage current info file
*/
#include "infofile.h"
#include "token.h"
+static void zero_info P((info_t *));
+
#ifdef TEXTDB
static char *infodir = (char *)0;
static char *infofile = (char *)0;
static char *newinfofile;
static int writing;
+
+ static FILE *open_txinfofile P((char *, char *, char *));
+ static int close_txinfofile P((FILE *));
+ static int read_txinfofile P((FILE *, info_t *));
+ static int write_txinfofile P((FILE *, info_t *));
+ static int delete_txinfofile P((char *, char *));
#else
# define MAX_KEY 256
/*# define HEADER (sizeof(info_t)-DUMP_LEVELS*sizeof(stats_t))*/
#ifdef TEXTDB
-FILE *open_txinfofile(host, disk, mode)
+static FILE *open_txinfofile(host, disk, mode)
char *host;
char *disk;
char *mode;
return infof;
}
-int close_txinfofile(infof)
+static int close_txinfofile(infof)
FILE *infof;
{
int rc = 0;
return rc;
}
-int read_txinfofile(infof, info) /* XXX - code assumes AVG_COUNT == 3 */
+static int read_txinfofile(infof, info) /* XXX - code assumes AVG_COUNT == 3 */
FILE *infof;
info_t *info;
{
onestat.date = date; /* time_t not guarranteed to be long */
- if(level < 0 || level > DUMP_LEVELS-1) break;
+ if(level < 0 || level > DUMP_LEVELS-1)
+ break;
info->inf[level] = onestat;
}
rc = sscanf(line, "last_level: %d %d",
&info->last_level, &info->consecutive_runs);
-
+
amfree(line);
if(rc > 2) return -2;
rc = 0;
for(i=0;i<=NB_HISTORY;i++) {
info->history[i].level = -2;
}
+
for(rc = -2; (line = agets(infof)) != NULL; free(line)) {
history_t onehistory; /* one history record */
long date;
#define sc "history:"
if(strncmp(line, sc, sizeof(sc)-1) != 0) {
+ amfree(line);
break;
}
s += sizeof(sc)-1;
skip_whitespace(s, ch);
if(ch == '\0' || sscanf((s - 1), "%d", &onehistory.level) != 1) {
+ amfree(line);
break;
}
skip_integer(s, ch);
skip_whitespace(s, ch);
if(ch == '\0' || sscanf((s - 1), "%ld", &onehistory.size) != 1) {
+ amfree(line);
break;
}
skip_integer(s, ch);
skip_whitespace(s, ch);
if(ch == '\0' || sscanf((s - 1), "%ld", &onehistory.csize) != 1) {
+ amfree(line);
break;
}
skip_integer(s, ch);
skip_whitespace(s, ch);
if(ch == '\0' || sscanf((s - 1), "%ld", &date) != 1) {
+ amfree(line);
break;
}
skip_integer(s, ch);
skip_whitespace(s, ch);
if(ch != '\0') {
if(sscanf((s - 1), "%ld", &onehistory.secs) != 1) {
+ amfree(line);
break;
}
skip_integer(s, ch);
info->history[nb_history++] = onehistory;
}
+ amfree(line);
if((line = agets(infof)) == NULL) return -1; /* // line */
amfree(line);
return rc;
}
-int write_txinfofile(infof, info)
+static int write_txinfofile(infof, info)
FILE *infof;
info_t *info;
{
return 0;
}
-int delete_txinfofile(host, disk)
+static int delete_txinfofile(host, disk)
char *host;
char *disk;
{
}
t = gmtime(&last);
- ap_snprintf(stamp, sizeof(stamp), "%d:%d:%d:%d:%d:%d",
+ snprintf(stamp, sizeof(stamp), "%d:%d:%d:%d:%d:%d",
t->tm_year+1900, t->tm_mon+1, t->tm_mday,
t->tm_hour, t->tm_min, t->tm_sec);
return sum / n;
}
-void zero_info(info)
+static void zero_info(info)
info_t *info;
{
int i;