cvs commit: ALFS/nALFS/src/handlers conditionals.c configure.c copy.c download.c execute.c link.c make.c mkdir.c move.c owner.c ownership.c package.c patch.c permissions.c remove.c search_replace.c setenv.c stage.c textdump.c unpack.c

kpfleming at linuxfromscratch.org kpfleming at linuxfromscratch.org
Mon Feb 23 13:19:35 PST 2004


kpfleming    04/02/23 14:19:35

  Modified:    nALFS/src handlers.c handlers.h libXML-tree.c
               nALFS/src/handlers conditionals.c configure.c copy.c
                        download.c execute.c link.c make.c mkdir.c move.c
                        owner.c ownership.c package.c patch.c permissions.c
                        remove.c search_replace.c setenv.c stage.c
                        textdump.c unpack.c
  Log:
  add handler_parameter structure, convert all handlers to use it
  
  Revision  Changes    Path
  1.23      +38 -19    ALFS/nALFS/src/handlers.c
  
  Index: handlers.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- handlers.c	23 Feb 2004 19:44:53 -0000	1.22
  +++ handlers.c	23 Feb 2004 21:19:35 -0000	1.23
  @@ -74,13 +74,42 @@
   		.main = root_main,
   		.type = HTYPE_NORMAL,
   	},
  +#if HANDLER_SYNTAX_2_0
   	{
  -		.name = "__comment",
  +		.name = "comment",
   		.description = "comment element",
  -		.syntax_version = "all",
  +		.syntax_version = "2.0",
   		.main = comment_main,
  -		.type = HTYPE_NORMAL,
  +		.type = HTYPE_COMMENT,
   	},
  +#endif
  +#if HANDLER_SYNTAX_3_0
  +	{
  +		.name = "comment",
  +		.description = "comment element",
  +		.syntax_version = "3.0",
  +		.main = comment_main,
  +		.type = HTYPE_COMMENT,
  +	},
  +#endif
  +#if HANDLER_SYNTAX_3_1
  +	{
  +		.name = "comment",
  +		.description = "comment element",
  +		.syntax_version = "3.1",
  +		.main = comment_main,
  +		.type = HTYPE_COMMENT,
  +	},
  +#endif
  +#if HANDLER_SYNTAX_3_2
  +	{
  +		.name = "comment",
  +		.description = "comment element",
  +		.syntax_version = "3.2",
  +		.main = comment_main,
  +		.type = HTYPE_COMMENT,
  +	},
  +#endif
   	{
   		.name = NULL
   	}
  @@ -126,18 +155,19 @@
   
   
   
  -static INLINE int add_new_parameters(const char **params)
  +static INLINE int add_new_parameters(const struct handler_parameter *params)
   {
   	int i, total = 0;
  -	const char *param;
  +	const struct handler_parameter *param;
   
   
  -	for (i = 0; (param = params[i]); ++i) {
  +	for (i = 0; (params[i].name); ++i) {
  +		param = &params[i];
   		int j, param_already_exists = 0;
   
   		/* Check if tok already exists in parameters. */
   		for (j = 0; parameters[j]; ++j) {
  -			if (strcmp(param, parameters[j]) == 0) {
  +			if (strcmp(param->name, parameters[j]) == 0) {
   				++param_already_exists;
   			}
   		}
  @@ -148,7 +178,7 @@
   			parameters = xrealloc(
   				parameters,
   				(j+2) * sizeof *parameters);
  -			parameters[j] = xstrdup(param);
  +			parameters[j] = xstrdup(param->name);
   			parameters[j+1] = NULL;
   		}
   	}
  @@ -542,17 +572,6 @@
   	}
   
   	return *string;
  -}
  -
  -char *parse_string_parameter(const char * const value,
  -			     const char * const message)
  -{
  -	if (strlen(value)) {
  -		return xstrdup(value);
  -	} else {
  -		Nprint_err(message);
  -		return NULL;
  -	}
   }
   
   char *parse_string_content(const char * const value,
  
  
  
  1.19      +15 -10    ALFS/nALFS/src/handlers.h
  
  Index: handlers.h
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers.h,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- handlers.h	23 Feb 2004 19:44:53 -0000	1.18
  +++ handlers.h	23 Feb 2004 21:19:35 -0000	1.19
  @@ -31,6 +31,7 @@
   
   
   typedef enum handler_type_e {
  +	HTYPE_COMMENT = (1 << 0),
   	HTYPE_NORMAL = (1 << 1),
   	HTYPE_PACKAGE = (1 << 2),
   	HTYPE_TEXTDUMP = (1 << 3),
  @@ -57,6 +58,12 @@
   	const int content_optional;
   };
   
  +struct handler_parameter {
  +	const char * const name;
  +	const int private;		/* Internal to handler. */
  +	const int content_optional;
  +};
  +
   typedef char *(*handler_data_f)(const element_s * const element,
   				const handler_data_e data_requested);
   typedef int (*handler_f)(element_s * const element);
  @@ -66,11 +73,11 @@
   typedef int (*handler_attribute)(const element_s * const element,
   				 const struct handler_attribute * const attr,
   				 const char * const value);
  -typedef int (*handler_parse)(const element_s * const element,
  -			     const char * const name,
  -			     const char * const value);
  -typedef int (*handler_parse_content)(const element_s * const element,
  -				     const char * const content);
  +typedef int (*handler_parameter)(const element_s * const element,
  +				 const struct handler_parameter * const param,
  +				 const char * const value);
  +typedef int (*handler_content)(const element_s * const element,
  +			       const char * const content);
   typedef int (*handler_invalid_data)(const element_s * const element);
   typedef int (*handler_invalid_child)(const element_s * const element,
   				     const element_s * const child);
  @@ -79,7 +86,7 @@
   	const char *name;		/* Name of the element it handles. */
   	const char *description;	/* Short description. */
   	const char *syntax_version;	/* Syntax version string. */
  -	const char **parameters;	/* Parameters allowed. */
  +	const struct handler_parameter *parameters; /* Parameters allowed. */
   	const struct handler_attribute *attributes; /* Attributes allowed. */
   
   	handler_type_e type;
  @@ -109,8 +116,8 @@
   	handler_invalid_data invalid_data; /* Validate private data. */
   	handler_invalid_child invalid_child; /* Validate potential child. */
   	handler_attribute attribute;
  -	handler_parse parse_parameter;
  -	handler_parse_content parse_content;
  +	handler_parameter parameter;
  +	handler_content content;
   } handler_info_s;
   
   
  @@ -144,8 +151,6 @@
   char *append_param_elements(char **string, element_s *el);
   char *append_prefix_elements(char **string, element_s *el);
   
  -char *parse_string_parameter(const char * const value,
  -			     const char * const message);
   char *parse_string_content(const char * const value,
   			   const char * const message);
   
  
  
  
  1.13      +27 -16    ALFS/nALFS/src/libXML-tree.c
  
  Index: libXML-tree.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/libXML-tree.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- libXML-tree.c	23 Feb 2004 19:44:53 -0000	1.12
  +++ libXML-tree.c	23 Feb 2004 21:19:35 -0000	1.13
  @@ -131,18 +131,20 @@
   	return NULL;
   }
   
  -static const char *find_handler_parameter(const handler_info_s *handler,
  -					  const char *name)
  +static const struct handler_parameter *find_handler_parameter(const handler_info_s *handler,
  +							      const char *name)
   {
   	int i;
  -	const char *param;
  +	const struct handler_parameter *param;
   
   	if (!handler->parameters)
   		return NULL;
   
  -	for (i = 0; (param = handler->parameters[i]); ++i)
  -		if (strcmp(param, name) == 0)
  +	for (i = 0; (handler->parameters[i].name); ++i) {
  +		param = &handler->parameters[i];
  +		if (strcmp(param->name, name) == 0)
   			return param;
  +	}
   
   	return NULL;
   }
  @@ -168,7 +170,7 @@
   			continue;
   		}
   		
  -		content = attr->children->content;
  +		content = (const char *) attr->children->content;
   
   		if ((!handler_attr->content_optional) && (strlen(content) == 0)) {
   			Nprint_err("<%s>: \"%s\" attribute cannot be empty.", handler->name, handler_attr->name);
  @@ -187,6 +189,8 @@
   {
   	handler_info_s *handler = element->handler;
   	xmlNodePtr child;
  +	const struct handler_parameter *param;
  +	const char *content;
   	int result;
   
   	/* Check all elements inside the node to see if they are
  @@ -198,15 +202,22 @@
   		if (!USED_NODE(child))
   			continue;
   
  -		if (find_handler_parameter(handler,
  -					   (const char *) child->name)) {
  -			result = handler->parse_parameter(element,
  -							  (const char *) child->name,
  -							  (const char *) child->children->content);
  +		param = find_handler_parameter(handler,
  +					       (const char *) child->name);
  +
  +		if (param) {
  +			content = (const char *) child->children->content;
  +
  +			if ((!param->content_optional) && (strlen(content) == 0)) {
  +				Nprint_err("<%s>: \"%s\" parameter cannot be empty.", handler->name, param->name);
  +				return 1;
  +			}
  +
  +			result = handler->parameter(element, param, content);
   			if (result)
   				return result;
   		} else if (!find_handler(child->name, syntax_version)) {
  -			Nprint_warn("<%s>: <%s> parameter is not supported.", 
  +			Nprint_warn("<%s>: <%s> not supported here.", 
   				    handler->name,
   				    (const char *) child->name);
   		}
  @@ -233,15 +244,15 @@
   		/* If the handler cares about its content, pass it in
   		   and check the result. */
   
  -		if (handler->parse_content) {
  +		if (handler->content) {
   			xmlChar *content;
   
   			if (node->children
   			    && node->children->type == XML_TEXT_NODE
   			    && node->children->next == NULL) {
   				if ((content = xmlNodeGetContent(node))) {
  -					result = handler->parse_content(element,
  -									content);
  +					result = handler->content(element,
  +								  content);
   					xfree(content);
   					if (result)
   						return result;
  @@ -326,7 +337,7 @@
   		case XML_COMMENT_NODE:
   			el->name = xstrdup("comment");
   			el->type = TYPE_COMMENT;
  -			el->handler = find_handler("__comment", "all")->info;
  +			el->handler = find_handler("comment", syntax_version)->info;
   			if (make_handler_element(node, el)) {
   				free_element(el);
   				el = NULL;
  
  
  
  1.8       +28 -3     ALFS/nALFS/src/handlers/conditionals.c
  
  Index: conditionals.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/conditionals.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- conditionals.c	21 Feb 2004 19:03:32 -0000	1.7
  +++ conditionals.c	23 Feb 2004 21:19:35 -0000	1.8
  @@ -79,7 +79,12 @@
   #endif
   
   #if HANDLER_SYNTAX_3_1
  -static const char *if_parameters_3_1[] = { "then", "else", NULL };
  +
  +static const struct handler_parameter if_parameters_3_1[] = {
  +	{ .name = "then" },
  +	{ .name = "else" },
  +	{ .name = NULL }
  +};
   
   static int if_main_3_1(element_s * const element)
   {
  @@ -112,8 +117,28 @@
   #endif
   
   #if HANDLER_SYNTAX_3_2
  -static const char *if_parameters_3_2[] = { "test", "package-version", "package-built", "and", "or", "not", "then", "else", NULL };
  -static const char *boolean_parameters_3_2[] = { "test", "package-version", "package-built", "and", "or", "not", NULL };
  +
  +static const struct handler_parameter if_parameters_3_2[] = {
  +	{ .name = "then" },
  +	{ .name = "else" },
  +	{ .name = "package-version" },
  +	{ .name = "package-built" },
  +	{ .name = "test" },
  +	{ .name = "and" },
  +	{ .name = "or" },
  +	{ .name = "not" },
  +	{ .name = NULL }
  +};
  +
  +static const struct handler_parameter boolean_parameters_3_2[] = {
  +	{ .name = "package-version" },
  +	{ .name = "package-built" },
  +	{ .name = "test" },
  +	{ .name = "and" },
  +	{ .name = "or" },
  +	{ .name = "not" },
  +	{ .name = NULL }
  +};
   
   static int if_main_3_2(element_s * const element)
   {
  
  
  
  1.16      +12 -4     ALFS/nALFS/src/handlers/configure.c
  
  Index: configure.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/configure.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- configure.c	21 Feb 2004 19:03:32 -0000	1.15
  +++ configure.c	23 Feb 2004 21:19:35 -0000	1.16
  @@ -42,8 +42,12 @@
   
   #if HANDLER_SYNTAX_2_0
   
  -static const char *configure_parameters_ver2[] =
  -{ "base", "command", "param", NULL };
  +static const struct handler_parameter configure_parameters_ver2[] = {
  +	{ .name = "base" },
  +	{ .name = "command" },
  +	{ .name = "param" },
  +	{ .name = NULL }
  +};
   
   static int configure_main_ver2(element_s * const el)
   {
  @@ -83,8 +87,12 @@
   
   #if HANDLER_SYNTAX_3_0 || HANDLER_SYNTAX_3_1 || HANDLER_SYNTAX_3_2
   
  -static const char *configure_parameters_ver3[] =
  -{ "param", "prefix", NULL };
  +static const struct handler_parameter configure_parameters_ver3[] = {
  +	{ .name = "prefix" },
  +	{ .name = "param" },
  +	{ .name = NULL }
  +};
  +
   // char *HANDLER_SYMBOL(attributes)[] = { "base", "command", NULL };
   
   static int configure_main_ver3(element_s * const el)
  
  
  
  1.16      +14 -4     ALFS/nALFS/src/handlers/copy.c
  
  Index: copy.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/copy.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- copy.c	21 Feb 2004 19:03:32 -0000	1.15
  +++ copy.c	23 Feb 2004 21:19:35 -0000	1.16
  @@ -46,8 +46,13 @@
   
   #if HANDLER_SYNTAX_2_0
   
  -static const char *copy_parameters_ver2[] =
  -{ "options", "base", "source", "destination", NULL };
  +static const struct handler_parameter copy_parameters_ver2[] = {
  +	{ .name = "options" },
  +	{ .name = "base" },
  +	{ .name = "source" },
  +	{ .name = "destination" },
  +	{ .name = NULL }
  +};
   
   static int copy_main_ver2(element_s * const el)
   {
  @@ -129,8 +134,13 @@
   
   #if HANDLER_SYNTAX_3_0 || HANDLER_SYNTAX_3_1 || HANDLER_SYNTAX_3_2
   
  -static const char *copy_parameters_ver3[] =
  -{ "option", "source", "destination", NULL };
  +static const struct handler_parameter copy_parameters_ver3[] = {
  +	{ .name = "option" },
  +	{ .name = "source" },
  +	{ .name = "destination" },
  +	{ .name = NULL }
  +};
  +
   // char *HANDLER_SYMBOL(attributes)[] = { "base", NULL };
   
   static int copy_main_ver3(element_s * const el)
  
  
  
  1.17      +13 -4     ALFS/nALFS/src/handlers/download.c
  
  Index: download.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/download.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- download.c	21 Feb 2004 19:03:32 -0000	1.16
  +++ download.c	23 Feb 2004 21:19:35 -0000	1.17
  @@ -50,8 +50,13 @@
   
   #if HANDLER_SYNTAX_3_1 
   
  -static const char *download_parameters[] =
  -{ "digest", "file", "url", "destination", NULL };
  +static const struct handler_parameter download_parameters[] = {
  +	{ .name = "digest" },
  +	{ .name = "file" },
  +	{ .name = "url" },
  +	{ .name = "destination" },
  +	{ .name = NULL }
  +};
   
   static int download_main(element_s * const el)
   {
  @@ -140,8 +145,12 @@
   
   #if HANDLER_SYNTAX_3_2
   
  -static const char *download_parameters_3_2[] =
  -{ "digest", "file", "url", NULL };
  +static const struct handler_parameter download_parameters_3_2[] = {
  +	{ .name = "digest" },
  +	{ .name = "file" },
  +	{ .name = "url" },
  +	{ .name = NULL }
  +};
   
   static int download_main_3_2(element_s * const el)
   {
  
  
  
  1.22      +19 -6     ALFS/nALFS/src/handlers/execute.c
  
  Index: execute.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/execute.c,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- execute.c	21 Feb 2004 19:03:32 -0000	1.21
  +++ execute.c	23 Feb 2004 21:19:35 -0000	1.22
  @@ -46,8 +46,12 @@
   
   #if HANDLER_SYNTAX_2_0
   
  -static const char *execute_parameters_ver2[] =
  -{ "base", "command", "param", NULL };
  +static const struct handler_parameter execute_parameters_ver2[] = {
  +	{ .name = "base" },
  +	{ .name = "command" },
  +	{ .name = "param" },
  +	{ .name = NULL }
  +};
   
   static int execute_main_ver2(element_s * const el)
   {
  @@ -96,8 +100,12 @@
   
   #if HANDLER_SYNTAX_3_0 || HANDLER_SYNTAX_3_1
   
  -static const char *execute_parameters_ver3[] =
  -{ "param", "prefix", NULL };
  +static const struct handler_parameter execute_parameters_ver3[] = {
  +	{ .name = "prefix" },
  +	{ .name = "param" },
  +	{ .name = NULL }
  +};
  +
   // char *HANDLER_SYMBOL(attributes)[] = { "base", "command", NULL };
   
   static int execute_main_ver3(element_s * const el)
  @@ -157,8 +165,13 @@
   
   #ifdef HANDLER_SYNTAX_3_2
   
  -static const char *execute_parameters_ver3_2[] =
  -{ "param", "prefix", "content", NULL };
  +static const struct handler_parameter execute_parameters_ver3_2[] = {
  +	{ .name = "prefix" },
  +	{ .name = "param" },
  +	{ .name = "content" },
  +	{ .name = NULL }
  +};
  +
   // char *HANDLER_SYMBOL(attributes)[] = { "base", "command", NULL };
   
   static int execute_main_ver3_2(element_s * const el)
  
  
  
  1.16      +15 -4     ALFS/nALFS/src/handlers/link.c
  
  Index: link.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/link.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- link.c	21 Feb 2004 19:03:32 -0000	1.15
  +++ link.c	23 Feb 2004 21:19:35 -0000	1.16
  @@ -45,8 +45,14 @@
   
   #if HANDLER_SYNTAX_2_0
   
  -static const char *link_parameters_ver2[] =
  -{ "options", "base", "target", "name", NULL };
  +static const struct handler_parameter link_parameters_ver2[] = {
  +	{ .name = "base" },
  +	{ .name = "options" },
  +	{ .name = "target" },
  +	{ .name = "name" },
  +	{ .name = NULL }
  +};
  +
   // char *HANDLER_SYMBOL(attributes)[] = { "type", NULL };
   
   static int link_main_ver2(element_s * const el)
  @@ -136,8 +142,13 @@
   
   #if HANDLER_SYNTAX_3_0 || HANDLER_SYNTAX_3_1 || HANDLER_SYNTAX_3_2
   
  -static const char *link_parameters_ver3[] =
  -{ "option", "target", "name", NULL };
  +static const struct handler_parameter link_parameters_ver3[] = {
  +	{ .name = "option" },
  +	{ .name = "target" },
  +	{ .name = "name" },
  +	{ .name = NULL }
  +};
  +
   // char *HANDLER_SYMBOL(attributes)[] = { "type", "base", NULL };
   
   static int link_main_ver3(element_s * const el)
  
  
  
  1.16      +11 -2     ALFS/nALFS/src/handlers/make.c
  
  Index: make.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/make.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- make.c	21 Feb 2004 19:03:32 -0000	1.15
  +++ make.c	23 Feb 2004 21:19:35 -0000	1.16
  @@ -42,7 +42,11 @@
   
   #if HANDLER_SYNTAX_2_0
   
  -static const char *make_parameters_ver2[] = { "base", "param", NULL };
  +static const struct handler_parameter make_parameters_ver2[] = {
  +	{ .name = "base" },
  +	{ .name = "param" },
  +	{ .name = NULL }
  +};
   
   static int make_main_ver2(element_s * const el)
   {
  @@ -77,7 +81,12 @@
   
   #if HANDLER_SYNTAX_3_0 || HANDLER_SYNTAX_3_1 || HANDLER_SYNTAX_3_2
   
  -static const char *make_parameters_ver3[] = { "param", "prefix", NULL };
  +static const struct handler_parameter make_parameters_ver3[] = {
  +	{ .name = "prefix" },
  +	{ .name = "param" },
  +	{ .name = NULL }
  +};
  +
   // char *HANDLER_SYMBOL(attributes)[] = { "base", NULL };
   
   static int make_main_ver3(element_s * const el)
  
  
  
  1.16      +14 -4     ALFS/nALFS/src/handlers/mkdir.c
  
  Index: mkdir.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/mkdir.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- mkdir.c	21 Feb 2004 19:03:32 -0000	1.15
  +++ mkdir.c	23 Feb 2004 21:19:35 -0000	1.16
  @@ -46,8 +46,13 @@
   
   #if HANDLER_SYNTAX_2_0
   
  -static const char *mkdir_parameters_ver2[] =
  -{ "options", "base", "dir", "permissions", NULL };
  +static const struct handler_parameter mkdir_parameters_ver2[] = {
  +	{ .name = "options" },
  +	{ .name = "base" },
  +	{ .name = "dir" },
  +	{ .name = "permissions" },
  +	{ .name = NULL }
  +};
   
   static int mkdir_main_ver2(element_s * const el)
   {
  @@ -118,8 +123,13 @@
   
   #if HANDLER_SYNTAX_3_0 || HANDLER_SYNTAX_3_1 || HANDLER_SYNTAX_3_2
   
  -static const char *mkdir_parameters_ver3[] =
  -{ "option", "name", "permissions", NULL };
  +static const struct handler_parameter mkdir_parameters_ver3[] = {
  +	{ .name = "option" },
  +	{ .name = "name" },
  +	{ .name = "permissions" },
  +	{ .name = NULL }
  +};
  +
   // char *HANDLER_SYMBOL(attributes)[] = { "base", NULL };
   
   static int mkdir_main_ver3(element_s * const el)
  
  
  
  1.16      +14 -4     ALFS/nALFS/src/handlers/move.c
  
  Index: move.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/move.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- move.c	21 Feb 2004 19:03:32 -0000	1.15
  +++ move.c	23 Feb 2004 21:19:35 -0000	1.16
  @@ -46,8 +46,13 @@
   
   #if HANDLER_SYNTAX_2_0
   
  -static const char *move_parameters_ver2[] =
  -{ "options", "base", "source", "destination", NULL };
  +static const struct handler_parameter move_parameters_ver2[] = {
  +	{ .name = "base" },
  +	{ .name = "options" },
  +	{ .name = "source" },
  +	{ .name = "destination" },
  +	{ .name = NULL }
  +};
   
   static int move_main_ver2(element_s * const el)
   {
  @@ -108,8 +113,13 @@
   
   #if HANDLER_SYNTAX_3_0 || HANDLER_SYNTAX_3_1 || HANDLER_SYNTAX_3_2
   
  -static const char *move_parameters_ver3[] =
  -{ "option", "source", "destination", NULL };
  +static const struct handler_parameter move_parameters_ver3[] = {
  +	{ .name = "option" },
  +	{ .name = "source" },
  +	{ .name = "destination" },
  +	{ .name = NULL }
  +};
  +
   // char *HANDLER_SYMBOL(attributes)[] = { "base", NULL };
   
   static int move_main_ver3(element_s * const el)
  
  
  
  1.16      +8 -2      ALFS/nALFS/src/handlers/owner.c
  
  Index: owner.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/owner.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- owner.c	21 Feb 2004 19:03:32 -0000	1.15
  +++ owner.c	23 Feb 2004 21:19:35 -0000	1.16
  @@ -47,8 +47,14 @@
   
   #if HANDLER_SYNTAX_2_0
   
  -static const char *owner_parameters[] =
  -{ "options", "base", "user", "group", "name", NULL };
  +static const struct handler_parameter owner_parameters[] = {
  +	{ .name = "options" },
  +	{ .name = "name" },
  +	{ .name = "base" },
  +	{ .name = "user" },
  +	{ .name = "group" },
  +	{ .name = NULL }
  +};
   
   static int owner_main(element_s * const el)
   {
  
  
  
  1.14      +6 -1      ALFS/nALFS/src/handlers/ownership.c
  
  Index: ownership.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/ownership.c,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ownership.c	21 Feb 2004 19:03:32 -0000	1.13
  +++ ownership.c	23 Feb 2004 21:19:35 -0000	1.14
  @@ -39,7 +39,12 @@
   
   #if HANDLER_SYNTAX_3_0 || HANDLER_SYNTAX_3_1 || HANDLER_SYNTAX_3_2
   
  -static const char *ownership_parameters[] = { "option", "name", NULL };
  +static const struct handler_parameter ownership_parameters[] = {
  +	{ .name = "option" },
  +	{ .name = "name" },
  +	{ .name = NULL }
  +};
  +
   // char *HANDLER_SYMBOL(attributes)[] = { "base", "user", "group", NULL };
   
   static int ownership_main(element_s *const el)
  
  
  
  1.18      +18 -13    ALFS/nALFS/src/handlers/package.c
  
  Index: package.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/package.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- package.c	21 Feb 2004 19:03:32 -0000	1.17
  +++ package.c	23 Feb 2004 21:19:35 -0000	1.18
  @@ -42,8 +42,12 @@
   
   #if HANDLER_SYNTAX_2_0
   
  -static const char *package_parameters_ver2[] =
  -{ "name", "version", "base", NULL };
  +static const struct handler_parameter package_parameters_ver2[] = {
  +	{ .name = "name" },
  +	{ .name = "version" },
  +	{ .name = "base" },
  +	{ .name = NULL }
  +};
   
   static int package_main_ver2(element_s * const el)
   {
  @@ -219,18 +223,19 @@
   }
   
   
  -static const char *package_parameters_ver3[] = { 
  -	"packageinfo",
  -	"description",
  -	"list",
  -	"item",
  -	"para",
  -	"requires",
  -	"utilizes",
  -	"name",
  -	"version",
  -	NULL
  +static const struct handler_parameter package_parameters_ver3[] = {
  +	{ .name = "name" },
  +	{ .name = "version" },
  +	{ .name = "packageinfo" },
  +	{ .name = "description" },
  +	{ .name = "list" },
  +	{ .name = "item" },
  +	{ .name = "para" },
  +	{ .name = "requires" },
  +	{ .name = "utilizes" },
  +	{ .name = NULL }
   };
  +
   // char *HANDLER_SYMBOL(attributes)[] = { "name", "version", "logfile", NULL };
   
   static int package_main_ver3(element_s * const el)
  
  
  
  1.20      +20 -4     ALFS/nALFS/src/handlers/patch.c
  
  Index: patch.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/patch.c,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- patch.c	21 Feb 2004 19:03:32 -0000	1.19
  +++ patch.c	23 Feb 2004 21:19:35 -0000	1.20
  @@ -44,7 +44,11 @@
   
   #if HANDLER_SYNTAX_2_0
   
  -static const char *patch_parameters_ver2[] = { "base", "param", NULL };
  +static const struct handler_parameter patch_parameters_ver2[] = {
  +	{ .name = "base" },
  +	{ .name = "param" },
  +	{ .name = NULL }
  +};
   
   static int patch_main_ver2(element_s * const el)
   {
  @@ -84,7 +88,12 @@
   
   #if HANDLER_SYNTAX_3_0 || HANDLER_SYNTAX_3_1
   
  -static const char *patch_parameters_ver3[] = { "param", "prefix", NULL };
  +static const struct handler_parameter patch_parameters_ver3[] = {
  +	{ .name = "prefix" },
  +	{ .name = "param" },
  +	{ .name = NULL }
  +};
  +
   // char *HANDLER_SYMBOL(attributes)[] = { "base", NULL };
   
   static int patch_main_ver3(element_s * const el)
  @@ -141,8 +150,15 @@
   
   #if HANDLER_SYNTAX_3_2
   
  -static const char *patch_parameters_ver3_2[] = { "digest", "reference", "file",
  -						 "param", "prefix", NULL };
  +static const struct handler_parameter patch_parameters_ver3_2[] = {
  +	{ .name = "prefix" },
  +	{ .name = "param" },
  +	{ .name = "digest" },
  +	{ .name = "reference" },
  +	{ .name = "file" },
  +	{ .name = NULL }
  +};
  +
   // char *HANDLER_SYMBOL(attributes)[] = { "base", "mode", "path_strip", NULL };
   
   static int patch_main_ver3_2(element_s * const el)
  
  
  
  1.16      +13 -4     ALFS/nALFS/src/handlers/permissions.c
  
  Index: permissions.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/permissions.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- permissions.c	21 Feb 2004 19:03:32 -0000	1.15
  +++ permissions.c	23 Feb 2004 21:19:35 -0000	1.16
  @@ -46,8 +46,13 @@
   
   #if HANDLER_SYNTAX_2_0
   
  -static const char *permissions_parameters_ver2[] =
  -{ "base", "options", "mode", "name", NULL };
  +static const struct handler_parameter permissions_parameters_ver2[] = {
  +	{ .name = "base" },
  +	{ .name = "options" },
  +	{ .name = "mode" },
  +	{ .name = "name" },
  +	{ .name = NULL }
  +};
   
   static int permissions_main_ver2(element_s * const el)
   {
  @@ -130,8 +135,12 @@
   
   #if HANDLER_SYNTAX_3_0 || HANDLER_SYNTAX_3_1 || HANDLER_SYNTAX_3_2
   
  -static const char *permissions_parameters_ver3[] =
  -{ "option", "name", NULL };
  +static const struct handler_parameter permissions_parameters_ver3[] = {
  +	{ .name = "option" },
  +	{ .name = "name" },
  +	{ .name = NULL }
  +};
  +
   // char *HANDLER_SYMBOL(attributes)[] = { "base", "mode", NULL };
   
   static int permissions_main_ver3(element_s * const el)
  
  
  
  1.20      +9 -6      ALFS/nALFS/src/handlers/remove.c
  
  Index: remove.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/remove.c,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- remove.c	21 Feb 2004 19:03:32 -0000	1.19
  +++ remove.c	23 Feb 2004 21:19:35 -0000	1.20
  @@ -41,7 +41,10 @@
   #include "parser.h"
   #include "backend.h"
   
  -static const char *remove_parameters_ver_3_2[] = { "base", "file",  NULL };
  +static const struct handler_parameter remove_parameters_ver3_2[] = {
  +	{ .name = "file" },
  +	{ .name = NULL }
  +};
   
   #if HANDLER_SYNTAX_2_0
   
  @@ -188,7 +191,7 @@
   		.description = "Remove files",
   		.syntax_version = "2.0",
   		.main = remove_main_ver2,
  -		.type = 0,
  +		.type = HTYPE_NORMAL,
   		.alloc_data = NULL,
   		.is_action = 1,
   		.priority = 0
  @@ -200,7 +203,7 @@
   		.description = "Remove files",
   		.syntax_version = "3.0",
   		.main = remove_main_ver3,
  -		.type = 0,
  +		.type = HTYPE_NORMAL,
   		.alloc_data = NULL,
   		.is_action = 1,
   		.priority = 0
  @@ -212,7 +215,7 @@
   		.description = "Remove files",
   		.syntax_version = "3.1",
   		.main = remove_main_ver3,
  -		.type = 0,
  +		.type = HTYPE_NORMAL,
   		.alloc_data = NULL,
   		.is_action = 1,
   		.priority = 0
  @@ -223,9 +226,9 @@
   		.name = "remove",
   		.description = "Remove files",
   		.syntax_version = "3.2",
  -		.parameters = remove_parameters_ver_3_2,
  +		.parameters = remove_parameters_ver3_2,
   		.main = remove_main_ver3_2,
  -		.type = 0,
  +		.type = HTYPE_NORMAL,
   		.alloc_data = NULL,
   		.is_action = 1,
   		.alternate_shell = 1,
  
  
  
  1.17      +14 -4     ALFS/nALFS/src/handlers/search_replace.c
  
  Index: search_replace.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/search_replace.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- search_replace.c	21 Feb 2004 19:03:32 -0000	1.16
  +++ search_replace.c	23 Feb 2004 21:19:35 -0000	1.17
  @@ -185,8 +185,13 @@
   
   #if HANDLER_SYNTAX_2_0
   
  -static const char *search_replace_parameters_ver2[] =
  -{ "base", "find", "replace", "file", NULL };
  +static const struct handler_parameter search_replace_parameters_ver2[] = {
  +	{ .name = "base" },
  +	{ .name = "find" },
  +	{ .name = "replace" },
  +	{ .name = "file" },
  +	{ .name = NULL }
  +};
   
   static int search_replace_main_ver2(element_s * const el)
   {
  @@ -205,8 +210,13 @@
   
   #if HANDLER_SYNTAX_3_0 || HANDLER_SYNTAX_3_1 || HANDLER_SYNTAX_3_2
   
  -static const char *search_replace_parameters_ver3[] =
  -{ "find", "replace", "file", NULL };
  +static const struct handler_parameter search_replace_parameters_ver3[] = {
  +	{ .name = "find" },
  +	{ .name = "replace" },
  +	{ .name = "file" },
  +	{ .name = NULL }
  +};
  +
   // char *HANDLER_SYMBOL(attributes)[] = { "base", NULL };
   
   static int search_replace_main_ver3(element_s * const el)
  
  
  
  1.14      +5 -1      ALFS/nALFS/src/handlers/setenv.c
  
  Index: setenv.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/setenv.c,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- setenv.c	21 Feb 2004 19:03:32 -0000	1.13
  +++ setenv.c	23 Feb 2004 21:19:35 -0000	1.14
  @@ -108,7 +108,11 @@
   }
   
   
  -static const char *setenv_parameters[] = { "variable", "value", NULL };
  +static const struct handler_parameter setenv_parameters[] = {
  +	{ .name = "variable" },
  +	{ .name = "value" },
  +	{ .name = NULL }
  +};
   
   static int setenv_main(element_s * const el)
   {
  
  
  
  1.25      +48 -35    ALFS/nALFS/src/handlers/stage.c
  
  Index: stage.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/stage.c,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- stage.c	23 Feb 2004 19:44:54 -0000	1.24
  +++ stage.c	23 Feb 2004 21:19:35 -0000	1.25
  @@ -346,10 +346,11 @@
   	}
   
   	return !(child->handler->type & (HTYPE_NORMAL |
  -			 HTYPE_TEXTDUMP |
  -			 HTYPE_PACKAGE |
  -			 HTYPE_EXECUTE |
  -			 HTYPE_STAGE));
  +					 HTYPE_COMMENT |
  +					 HTYPE_TEXTDUMP |
  +					 HTYPE_PACKAGE |
  +					 HTYPE_EXECUTE |
  +					 HTYPE_STAGE));
   }
   
   static int stage_main(element_s * const element)
  @@ -442,12 +443,29 @@
   
   /* <stageinfo> handler */
   
  -static const char *stageinfo_parameters[] = { "base", "root", "user", NULL };
  +enum stageinfo_parameter_types {
  +	STAGEINFO_BASE,
  +	STAGEINFO_ROOT,
  +	STAGEINFO_USER,
  +	STAGEINFO_SHELL,
  +};
  +
  +static const struct handler_parameter stageinfo_parameters[] = {
  +	{ .name = "base", .private = STAGEINFO_BASE },
  +	{ .name = "root", .private = STAGEINFO_ROOT },
  +	{ .name = "user", .private = STAGEINFO_USER },
  +	{ .name = NULL }
  +};
   
   #if HANDLER_SYNTAX_3_2
   
  -static const char *stageinfo_parameters_3_2[] = { "base", "root", "user",
  -						  "shell", NULL };
  +static const struct handler_parameter stageinfo_parameters_3_2[] = {
  +	{ .name = "base", .private = STAGEINFO_BASE },
  +	{ .name = "root", .private = STAGEINFO_ROOT },
  +	{ .name = "user", .private = STAGEINFO_USER },
  +	{ .name = "shell", .private = STAGEINFO_SHELL },
  +	{ .name = NULL }
  +};
   
   #endif
   
  @@ -486,32 +504,27 @@
   }
   
   static int stageinfo_parameter(const element_s * const element,
  -			       const char * const parameter,
  +			       const struct handler_parameter * const param,
   			       const char * const value)
   {
   	struct stageinfo_data *data = (struct stageinfo_data *) element->handler_data;
   
  -	if (strcmp(parameter, "base") == 0)
  -		if ((data->base = parse_string_parameter(value,
  -							 "<stageinfo>: \"base\" cannot be empty.")))
  -			return 0;
  -
  -	if (strcmp(parameter, "user") == 0)
  -		if ((data->user = parse_string_parameter(value,
  -							 "<stageinfo>: \"user\" cannot be empty.")))
  -			return 0;
  -
  -	if (strcmp(parameter, "root") == 0)
  -		if ((data->root = parse_string_parameter(value,
  -							 "<stageinfo>: \"root\" cannot be empty.")))
  -			return 0;
  -
  -	if (strcmp(parameter, "shell") == 0)
  -		if ((data->shell = parse_string_parameter(value,
  -							  "<stageinfo>: \"shell\" cannot be empty.")))
  -			return 0;
  -
  -	return 1;
  +	switch (param->private) {
  +	case STAGEINFO_BASE:
  +		data->base = xstrdup(value);
  +		return 0;
  +	case STAGEINFO_USER:
  +		data->user = xstrdup(value);
  +		return 0;
  +	case STAGEINFO_ROOT:
  +		data->root = xstrdup(value);
  +		return 0;
  +	case STAGEINFO_SHELL:
  +		data->shell = xstrdup(value);
  +		return 0;
  +	default:
  +		return 1;
  +	}
   }
   
   static int stageinfo_invalid_child(const element_s * const element,
  @@ -759,7 +772,7 @@
   		.setup = stageinfo_setup,
   		.free = stageinfo_free,
   		.parameters = stageinfo_parameters,
  -		.parse_parameter = stageinfo_parameter,
  +		.parameter = stageinfo_parameter,
   		.invalid_child = stageinfo_invalid_child,
   	},
   	{
  @@ -780,7 +793,7 @@
   		.free = variable_free,
   		.attributes = variable_attributes,
   		.attribute = variable_attribute,
  -		.parse_content = variable_content,
  +		.content = variable_content,
   		.invalid_data = variable_invalid_data,
   		.invalid_child = variable_invalid_child,
   	},
  @@ -838,7 +851,7 @@
   		.setup = stageinfo_setup,
   		.free = stageinfo_free,
   		.parameters = stageinfo_parameters,
  -		.parse_parameter = stageinfo_parameter,
  +		.parameter = stageinfo_parameter,
   		.invalid_child = stageinfo_invalid_child,
   	},
   	{
  @@ -859,7 +872,7 @@
   		.free = variable_free,
   		.attributes = variable_attributes,
   		.attribute = variable_attribute,
  -		.parse_content = variable_content,
  +		.content = variable_content,
   		.invalid_data = variable_invalid_data,
   		.invalid_child = variable_invalid_child,
   	},
  @@ -917,7 +930,7 @@
   		.free = stageinfo_free,
   		.alloc_data = stageinfo_data,
   		.parameters = stageinfo_parameters_3_2,
  -		.parse_parameter = stageinfo_parameter,
  +		.parameter = stageinfo_parameter,
   		.invalid_child = stageinfo_invalid_child,
   	},
   	{
  @@ -938,7 +951,7 @@
   		.free = variable_free,
   		.attributes = variable_attributes,
   		.attribute = variable_attribute,
  -		.parse_content = variable_content,
  +		.content = variable_content,
   		.invalid_data = variable_invalid_data,
   		.invalid_child = variable_invalid_child,
   	},
  
  
  
  1.18      +13 -4     ALFS/nALFS/src/handlers/textdump.c
  
  Index: textdump.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/textdump.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- textdump.c	21 Feb 2004 19:03:32 -0000	1.17
  +++ textdump.c	23 Feb 2004 21:19:35 -0000	1.18
  @@ -110,8 +110,13 @@
   
   #if HANDLER_SYNTAX_2_0
   
  -static const char *textdump_parameters_ver2[] =
  -{ "base", "file", "content", NULL };
  +static const struct handler_parameter textdump_parameters_ver2[] = {
  +	{ .name = "base" },
  +	{ .name = "file" },
  +	{ .name = "content" },
  +	{ .name = NULL }
  +};
  +
   // char *HANDLER_SYMBOL(attributes)[] = { "mode", NULL };
   
   static int textdump_main_ver2(element_s * const el)
  @@ -131,8 +136,12 @@
   
   #if HANDLER_SYNTAX_3_0 || HANDLER_SYNTAX_3_1 || HANDLER_SYNTAX_3_2
   
  -static const char *textdump_parameters_ver3[] =
  -{ "file", "content", NULL };
  +static const struct handler_parameter textdump_parameters_ver3[] = {
  +	{ .name = "file" },
  +	{ .name = "content" },
  +	{ .name = NULL }
  +};
  +
   // char *HANDLER_SYMBOL(attributes)[] = { "base", "mode", NULL };
   
   static int textdump_main_ver3(element_s * const el)
  
  
  
  1.23      +18 -6     ALFS/nALFS/src/handlers/unpack.c
  
  Index: unpack.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/unpack.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- unpack.c	21 Feb 2004 19:03:32 -0000	1.22
  +++ unpack.c	23 Feb 2004 21:19:35 -0000	1.23
  @@ -113,8 +113,11 @@
   
   #if HANDLER_SYNTAX_2_0
   
  -static const char *unpack_parameters_ver2[] =
  -{ "archive", "destination", NULL };
  +static const struct handler_parameter unpack_parameters_ver2[] = {
  +	{ .name = "archive" },
  +	{ .name = "destination" },
  +	{ .name = NULL }
  +};
   
   static int unpack_main_ver2(element_s * const el)
   {
  @@ -165,8 +168,13 @@
   
   #if HANDLER_SYNTAX_3_0 || HANDLER_SYNTAX_3_1
   
  -static const char *unpack_parameters_ver3[] =
  -{ "digest", "reference", "archive", "destination", NULL };
  +static const struct handler_parameter unpack_parameters_ver3[] = {
  +	{ .name = "archive" },
  +	{ .name = "destination" },
  +	{ .name = "digest" },
  +	{ .name = "reference" },
  +	{ .name = NULL }
  +};
   
   static int unpack_main_ver3(element_s * const el)
   {
  @@ -252,8 +260,12 @@
   
   #if HANDLER_SYNTAX_3_2
   
  -static const char *unpack_parameters_ver3_2[] =
  -{ "digest", "reference", "archive", NULL };
  +static const struct handler_parameter unpack_parameters_ver3_2[] = {
  +	{ .name = "archive" },
  +	{ .name = "digest" },
  +	{ .name = "reference" },
  +	{ .name = NULL }
  +};
   
   static int unpack_main_ver3_2(element_s * const el)
   {
  
  
  



More information about the alfs-log mailing list