Browse Source

Added descriptive text for settings and setting types, and display it in

the option config UI.
tags/v0.9.3
Michael Brown 18 years ago
parent
commit
b93ff48173
3 changed files with 86 additions and 9 deletions
  1. 12
    2
      src/core/settings.c
  2. 70
    7
      src/hci/tui/settings_ui.c
  3. 4
    0
      src/include/gpxe/settings.h

+ 12
- 2
src/core/settings.c View File

19
 #include <stdint.h>
19
 #include <stdint.h>
20
 #include <stdlib.h>
20
 #include <stdlib.h>
21
 #include <string.h>
21
 #include <string.h>
22
+#include <strings.h>
22
 #include <byteswap.h>
23
 #include <byteswap.h>
23
 #include <errno.h>
24
 #include <errno.h>
24
 #include <assert.h>
25
 #include <assert.h>
56
 
57
 
57
 	for ( type = config_setting_types ; type < config_setting_types_end ;
58
 	for ( type = config_setting_types ; type < config_setting_types_end ;
58
 	      type++ ) {
59
 	      type++ ) {
59
-		if ( strcmp ( name, type->name ) == 0 )
60
+		if ( strcasecmp ( name, type->name ) == 0 )
60
 			return type;
61
 			return type;
61
 	}
62
 	}
62
 	return NULL;
63
 	return NULL;
73
 
74
 
74
 	for ( setting = config_settings ; setting < config_settings_end ;
75
 	for ( setting = config_settings ; setting < config_settings_end ;
75
 	      setting++ ) {
76
 	      setting++ ) {
76
-		if ( strcmp ( name, setting->name ) == 0 )
77
+		if ( strcasecmp ( name, setting->name ) == 0 )
77
 			return setting;
78
 			return setting;
78
 	}
79
 	}
79
 	return NULL;
80
 	return NULL;
216
 /** A string configuration setting */
217
 /** A string configuration setting */
217
 struct config_setting_type config_setting_type_string __config_setting_type = {
218
 struct config_setting_type config_setting_type_string __config_setting_type = {
218
 	.name = "string",
219
 	.name = "string",
220
+	.description = "Text string",
219
 	.show = show_string,
221
 	.show = show_string,
220
 	.set = set_string,
222
 	.set = set_string,
221
 };
223
 };
269
 /** An IPv4 configuration setting */
271
 /** An IPv4 configuration setting */
270
 struct config_setting_type config_setting_type_ipv4 __config_setting_type = {
272
 struct config_setting_type config_setting_type_ipv4 __config_setting_type = {
271
 	.name = "ipv4",
273
 	.name = "ipv4",
274
+	.description = "IPv4 address",
272
 	.show = show_ipv4,
275
 	.show = show_ipv4,
273
 	.set = set_ipv4,
276
 	.set = set_ipv4,
274
 };
277
 };
348
 /** An 8-bit integer configuration setting */
351
 /** An 8-bit integer configuration setting */
349
 struct config_setting_type config_setting_type_int8 __config_setting_type = {
352
 struct config_setting_type config_setting_type_int8 __config_setting_type = {
350
 	.name = "int8",
353
 	.name = "int8",
354
+	.description = "8-bit integer",
351
 	.show = show_int,
355
 	.show = show_int,
352
 	.set = set_int8,
356
 	.set = set_int8,
353
 };
357
 };
355
 /** Some basic setting definitions */
359
 /** Some basic setting definitions */
356
 struct config_setting ip_config_setting __config_setting = {
360
 struct config_setting ip_config_setting __config_setting = {
357
 	.name = "ip",
361
 	.name = "ip",
362
+	.description = "IP address of this machine (e.g. 192.168.0.1)",
358
 	.tag = DHCP_EB_YIADDR,
363
 	.tag = DHCP_EB_YIADDR,
359
 	.type = &config_setting_type_ipv4,
364
 	.type = &config_setting_type_ipv4,
360
 };
365
 };
361
 struct config_setting hostname_config_setting __config_setting = {
366
 struct config_setting hostname_config_setting __config_setting = {
362
 	.name = "hostname",
367
 	.name = "hostname",
368
+	.description = "Host name of this machine",
363
 	.tag = DHCP_HOST_NAME,
369
 	.tag = DHCP_HOST_NAME,
364
 	.type = &config_setting_type_string,
370
 	.type = &config_setting_type_string,
365
 };
371
 };
366
 struct config_setting username_config_setting __config_setting = {
372
 struct config_setting username_config_setting __config_setting = {
367
 	.name = "username",
373
 	.name = "username",
374
+	.description = "User name for authentication to servers",
368
 	.tag = DHCP_EB_USERNAME,
375
 	.tag = DHCP_EB_USERNAME,
369
 	.type = &config_setting_type_string,
376
 	.type = &config_setting_type_string,
370
 };
377
 };
