}
status = buffer_add_string (filename, &buffer_ptr, &buffer_free);
- status = buffer_add_string ("-b", &buffer_ptr, &buffer_free);
- status = buffer_add_ulong (last_up, &buffer_ptr, &buffer_free);
+ if (last_up >= 0) {
+ status = buffer_add_string ("-b", &buffer_ptr, &buffer_free);
+ status = buffer_add_ulong (last_up, &buffer_ptr, &buffer_free);
+ }
status = buffer_add_string ("-s", &buffer_ptr, &buffer_free);
status = buffer_add_ulong (pdp_step, &buffer_ptr, &buffer_free);
if(no_overwrite) {
status = buffer_add_string ("-O", &buffer_ptr, &buffer_free);
}
-
+
if (sources != NULL) {
for (const char **p = sources ; *p ; p++) {
- buffer_add_string ("-r", &buffer_ptr, &buffer_free);
- buffer_add_string (*p, &buffer_ptr, &buffer_free);
+ status = buffer_add_string ("-r", &buffer_ptr, &buffer_free);
+ status = buffer_add_string (*p, &buffer_ptr, &buffer_free);
}
}
if (template != NULL) {
- buffer_add_string ("-t", &buffer_ptr, &buffer_free);
- buffer_add_string (template, &buffer_ptr, &buffer_free);
+ status = buffer_add_string ("-t", &buffer_ptr, &buffer_free);
+ status = buffer_add_string (template, &buffer_ptr, &buffer_free);
}
if (status != 0)
rrd_close(tf);
}
- if (rrd.stat_head->pdp_step == 0) {
+ if (rrd.stat_head->pdp_step <= 0) {
rrd.stat_head->pdp_step = 300;
}
rc = rrd_init_data(&rrd);
if (rc != 0) goto done;
+ rc = -1; // reset rc to default error state
+
if (sources != NULL) {
time_t sources_latest_last_up = 0;
int sources_length = 0;
char *template = NULL;
int status;
- unsigned long step = 300;
- time_t last_up = time(NULL)-10;
+ unsigned long step = 0;
+ time_t last_up = -1;
int no_overwrite = opt_no_overwrite;
int rc = -1;
rc = send_response(sock, RESP_ERR, "Cannot allocate memory\n");
goto done;
}
+
+ flush_file(tok);
+
sources[sources_length++] = tok;
- sources[sources_length + 1] = NULL;
+ sources[sources_length] = NULL;
+
continue;
}
if( ! strncmp(tok,"-t",2) ) {
rc = syntax_error(sock,cmd);
goto done;
}
+ flush_file(tok);
+
template = tok;
continue;
}
rc = syntax_error(sock,cmd);
goto done;
}
- if(step<1) {
- rc = send_response(sock, RESP_ERR, "The step size cannot be less than 1 second.\n");
- goto done;
- }
- if (last_up < 3600 * 24 * 365 * 10) {
+ if (last_up != -1 && last_up < 3600 * 24 * 365 * 10) {
rc = send_response(sock, RESP_ERR, "The first entry must be after 1980.\n");
goto done;
}