瀏覽代碼

[parseopt] Move parse_settings() to parseopt.c

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 年之前
父節點
當前提交
46433f9b5e
共有 3 個檔案被更改,包括 25 行新增23 行删除
  1. 23
    0
      src/core/parseopt.c
  2. 0
    22
      src/hci/commands/config_cmd.c
  3. 2
    1
      src/include/ipxe/parseopt.h

+ 23
- 0
src/core/parseopt.c 查看文件

@@ -28,6 +28,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
28 28
 #include <getopt.h>
29 29
 #include <ipxe/netdevice.h>
30 30
 #include <ipxe/menu.h>
31
+#include <ipxe/settings.h>
31 32
 #include <ipxe/parseopt.h>
32 33
 
33 34
 /** @file
@@ -172,6 +173,28 @@ int parse_key ( char *text, unsigned int *key ) {
172 173
 	return parse_integer ( text, key );
173 174
 }
174 175
 
176
+/**
177
+ * Parse settings block name
178
+ *
179
+ * @v text		Text
180
+ * @ret value		Integer value
181
+ * @ret rc		Return status code
182
+ */
183
+int parse_settings ( char *text, struct settings **value ) {
184
+
185
+	/* Sanity check */
186
+	assert ( text != NULL );
187
+
188
+	/* Parse scope name */
189
+	*value = find_settings ( text );
190
+	if ( ! *value ) {
191
+		printf ( "\"%s\": no such scope\n", text );
192
+		return -EINVAL;
193
+	}
194
+
195
+	return 0;
196
+}
197
+
175 198
 /**
176 199
  * Print command usage message
177 200
  *

+ 0
- 22
src/hci/commands/config_cmd.c 查看文件

@@ -44,28 +44,6 @@ static struct option_descriptor config_opts[] = {};
44 44
 static struct command_descriptor config_cmd =
45 45
 	COMMAND_DESC ( struct config_options, config_opts, 0, 1, "[<scope>]" );
46 46
 
47
-/**
48
- * Parse settings scope name
49
- *
50
- * @v text		Text
51
- * @ret value		Integer value
52
- * @ret rc		Return status code
53
- */
54
-static int parse_settings ( const char *text, struct settings **value ) {
55
-
56
-	/* Sanity check */
57
-	assert ( text != NULL );
58
-
59
-	/* Parse scope name */
60
-	*value = find_settings ( text );
61
-	if ( ! *value ) {
62
-		printf ( "\"%s\": no such scope\n", text );
63
-		return -EINVAL;
64
-	}
65
-
66
-	return 0;
67
-}
68
-
69 47
 /**
70 48
  * "config" command
71 49
  *

+ 2
- 1
src/include/ipxe/parseopt.h 查看文件

@@ -14,6 +14,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
14 14
 
15 15
 struct net_device;
16 16
 struct menu;
17
+struct settings;
17 18
 
18 19
 /** A command-line option descriptor */
19 20
 struct option_descriptor {
@@ -120,7 +121,7 @@ extern int parse_netdev ( char *text, struct net_device **netdev );
120 121
 extern int parse_menu ( char *text, struct menu **menu );
121 122
 extern int parse_flag ( char *text __unused, int *flag );
122 123
 extern int parse_key ( char *text, unsigned int *key );
123
-extern void print_usage ( struct command_descriptor *cmd, char **argv );
124
+extern int parse_settings ( char *text, struct settings **settings );
124 125
 extern int reparse_options ( int argc, char **argv,
125 126
 			     struct command_descriptor *cmd, void *opts );
126 127
 extern int parse_options ( int argc, char **argv,

Loading…
取消
儲存