From 78e51a8c6678b6e3dff3d619aa786669f531f4bc Mon Sep 17 00:00:00 2001 From: rsc Date: Fri, 14 Jan 2005 03:45:44 +0000 Subject: checkpoint --- man/man3/9p-cmdbuf.html | 128 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 man/man3/9p-cmdbuf.html (limited to 'man/man3/9p-cmdbuf.html') diff --git a/man/man3/9p-cmdbuf.html b/man/man3/9p-cmdbuf.html new file mode 100644 index 00000000..122a5857 --- /dev/null +++ b/man/man3/9p-cmdbuf.html @@ -0,0 +1,128 @@ + +9p-cmdbuf(3) - Plan 9 from User Space + + + + +
+
+
9P-CMDBUF(3)9P-CMDBUF(3) +
+
+

NAME
+ +
+ + Cmdbuf, parsecmd, respondcmderror, lookupcmd – control message + parsing
+ +
+

SYNOPSIS
+ +
+ + #include <u.h>
+ #include <libc.h>
+ #include <fcall.h>
+ #include <thread.h>
+ #include <9p.h>
+ +
+ + typedef struct Cmdbuf
+ {
+ +
+ + char      *buf;
+ char      **f;
+ int       nf;
+ +
+ } Cmdbuf;
+ typedef struct Cmdtab
+ {
+ +
+ + int       index;
+ char      *cmd;
+ int       narg;
+ +
+ };
+ Cmdbuf        *parsecmd(char *p, int n)
+ Cmdtab        *lookupcmd(Cmdbuf *cb, Cmdtab *tab, int ntab)
+ void          respondcmderror(Req *r, Cmdbuf *cb, char *fmt, ...)
+
+
+

DESCRIPTION
+ +
+ + These data structures and functions provide parsing of textual + control messages. +
+ + Parsecmd treats the n bytes at p (which need not be NUL-terminated) + as a UTF string and splits it using tokenize (see getfields(3)). + It returns a Cmdbuf structure holding pointers to each field in + the message. +
+ + Lookupcmd walks through the array ctab, which has ntab entries, + looking for the first Cmdtab that matches the parsed command. + (If the parsed command is empty, lookupcmd returns nil immediately.) + A Cmdtab matches the command if cmd is equal to cb−>f[0] or if + cmd is *. Once a matching Cmdtab has been + found, if narg is not zero, then the parsed command must have + exactly narg fields (including the command string itself). If + the command has the wrong number of arguments, lookupcmd returns + nil. Otherwise, it returns a pointer to the Cmdtab entry. If lookupcmd + does not find a matching command at all, it returns + nil. Whenever lookupcmd returns nil, it sets the system error + string. +
+ + Respondcmderror resoponds to request r with an error of the form + ‘fmt: cmd,’ where fmt is the formatted string and cmd is a reconstruction + of the parsed command. Fmt is often simply %r .
+
+
+

EXAMPLES
+ +
+ + This interface is not used in any distributed 9P servers. It was + lifted from the Plan 9 kernel. Almost any Plan 9 kernel driver + (/sys/src/9/*/dev*.c on Plan 9) is a good example.
+ +
+

SOURCE
+ +
+ + /usr/local/plan9/src/lib9p/parse.c
+
+
+

SEE ALSO
+ +
+ + 9p(3)
+ +
+ +

+
+
+ + +
+
+
+Space Glenda +
+
+ + -- cgit v1.2.3