371
 struct config_setting password_config_setting __config_setting = {
378
 struct config_setting password_config_setting __config_setting = {
372
 	.name = "password",
379
 	.name = "password",
380
+	.description = "Password for authentication to servers",
373
 	.tag = DHCP_EB_PASSWORD,
381
 	.tag = DHCP_EB_PASSWORD,
374
 	.type = &config_setting_type_string,
382
 	.type = &config_setting_type_string,
375
 };
383
 };
376
 struct config_setting root_path_config_setting __config_setting = {
384
 struct config_setting root_path_config_setting __config_setting = {
377
 	.name = "root-path",
385
 	.name = "root-path",
386
+	.description = "NFS/iSCSI root path",
378
 	.tag = DHCP_ROOT_PATH,
387
 	.tag = DHCP_ROOT_PATH,
379
 	.type = &config_setting_type_string,
388
 	.type = &config_setting_type_string,
380
 };
389
 };
381
 struct config_setting priority_config_setting __config_setting = {
390
 struct config_setting priority_config_setting __config_setting = {
382
 	.name = "priority",
391
 	.name = "priority",
392
+	.description = "Priority of these options",
383
 	.tag = DHCP_EB_PRIORITY,
393
 	.tag = DHCP_EB_PRIORITY,
384
 	.type = &config_setting_type_int8,
394
 	.type = &config_setting_type_int8,
385
 };
395
 };

+ 70
- 7
src/hci/tui/settings_ui.c View File

16
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
  */
17
  */
18
 
18
 
19
+#include <stdarg.h>
19
 #include <unistd.h>
20
 #include <unistd.h>
20
 #include <string.h>
21
 #include <string.h>
21
 #include <curses.h>
22
 #include <curses.h>
39
 #define CPAIR_ALERT	4
40
 #define CPAIR_ALERT	4
40
 
41
 
41
 /* Screen layout */
42
 /* Screen layout */
43
+#define BANNER_ROW		1
42
 #define SETTINGS_LIST_ROW	3
44
 #define SETTINGS_LIST_ROW	3
43
 #define SETTINGS_LIST_COL	1
45
 #define SETTINGS_LIST_COL	1
46
+#define INFO_ROW		20
44
 #define ALERT_ROW		20
47
 #define ALERT_ROW		20
45
 
48
 
46
 /** Layout of text within a setting widget */
49
 /** Layout of text within a setting widget */
203
 		       ( SETTINGS_LIST_ROW + index ), SETTINGS_LIST_COL );
206
 		       ( SETTINGS_LIST_ROW + index ), SETTINGS_LIST_COL );
204
 }
207
 }
205
 
208
 
206
-static void alert ( const char *fmt, ... ) {
209
+/**
210
+ * Print message centred on specified row
211
+ *
212
+ * @v row		Row
213
+ * @v fmt		printf() format string
214
+ * @v args		printf() argument list
215
+ */
216
+static void vmsg ( unsigned int row, const char *fmt, va_list args ) {
207
 	char buf[COLS];
217
 	char buf[COLS];
208
-	va_list args;
209
 	size_t len;
218
 	size_t len;
210
 
219
 
211
-	va_start ( args, fmt );
212
 	len = vsnprintf ( buf, sizeof ( buf ), fmt, args );
220
 	len = vsnprintf ( buf, sizeof ( buf ), fmt, args );
221
+	mvprintw ( row, ( ( COLS - len ) / 2 ), "%s", buf );
222
+}
223
+
224
+/**
225
+ * Print message centred on specified row
226
+ *
227
+ * @v row		Row
228
+ * @v fmt		printf() format string
229
+ * @v ..		printf() arguments
230
+ */
231
+static void msg ( unsigned int row, const char *fmt, ... ) {
232
+	va_list args;
233
+
234
+	va_start ( args, fmt );
235
+	vmsg ( row, fmt, args );
213
 	va_end ( args );
236
 	va_end ( args );
237
+}
238
+
239
+/**
240
+ * Clear message on specified row
241
+ *
242
+ * @v row		Row
243
+ */
244
+static void clearmsg ( unsigned int row ) {
245
+	move ( row, 0 );
246
+	clrtoeol();
247
+}
214
 
248
 
249
+/**
250
+ * Print alert message
251
+ *
252
+ * @v fmt		printf() format string
253
+ * @v args		printf() argument list
254
+ */
255
+static void valert ( const char *fmt, va_list args ) {
215
 	color_set ( CPAIR_ALERT, NULL );
256
 	color_set ( CPAIR_ALERT, NULL );
216
-	mvprintw ( ALERT_ROW, ( ( COLS - len ) / 2 ), "%s", buf );
257
+	vmsg ( ALERT_ROW, fmt, args );
217
 	sleep ( 2 );
258
 	sleep ( 2 );
218
 	color_set ( CPAIR_NORMAL, NULL );
259
 	color_set ( CPAIR_NORMAL, NULL );
219
-	move ( ALERT_ROW, 0 );
220
-	clrtoeol();
260
+	clearmsg ( ALERT_ROW );
261
+}
262
+
263
+/**
264
+ * Print alert message
265
+ *
266
+ * @v fmt		printf() format string
267
+ * @v ...		printf() arguments
268
+ */
269
+static void alert ( const char *fmt, ... ) {
270
+	va_list args;
271
+
272
+	va_start ( args, fmt );
273
+	valert ( fmt, args );
274
+	va_end ( args );
221
 }
275
 }
