cvs commit: ALFS/nALFS/src/handlers alfs.c check.c execute.c package.c postbuild.c prebuild.c stage.c su.c textdump.c

kpfleming at linuxfromscratch.org kpfleming at linuxfromscratch.org
Mon Mar 15 20:21:59 PST 2004


kpfleming    04/03/15 21:21:59

  Modified:    nALFS/src backend.c handlers.c handlers.h libXML-tree.c
                        logging.c nalfs.c parser.c parser.h
               nALFS/src/handlers alfs.c check.c execute.c package.c
                        postbuild.c prebuild.c stage.c su.c textdump.c
  Log:
  allow handlers to provide their own "display name", rather than hardcoding how to construct these in the frontend
  remove extraneous HTYPE entries that were needed only for constructing special display names
  remove name and content fields from element_s structure, they are not needed any longer
  modify profile "handler" to allow storing of path profile was loaded from
  modify comment "handler" to allow storing comment text
  replace text comparisons of handler names with checking handler->type
  modify handlers for <textdump>, <check>, <execute>, <package> and <stage> to provide their own "display name"
  
  Revision  Changes    Path
  1.15      +9 -10     ALFS/nALFS/src/backend.c
  
  Index: backend.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/backend.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- backend.c	2 Mar 2004 04:07:54 -0000	1.14
  +++ backend.c	16 Mar 2004 04:21:58 -0000	1.15
  @@ -342,7 +342,7 @@
   static INLINE void change_to_profiles_dir(element_s *el)
   {
   	element_s *profile = get_profile_by_element(el);
  -	char *path = xstrdup(profile->name);
  +	char *path = xstrdup(profile->handler->name);
   	char *tmp;
   
   
  @@ -369,7 +369,7 @@
   	}
   
   	comm_send_ctrl_msg(BACKEND_CTRL_SOCK, CTRL_ELEMENT_STARTED,
  -		"%s %s %d", profile->name, el->name, el->id);
  +		"%s %s %d", profile->handler->name, el->handler->name, el->id);
   
   	if (el->type == TYPE_PROFILE) {
   		i = execute_children(el);
  @@ -388,7 +388,7 @@
   			  * type and only those elements can run.)
   			  */
   			ASSERT(0);
  -			Nprint_err("No handler for %s", el->name);
  +			Nprint_err("No handler for %s", el->handler->name);
   			return -1;
   		}
   	}
  @@ -397,11 +397,11 @@
   		// TODO: Is there a point of setting these at all?
   		el->run_status = get_element_status(el);
   		comm_send_ctrl_msg(BACKEND_CTRL_SOCK, CTRL_ELEMENT_ENDED,
  -			"%s %s %d", profile->name, el->name, el->id);
  +			"%s %s %d", profile->handler->name, el->handler->name, el->id);
   	} else {
   		el->run_status = RUN_STATUS_FAILED;
   		comm_send_ctrl_msg(BACKEND_CTRL_SOCK, CTRL_ELEMENT_FAILED,
  -			"%s %s %d", profile->name, el->name, el->id);
  +			"%s %s %d", profile->handler->name, el->handler->name, el->id);
   	}
   
   	return i;
  @@ -418,7 +418,7 @@
   	}
   
   	comm_send_ctrl_msg(BACKEND_CTRL_SOCK, CTRL_ELEMENT_STARTED,
  -		"%s %s %d", profile->name, element->name, element->id);
  +		"%s %s %d", profile->handler->name, element->handler->name, element->id);
   
   	if (*opt_use_relative_dirs)
   		change_to_profiles_dir(element);
  @@ -429,11 +429,11 @@
   		// TODO: Is there a point of setting these at all?
   		element->run_status = get_element_status(element);
   		comm_send_ctrl_msg(BACKEND_CTRL_SOCK, CTRL_ELEMENT_ENDED,
  -			"%s %s %d", profile->name, element->name, element->id);
  +			"%s %s %d", profile->handler->name, element->handler->name, element->id);
   	} else {
   		element->run_status = RUN_STATUS_FAILED;
   		comm_send_ctrl_msg(BACKEND_CTRL_SOCK, CTRL_ELEMENT_FAILED,
  -			"%s %s %d", profile->name, element->name, element->id);
  +			"%s %s %d", profile->handler->name, element->handler->name, element->id);
   	}
   
   	return i;
  @@ -442,8 +442,7 @@
   int execute_children(element_s *element)
   {
   	return execute_children_filtered(element,
  -					 HTYPE_NORMAL | HTYPE_EXECUTE | 
  -					 HTYPE_PACKAGE | HTYPE_TEXTDUMP);
  +					 HTYPE_NORMAL | HTYPE_PACKAGE);
   }
   
   int execute_children_filtered(element_s *element, handler_type_e type_filter)
  
  
  
  1.32      +91 -15    ALFS/nALFS/src/handlers.c
  
  Index: handlers.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers.c,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- handlers.c	16 Mar 2004 02:09:38 -0000	1.31
  +++ handlers.c	16 Mar 2004 04:21:58 -0000	1.32
  @@ -50,13 +50,56 @@
   
   /* Embedded "handlers" for the profile and comment elements. */
   
  -static int profile_main(const element_s * const el)
  +enum {
  +	PROFILE_PATH
  +};
  +
  +struct profile_data {
  +	char *path;
  +};
  +
  +static const struct handler_attribute profile_attributes[] = {
  +	{ .name = "path", .private = PROFILE_PATH },
  +        { .name = NULL }
  +};
  +
  +static int profile_setup(element_s * const element)
   {
  -	(void) el;
  +	struct profile_data *data;
  +
  +	if ((data = xmalloc(sizeof(struct profile_data))) == NULL)
  +		return 1;
  +
  +	data->path = NULL;
  +	element->handler_data = data;
   
   	return 0;
   }
   
  +static void profile_free(const element_s * const element)
  +{
  +	struct profile_data *data = (struct profile_data *) element->handler_data;
  +
  +	xfree(data->path);
  +	xfree(data);
  +}
  +
  +static int profile_attribute(const element_s * const element,
  +			     const struct handler_attribute * const attr,
  +			     const char * const value)
  +{
  +	struct profile_data *data = (struct profile_data *) element->handler_data;
  +
  +	switch (attr->private) {
  +	case PROFILE_PATH:
  +		/* will never be called by parser more than once */
  +		data->path = xstrdup(value);
  +		return 0;
  +	default:
  +		return 1;
  +	}
  +}
  +
   static int profile_valid_child(const element_s * const element,
   			       const element_s * const child)
   {
  @@ -68,11 +111,22 @@
   static char *profile_data(const element_s * const element,
   			  const handler_data_e data_requested)
   {
  -	(void) element;
  +	struct profile_data *data = (struct profile_data *) element->handler_data;
  +
   	switch (data_requested) {
   	case HDATA_SYNTAX_VERSION:
   		return xstrdup(*opt_default_syntax);
  -		break;
  +	case HDATA_DISPLAY_NAME:
  +	{
  +		char *tmp;
  +
  +		/* display only the file name, not the whole path */
  +		if ((tmp = strrchr(data->path, '/'))) {
  +			return xstrdup(++tmp);
  +		} else {
  +			return xstrdup(data->path);
  +		}
  +	}
   	default:
   		break;
   	}
  @@ -80,6 +134,13 @@
   	return NULL;
   }
   
  +static int profile_main(const element_s * const el)
  +{
  +	(void) el;
  +
  +	return 0;
  +}
  +
   struct comment_data {
   	char *content;
   };
  @@ -116,6 +177,25 @@
   	return 0;
   }
   
  +static char *comment_data(const element_s * const element,
  +			  const handler_data_e data_requested)
  +{
  +	struct comment_data *data = (struct comment_data *) element->handler_data;
  +
  +	switch (data_requested) {
  +	case HDATA_DISPLAY_NAME:
  +		if (strchr(data->content, '\n')) {
  +			return xstrdup("comment block");
  +		} else {
  +			return xstrdup(data->content);
  +		};
  +	default:
  +		break;
  +	}
  +
  +	return NULL;
  +}
  +
   static int comment_main(const element_s * const el)
   {
   	(void) el;
  @@ -131,8 +211,12 @@
   		.main = profile_main,
   		.type = HTYPE_NORMAL,
   		.valid_child = profile_valid_child,
  -		.data = HDATA_SYNTAX_VERSION,
  +		.data = HDATA_SYNTAX_VERSION | HDATA_DISPLAY_NAME,
   		.alloc_data = profile_data,
  +		.attributes = profile_attributes,
  +		.attribute = profile_attribute,
  +		.setup = profile_setup,
  +		.free = profile_free,
   	},
   	{
   		.name = "__comment",
  @@ -143,6 +227,8 @@
   		.setup = comment_setup,
   		.free = comment_free,
   		.content = comment_content,
  +		.data = HDATA_DISPLAY_NAME,
  +		.alloc_data = comment_data,
   	},
   	{
   		.name = NULL
  @@ -342,16 +428,6 @@
   	xfree(version);
   
   	return s;
  -}
  -
  -char *alloc_textdump_file(element_s *el)
  -{
  -	return el->handler->alloc_data(el, HDATA_FILE);
  -}
  -
  -char *alloc_execute_command(element_s *el)
  -{
  -	return el->handler->alloc_data(el, HDATA_COMMAND);
   }
   
   const char *find_handler_data(const element_s * const element,
  
  
  
  1.30      +21 -21    ALFS/nALFS/src/handlers.h
  
  Index: handlers.h
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers.h,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- handlers.h	16 Mar 2004 02:09:38 -0000	1.29
  +++ handlers.h	16 Mar 2004 04:21:58 -0000	1.30
  @@ -31,28 +31,30 @@
   
   
   typedef enum handler_type_e {
  -	HTYPE_COMMENT = (1 << 0),
  -	HTYPE_NORMAL = (1 << 1),
  -	HTYPE_PACKAGE = (1 << 2),
  -	HTYPE_TEXTDUMP = (1 << 3),
  -	HTYPE_TEST = (1 << 4),		/* handler provides a test result */
  -	HTYPE_TRUE_RESULT = (1 << 5),	/* handler should be run for a true test */
  -	HTYPE_FALSE_RESULT = (1 << 6),	/* handler should be run for a false test */
  -	HTYPE_EXECUTE = (1 << 7),
  -	HTYPE_STAGE = (1 << 8),      /* handler is a stage container */
  -	HTYPE_STAGEINFO = (1 << 9),  /* handler provides stage information */
  -	HTYPE_DIGEST = (1 << 10),    /* handler provides file digest information */
  -	HTYPE_PACKAGEINFO = (1 << 11),  /* handler provides package information */
  +	HTYPE_COMMENT = 1,
  +	HTYPE_NORMAL = 2,
  +	HTYPE_PACKAGE = 4,
  +	HTYPE_TEST = 16,		/* handler provides a test result */
  +	HTYPE_TRUE_RESULT = 32,	/* handler should be run for a true test */
  +	HTYPE_FALSE_RESULT = 64,	/* handler should be run for a false test */
  +	HTYPE_STAGE = 256,      /* handler is a stage container */
  +	HTYPE_STAGEINFO = 512,  /* handler provides stage information */
  +	HTYPE_DIGEST = 1024,    /* handler provides file digest information */
  +	HTYPE_PACKAGEINFO = 2048,  /* handler provides package information */
   } handler_type_e;
   
   typedef enum handler_data_e {
  -	HDATA_COMMAND = (1 << 1),
  -	HDATA_NAME = (1 << 2),
  -	HDATA_VERSION = (1 << 3),
  -	HDATA_FILE = (1 << 4),
  -	HDATA_BASE = (1 << 5),
  -	HDATA_SHELL = (1 << 6),
  -	HDATA_SYNTAX_VERSION = (1 << 7),
  +	HDATA_COMMAND = 1,
  +	HDATA_VERSION = 4,
  +	HDATA_NAME = 2,
  +#if 0
  +	HDATA_FILE = 8,
  +#endif
  +	HDATA_BASE = 16,
  +	HDATA_SHELL = 32,
  +	HDATA_SYNTAX_VERSION = 64,
  +	HDATA_DISPLAY_NAME = 128,
  +	HDATA_DISPLAY_DETAILS = 256,
   } handler_data_e;
   
   struct handler_attribute {
  @@ -145,8 +147,6 @@
   char *alloc_package_version(element_s *el);
   char *alloc_package_string(element_s *el);
   int package_has_name_and_version(element_s *el);
  -char *alloc_textdump_file(element_s *el);
  -char *alloc_execute_command(element_s *el);
   
   const char *find_handler_data(const element_s * const element,
   			      const handler_data_e data_requested);
  
  
  
  1.24      +14 -12    ALFS/nALFS/src/libXML-tree.c
  
  Index: libXML-tree.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/libXML-tree.c,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- libXML-tree.c	16 Mar 2004 02:09:38 -0000	1.23
  +++ libXML-tree.c	16 Mar 2004 04:21:58 -0000	1.24
  @@ -222,20 +222,22 @@
   		   and check the result. */
   
   		if (handler->content) {
  -			xmlChar *content;
  +			xmlChar *content = NULL;
   
  -			if (node->children
  -			    && node->children->type == XML_TEXT_NODE
  -			    && node->children->next == NULL) {
  -				if ((content = xmlNodeGetContent(node))) {
  -					result = handler->content(element,
  -								  content);
  -					xfree(content);
  -					if (result)
  -						return result;
  -				}
  +			if (node->type == XML_COMMENT_NODE) {
  +				content = xmlNodeGetContent(node);
  +			} else if (node->children
  +				   && node->children->type == XML_TEXT_NODE
  +				   && node->children->next == NULL) {
  +				content = xmlNodeGetContent(node);
  +			}
  +			if (content) {
  +				result = handler->content(element,
  +							  content);
  +				xmlFree(content);
  +				if (result)
  +					return result;
   			}
  -
   		}
   
   		/* If the handler wants to validate its private data */
  
  
  
  1.18      +5 -5      ALFS/nALFS/src/logging.c
  
  Index: logging.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/logging.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- logging.c	14 Mar 2004 07:28:29 -0000	1.17
  +++ logging.c	16 Mar 2004 04:21:58 -0000	1.18
  @@ -636,7 +636,7 @@
   	element_s *profile = get_profile_by_element(el);
   
   	comm_send_ctrl_msg(BACKEND_CTRL_SOCK, CTRL_REQUEST_EL_STATUS,
  -		"%s %s %d", profile->name, el->name, el->id);
  +		"%s %s %d", profile->handler->name, el->handler->name, el->id);
   
   	while ((message = comm_read_ctrl_message(BACKEND_CTRL_SOCK)) == NULL)
   		/* Wait for the first control message. */ ;
  @@ -816,7 +816,7 @@
   	t = time(NULL);
   	strftime(time_str, sizeof time_str, DATE_FORMAT, localtime(&t));
   
  -	logs_add_end_time(logs, el->name, time_str, status);
  +	logs_add_end_time(logs, el->handler->name, time_str, status);
   }
   
   void log_start_time(const element_s * const el)
  @@ -833,7 +833,7 @@
   	t = time(NULL);
   	strftime(time_str, sizeof time_str, DATE_FORMAT, localtime(&t));
   
  -	logs_add_start_time(logs, el->name, time_str);
  +	logs_add_start_time(logs, el->handler->name, time_str);
   }
   
   void start_logging_element(const element_s * const el)
  @@ -843,7 +843,7 @@
   		return;
   	}
   
  -	if (Is_element_name(el, "package")) {
  +	if (el->handler->type & HTYPE_PACKAGE) {
   		if (package_has_name_and_version(el)) {
   			logs = start_package_logging(el);
   
  @@ -860,7 +860,7 @@
   		return;
   	}
   
  -	if (Is_element_name(el, "package")) {
  +	if (el->handler->type & HTYPE_PACKAGE) {
   		end_package_logging(status);
   
   	}
  
  
  
  1.46      +37 -115   ALFS/nALFS/src/nalfs.c
  
  Index: nalfs.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/nalfs.c,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- nalfs.c	16 Mar 2004 02:09:38 -0000	1.45
  +++ nalfs.c	16 Mar 2004 04:21:58 -0000	1.46
  @@ -456,10 +456,10 @@
   	char *tmp, *profile_name = NULL;
   
   
  -	if ((tmp = strrchr(profile->name, '/'))) {
  +	if ((tmp = strrchr(profile->handler->name, '/'))) {
   		append_str(&profile_name, ++tmp);
   	} else {
  -		append_str(&profile_name, profile->name);
  +		append_str(&profile_name, profile->handler->name);
   	}
   
   	ASSERT(profile_name != NULL);
  @@ -504,7 +504,7 @@
   
   
   	for (p = el; p; p = p->parent) {
  -		if (Is_element_name(p, "package")) {
  +		if (p->handler->type & HTYPE_PACKAGE) {
   			break;
   		}
   	}
  @@ -527,18 +527,18 @@
   
   
   	if ((current_package = get_elements_package(el)) == NULL) {
  -		Debug_logging("Element %s is not inside <package>.", el->name);
  +		Debug_logging("Element %s is not inside <package>.", el->handler->name);
   		return 0;
   	}
   
   	if (package_has_name_and_version(current_package)) {
   		Debug_logging("Element's <package> has "
  -			"name and version (%s).", el->name);
  +			"name and version (%s).", el->handler->name);
   		package_str = alloc_package_string(current_package);
   
   	} else {
   		Debug_logging("Element's <package> dosn't have "
  -			"name and version (%s).", el->name);
  +			"name and version (%s).", el->handler->name);
   		return 0;
   	}
   
  @@ -809,7 +809,7 @@
   {
   	current_running = find_element_by_key(msg_content);
   
  -	// Nprint("Started: %s (%s)", msg_content, current_running->name);
  +	// Nprint("Started: %s (%s)", msg_content, current_running->handler->name);
   
   	ASSERT(current_running != NULL);
   
  @@ -826,7 +826,7 @@
   {
   	element_s *current_ended = find_element_by_key(msg_content);
   
  -	// Nprint("Ended: %s (%s)", msg_content, current_ended->name);
  +	// Nprint("Ended: %s (%s)", msg_content, current_ended->handler->name);
   
   	ASSERT(current_ended != NULL);
   
  @@ -843,7 +843,7 @@
   {
   	element_s *current_failed = find_element_by_key(msg_content);
   
  -	// Nprint("Failed: %s (%s)", msg_content, current_failed->name);
  +	// Nprint("Failed: %s (%s)", msg_content, current_failed->handler->name);
   
   	ASSERT(current_failed != NULL);
   
  @@ -1318,76 +1318,6 @@
    * Writing to main window.
    */
   
  -/* Not really the good place for this. */
  -static INLINE void add_element_specific_info(char **line, element_s *el)
  -{
  -	if (Is_element_name(el, "package")) {
  -		char *name, *version;
  -
  -		if ((name = alloc_package_name(el))) {
  -			append_str(line, " ");
  -			append_str(line, name);
  -
  -			if ((version = alloc_package_version(el))) {
  -				append_str(line, " ");
  -				append_str(line, version);
  -
  -				xfree(version);
  -			}
  -
  -			xfree(name);
  -		}
  -
  -	} else if (Is_element_name(el, "execute")) {
  -		char *command;
  -
  -		if ((command = alloc_execute_command(el))) {
  -			append_str(line, " ");
  -			append_str(line, command);
  -
  -			xfree(command);
  -
  -			/* In case command has multiple lines. */
  -			remove_new_line(*line);
  -		}
  -
  -	} else if (Is_element_name(el, "textdump")) {
  -		char *file;
  -
  -		if ((file = alloc_textdump_file(el))) {
  -			append_str(line, " (");
  -			append_str(line, file);
  -			append_str(line, ")");
  -
  -			xfree(file);
  -		}
  -
  -	} else if (Is_element_name(el, "stage")) {
  -		char *s;
  -
  -/* TODO: get description/name from handler */
  -/*		if ((s = attr_value("description", el))) {
  -			append_str(line, s);
  -
  -		} else {
  -			if ((s = attr_value("name", el))) {
  -				append_str(line, s);
  -			}
  -		}
  -*/
  -
  -	} else if (Is_element_name(el, "check")) {
  -		char *s;
  -
  -		if ((s = alloc_trimmed_str(el->content)) != NULL) {
  -			append_str(line, ": ");
  -			append_str(line, s);
  -
  -			xfree(s);
  -		}
  -	}
  -}
  -
   static int should_skip_element(element_s *el, int *depth)
   {
   	if (el->type == TYPE_COMMENT && !*opt_display_comments) {
  @@ -1476,25 +1406,13 @@
   		append_str(&line, "  ");
   	}
   
  -	if (el->handler) { /* Description and some element-specific info. */
  -		if (! Is_element_name(el, "stage") || *opt_display_stage_header) {
  -			append_str(&line, el->handler->description);
  -		}
  -
  -		add_element_specific_info(&line, el);
  -
  -	} else { /* We don't want to print huge profile's directories. */
  -		if (el->type == TYPE_PROFILE) {
  -			char *tmp;
  -
  -			if ((tmp = strrchr(el->name, '/'))) {
  -				append_str(&line, ++tmp);
  -			} else {
  -				append_str(&line, el->name);
  -			}
  -		} else {
  -			append_str(&line, el->name);
  -		}
  +	if (el->handler->data & HDATA_DISPLAY_NAME) {
  +		char *display = el->handler->alloc_data(el,
  +							HDATA_DISPLAY_NAME);
  +		append_str(&line, display);
  +		xfree(display);
  +	} else {
  +		append_str(&line, el->handler->description);
   	}
   
   	/* Print the line. */
  @@ -1588,7 +1506,7 @@
   				|| el->run_status == RUN_STATUS_SOME_DONE);
   
   		case JUMP_TO_PACKAGE:
  -			return Is_element_name(el, "package");
  +			return el->handler->type & HTYPE_PACKAGE;
   	}
   
   	/* Never reached. */
  @@ -2868,13 +2786,14 @@
   
   static void build_description_aux(char **pcontent, element_s *node, int indent)
   {
  +#if 0
   	static const char *spaces = "            ";
   
   	if (indent > 12) {
   		indent = 12;
   	}
   
  -	if (strcmp(node->name, "para") == 0) {
  +	if (strcmp(node->handler->name, "para") == 0) {
   		char *s = xstrdup(node->content);
   
   		if (! Empty_string(s)) {
  @@ -2897,14 +2816,14 @@
   		xfree(s);
   	}
   
  -	if (strcmp(node->name, "list") == 0) {
  +	if (strcmp(node->handler->name, "list") == 0) {
   		element_s *child;
   		for (child = node->children; child; child = child->next) {
   			build_description_aux(pcontent, child, indent + 4);
   		}
   	}
   
  -	if (strcmp(node->name, "item") == 0) {
  +	if (strcmp(node->handler->name, "item") == 0) {
   		char *s = xstrdup(node->content);
   
   		if (! Empty_string(s)) {
  @@ -2935,6 +2854,7 @@
   
   		xfree(s);
   	}
  +#endif
   }
   
   static char *build_description(element_s *el)
  @@ -2971,7 +2891,7 @@
   		Xwaddch(windows.main->name, '\n');
   	}
   	
  -	Xwprintw(windows.main->name, "Element name  : %s\n\n", el->name);
  +	Xwprintw(windows.main->name, "Element name  : %s (syntax version %s)\n\n", el->handler->name, el->handler->syntax_version);
   
   /* TODO: get content from handler */
   	/* Print attributes (if any).
  @@ -3004,7 +2924,6 @@
   		xfree(s);
   
   	} else if (el->content) {
  -*/
   	if (el->content) {
   		Xwprintw(windows.main->name,
   			"Full content\n------------\n%s",
  @@ -3013,6 +2932,7 @@
   	} else {
   		Xwaddstr(windows.main->name, "No content.");
   	}
  +*/
   
   	getyx(windows.main->name, lines, i);
   
  @@ -3150,7 +3070,7 @@
   
   
   	Nprint("");
  -	Nprint("Executing %s...", el->name);
  +	Nprint("Executing %s...", el->handler->name);
   	Nprint("");
   
   	start_executing();
  @@ -3186,7 +3106,7 @@
   
   
   	Nprint("");
  -	Nprint("Executing from %s...", el->name);
  +	Nprint("Executing from %s...", el->handler->name);
   	Nprint("");
   
   	start_executing();
  @@ -3201,8 +3121,8 @@
   	element_s *new_profile;
   
   
  -	if ((new_profile = parse_profile(old_profile->name)) == NULL) {
  -		Nprint_err("Parsing %s failed.", old_profile->name);
  +	if ((new_profile = parse_profile(old_profile->handler->name)) == NULL) {
  +		Nprint_err("Parsing %s failed.", old_profile->handler->name);
   		return -1;
   	}
   
  @@ -3245,7 +3165,7 @@
   
   	add_profile(new_profile);
   
  -	Nprint("Profile added: %s", new_profile->name);
  +	Nprint("Profile added: %s", profile);
   
   	return new_profile;
   }
  @@ -3464,7 +3384,7 @@
   	}
   
   	if (what & SEARCH_ELEMENT_NAME) {
  -		if (xstrcasestr(el->name, string + offset)) {
  +		if (xstrcasestr(el->handler->name, string + offset)) {
   			return 1;
   		}
   	}
  @@ -3481,13 +3401,15 @@
   	}
   */
   
  +#if 0
   	if ((what & SEARCH_CONTENT) && el->content) {
   		if (xstrcasestr(el->content, string + offset)) {
   			return 1;
   		}
   	}
  +#endif
   
  -	if ((what & SEARCH_FOR_PACKAGE) && Is_element_name(el, "package")) {
  +	if ((what & SEARCH_FOR_PACKAGE) && (el->handler->type & HTYPE_PACKAGE)) {
   		int match;
   		char *name = alloc_package_name(el);
   
  @@ -3500,7 +3422,7 @@
   		}
   	}
   
  -	if ((what & SEARCH_FOR_FULL_PACKAGE) && Is_element_name(el, "package")) {
  +	if ((what & SEARCH_FOR_FULL_PACKAGE) && (el->handler->type & HTYPE_PACKAGE)) {
   		int match;
   		char *name = alloc_package_name(el);
   
  @@ -3952,7 +3874,7 @@
   				element_s *profile =
   				get_profile_by_element(Current_element);
   
  -				run_editor(profile->name);
  +				run_editor(profile->handler->name);
   			}
   
   
  @@ -4159,7 +4081,7 @@
   			displayed.current = find_cursor(el);
   
   			if (reload_profile(el)) {
  -				Nprint_err("Reloading %s failed.", el->name);
  +				Nprint_err("Reloading %s failed.", el->handler->name);
   				break;
   			}
   
  @@ -4167,7 +4089,7 @@
   
   			rewrite_main();
   
  -			Nprint("Profile %s reloaded.", Current_element->name);
  +			Nprint("Profile %s reloaded.", Current_element->handler->name);
   
   			break;
   		}
  
  
  
  1.16      +7 -11     ALFS/nALFS/src/parser.c
  
  Index: parser.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/parser.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- parser.c	16 Mar 2004 02:09:39 -0000	1.15
  +++ parser.c	16 Mar 2004 04:21:58 -0000	1.16
  @@ -51,9 +51,6 @@
   
   	new->id = element_id++;
   
  -	new->name = NULL;
  -	new->content = NULL;
  -
   	new->should_run = 0;
   	new->run_status = RUN_STATUS_NONE;
   	new->marked = 0;
  @@ -120,7 +117,11 @@
   	profile->parent = root_element;
   	profile->profile = profile;
   	profile->handler = find_handler("__profile", "all")->info;
  -	profile->name = xstrdup(profile_path);
  +	(void) profile->handler->setup(profile);
  +	(void) profile->handler->attribute(profile,
  +					   find_handler_attribute(profile->handler,
  +								  "path"),
  +					   profile_path);
   
   	return profile;
   }
  @@ -134,7 +135,6 @@
   	el->parent = parent;
   	el->profile = profile;
   	el->handler = find_handler("__comment", "all")->info;
  -	el->name = xstrdup("Xcomment");
   
   	return el;
   }
  @@ -154,7 +154,6 @@
   		el->parent = parent;
   		el->profile = profile;
   		el->handler = handler->info;
  -		el->name = xstrdup(handler_name);
   	} else {
   		Nprint_err("No handler found for %s (syntax version %s).",
   			   handler_name, syntax_version);
  @@ -180,9 +179,6 @@
   	if (el->handler_data)
   		el->handler->free(el);
   
  -	xfree(el->name);
  -	xfree(el->content);
  -
   	xfree(el);
   }
   
  @@ -208,7 +204,7 @@
   		append_str(el_path, "->");
   	}
   
  -	append_str(el_path, el->name);
  +	append_str(el_path, el->handler->name);
   }
   
   static INLINE void print_unknown_elements(element_s *profile)
  @@ -260,7 +256,7 @@
   	element_s *el;
   
   	for (el = root_element->children; el; el = el->next) {
  -		if (strcmp(el->name, name) == 0) {
  +		if (strcmp(el->handler->name, name) == 0) {
   			return el;
   		}
   	}
  
  
  
  1.11      +1 -7      ALFS/nALFS/src/parser.h
  
  Index: parser.h
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/parser.h,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- parser.h	16 Mar 2004 02:09:39 -0000	1.10
  +++ parser.h	16 Mar 2004 04:21:58 -0000	1.11
  @@ -31,10 +31,7 @@
   	(el)->type == TYPE_ROOT )
   
   #define Is_element_name(el,str) \
  -	(el->type == TYPE_ELEMENT && strcmp(el->name, str) == 0)
  -#define Is_parameter_name(el,str) \
  -	(el->type == TYPE_PARAMETER && strcmp(el->name, str) == 0)
  -
  +	(el->type == TYPE_ELEMENT && strcmp(el->handler->name, str) == 0)
   
   typedef enum run_status_e {
   	RUN_STATUS_FAILED,
  @@ -66,9 +63,6 @@
   
   	struct handler_info_s *handler;
   	void *handler_data;
  -
  -	char *name;
  -	char *content;
   
   	struct element_s *parent;
   	struct element_s *children;
  
  
  
  1.24      +1 -3      ALFS/nALFS/src/handlers/alfs.c
  
  Index: alfs.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/alfs.c,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- alfs.c	14 Mar 2004 06:58:36 -0000	1.23
  +++ alfs.c	16 Mar 2004 04:21:59 -0000	1.24
  @@ -97,9 +97,7 @@
   
   	return child->handler->type & (HTYPE_NORMAL |
   				       HTYPE_COMMENT |
  -				       HTYPE_TEXTDUMP |
  -				       HTYPE_PACKAGE |
  -				       HTYPE_EXECUTE);
  +				       HTYPE_PACKAGE);
   }
   
   static char *alfs_data(const element_s * const element,
  
  
  
  1.18      +27 -0     ALFS/nALFS/src/handlers/check.c
  
  Index: check.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/check.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- check.c	29 Feb 2004 04:24:59 -0000	1.17
  +++ check.c	16 Mar 2004 04:21:59 -0000	1.18
  @@ -96,6 +96,31 @@
   	return 0;
   }
   
  +static char *check_data(const element_s * const element,
  +			  const handler_data_e data_requested)
  +{
  +	struct check_data *data = (struct check_data *) element->handler_data;
  +
  +	switch (data_requested) {
  +	case HDATA_DISPLAY_NAME:
  +	{
  +		char *display;
  +
  +		display = xstrdup("Check for installed package");
  +		if (data->content) {
  +			append_str(&display, ": ");
  +			append_str(&display, data->content);
  +		}
  +
  +		return display;
  +	}
  +	default:
  +		break;
  +	}
  +
  +	return NULL;
  +}
  +
   static int check_main(const element_s * const element)
   {
   	struct check_data *data = (struct check_data *) element->handler_data;
  @@ -167,6 +192,8 @@
   		.setup = check_setup,
   		.free = check_free,
   		.content = check_content,
  +		.data = HDATA_DISPLAY_NAME,
  +		.alloc_data = check_data,
   	},
   #endif
   	{
  
  
  
  1.28      +27 -22    ALFS/nALFS/src/handlers/execute.c
  
  Index: execute.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/execute.c,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- execute.c	3 Mar 2004 03:56:55 -0000	1.27
  +++ execute.c	16 Mar 2004 04:21:59 -0000	1.28
  @@ -236,9 +236,25 @@
   {
   	struct execute_data *data = (struct execute_data *) element->handler_data;
   
  -	(void) data_requested;
  +	switch (data_requested) {
  +	case HDATA_DISPLAY_NAME:
  +	{
  +		char *display;
  +
  +		display = xstrdup("Execute ");
  +		if (data->command) {
  +			append_str(&display, data->command);
  +		} else if (data->content) {
  +			append_str(&display, "script");
  +		}
   
  -	return xstrdup(data->command);
  +		return display;
  +	}
  +	default:
  +		break;
  +	}
  +
  +	return NULL;
   }
   
   #endif /* HANDLER_SYNTAX_2_0 || HANDLER_SYNTAX_3_0 || HANDLER_SYNTAX_3_1 */
  @@ -335,21 +351,6 @@
   	return status;
   }
   
  -static char *execute_data_ver3_2(const element_s * const element,
  -				 const handler_data_e data_requested)
  -{
  -	struct execute_data *data = (struct execute_data *) element->handler_data;
  -
  -	(void) data_requested;
  -
  -	if (data->command) {
  -		return xstrdup(data->command);
  -	} else if (data->content) {
  -		return xstrdup(data->content);
  -	}
  -	return NULL;
  -}
  -
   #endif
   
   /*
  @@ -364,7 +365,8 @@
   		.syntax_version = "2.0",
   		.parameters = execute_parameters_v2,
   		.main = execute_main,
  -		.type = HTYPE_EXECUTE,
  +		.type = HTYPE_NORMAL,
  +		.data = HDATA_DISPLAY_NAME,
   		.alloc_data = execute_data,
   		.is_action = 1,
   		.setup = execute_setup,
  @@ -381,7 +383,8 @@
   		.parameters = execute_parameters_v3,
   		.attributes = execute_attributes_v3,
   		.main = execute_main,
  -		.type = HTYPE_EXECUTE,
  +		.type = HTYPE_NORMAL,
  +		.data = HDATA_DISPLAY_NAME,
   		.alloc_data = execute_data,
   		.is_action = 1,
   		.setup = execute_setup,
  @@ -399,7 +402,8 @@
   		.parameters = execute_parameters_v3,
   		.attributes = execute_attributes_v3,
   		.main = execute_main,
  -		.type = HTYPE_EXECUTE,
  +		.type = HTYPE_NORMAL,
  +		.data = HDATA_DISPLAY_NAME,
   		.alloc_data = execute_data,
   		.is_action = 1,
   		.setup = execute_setup,
  @@ -417,8 +421,9 @@
   		.parameters = execute_parameters_v3_2,
   		.attributes = execute_attributes_v3_2,
   		.main = execute_main_ver3_2,
  -		.type = HTYPE_EXECUTE,
  -		.alloc_data = execute_data_ver3_2,
  +		.type = HTYPE_NORMAL,
  +		.data = HDATA_DISPLAY_NAME,
  +		.alloc_data = execute_data,
   		.is_action = 1,
   		.alternate_shell = 1,
   		.setup = execute_setup,
  
  
  
  1.23      +23 -7     ALFS/nALFS/src/handlers/package.c
  
  Index: package.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/package.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- package.c	14 Mar 2004 04:48:15 -0000	1.22
  +++ package.c	16 Mar 2004 04:21:59 -0000	1.23
  @@ -158,9 +158,7 @@
   
   	return child->handler->type & (HTYPE_NORMAL |
   				       HTYPE_COMMENT |
  -				       HTYPE_TEXTDUMP |
  -				       HTYPE_PACKAGE |
  -				       HTYPE_EXECUTE);
  +				       HTYPE_PACKAGE);
   }
   
   static int package_valid_data(const element_s * const element)
  @@ -193,6 +191,24 @@
   		if (data->version)
   			return xstrdup(data->version);
   		break;
  +	case HDATA_DISPLAY_NAME:
  +	{
  +		char *display;
  +
  +		display = xstrdup("Package");
  +
  +		if (data->name) {
  +			append_str(&display, " ");
  +			append_str(&display, data->name);
  +		}
  +
  +		if (data->version) {
  +			append_str(&display, " ");
  +			append_str(&display, data->version);
  +		}
  +
  +		return display;
  +	}
   	default:
   		break;
   	}
  @@ -488,7 +504,7 @@
   		.parameters = package_parameters_v2,
   		.main = package_main,
   		.type = HTYPE_PACKAGE,
  -		.data = HDATA_NAME | HDATA_VERSION | HDATA_BASE,
  +		.data = HDATA_NAME | HDATA_VERSION | HDATA_BASE | HDATA_DISPLAY_NAME,
   		.alloc_data = package_data,
   		.setup = package_setup,
   		.free = package_free,
  @@ -506,7 +522,7 @@
   		.attributes = package_attributes_v3,
   		.main = package_main,
   		.type = HTYPE_PACKAGE,
  -		.data = HDATA_NAME | HDATA_VERSION,
  +		.data = HDATA_NAME | HDATA_VERSION | HDATA_DISPLAY_NAME,
   		.alloc_data = package_data,
   		.setup = package_setup,
   		.free = package_free,
  @@ -571,7 +587,7 @@
   		.attributes = package_attributes_v3,
   		.main = package_main,
   		.type = HTYPE_PACKAGE,
  -		.data = HDATA_NAME | HDATA_VERSION,
  +		.data = HDATA_NAME | HDATA_VERSION | HDATA_DISPLAY_NAME,
   		.alloc_data = package_data,
   		.setup = package_setup,
   		.free = package_free,
  @@ -636,7 +652,7 @@
   		.attributes = package_attributes_v3,
   		.main = package_main,
   		.type = HTYPE_PACKAGE,
  -		.data = HDATA_NAME | HDATA_VERSION,
  +		.data = HDATA_NAME | HDATA_VERSION | HDATA_DISPLAY_NAME,
   		.alloc_data = package_data,
   		.setup = package_setup,
   		.free = package_free,
  
  
  
  1.20      +1 -3      ALFS/nALFS/src/handlers/postbuild.c
  
  Index: postbuild.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/postbuild.c,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- postbuild.c	2 Mar 2004 06:21:46 -0000	1.19
  +++ postbuild.c	16 Mar 2004 04:21:59 -0000	1.20
  @@ -49,9 +49,7 @@
   
   	return child->handler->type & (HTYPE_NORMAL |
   				       HTYPE_COMMENT |
  -				       HTYPE_TEXTDUMP |
  -				       HTYPE_PACKAGE |
  -				       HTYPE_EXECUTE);
  +				       HTYPE_PACKAGE);
   }
   
   static int postbuild_main(const element_s * const el)
  
  
  
  1.20      +1 -3      ALFS/nALFS/src/handlers/prebuild.c
  
  Index: prebuild.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/prebuild.c,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- prebuild.c	2 Mar 2004 06:21:46 -0000	1.19
  +++ prebuild.c	16 Mar 2004 04:21:59 -0000	1.20
  @@ -49,9 +49,7 @@
   
   	return child->handler->type & (HTYPE_NORMAL |
   				       HTYPE_COMMENT |
  -				       HTYPE_TEXTDUMP |
  -				       HTYPE_PACKAGE |
  -				       HTYPE_EXECUTE);
  +				       HTYPE_PACKAGE);
   }
   
   static int prebuild_main(const element_s * const el)
  
  
  
  1.33      +31 -13    ALFS/nALFS/src/handlers/stage.c
  
  Index: stage.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/stage.c,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- stage.c	14 Mar 2004 04:48:00 -0000	1.32
  +++ stage.c	16 Mar 2004 04:21:59 -0000	1.33
  @@ -349,9 +349,7 @@
   
   	return child->handler->type & (HTYPE_NORMAL |
   				       HTYPE_COMMENT |
  -				       HTYPE_TEXTDUMP |
  -				       HTYPE_PACKAGE |
  -				       HTYPE_EXECUTE);
  +				       HTYPE_PACKAGE);
   }
   
   static int stage_main(const element_s * const element)
  @@ -389,15 +387,35 @@
   {
   	struct stage_data *data = (struct stage_data *) element->handler_data;
   
  -	/* the only data elements currently supported by the <stage>
  +	/* some data elements currently supported by the <stage>
   	   element are HDATA_BASE and HDATA_SHELL, which actually
   	   are supplied by an HTYPE_STAGEINFO child, if it exists
   	*/
   
  -	if (!data->stageinfo)
  -		return NULL;
  +	switch (data_requested) {
  +	case HDATA_DISPLAY_NAME:
  +	{
  +		char *display = NULL;
  +
  +		if (*opt_display_stage_header)
  +			append_str(&display, "Enter stage: ");
  +
  +		if (data->name)
  +			append_str(&display, data->name);
  +
  +		return display;
  +	}
  +	case HDATA_BASE:
  +	case HDATA_SHELL:
  +		if (!data->stageinfo)
  +			return NULL;
   	
  -	return data->stageinfo->handler->alloc_data(data->stageinfo, data_requested);
  +		return data->stageinfo->handler->alloc_data(data->stageinfo, data_requested);
  +	default:
  +		break;
  +	}
  +
  +	return NULL;
   }
   
   #if HANDLER_SYNTAX_3_1 || HANDLER_SYNTAX_3_2
  @@ -766,11 +784,11 @@
   #if HANDLER_SYNTAX_3_0
   	{
   		.name = "stage",
  -		.description = "Enter stage: ", // FIXME
  +		.description = "Enter stage: ",
   		.syntax_version = "3.0",
   		.type = HTYPE_NORMAL | HTYPE_STAGE,
   		.main = stage_main,
  -		.data = HDATA_BASE,
  +		.data = HDATA_BASE | HDATA_DISPLAY_NAME,
   		.alloc_data = stage_data,
   		.setup = stage_setup,
   		.free = stage_free,
  @@ -816,11 +834,11 @@
   #if HANDLER_SYNTAX_3_1
   	{
   		.name = "stage",
  -		.description = "Enter stage: ", // FIXME
  +		.description = "stage",
   		.syntax_version = "3.1",
   		.type = HTYPE_NORMAL | HTYPE_STAGE,
   		.main = stage_main,
  -		.data = HDATA_BASE,
  +		.data = HDATA_BASE | HDATA_DISPLAY_NAME,
   		.alloc_data = stage_data,
   		.setup = stage_setup,
   		.free = stage_free,
  @@ -894,11 +912,11 @@
   #if HANDLER_SYNTAX_3_2
   	{
   		.name = "stage",
  -		.description = "Enter stage: ", // FIXME
  +		.description = "Enter stage: ",
   		.syntax_version = "3.2",
   		.type = HTYPE_NORMAL | HTYPE_STAGE,
   		.main = stage_main,
  -		.data = HDATA_BASE | HDATA_SHELL,
  +		.data = HDATA_BASE | HDATA_SHELL | HDATA_DISPLAY_NAME,
   		.alloc_data = stage_data,
   		.setup = stage_setup,
   		.free = stage_free,
  
  
  
  1.22      +1 -3      ALFS/nALFS/src/handlers/su.c
  
  Index: su.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/su.c,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- su.c	2 Mar 2004 05:18:06 -0000	1.21
  +++ su.c	16 Mar 2004 04:21:59 -0000	1.22
  @@ -120,9 +120,7 @@
   
   	return child->handler->type & (HTYPE_NORMAL |
   				       HTYPE_COMMENT |
  -				       HTYPE_TEXTDUMP |
  -				       HTYPE_PACKAGE |
  -				       HTYPE_EXECUTE);
  +				       HTYPE_PACKAGE);
   }
   
   static INLINE int set_supplementary_groups(const char *user)
  
  
  
  1.26      +23 -6     ALFS/nALFS/src/handlers/textdump.c
  
  Index: textdump.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/textdump.c,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- textdump.c	14 Mar 2004 06:11:07 -0000	1.25
  +++ textdump.c	16 Mar 2004 04:21:59 -0000	1.26
  @@ -228,9 +228,22 @@
   {
   	struct textdump_data *data = (struct textdump_data *) element->handler_data;
   
  -	(void) data_requested;
  +	switch (data_requested) {
  +	case HDATA_DISPLAY_NAME:
  +	{
  +		char *display;
  +
  +		display = xstrdup("Dump text (");
  +		append_str(&display, data->file);
  +		append_str(&display, ")");
  +
  +		return display;
  +	}
  +	default:
  +		break;
  +	}
   
  -	return xstrdup(data->file);
  +	return NULL;
   }
   
   /*
  @@ -243,7 +256,8 @@
   		.name = "textdump",
   		.description = "Dump text",
   		.syntax_version = "2.0",
  -		.type = HTYPE_TEXTDUMP,
  +		.type = HTYPE_NORMAL,
  +		.data = HDATA_DISPLAY_NAME,
   		.alloc_data = textdump_data,
   		.is_action = 1,
   		.main = textdump_main,
  @@ -261,7 +275,8 @@
   		.name = "textdump",
   		.description = "Dump text",
   		.syntax_version = "3.0",
  -		.type = HTYPE_TEXTDUMP,
  +		.type = HTYPE_NORMAL,
  +		.data = HDATA_DISPLAY_NAME,
   		.alloc_data = textdump_data,
   		.is_action = 1,
   		.main = textdump_main,
  @@ -279,7 +294,8 @@
   		.name = "textdump",
   		.description = "Dump text",
   		.syntax_version = "3.1",
  -		.type = HTYPE_TEXTDUMP,
  +		.type = HTYPE_NORMAL,
  +		.data = HDATA_DISPLAY_NAME,
   		.alloc_data = textdump_data,
   		.is_action = 1,
   		.main = textdump_main,
  @@ -297,7 +313,8 @@
   		.name = "textdump",
   		.description = "Dump text",
   		.syntax_version = "3.2",
  -		.type = HTYPE_TEXTDUMP,
  +		.type = HTYPE_NORMAL,
  +		.data = HDATA_DISPLAY_NAME,
   		.alloc_data = textdump_data,
   		.is_action = 1,
   		.alternate_shell = 1,
  
  
  



More information about the alfs-log mailing list