Sfoglia il codice sorgente

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

the option config UI.
tags/v0.9.3
Michael Brown 18 anni fa
parent
commit
b93ff48173
3 ha cambiato i file con 86 aggiunte e 9 eliminazioni
  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 Vedi File

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

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

@@ -16,6 +16,7 @@
16 16
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 17
  */
18 18
 
19
+#include <stdarg.h>
19 20
 #include <unistd.h>
20 21
 #include <string.h>
21 22
 #include <curses.h>
@@ -39,8 +40,10 @@ extern struct nvo_block *ugly_nvo_hack;
39 40
 #define CPAIR_ALERT	4
40 41
 
41 42
 /* Screen layout */
43
+#define BANNER_ROW		1
42 44
 #define SETTINGS_LIST_ROW	3
43 45
 #define SETTINGS_LIST_COL	1
46
+#define INFO_ROW		20
44 47
 #define ALERT_ROW		20
45 48
 
46 49
 /** Layout of text within a setting widget */
@@ -203,21 +206,72 @@ static void init_setting_index ( struct setting_widget *widget,
203 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 217
 	char buf[COLS];
208
-	va_list args;
209 218
 	size_t len;
210 219
 
211
-	va_start ( args, fmt );
212 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 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 256
 	color_set ( CPAIR_ALERT, NULL );
216
-	mvprintw ( ALERT_ROW, ( ( COLS - len ) / 2 ), "%s", buf );
257
+	vmsg ( ALERT_ROW, fmt, args );
217 258
 	sleep ( 2 );
218 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 277
 static void main_loop ( struct config_context *context ) {
@@ -230,12 +284,21 @@ static void main_loop ( struct config_context *context ) {
230 284
 
231 285
 	/* Print initial screen content */
232 286
 	color_set ( CPAIR_NORMAL, NULL );
287
+	attron ( A_BOLD );
288
+	msg ( BANNER_ROW, "gPXE option configuration console" );
289
+	attroff ( A_BOLD );
233 290
 	for ( i = ( NUM_SETTINGS - 1 ) ; i >= 0 ; i-- ) {
234 291
 		init_setting_index ( &widget, context, i );
235 292
 		draw_setting ( &widget );
236 293
 	}
237 294
 
238 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 302
 		/* Redraw current setting */
240 303
 		color_set ( ( widget.editing ? CPAIR_EDIT : CPAIR_SELECT ),
241 304
 			    NULL );
@@ -293,7 +356,7 @@ void uitest ( void ) {
293 356
 	initscr();
294 357
 	start_color();
295 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 360
 	init_pair ( CPAIR_EDIT, COLOR_BLACK, COLOR_CYAN );
298 361
 	init_pair ( CPAIR_ALERT, COLOR_WHITE, COLOR_RED );
299 362
 	color_set ( CPAIR_NORMAL, NULL );

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

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

Loading…
Annulla
Salva