X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=server-src%2Ffind.c;h=74b712c464865e9f3a3f177c750a8c5a7ac9d961;hb=refs%2Ftags%2Fupstream%2F3.2.1;hp=dadbd5738ba0f7b6d844f25d5816ad13177f7ce6;hpb=b116e9366c7b2ea2c2eb53b0a13df4090e176235;p=debian%2Famanda diff --git a/server-src/find.c b/server-src/find.c index dadbd57..74b712c 100644 --- a/server-src/find.c +++ b/server-src/find.c @@ -40,7 +40,8 @@ #include "cmdline.h" int find_match(char *host, char *disk); -char *find_nicedate(char *datestamp); +static char *find_nicedate(char *datestamp); +static int len_find_nicedate(char *datestamp); static int find_compare(const void *, const void *); static int parse_taper_datestamp_log(char *logline, char **datestamp, char **level); static gboolean logfile_has_tape(char * label, char * datestamp, @@ -287,7 +288,7 @@ search_holding_disk( dumpfile_free_data(&file); } - g_slist_free_full(holding_file_list); + slist_free_full(holding_file_list, g_free); } static int @@ -402,10 +403,9 @@ print_find_result( for(output_find_result=output_find; output_find_result; output_find_result=output_find_result->next) { - char *qdiskname; char *s; - len=strlen(find_nicedate(output_find_result->timestamp)); + len=len_find_nicedate(output_find_result->timestamp); if((int)len > max_len_datestamp) max_len_datestamp=(int)len; @@ -413,16 +413,12 @@ print_find_result( if((int)len > max_len_hostname) max_len_hostname = (int)len; - qdiskname=quote_string(output_find_result->diskname); - len=strlen(qdiskname); - amfree(qdiskname); + len = len_quote_string(output_find_result->diskname); if((int)len > max_len_diskname) max_len_diskname = (int)len; if (output_find_result->label != NULL) { - char *qlabel = quote_string(output_find_result->label); - len=strlen(qlabel); - amfree(qlabel); + len = len_quote_string(output_find_result->label); if((int)len > max_len_label) max_len_label = (int)len; } @@ -540,7 +536,7 @@ find_match( return (dp && dp->todo); } -char * +static char * find_nicedate( char *datestamp) { @@ -576,6 +572,17 @@ find_nicedate( return nice; } +static int +len_find_nicedate( + char *datestamp) +{ + if(strlen(datestamp) <= 8) { + return 10; + } else { + return 19; + } +} + static int parse_taper_datestamp_log( char *logline, @@ -695,7 +702,7 @@ search_logfile( char *number; int fileno; char *current_label = stralloc(""); - char *rest; + char *rest, *rest_undo; char *ck_label=NULL; int level = 0; off_t filenum; @@ -709,9 +716,6 @@ search_logfile( find_result_t *a_part_find; gboolean right_label = FALSE; gboolean found_something = FALSE; - regex_t regex; - int reg_result; - regmatch_t pmatch[4]; double sec; off_t kb; off_t orig_kb; @@ -886,69 +890,82 @@ search_logfile( continue; } rest = s - 1; - if((s = strchr(s, '\n')) != NULL) { - *s = '\0'; - } - - /* extract sec, kb, kps, orig-kb from 'rest', if present. This isn't the stone age - * anymore, so we'll just do it the easy way (a regex) */ - bzero(®ex, sizeof(regex)); - reg_result = regcomp(®ex, - "\\[sec ([0-9.]+) kb ([0-9]+) kps [0-9.]+ orig-kb ([0-9]+)\\]", REG_EXTENDED); - if (reg_result != 0) { - error("Error compiling regular expression for parsing log lines"); - /* NOTREACHED */ - } - - /* an error here just means the line wasn't found -- not fatal. */ - reg_result = regexec(®ex, rest, sizeof(pmatch)/sizeof(*pmatch), pmatch, 0); - if (reg_result == 0) { - char *str; - - str = find_regex_substring(rest, pmatch[1]); - sec = atof(str); - amfree(str); - - str = find_regex_substring(rest, pmatch[2]); - kb = OFF_T_ATOI(str); - amfree(str); - - str = find_regex_substring(rest, pmatch[3]); - orig_kb = OFF_T_ATOI(str); - amfree(str); - } else { - regfree(®ex); - bzero(®ex, sizeof(regex)); - /* the .* at the end of this captures the old {wr: .. } statistics */ - reg_result = regcomp(®ex, - "\\[sec ([0-9.]+) kb ([0-9]+) kps [0-9.]+.*\\]", REG_EXTENDED); - if (reg_result != 0) { - error("Error compiling regular expression for parsing log lines"); - /* NOTREACHED */ + skip_non_whitespace(s, ch); + rest_undo = s - 1; + *rest_undo = '\0'; + if (strcmp(rest, "[sec") == 0) { + skip_whitespace(s, ch); + if(ch == '\0') { + g_printf(_("strange log line in %s \"%s\"\n"), + logfile, curstr); + continue; + } + sec = atof(s - 1); + skip_non_whitespace(s, ch); + skip_whitespace(s, ch); + rest = s - 1; + skip_non_whitespace(s, ch); + rest_undo = s - 1; + *rest_undo = '\0'; + if (strcmp(rest, "kb") != 0) { + g_printf(_("Bstrange log line in %s \"%s\"\n"), + logfile, curstr); + continue; } - /* an error here just means the line wasn't found -- not fatal. */ - reg_result = regexec(®ex, rest, sizeof(pmatch)/sizeof(*pmatch), pmatch, 0); - if (reg_result == 0) { - char *str; - - str = find_regex_substring(rest, pmatch[1]); - sec = atof(str); - amfree(str); + skip_whitespace(s, ch); + if (ch == '\0') { + g_printf(_("strange log line in %s \"%s\"\n"), + logfile, curstr); + continue; + } + kb = atof(s - 1); + skip_non_whitespace(s, ch); + skip_whitespace(s, ch); + rest = s - 1; + skip_non_whitespace(s, ch); + rest_undo = s - 1; + *rest_undo = '\0'; + if (strcmp(rest, "kps") != 0) { + g_printf(_("Cstrange log line in %s \"%s\"\n"), + logfile, curstr); + continue; + } - str = find_regex_substring(rest, pmatch[2]); - kb = OFF_T_ATOI(str); - amfree(str); + skip_whitespace(s, ch); + if (ch == '\0') { + g_printf(_("strange log line in %s \"%s\"\n"), + logfile, curstr); + continue; + } + /* kps = atof(s - 1); */ + skip_non_whitespace(s, ch); + skip_whitespace(s, ch); + rest = s - 1; + skip_non_whitespace(s, ch); + rest_undo = s - 1; + *rest_undo = '\0'; + if (strcmp(rest, "orig-kb") != 0) { orig_kb = 0; } else { - sec = 0; - kb = 0; - orig_kb = 0; + + skip_whitespace(s, ch); + if(ch == '\0') { + g_printf(_("strange log line in %s \"%s\"\n"), + logfile, curstr); + continue; + } + orig_kb = atof(s - 1); } + } else { + sec = 0; + kb = 0; + orig_kb = 0; + *rest_undo = ' '; } - if (strncmp(rest, "error ", 6) == 0) rest += 6; - if (strncmp(rest, "config ", 7) == 0) rest += 7; - regfree(®ex); + + if (strncmp(rest, "error", 5) == 0) rest += 6; + if (strncmp(rest, "config", 6) == 0) rest += 7; dp = lookup_disk(host,disk); if ( dp == NULL ) {