浏览代码

[parseopt] Add support for boolean options

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 年前
父节点
当前提交
a246434299
共有 2 个文件被更改,包括 16 次插入0 次删除
  1. 15
    0
      src/core/parseopt.c
  2. 1
    0
      src/include/ipxe/parseopt.h

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

@@ -125,6 +125,21 @@ int parse_image ( const char *text, struct image **image ) {
125 125
 	return 0;
126 126
 }
127 127
 
128
+/**
129
+ * Parse flag
130
+ *
131
+ * @v text		Text (ignored)
132
+ * @ret flag		Flag to set
133
+ * @ret rc		Return status code
134
+ */
135
+int parse_flag ( const char *text __unused, int *flag ) {
136
+
137
+	/* Set flag */
138
+	*flag = 1;
139
+
140
+	return 0;
141
+}
142
+
128 143
 /**
129 144
  * Print command usage message
130 145
  *

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

@@ -118,6 +118,7 @@ extern int parse_string ( const char *text, const char **value );
118 118
 extern int parse_integer ( const char *text, unsigned int *value );
119 119
 extern int parse_netdev ( const char *text, struct net_device **netdev );
120 120
 extern int parse_image ( const char *text, struct image **image );
121
+extern int parse_flag ( const char *text __unused, int *flag );
121 122
 extern void print_usage ( struct command_descriptor *cmd, char **argv );
122 123
 extern int parse_options ( int argc, char **argv,
123 124
 			   struct command_descriptor *cmd, void *opts );

正在加载...
取消
保存