222
 
276
 
223
 static void main_loop ( struct config_context *context ) {
277
 static void main_loop ( struct config_context *context ) {
230
 
284
 
231
 	/* Print initial screen content */
285
 	/* Print initial screen content */
232
 	color_set ( CPAIR_NORMAL, NULL );
286
 	color_set ( CPAIR_NORMAL, NULL );
287
+	attron ( A_BOLD );
288
+	msg ( BANNER_ROW, "gPXE option configuration console" );
289
+	attroff ( A_BOLD );
233
 	for ( i = ( NUM_SETTINGS - 1 ) ; i >= 0 ; i-- ) {
290
 	for ( i = ( NUM_SETTINGS - 1 ) ; i >= 0 ; i-- ) {
234
 		init_setting_index ( &widget, context, i );
291
 		init_setting_index ( &widget, context, i );
235
 		draw_setting ( &widget );
292
 		draw_setting ( &widget );
236
 	}
293
 	}
237
 
294
 
238
 	while ( 1 ) {
295
 	while ( 1 ) {
296
+		/* Redraw information row */
297
+		clearmsg ( INFO_ROW );
298
+		msg ( INFO_ROW, "%s (%s) - %s", widget.setting->name,
299
+		      widget.setting->type->description,
300
+		      widget.setting->description );
301
+
239
 		/* Redraw current setting */
302
 		/* Redraw current setting */
240
 		color_set ( ( widget.editing ? CPAIR_EDIT : CPAIR_SELECT ),
303
 		color_set ( ( widget.editing ? CPAIR_EDIT : CPAIR_SELECT ),
241
 			    NULL );
304
 			    NULL );
293
 	initscr();
356
 	initscr();
294
 	start_color();
357
 	start_color();
295
 	init_pair ( CPAIR_NORMAL, COLOR_WHITE, COLOR_BLUE );
358
 	init_pair ( CPAIR_NORMAL, COLOR_WHITE, COLOR_BLUE );
296
-	init_pair ( CPAIR_SELECT, COLOR_BLACK, COLOR_WHITE );
359
+	init_pair ( CPAIR_SELECT, COLOR_WHITE, COLOR_RED );
297
 	init_pair ( CPAIR_EDIT, COLOR_BLACK, COLOR_CYAN );
360
 	init_pair ( CPAIR_EDIT, COLOR_BLACK, COLOR_CYAN );
298
 	init_pair ( CPAIR_ALERT, COLOR_WHITE, COLOR_RED );
361
 	init_pair ( CPAIR_ALERT, COLOR_WHITE, COLOR_RED );
299
 	color_set ( CPAIR_NORMAL, NULL );
362
 	color_set ( CPAIR_NORMAL, NULL );

+ 4
- 0
src/include/gpxe/settings.h View File

40
 	 * This is the name exposed to the user (e.g. "string").
40
 	 * This is the name exposed to the user (e.g. "string").
41
 	 */
41
 	 */
42
 	const char *name;
42
 	const char *name;
43
+	/** Description */
44
+	const char *description;
43
 	/** Show value of setting
45
 	/** Show value of setting
44
 	 *
46
 	 *
45
 	 * @v context		Configuration context
47
 	 * @v context		Configuration context
79
 	 * dhcp-options(5)).
81
 	 * dhcp-options(5)).
80
 	 */
82
 	 */
81
 	const char *name;
83
 	const char *name;
84
+	/** Description */
85
+	const char *description;
82
 	/** DHCP option tag
86
 	/** DHCP option tag
83
 	 *
87
 	 *
84
 	 * This is the DHCP tag used to identify the option in DHCP
88
 	 * This is the DHCP tag used to identify the option in DHCP

Loading…
Cancel
Save