summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 598e1be)
raw | patch | inline | side by side (parent: 598e1be)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Thu, 12 May 2005 11:22:11 +0000 (11:22 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Thu, 12 May 2005 11:22:11 +0000 (11:22 +0000) |
error messages. -- Alex
git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@547 a5681a0c-68f1-0310-ab6d-d61299d08faa
git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@547 a5681a0c-68f1-0310-ab6d-d61299d08faa
src/rrd_create.c | patch | blob | history |
diff --git a/src/rrd_create.c b/src/rrd_create.c
index 1c2cbd82897e4b9150beb7059ce5031bbc5e0a25..0d0671fc0dd578d856af77c84a584eba2fb43910 100644 (file)
--- a/src/rrd_create.c
+++ b/src/rrd_create.c
rrd_t rrd;
long i;
int offset;
- char *token;
+ char *token,dummychar1,dummychar2;
unsigned short token_idx, error_flag, period=0;
unsigned long hashed_name;
}
memset(&rrd.ds_def[rrd.stat_head->ds_cnt], 0, sizeof(ds_def_t));
/* extract the name and type */
- if (sscanf(&argv[i][3],
- DS_NAM_FMT ":" DST_FMT ":%n",
- rrd.ds_def[rrd.stat_head->ds_cnt].ds_nam,
- rrd.ds_def[rrd.stat_head->ds_cnt].dst,&offset) == 2)
- {
- /* check for duplicate datasource names */
- for(ii=0;ii<rrd.stat_head->ds_cnt;ii++)
- if(strcmp(rrd.ds_def[rrd.stat_head->ds_cnt].ds_nam,
- rrd.ds_def[ii].ds_nam) == 0){
- rrd_set_error("Duplicate DS name: %s",rrd.ds_def[ii].ds_nam);
- }
- } else {
- rrd_set_error("invalid DS format");
+ switch (sscanf(&argv[i][3],
+ DS_NAM_FMT "%1[:]" DST_FMT "%1[:]%n",
+ rrd.ds_def[rrd.stat_head->ds_cnt].ds_nam,
+ &dummychar1,
+ rrd.ds_def[rrd.stat_head->ds_cnt].dst,
+ &dummychar2,
+ &offset)) {
+ case 0:
+ case 1: rrd_set_error("Invalid DS name"); break;
+ case 2:
+ case 3: rrd_set_error("Invalid DS type"); break;
+ case 4: /* (%n may or may not be counted) */
+ case 5: /* check for duplicate datasource names */
+ for (ii=0;ii<rrd.stat_head->ds_cnt;ii++)
+ if(strcmp(rrd.ds_def[rrd.stat_head->ds_cnt].ds_nam,
+ rrd.ds_def[ii].ds_nam) == 0)
+ rrd_set_error("Duplicate DS name: %s",
+ rrd.ds_def[ii].ds_nam);
+ /* DS_type may be valid or not. Checked later */
+ break;
+ default: rrd_set_error("invalid DS format");
+ }
+ if (rrd_test_error()) {
+ rrd_free(&rrd);
+ return -1;
}
/* parse the remainder of the arguments */