diff options
Diffstat (limited to 'man/man3/9p-cmdbuf.html')
-rw-r--r-- | man/man3/9p-cmdbuf.html | 128 |
1 files changed, 128 insertions, 0 deletions
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 @@ +<head> +<title>9p-cmdbuf(3) - Plan 9 from User Space</title> +<meta content="text/html; charset=utf-8" http-equiv=Content-Type> +</head> +<body bgcolor=#ffffff> +<table border=0 cellpadding=0 cellspacing=0 width=100%> +<tr height=10><td> +<tr><td width=20><td> +<tr><td width=20><td><b>9P-CMDBUF(3)</b><td align=right><b>9P-CMDBUF(3)</b> +<tr><td width=20><td colspan=2> + <br> +<p><font size=+1><b>NAME </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Cmdbuf, parsecmd, respondcmderror, lookupcmd – control message + parsing<br> + +</table> +<p><font size=+1><b>SYNOPSIS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>#include <u.h><br> + #include <libc.h><br> + #include <fcall.h><br> + #include <thread.h><br> + #include <9p.h><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + typedef struct Cmdbuf<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + char *buf;<br> + char **f;<br> + int nf;<br> + + </table> + } Cmdbuf;<br> + typedef struct Cmdtab<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int index;<br> + char *cmd;<br> + int narg;<br> + + </table> + };<br> + Cmdbuf *parsecmd(char *p, int n)<br> + Cmdtab *lookupcmd(Cmdbuf *cb, Cmdtab *tab, int ntab)<br> + void respondcmderror(Req *r, Cmdbuf *cb, char *fmt, ...)<br> + </font></tt> +</table> +<p><font size=+1><b>DESCRIPTION </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + These data structures and functions provide parsing of textual + control messages. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Parsecmd</i> treats the <i>n</i> bytes at <i>p</i> (which need not be NUL-terminated) + as a UTF string and splits it using <i>tokenize</i> (see <a href="../man3/getfields.html"><i>getfields</i>(3)</a>). + It returns a <tt><font size=+1>Cmdbuf</font></tt> structure holding pointers to each field in + the message. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Lookupcmd</i> walks through the array <i>ctab</i>, which has <i>ntab</i> entries, + looking for the first <tt><font size=+1>Cmdtab</font></tt> that matches the parsed command. + (If the parsed command is empty, <i>lookupcmd</i> returns nil immediately.) + A <tt><font size=+1>Cmdtab</font></tt> matches the command if <i>cmd</i> is equal to <i>cb</i><tt><font size=+1>−></font></tt><i>f</i><tt><font size=+1>[0]</font></tt> or if + <i>cmd</i> is <tt><font size=+1>*</font></tt>. Once a matching <tt><font size=+1>Cmdtab</font></tt> has been + found, if <i>narg</i> is not zero, then the parsed command must have + exactly <i>narg</i> fields (including the command string itself). If + the command has the wrong number of arguments, <i>lookupcmd</i> returns + nil. Otherwise, it returns a pointer to the <tt><font size=+1>Cmdtab</font></tt> entry. If <i>lookupcmd</i> + does not find a matching command at all, it returns + nil. Whenever <i>lookupcmd</i> returns nil, it sets the system error + string. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Respondcmderror</i> resoponds to request <i>r</i> with an error of the form + ‘<i>fmt</i>: <i>cmd</i>,’ where <i>fmt</i> is the formatted string and <i>cmd</i> is a reconstruction + of the parsed command. Fmt is often simply <tt><font size=+1>%r .<br> + </font></tt> +</table> +<p><font size=+1><b>EXAMPLES </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + This interface is not used in any distributed 9P servers. It was + lifted from the Plan 9 kernel. Almost any Plan 9 kernel driver + (<tt><font size=+1>/sys/src/9/*/dev*.c</font></tt> on Plan 9) is a good example.<br> + +</table> +<p><font size=+1><b>SOURCE </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>/usr/local/plan9/src/lib9p/parse.c<br> + </font></tt> +</table> +<p><font size=+1><b>SEE ALSO </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <a href="../man3/9p.html"><i>9p</i>(3)</a><br> + +</table> + +<td width=20> +<tr height=20><td> +</table> +<!-- TRAILER --> +<table border=0 cellpadding=0 cellspacing=0 width=100%> +<tr height=15><td width=10><td><td width=10> +<tr><td><td> +<center> +<a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a> +</center> +</table> +<!-- TRAILER --> +</body></html> |