[PVFS2-CVS]
commit by bradles in pvfs2/src/common/dotconf: dotconf.c dotconf.h
CVS commit program
cvs at parl.clemson.edu
Thu Jun 23 13:28:13 EDT 2005
Update of /projects/cvsroot/pvfs2/src/common/dotconf
In directory parlweb:/tmp/cvs-serv13477/src/common/dotconf
Modified Files:
dotconf.c dotconf.h
Log Message:
Applied Phil Carns patch to improve the dot conf parser error messages and
type checking.
Index: dotconf.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/common/dotconf/dotconf.c,v
diff -p -u -r1.7 -r1.8
--- dotconf.c 23 Jun 2005 16:09:42 -0000 1.7
+++ dotconf.c 23 Jun 2005 16:28:13 -0000 1.8
@@ -533,6 +533,7 @@ void PINT_dotconf_set_command(
command_t * cmd)
{
char *eob = 0;
+ int ret = -1;
eob = args + strlen(args);
@@ -543,6 +544,7 @@ void PINT_dotconf_set_command(
cmd->configfile = configfile;
cmd->data.list = (char **) calloc(CFG_VALUES, sizeof(char *));
cmd->data.str = 0;
+ cmd->error = 0;
if (option->type == ARG_RAW)
{
@@ -609,7 +611,8 @@ void PINT_dotconf_set_command(
{
PINT_dotconf_warning(configfile, DCLOG_WARNING,
ERR_WRONG_ARG_COUNT,
- "Missing argument to option '%s'", name);
+ "Missing argument to option '%s'\n", name);
+ cmd->error = 1;
return;
}
@@ -620,18 +623,27 @@ void PINT_dotconf_set_command(
{
PINT_dotconf_warning(configfile, DCLOG_WARNING,
ERR_WRONG_ARG_COUNT,
- "Missing argument to option '%s'", name);
+ "Missing argument to option '%s'\n", name);
+ cmd->error = 1;
return;
}
- sscanf(cmd->data.list[0], "%li", &cmd->data.value);
+ ret = sscanf(cmd->data.list[0], "%li", &cmd->data.value);
+ if(ret != 1)
+ {
+ PINT_dotconf_warning(configfile, DCLOG_WARNING,
+ ERR_PARSE_ERROR,
+ "Non-integer argument to option '%s'\n", name);
+ cmd->error = 1;
+ }
break;
case ARG_STR:
if (cmd->arg_count < 1)
{
PINT_dotconf_warning(configfile, DCLOG_WARNING,
ERR_WRONG_ARG_COUNT,
- "Missing argument to option '%s'", name);
+ "Missing argument to option '%s'\n", name);
+ cmd->error = 1;
return;
}
@@ -735,6 +747,12 @@ const char *PINT_dotconf_handle_command(
/* set up the command structure (contextchecker wants this) */
PINT_dotconf_set_command(configfile, option, cp1, &command);
+ if(command.error)
+ {
+ error = "Parse error.\n";
+ PINT_dotconf_free_command(&command);
+ break;
+ }
if (configfile->contextchecker)
context_error =
Index: dotconf.h
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/common/dotconf/dotconf.h,v
diff -p -u -r1.6 -r1.7
--- dotconf.h 28 Jul 2004 14:32:34 -0000 1.6
+++ dotconf.h 23 Jun 2005 16:28:13 -0000 1.7
@@ -193,6 +193,7 @@ extern "C"
char **list; /* ARG_LIST */
} data;
int arg_count; /* number of arguments (in data.list) */
+ int error; /* set to non-zero if parsing error */
/* ------ misc context information ---------------------------------------------------------- */
configfile_t *configfile;
More information about the PVFS2-CVS
mailing list