3 parsecmd, cmderror, lookupcmd
4 \- parse device commands
8 Cmdbuf* parsecmd(char *a, int n)
11 void cmderror(Cmdbuf *cb, char *s)
14 Cmdtab* lookupcmd(Cmdbuf *cb, Cmdtab *ctab, int nctab)
21 that safely parses a command, with blank-separated fields, as might be
29 can be those passed to the driver's
33 converts the byte array (which might not be null-terminated) to a null-terminated string,
34 trimming any trailing new line,
37 to break the string into arguments, interpreting blank and tab as field separators
38 when they are not quoted
41 It returns a pointer to a dynamically-allocated
44 which holds a copy of the string and the resulting fields; it is
60 holds the field pointers;
62 gives the number of fields.
68 and the caller is responsible for freeing it using
71 prepends the given format with the original command,
75 Command strings may be turned into a (typically enumerated)
80 matches any text. Unrecognized commands, or commands
81 given an unacceptable number of arguments generate a
84 The definition is as follows
91 int index; /* used by client to switch on result */
92 char *cmd; /* command name */
93 int narg; /* expected #args; 0 ==> variadic */
99 is the number returned on command match.
102 is the command name, and
104 is 0 (indicating a variadic function) or the
107 .B /sys/src/9/port/parse.c