When I converted befs's option parsing to use the new lib/parser.cfunctions, I had to read the functions (and the patch converting ext3)in order to understand exactly how to use them. They are not thatcomplicated, but since I'd already read and (hopefully) understood thefunctions, I figured I'd add a bit of documentation for others.

I am not the author of the functions I am attempting to document here,so any mistakes are just that: mistakes on my part.

+/**+ * match_token: - Find a token (and optional args) in a string+ * @s: the string to examine for token/argument pairs+ * @table: match_table_t describing the set of allowed option tokensand the+ * arguments that may be associated with them. Must be terminated witha+ * &struct match_token who's pattern is set to the NULL pointer.+ * @args: array of %MAX_OPT_ARGS &substring_t elements. Used to returnmatch+ * locations.+ *+ * Description: Detects which if any of a set of token strings has beenpassed+ * to it. Tokens can include up to MAX_OPT_ARGS instances of basicc-style+ * format identifiers which will be taken into account when matchingthe+ * tokens, and who's locations will be returned in the @args array.+ */ int match_token(char *s, match_table_t table, substring_t args[]) { struct match_token *p;@@ -84,6 +109,16 @@ return p->token; }

+/**+ * match_number: scan a number in the given base from a substring_t+ * @s: substring to be scanned+ * @result: resulting integer on success+ * @base: base to use when converting string+ *+ * Description: Given a &substring_t and a base, attempts to parse thesubstring+ * as a number in that base. On success, sets @result to the integerrepresented+ * by the string and returns 0. Returns either -ENOMEM or -EINVAL onfailure.+ */ static int match_number(substring_t *s, int *result, int base) { char *endp;@@ -103,27 +138,71 @@ return ret; }