X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=server-src%2Finfofile.c;h=ef5052ca944f7eb272e00c66e6165688da5afcb1;hb=0de2ad0a86685398621fb8ffa6990c029681bb3a;hp=ae41ff61940dc414b33afe63e712177b0df7672c;hpb=3ab887b9bc819a846c75dd7f2ee5d41fac22b19f;p=debian%2Famanda diff --git a/server-src/infofile.c b/server-src/infofile.c index ae41ff6..ef5052c 100644 --- a/server-src/infofile.c +++ b/server-src/infofile.c @@ -25,7 +25,7 @@ * University of Maryland at College Park */ /* - * $Id: infofile.c,v 1.44.4.4 1999/11/10 14:36:10 oliva Exp $ + * $Id: infofile.c,v 1.44.4.4.8.2 2005/03/16 18:15:28 martinea Exp $ * * manage current info file */ @@ -134,6 +134,8 @@ info_t *info; perf_t *pp; char *s; int ch; + int nb_history; + int i; /* get version: command: lines */ @@ -194,6 +196,9 @@ info_t *info; else if (strncmp(line,"last_level:",11) == 0) { break; /* normal */ } + else if (strncmp(line,"history:",8) == 0) { + break; /* normal */ + } memset(&onestat, 0, sizeof(onestat)); s = line; @@ -268,7 +273,73 @@ info_t *info; if(rc > 2) return -2; rc = 0; - if((line = agets(infof)) == NULL) return -1; + nb_history = 0; + for(i=0;i<=NB_HISTORY+1;i++) { + info->history[i].level = -2; + } + for(rc = -2; (line = agets(infof)) != NULL; free(line)) { + history_t onehistory; /* one history record */ + long date; + + if(line[0] == '/' && line[1] == '/') { + info->history[nb_history].level = -2; + rc = 0; + amfree(line); + return 0; /* normal end of record */ + } + + memset(&onehistory, 0, sizeof(onehistory)); + + s = line; + ch = *s++; + +#define sc "history:" + if(strncmp(line, sc, sizeof(sc)-1) != 0) { + break; + } + s += sizeof(sc)-1; + ch = s[-1]; +#undef sc + + skip_whitespace(s, ch); + if(ch == '\0' || sscanf((s - 1), "%d", &onehistory.level) != 1) { + break; + } + skip_integer(s, ch); + + skip_whitespace(s, ch); + if(ch == '\0' || sscanf((s - 1), "%ld", &onehistory.size) != 1) { + break; + } + skip_integer(s, ch); + + skip_whitespace(s, ch); + if(ch == '\0' || sscanf((s - 1), "%ld", &onehistory.csize) != 1) { + break; + } + skip_integer(s, ch); + + skip_whitespace(s, ch); + if(ch == '\0' || sscanf((s - 1), "%ld", &date) != 1) { + break; + } + skip_integer(s, ch); + + onehistory.date = date; /* time_t not guarranteed to be long */ + + onehistory.secs = -1; + skip_whitespace(s, ch); + if(ch != '\0') { + if(sscanf((s - 1), "%ld", &onehistory.secs) != 1) { + break; + } + skip_integer(s, ch); + } + + info->history[nb_history++] = onehistory; + } + + if((line = agets(infof)) == NULL) return -1; /* // line */ amfree(line); return rc; @@ -328,6 +399,12 @@ info_t *info; } fprintf(infof, "last_level: %d %d\n", info->last_level, info->consecutive_runs); + + for(i=0;info->history[i].level > -1;i++) { + fprintf(infof, "history: %d %ld %ld %ld %ld\n",info->history[i].level, + info->history[i].size, info->history[i].csize, + info->history[i].date, info->history[i].secs); + } fprintf(infof, "//\n"); return 0; @@ -487,6 +564,12 @@ info_t *info; info->last_level = -1; info->consecutive_runs = -1; + for(i=0;i<=NB_HISTORY;i++) { + info->history[i].level = -2; + info->history[i].size = 0; + info->history[i].csize = 0; + info->history[i].date = 0; + } return; }