*****************************************************************************
* rrd_restore.c creates new rrd from data dumped by rrd_dump.c
*****************************************************************************/
*****************************************************************************
* rrd_restore.c creates new rrd from data dumped by rrd_dump.c
*****************************************************************************/
int eat_tag(char **, char *);
int read_tag(char **, char *, char *, void *);
int xml2rrd(char*, rrd_t*, char);
int eat_tag(char **, char *);
int read_tag(char **, char *, char *, void *);
int xml2rrd(char*, rrd_t*, char);
void parse_patch1028_RRA_params(char **buf, rrd_t *rrd, int rra_index);
void parse_patch1028_CDP_params(char **buf, rrd_t *rrd, int rra_index, int ds_index);
void parse_FAILURES_history(char **buf, rrd_t *rrd, int rra_index, int ds_index);
void parse_patch1028_RRA_params(char **buf, rrd_t *rrd, int rra_index);
void parse_patch1028_CDP_params(char **buf, rrd_t *rrd, int rra_index, int ds_index);
void parse_FAILURES_history(char **buf, rrd_t *rrd, int rra_index, int ds_index);
rrd->stat_head->float_cookie = FLOAT_COOKIE;
rrd->stat_head->ds_cnt = 0;
rrd->stat_head->rra_cnt = 0;
rrd->stat_head->float_cookie = FLOAT_COOKIE;
rrd->stat_head->ds_cnt = 0;
rrd->stat_head->rra_cnt = 0;
read_tag(&ptr2,"type",DST_FMT,rrd->ds_def[rrd->stat_head->ds_cnt-1].dst);
/* test for valid type */
read_tag(&ptr2,"type",DST_FMT,rrd->ds_def[rrd->stat_head->ds_cnt-1].dst);
/* test for valid type */
while (eat_tag(&ptr2,"rra") == 1){
rrd->stat_head->rra_cnt++;
while (eat_tag(&ptr2,"rra") == 1){
rrd->stat_head->rra_cnt++;
if((rrd->rra_def = rrd_realloc(rrd->rra_def,rrd->stat_head->rra_cnt*sizeof(rra_def_t)))==NULL){
rrd_set_error("allocating rra_def"); return -1; }
memset(&(rrd->rra_def[rrd->stat_head->rra_cnt-1]), 0, sizeof(rra_def_t));
if((rrd->rra_def = rrd_realloc(rrd->rra_def,rrd->stat_head->rra_cnt*sizeof(rra_def_t)))==NULL){
rrd_set_error("allocating rra_def"); return -1; }
memset(&(rrd->rra_def[rrd->stat_head->rra_cnt-1]), 0, sizeof(rra_def_t));
if((rrd->cdp_prep = rrd_realloc(rrd->cdp_prep,
rrd->stat_head->rra_cnt
*rrd->stat_head->ds_cnt*sizeof(cdp_prep_t)))==NULL){
if((rrd->cdp_prep = rrd_realloc(rrd->cdp_prep,
rrd->stat_head->rra_cnt
*rrd->stat_head->ds_cnt*sizeof(cdp_prep_t)))==NULL){
read_tag(&ptr2,"cf",CF_NAM_FMT,rrd->rra_def[rrd->stat_head->rra_cnt-1].cf_nam);
/* test for valid type */
read_tag(&ptr2,"cf",CF_NAM_FMT,rrd->rra_def[rrd->stat_head->rra_cnt-1].cf_nam);
/* test for valid type */
read_tag(&ptr2,"pdp_per_row","%lu",&(rrd->rra_def[rrd->stat_head->rra_cnt-1].pdp_cnt));
/* support to read RRA parameters */
read_tag(&ptr2,"pdp_per_row","%lu",&(rrd->rra_def[rrd->stat_head->rra_cnt-1].pdp_cnt));
/* support to read RRA parameters */
}
eat_tag(&ptr2, "/params");
eat_tag(&ptr2,"cdp_prep");
}
eat_tag(&ptr2, "/params");
eat_tag(&ptr2,"cdp_prep");
/* last row in the xml file is the most recent; as
* rrd_update increments the current row pointer, set cur_row
* here to the last row. */
/* last row in the xml file is the most recent; as
* rrd_update increments the current row pointer, set cur_row
* here to the last row. */
- int fd = open(file_name,O_RDWR|O_CREAT|O_EXCL,0666);
+#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
+ fdflags = O_RDWR|O_BINARY|O_CREAT;
+#else
+ fdflags = O_WRONLY|O_CREAT;
+#endif
+ if (force_overwrite == 0) {
+ fdflags |= O_EXCL;
+ }
+ fd = open(file_name,fdflags,0666);
if (fd == -1 || (rrd_file = fdopen(fd,"wb")) == NULL) {
rrd_set_error("creating '%s': %s",file_name,rrd_strerror(errno));
if (fd != -1)
if (fd == -1 || (rrd_file = fdopen(fd,"wb")) == NULL) {
rrd_set_error("creating '%s': %s",file_name,rrd_strerror(errno));
if (fd != -1)
static struct option long_options[] =
{
{"range-check", required_argument, 0, 'r'},
static struct option long_options[] =
{
{"range-check", required_argument, 0, 'r'},
- opt = getopt_long(argc, argv, "r", long_options, &option_index);
+ opt = getopt_long(argc, argv, "r:f", long_options, &option_index);