- fclose(infile);
- fclose(outfile);
- return(-1);
- }
- fwrite(rrdnew.stat_head, sizeof(stat_head_t),1,outfile);
- fwrite(rrdnew.ds_def,sizeof(ds_def_t),rrdnew.stat_head->ds_cnt,outfile);
- fwrite(rrdnew.rra_def,sizeof(rra_def_t),rrdnew.stat_head->rra_cnt,outfile);
- fwrite(rrdnew.live_head,sizeof(live_head_t),1,outfile);
- fwrite(rrdnew.pdp_prep,sizeof(pdp_prep_t),rrdnew.stat_head->ds_cnt,outfile);
- fwrite(rrdnew.cdp_prep,sizeof(cdp_prep_t),rrdnew.stat_head->ds_cnt*rrdnew.stat_head->rra_cnt,outfile);
- fwrite(rrdnew.rra_ptr,sizeof(rra_ptr_t),rrdnew.stat_head->rra_cnt,outfile);
+ rrd_close(rrd_file);
+ rrd_close(rrd_out_file);
+ return (-1);
+ }
+
+ /* Put this back the way it was so that the rest of the algorithm
+ below remains unchanged, it will be corrected later */
+ rrdnew.rra_def[target_rra].row_cnt -= modify;
+
+ rrdnew.ds_def = rrdold.ds_def;
+ rrdnew.live_head = rrdold.live_head;
+ rrdnew.pdp_prep = rrdold.pdp_prep;
+ rrdnew.cdp_prep = rrdold.cdp_prep;
+ memcpy(rrdnew.rra_ptr,rrdold.rra_ptr,sizeof(rra_ptr_t) * rrdold.stat_head->rra_cnt);
+
+
+ version = atoi(rrdold.stat_head->version);
+ switch (version) {
+ case 4:
+ break;
+ case 3:
+ break;
+ case 1:
+ rrdnew.stat_head->version[3] = '3';
+ break;
+ default:
+ rrd_set_error("Do not know how to handle RRD version %s",
+ rrdold.stat_head->version);
+ rrd_free(&rrdnew);
+ rrd_free(&rrdold);
+ rrd_close(rrd_file);
+ rrd_close(rrd_out_file);
+ return (-1);
+ break;
+ }
+
+/* XXX: Error checking? */
+ rrd_write(rrd_out_file, rrdnew.stat_head, sizeof(stat_head_t) * 1);
+ rrd_write(rrd_out_file, rrdnew.ds_def,
+ sizeof(ds_def_t) * rrdnew.stat_head->ds_cnt);
+ rrd_write(rrd_out_file, rrdnew.rra_def,
+ sizeof(rra_def_t) * rrdnew.stat_head->rra_cnt);
+ rrd_write(rrd_out_file, rrdnew.live_head, sizeof(live_head_t) * 1);
+ rrd_write(rrd_out_file, rrdnew.pdp_prep,
+ sizeof(pdp_prep_t) * rrdnew.stat_head->ds_cnt);
+ rrd_write(rrd_out_file, rrdnew.cdp_prep,
+ sizeof(cdp_prep_t) * rrdnew.stat_head->ds_cnt *
+ rrdnew.stat_head->rra_cnt);
+ rrd_write(rrd_out_file, rrdnew.rra_ptr,
+ sizeof(rra_ptr_t) * rrdnew.stat_head->rra_cnt);