Quellcode durchsuchen

[parseopt] Add parse_netdev_configurator()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown vor 11 Jahren
Ursprung
Commit
3a67224c62
2 geänderte Dateien mit 27 neuen und 0 gelöschten Zeilen
  1. 23
    0
      src/core/parseopt.c
  2. 4
    0
      src/include/ipxe/parseopt.h

+ 23
- 0
src/core/parseopt.c Datei anzeigen

@@ -139,6 +139,29 @@ int parse_netdev ( char *text, struct net_device **netdev ) {
139 139
 	return 0;
140 140
 }
141 141
 
142
+/**
143
+ * Parse network device configurator name
144
+ *
145
+ * @v text		Text
146
+ * @ret configurator	Network device configurator
147
+ * @ret rc		Return status code
148
+ */
149
+int parse_netdev_configurator ( char *text,
150
+				struct net_device_configurator **configurator ){
151
+
152
+	/* Sanity check */
153
+	assert ( text != NULL );
154
+
155
+	/* Find network device configurator */
156
+	*configurator = find_netdev_configurator ( text );
157
+	if ( ! *configurator ) {
158
+		printf ( "\"%s\": no such configurator\n", text );
159
+		return -ENOTSUP;
160
+	}
161
+
162
+	return 0;
163
+}
164
+
142 165
 /**
143 166
  * Parse menu name
144 167
  *

+ 4
- 0
src/include/ipxe/parseopt.h Datei anzeigen

@@ -14,6 +14,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
14 14
 #include <ipxe/settings.h>
15 15
 
16 16
 struct net_device;
17
+struct net_device_configurator;
17 18
 struct menu;
18 19
 struct parameters;
19 20
 
@@ -128,6 +129,9 @@ extern int parse_string ( char *text, char **value );
128 129
 extern int parse_integer ( char *text, unsigned int *value );
129 130
 extern int parse_timeout ( char *text, unsigned long *value );
130 131
 extern int parse_netdev ( char *text, struct net_device **netdev );
132
+extern int
133
+parse_netdev_configurator ( char *text,
134
+			    struct net_device_configurator **configurator );
131 135
 extern int parse_menu ( char *text, struct menu **menu );
132 136
 extern int parse_flag ( char *text __unused, int *flag );
133 137
 extern int parse_key ( char *text, unsigned int *key );

Laden…
Abbrechen
Speichern