Bugs: Browse | Submit New | Admin

[#5560] restore does not work

Date:
2006-08-29 16:33
Priority:
3
Submitted By:
Nobody
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
restore does not work

Detailed description
As far as I can tell restore does not work.
First, the @rrdname is ignored and overwritten by an rrd argument. Why?
Second, the xml filename is pushed as argument twice. Why?
Also, why is this not a class method?
Thanks for all the good work!

Add A Comment: Notepad

Please login


Followup

Message
Date: 2007-01-03 07:39
Sender: Thorsten von Eicken

I fixed restore as follows, replace lines
    s_arr_push(STR2CSTR(rrd), &a);
    s_arr_push(STR2CSTR(xml), &a);
    s_arr_push(STR2CSTR(xml), &a);
by
    s_arr_append(STR2CSTR(xml), &a);
    s_arr_append(STR2CSTR(rrd), &a);

And I defined the new a_arr_append function as follows:

/*
 * add an element to a string array at the *end* of the array
 */
static bool s_arr_append(char *val, s_arr *sa) {
    char **tmp;
    int    i;
#ifdef R_RRD_DBG    
    char   buf[NUM_BUF_SZ+1];
#endif
    
#ifdef R_RRD_DBG    
    snprintf(buf, NUM_BUF_SZ, "s_arr_append: n=%d val=%s",
sa->len, val);
    buf[NUM_BUF_SZ] = 0;
    _dbug(R_RRD_DEBUG_SIM, buf);
#endif          
    
    /* set the array length */
    tmp = ALLOC_N(char*, sa->len+1);
    for (i=0; i<sa->len; i++) {
	tmp[i] = sa->strs[i];
    }
    tmp[sa->len] = strdup(val);
    sa->len++;
    sa->strs = tmp;
    
#ifdef R_RRD_DBG    
    snprintf(buf, NUM_BUF_SZ, "s_arr_append: len -> %d",
sa->len);
    buf[NUM_BUF_SZ] = 0;
    _dbug(R_RRD_DEBUG_SIM, buf);
    for (i = 0; i < sa->len; i++) {
       snprintf(buf, NUM_BUF_SZ, "s_arr_append: s_arr[%d]
-> %s", i, sa->strs[i]);
       buf[NUM_BUF_SZ] = 0;
       _dbug(R_RRD_DEBUG_SIM, buf);
    }
#endif
    return true;
}
Date: 2006-08-29 17:45
Sender: Thorsten von Eicken

Oops, the previous follow-up should have read: "I fixed
rrd_restore ..." not rrdgraph!
Date: 2006-08-29 17:43
Sender: Thorsten von Eicken

I fixed rrdgraph as follows. First added a s_arr_append
function:

{{{
/*
 * add an element to a string array at the *end* of the array
 */
static bool s_arr_append(char *val, s_arr *sa) {
    char **tmp;
    int    i;
#ifdef R_RRD_DBG    
    char   buf[NUM_BUF_SZ+1];
#endif
    
#ifdef R_RRD_DBG    
    snprintf(buf, NUM_BUF_SZ, "s_arr_append: n=%d val=%s",
sa->len, val);
    buf[NUM_BUF_SZ] = 0;
    _dbug(R_RRD_DEBUG_SIM, buf);
#endif          
    
    /* set the array length */
    tmp = ALLOC_N(char*, sa->len+1);
    for (i=0; i<sa->len; i++) {
	tmp[i] = sa->strs[i];
    }
    tmp[sa->len] = strdup(val);
    sa->len++;
    sa->strs = tmp;
    
#ifdef R_RRD_DBG    
    snprintf(buf, NUM_BUF_SZ, "s_arr_append: len -> %d",
sa->len);
    buf[NUM_BUF_SZ] = 0;
    _dbug(R_RRD_DEBUG_SIM, buf);
    for (i = 0; i < sa->len; i++) {
       snprintf(buf, NUM_BUF_SZ, "s_arr_append: s_arr[%d]
-> %s", i, sa->strs[i]);
       buf[NUM_BUF_SZ] = 0;
       _dbug(R_RRD_DEBUG_SIM, buf);
    }
#endif
    return true;
}
}}}

Then change in the middle of rrdtool_restore:

{{{
    a = s_arr_new(self, false, false, args);
    s_arr_append(STR2CSTR(xml), &a);
    s_arr_append(STR2CSTR(rrd), &a);
}}}

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item