cvs commit: ALFS/nALFS/src/handlers stage.c

kpfleming at linuxfromscratch.org kpfleming at linuxfromscratch.org
Sun Mar 21 20:28:48 PST 2004


kpfleming    04/03/21 21:28:48

  Modified:    nALFS/src handlers.h nalfs.c
               nALFS/src/handlers stage.c
  Log:
  allow handlers to provide their "detailed information" for the frontend to display
  add detailed info for <stageinfo> and <variable>
  change <variable> to include variable name in the tree display
  
  Revision  Changes    Path
  1.32      +0 -3      ALFS/nALFS/src/handlers.h
  
  Index: handlers.h
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers.h,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- handlers.h	21 Mar 2004 04:54:33 -0000	1.31
  +++ handlers.h	22 Mar 2004 04:28:48 -0000	1.32
  @@ -47,9 +47,6 @@
   	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,
  
  
  
  1.52      +14 -53    ALFS/nALFS/src/nalfs.c
  
  Index: nalfs.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/nalfs.c,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- nalfs.c	21 Mar 2004 18:40:32 -0000	1.51
  +++ nalfs.c	22 Mar 2004 04:28:48 -0000	1.52
  @@ -2753,32 +2753,15 @@
   #endif
   }
   
  -static char *build_description(element_s *el)
  -{
  -	/* append_str(char **ptr, const char *str) */
  -
  -	char *content = NULL;
  -	element_s *child;
  -
  -	for (child = el->children; child; child = child->next) {
  -		build_description_aux(&content, child, 0);
  -	}
  -
  -	return content;
  -}
  -
   enum print_info_amount {
   	PRINT_MORE_INFO,
   	PRINT_LESS_INFO
   };
   
  -static int write_element_info(
  -	element_s *el,
  -	enum print_info_amount print_extra_info)
  +static int write_element_info(element_s *el, enum print_info_amount print_extra_info)
   {
   	int lines, i;
   
  -
   	Xwerase(windows.main->name);
   	Xwmove(windows.main->name, 0, 0);
   
  @@ -2787,29 +2770,19 @@
   		Xwaddch(windows.main->name, '\n');
   	}
   	
  -	Xwprintw(windows.main->name, "Element name  : %s (syntax version %s)\n\n", el->handler->name, el->handler->syntax_version);
  +	Xwprintw(windows.main->name, "Element name: %s (syntax version %s)\n\n",
  +		 el->handler->name, el->handler->syntax_version);
  +
  +	if (el->handler->data && HDATA_DISPLAY_DETAILS) {
  +		char *details;
   
  -/* TODO: get content from handler */
  -	/* Print attributes (if any).
  -	if (el->attr) {
  -		for (i = 0; el->attr[i]; i += 2) {
  -			Xwprintw(windows.main->name, "%s = %s\n",
  -				el->attr[i], el->attr[i+1]);
  -		}
  -
  -	} else {
  -		Xwaddstr(windows.main->name, "No attributes.\n");
  -        }
  -	*/
  -
  -	Xwaddch(windows.main->name, '\n');
  -
  -	/*
  -	 * Print content (if any).
  -	 */
  +		details = el->handler->alloc_data(el, HDATA_DISPLAY_DETAILS);
  +		Xwaddstr(windows.main->name, details);
  +		xfree(details);
  +	}
   
  -/* TODO: get data from handler */
  -/*	if (Is_parameter_name(el, "description")
  +#if 0
  +	if (Is_parameter_name(el, "description")
   	&& el->parent && Is_parameter_name(el->parent, "packageinfo")) {
   		char *s = build_description(el);
   
  @@ -2818,29 +2791,17 @@
   			Empty_string(s) ? el->content : s);
   
   		xfree(s);
  -
  -	} else if (el->content) {
  -	if (el->content) {
  -		Xwprintw(windows.main->name,
  -			"Full content\n------------\n%s",
  -			el->content);
  -
  -	} else {
  -		Xwaddstr(windows.main->name, "No content.");
   	}
  -*/
  +#endif
   
   	getyx(windows.main->name, lines, i);
   
   	return lines;
   }
   
  -static void display_element_info(
  -	element_s *el,
  -	enum print_info_amount print_extra_info)
  +static void display_element_info(element_s *el, enum print_info_amount print_extra_info)
   {
   	int lines, top = 0;
  -
   
   	windows.active = TMP_WINDOW;
   
  
  
  
  1.36      +70 -0     ALFS/nALFS/src/handlers/stage.c
  
  Index: stage.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/handlers/stage.c,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- stage.c	21 Mar 2004 03:40:52 -0000	1.35
  +++ stage.c	22 Mar 2004 04:28:48 -0000	1.36
  @@ -609,6 +609,22 @@
   		if (data->base)
   			return xstrdup(data->base);
   		break;
  +	case HDATA_DISPLAY_DETAILS:
  +	{
  +		char *display = NULL;
  +
  +		if (data->base)
  +			append_str_format(&display, "Base directory: %s\n", data->base);
  +		if (data->shell)
  +			append_str_format(&display, "Shell to use for commands: %s\n",
  +					  data->shell);
  +		if (data->root)
  +			append_str_format(&display, "Root directory: %s\n", data->root);
  +		if (data->user)
  +			append_str_format(&display, "User name: %s\n", data->user);
  +
  +		return display;
  +	}
   	default:
   		break;
   	}
  @@ -768,6 +784,51 @@
   	return 1;
   }
   
  +static char *variable_data(const element_s * const element,
  +			   const handler_data_e data_requested)
  +{
  +	struct variable_data *data = (struct variable_data *) element->handler_data;
  +
  +	switch (data_requested) {
  +	case HDATA_DISPLAY_NAME:
  +	{
  +		char *display = NULL;
  +
  +		append_str_format(&display, "Variable: %s", data->name);
  +
  +		return display;
  +	}
  +	case HDATA_DISPLAY_DETAILS:
  +	{
  +		char *display = NULL;
  +
  +		append_str_format(&display, "Variable name: %s\n", data->name);
  +		switch (data->mode) {
  +		case VAR_SET:
  +			if (data->value) {
  +				append_str_format(&display, "New value: %s\n", data->value);
  +			} else {
  +				append_str(&display, "Variable will be cleared\n");
  +			}
  +			break;
  +		case VAR_APPEND:
  +			append_str_format(&display, "Prepend value: %s\n", data->value);
  +			break;
  +		case VAR_PREPEND:
  +			append_str_format(&display, "Append value: %s\n", data->value);
  +			break;
  +		}
  +
  +		return display;
  +	}
  +	default:
  +		break;
  +	}
  +
  +	return NULL;
  +}
  +
  +
   /*
    * Handlers' information.
    */
  @@ -800,6 +861,7 @@
   		.parameters = stageinfo_parameters,
   		.parameter = stageinfo_parameter,
   		.valid_child = stageinfo_valid_child,
  +		.data =  HDATA_DISPLAY_DETAILS,
   	},
   	{
   		.name = "environment",
  @@ -821,6 +883,8 @@
   		.attribute = variable_attribute,
   		.content = variable_content,
   		.valid_data = variable_valid_data,
  +		.data = HDATA_DISPLAY_DETAILS | HDATA_DISPLAY_NAME,
  +		.alloc_data = variable_data,
   	},
   #endif
   #if HANDLER_SYNTAX_3_1
  @@ -878,6 +942,7 @@
   		.parameters = stageinfo_parameters,
   		.parameter = stageinfo_parameter,
   		.valid_child = stageinfo_valid_child,
  +		.data =  HDATA_DISPLAY_DETAILS,
   	},
   	{
   		.name = "environment",
  @@ -899,6 +964,8 @@
   		.attribute = variable_attribute,
   		.content = variable_content,
   		.valid_data = variable_valid_data,
  +		.data = HDATA_DISPLAY_DETAILS | HDATA_DISPLAY_NAME,
  +		.alloc_data = variable_data,
   	},
   #endif
   #if HANDLER_SYNTAX_3_2
  @@ -956,6 +1023,7 @@
   		.parameters = stageinfo_parameters_3_2,
   		.parameter = stageinfo_parameter,
   		.valid_child = stageinfo_valid_child,
  +		.data =  HDATA_DISPLAY_DETAILS,
   	},
   	{
   		.name = "environment",
  @@ -977,6 +1045,8 @@
   		.attribute = variable_attribute,
   		.content = variable_content,
   		.valid_data = variable_valid_data,
  +		.data = HDATA_DISPLAY_DETAILS | HDATA_DISPLAY_NAME,
  +		.alloc_data = variable_data,
   	},
   #endif
   	{
  
  
  



More information about the alfs-log mailing list