projects
/
rrdtool.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
prepare for the release of rrdtool-1.2.21
[rrdtool.git]
/
src
/
rrd_create.c
diff --git
a/src/rrd_create.c
b/src/rrd_create.c
index
3e9c68c
..
953d91b
100644
(file)
--- a/
src/rrd_create.c
+++ b/
src/rrd_create.c
@@
-1,5
+1,5
@@
/*****************************************************************************
/*****************************************************************************
- * RRDtool 1.2.
9 Copyright by Tobi Oetiker, 1997-2005
+ * RRDtool 1.2.
21 Copyright by Tobi Oetiker, 1997-2007
*****************************************************************************
* rrd_create.c creates new rrds
*****************************************************************************/
*****************************************************************************
* rrd_create.c creates new rrds
*****************************************************************************/
@@
-10,9
+10,9
@@
#include "rrd_is_thread_safe.h"
#include "rrd_is_thread_safe.h"
-unsigned long FnvHash(char *str);
+unsigned long FnvHash(c
onst c
har *str);
int create_hw_contingent_rras(rrd_t *rrd, unsigned short period, unsigned long hashed_name);
int create_hw_contingent_rras(rrd_t *rrd, unsigned short period, unsigned long hashed_name);
-void parseGENERIC_DS(char *def,rrd_t *rrd, int ds_idx);
+void parseGENERIC_DS(c
onst c
har *def,rrd_t *rrd, int ds_idx);
int
rrd_create(int argc, char **argv)
int
rrd_create(int argc, char **argv)
@@
-78,25
+78,28
@@
rrd_create(int argc, char **argv)
return(-1);
}
}
return(-1);
}
}
-
+ if (optind == argc) {
+ rrd_set_error("what is the name of the rrd file you want to create?");
+ return -1;
+ }
rc = rrd_create_r(argv[optind],
pdp_step, last_up,
rc = rrd_create_r(argv[optind],
pdp_step, last_up,
- argc - optind - 1,
argv + optind + 1
);
+ argc - optind - 1,
(const char **)(argv + optind + 1)
);
return rc;
}
/* #define DEBUG */
int
return rc;
}
/* #define DEBUG */
int
-rrd_create_r(char *filename,
+rrd_create_r(c
onst c
har *filename,
unsigned long pdp_step, time_t last_up,
unsigned long pdp_step, time_t last_up,
- int argc, char **argv)
+ int argc, c
onst c
har **argv)
{
rrd_t rrd;
long i;
int offset;
char *token;
{
rrd_t rrd;
long i;
int offset;
char *token;
-
unsigned short dummychar1,dummychar2
;
+
char dummychar1[2], dummychar2[2]
;
unsigned short token_idx, error_flag, period=0;
unsigned long hashed_name;
unsigned short token_idx, error_flag, period=0;
unsigned long hashed_name;
@@
-150,9
+153,9
@@
rrd_create_r(char *filename,
switch (sscanf(&argv[i][3],
DS_NAM_FMT "%1[:]" DST_FMT "%1[:]%n",
rrd.ds_def[rrd.stat_head->ds_cnt].ds_nam,
switch (sscanf(&argv[i][3],
DS_NAM_FMT "%1[:]" DST_FMT "%1[:]%n",
rrd.ds_def[rrd.stat_head->ds_cnt].ds_nam,
-
&
dummychar1,
+ dummychar1,
rrd.ds_def[rrd.stat_head->ds_cnt].dst,
rrd.ds_def[rrd.stat_head->ds_cnt].dst,
-
&
dummychar2,
+ dummychar2,
&offset)) {
case 0:
case 1: rrd_set_error("Invalid DS name"); break;
&offset)) {
case 0:
case 1: rrd_set_error("Invalid DS name"); break;
@@
-436,7
+439,7
@@
rrd_create_r(char *filename,
return rrd_create_fn(filename, &rrd);
}
return rrd_create_fn(filename, &rrd);
}
-void parseGENERIC_DS(char *def,rrd_t *rrd, int ds_idx)
+void parseGENERIC_DS(c
onst c
har *def,rrd_t *rrd, int ds_idx)
{
char minstr[DS_NAM_SIZE], maxstr[DS_NAM_SIZE];
/*
{
char minstr[DS_NAM_SIZE], maxstr[DS_NAM_SIZE];
/*
@@
-544,7
+547,7
@@
create_hw_contingent_rras(rrd_t *rrd, unsigned short period, unsigned long hashe
/* create and empty rrd file according to the specs given */
int
/* create and empty rrd file according to the specs given */
int
-rrd_create_fn(char *file_name, rrd_t *rrd)
+rrd_create_fn(c
onst c
har *file_name, rrd_t *rrd)
{
unsigned long i,ii;
FILE *rrd_file;
{
unsigned long i,ii;
FILE *rrd_file;
@@
-554,8
+557,11
@@
rrd_create_fn(char *file_name, rrd_t *rrd)
if ((rrd_file = fopen(file_name,"wb")) == NULL ) {
rrd_set_error("creating '%s': %s",file_name, rrd_strerror(errno));
free(rrd->stat_head);
if ((rrd_file = fopen(file_name,"wb")) == NULL ) {
rrd_set_error("creating '%s': %s",file_name, rrd_strerror(errno));
free(rrd->stat_head);
+ rrd->stat_head = NULL;
free(rrd->ds_def);
free(rrd->ds_def);
+ rrd->ds_def = NULL;
free(rrd->rra_def);
free(rrd->rra_def);
+ rrd->rra_def = NULL;
return(-1);
}
return(-1);
}