Skip to content

Commit

Permalink
added support for restoring rrdtool 1.0.x files ... removed support f…
Browse files Browse the repository at this point in the history
…or old HW patched rrd format created by an early patched version of 1.0.x

git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1446 a5681a0c-68f1-0310-ab6d-d61299d08faa
  • Loading branch information
oetiker committed Jul 23, 2008
1 parent f8600c7 commit 39d1a7d
Showing 1 changed file with 14 additions and 41 deletions.
55 changes: 14 additions & 41 deletions src/rrd_restore.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ static int parse_tag_rra_cdp_prep_ds(

status = 0;
for (child = node->xmlChildrenNode; child != NULL; child = child->next) {
if (atoi(rrd->stat_head->version) == 1){
cdp_prep->scratch[CDP_primary_val].u_val = 0.0;
cdp_prep->scratch[CDP_secondary_val].u_val = 0.0;
}
if ((xmlStrcmp(child->name, (const xmlChar *) "comment") == 0)
|| (xmlStrcmp(child->name, (const xmlChar *) "text") == 0))
/* ignore */ ;
Expand Down Expand Up @@ -385,45 +389,6 @@ static int parse_tag_rra_cdp_prep_ds(
status = get_int_from_node(doc, child,
(int *) &cdp_prep->
scratch[CDP_unkn_pdp_cnt].u_cnt);
/*
* Compatibility code for 1.0.49
*/
else if (xmlStrcmp(child->name, (const xmlChar *) "value") == 0) { /* {{{ */
unsigned int i = 0;
rra_def_t *rra_def = rrd->rra_def + (rrd->stat_head->rra_cnt - 1);

while (42) {
if (i >= ARRAY_LENGTH(cdp_prep->scratch)) {
status = -1;
break;
}

if ((cf_conv(rra_def->cf_nam) == CF_FAILURES)
|| (i == CDP_unkn_pdp_cnt)
|| (i == CDP_null_count)
|| (i == CDP_last_null_count))
status = get_int_from_node(doc, child,
(int *) &cdp_prep->scratch[i].
u_cnt);
else
status = get_double_from_node(doc, child,
&cdp_prep->scratch[i].
u_val);

if (status != 0)
break;

/* When this loops exits (sucessfully) `child' points to the last
* `value' tag in the list. */
if ((child->next == NULL)
|| (xmlStrcmp(child->name, (const xmlChar *) "value") !=
0))
break;

child = child->next;
i++;
}
} /* }}} */
else {
rrd_set_error("parse_tag_rra_cdp_prep: Unknown tag: %s",
child->name);
Expand Down Expand Up @@ -708,7 +673,12 @@ static int parse_tag_rra(
else if (xmlStrcmp(child->name, (const xmlChar *) "pdp_per_row") == 0)
status = get_int_from_node(doc, child,
(int *) &cur_rra_def->pdp_cnt);
else if (xmlStrcmp(child->name, (const xmlChar *) "params") == 0)
else if (atoi(rrd->stat_head->version) == 1
&& xmlStrcmp(child->name, (const xmlChar *) "xff") == 0)
status = get_double_from_node(doc, child,
(double *) &cur_rra_def->par[RRA_cdp_xff_val].u_val);
else if (atoi(rrd->stat_head->version) >= 2
&& xmlStrcmp(child->name, (const xmlChar *) "params") == 0)
status = parse_tag_rra_params(doc, child, cur_rra_def);
else if (xmlStrcmp(child->name, (const xmlChar *) "cdp_prep") == 0)
status = parse_tag_rra_cdp_prep(doc, child, rrd, cur_cdp_prep);
Expand Down Expand Up @@ -1025,7 +995,10 @@ static int write_file(
return (-1);
}
}

if (atoi(rrd->stat_head->version) < 3){
/* we output 3 or higher */
strcpy(rrd->stat_head->version,"0003");
}
fwrite(rrd->stat_head, sizeof(stat_head_t), 1, fh);
fwrite(rrd->ds_def, sizeof(ds_def_t), rrd->stat_head->ds_cnt, fh);
fwrite(rrd->rra_def, sizeof(rra_def_t), rrd->stat_head->rra_cnt, fh);
Expand Down

0 comments on commit 39d1a7d

Please sign in to comment.