⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reporter.c

📁 开源备份软件源码 AMANDA, the Advanced Maryland Automatic Network Disk Archiver, is a backup system that a
💻 C
📖 第 1 页 / 共 5 页
字号:
    s[-1] = '\0';    diskname = unquote_string(fp);    s[-1] = (char)ch;        skip_whitespace(s, ch);    if(ch == '\0') { 	bogus_line(s - 1); 	amfree(hostname); 	amfree(diskname); 	return NULL;    }    fp = s - 1;    skip_non_whitespace(s, ch);    s[-1] = '\0';    datestamp = stralloc(fp);    s[-1] = (char)ch;     skip_whitespace(s, ch);    if(ch == '\0' || sscanf(s - 1, "%d", &chunk) != 1) {	bogus_line(s - 1);	amfree(hostname);	amfree(diskname);	amfree(datestamp);	return NULL;    }    skip_integer(s, ch);    if (ch != '\0' && s[-1] == '/') {	s++; ch = s[-1];	if (sscanf(s - 1, "%d", &totpart) != 1) {	    bogus_line(s - 1);	    amfree(hostname);	    amfree(diskname);	    amfree(datestamp);	    return NULL;	}	skip_integer(s, ch);    }    skip_whitespace(s, ch);    if(ch == '\0' || sscanf(s - 1, "%d", &level) != 1) {	bogus_line(s - 1);	amfree(hostname);	amfree(diskname);	amfree(datestamp);	return NULL;    }    skip_integer(s, ch);        /*@ignore@*/    if(level < 0 || level > 9) { 	amfree(hostname); 	amfree(diskname); 	amfree(datestamp); 	return NULL;    }    /*@end@*/     skip_whitespace(s, ch);    if(sscanf(s - 1,"[sec %lf kb %lf kps %lf", &sec, &kbytes, &kps) != 3)  { 	bogus_line(s - 1); 	amfree(hostname); 	amfree(diskname); 	amfree(datestamp); 	return NULL;    }            dp = lookup_disk(hostname, diskname);    if(dp == NULL) { 	char *str = NULL;	 	str = vstrallocf(_("  %s ERROR [not in disklist]"),			prefix(hostname, diskname, level)); 	addline(&errsum, str); 	amfree(str); 	amfree(hostname); 	amfree(diskname); 	amfree(datestamp); 	return NULL;    }        repdata = find_repdata(dp, datestamp, level);        sp = &(repdata->taper);        i = level > 0;        amfree(hostname);    amfree(diskname);    amfree(datestamp);        if(current_tape == NULL) { 	error("current_tape == NULL");    }    if (sp->filenum == 0) { 	sp->filenum = ++tapefcount; 	sp->tapelabel = current_tape->label;    }    tapechunks[level] +=1;    stats[i].tapechunks +=1;    current_tape->taper_time += sec;    current_tape->coutsize += kbytes;    current_tape->tapechunks += 1;    return repdata;}static repdata_t *handle_success(    logtype_t	logtype){    disk_t *dp;    double sec = 0.0;    double kps = 0.0;    double kbytes = 0.0;    double origkb = 0.0;    timedata_t *sp;    int i;    char *s, *fp, *qdiskname;    int ch;    char *hostname = NULL;    char *diskname = NULL;    repdata_t *repdata;    int level = 0;    int totpart = 0;    char *datestamp;    (void)logtype;    if(curprog != P_TAPER && curprog != P_DUMPER && curprog != P_PLANNER &&       curprog != P_CHUNKER) {	bogus_line(curstr);	return NULL;    }    s = curstr;    ch = *s++;    skip_whitespace(s, ch);    if(ch == '\0') {	bogus_line(s - 1);	return NULL;    }    fp = s - 1;    skip_non_whitespace(s, ch);    s[-1] = '\0';    hostname = stralloc(fp);    s[-1] = (char)ch;    skip_whitespace(s, ch);    if(ch == '\0') {	bogus_line(s - 1);	amfree(hostname);	return NULL;    }    qdiskname = s - 1;    skip_quoted_string(s, ch);    s[-1] = '\0';    diskname = unquote_string(qdiskname);    skip_whitespace(s, ch);    if(ch == '\0') {	bogus_line(s - 1);	amfree(hostname);	amfree(diskname);	return NULL;    }    fp = s - 1;    skip_non_whitespace(s, ch);    s[-1] = '\0';    datestamp = stralloc(fp);    s[-1] = (char)ch;    //datestamp is optional    if(strlen(datestamp) < 6) {	totpart = atoi(datestamp);	datestamp = newstralloc(datestamp, run_datestamp);    }    else {	skip_whitespace(s, ch);	if(ch == '\0' || sscanf(s - 1, "%d", &totpart) != 1) {	    bogus_line(s - 1);	    amfree(hostname);	    amfree(diskname);	    amfree(datestamp);	    return NULL;	}	skip_integer(s, ch);    }    skip_whitespace(s, ch);    //totpart is optional    if (*(s-1) == '"')	s++;    if (*(s-1) == '[') {	level = totpart;	totpart = -1;    } else {	if(ch == '\0' || sscanf(s - 1, "%d", &level) != 1) {	    bogus_line(s - 1);	    amfree(hostname);	    amfree(diskname);	    amfree(datestamp);	    return NULL;	}	skip_integer(s, ch);	skip_whitespace(s, ch);    }    if(level < 0 || level > 9) {	amfree(hostname);	amfree(diskname);	amfree(datestamp);	return NULL;    }				/* Planner success messages (for skipped				   dumps) do not contain statistics */    if(curprog != P_PLANNER) {	if(*(s - 1) == '"')	    s++;	if((curprog != P_DUMPER)	    || (sscanf(s - 1,"[sec %lf kb %lf kps %lf orig-kb %lf", 		  &sec, &kbytes, &kps, &origkb) != 4))  {	    origkb = -1;	    if(sscanf(s - 1,"[sec %lf kb %lf kps %lf",		      &sec, &kbytes, &kps) != 3) {		bogus_line(s - 1);	        amfree(hostname);	        amfree(diskname);	        amfree(datestamp);		return NULL;	    }	}	else {	    if(!isnormal(origkb))		origkb = 0.1;	}    }    dp = lookup_disk(hostname, diskname);    if(dp == NULL) {	addtoX_summary(&first_failed, &last_failed, hostname, qdiskname, level,		       _("ERROR [not in disklist]"));	exit_status |= STATUS_FAILED;	amfree(hostname);	amfree(diskname);	amfree(datestamp);	return NULL;    }    repdata = find_repdata(dp, datestamp, level);    if(curprog == P_PLANNER) {	repdata->dumper.result = L_SKIPPED;	amfree(hostname);	amfree(diskname);	amfree(datestamp);	return repdata;    }    if(curprog == P_TAPER)	sp = &(repdata->taper);    else if(curprog == P_DUMPER)	sp = &(repdata->dumper);    else sp = &(repdata->chunker);    i = level > 0;    if(origkb < 0.0) {	info_t inf;	struct tm *tm;	int Idatestamp;	get_info(hostname, diskname, &inf);        tm = localtime(&inf.inf[level].date);	if (tm) {            Idatestamp = 10000*(tm->tm_year+1900) +			 100*(tm->tm_mon+1) + tm->tm_mday;	} else {	    Idatestamp = 19000101;	}	if(atoi(datestamp) == Idatestamp) {	    /* grab original size from record */	    origkb = (double)inf.inf[level].size;	}	else	    origkb = 0.0;    }    if (curprog == P_DUMPER &&	(sp->result == L_FAIL || sp->result == L_PARTIAL)) {	addtoX_summary(&first_failed, &last_failed, hostname, qdiskname, level,		       _("was successfully retried"));    }    amfree(hostname);    amfree(diskname);    amfree(datestamp);    sp->result = L_SUCCESS;    sp->datestamp = repdata->datestamp;    sp->sec = sec;    sp->kps = kps;    sp->origsize = origkb;    sp->outsize = kbytes;    if(curprog == P_TAPER) {	if(current_tape == NULL) {	    error(_("current_tape == NULL"));	    /*NOTREACHED*/	}	stats[i].taper_time += sec;	sp->filenum = ++tapefcount;	sp->tapelabel = current_tape->label;	sp->totpart = totpart;	tapedisks[level] +=1;	stats[i].tapedisks +=1;	stats[i].tapesize += kbytes;	sp->outsize = kbytes;	if(!isnormal(repdata->chunker.outsize) && isnormal(repdata->dumper.outsize)) { /* dump to tape */	    stats[i].outsize += kbytes;	    if (abs(kbytes - origkb) >= 32) {		stats[i].coutsize += kbytes;	    }	}	current_tape->tapedisks += 1;    }    if(curprog == P_DUMPER) {	stats[i].dumper_time += sec;	if (abs(kbytes - origkb) < 32) {	    sp->origsize = kbytes;	}	else {	    stats[i].corigsize += sp->origsize;	}	dumpdisks[level] +=1;	stats[i].dumpdisks +=1;	stats[i].origsize += sp->origsize;    }    if(curprog == P_CHUNKER) {	sp->outsize = kbytes;	stats[i].outsize += kbytes;	if (abs(kbytes - origkb) >= 32) {	    stats[i].coutsize += kbytes;	}    }    return repdata;}static voidhandle_partial(void){    repdata_t *repdata;    timedata_t *sp;    repdata = handle_success(L_PARTIAL);    if (!repdata)	return;    if(curprog == P_TAPER)	sp = &(repdata->taper);    else if(curprog == P_DUMPER)	sp = &(repdata->dumper);    else sp = &(repdata->chunker);    sp->result = L_PARTIAL;}static voidhandle_strange(void){    char *str = NULL;    char *strangestr = NULL;    repdata_t *repdata;    char *qdisk;    repdata = handle_success(L_SUCCESS);    if (!repdata)	return;    qdisk = quote_string(repdata->disk->name);    addline(&strangedet,"");    str = vstrallocf("/-- %s STRANGE",		prefix(repdata->disk->host->hostname, qdisk, repdata->level));    addline(&strangedet, str);    amfree(str);    while(contline_next()) {	char *s, ch;	get_logline(logfile);	s = curstr;	if(strncmp_const_skip(curstr, "sendbackup: warning ", s, ch) == 0) {	    strangestr = newstralloc(strangestr, s);	}	addline(&strangedet, curstr);    }    addline(&strangedet,"\\--------");    str = vstrallocf("STRANGE %s", strangestr? strangestr : _("(see below)"));    addtoX_summary(&first_strange, &last_strange,		   repdata->disk->host->hostname, qdisk, repdata->level, str);    exit_status |= STATUS_STRANGE;    amfree(qdisk);    amfree(str);    amfree(strangestr);}static voidhandle_failed(void){    disk_t *dp;    char *hostname;    char *diskname;    char *datestamp;    char *errstr;    int level = 0;    char *s, *fp, *qdiskname;    int ch;    char *str = NULL;    repdata_t *repdata;    timedata_t *sp;    hostname = NULL;    diskname = NULL;    s = curstr;    ch = *s++;    skip_whitespace(s, ch);    if(ch == '\0') {	bogus_line(s - 1);	return;    }    hostname = s - 1;    skip_non_whitespace(s, ch);    s[-1] = '\0';    skip_whitespace(s, ch);    if(ch == '\0') {	bogus_line(s - 1);	return;    }    qdiskname = s - 1;    skip_quoted_string(s, ch);    s[-1] = '\0';    diskname = unquote_string(qdiskname);    skip_whitespace(s, ch);    if(ch == '\0') {	bogus_line(s - 1);	amfree(diskname);	return;    }    fp = s - 1;    skip_non_whitespace(s, ch);    s[-1] = '\0';    datestamp = stralloc(fp);    if(strlen(datestamp) < 3) { /* there is no datestamp, it's the level */	level = atoi(datestamp);	datestamp = newstralloc(datestamp, run_datestamp);    }    else { /* read the level */	skip_whitespace(s, ch);	if(ch == '\0' || sscanf(s - 1, "%d", &level) != 1) {	    bogus_line(s - 1);	    amfree(datestamp);	    amfree(diskname);	    return;	}	skip_integer(s, ch);    }    skip_whitespace(s, ch);    if(ch == '\0') {	bogus_line(s - 1);	amfree(datestamp);	amfree(diskname);	return;    }    errstr = s - 1;    if((s = strchr(errstr, '\n')) != NULL) {	*s = '\0';    }    dp = lookup_disk(hostname, diskname);    amfree(diskname);    if(dp == NULL) {	addtoX_summary(&first_failed, &last_failed, hostname, qdiskname, level,		       _("ERROR [not in disklist]"));    } else {	repdata = find_repdata(dp, datestamp, level);	if(curprog == P_TAPER)	    sp = &(repdata->taper);	else sp = &(repdata->dumper);	if(sp->result != L_SUCCESS)	    sp->result = L_FAIL;    }    amfree(datestamp);    str = vstrallocf(_("FAILED %s"), errstr);    addtoX_summary(&first_failed, &last_failed, hostname, qdiskname, level,		   str);    amfree(str);    if(curprog == P_DUMPER) {	addline(&errdet,"");	str = vstrallocf("/-- %s FAILED %s",			prefix(hostname, qdiskname, level), 			errstr);	addline(&errdet, str);	amfree(str);	while(contline_next()) {	    get_logline(logfile);	    addline(&errdet, curstr);	}	addline(&errdet,"\\--------");	exit_status |= STATUS_FA

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -