diff options
author | rsc <devnull@localhost> | 2005-01-14 03:45:44 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2005-01-14 03:45:44 +0000 |
commit | 78e51a8c6678b6e3dff3d619aa786669f531f4bc (patch) | |
tree | 015e00fde4fc837fd31b705e18d17dc913829388 /man/man3 | |
parent | 2634795b5f0053bc0ff08e5d7bbc0eda8efea061 (diff) | |
download | plan9port-78e51a8c6678b6e3dff3d619aa786669f531f4bc.tar.gz plan9port-78e51a8c6678b6e3dff3d619aa786669f531f4bc.tar.bz2 plan9port-78e51a8c6678b6e3dff3d619aa786669f531f4bc.zip |
checkpoint
Diffstat (limited to 'man/man3')
113 files changed, 22752 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> diff --git a/man/man3/9p-fid.html b/man/man3/9p-fid.html new file mode 100644 index 00000000..44bca53c --- /dev/null +++ b/man/man3/9p-fid.html @@ -0,0 +1,170 @@ +<head> +<title>9p-fid(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-FID(3)</b><td align=right><b>9P-FID(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> + + Fid, Fidpool, allocfidpool, freefidpool, allocfid, closefid, lookupfid, + removefid, Req, Reqpool, allocreqpool, freereqpool, allocreq, + closereq, lookupreq, removereq – 9P fid, request tracking<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 Fid<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + ulong fid;<br> + char omode; /* −1 if not open */<br> + char *uid;<br> + Qid qid;<br> + File *file;<br> + void *aux;<br> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>...<br> + </i> + </table> + <tt><font size=+1>} Fid;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + typedef struct Req<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + ulong tag;<br> + Fcall ifcall;<br> + Fcall ofcall;<br> + Req *oldreq;<br> + void *aux;<br> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>...<br> + </i> + </table> + <tt><font size=+1>} Req;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Fidpool* allocfidpool(void (*destroy)(Fid*))<br> + void freefidpool(Fidpool *p)<br> + Fid* allocfid(Fidpool *p, ulong fid)<br> + Fid* lookupfid(Fidpool *p, ulong fid)<br> + void closefid(Fid *f)<br> + void removefid(Fid *f)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Reqpool* allocreqpool(void (*destroy)(Req*))<br> + void freereqpool(Reqpool *p)<br> + Req* allocreq(Reqpool *p, ulong tag)<br> + Req* lookupreq(Reqpool *p, ulong tag)<br> + void closereq(Req *f)<br> + void removereq(Req *r)<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 routines provide management of <tt><font size=+1>Fid</font></tt> and <tt><font size=+1>Req</font></tt> structures from + <tt><font size=+1>Fidpool</font></tt>s and <tt><font size=+1>Reqpool</font></tt>s. They are primarily used by the 9P server + loop described in <a href="../man3/9p.html"><i>9p</i>(3)</a>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>Fid</font></tt> structures are intended to represent active fids in a 9P connection, + as <tt><font size=+1>Chan</font></tt> structures do in the Plan 9 kernel. The <tt><font size=+1>fid</font></tt> element is + the integer fid used in the 9P connection. <tt><font size=+1>Omode</font></tt> is the mode under + which the fid was opened, or <tt><font size=+1>−1</font></tt> if this fid has not been opened + yet. Note that in addition to the values <tt><font size=+1>OREAD</font></tt>, + <tt><font size=+1>OWRITE</font></tt>, and <tt><font size=+1>ORDWR</font></tt>, <tt><font size=+1>omode</font></tt> can contain the various flags permissible + in an open call. To ignore the flags, use <tt><font size=+1>omode&OMASK</font></tt>. <tt><font size=+1>Omode</font></tt> should + not be changed by the client. The fid derives from a successful + authentication by <tt><font size=+1>uid</font></tt>. <tt><font size=+1>Qid</font></tt> contains the qid returned in the last + successful <tt><font size=+1>walk</font></tt> or <tt><font size=+1>create</font></tt> transaction + involving the fid. In a file tree-based server, the <tt><font size=+1>Fid</font></tt>’s <tt><font size=+1>file</font></tt> + element points at a <tt><font size=+1>File</font></tt> structure (see <a href="../man3/9p-file.html"><i>9p-file</i>(3)</a>) corresponding + to the fid. The <tt><font size=+1>aux</font></tt> member is intended for use by the client to + hold information specific to a particular <tt><font size=+1>Fid</font></tt>. With the exception + of <tt><font size=+1>aux</font></tt>, these elements should be treated as read-only by + the client. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Allocfidpool</i> creates a new <tt><font size=+1>Fidpool</font></tt>. <i>Freefidpool</i> destroys such + a pool. <i>Allocfid</i> returns a new <tt><font size=+1>Fid</font></tt> whose fid number is <i>fid</i>. There + must not already be an extant <tt><font size=+1>Fid</font></tt> with that number in the pool. + Once a <tt><font size=+1>Fid</font></tt> has been allocated, it can be looked up by fid number + using <i>lookupfid</i>. <tt><font size=+1>Fid</font></tt>s are reference counted: both + <i>allocfid</i> and <i>lookupfid</i> increment the reference count on the <tt><font size=+1>Fid</font></tt> + structure before returning. When a reference to a <tt><font size=+1>Fid</font></tt> is no longer + needed, <i>closefid</i> should be called to note the destruction of the + reference. When the last reference to a <tt><font size=+1>Fid</font></tt> is removed, if <i>destroy</i> + (supplied when creating the fid pool) is not zero, it is + called with the <tt><font size=+1>Fid</font></tt> as a parameter. It should perform whatever + cleanup is necessary regarding the <tt><font size=+1>aux</font></tt> element. <i>Removefid</i> is equivalent + to <i>closefid</i> but also removes the <tt><font size=+1>Fid</font></tt> from the pool. Note that + due to lingering references, the return of <i>removefid</i> may not mean + that <i>destroy</i> has been called. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Allocreqpool</i>, <i>freereqpool</i>, <i>allocreq</i>, <i>lookupreq</i>, <i>closereq</i>, and + <i>removereq</i> are analogous but operate on <tt><font size=+1>Reqpool</font></tt>s and <tt><font size=+1>Req</font></tt> structures.<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<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>, <a href="../man3/9p-file.html"><i>9p-file</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> diff --git a/man/man3/9p-file.html b/man/man3/9p-file.html new file mode 100644 index 00000000..63ae5042 --- /dev/null +++ b/man/man3/9p-file.html @@ -0,0 +1,258 @@ +<head> +<title>9p-file(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-FILE(3)</b><td align=right><b>9P-FILE(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> + + Tree, alloctree, freetree, File, createfile, closefile, removefile, + walkfile, opendirfile, readdirfile, closedirfile, hasperm – in-memory + file hierarchy<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 File<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Ref;<br> + Dir;<br> + void*aux;<br> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>...<br> + </i> + </table> + + </table> + <tt><font size=+1>} File;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + typedef struct Tree<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + File *root;<br> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>...<br> + </i> + </table> + + </table> + <tt><font size=+1>} Tree;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Tree* alloctree(char *uid, char *gid, ulong mode,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + void (*destroy)(File*))<br> + + </table> + + </table> + void freetree(Tree *tree)<br> + File* createfile(File *dir, char *name, char *uid,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + ulong mode, void *aux)<br> + + </table> + + </table> + int removefile(File *file)<br> + void closefile(File *file)<br> + File* walkfile(File *dir, char *path)<br> + Readdir* opendirfile(File *dir)<br> + long readdirfile(Readdir *rdir, char *buf, long n)<br> + void closedirfile(Readdir *rdir)<br> + int hasperm(File *file, char *uid, int p)<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> + + <tt><font size=+1>File</font></tt>s and <tt><font size=+1>Tree</font></tt>s provide an in-memory file hierarchy intended for + use in 9P file servers. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Alloctree</i> creates a new tree of files, and <i>freetree</i> destroys it. + The root of the tree (also the <tt><font size=+1>root</font></tt> element in the structure) + will have mode <i>mode</i> and be owned by user <i>uid</i> and group <i>gid</i>. <i>Destroy</i> + is used when freeing <tt><font size=+1>File</font></tt> structures and is described later. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>File</font></tt>s (including directories) other than the root are created + using <i>createfile</i>, which attempts to create a file named <i>name</i> in + the directory <i>dir</i>. If created, the file will have owner <i>uid</i> and + have a group inherited from the directory. <i>Mode</i> and the permissions + of <i>dir</i> are used to calculate the permission bits for the file + as + described in <i>open</i>(9p). It is permissible for <i>name</i> to be a slash-separated + path rather than a single element. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Removefile</i> removes a file from the file tree. The file will not + be freed until the last reference to it has been removed. Directories + may only be removed when empty. <i>Removefile</i> returns zero on success, + –1 on error. It is correct to consider <i>removefile</i> to be <i>closefile</i> + with the side effect of removing the file when possible. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Walkfile</i> evaluates <i>path</i> relative to the directory <i>dir</i>, returning + the resulting file, or zero if the named file or any intermediate + element does not exist. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The <tt><font size=+1>File</font></tt> structure’s <tt><font size=+1>aux</font></tt> pointer may be used by the client for + per-<tt><font size=+1>File</font></tt> storage. <tt><font size=+1>File</font></tt>s are reference-counted: if not zero, <i>destroy</i> + (specified in the call to <i>alloctree</i>) will be called for each file + when its last reference is removed or when the tree is freed. + <i>Destroy</i> should take care of any necessary cleanup related to + <tt><font size=+1>aux</font></tt>. When creating new file references by copying pointers, call + <i>incref</i> (see <a href="../man3/lock.html"><i>lock</i>(3)</a>) to update the reference count. To note the + removal of a reference to a file, call <i>closefile</i>. <i>Createfile</i> and + <i>walkfile</i> return new references. <i>Removefile</i>, <i>closefile</i>, and <i>walkfile</i> + (but not <i>createfile</i>) consume the passed reference. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Directories may be read, yielding a directory entry structure + (see <i>stat</i>(9p)) for each file in the directory. In order to allow + concurrent reading of directories, clients must obtain a <tt><font size=+1>Readdir</font></tt> + structure by calling <i>opendirfile</i> on a directory. Subsequent calls + to <i>readdirfile</i> will each yield an integral number of machine- + independent stat buffers, until end of directory. When finished, + call <i>closedirfile</i> to free the <tt><font size=+1>Readdir</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Hasperm</i> does simplistic permission checking; it assumes only one-user + groups named by uid and returns non-zero if <i>uid</i> has permission + <i>p</i> (a bitwise-or of <tt><font size=+1>AREAD</font></tt>, <tt><font size=+1>AWRITE</font></tt> and <tt><font size=+1>AEXEC</font></tt>) according to <i>file</i><tt><font size=+1>−>mode</font></tt>. + 9P servers written using <tt><font size=+1>File</font></tt> trees will do standard permission + checks automatically; <i>hasperm</i> may be + called explicitly to do additional checks. A 9P server may link + against a different <i>hasperm</i> implementation to provide more complex + groups.<br> + +</table> +<p><font size=+1><b>EXAMPLE </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The following code correctly handles references when elementwise + walking a path and creating a file.<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>f = tree−>root;<br> + incref(f);<br> + for(i=0; i<n && f!=nil; i++)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + f = walkfile(f, elem[i]);<br> + + </table> + if(f == nil)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + return nil;<br> + + </table> + nf = createfile(f, "foo", "nls", 0666, nil);<br> + closefile(f);<br> + return nf;<br> + </font></tt> + </table> + +</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/file.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> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The reference counting is cumbersome.<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> diff --git a/man/man3/9p-intmap.html b/man/man3/9p-intmap.html new file mode 100644 index 00000000..f6d1822f --- /dev/null +++ b/man/man3/9p-intmap.html @@ -0,0 +1,110 @@ +<head> +<title>9p-intmap(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-INTMAP(3)</b><td align=right><b>9P-INTMAP(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> + + Intmap, allocmap, freemap, insertkey, caninsertkey, lookupkey, + deletekey – integer to data structure maps<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> + + Intmap* allocmap(void (*inc)(void*))<br> + void freemap(Intmap *map, void (*dec)(void*))<br> + void* lookupkey(Intmap *map, ulong key)<br> + void* insertkey(Intmap *map, ulong key, void *val)<br> + int caninsertkey(Intmap *map, ulong key, void *val)<br> + void* lookupkey(Intmap *map, ulong key)<br> + void* deletekey(Intmap *map, ulong key)<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> + + An <tt><font size=+1>Intmap</font></tt> is an arbitrary mapping from integers to pointers. <i>Allocmap</i> + creates a new map, and <i>freemap</i> destroys it. The <i>inc</i> function is + called each time a new pointer is added to the map; similarly, + <i>dec</i> is called on each pointer left in the map when it is being + freed. Typically these functions maintain reference counts. + New entries are added to the map by calling <i>insertkey</i>, which will + return the previous value associated with the given <i>key</i>, or zero + if there was no previous value. <i>Caninsertkey</i> is like <i>insertkey</i> + but only inserts <i>val</i> if there is no current mapping. It returns + 1 if <i>val</i> was inserted, 0 otherwise. <i>Lookupkey</i> returns the pointer + associated with <i>key</i>, or zero if there is no such pointer. <i>Deletekey</i> + removes the entry for <i>id</i> from the map, returning the associated + pointer, if any. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Concurrent access to <tt><font size=+1>Intmap</font></tt>s is safe, moderated via a <tt><font size=+1>QLock</font></tt> stored + in the <tt><font size=+1>Intmap</font></tt> structure. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + In anticipation of the storage of reference-counted structures, + an increment function <i>inc</i> may be specified at map creation time. + <i>Lookupkey</i> calls <i>inc</i> (if non-zero) on pointers before returning + them. If the reference count adjustments were left to the caller + (and thus not protected by the lock), it would be possible to + accidentally reclaim a structure if, for example, it was deleted + from the map and its reference count decremented between the return + of <i>insertkey</i> and the external increment. <i>Insertkey</i> and <i>caninsertkey</i> + do <i>not</i> call <i>inc</i> when inserting <i>val</i> into the map, nor do <i>insertkey</i> + or <i>deletekey</i> call <i>inc</i> when returning old map entries. + The rationale is that calling an insertion function transfers + responsibility for the reference to the map, and responsibility + is given back via the return value of <i>deletekey</i> or the next <i>insertkey</i>. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>Intmap</font></tt>s are used by the 9P library to implement <tt><font size=+1>Fidpool</font></tt>s and <tt><font size=+1>Reqpool</font></tt>s.<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/intmap.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>, <a href="../man3/9p-fid.html"><i>9p-fid</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> diff --git a/man/man3/9p.html b/man/man3/9p.html new file mode 100644 index 00000000..9896b0b7 --- /dev/null +++ b/man/man3/9p.html @@ -0,0 +1,434 @@ +<head> +<title>9p(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(3)</b><td align=right><b>9P(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> + + Srv, dirread9p, emalloc9p, erealloc9p, estrdup9p, postfd, postmountsrv, + readbuf, readstr, respond, srv, threadpostmountsrv, walkandclone + – 9P file service<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 Srv {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Tree* tree;<br> + void (*attach)(Req *r);<br> + void (*auth)(Req *r);<br> + void (*open)(Req *r);<br> + void (*create)(Req *r);<br> + void (*read)(Req *r);<br> + void (*write)(Req *r);<br> + void (*remove)(Req *r);<br> + void (*flush)(Req *r);<br> + void (*stat)(Req *r);<br> + void (*wstat)(Req *r);<br> + void (*walk)(Req *r);<br> + char* (*walk1)(Fid *fid, char *name, Qid *qid);<br> + char* (*clone)(Fid *oldfid, Fid *newfid);<br> + void (*destroyfid)(Fid *fid);<br> + void (*destroyreq)(Req *r);<br> + void (*end)(Srv *s);<br> + void* aux;<br> + int infd;<br> + int outfd;<br> + int srvfd;<br> + int nopipe;<br> + + </table> + } Srv;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + int srv(Srv *s)<br> + void postmountsrv(Srv *s, char *name, char *mtpt, int flag)<br> + void threadpostmountsrv(Srv *s, char *name, char *mtpt, int flag)<br> + int postfd(char *srvname, int fd)<br> + void respond(Req *r, char *error)<br> + ulong readstr(Req *r, char *src)<br> + ulong readbuf(Req *r, void *src, ulong nsrc)<br> + typedef int Dirgen(int n, Dir *dir, void *aux)<br> + void dirread9p(Req *r, Dirgen *gen, void *aux)<br> + void walkandclone(Req *r, char *(*walk1)(Fid *old, char *name, + void *v),<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + char *(*clone)(Fid *old, Fid *new, void *v), void *v)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + void* emalloc9p(ulong n)<br> + void* erealloc9p(void *v, ulong n)<br> + char* estrdup9p(char *s)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + extern int chatty9p;<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> + + The function <i>srv</i> serves a 9P session by reading requests from + <tt><font size=+1>s−>infd</font></tt>, dispatching them to the function pointers kept in <tt><font size=+1>Srv</font></tt>, + and writing the responses to <tt><font size=+1>s−>outfd</font></tt>. (Typically, <i>postmountsrv</i> + or <i>threadpostmountsrv</i> initializes the <tt><font size=+1>infd</font></tt> and <tt><font size=+1>outfd</font></tt> structure + members. See the description below.) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>Req</font></tt> and <tt><font size=+1>Fid</font></tt> structures are allocated one-to-one with uncompleted + requests and active fids, and are described in <a href="../man3/9p-fid.html"><i>9p-fid</i>(3)</a>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The behavior of <i>srv</i> depends on whether there is a file tree (see + <a href="../man3/9p-file.html"><i>9p-file</i>(3)</a>) associated with the server, that is, whether the <tt><font size=+1>tree</font></tt> + element is nonzero. The differences are made explicit in the discussion + of the service loop below. The <tt><font size=+1>aux</font></tt> element is the client’s, to + do with as it pleases. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Srv</i> does not return until the 9P conversation is finished. Since + it is usually run in a separate process so that the caller can + exit, the service loop has little chance to return gracefully + on out of memory errors. It calls <i>emalloc9p</i>, <i>erealloc9p</i>, and <i>estrdup9p</i> + to obtain its memory. The default implementations of these + functions act as <i>malloc</i>, <i>realloc</i>, and <i>strdup</i> but abort the program + if they run out of memory. If alternate behavior is desired, clients + can link against alternate implementations of these functions. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Postmountsrv</i> and <i>threadpostmountsrv</i> are wrappers that create a + separate process in which to run <i>srv</i>. They do the following:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + If <i>s</i><tt><font size=+1>−></font></tt><i>nopipe</i> is zero (the common case), initialize <i>s</i><tt><font size=+1>−></font></tt><i>infd</i> and <i>s</i><tt><font size=+1>−></font></tt><i>outfd</i> + to be one end of a freshly allocated pipe, with <i>s</i><tt><font size=+1>−></font></tt><i>srvfd</i> initialized + as the other end.<br> + If <tt><font size=+1>name</font></tt> is non-nil, call <tt><font size=+1>postfd(</font></tt><i>s</i><tt><font size=+1>−></font></tt><i>srvfd</i><tt><font size=+1>,</font></tt> <i>name</i><tt><font size=+1>)</font></tt> to post <i>s</i><tt><font size=+1>−></font></tt><i>srvfd</i> + as <tt><font size=+1>/srv/</font></tt><i>name</i><tt><font size=+1>.<br> + </font></tt>Fork a child process via <a href="../man3/rfork.html"><i>rfork</i>(3)</a> or <i>procrfork</i> (see <a href="../man3/thread.html"><i>thread</i>(3)</a>), + using the <tt><font size=+1>RFFDG</font></tt>, <tt><font size=+1>RFNAMEG</font></tt>, and <tt><font size=+1>RFMEM</font></tt> flags. The child process calls + <i>close(</i><tt><font size=+1>s</font></tt><i>-></i><tt><font size=+1>srvfd</font></tt><i>)</i> and then <i>srv(</i><tt><font size=+1>s</font></tt><i>)</i>; it will exit once <i>srv</i> returns.<br> + If <i>mtpt</i> is non-nil, call <tt><font size=+1>amount(</font></tt><i>s</i><tt><font size=+1>−></font></tt><i>srvfd, mtpt</i><tt><font size=+1>,</font></tt> <i>flag</i><tt><font size=+1>, </font></tt>""); otherwise, + close <i>s</i><tt><font size=+1>−></font></tt><i>srvfd</i>.<br> + The parent returns to the caller. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + If any error occurs during this process, the entire process is + terminated by calling <a href="../man3/sysfatal.html"><i>sysfatal</i>(3)</a>.<br> + <p><font size=+1><b>Service functions </b></font><br> + The functions in a <tt><font size=+1>Srv</font></tt> structure named after 9P transactions are + called to satisfy requests as they arrive. If a function is provided, + it <i>must</i> arrange for <i>respond</i> to be called when the request is satisfied. + The only parameter of each service function is a <tt><font size=+1>Req*</font></tt> parameter + (say <i>r</i>). The incoming request parameters are + stored in <i>r</i><tt><font size=+1>−></font></tt><i>ifcall</i>; <i>r</i><tt><font size=+1>−></font></tt><i>fid</i> and <i>r</i><tt><font size=+1>−></font></tt><i>newfid</i> are pointers to <tt><font size=+1>Fid</font></tt> structures + corresponding to the numeric fids in <i>r</i><tt><font size=+1>−></font></tt><i>ifcall</i>; similarly, <i>r</i><tt><font size=+1>−></font></tt><i>oldreq</i> + is the <tt><font size=+1>Req</font></tt> structure corresponding to <i>r</i><tt><font size=+1>−></font></tt><i>ifcall.oldtag</i>. The outgoing + response data should be stored in <i>r</i><tt><font size=+1>−></font></tt><i>ofcall</i>. The one exception + to this rule is that <i>stat</i> should fill in + <i>r</i><tt><font size=+1>−></font></tt><i>d</i> rather than <i>r</i><tt><font size=+1>−></font></tt><i>ofcall.stat</i>: the library will convert the structure + into the machine-independent wire representation. Similarly, <i>wstat</i> + may consult <i>r</i><tt><font size=+1>−></font></tt><i>d</i> rather than decoding <i>r</i><tt><font size=+1>−></font></tt><i>ifcall</i><tt><font size=+1>.</font></tt><i>stat</i> itself. When + a request has been handled, <i>respond</i> should be called with <i>r</i> and + an error string. If the request was satisfied + successfully, the error string should be a nil pointer. Note that + it is permissible for a function to return without itself calling + <i>respond</i>, as long as it has arranged for <i>respond</i> to be called at + some point in the future by another proc sharing its address space, + but see the discussion of <i>flush</i> below. Once <i>respond</i> has been + called, the <tt><font size=+1>Req*</font></tt> as well as any pointers it once contained must + be considered freed and not referenced. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + If the service loop detects an error in a request (e.g., an attempt + to reuse an extant fid, an open of an already open fid, a read + from a fid opened for write, etc.) it will reply with an error + without consulting the service functions. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The service loop provided by <i>srv</i> (and indirectly by <i>postmountsrv</i> + and <i>threadpostmountsrv</i>) is single-threaded. If it is expected + that some requests might block, arranging for alternate processes + to handle them is suggested. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The constraints on the service functions are as follows. These + constraints are checked while the server executes. If a service + function fails to do something it ought to have, <i>srv</i> will call + <i>endsrv</i> and then abort.<br> + <i>Auth</i> If authentication is desired, the <i>auth</i> function should record + that <i>afid</i> is the new authentication fid and set <i>afid->qid</i> and <i>ofcall.qid</i>. + <i>Auth</i> may be nil, in which case it will be treated as having responded + with the error “<i>argv0: authentication not required</i>,” where <i>argv0</i> + is the program name variable as set by + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>ARGBEGIN</i> (see <a href="../man3/arg.html"><i>arg</i>(3)</a>).<br> + + </table> + <i>Attach</i>The <i>attach</i> function should check the authentication state + of <i>afid</i> if desired, and set <i>r</i><tt><font size=+1>−></font></tt><i>fid</i><tt><font size=+1>−></font></tt><i>qid</i> and <i>ofcall.qid</i> to the qid + of the file system root. <i>Attach</i> may be nil only if file trees + are in use; in this case, the qid will be filled from the root + of the tree, and no authentication will be done. + <i>Walk</i> If file trees are in use, <i>walk</i> is handled internally, and + <i>srv</i><tt><font size=+1>−></font></tt><i>walk</i> is never called.<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + If file trees are not in use, <i>walk</i> should consult <i>r</i><tt><font size=+1>−></font></tt><i>ifcall</i><tt><font size=+1>.</font></tt><i>wname</i> + and <i>r</i><tt><font size=+1>−></font></tt><i>ifcall</i><tt><font size=+1>.</font></tt><i>nwname</i>, filling in <i>ofcall</i><tt><font size=+1>.</font></tt><i>qid</i> and <i>ofcall</i><tt><font size=+1>.</font></tt><i>nqid</i>, and + also copying any necessary <i>aux</i> state from <i>r</i><tt><font size=+1>−></font></tt><i>fid</i> to <i>r</i><tt><font size=+1>−></font></tt><i>newfid</i> when + the two are different. As long as <i>walk</i> sets <i>ofcall</i><tt><font size=+1>.</font></tt><i>nqid</i> appropriately, + it can <i>respond</i> with a nil error string + even when 9P demands an error (<i>e.g.</i>, in the case of a short walk); + the library detects error conditions and handles them appropriately.<br> + Because implementing the full walk message is intricate and prone + to error, the helper routine <i>walkandclone</i> will handle the request + given pointers to two functions <i>walk1</i> and (optionally) <i>clone . + Clone</i>, if non-nil, is called to signal the creation of <i>newfid</i> + from <i>oldfid</i>. Typically a <i>clone</i> routine will copy or increment + a reference count in <i>oldfid</i>’s <i>aux</i> element. <i>Walk1</i> should walk <i>fid</i> + to <i>name</i>, initializing <i>fid</i><tt><font size=+1>−></font></tt><i>qid</i> to the new path’s qid. Both should + return nil on success or an error message on error. <i>Walkandclone</i> + will call <i>respond</i> after handling the request.<br> + + </table> + <i>Walk1</i>, <i>Clone<br> + </i> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + If the client provides functions <i>srv</i><tt><font size=+1>−></font></tt><i>walk1</i> and (optionally) <i>srv</i><tt><font size=+1>−></font></tt><i>clone</i>, + the 9P service loop will call <i>walkandclone</i> with these functions + to handle the request. Unlike the <i>walk1</i> above, <i>srv</i><tt><font size=+1>−></font></tt><i>walk1</i> must + fill in both <i>fid</i><tt><font size=+1>−></font></tt><i>qid</i> and <tt><font size=+1>*</font></tt><i>qid</i> with the new qid on a successful + walk.<br> + + </table> + <i>Open</i> If file trees are in use, the file metadata will be consulted + on open, create, remove, and wstat to see if the requester has + the appropriate permissions. If not, an error will be sent back + without consulting a service function. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + If not using file trees or the user has the appropriate permissions, + <i>open</i> is called with <i>r</i><tt><font size=+1>−></font></tt><i>ofcall</i><tt><font size=+1>.</font></tt><i>qid</i> already initialized to the one + stored in the <tt><font size=+1>Fid</font></tt> structure (that is, the one returned in the + previous walk). If the qid changes, both should be updated.<br> + <i>Create</i>The <i>create</i> function must fill in both <i>r</i><tt><font size=+1>−></font></tt><i>fid</i><tt><font size=+1>−></font></tt><i>qid</i> and <i>r</i><tt><font size=+1>−></font></tt><i>ofcall</i><tt><font size=+1>.</font></tt><i>qid</i> + on success. When using file trees, <i>create</i> should allocate a new + <tt><font size=+1>File</font></tt> with <i>createfile</i>; note that <i>createfile</i> may return nil (because, + say, the file already exists). If the <i>create</i> function is nil, + <i>srv</i> behaves as though it were a function that always + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + responded with the error “create prohibited”.<br> + + </table> + <i>Remove<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Remove + </table> + </i> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + should mark the file as removed, whether by calling <i>removefile</i> + when using file trees, or by updating an internal data structure. + In general it is not a good idea to clean up the <i>aux</i> information + associated with the corresponding <tt><font size=+1>File</font></tt> at this time, to avoid + memory errors if other fids have references to that + file. Instead, it is suggested that <i>remove</i> simply mark the file + as removed (so that further operations on it know to fail) and + wait until the file tree’s destroy function is called to reclaim + the <i>aux</i> pointer. If not using file trees, it is prudent to take + the analogous measures. If <i>remove</i> is not provided, all remove + requests will draw “remove prohibited” errors.<br> + + </table> + <i>Read</i> The <i>read</i> function must be provided; it fills <i>r</i><tt><font size=+1>−></font></tt><i>ofcall</i><tt><font size=+1>.</font></tt><i>data</i> + with at most <i>r</i><tt><font size=+1>−></font></tt><i>ifcall</i><tt><font size=+1>.</font></tt><i>count</i> bytes of data from offset <i>r</i><tt><font size=+1>−></font></tt><i>ifcall</i><tt><font size=+1>.</font></tt><i>offset</i> + of the file. It also sets <i>r</i><tt><font size=+1>−></font></tt><i>ofcall</i><tt><font size=+1>.</font></tt><i>count</i> to the number of bytes + being returned. If using file trees, <i>srv</i> will handle reads of + directories internally, only calling <i>read</i> for requests on + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + files. <i>Readstr</i> and <i>readbuf</i> are useful for satisfying read requests + on a string or buffer. Consulting the request in <i>r</i><tt><font size=+1>−></font></tt><i>ifcall</i>, they + fill <i>r</i><tt><font size=+1>−></font></tt><i>ofcall</i><tt><font size=+1>.</font></tt><i>data</i> and set <i>r</i><tt><font size=+1>−></font></tt><i>ofcall</i><tt><font size=+1>.</font></tt><i>count</i>; they do not call <i>respond</i><tt><font size=+1>.</font></tt> + Similarly, <i>dirread9p</i> can be used to handle directory reads in + servers not using file trees. The passed <i>gen + </i>function will be called as necessary to fill <i>dir</i> with information + for the <i>n</i>th entry in the directory. The string pointers placed + in <i>dir</i> should be fresh copies made with <i>estrdup9p</i>; they will be + freed by <i>dirread9p</i> after each successful call to <i>gen</i>. <i>Gen</i> should + return zero if it successfully filled <i>dir</i>, minus one on end of + directory.<br> + + </table> + <i>Write</i>The <i>write</i> function is similar but need not be provided. If + it is not, all writes will draw “write prohibited” errors. Otherwise, + <i>write</i> should attempt to write the <i>r</i><tt><font size=+1>−></font></tt><i>ifcall</i><tt><font size=+1>.</font></tt><i>count</i> bytes of <i>r</i><tt><font size=+1>−></font></tt><i>ifcall</i><tt><font size=+1>.</font></tt><i>data</i> + to offset <i>r</i><tt><font size=+1>−></font></tt><i>ifcall</i><tt><font size=+1>.</font></tt><i>offset</i> of the file, setting <i>r</i><tt><font size=+1>−></font></tt><i>ofcall</i><tt><font size=+1>.</font></tt><i>count</i> + to the number of bytes actually written. Most + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + programs consider it an error to write less than the requested + amount.<br> + + </table> + <i>Stat Stat</i> should fill <i>r</i><tt><font size=+1>−></font></tt><i>d</i> with the stat information for <i>r</i><tt><font size=+1>−></font></tt><i>fid</i>. + If using file trees, <i>r</i><tt><font size=+1>−></font></tt><i>d</i> will have been initialized with the stat + info from the tree, and <i>stat</i> itself may be nil.<br> + <i>Wstat</i>The <i>wstat</i> consults <i>r</i><tt><font size=+1>−></font></tt><i>d</i> in changing the metadata for <i>r</i><tt><font size=+1>−></font></tt><i>fid</i> + as described in <i>stat</i>(9p). When using file trees, <i>srv</i> will take + care to check that the request satisfies the permissions outlined + in <i>stat</i>(9p). Otherwise <i>wstat</i> should take care to enforce permissions + where appropriate.<br> + <i>Flush</i> Single-threaded servers, which always call <i>respond</i> before + returning from the service functions, need not provide a <i>flush</i> + implementation: <i>flush</i> is only necessary in multithreaded programs, + which arrange for <i>respond</i> to be called asynchronously. <i>Flush</i> should + cause the request <i>r</i><tt><font size=+1>−></font></tt><i>oldreq</i> to be cancelled or + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + hurried along. If <i>oldreq</i> is cancelled, this should be signalled + by calling <i>respond</i> on <i>oldreq</i> with error string ‘<tt><font size=+1>interrupted</font></tt>’. + <i>Flush</i> must respond to <i>r</i> with a nil error string. <i>Flush</i> may respond + to <i>r</i> before forcing a response to <i>r</i><tt><font size=+1>−></font></tt><i>oldreq</i>. In this case, the + library will delay sending the <i>Rflush</i> message until the + response to <i>r</i><tt><font size=+1>−></font></tt><i>oldreq</i> has been sent. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + <i>Destroyfid</i>, <i>destroyreq</i>, and <i>end</i> are auxiliary functions, not called + in direct response to 9P requests.<br> + <i>Destroyfid<br> + </i> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + When a <tt><font size=+1>Fid</font></tt>’s reference count drops to zero (<i>i.e.,</i> it has been + clunked and there are no outstanding requests referring to it), + <i>destroyfid</i> is called to allow the program to dispose of the <i>fid</i><tt><font size=+1>−></font></tt><i>aux</i> + pointer.<br> + + </table> + <i>Destroyreq<br> + </i> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Similarly, when a <tt><font size=+1>Req</font></tt>’s reference count drops to zero (<i>i.e.</i>, it + has been handled via <i>respond</i> and other outstanding pointers to + it have been closed), <i>destroyreq</i> is called to allow the program + to dispose of the <i>r</i><tt><font size=+1>−></font></tt><i>aux</i> pointer.<br> + + </table> + <i>End</i> Once the 9P service loop has finished (end of file been reached + on the service pipe or a bad message has been read), <i>end</i> is called + (if provided) to allow any final cleanup. For example, it was + used by the Palm Pilot synchronization file system (never finished) + to gracefully terminate the serial conversation once the + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + file system had been unmounted. After calling <i>end</i>, the service + loop (which runs in a separate process from its caller) terminates + using <i>_exits</i> (see <a href="../man3/exits.html"><i>exits</i>(3)</a>). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + If the <tt><font size=+1>chatty9p</font></tt> flag is at least one, a transcript of the 9P session + is printed on standard error. If the <tt><font size=+1>chatty9p</font></tt> flag is greater + than one, additional unspecified debugging output is generated. + By convention, servers written using this library accept the <tt><font size=+1>−D</font></tt> + option to increment <tt><font size=+1>chatty9p</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> + + <tt><font size=+1>/usr/local/plan9/src/lib9p/ramfs.c</font></tt> is an example of a simple single-threaded + file server. On Plan 9, see <i>archfs</i>, <i>cdfs</i>, <i>nntpfs</i>, <i>webfs</i>, and <i>sshnet</i> + for more examples. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + In general, the <tt><font size=+1>File</font></tt> interface is appropriate for maintaining + arbitrary file trees (as in <i>ramfs</i>). The <tt><font size=+1>File</font></tt> interface is best + avoided when the tree structure is easily generated as necessary; + this is true when the tree is highly structured (as in <i>cdfs</i> and + <i>nntpfs</i>) or is maintained elsewhere.<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<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-fid.html"><i>9p-fid</i>(3)</a>, <a href="../man3/9p-file.html"><i>9p-file</i>(3)</a>, <i>intro</i>(9p)<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> diff --git a/man/man3/9pclient.html b/man/man3/9pclient.html new file mode 100644 index 00000000..4ae50c21 --- /dev/null +++ b/man/man3/9pclient.html @@ -0,0 +1,250 @@ +<head> +<title>9pclient(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>9PCLIENT(3)</b><td align=right><b>9PCLIENT(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> + + CFid, CFsys, fsinit, fsmount, fsroot, fssetroot, fsunmount, nsmount, + fsversion, fsauth, fsattach, fsclose, fscreate, fsdirread, fsdirreadall, + fsdirstat, fsdirfstat, fsdirwstat, fsdirfwstat, fsopen, fsopenfd, + fspread, fspwrite, fsread, fsreadn, fswrite – 9P client library<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include <libc.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include <fcall.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include <9pclient.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>CFsys* fsmount(int fd, char *aname) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>CFsys* nsmount(char *name, char *aname) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>CFid* fsroot(CFsys *fsys) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void fsunmount(CFsys *fsys) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>CFsys* fsinit(int fd) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int fsversion(CFsys *fsys, int msize, char *version, int nversion) + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>CFid *fsauth(CFsys *fsys, char *uname, char *aname) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>CFid *fsattach(CFsys *fsys, CFid *afid, char *uname, char *aname) + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void fssetroot(CFsys *fsys, CFid *fid) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void fsclose(CFid *fid) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>CFid *fscreate(CFsys *fs, char *path, int mode, ulong perm) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>CFid* fsopen(CFsys *fs, char *path, int mode) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long fspread(CFid *fid, void *buf, long n, vlong offset) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long fspwrite(CFid *fid, void *buf, long n, vlong offset) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long fsread(CFid *fid, void *buf, long n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long fsreadn(CFid *fid, void *buf, long n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long fswrite(CFid *fid, void *buf, long n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long fsdirread(CFid *fid, Dir **d) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long fsdirreadall(CFid *fid, Dir **d) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Dir* fsdirstat(CFsys *fs, char *path) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Dir* fsdirfstat(CFid *fid) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int fsdirwstat(CFsys *fs, char *path, Dir *d) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int fsdirfwstat(CFid *fid, Dir *d) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int fsopenfd(CFsys *fs, char *path, int mode)<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> + + The <i>9pclient</i> library helps client programs interact with 9P servers. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + A <tt><font size=+1>CFsys*</font></tt> represents a connection to a 9P server. A <tt><font size=+1>CFid*</font></tt> represents + an active fid on some connection; see <i>intro</i>(9p). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + A new connection to a 9P server is typically established by <i>fsmount</i> + or <i>nsmount</i>. <i>Fsmount</i> initializes a new 9P conversation on the open + file descriptor <i>fd</i>; <i>nsmount</i> connects to a service named <i>name</i> in + the current name space directory (see <a href="../man4/intro.html"><i>intro</i>(4)</a>). Both attach to + the root of the file system using the attach name <i>aname</i>. + <i>Fsroot</i> returns the <tt><font size=+1>CFid*</font></tt> corresponding to this root. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Fsinit</i>, <i>fsversion</i>, <i>fsauth</i>, <i>fsattach</i>, and <i>fssetroot</i> provide more + detailed control over the file system connection than <i>fsmount</i> + and <i>nsmount</i>. <i>Fsinit</i> allocates a new <tt><font size=+1>CFsys*</font></tt> corresponding to a + 9P conversation on the file descriptor <i>fd</i>. <i>Fsversion</i> executes + a <i>version</i>(9p) transaction to establish maximum message size and + 9P + version. <i>Fsauth</i> executes an <i>auth</i>(9p) transaction, returning the + new auth fid. (<i>Fsread</i> and <i>fswrite</i> can then be used to run the + authentication protocol over the fid.) <i>Fsattach</i> executes an <i>attach</i>(9p) + transaction to connect to the root of a file tree served by the + server. It presents <i>afid</i> (which may be nil) to establish + identity. <i>Fssetroot</i> sets the root fid used by <i>fsopen</i>, <i>fsopenfd</i>, + <i>fsdirstat</i>, and <i>fsdirwstat</i>, which evaluate rooted path names. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + When a fid is no longer needed, it should be clunked by calling + <i>fsclose</i> and then considered freed. Similarly, when the connection + to the server is no longer needed, it should be closed by calling + <i>fsunmount</i>, which will take care of calling <i>fsclose</i> on the current + root fid. Once all fids have been clunked <i>and</i> the connection + has been closed (the order is not important), the allocated structures + will be freed and the file descriptor corresponding to the connection + will be closed (see <a href="../man2/close.html"><i>close</i>(2)</a>). Fids are not reference counted: + when <i>fsclose</i> is called, the clunk transaction and freeing of storage + happen immediately. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Fscreate</i> and <i>fsopen</i> establish new fids using the <i>walk</i>, <i>create</i> + and <i>open</i> transactions (see <i>walk</i>(9p) and <i>open</i>(9p)). The <i>path</i> argument + is evaluated relative to the <tt><font size=+1>CFsys</font></tt> root (see <i>fsroot</i> and <i>fssetroot</i> + above). The path is parsed as a slash-separated sequence of path + elements, as on Unix and Plan 9. Elements that are + empty or dot (<tt><font size=+1>.</font></tt>) are ignored. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Once opened, these fids can be read and written using <i>fspread</i> + and <i>fspwrite</i>, which execute <i>read</i> and <i>write</i> transactions (see <i>read</i>(9p)). + The library maintains an offset for each fid, analagous to the + offset maintained by the kernel for each open file descriptor. + <i>Fsread</i> and <i>fswrite</i> read and write from this offset, and + update it after successful calls. Calling <i>fspread</i> or <i>fspwrite</i> + with an <i>offset</i> of –1 is identical to calling <i>fsread</i> or <i>fswrite</i>. + <i>Fsreadn</i> calls <i>fsread</i> repeatedly to obtain exactly <i>n</i> bytes of data, + unless it encounters end-of-file or an error. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Reading an open a directory returns directory entries encoded + as described in <i>stat</i>(9p). <i>Fsdirread</i> calls <i>fsread</i> and then parses + the encoded entries into an array of <tt><font size=+1>Dir*</font></tt> data structures, storing + a pointer to the array in <tt><font size=+1>*d</font></tt> and returning the number of entries. + <i>Fsdirreadall</i> is similar but reads the entire directory. The + returned pointer should be freed with <i>free</i> (see <a href="../man3/malloc.html"><i>malloc</i>(3)</a>) when + no longer needed. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Fsdirfstat</i> and <i>fsdirfwstat</i> execute <i>stat</i> and <i>wstat</i> (see <i>stat</i>(9p)) + transactions. The <tt><font size=+1>Dir</font></tt> structure returned by <i>fsdirfstat</i> should + be freed with <i>free</i> (see <a href="../man3/malloc.html"><i>malloc</i>(3)</a>) when no longer needed. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Fsdirstat</i> and <i>fsdirwstat</i> are similar to <i>fsdirfstat</i> and <i>fsdirfwstat</i> + but operate on paths relative to the file system root (see <i>fsopen</i> + and <i>fscreate</i> above). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Fsopenfd</i> opens a file on the 9P server for reading or writing + but returns a Unix file descriptor instead of a fid structure. + The file descriptor is actually one end of a <a href="../man2/pipe.html"><i>pipe</i>(2)</a>. A proxy + process on the other end is ferrying data between the pipe and + the 9P fid. Because of the implementation as a pipe, the only + signal of a + read or write error is the closing of the pipe. The file descriptor + remains valid even after the <tt><font size=+1>CFsys</font></tt> is unmounted.<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/lib9pclient<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="../man4/intro.html"><i>intro</i>(4)</a>, <i>intro</i>(9p)<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The implementation should use a special version string to distinguish + between servers that support <i>openfd</i>(9p) and servers that do not. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The interface does not provide access to the <i>walk</i>(9p) transaction, + or to <i>open</i> and <i>create</i> on already-established fids. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + There is no <i>fsseek</i>.<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> diff --git a/man/man3/addpt.html b/man/man3/addpt.html new file mode 100644 index 00000000..1c327aaa --- /dev/null +++ b/man/man3/addpt.html @@ -0,0 +1,174 @@ +<head> +<title>addpt(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>ADDPT(3)</b><td align=right><b>ADDPT(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> + + addpt, subpt, mulpt, divpt, rectaddpt, rectsubpt, insetrect, canonrect, + eqpt, eqrect, ptinrect, rectinrect, rectXrect, rectclip, combinerect, + Dx, Dy, Pt, Rect, Rpt – arithmetic on points and rectangles<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 <draw.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point addpt(Point p, Point q) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point subpt(Point p, Point q) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point mulpt(Point p, int a) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point divpt(Point p, int a) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rectangle rectaddpt(Rectangle r, Point p) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rectangle rectsubpt(Rectangle r, Point p) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rectangle insetrect(Rectangle r, int n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rectangle canonrect(Rectangle r) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int eqpt(Point p, Point q) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int eqrect(Rectangle r, Rectangle s) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int ptinrect(Point p, Rectangle r) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int rectinrect(Rectangle r, Rectangle s) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int rectXrect(Rectangle r, Rectangle s) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int rectclip(Rectangle *rp, Rectangle b) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void combinerect(Rectangle *rp, Rectangle b) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int Dx(Rectangle r) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int Dy(Rectangle r) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point Pt(int x, int y) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rectangle Rect(int x0, int y0, int x1, int y1) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rectangle Rpt(Point p, Point q)<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> + + The functions <i>Pt</i>, <i>Rect</i> and <i>Rpt</i> construct geometrical data types + from their components. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Addpt</i> returns the Point sum of its arguments: <tt><font size=+1>Pt(</font></tt><i>p</i><tt><font size=+1>.x+</font></tt><i>q</i><tt><font size=+1>.x,</font></tt> <i>p</i><tt><font size=+1>.y+</font></tt><i>q</i><tt><font size=+1>.y)</font></tt>. + <i>Subpt</i> returns the Point difference of its arguments: <tt><font size=+1>Pt(</font></tt><i>p</i><tt><font size=+1>.x−</font></tt><i>q</i><tt><font size=+1>.x,</font></tt> + <i>p</i><tt><font size=+1>.y−</font></tt><i>q</i><tt><font size=+1>.y)</font></tt>. <i>Mulpt</i> returns the Point <tt><font size=+1>Pt(</font></tt><i>p</i><tt><font size=+1>.x*</font></tt><i>a</i><tt><font size=+1>,</font></tt> <i>p</i><tt><font size=+1>.y*</font></tt><i>a</i><tt><font size=+1>)</font></tt>. <i>Divpt</i> returns + the Point <tt><font size=+1>Pt(</font></tt><i>p</i><tt><font size=+1>.x/</font></tt><i>a</i><tt><font size=+1>,</font></tt> <i>p</i><tt><font size=+1>.y/</font></tt><i>a</i><tt><font size=+1>)</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Rectaddpt</i> returns the Rectangle <tt><font size=+1>Rect(add(</font></tt><i>r</i><tt><font size=+1>.min,</font></tt> <i>p</i><tt><font size=+1>)</font></tt>, <tt><font size=+1>add(</font></tt><i>r</i><tt><font size=+1>.max,</font></tt> + <i>p</i><tt><font size=+1>))</font></tt>; <i>rectsubpt</i> returns the Rectangle <tt><font size=+1>Rpt(sub(</font></tt><i>r</i><tt><font size=+1>.min,</font></tt> <i>p</i><tt><font size=+1>), sub(</font></tt><i>r</i><tt><font size=+1>.max,</font></tt> + <i>p</i><tt><font size=+1>))</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Insetrect</i> returns the Rectangle <tt><font size=+1>Rect(</font></tt><i>r</i><tt><font size=+1>.min.x+</font></tt><i>n</i>, <i>r</i><tt><font size=+1>.min.y+</font></tt><i>n</i>, <i>r</i><tt><font size=+1>.max.x−</font></tt><i>n</i>, + <i>r</i><tt><font size=+1>.max.y−</font></tt><i>n</i><tt><font size=+1>)</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Canonrect</i> returns a rectangle with the same extent as <i>r</i>, canonicalized + so that <tt><font size=+1>min.x </font></tt>≤ <tt><font size=+1>max.x</font></tt>, and <tt><font size=+1>min.y </font></tt>≤ <tt><font size=+1>max.y</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Eqpt</i> compares its argument Points and returns 0 if unequal, 1 + if equal. <i>Eqrect</i> does the same for its argument Rectangles. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Ptinrect</i> returns 1 if <i>p</i> is a point within <i>r</i>, and 0 otherwise. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Rectinrect</i> returns 1 if all the pixels in <i>r</i> are also in <i>s</i>, and + 0 otherwise. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>RectXrect</i> returns 1 if <i>r</i> and <i>s</i> share any point, and 0 otherwise. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Rectclip</i> clips in place the Rectangle pointed to by <i>rp</i> so that + it is completely contained within <i>b</i>. The return value is 1 if + any part of *<i>rp</i> is within <i>b</i>. Otherwise, the return value is 0 + and *<i>rp</i> is unchanged. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Combinerect</i> overwrites <tt><font size=+1>*rp</font></tt> with the smallest rectangle sufficient + to cover all the pixels of <tt><font size=+1>*rp</font></tt> and <tt><font size=+1>b</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The functions <i>Dx</i> and <i>Dy</i> give the width (Δx) and height (Δy) of + a Rectangle. They are implemented as macros.<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/libdraw<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/graphics.html"><i>graphics</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> diff --git a/man/man3/aes.html b/man/man3/aes.html new file mode 100644 index 00000000..1a455c2f --- /dev/null +++ b/man/man3/aes.html @@ -0,0 +1,85 @@ +<head> +<title>aes(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>AES(3)</b><td align=right><b>AES(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> + + setupAESstate, aesCBCencrypt, aesCBCdecrypt - advanced encryption + standard (rijndael)<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 <mp.h><br> + #include <libsec.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void setupAESstate(AESstate *s, uchar key[], int keybytes, uchar + *ivec) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void aesCBCencrypt(uchar*, int, AESstate*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void aesCBCdecrypt(uchar*, int, AESstate*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + +</table> +<p><font size=+1><b>DESCRIPTION </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + DES is being replaced by Rijndael, also known as AES, as the preferred + block ciper. <i>setupAESstate</i>, <i>aesCBCencrypt</i>, and <i>aesCBCdecrypt</i> implement + cipher block chaining encryption. <i>Keybytes</i> should be 16, 24, or + 32. The initialization vector <i>ivec</i> of <i>AESbsize</i> bytes should random + enough to be unlikely to be reused but + does not need to be cryptographically strongly unpredictable.<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/libsec<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/mp.html"><i>mp</i>(3)</a>, <a href="../man3/blowfish.html"><i>blowfish</i>(3)</a>, <a href="../man3/des.html"><i>des</i>(3)</a>, <a href="../man3/dsa.html"><i>dsa</i>(3)</a>, <a href="../man3/elgamal.html"><i>elgamal</i>(3)</a>, <a href="../man3/rc4.html"><i>rc4</i>(3)</a>, <a href="../man3/rsa.html"><i>rsa</i>(3)</a>, + <a href="../man3/sechash.html"><i>sechash</i>(3)</a>, <a href="../man3/prime.html"><i>prime</i>(3)</a>, <a href="../man3/rand.html"><i>rand</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> diff --git a/man/man3/allocimage.html b/man/man3/allocimage.html new file mode 100644 index 00000000..d36fb0eb --- /dev/null +++ b/man/man3/allocimage.html @@ -0,0 +1,321 @@ +<head> +<title>allocimage(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>ALLOCIMAGE(3)</b><td align=right><b>ALLOCIMAGE(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> + + allocimage, allocimagemix, freeimage, nameimage, namedimage, setalpha, + loadimage, cloadimage, unloadimage, readimage, writeimage, bytesperline, + wordsperline – allocating, freeing, reading, writing images<br> + +</table> +<p><font size=+1><b>SYNOPSIS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<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 <draw.h><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Image *allocimage(Display *d, Rectangle r, <br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + ulong chan, int repl, int col)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>Image *allocimagemix(Display *d, ulong one, ulong three)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void freeimage(Image *i)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int nameimage(Image *i, char *name, int in)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Image *namedimage(Display *d, char *name)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ulong setalpha(ulong color, uchar alpha)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int loadimage(Image *i, Rectangle r, uchar *data, int ndata)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int cloadimage(Image *i, Rectangle r, uchar *data, int ndata)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int unloadimage(Image *i, Rectangle r, uchar *data, int ndata)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Image *readimage(Display *d, int fd, int dolock)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int writeimage(int fd, Image *i, int dolock)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int bytesperline(Rectangle r, int d)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int wordsperline(Rectangle r, int d)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>enum<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + DOpaque = 0xFFFFFFFF,<br> + DTransparent = 0x00000000,<br> + DBlack = 0x000000FF,<br> + DWhite = 0xFFFFFFFF,<br> + DRed = 0xFF0000FF,<br> + DGreen = 0x00FF00FF,<br> + DBlue = 0x0000FFFF,<br> + DCyan = 0x00FFFFFF,<br> + DMagenta = 0xFF00FFFF,<br> + DYellow = 0xFFFF00FF,<br> + DPaleyellow = 0xFFFFAAFF,<br> + DDarkyellow = 0xEEEE9EFF,<br> + DDarkgreen = 0x448844FF,<br> + DPalegreen = 0xAAFFAAFF,<br> + DMedgreen = 0x88CC88FF,<br> + DDarkblue = 0x000055FF,<br> + DPalebluegreen = 0xAAFFFFFF,<br> + DPaleblue = 0x0000BBFF,<br> + DBluegreen = 0x008888FF,<br> + DGreygreen = 0x55AAAAFF,<br> + DPalegreygreen = 0x9EEEEEFF,<br> + DYellowgreen = 0x99994CFF,<br> + DMedblue = 0x000099FF,<br> + DGreyblue = 0x005DBBFF,<br> + DPalegreyblue = 0x4993DDFF,<br> + DPurpleblue = 0x8888CCFF,<br> + DNotacolor = 0xFFFFFF00,<br> + DNofill = DNotacolor,<br> + <br> + + </table> + };<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> + + A new <tt><font size=+1>Image</font></tt> on <tt><font size=+1>Display d</font></tt> is allocated with <tt><font size=+1>allocimage</font></tt>; it will + have the rectangle, pixel channel format, and replication flag + given by its arguments. Convenient pixel channels like <tt><font size=+1>GREY1</font></tt>, + <tt><font size=+1>GREY2</font></tt>, <tt><font size=+1>CMAP8</font></tt>, <tt><font size=+1>RGB16</font></tt>, <tt><font size=+1>RGB24</font></tt>, and <tt><font size=+1>RGBA32</font></tt> are predefined. All the + new image’s pixels will have initial value <i>col</i>. If <i>col + </i>is <tt><font size=+1>DNofill</font></tt>, no initialization is done. Representative useful values + of color are predefined: <tt><font size=+1>DBlack</font></tt>, <tt><font size=+1>DWhite</font></tt>, <tt><font size=+1>DRed</font></tt>, and so on. Colors + are specified by 32-bit numbers comprising, from most to least + significant byte, 8-bit values for red, green, blue, and alpha. + The values correspond to illumination, so 0 is black + and 255 is white. Similarly, for alpha 0 is transparent and 255 + is opaque. The <i>id</i> field will have been set to the identifying + number used by <tt><font size=+1>/dev/draw</font></tt> (see <a href="../man3/draw.html"><i>draw</i>(3)</a>), and the <i>cache</i> field will + be zero. If <i>repl</i> is true, the clip rectangle is set to a very + large region; if false, it is set to <i>r</i>. The <i>depth</i> field will be + set to the + number of bits per pixel specified by the channel descriptor (see + <a href="../man7/image.html"><i>image</i>(7)</a>). <i>Allocimage</i> returns 0 if the server has run out of image + memory. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Allocimagemix</i> is used to allocate background colors. On 8-bit + color-mapped displays, it returns a 2x2 replicated image with one + pixel colored the color <i>one</i> and the other three with <i>three</i>. (This + simulates a wider range of tones than can be represented by a + single pixel value on a color-mapped display.) On true color + displays, it returns a 1x1 replicated image whose pixel is the + result of mixing the two colors in a one to three ratio. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Freeimage</i> frees the resources used by its argument image. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Nameimage</i> publishes in the server the image <i>i</i> under the given + <i>name</i>. If <i>in</i> is non-zero, the image is published; otherwise <i>i</i> must + be already named <i>name</i> and it is withdrawn from publication. <i>Namedimage</i> + returns a reference to the image published under the given <i>name</i> + on <tt><font size=+1>Display</font></tt> <i>d</i>. These routines permit + unrelated applications sharing a display to share an image; for + example they provide the mechanism behind <tt><font size=+1>getwindow</font></tt> (see <a href="../man3/graphics.html"><i>graphics</i>(3)</a>). + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The RGB values in a color are <i>premultiplied</i> by the alpha value; + for example, a 50% red is <tt><font size=+1>0x7F00007F</font></tt> not <tt><font size=+1>0xFF00007F</font></tt>. The function + <i>setalpha</i> performs the alpha computation on a given <tt><font size=+1>color</font></tt>, ignoring + its initial alpha value, multiplying the components by the supplied + <tt><font size=+1>alpha</font></tt>. For example, to make a 50% red + color value, one could execute <tt><font size=+1>setalpha(DRed, 0x7F)</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The remaining functions deal with moving groups of pixel values + between image and user space or external files. There is a fixed + format for the exchange and storage of image data (see <a href="../man7/image.html"><i>image</i>(7)</a>). + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Unloadimage</i> reads a rectangle of pixels from image <i>i</i> into <i>data</i>, + whose length is specified by <i>ndata</i>. It is an error if <i>ndata</i> is + too small to accommodate the pixels. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Loadimage</i> replaces the specified rectangle in image <i>i</i> with the + <i>ndata</i> bytes of <i>data</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The pixels are presented one horizontal line at a time, starting + with the top-left pixel of <i>r</i>. In the data processed by these routines, + each scan line starts with a new byte in the array, leaving the + last byte of the previous line partially empty, if necessary. + Pixels are packed as tightly as possible within <i>data</i>, regardless + of + the rectangle being extracted. Bytes are filled from most to least + significant bit order, as the <i>x</i> coordinate increases, aligned + so <i>x</i>=0 would appear as the leftmost pixel of its byte. Thus, for + <tt><font size=+1>depth</font></tt> 1, the pixel at <i>x</i> offset 165 within the rectangle will be + in a <i>data</i> byte at bit-position <tt><font size=+1>0x04</font></tt> regardless of the overall + rectangle: 165 mod 8 equals 5, and <tt><font size=+1>0x80 >> 5</font></tt> equals <tt><font size=+1>0x04</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>Cloadimage</font></tt> does the same as <i>loadimage</i>, but for <i>ndata</i> bytes of + compressed image <i>data</i> (see <a href="../man7/image.html"><i>image</i>(7)</a>). On each call to <i>cloadimage,</i> + the <i>data</i> must be at the beginning of a compressed data block, + in particular, it should start with the <tt><font size=+1>y</font></tt> coordinate and data + length for the block. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Loadimage</i>, <i>cloadimage</i>, and <i>unloadimage</i> return the number of bytes + copied. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Readimage</i> creates an image from data contained in an external + file (see <a href="../man7/image.html"><i>image</i>(7)</a> for the file format); <i>fd</i> is a file descriptor + obtained by opening such a file for reading. The returned image + is allocated using <i>allocimage</i>. The <i>dolock</i> flag specifies whether + the <tt><font size=+1>Display</font></tt> should be synchronized for multithreaded access; + single-threaded programs can leave it zero. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Writeimage</i> writes image <i>i</i> onto file descriptor <i>fd</i>, which should + be open for writing. The format is as described for <i>readimage</i>. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Readimage</i> and <i>writeimage</i> do not close <i>fd</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Bytesperline</i> and <i>wordsperline</i> return the number of bytes or words + occupied in memory by one scan line of rectangle <i>r</i> in an image + with <i>d</i> bits per pixel.<br> + +</table> +<p><font size=+1><b>EXAMPLE </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + To allocate a single-pixel replicated image that may be used to + paint a region red,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>red = allocimage(display, Rect(0, 0, 1, 1), RGB24, 1, DRed);<br> + </font></tt> + </table> + +</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/libdraw<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/graphics.html"><i>graphics</i>(3)</a>, <a href="../man3/draw.html"><i>draw</i>(3)</a>, <a href="../man3/draw.html"><i>draw</i>(3)</a>, <a href="../man7/image.html"><i>image</i>(7)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + These functions return pointer 0 or integer –1 on failure, usually + due to insufficient memory. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + May set <i>errstr</i>.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>Depth</font></tt> must be a divisor or multiple of 8.<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> diff --git a/man/man3/arg.html b/man/man3/arg.html new file mode 100644 index 00000000..8ca66c80 --- /dev/null +++ b/man/man3/arg.html @@ -0,0 +1,152 @@ +<head> +<title>arg(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>ARG(3)</b><td align=right><b>ARG(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> + + ARGBEGIN, ARGEND, ARGC, ARGF, EARGF, arginit, argopt – process + option letters from argv<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ARGBEGIN { <br> + char *ARGF(); <br> + char *EARGF(code); <br> + Rune ARGC(); <br> + } ARGEND <br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>extern char *argv0; <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 macros assume the names <i>argc</i> and <i>argv</i> are in scope; see + <a href="../man3/exec.html"><i>exec</i>(3)</a>. <i>ARGBEGIN</i> and <i>ARGEND</i> surround code for processing program + options. The code should be the cases of a C switch on option + characters; it is executed once for each option character. Options + end after an argument <tt><font size=+1>−−</font></tt>, before an argument <tt><font size=+1>−</font></tt>, or + before an argument that doesn’t begin with <tt><font size=+1>−</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The function macro <i>ARGC</i> returns the current option character, + as an integer. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The function macro <i>ARGF</i> returns the current option argument: a + pointer to the rest of the option string if not empty, or the + next argument in <i>argv</i> if any, or 0. <i>ARGF</i> must be called just once + for each option that takes an argument. The macro <i>EARGF</i> is like + <i>ARGF</i> but instead of returning zero runs <i>code</i> and, if that + returns, calls <a href="../man3/abort.html"><i>abort</i>(3)</a>. A typical value for <i>code</i> is <tt><font size=+1>usage()</font></tt>, + as in <tt><font size=+1>EARGF(usage())</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + After <i>ARGBEGIN</i>, <i>argv0</i> is a copy of <tt><font size=+1>argv[0]</font></tt> (conventionally the + name of the program). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + After <i>ARGEND</i>, <i>argv</i> points at a zero-terminated list of the remaining + <i>argc</i> arguments.<br> + +</table> +<p><font size=+1><b>EXAMPLE </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + This C program can take option <tt><font size=+1>b</font></tt> and option <tt><font size=+1>f</font></tt>, which requires + an argument.<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> + void<br> + main(int argc, char *argv[])<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + char *f;<br> + print("%s", argv[0]);<br> + ARGBEGIN {<br> + case 'b':<br> + print(" −b");<br> + break;<br> + case 'f':<br> + print(" −f(%s)", (f=ARGF())? f: "no arg");<br> + break;<br> + default:<br> + print(" badflag('%c')", ARGC());<br> + } ARGEND<br> + print(" %d args:", argc);<br> + while(*argv)<br> + print(" '%s'", *argv++);<br> + print("\n");<br> + exits(nil);<br> + + </table> + }<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + Here is the output from running the command <tt><font size=+1>prog −bffile1 −r −f + file2 arg1 arg2<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + prog −b −f(file1) badflag('r') −f(file2) 2 args: 'arg1' 'arg2' + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + +</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/include/libc.h<br> + </font></tt> +</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> diff --git a/man/man3/arith3.html b/man/man3/arith3.html new file mode 100644 index 00000000..71cf815c --- /dev/null +++ b/man/man3/arith3.html @@ -0,0 +1,216 @@ +<head> +<title>arith3(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>ARITH3(3)</b><td align=right><b>ARITH3(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> + + add3, sub3, neg3, div3, mul3, eqpt3, closept3, dot3, cross3, len3, + dist3, unit3, midpt3, lerp3, reflect3, nearseg3, pldist3, vdiv3, + vrem3, pn2f3, ppp2f3, fff2p3, pdiv4, add4, sub4 – operations on + 3-d points and planes<br> + +</table> +<p><font size=+1><b>SYNOPSIS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>#include <draw.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include <geometry.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point3 add3(Point3 a, Point3 b) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point3 sub3(Point3 a, Point3 b) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point3 neg3(Point3 a) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point3 div3(Point3 a, double b) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point3 mul3(Point3 a, double b) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int eqpt3(Point3 p, Point3 q) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int closept3(Point3 p, Point3 q, double eps) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>double dot3(Point3 p, Point3 q) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point3 cross3(Point3 p, Point3 q) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>double len3(Point3 p) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>double dist3(Point3 p, Point3 q) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point3 unit3(Point3 p) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point3 midpt3(Point3 p, Point3 q) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point3 lerp3(Point3 p, Point3 q, double alpha) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point3 reflect3(Point3 p, Point3 p0, Point3 p1) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point3 nearseg3(Point3 p0, Point3 p1, Point3 testp) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>double pldist3(Point3 p, Point3 p0, Point3 p1) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>double vdiv3(Point3 a, Point3 b) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point3 vrem3(Point3 a, Point3 b) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point3 pn2f3(Point3 p, Point3 n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point3 ppp2f3(Point3 p0, Point3 p1, Point3 p2) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point3 fff2p3(Point3 f0, Point3 f1, Point3 f2) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point3 pdiv4(Point3 a) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point3 add4(Point3 a, Point3 b) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point3 sub4(Point3 a, Point3 b)<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 routines do arithmetic on points and planes in affine or + projective 3-space. Type <tt><font size=+1>Point3</font></tt> is<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef struct Point3 Point3;<br> + struct Point3{<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + double x, y, z, w;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + Routines whose names end in <tt><font size=+1>3</font></tt> operate on vectors or ordinary points + in affine 3-space, represented by their Euclidean <tt><font size=+1>(x,y,z)</font></tt> coordinates. + (They assume <tt><font size=+1>w=1</font></tt> in their arguments, and set <tt><font size=+1>w=1</font></tt> in their results.)<br> + Name Description<br> + <tt><font size=+1>add3</font></tt> Add the coordinates of two points.<br> + <tt><font size=+1>sub3</font></tt> Subtract coordinates of two points.<br> + <tt><font size=+1>neg3</font></tt> Negate the coordinates of a point.<br> + <tt><font size=+1>mul3</font></tt> Multiply coordinates by a scalar.<br> + <tt><font size=+1>div3</font></tt> Divide coordinates by a scalar.<br> + <tt><font size=+1>eqpt3</font></tt> Test two points for exact equality.<br> + <tt><font size=+1>closept3</font></tt> Is the distance between two points smaller than <i>eps</i>?<br> + <tt><font size=+1>dot3</font></tt> Dot product.<br> + <tt><font size=+1>cross3</font></tt> Cross product.<br> + <tt><font size=+1>len3</font></tt> Distance to the origin.<br> + <tt><font size=+1>dist3</font></tt> Distance between two points.<br> + <tt><font size=+1>unit3</font></tt> A unit vector parallel to <i>p</i>.<br> + <tt><font size=+1>midpt3</font></tt> The midpoint of line segment <i>pq</i>.<br> + <tt><font size=+1>lerp3</font></tt> Linear interpolation between <i>p</i> and <i>q</i>.<br> + <tt><font size=+1>reflect3</font></tt> The reflection of point <i>p</i> in the segment joining <i>p0</i> and + <i>p1</i>.<br> + <tt><font size=+1>nearseg3</font></tt> The closest point to <i>testp</i> on segment <i>p0 p1</i>.<br> + <tt><font size=+1>pldist3</font></tt> The distance from <i>p</i> to segment <i>p0 p1</i>.<br> + <tt><font size=+1>vdiv3</font></tt> Vector divide -- the length of the component of <i>a</i> parallel + to <i>b</i>, in units of the length of <i>b</i>.<br> + <tt><font size=+1>vrem3</font></tt> Vector remainder -- the component of <i>a</i> perpendicular to <i>b</i>. + Ignoring roundoff, we have <tt><font size=+1>eqpt3(add3(mul3(b, vdiv3(a, b)), vrem3(a, + b)), a)</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The following routines convert amongst various representations + of points and planes. Planes are represented identically to points, + by duality; a point <tt><font size=+1>p</font></tt> is on a plane <tt><font size=+1>q</font></tt> whenever <tt><font size=+1>p.x*q.x+p.y*q.y+p.z*q.z+p.w*q.w=0</font></tt>. + Although when dealing with affine points we assume <tt><font size=+1>p.w=1</font></tt>, we can’t + make the same + assumption for planes. The names of these routines are extra-cryptic. + They contain an <tt><font size=+1>f</font></tt> (for ‘face’) to indicate a plane, <tt><font size=+1>p</font></tt> for a point + and <tt><font size=+1>n</font></tt> for a normal vector. The number <tt><font size=+1>2</font></tt> abbreviates the word ‘to.’ + The number <tt><font size=+1>3</font></tt> reminds us, as before, that we’re dealing with affine + points. Thus <tt><font size=+1>pn2f3</font></tt> takes a point and a normal + vector and returns the corresponding plane.<br> + Name Description<br> + <tt><font size=+1>pn2f3</font></tt> Compute the plane passing through <i>p</i> with normal <i>n</i>.<br> + <tt><font size=+1>ppp2f3</font></tt> Compute the plane passing through three points.<br> + <tt><font size=+1>fff2p3</font></tt> Compute the intersection point of three planes. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The names of the following routines end in <tt><font size=+1>4</font></tt> because they operate + on points in projective 4-space, represented by their homogeneous + coordinates.<br> + pdiv4Perspective division. Divide <tt><font size=+1>p.w</font></tt> into <i>p</i>’s coordinates, converting + to affine coordinates. If <tt><font size=+1>p.w</font></tt> is zero, the result is the same + as the argument.<br> + add4 Add the coordinates of two points.<br> + sub4 Subtract the coordinates of two points.<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/libgeometry<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/matrix.html"><i>matrix</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> diff --git a/man/man3/atof.html b/man/man3/atof.html new file mode 100644 index 00000000..ef464d0a --- /dev/null +++ b/man/man3/atof.html @@ -0,0 +1,170 @@ +<head> +<title>atof(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>ATOF(3)</b><td align=right><b>ATOF(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> + + atof, atoi, atol, atoll, charstod, strtod, strtol, strtoll, strtoul, + strtoull – convert text to numbers<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>double atof(char *nptr)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int atoi(char *nptr)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long atol(char *nptr)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>vlong atoll(char *nptr)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>double charstod(int (*f)(void *), void *a)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>double strtod(char *nptr, char **rptr)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long strtol(char *nptr, char **rptr, int base)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>vlong strtoll(char *nptr, char **rptr, int base)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ulong strtoul(char *nptr, char **rptr, int base)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>vlong strtoull(char *nptr, char **rptr, int base)<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> + + <i>Atof</i>, <i>atoi</i>, <i>atol</i>, and <i>atoll</i> convert a string pointed to by <i>nptr</i> + to floating, integer, long integer, and long long integer (<tt><font size=+1>vlong</font></tt>) + representation respectively. The first unrecognized character + ends the string. Leading C escapes are understood, as in <i>strtol</i> + with <i>base</i> zero (described below). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Atof</i> recognizes an optional string of tabs and spaces, then an + optional sign, then a string of digits optionally containing a + decimal point, then an optional <tt><font size=+1>e</font></tt> or <tt><font size=+1>E</font></tt> followed by an optionally + signed integer. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Atoi</i> and <i>atol</i> recognize an optional string of tabs and spaces, + then an optional sign, then a string of decimal digits. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Strtod</i>, <i>strtol</i>, <i>strtoll</i>, <i>strtoul</i>, and <i>strtoull</i> behave similarly + to <i>atof</i> and <i>atol</i> and, if <i>rptr</i> is not zero, set <i>*rptr</i> to point + to the input character immediately after the string converted. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Strtol</i>, <i>strtoll</i>, <i>strtoul</i>, and <i>strtoull</i> interpret the digit string + in the specified <i>base</i>, from 2 to 36, each digit being less than + the base. Digits with value over 9 are represented by letters, + a-z or A-Z. If <i>base</i> is 0, the input is interpreted as an integral + constant in the style of C (with no suffixed type indicators): + numbers are + octal if they begin with <tt><font size=+1>0</font></tt>, hexadecimal if they begin with <tt><font size=+1>0x</font></tt> + or <tt><font size=+1>0X</font></tt>, otherwise decimal. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Charstod</i> interprets floating point numbers in the manner of <i>atof</i>, + but gets successive characters by calling <tt><font size=+1>(*</font></tt><i>f</i><tt><font size=+1>)(a)</font></tt>. The last call + to <i>f</i> terminates the scan, so it must have returned a character + that is not a legal continuation of a number. Therefore, it may + be necessary to back up the input stream one character after + calling <i>charstod</i>.<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/lib9<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/fscanf.html"><i>fscanf</i>(3)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Zero is returned if the beginning of the input string is not interpretable + as a number; even in this case, <i>rptr</i> will be updated.<br> + These routines set <i>errstr</i>.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Atoi</i> and <i>atol</i> accept octal and hexadecimal numbers in the style + of C, contrary to the ANSI specification. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Atof</i>, <i>strtod</i>, <i>strtol</i>, <i>strtoul</i>, <i>strtoll</i>, and <i>strtoull</i> are not provided: + they are expected to be provided by the underlying system. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Because they are implemented in the fmt library, <i>charstod</i> and + <i>strtod</i> are preprocessor macros defined as <i>fmtcharstod</i> and <i>fmtstrtod</i>. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + To avoid name conflicts with the underlying system, <i>atoi</i>, <i>atol</i>, + and <i>atoll</i> are preprocessor macros defined as <i>p9atoi</i>, <i>p9atol</i>, and + <i>p9atoll</i>; see <a href="../man3/intro.html"><i>intro</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> diff --git a/man/man3/bin.html b/man/man3/bin.html new file mode 100644 index 00000000..f016622f --- /dev/null +++ b/man/man3/bin.html @@ -0,0 +1,131 @@ +<head> +<title>bin(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>BIN(3)</b><td align=right><b>BIN(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> + + binalloc, bingrow, binfree – grouped memory allocation<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 <bin.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>typedef struct BinBin; + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void *binalloc(Bin **bp, ulong size, int clr); + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void *bingrow(Bin **bp, void *op, ulong osize,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + ulong size, int clr); + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>void binfree(Bin **bp);<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 routines provide simple grouped memory allocation and deallocation. + Items allocated with <i>binalloc</i> are added to the <i>Bin</i> pointed to + by <i>bp</i>. All items in a bin may be freed with one call to <i>binfree</i>; + there is no way to free a single item. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Binalloc</i> returns a pointer to a new block of at least <i>size</i> bytes. + The block is suitably aligned for storage of any type of object. + No two active pointers from <i>binalloc</i> will have the same value. + The call <tt><font size=+1>binalloc(0)</font></tt> returns a valid pointer rather than null. + If <i>clr</i> is non-zero, the allocated memory is set to 0; otherwise, + the contents are undefined. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Bingrow</i> is used to extend the size of a block of memory returned + by <i>binalloc</i>. <i>Bp</i> must point to the same bin group used to allocate + the original block, and <i>osize</i> must be the last size used to allocate + or grow the block. A pointer to a block of at least <i>size</i> bytes + is returned, with the same contents in the first <i>osize + </i>locations. If <i>clr</i> is non-zero, the remaining bytes are set to + 0, and are undefined otherwise. If <i>op</i> is <tt><font size=+1>nil</font></tt>, it and <i>osize</i> are + ignored, and the result is the same as calling <i>binalloc</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Binalloc</i> and <i>bingrow</i> allocate large chunks of memory using <a href="../man3/malloc.html"><i>malloc</i>(3)</a> + and return pieces of these chunks. The chunks are <i>free</i>’d upon + a call to <i>binfree</i>.<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/libbin<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/malloc.html"><i>malloc</i>(3)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>binalloc</i> and <i>bingrow</i> return 0 if there is no available memory.<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> diff --git a/man/man3/bio.html b/man/man3/bio.html new file mode 100644 index 00000000..78259922 --- /dev/null +++ b/man/man3/bio.html @@ -0,0 +1,293 @@ +<head> +<title>bio(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>BIO(3)</b><td align=right><b>BIO(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> + + Bopen, Bfdopen, Binit, Binits, Brdline, Brdstr, Bgetc, Bgetrune, + Bgetd, Bungetc, Bungetrune, Bread, Bseek, Boffset, Bfildes, Blinelen, + Bputc, Bputrune, Bprint, Bvprint, Bwrite, Bflush, Bterm, Bbuffered + – buffered input/output<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 <bio.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Biobuf* Bopen(char *file, int mode) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Biobuf* Bfdopen(int fd, int mode) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int Binit(Biobuf *bp, int fd, int mode) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int Binits(Biobufhdr *bp, int fd, int mode, uchar *buf, int size) + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int Bterm(Biobufhdr *bp) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int Bprint(Biobufhdr *bp, char *format, ...) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int Bvprint(Biobufhdr *bp, char *format, va_list arglist); + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void* Brdline(Biobufhdr *bp, int delim) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* Brdstr(Biobufhdr *bp, int delim, int nulldelim) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int Blinelen(Biobufhdr *bp) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>vlong Boffset(Biobufhdr *bp) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int Bfildes(Biobufhdr *bp) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int Bgetc(Biobufhdr *bp) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long Bgetrune(Biobufhdr *bp) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int Bgetd(Biobufhdr *bp, double *d) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int Bungetc(Biobufhdr *bp) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int Bungetrune(Biobufhdr *bp) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>vlong Bseek(Biobufhdr *bp, vlong n, int type) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int Bputc(Biobufhdr *bp, int c) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int Bputrune(Biobufhdr *bp, long c) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long Bread(Biobufhdr *bp, void *addr, long nbytes) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long Bwrite(Biobufhdr *bp, void *addr, long nbytes) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int Bflush(Biobufhdr *bp) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int Bbuffered(Biobufhdr *bp) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </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 routines implement fast buffered I/O. I/O on different file + descriptors is independent. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Bopen</i> opens <i>file</i> for mode <tt><font size=+1>OREAD</font></tt> or creates for mode <tt><font size=+1>OWRITE</font></tt>. It + calls <a href="../man3/malloc.html"><i>malloc</i>(3)</a> to allocate a buffer. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Bfdopen</i> allocates a buffer for the already-open file descriptor + <i>fd</i> for mode <tt><font size=+1>OREAD</font></tt> or <tt><font size=+1>OWRITE</font></tt>. It calls <a href="../man3/malloc.html"><i>malloc</i>(3)</a> to allocate a + buffer. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Binit</i> initializes a standard size buffer, type <i>Biobuf</i>, with the + open file descriptor passed in by the user. <i>Binits</i> initializes + a non-standard size buffer, type <i>Biobufhdr</i>, with the open file + descriptor, buffer area, and buffer size passed in by the user. + <i>Biobuf</i> and <i>Biobufhdr</i> are related by the declaration: + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef struct Biobuf Biobuf;<br> + struct Biobuf<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Biobufhdr;<br> + uchar b[Bungetsize+Bsize];<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + Arguments of types pointer to Biobuf and pointer to Biobufhdr + can be used interchangeably in the following routines. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Bopen</i>, <i>Binit</i>, or <i>Binits</i> should be called before any of the other + routines on that buffer. <i>Bfildes</i> returns the integer file descriptor + of the associated open file. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Bterm</i> flushes the buffer for <i>bp</i>. If the buffer was allocated by + <i>Bopen</i>, the buffer is <i>freed</i> and the file is closed. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Brdline</i> reads a string from the file associated with <i>bp</i> up to + and including the first <i>delim</i> character. The delimiter character + at the end of the line is not altered. <i>Brdline</i> returns a pointer + to the start of the line or <tt><font size=+1>0</font></tt> on end-of-file or read error. <i>Blinelen</i> + returns the length (including the delimiter) of the most recent + string + returned by <i>Brdline</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Brdstr</i> returns a <a href="../man3/malloc.html"><i>malloc</i>(3)</a>-allocated buffer containing the next + line of input delimited by <i>delim</i>, terminated by a NUL (0) byte. + Unlike <i>Brdline</i>, which returns when its buffer is full even if + no delimiter has been found, <i>Brdstr</i> will return an arbitrarily + long line in a single call. If <i>nulldelim</i> is set, the terminal + delimiter will be + overwritten with a NUL. After a successful call to <i>Brdstr</i>, the + return value of <i>Blinelen</i> will be the length of the returned buffer, + excluding the NUL. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Bgetc</i> returns the next character from <i>bp</i>, or a negative value + at end of file. <i>Bungetc</i> may be called immediately after <i>Bgetc</i> + to allow the same character to be reread. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Bgetrune</i> calls <i>Bgetc</i> to read the bytes of the next UTF sequence + in the input stream and returns the value of the rune represented + by the sequence. It returns a negative value at end of file. <i>Bungetrune</i> + may be called immediately after <i>Bgetrune</i> to allow the same UTF + sequence to be reread as either bytes or a rune. + <i>Bungetc</i> and <i>Bungetrune</i> may back up a maximum of five bytes. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Bgetd</i> uses <i>charstod</i> (see <a href="../man3/atof.html"><i>atof</i>(3)</a>) and <i>Bgetc</i> to read the formatted + floating-point number in the input stream, skipping initial blanks + and tabs. The value is stored in <tt><font size=+1>*d. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <i>Bread</i> reads <i>nbytes</i> of data from <i>bp</i> into memory starting at <i>addr</i>. + The number of bytes read is returned on success and a negative + value is returned if a read error occurred. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Bseek</i> applies <a href="../man3/seek.html"><i>seek</i>(3)</a> to <i>bp</i>. It returns the new file offset. <i>Boffset</i> + returns the file offset of the next character to be processed. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Bputc</i> outputs the low order 8 bits of <i>c</i> on <i>bp</i>. If this causes + a <i>write</i> to occur and there is an error, a negative value is returned. + Otherwise, a zero is returned. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Bputrune</i> calls <i>Bputc</i> to output the low order 16 bits of <i>c</i> as a + rune in UTF format on the output stream. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Bprint</i> is a buffered interface to <a href="../man3/print.html"><i>print</i>(3)</a>. If this causes a <i>write</i> + to occur and there is an error, a negative value (<tt><font size=+1>Beof</font></tt>) is returned. + Otherwise, the number of bytes output is returned. <i>Bvprint</i> does + the same except it takes as argument a <tt><font size=+1>va_list</font></tt> parameter, so it + can be called within a variadic function. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Bwrite</i> outputs <i>nbytes</i> of data starting at <i>addr</i> to <i>bp</i>. If this + causes a <i>write</i> to occur and there is an error, a negative value + is returned. Otherwise, the number of bytes written is returned. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Bflush</i> causes any buffered output associated with <i>bp</i> to be written. + The return is as for <i>Bputc</i>. <i>Bflush</i> is called on exit for every + buffer still open for writing. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Bbuffered</i> returns the number of bytes in the buffer. When reading, + this is the number of bytes still available from the last read + on the file; when writing, it is the number of bytes ready to + be written.<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/libbio<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/open.html"><i>open</i>(3)</a>, <a href="../man3/print.html"><i>print</i>(3)</a>, <a href="../man3/exits.html"><i>exits</i>(3)</a>, <a href="../man7/utf.html"><i>utf</i>(7)</a>,<br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Bio</i> routines that return integers yield <tt><font size=+1>Beof</font></tt> if <i>bp</i> is not the + descriptor of an open file. <i>Bopen</i> returns zero if the file cannot + be opened in the given mode. All routines set <i>errstr</i> on error.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Brdline</i> returns an error on strings longer than the buffer associated + with the file and also if the end-of-file is encountered before + a delimiter. <i>Blinelen</i> will tell how many characters are available + in these cases. In the case of a true end-of-file, <i>Blinelen</i> will + return zero. At the cost of allocating a buffer, <i>Brdstr</i> sidesteps + these issues. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The data returned by <i>Brdline</i> may be overwritten by calls to any + other <i>bio</i> routine on the same <i>bp.</i><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> diff --git a/man/man3/blowfish.html b/man/man3/blowfish.html new file mode 100644 index 00000000..d8da66de --- /dev/null +++ b/man/man3/blowfish.html @@ -0,0 +1,95 @@ +<head> +<title>blowfish(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>BLOWFISH(3)</b><td align=right><b>BLOWFISH(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> + + setupBFstate, bfCBCencrypt, bfCBCdecrypt, bfECBencrypt, bfECBdecrypt + - blowfish encryption<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 <mp.h><br> + #include <libsec.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void setupBFstate(BFstate *s, uchar key[], int keybytes, uchar + *ivec) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void bfCBCencrypt(uchar *data, int len, BFstate *s) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void bfCBCdecrypt(uchar *data, int len, BFstate *s) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void bfECBencrypt(uchar *data, int len, BFstate *s) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void bfECBdecrypt(uchar *data, int len, BFstate *s)<br> + </font></tt> +</table> +<p><font size=+1><b>DESCRIPTION </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Blowfish is Bruce Schneier’s symmetric block cipher. It supports + variable length keys from 32 to 448 bits and has a block size + of 64 bits. Both CBC and ECB modes are supported. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + setupBFstate takes a BFstate structure, a key of at most 56 bytes, + the length of the key in bytes, and an initialization vector of + 8 bytes (set to all zeroes if argument is nil). The encryption + and decryption functions take a BFstate structure, a data buffer, + and a length, which must be a multiple of eight bytes as padding + is + currently unsupported.<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/libsec<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/mp.html"><i>mp</i>(3)</a>, <a href="../man3/aes.html"><i>aes</i>(3)</a>, <a href="../man3/des.html"><i>des</i>(3)</a>, <a href="../man3/dsa.html"><i>dsa</i>(3)</a>, <a href="../man3/elgamal.html"><i>elgamal</i>(3)</a>, <a href="../man3/rc4.html"><i>rc4</i>(3)</a>, <a href="../man3/rsa.html"><i>rsa</i>(3)</a>, <a href="../man3/sechash.html"><i>sechash</i>(3)</a>, + <a href="../man3/prime.html"><i>prime</i>(3)</a>, <a href="../man3/rand.html"><i>rand</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> diff --git a/man/man3/cachechars.html b/man/man3/cachechars.html new file mode 100644 index 00000000..382b5e7e --- /dev/null +++ b/man/man3/cachechars.html @@ -0,0 +1,292 @@ +<head> +<title>cachechars(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>CACHECHARS(3)</b><td align=right><b>CACHECHARS(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> + + cachechars, agefont, loadchar, Subfont, Fontchar, Font – font utilities<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 <draw.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>int cachechars(Font *f, char **s, Rune **r, ushort *c, int max, + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>int *widp, char **sfname) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + + </table> + <tt><font size=+1>int loadchar(Font *f, Rune r, Cacheinfo *c, int h, + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>int noclr, char **sfname) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + + </table> + <tt><font size=+1>void agefont(Font *f)<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> + + A <i>Font</i> may contain too many characters to hold in memory simultaneously. + The graphics library and draw device (see <a href="../man3/draw.html"><i>draw</i>(3)</a>) cooperate to + solve this problem by maintaining a cache of recently used character + images. The details of this cooperation need not be known by most + programs: <i>initdraw</i> and its associated + <i>font</i> variable, <i>openfont</i>, <i>stringwidth</i>, <i>string</i>, and <i>freefont</i> are + sufficient for most purposes. The routines described below are + used internally by the graphics library to maintain the font cache. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + A <tt><font size=+1>Subfont</font></tt> is a set of images for a contiguous range of characters, + stored as a single image with the characters placed side-by-side + on a common baseline. It is described by the following data structures.<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef<br> + struct Fontchar {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int x; /* left edge of bits */<br> + uchar top; /* first non−zero scan−line */<br> + uchar bottom; /* last non−zero scan−line */<br> + char left; /* offset of baseline */<br> + uchar width; /* width of baseline */<br> + + </table> + } Fontchar;<br> + typedef<br> + struct Subfont {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + char *name;<br> + short n; /* number of chars in subfont */<br> + uchar height; /* height of image */<br> + char ascent; /* top of image to baseline */<br> + Fontchar *info; /* n+1 Fontchars */<br> + Image *bits; /* of font */<br> + + </table> + } Subfont;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + The image fills the rectangle <tt><font size=+1>(0, 0,</font></tt> <i>w</i><tt><font size=+1>, height)</font></tt>, where <i>w</i> is the + sum of the horizontal extents (of non-zero pixels) for all characters. + The pixels to be displayed for character <i>c</i> are in the rectangle + <tt><font size=+1>(</font></tt><i>i</i><tt><font size=+1>−>x,</font></tt> <i>i</i><tt><font size=+1>−>top, (</font></tt><i>i</i><tt><font size=+1>+1)−>x,</font></tt> <i>i</i><tt><font size=+1>−>bottom)</font></tt> where <i>i</i> is <tt><font size=+1>&subfont−>info[</font></tt><i>c</i><tt><font size=+1>]</font></tt>. When + a character is displayed + at <tt><font size=+1>Point p</font></tt> in an image, the character rectangle is placed at <tt><font size=+1>(p.x+</font></tt><i>i</i><tt><font size=+1>−>left, + p.y)</font></tt> and the next character of the string is displayed at <tt><font size=+1>(p.x+</font></tt><i>i</i><tt><font size=+1>−>width, + p.y)</font></tt>. The baseline of the characters is <tt><font size=+1>ascent</font></tt> rows down from + the top of the subfont image. The <tt><font size=+1>info</font></tt> array has <tt><font size=+1>n+1</font></tt> elements, + one each for characters 0 + to <tt><font size=+1>n−1</font></tt> plus an additional entry so the size of the last character + can be calculated. Thus the width, <i>w</i>, of the <tt><font size=+1>Image</font></tt> associated + with a <tt><font size=+1>Subfont s</font></tt> is <tt><font size=+1>s−>info[s−>n].x</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + A <tt><font size=+1>Font</font></tt> consists of an overall height and ascent and a collection + of subfonts together with the ranges of runes (see <a href="../man7/utf.html"><i>utf</i>(7)</a>) they + represent. Fonts are described by the following structures.<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef<br> + struct Cachefont {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Rune min; /* value of 0th char in subfont */<br> + Rune max; /* value+1 of last char in subfont */<br> + int offset; /* posn in subfont of char at min */<br> + char *name; /* stored in font */<br> + char *subfontname;/* to access subfont */<br> + + </table> + } Cachefont;<br> + typedef<br> + struct Cacheinfo {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + ushort x; /* left edge of bits */<br> + uchar width; /* width of baseline */<br> + schar left; /* offset of baseline */<br> + Rune value; /* of char at this slot in cache */<br> + ushort age;<br> + + </table> + } Cacheinfo;<br> + typedef<br> + struct Cachesubf {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + ulong age; /* for replacement */<br> + Cachefont *cf; /* font info that owns us */<br> + Subfont *f; /* attached subfont */<br> + + </table> + } Cachesubf;<br> + typedef<br> + struct Font {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + char *name;<br> + Display *display;<br> + short height; /* max ht of image;interline space*/<br> + short ascent; /* top of image to baseline */<br> + short width; /* widest so far; used in caching */<br> + short nsub; /* number of subfonts */<br> + ulong age; /* increasing counter; for LRU */<br> + int ncache; /* size of cache */<br> + int nsubf; /* size of subfont list */<br> + Cacheinfo *cache;<br> + Cachesubf *subf;<br> + Cachefont **sub; /* as read from file */<br> + Image *cacheimage;<br> + + </table> + } Font;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + The <tt><font size=+1>height</font></tt> and <tt><font size=+1>ascent</font></tt> fields of Font are described in <a href="../man3/graphics.html"><i>graphics</i>(3)</a>. + <tt><font size=+1>Sub</font></tt> contains <tt><font size=+1>nsub</font></tt> pointers to <tt><font size=+1>Cachefonts</font></tt>. A <tt><font size=+1>Cachefont</font></tt> connects + runes <tt><font size=+1>min</font></tt> through <tt><font size=+1>max</font></tt>, inclusive, to the subfont with file name + <tt><font size=+1>name</font></tt>; it corresponds to a line of the file describing the font. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The characters are taken from the subfont starting at character + number <tt><font size=+1>offset</font></tt> (usually zero) in the subfont, permitting selection + of parts of subfonts. Thus the image for rune <i>r</i> is found in position + <i>r</i><tt><font size=+1>−min+offset</font></tt> of the subfont. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + For each font, the library, with support from the graphics server, + maintains a cache of subfonts and a cache of recently used character + images. The <tt><font size=+1>subf</font></tt> and <tt><font size=+1>cache</font></tt> fields are used by the library to maintain + these caches. The <tt><font size=+1>width</font></tt> of a font is the maximum of the horizontal + extents of the characters in the cache. + <i>String</i> draws a string by loading the cache and emitting a sequence + of cache indices to draw. <i>Cachechars</i> guarantees the images for + the characters pointed to by <i>*s</i> or <i>*r</i> (one of these must be nil + in each call) are in the cache of <i>f</i>. It calls <i>loadchar</i> to put + missing characters into the cache. <i>Cachechars</i> translates the + character string into a set of cache indices which it loads into + the array <i>c</i>, up to a maximum of <i>n</i> indices or the length of the + string. <i>Cachechars</i> returns in <i>c</i> the number of cache indices emitted, + updates <i>*s</i> to point to the next character to be processed, and + sets <i>*widp</i> to the total width of the characters processed. + <i>Cachechars</i> may return before the end of the string if it cannot + proceed without destroying active data in the caches. If it needs + to load a new subfont, it will fill <tt><font size=+1>*sfname</font></tt> with the name of the + subfont it needs and return –1. It can return zero if it is unable + to make progress because it cannot resize the caches. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Loadchar</i> loads a character image into the character cache. Then + it tells the graphics server to copy the character into position + <i>h</i> in the character cache. If the current font <tt><font size=+1>width</font></tt> is smaller + than the horizontal extent of the character being loaded, <i>loadfont</i> + clears the cache and resets it to accept characters with the + bigger width, unless <i>noclr</i> is set, in which case it just returns + –1. If the character does not exist in the font at all, <i>loadfont</i> + returns 0; if it is unable to load the character without destroying + cached information, it returns –1, updating <tt><font size=+1>*sfname</font></tt> as described + above. It returns 1 to indicate success. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The <tt><font size=+1>age</font></tt> fields record when subfonts and characters have been used. + The font <tt><font size=+1>age</font></tt> is increased every time the font is used (<i>agefont</i> + does this). A character or subfont <tt><font size=+1>age</font></tt> is set to the font age + at each use. Thus, characters or subfonts with small ages are + the best candidates for replacement when the cache is full. + +</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/libdraw<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/graphics.html"><i>graphics</i>(3)</a>, <a href="../man3/allocimage.html"><i>allocimage</i>(3)</a>, <a href="../man3/draw.html"><i>draw</i>(3)</a>, <a href="../man3/subfont.html"><i>subfont</i>(3)</a>, <a href="../man7/image.html"><i>image</i>(7)</a>, <a href="../man7/font.html"><i>font</i>(7)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + All of the functions use the graphics error function (see <a href="../man3/graphics.html"><i>graphics</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> diff --git a/man/man3/cleanname.html b/man/man3/cleanname.html new file mode 100644 index 00000000..eba39965 --- /dev/null +++ b/man/man3/cleanname.html @@ -0,0 +1,71 @@ +<head> +<title>cleanname(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>CLEANNAME(3)</b><td align=right><b>CLEANNAME(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> + + cleanname – clean a path name<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> + char* cleanname(char *filename)<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> + + <i>Cleanname</i> takes a <i>filename</i> and by lexical processing only returns + the shortest string that names the same (possibly hypothetical) + file. It eliminates multiple and trailing slashes, and it lexically + interprets <tt><font size=+1>.</font></tt> and <tt><font size=+1>..</font></tt> directory components in the name. The string + is overwritten in place. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The shortest string <i>cleanname</i> can return is two bytes: the null-terminated + string <tt><font size=+1>"."</font></tt>. Therefore <i>filename</i> must contain room for at least two + bytes.<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/lib9/cleanname.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="../man1/cleanname.html"><i>cleanname</i>(1)</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> diff --git a/man/man3/color.html b/man/man3/color.html new file mode 100644 index 00000000..a8274707 --- /dev/null +++ b/man/man3/color.html @@ -0,0 +1,89 @@ +<head> +<title>color(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>COLOR(3)</b><td align=right><b>COLOR(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> + + cmap2rgb, cmap2rgba, rgb2cmap – colors and color maps<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 <draw.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int rgb2cmap(int red, int green, int blue) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int cmap2rgb(int col) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int cmap2rgba(int col)<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 routines convert between ‘true color’ red/green/blue triples + and the Plan 9 color map. See <a href="../man7/color.html"><i>color</i>(7)</a> for a description of RGBV, + the standard color map. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Rgb2cmap</i> takes a trio of color values, scaled from 0 (no intensity) + to 255 (full intensity), and returns the index of the color in + RGBV closest to that represented by those values. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Cmap2rgb</i> decomposes the color of RGBV index <i>col</i> and returns a + 24-bit integer with the low 8 bits representing the blue value, + the next 8 representing green, and the next 8 representing red. + <i>Cmap2rgba</i> decomposes the color of RGBV index <i>col</i> and returns a + 32-bit integer with the low 8 bits representing an alpha + value, defined to be 255, and the next 8 representing blue, then + green, then red, as for <i>cmap2rgba</i> shifted up 8 bits. This 32-bit + representation is the format used by <a href="../man3/draw.html"><i>draw</i>(3)</a> and <a href="../man3/memdraw.html"><i>memdraw</i>(3)</a> library + routines that take colors as arguments.<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/libdraw<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/graphics.html"><i>graphics</i>(3)</a>, <a href="../man3/allocimage.html"><i>allocimage</i>(3)</a>, <a href="../man3/draw.html"><i>draw</i>(3)</a>, <a href="../man7/image.html"><i>image</i>(7)</a>, <a href="../man7/color.html"><i>color</i>(7)</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> diff --git a/man/man3/complete.html b/man/man3/complete.html new file mode 100644 index 00000000..29453752 --- /dev/null +++ b/man/man3/complete.html @@ -0,0 +1,136 @@ +<head> +<title>complete(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>COMPLETE(3)</b><td align=right><b>COMPLETE(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> + + complete, freecompletion – file name completion<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 <complete.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>typedef struct CompletionCompletion;<br> + struct Completion{<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + uchar advance;<br> + uchar complete;<br> + char *string;<br> + int nmatch;<br> + int nfile;<br> + char **filename;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Completion* complete(char *dir, char *s); + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void freecompletion(Completion *c);<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> + + The <i>complete</i> function implements file name completion. Given a + directory <i>dir</i> and a string <i>s</i>, it returns an analysis of the file + names in that directory that begin with the string <i>s</i>. The fields + <tt><font size=+1>nmatch</font></tt> and <tt><font size=+1>nfile</font></tt> will be set to the number of files that match + the prefix and <tt><font size=+1>filename</font></tt> will be filled in with their names. If + the file named is a directory, a slash character will be appended + to it. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + If no files match the string, <tt><font size=+1>nmatch</font></tt> will be zero, but <i>complete</i> + will return the full set of files in the directory, with <i>nfile</i> + set to their number. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The flag <tt><font size=+1>advance</font></tt> reports whether the string <i>s</i> can be extended + without changing the set of files that match. If true, <tt><font size=+1>string</font></tt> + will be set to the extension; that is, the value of <tt><font size=+1>string</font></tt> may + be appended to <i>s</i> by the caller to extend the embryonic file name + unambiguously. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The flag <tt><font size=+1>complete</font></tt> reports whether the extended file name uniquely + identifies a file. If true, <tt><font size=+1>string</font></tt> will be suffixed with a blank, + or a slash and a blank, depending on whether the resulting file + name identifies a plain file or a directory. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The <i>freecompletion</i> function frees a <tt><font size=+1>Completion</font></tt> structure and its + contents. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + In <a href="../man1/rio.html"><i>rio</i>(1)</a> and <a href="../man1/acme.html"><i>acme</i>(1)</a>, file name completion is triggered by a + control-F character or an Insert character.<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/libcomplete<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="../man1/rio.html"><i>rio</i>(1)</a>, <a href="../man1/acme.html"><i>acme</i>(1)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The <i>complete</i> function returns a null pointer and sets <i>errstr</i> if + the directory is unreadable or there is some other error.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The behavior of file name completion should be controlled by the + plumber.<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> diff --git a/man/man3/cputime.html b/man/man3/cputime.html new file mode 100644 index 00000000..fafc7f57 --- /dev/null +++ b/man/man3/cputime.html @@ -0,0 +1,65 @@ +<head> +<title>cputime(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>CPUTIME(3)</b><td align=right><b>CPUTIME(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> + + cputime, times – cpu time in this process and children<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int times(long t[4]) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>double cputime(void)<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> + + If <i>t</i> is non-null, <i>times</i> fills it in with the number of milliseconds + spent in user code, system calls, child processes in user code, + and child processes in system calls. <i>Cputime</i> returns the sum of + those same times, converted to seconds. <i>Times</i> returns the elapsed + real time, in milliseconds, that the process has been + running.<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/lib9/time.c<br> + </font></tt> +</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> diff --git a/man/man3/ctime.html b/man/man3/ctime.html new file mode 100644 index 00000000..4c162391 --- /dev/null +++ b/man/man3/ctime.html @@ -0,0 +1,150 @@ +<head> +<title>ctime(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>CTIME(3)</b><td align=right><b>CTIME(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> + + ctime, localtime, gmtime, asctime, tm2sec, timezone – convert date + and time<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* ctime(long clock) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Tm* localtime(long clock) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Tm* gmtime(long clock) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* asctime(Tm *tm) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long tm2sec(Tm *tm)<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> + + <i>Ctime</i> converts a time <i>clock</i> such as returned by <a href="../man3/time.html"><i>time</i>(3)</a> into ASCII + (sic) and returns a pointer to a 30-byte string in the following + form. All the fields have constant width. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>Wed Aug 5 01:07:47 EST 1973\n\0 + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + + </table> + <i>Localtime</i> and <i>gmtime</i> return pointers to structures containing + the broken-down time. <i>Localtime</i> corrects for the time zone and + possible daylight savings time; <i>gmtime</i> converts directly to GMT. + <i>Asctime</i> converts a broken-down time to ASCII and returns a pointer + to a 30-byte string.<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef<br> + struct {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int sec; /* seconds (range 0..59) */<br> + int min; /* minutes (0..59) */<br> + int hour; /* hours (0..23) */<br> + int mday; /* day of the month (1..31) */<br> + int mon; /* month of the year (0..11) */<br> + int year; /* year A.D. – 1900 */<br> + int wday; /* day of week (0..6, Sunday = 0) */<br> + int yday; /* day of year (0..365) */<br> + char zone[4]; /* time zone name */<br> + int tzoff; /* time zone delta from GMT */<br> + + </table> + } Tm;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + <i>Tm2sec</i> converts a broken-down time to seconds since the start + of the epoch. It ignores <tt><font size=+1>wday</font></tt>, and assumes the local time zone + if <tt><font size=+1>zone</font></tt> is not <tt><font size=+1>GMT</font></tt>.<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/lib9/date.c<br> + /usr/local/plan9/src/lib9/ctime.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="../man1/date.html"><i>date</i>(1)</a>, <a href="../man3/time.html"><i>time</i>(3)</a><br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The return values point to static data whose content is overwritten + by each call. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Daylight Savings Time is “normal” in the Southern hemisphere. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + These routines are not equipped to handle non-ASCII text, and + are provincial anyway. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + To avoid name conflicts with the underlying system, <i>ctime</i>, <i>localtime</i>, + <i>gmtime</i>, <i>asctime</i>, and <i>tm2sec</i> are preprocessor macros defined as + <i>p9ctime</i>, <i>p9localtime</i>, <i>p9gmtime</i>, <i>p9asctime</i>, and <i>p9tm2sec</i>; see <a href="../man3/intro.html"><i>intro</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> diff --git a/man/man3/des.html b/man/man3/des.html new file mode 100644 index 00000000..0752e8c8 --- /dev/null +++ b/man/man3/des.html @@ -0,0 +1,170 @@ +<head> +<title>des(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>DES(3)</b><td align=right><b>DES(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> + + setupDESstate, des_key_setup, block_cipher, desCBCencrypt, desCBCdecrypt, + desECBencrypt, desECBdecrypt, des3CBCencrypt, des3CBCdecrypt, + des3ECBencrypt, des3ECBdecrypt, key_setup, des56to64, des64to56, + setupDES3state, triple_block_cipher, - single and triple digital + encryption standard + +</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 <mp.h><br> + #include <libsec.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void des_key_setup(uchar key[8], ulong schedule[32]) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void block_cipher(ulong *schedule, uchar *data, int decrypting) + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void setupDESstate(DESstate *s, uchar key[8], uchar *ivec) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void desCBCencrypt(uchar*, int, DESstate*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void desCBCdecrypt(uchar*, int, DESstate*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void desECBencrypt(uchar*, int, DESstate*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void desECBdecrypt(uchar*, int, DESstate*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void triple_block_cipher(ulong keys[3][32], uchar*, int) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void setupDES3state(DES3state *s, uchar key[3][8], uchar *ivec) + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void des3CBCencrypt(uchar*, int, DES3state*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void des3CBCdecrypt(uchar*, int, DES3state*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void des3ECBencrypt(uchar*, int, DES3state*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void des3ECBdecrypt(uchar*, int, DES3state*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void key_setup(uchar[7], ulong[32]) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void des56to64(uchar *k56, uchar *k64) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void des64to56(uchar *k64, uchar *k56)<br> + </font></tt> +</table> +<p><font size=+1><b>DESCRIPTION </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The Digital Encryption Standard (DES) is a shared key or symmetric + encryption using either a 56 bit key for single DES or three 56 + bit keys for triple des. The keys are encoded into 64 bits where + every eight bit is parity. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The basic DES function, <i>block_cipher</i>, works on a block of 8 bytes, + converting them in place. It takes a key schedule, a pointer to + the block, and a flag indicating encrypting (0) or decrypting + (1). The key schedule is created from the key using <i>des_key_setup</i>. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Since it is a bit awkward, <i>block_cipher</i> is rarely called directly. + Instead, one normally uses routines that encrypt larger buffers + of data and which may chain the encryption state from one buffer + to the next. These routines keep track of the state of the encryption + using a <tt><font size=+1>DESstate</font></tt> structure that contains the key + schedule and any chained state. <i>SetupDESstate</i> sets up the <tt><font size=+1>DESstate</font></tt> + structure using the key and an 8 byte initialization vector. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Electronic code book, using <i>desECBencrypt</i> and <i>desECBdecrypt</i>, is + the less secure mode. The encryption of each 8 bytes does not + depend on the encryption of any other. Hence the encryption is + a substitution cipher using 64 bit characters. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Cipher block chaining mode, using <i>desCBCencrypt</i> and <i>desCBCdecrypt</i>, + is more secure. Every block encrypted depends on the initialization + vector and all blocks encrypted before it. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + For both CBC and ECB modes, a stream of data can be encrypted + as multiple buffers. However, all buffers except the last must + be a multiple of 8 bytes to ensure successful decryption of the + stream. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + There are equivalent triple DES functions for each of the DES + functions. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + In the past Plan 9 used a 56 bit or 7 byte format for DES keys. + To be compatible with the rest of the world, we’ve abandoned this + format. There are two functions: <i>des56to64</i> and <i>des64to56</i> to convert + back and forth between the two formats. Also a key schedule can + be set up from the 7 byte format using <i>key_setup</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +</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/libsec<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/mp.html"><i>mp</i>(3)</a>, <a href="../man3/aes.html"><i>aes</i>(3)</a>, <a href="../man3/blowfish.html"><i>blowfish</i>(3)</a>, <a href="../man3/dsa.html"><i>dsa</i>(3)</a>, <a href="../man3/elgamal.html"><i>elgamal</i>(3)</a>, <a href="../man3/rc4.html"><i>rc4</i>(3)</a>, <a href="../man3/rsa.html"><i>rsa</i>(3)</a>, + <a href="../man3/sechash.html"><i>sechash</i>(3)</a>, <a href="../man3/prime.html"><i>prime</i>(3)</a>, <a href="../man3/rand.html"><i>rand</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> diff --git a/man/man3/dial.html b/man/man3/dial.html new file mode 100644 index 00000000..e1014859 --- /dev/null +++ b/man/man3/dial.html @@ -0,0 +1,241 @@ +<head> +<title>dial(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>DIAL(3)</b><td align=right><b>DIAL(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> + + dial, announce, listen, accept, reject, netmkaddr, dialparse – + make and break network connections<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int dial(char *addr, char *local, char *dir, int *cfdp) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int announce(char *addr, char *dir) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int listen(char *dir, char *newdir) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int accept(int ctl, char *dir) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int reject(int ctl, char *dir, char *cause) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* netmkaddr(char *addr, char *defnet, char *defservice) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int dialparse(char *addr, char **net, char **unix,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + u32int *host, int *port)<br> + + </table> + + </table> + </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> + + For these routines, <i>addr</i> is a network address of the form <i>network</i><tt><font size=+1>!</font></tt><i>netaddr</i><tt><font size=+1>!</font></tt><i>service</i>, + <i>network</i><tt><font size=+1>!</font></tt><i>netaddr</i>, or simply <i>netaddr</i>. <i>Network</i> is <tt><font size=+1>tcp</font></tt>, <tt><font size=+1>udp</font></tt>, <tt><font size=+1>unix</font></tt>, + or the special token, <tt><font size=+1>net</font></tt>. <tt><font size=+1>Net</font></tt> is a free variable that stands + for any network in common between the source and the host <i>netaddr</i>. + <i>Netaddr</i> can be a host name, a + domain name, or a network address. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + On Plan 9, the <i>dir</i> argument is a path name to a <i>line directory</i> + that has files for accessing the connection. To keep the same + function signatures, the Unix port of these routines uses strings + of the form <tt><font size=+1>/dev/fd/</font></tt><i>n</i> instead of line directory paths. These strings + should be treated as opaque data and ignored. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Dial</i> makes a call to destination <i>addr</i> on a multiplexed network. + If the network in <i>addr</i> is <tt><font size=+1>net</font></tt>, <i>dial</i> will try in succession all + networks in common between source and destination until a call + succeeds. It returns a file descriptor open for reading and writing + the <tt><font size=+1>data</font></tt> file in the line directory. The <tt><font size=+1>addr</font></tt> file in the line + directory contains the address called. <i>Dial</i>’s <i>local</i>, <i>dir</i>, and + <i>cfdp</i> arguments are not supported and must be zero. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Announce</i> and <i>listen</i> are the complements of <i>dial</i>. <i>Announce</i> establishes + a network name to which calls can be made. Like <i>dial</i>, <i>announce</i> + returns an open <tt><font size=+1>ctl</font></tt> file. The <i>netaddr</i> used in announce may be + a local address or an asterisk, to indicate all local addresses, + e.g. <tt><font size=+1>tcp!*!echo</font></tt>. The <i>listen</i> routine takes as its + first argument the <i>dir</i> of a previous <i>announce</i>. When a call is + received, <i>listen</i> returns an open <tt><font size=+1>ctl</font></tt> file for the line the call + was received on. It sets <i>newdir</i> to the path name of the new line + directory. <i>Accept</i> accepts a call received by <i>listen</i>, while <i>reject</i> + refuses the call because of <i>cause</i>. <i>Accept</i> returns a file descriptor + for + the data file opened <tt><font size=+1>ORDWR</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Netmkaddr</i> makes an address suitable for dialing or announcing. + It takes an address along with a default network and service to + use if they are not specified in the address. It returns a pointer + to static data holding the actual address to use. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Dialparse</i> parses a network address as described above into a network + name, a Unix domain socket address, an IPv4 host address, and + an IPv4 port number.<br> + +</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> + + Make a call and return an open file descriptor to use for communications:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>int callkremvax(void)<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + return dial("kremvax", 0, 0, 0);<br> + + </table> + }<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + Connect to a Unix socket served by <a href="../man4/acme.html"><i>acme</i>(4)</a>:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>int dialacme(void)<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + return dial("unix!/tmp/ns.ken.:0/acme", 0, 0, 0);<br> + + </table> + }<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + Announce as <tt><font size=+1>kremvax</font></tt> on TCP/IP and loop forever receiving calls + and echoing back to the caller anything sent:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>int<br> + bekremvax(void)<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int dfd, acfd, lcfd;<br> + char adir[40], ldir[40];<br> + int n;<br> + char buf[256];<br> + acfd = announce("tcp!*!7", adir);<br> + if(acfd < 0)<br> + return −1;<br> + for(;;){<br> + /* listen for a call */<br> + lcfd = listen(adir, ldir);<br> + if(lcfd < 0)<br> + return −1;<br> + /* fork a process to echo */<br> + switch(fork()){<br> + case −1:<br> + perror("forking");<br> + close(lcfd);<br> + break;<br> + case 0:<br> + /* accept the call and open the data file */<br> + dfd = accept(lcfd, ldir);<br> + if(dfd < 0)<br> + return −1;<br> + /* echo until EOF */<br> + while((n = read(dfd, buf, sizeof(buf))) > 0)<br> + write(dfd, buf, n);<br> + exits(0);<br> + default:<br> + close(lcfd);<br> + break;<br> + }<br> + }<br> + + </table> + }<br> + </font></tt> + </table> + +</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/lib9/dial.c<br> + /usr/local/plan9/src/lib9/announce.c<br> + /usr/local/plan9/src/lib9/_p9dialparse.c<br> + </font></tt> +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Dial</i>, <i>announce</i>, and <i>listen</i> return –1 if they fail.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + To avoid name conflicts with the underlying system, <i>dial</i>, <i>announce</i>, + <i>listen</i>, <i>netmkaddr</i>, and <i>reject</i> are preprocessor macros defined + as <i>p9dial</i>, <i>p9announce</i>, and so on; see <a href="../man3/intro.html"><i>intro</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> diff --git a/man/man3/dirread.html b/man/man3/dirread.html new file mode 100644 index 00000000..7c5ba4ed --- /dev/null +++ b/man/man3/dirread.html @@ -0,0 +1,114 @@ +<head> +<title>dirread(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>DIRREAD(3)</b><td align=right><b>DIRREAD(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> + + dirread, dirreadall – read directory<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long dirread(int fd, Dir **buf) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long dirreadall(int fd, Dir **buf) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#define STATMAX 65535U + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#define DIRMAX (sizeof(Dir)+STATMAX)<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> + + The data returned by a <a href="../man3/read.html"><i>read</i>(3)</a> on a directory is a set of complete + directory entries in a machine-independent format, exactly equivalent + to the result of a <a href="../man3/stat.html"><i>stat</i>(3)</a> on each file or subdirectory in the + directory. <i>Dirread</i> decodes the directory entries into a machine-dependent + form. It reads from <i>fd</i> and unpacks the data + into an array of <tt><font size=+1>Dir</font></tt> structures whose address is returned in <tt><font size=+1>*buf</font></tt> + (see <a href="../man3/stat.html"><i>stat</i>(3)</a> for the layout of a <tt><font size=+1>Dir</font></tt>). The array is allocated + with <a href="../man3/malloc.html"><i>malloc</i>(3)</a> each time <i>dirread</i> is called. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Dirreadall</i> is like <i>dirread</i>, but reads in the entire directory; + by contrast, <i>dirread</i> steps through a directory one <a href="../man3/read.html"><i>read</i>(3)</a> at + a time. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Directory entries have variable length. A successful <i>read</i> of a + directory always returns an integral number of complete directory + entries; <i>dirread</i> always returns complete <tt><font size=+1>Dir</font></tt> structures. See <i>read</i>(9p) + for more information. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The constant <tt><font size=+1>STATMAX</font></tt> is the maximum size that a directory entry + can occupy. The constant <tt><font size=+1>DIRMAX</font></tt> is an upper limit on the size + necessary to hold a <tt><font size=+1>Dir</font></tt> structure and all the associated data. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Dirread</i> and <i>dirreadall</i> return the number of <tt><font size=+1>Dir</font></tt> structures filled + in <tt><font size=+1>buf</font></tt>. The file offset is advanced by the number of bytes actually + read.<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/lib9/dirread.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/intro.html"><i>intro</i>(3)</a>, <a href="../man3/open.html"><i>open</i>(3)</a>, <a href="../man3/read.html"><i>read</i>(3)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Dirread</i> and <i>Dirreadall</i> return zero for end of file and a negative + value for error. In either case, <tt><font size=+1>*buf</font></tt> is set to <tt><font size=+1>nil</font></tt> so the pointer + can always be freed with impunity. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + These functions set <i>errstr</i>.<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> diff --git a/man/man3/draw.html b/man/man3/draw.html new file mode 100644 index 00000000..f90b16fc --- /dev/null +++ b/man/man3/draw.html @@ -0,0 +1,1174 @@ +<head> +<title>draw(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>DRAW(3)</b><td align=right><b>DRAW(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> + + Image, draw, drawop, gendraw, gendrawop, drawreplxy, drawrepl, + replclipr, line, lineop, poly, polyop, fillpoly, fillpolyop, bezier, + bezierop, bezspline, bezsplineop, bezsplinepts, fillbezier, fillbezierop, + fillbezspline, fillbezsplineop, ellipse, ellipseop, fillellipse, + fillellipseop, arc, arcop, fillarc, fillarcop, icossin, icossin2, + border, string, stringop, stringn, stringnop, runestring, runestringop, + runestringn, runestringnop, stringbg, stringbgop, stringnbg, stringnbgop, + runestringbg, runestringbgop, runestringnbg, runestringnbgop, + _string, ARROW, drawsetdebug – graphics functions<br> + +</table> +<p><font size=+1><b>SYNOPSIS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<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 <draw.h><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + typedef<br> + struct Image<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Display *display; /* display holding data */<br> + int id; /* id of system−held Image */<br> + Rectangle r; /* rectangle in data area, local coords */<br> + Rectangle clipr; /* clipping region */<br> + ulong chan; /* pixel channel format descriptor */<br> + int depth; /* number of bits per pixel */<br> + int repl; /* flag: data replicates to tile clipr */<br> + Screen *screen; /* 0 if not a window */<br> + Image *next; /* next in list of windows */<br> + + </table> + } Image;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + typedef enum<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + /* Porter−Duff compositing operators */<br> + Clear = 0,<br> + SinD = 8,<br> + DinS = 4,<br> + SoutD = 2,<br> + DoutS = 1,<br> + S = SinD|SoutD,<br> + SoverD = SinD|SoutD|DoutS,<br> + SatopD = SinD|DoutS,<br> + SxorD = SoutD|DoutS,<br> + D = DinS|DoutS,<br> + DoverS = DinS|DoutS|SoutD,<br> + DatopS = DinS|SoutD,<br> + DxorS = DoutS|SoutD, /* == SxorD */<br> + Ncomp = 12,<br> + + </table> + } Drawop;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + void draw(Image *dst, Rectangle r, Image *src,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Image *mask, Point p)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + void drawop(Image *dst, Rectangle r, Image *src,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Image *mask, Point p, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + void gendraw(Image *dst, Rectangle r, Image *src, Point sp,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Image *mask, Point mp)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + void gendrawop(Image *dst, Rectangle r, Image *src, Point sp,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Image *mask, Point mp, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + int drawreplxy(int min, int max, int x)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Point drawrepl(Rectangle r, Point p)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + void replclipr(Image *i, int repl, Rectangle clipr)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + void line(Image *dst, Point p0, Point p1, int end0, int end1,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int radius, Image *src, Point sp)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + void lineop(Image *dst, Point p0, Point p1, int end0, int end1,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int radius, Image *src, Point sp, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + void poly(Image *dst, Point *p, int np, int end0, int end1,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int radius, Image *src, Point sp)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + void polyop(Image *dst, Point *p, int np, int end0, int end1,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int radius, Image *src, Point sp, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + void fillpoly(Image *dst, Point *p, int np, int wind,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Image *src, Point sp)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + void fillpolyop(Image *dst, Point *p, int np, int wind,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Image *src, Point sp, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + int bezier(Image *dst, Point p0, Point p1, Point p2, Point p3,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int end0, int end1, int radius, Image *src, Point sp)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + int bezierop(Image *dst, Point p0, Point p1, Point p2, Point p3,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int end0, int end1, int radius, Image *src, Point sp,<br> + Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + int bezspline(Image *dst, Point *pt, int npt, int end0, int end1,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int radius, Image *src, Point sp)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + int bezsplineop(Image *dst, Point *pt, int npt, int end0, int + end1,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int radius, Image *src, Point sp, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + int bezsplinepts(Point *pt, int npt, Point **pp)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + int fillbezier(Image *dst, Point p0, Point p1, Point p2, Point + p3,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int w, Image *src, Point sp)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + int fillbezierop(Image *dst, Point p0, Point p1, Point p2, Point + p3,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int w, Image *src, Point sp, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + int fillbezspline(Image *dst, Point *pt, int npt, int w,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Image *src, Point sp)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + int fillbezsplineop(Image *dst, Point *pt, int npt, int w,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Image *src, Point sp, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + void ellipse(Image *dst, Point c, int a, int b, int thick,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Image *src, Point sp)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + void ellipseop(Image *dst, Point c, int a, int b, int thick,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Image *src, Point sp, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + void fillellipse(Image *dst, Point c, int a, int b,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Image *src, Point sp)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + void fillellipseop(Image *dst, Point c, int a, int b,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Image *src, Point sp, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + void arc(Image *dst, Point c, int a, int b, int thick,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Image *src, Point sp, int alpha, int phi)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + void arcop(Image *dst, Point c, int a, int b, int thick,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Image *src, Point sp, int alpha, int phi, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + void fillarc(Image *dst, Point c, int a, int b, Image *src,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Point sp, int alpha, int phi)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + void fillarcop(Image *dst, Point c, int a, int b, Image *src,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Point sp, int alpha, int phi, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + int icossin(int deg, int *cosp, int *sinp)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + int icossin2(int x, int y, int *cosp, int *sinp)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + void border(Image *dst, Rectangle r, int i, Image *color, Point + sp)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Point string(Image *dst, Point p, Image *src, Point sp,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Font *f, char *s)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + Point stringop(Image *dst, Point p, Image *src, Point sp,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Font *f, char *s, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + Point stringn(Image *dst, Point p, Image *src, Point sp,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Font *f, char *s, int len)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + Point stringnop(Image *dst, Point p, Image *src, Point sp,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Font *f, char *s, int len, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + Point runestring(Image *dst, Point p, Image *src, Point sp,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Font *f, Rune *r)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + Point runestringop(Image *dst, Point p, Image *src, Point sp,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Font *f, Rune *r, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + Point runestringn(Image *dst, Point p, Image *src, Point sp,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Font *f, Rune *r, int len)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + Point runestringnop(Image *dst, Point p, Image *src, Point sp,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Font *f, Rune *r, int len, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + Point stringbg(Image *dst, Point p, Image *src, Point sp,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Font *f, char *s, Image *bg, Point bgp)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + Point stringbgop(Image *dst, Point p, Image *src, Point sp,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Font *f, char *s, Image *bg, Point bgp, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + Point stringnbg(Image *dst, Point p, Image *src, Point sp,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Font *f, char *s, int len, Image *bg, Point bgp)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + Point stringnbgop(Image *dst, Point p, Image *src, Point sp,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Font *f, char *s, int len, Image *bg, Point bgp, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + Point runestringbg(Image *dst, Point p, Image *src, Point sp,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Font *f, Rune *r, Image *bg, Point bgp)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + Point runestringbgop(Image *dst, Point p, Image *src, Point sp,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Font *f, Rune *r, Image *bg, Point bgp, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + Point runestringnbg(Image *dst, Point p, Image *src, Point sp,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Font *f, Rune *r, int len, Image *bg, Point bgp)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + Point runestringnbgop(Image *dst, Point p, Image *src, Point sp,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Font *f, Rune *r, int len, Image *bg, Point bgp, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + Point _string(Image *dst, Point p, Image *src,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Point sp, Font *f, char *s, Rune *r, int len,<br> + Rectangle clipr, Image *bg, Point bgp, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + void drawsetdebug(int on)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + enum<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + /* line ends */<br> + Endsquare = 0,<br> + Enddisc = 1,<br> + Endarrow = 2,<br> + Endmask = 0x1F<br> + + </table> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + #define ARROW(a, b, c) (Endarrow|((a)<<5)|((b)<<14)|((c)<<23))<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> + + The <tt><font size=+1>Image</font></tt> type defines rectangular pictures and the methods to + draw upon them; it is also the building block for higher level + objects such as windows and fonts. In particular, a window is + represented as an <tt><font size=+1>Image</font></tt>; no special operators are needed to draw + on a window. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>r</font></tt> The coordinates of the rectangle in the plane for which the <tt><font size=+1>Image</font></tt> + has defined pixel values. It should not be modified after the + image is created.<br> + <tt><font size=+1>clipr</font></tt> The clipping rectangle: operations that read or write the + image will not access pixels outside <tt><font size=+1>clipr</font></tt>. Frequently, <tt><font size=+1>clipr</font></tt> + is the same as <tt><font size=+1>r</font></tt>, but it may differ; see in particular the discussion + of <tt><font size=+1>repl</font></tt>. The clipping region may be modified dynamically using + <i>replclipr</i> (<i>q.v.</i>).<br> + <tt><font size=+1>chan</font></tt> The pixel channel format descriptor, as described in <a href="../man7/image.html"><i>image</i>(7)</a>. + The value should not be modified after the image is created.<br> + <tt><font size=+1>depth</font></tt> The number of bits per pixel in the picture; it is identically + <tt><font size=+1>chantodepth(chan)</font></tt> (see <a href="../man3/graphics.html"><i>graphics</i>(3)</a>) and is provided as a convenience. + The value should not be modified after the image is created.<br> + <tt><font size=+1>repl</font></tt> A boolean value specifying whether the image is tiled to cover + the plane when used as a source for a drawing operation. If <tt><font size=+1>repl</font></tt> + is zero, operations are restricted to the intersection of <tt><font size=+1>r</font></tt> and + <tt><font size=+1>clipr</font></tt>. If <tt><font size=+1>repl</font></tt> is set, <tt><font size=+1>r</font></tt> defines the tile to be replicated and + <tt><font size=+1>clipr</font></tt> defines the portion of the plane covered by the + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + tiling, in other words, <tt><font size=+1>r</font></tt> is replicated to cover <tt><font size=+1>clipr</font></tt>; in such + cases <tt><font size=+1>r</font></tt> and <tt><font size=+1>clipr</font></tt> are independent.<br> + For example, a replicated image with <tt><font size=+1>r</font></tt> set to ((0, 0), (1, 1)) + and <tt><font size=+1>clipr</font></tt> set to ((0, 0), (100, 100)), with the single pixel of + <tt><font size=+1>r</font></tt> set to blue, behaves identically to an image with <tt><font size=+1>r</font></tt> and <tt><font size=+1>clipr</font></tt> + both set to ((0, 0), (100, 100)) and all pixels set to blue. However, + the first image requires far less memory. The + replication flag may be modified dynamically using <i>replclipr</i> (<i>q.v.</i>). + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + Most of the drawing functions come in two forms: a basic form, + and an extended form that takes an extra <tt><font size=+1>Drawop</font></tt> to specify a Porter-Duff + compositing operator to use. The basic forms assume the operator + is <tt><font size=+1>SoverD</font></tt>, which suffices for the vast majority of applications. + The extended forms are named by adding an + -<tt><font size=+1>op</font></tt> suffix to the basic form. Only the basic forms are listed + below.<br> + <tt><font size=+1>draw(</font></tt><i>dst</i><tt><font size=+1>,</font></tt> <i>r</i><tt><font size=+1>,</font></tt> <i>src</i><tt><font size=+1>,</font></tt> <i>mask</i><tt><font size=+1>,</font></tt> <i>p</i><tt><font size=+1>)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Draw</i> is the standard drawing function. Only those pixels within + the intersection of <i>dst</i><tt><font size=+1>−>r</font></tt> and <i>dst</i><tt><font size=+1>−>clipr</font></tt> will be affected; <i>draw</i> + ignores <i>dst</i><tt><font size=+1>−>repl</font></tt>. The operation proceeds as follows (this is a + description of the behavior, not the implementation):<br> + 1. If <tt><font size=+1>repl</font></tt> is set in <i>src</i> or <i>mask</i>, replicate their contents to fill + their clip rectangles.<br> + 2. Translate <i>src</i> and <i>mask</i> so <i>p</i> is aligned with <i>r</i><tt><font size=+1>.min</font></tt>.<br> + 3. Set <i>r</i> to the intersection of <i>r</i> and <i>dst</i><tt><font size=+1>−>r</font></tt>.<br> + 4. Intersect <i>r</i> with <i>src</i><tt><font size=+1>−>clipr</font></tt>. If <i>src</i><tt><font size=+1>−>repl</font></tt> is false, also intersect + <i>r</i> with <i>src</i><tt><font size=+1>−>r</font></tt>.<br> + 5. Intersect <i>r</i> with <i>mask</i><tt><font size=+1>−>clipr</font></tt>. If <i>mask</i><tt><font size=+1>−>repl</font></tt> is false, also intersect + <i>r</i> with <i>mask</i><tt><font size=+1>−>r</font></tt>.<br> + 6. For each location in <i>r</i>, combine the <i>dst</i> pixel with the <i>src</i> pixel + using the alpha value corresponding to the <i>mask</i> pixel. If the + <i>mask</i> has an explicit alpha channel, the alpha value corresponding + to the <i>mask</i> pixel is simply that pixel’s alpha channel. Otherwise, + the alpha value is the NTSC greyscale + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + equivalent of the color value, with white meaning opaque and black + transparent. In terms of the Porter-Duff compositing algebra, + <i>draw</i> replaces the <i>dst</i> pixels with (<i>src</i> in <i>mask</i>) over <i>dst</i>. (In + the extended form, “over” is replaced by <i>op</i>).<br> + + </table> + The various pixel channel formats involved need not be identical. + If the channels involved are smaller than 8-bits, they will be + promoted before the calculation by replicating the extant bits; + after the calculation, they will be truncated to their proper + sizes.<br> + + </table> + <tt><font size=+1>gendraw(</font></tt><i>dst</i><tt><font size=+1>,</font></tt> <i>r</i><tt><font size=+1>,</font></tt> <i>src</i><tt><font size=+1>,</font></tt> <i>p0</i><tt><font size=+1>,</font></tt> <i>mask</i><tt><font size=+1>,</font></tt> <i>p1</i><tt><font size=+1>)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Similar to <i>draw</i> except that <i>gendraw</i> aligns the source and mask + differently: <i>src</i> is aligned so <i>p0</i> corresponds to <i>r</i><tt><font size=+1>.min</font></tt> and <i>mask</i> + is aligned so <i>p1</i> corresponds to <i>r</i><tt><font size=+1>.min</font></tt><i>.</i> For most purposes with + simple masks and source images, <tt><font size=+1>draw</font></tt> is sufficient, but <tt><font size=+1>gendraw</font></tt> + is the general operator and the one all other + drawing primitives are built upon.<br> + + </table> + <tt><font size=+1>drawreplxy(</font></tt><i>min</i><tt><font size=+1>,</font></tt><i>max</i><tt><font size=+1>,</font></tt><i>x</i><tt><font size=+1>)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Clips <i>x</i> to be in the half-open interval [<i>min</i>, <i>max</i>) by adding or + subtracting a multiple of <i>max-min</i>.<br> + + </table> + <tt><font size=+1>drawrepl(</font></tt><i>r</i><tt><font size=+1>,</font></tt><i>p</i><tt><font size=+1>)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Clips the point <i>p</i> to be within the rectangle <i>r</i> by translating + the point horizontally by an integer multiple of rectangle width + and vertically by the height.<br> + + </table> + <tt><font size=+1>replclipr(</font></tt><i>i</i><tt><font size=+1>,</font></tt><i>repl</i><tt><font size=+1>,</font></tt><i>clipr</i><tt><font size=+1>)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Because the image data is stored on the server, local modifications + to the <tt><font size=+1>Image</font></tt> data structure itself will have no effect. <i>Repclipr</i> + modifies the local <tt><font size=+1>Image</font></tt> data structure’s <tt><font size=+1>repl</font></tt> and <tt><font size=+1>clipr</font></tt> fields, + and notifies the server of their modification.<br> + + </table> + <tt><font size=+1>line(</font></tt><i>dst</i><tt><font size=+1>,</font></tt> <i>p0</i><tt><font size=+1>,</font></tt> <i>p1</i><tt><font size=+1>,</font></tt> <i>end0</i><tt><font size=+1>,</font></tt> <i>end1</i><tt><font size=+1>,</font></tt> <i>thick</i><tt><font size=+1>,</font></tt> <i>src</i><tt><font size=+1>,</font></tt> <i>sp</i><tt><font size=+1>)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Line draws in <i>dst</i> a line of width 1+2*<i>thick</i> pixels joining points + <i>p0</i> and <i>p1</i>. The line is drawn using pixels from the <i>src</i> image aligned + so <i>sp</i> in the source corresponds to <i>p0</i> in the destination. The + line touches both <i>p0</i> and <i>p1</i>, and <i>end0</i> and <i>end1</i> specify how the + ends of the line are drawn. <tt><font size=+1>Endsquare + </font></tt>terminates the line perpendicularly to the direction of the line; + a thick line with <tt><font size=+1>Endsquare</font></tt> on both ends will be a rectangle. + <tt><font size=+1>Enddisc</font></tt> terminates the line by drawing a disc of diameter 1+2*<i>thick</i> + centered on the end point. <tt><font size=+1>Endarrow</font></tt> terminates the line with an + arrowhead whose tip touches the endpoint. + The macro <tt><font size=+1>ARROW</font></tt> permits explicit control of the shape of the arrow. + If all three parameters are zero, it produces the default arrowhead, + otherwise, <i>a</i> sets the distance along line from end of the regular + line to tip, <i>b</i> sets the distance along line from the barb to the + tip, and <i>c</i> sets the distance perpendicular to the + line from edge of line to the tip of the barb, all in pixels.<br> + <i>Line</i> and the other geometrical operators are equivalent to calls + to <i>gendraw</i> using a mask produced by the geometric procedure.<br> + + </table> + <tt><font size=+1>poly(</font></tt><i>dst</i><tt><font size=+1>,</font></tt> <i>p</i><tt><font size=+1>,</font></tt> <i>np</i><tt><font size=+1>,</font></tt> <i>end0</i><tt><font size=+1>,</font></tt> <i>end1</i><tt><font size=+1>,</font></tt> <i>thick</i><tt><font size=+1>,</font></tt> <i>src</i><tt><font size=+1>,</font></tt> <i>sp</i><tt><font size=+1>)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Poly</i> draws a general polygon; it is conceptually equivalent to + a series of calls to <i>line</i> joining adjacent points in the array + of <tt><font size=+1>Points</font></tt> <i>p</i>, which has <i>np</i> elements. The ends of the polygon are + specified as in <i>line</i>; interior lines are terminated with <tt><font size=+1>Enddisc</font></tt> + to make smooth joins. The source is aligned so <i>sp + </i>corresponds to <i>p</i><tt><font size=+1>[0]</font></tt>.<br> + + </table> + <tt><font size=+1>fillpoly(</font></tt><i>dst</i><tt><font size=+1>,</font></tt> <i>p</i><tt><font size=+1>,</font></tt> <i>np</i><tt><font size=+1>,</font></tt> <i>wind</i><tt><font size=+1>,</font></tt> <i>src</i><tt><font size=+1>,</font></tt> <i>sp</i><tt><font size=+1>)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Fillpoly</i> is like <i>poly</i> but fills in the resulting polygon rather + than outlining it. The source is aligned so <i>sp</i> corresponds to + <i>p</i><tt><font size=+1>[0]</font></tt>. The winding rule parameter <i>wind</i> resolves ambiguities about + what to fill if the polygon is self-intersecting. If <i>wind</i> is <tt><font size=+1>~0</font></tt>, + a pixel is inside the polygon if the polygon’s winding number + about the point is non-zero. If <i>wind</i> is <tt><font size=+1>1</font></tt>, a pixel is inside if + the winding number is odd. Complementary values (0 or ~1) cause + outside pixels to be filled. The meaning of other values is undefined. + The polygon is closed with a line if necessary.<br> + + </table> + <tt><font size=+1>bezier(</font></tt><i>dst</i><tt><font size=+1>,</font></tt> <i>a</i><tt><font size=+1>,</font></tt> <i>b</i><tt><font size=+1>,</font></tt> <i>c</i><tt><font size=+1>,</font></tt> <i>d</i><tt><font size=+1>,</font></tt> <i>end0</i><tt><font size=+1>,</font></tt> <i>end1</i><tt><font size=+1>,</font></tt> <i>thick</i><tt><font size=+1>,</font></tt> <i>src</i><tt><font size=+1>,</font></tt> <i>sp</i><tt><font size=+1>)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Bezier</i> draws the cubic Bezier curve defined by <tt><font size=+1>Points</font></tt> <i>a</i>, <i>b</i>, <i>c</i>, + and <i>d</i>. The end styles are determined by <i>end0</i> and <i>end1</i>; the thickness + of the curve is 1+2*<i>thick</i>. The source is aligned so <i>sp</i> in <i>src</i> + corresponds to <i>a</i> in <i>dst</i>.<br> + + </table> + <tt><font size=+1>bezspline(</font></tt><i>dst</i><tt><font size=+1>,</font></tt> <i>p</i><tt><font size=+1>,</font></tt> <i>end0</i><tt><font size=+1>,</font></tt> <i>end1</i><tt><font size=+1>,</font></tt> <i>thick</i><tt><font size=+1>,</font></tt> <i>src</i><tt><font size=+1>,</font></tt> <i>sp</i><tt><font size=+1>)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Bezspline</i> takes the same arguments as <i>poly</i> but draws a quadratic + B-spline (despite its name) rather than a polygon. If the first + and last points in <i>p</i> are equal, the spline has periodic end conditions.<br> + + </table> + <tt><font size=+1>bezsplinepts(</font></tt><i>pt</i><tt><font size=+1>,</font></tt> <i>npt</i><tt><font size=+1>,</font></tt> <i>pp</i><tt><font size=+1>)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Bezsplinepts</i> returns in <i>pp</i> a list of points making up the open + polygon that <i>bezspline</i> would draw. The caller is responsible for + freeing <i>*pp</i>.<br> + + </table> + <tt><font size=+1>fillbezier(</font></tt><i>dst</i><tt><font size=+1>,</font></tt> <i>a</i><tt><font size=+1>,</font></tt> <i>b</i><tt><font size=+1>,</font></tt> <i>c</i><tt><font size=+1>,</font></tt> <i>d</i><tt><font size=+1>,</font></tt> <i>wind</i><tt><font size=+1>,</font></tt> <i>src</i><tt><font size=+1>,</font></tt> <i>sp</i><tt><font size=+1>)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Fillbezier</i> is to <i>bezier</i> as <i>fillpoly</i> is to <i>poly</i>.<br> + + </table> + <tt><font size=+1>fillbezspline(</font></tt><i>dst</i><tt><font size=+1>,</font></tt> <i>p</i><tt><font size=+1>,</font></tt> <i>wind</i><tt><font size=+1>,</font></tt> <i>src</i><tt><font size=+1>,</font></tt> <i>sp</i><tt><font size=+1>)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Fillbezspline</i> is like <i>fillpoly</i> but fills the quadratic B-spline + rather than the polygon outlined by <i>p</i>. The spline is closed with + a line if necessary.<br> + + </table> + <tt><font size=+1>ellipse(</font></tt><i>dst</i><tt><font size=+1>,</font></tt> <i>c</i><tt><font size=+1>,</font></tt> <i>a</i><tt><font size=+1>,</font></tt> <i>b</i><tt><font size=+1>,</font></tt> <i>thick</i><tt><font size=+1>,</font></tt> <i>src</i><tt><font size=+1>,</font></tt> <i>sp</i><tt><font size=+1>)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Ellipse</i> draws in <i>dst</i> an ellipse centered on <i>c</i> with horizontal + and vertical semiaxes <i>a</i> and <i>b</i>. The source is aligned so <i>sp</i> in + <i>src</i> corresponds to <i>c</i> in <i>dst</i>. The ellipse is drawn with thickness + 1+2*<i>thick</i>.<br> + + </table> + <tt><font size=+1>fillellipse(</font></tt><i>dst</i><tt><font size=+1>,</font></tt> <i>c</i><tt><font size=+1>,</font></tt> <i>a</i><tt><font size=+1>,</font></tt> <i>b</i><tt><font size=+1>,</font></tt> <i>src</i><tt><font size=+1>,</font></tt> <i>sp</i><tt><font size=+1>)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Fillellipse</i> is like <i>ellipse</i> but fills the ellipse rather than + outlining it.<br> + + </table> + <tt><font size=+1>arc(</font></tt><i>dst</i><tt><font size=+1>,</font></tt> <i>c</i><tt><font size=+1>,</font></tt> <i>a</i><tt><font size=+1>,</font></tt> <i>b</i><tt><font size=+1>,</font></tt> <i>thick</i><tt><font size=+1>,</font></tt> <i>src</i><tt><font size=+1>,</font></tt> <i>sp</i><tt><font size=+1>,</font></tt> <i>alpha</i><tt><font size=+1>,</font></tt> <i>phi</i><tt><font size=+1>)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Arc</i> is like <i>ellipse</i>, but draws only that portion of the ellipse + starting at angle <i>alpha</i> and extending through an angle of <i>phi</i>. + The angles are measured in degrees counterclockwise from the positive + <i>x</i> axis.<br> + + </table> + <tt><font size=+1>fillarc(</font></tt><i>dst</i><tt><font size=+1>,</font></tt> <i>c</i><tt><font size=+1>,</font></tt> <i>a</i><tt><font size=+1>,</font></tt> <i>b</i><tt><font size=+1>,</font></tt> <i>src</i><tt><font size=+1>,</font></tt> <i>sp</i><tt><font size=+1>,</font></tt> <i>alpha</i><tt><font size=+1>,</font></tt> <i>phi</i><tt><font size=+1>)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Fillarc</i> is like <i>arc</i>, but fills the sector with the source color.<br> + + </table> + <tt><font size=+1>icossin(</font></tt><i>deg</i><tt><font size=+1>,</font></tt> <i>cosp</i><tt><font size=+1>,</font></tt> <i>sinp</i><tt><font size=+1>)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Icossin</i> stores in <tt><font size=+1>*</font></tt><i>cosp</i> and <tt><font size=+1>*</font></tt><i>sinp</i> scaled integers representing + the cosine and sine of the angle <i>deg</i>, measured in integer degrees. + The values are scaled so cos(0) is 1024.<br> + + </table> + <tt><font size=+1>icossin2(</font></tt><i>x</i><tt><font size=+1>,</font></tt> <i>y</i><tt><font size=+1>,</font></tt> <i>cosp</i><tt><font size=+1>,</font></tt> <i>sinp</i><tt><font size=+1>)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Icossin2</i> is analogous to <i>icossin,</i> with the angle represented not + in degrees but implicitly by the point (<i>x</i>,<i>y</i>). It is to <i>icossin</i> + what <tt><font size=+1>atan2</font></tt> is to <tt><font size=+1>atan</font></tt> (see <a href="../man3/sin.html"><i>sin</i>(3)</a>).<br> + + </table> + <tt><font size=+1>border(</font></tt><i>dst</i><tt><font size=+1>,</font></tt> <i>r</i><tt><font size=+1>,</font></tt> <i>i</i><tt><font size=+1>,</font></tt> <i>color</i><tt><font size=+1>,</font></tt> <i>sp</i><tt><font size=+1>)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Border</i> draws an outline of rectangle <i>r</i> in the specified <i>color</i>. + The outline has width <i>i</i>; if positive, the border goes inside the + rectangle; negative, outside. The source is aligned so <i>sp</i> corresponds + to <i>r</i><tt><font size=+1>.min</font></tt><i>.<br> + </i> + </table> + <tt><font size=+1>string(</font></tt><i>dst</i><tt><font size=+1>,</font></tt> <i>p</i><tt><font size=+1>,</font></tt> <i>src</i><tt><font size=+1>,</font></tt> <i>sp</i><tt><font size=+1>,</font></tt> <i>font</i><tt><font size=+1>,</font></tt> <i>s</i><tt><font size=+1>)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>String</i> draws in <i>dst</i> characters specified by the string <i>s</i> and <i>font</i>; + it is equivalent to a series of calls to <i>gendraw</i> using source + <i>src</i> and masks determined by the character shapes. The text is + positioned with the left of the first character at <i>p</i><tt><font size=+1>.x</font></tt> and the + top of the line of text at <i>p</i><tt><font size=+1>.y</font></tt>. The source is positioned so <i>sp</i> + in + <i>src</i> corresponds to <i>p</i> in <i>dst</i>. <i>String</i> returns a <tt><font size=+1>Point</font></tt> that is the + position of the next character that would be drawn if the string + were longer.<br> + For characters with undefined or zero-width images in the font, + the character at font position 0 (NUL) is drawn.<br> + The other string routines are variants of this basic form, and + have names that encode their variant behavior. Routines whose + names contain <tt><font size=+1>rune</font></tt> accept a string of Runes rather than UTF-encoded + bytes. Routines ending in <tt><font size=+1>n</font></tt> accept an argument, <i>n</i>, that defines + the number of characters to draw rather than + accepting a NUL-terminated string. Routines containing <tt><font size=+1>bg</font></tt> draw + the background behind the characters in the specified color (<i>bg</i>) + and alignment (<i>bgp</i>); normally the text is drawn leaving the background + intact.<br> + The routine <i>_string</i> captures all this behavior into a single operator. + Whether it draws a UTF string or Rune string depends on whether + <i>s</i> or <i>r</i> is null (the string length is always determined by <i>len</i>). + If <i>bg</i> is non-null, it is used as a background color. The <i>clipr</i> + argument allows further management of clipping when + drawing the string; it is intersected with the usual clipping + rectangles to further limit the extent of the text.<br> + + </table> + <tt><font size=+1>drawsetdebug(</font></tt><i>on</i><tt><font size=+1>)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Turns on or off debugging output (usually to a serial line) according + to whether <i>on</i> is non-zero.<br> + + </table> + +</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/libdraw<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/graphics.html"><i>graphics</i>(3)</a>, <a href="../man3/stringsize.html"><i>stringsize</i>(3)</a>, <a href="../man7/color.html"><i>color</i>(7)</a>, <a href="../man7/utf.html"><i>utf</i>(7)</a>, <a href="../man3/addpt.html"><i>addpt</i>(3)</a> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + T. Porter, T. Duff. “Compositing Digital Images”, <i>Computer Graphics</i> + (Proc. SIGGRAPH), 18:3, pp. 253-259, 1984.<br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + These routines call the graphics error function on fatal errors.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Anti-aliased characters can be drawn by defining a font with multiple + bits per pixel, but there are no anti-aliasing geometric primitives.<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> diff --git a/man/man3/dsa.html b/man/man3/dsa.html new file mode 100644 index 00000000..765ddd7c --- /dev/null +++ b/man/man3/dsa.html @@ -0,0 +1,172 @@ +<head> +<title>dsa(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>DSA(3)</b><td align=right><b>DSA(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> + + dsagen, dsasign, dsaverify, dsapuballoc, dsapubfree, dsaprivalloc, + dsaprivfree, dsasigalloc, dsasigfree, dsaprivtopub - digital signature + algorithm<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 <mp.h><br> + #include <libsec.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>DSApriv* dsagen(DSApub *opub) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>DSAsig* dsasign(DSApriv *k, mpint *m) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int dsaverify(DSApub *k, DSAsig *sig, mpint *m) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>DSApub* dsapuballoc(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void dsapubfree(DSApub*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>DSApriv* dsaprivalloc(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void dsaprivfree(DSApriv*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>DSAsig* dsasigalloc(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void dsasigfree(DSAsig*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>DSApub* dsaprivtopub(DSApriv*)<br> + </font></tt> +</table> +<p><font size=+1><b>DESCRIPTION </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + DSA is the NIST approved digital signature algorithm. The owner + of a key publishes the public part of the key:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>struct DSApub<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + mpint *p; // modulus<br> + mpint *q; // group order, q divides p−1<br> + mpint *alpha; // group generator<br> + mpint *key; // alpha**secret mod p<br> + + </table> + };<br> + </font></tt> + </table> + This part can be used for verifying signatures (with <i>dsaverify</i>) + created by the owner. The owner signs (with <i>dsasign</i>) using his + private key:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>struct DSApriv<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + DSApub pub;<br> + mpint *secret; // (decryption key)<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + Keys are generated using <i>dsagen</i>. If <i>dsagen</i>’s argument <i>opub</i> is + <tt><font size=+1>nil</font></tt>, a key is created using a new <tt><font size=+1>p</font></tt> and <tt><font size=+1>q</font></tt> generated by <i>DSAprimes</i> + (see <a href="../man3/prime.html"><i>prime</i>(3)</a>). Otherwise, <tt><font size=+1>p</font></tt> and <tt><font size=+1>q</font></tt> are copied from the old key. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Dsaprivtopub</i> returns a newly allocated copy of the public key + corresponding to the private key. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The routines <i>dsapuballoc</i>, <i>dsapubfree</i>, <i>dsaprivalloc</i>, and <i>dsaprivfree</i> + are provided to manage key storage. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Dsasign</i> signs message <i>m</i> using a private key <i>k</i> yielding a<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>struct DSAsig<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + mpint *r, *s;<br> + + </table> + };<br> + </font></tt> + </table> + <i>Dsaverify</i> returns 0 if the signature is valid and –1 if not. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The routines <i>dsasigalloc</i> and <i>dsasigfree</i> are provided to manage + signature storage.<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/libsec<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/mp.html"><i>mp</i>(3)</a>, <a href="../man3/aes.html"><i>aes</i>(3)</a>, <a href="../man3/blowfish.html"><i>blowfish</i>(3)</a>, <a href="../man3/des.html"><i>des</i>(3)</a>, <a href="../man3/rc4.html"><i>rc4</i>(3)</a>, <a href="../man3/rsa.html"><i>rsa</i>(3)</a>, <a href="../man3/sechash.html"><i>sechash</i>(3)</a>, + <a href="../man3/prime.html"><i>prime</i>(3)</a>, <a href="../man3/rand.html"><i>rand</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> diff --git a/man/man3/dup.html b/man/man3/dup.html new file mode 100644 index 00000000..c601e3b2 --- /dev/null +++ b/man/man3/dup.html @@ -0,0 +1,78 @@ +<head> +<title>dup(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>DUP(3)</b><td align=right><b>DUP(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> + + dup – duplicate an open file descriptor<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int dup(int oldfd, int newfd)<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> + + Given a file descriptor, <i>oldfd</i>, referring to an open file, <i>dup</i> + returns a new file descriptor referring to the same file. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + If <i>newfd</i> is –1 the system chooses the lowest available file descriptor. + Otherwise, <i>dup</i> will use <i>newfd</i> for the new file descriptor (closing + any old file associated with <i>newfd</i>).<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/lib9/dup.c<br> + </font></tt> +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Sets <i>errstr</i>.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + To avoid name conflicts with the underlying system, <i>dup</i> is a preprocessor + macro defined as <i>p9dup</i>; see <a href="../man3/intro.html"><i>intro</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> diff --git a/man/man3/elgamal.html b/man/man3/elgamal.html new file mode 100644 index 00000000..a6518468 --- /dev/null +++ b/man/man3/elgamal.html @@ -0,0 +1,174 @@ +<head> +<title>elgamal(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>ELGAMAL(3)</b><td align=right><b>ELGAMAL(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> + + eggen, egencrypt, egdecrypt, egsign, egverify, egpuballoc, egpubfree, + egprivalloc, egprivfree, egsigalloc, egsigfree, egprivtopub - + elgamal encryption<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 <mp.h><br> + #include <libsec.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>EGpriv* eggen(int nlen, int nrep) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>mpint* egencrypt(EGpub *k, mpint *in, mpint *out) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>mpint* egdecrypt(EGpriv *k, mpint *in, mpint *out) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>EGsig* egsign(EGpriv *k, mpint *m) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int egverify(EGpub *k, EGsig *sig, mpint *m) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>EGpub* egpuballoc(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void egpubfree(EGpub*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>EGpriv* egprivalloc(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void egprivfree(EGpriv*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>EGsig* egsigalloc(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void egsigfree(EGsig*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>EGpub* egprivtopub(EGpriv*)<br> + </font></tt> +</table> +<p><font size=+1><b>DESCRIPTION </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Elgamal is a public key encryption and signature algorithm. The + owner of a key publishes the public part of the key:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>struct EGpub<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + mpint *p; // modulus<br> + mpint *alpha; // generator<br> + mpint *key; // (encryption key) alpha**secret mod p<br> + + </table> + };<br> + </font></tt> + </table> + This part can be used for encrypting data (with <i>egencrypt</i>) to + be sent to the owner. The owner decrypts (with <i>egdecrypt</i>) using + his private key:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>struct EGpriv<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + EGpub pub;<br> + mpint *secret; // (decryption key)<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + Keys are generated using <i>eggen</i>. <i>Eggen</i> takes both bit length of + the modulus and the number of repetitions of the Miller-Rabin + primality test to run. If the latter is 0, it does the default + number of rounds. <i>Egprivtopub</i> returns a newly allocated copy of + the public key corresponding to the private key. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The routines <i>egpuballoc</i>, <i>egpubfree</i>, <i>egprivalloc</i>, and <i>egprivfree</i> + are provided to manage key storage. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Egsign</i> signs message <i>m</i> using a private key <i>k</i> yielding a<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>struct EGsig<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + mpint *r, *s;<br> + + </table> + };<br> + </font></tt> + </table> + <i>Egverify</i> returns 0 if the signature is valid and –1 if not. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The routines <i>egsigalloc</i> and <i>egsigfree</i> are provided to manage signature + storage.<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/libsec<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/mp.html"><i>mp</i>(3)</a>, <a href="../man3/aes.html"><i>aes</i>(3)</a>, <a href="../man3/blowfish.html"><i>blowfish</i>(3)</a>, <a href="../man3/des.html"><i>des</i>(3)</a>, <a href="../man3/dsa.html"><i>dsa</i>(3)</a>, <a href="../man3/rc4.html"><i>rc4</i>(3)</a>, <a href="../man3/rsa.html"><i>rsa</i>(3)</a>, <a href="../man3/sechash.html"><i>sechash</i>(3)</a>, + <a href="../man3/prime.html"><i>prime</i>(3)</a>, <a href="../man3/rand.html"><i>rand</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> diff --git a/man/man3/encode.html b/man/man3/encode.html new file mode 100644 index 00000000..c7a8132c --- /dev/null +++ b/man/man3/encode.html @@ -0,0 +1,109 @@ +<head> +<title>encode(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>ENCODE(3)</b><td align=right><b>ENCODE(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> + + dec64, enc64, dec32, enc32, dec16, enc16, encodefmt – encoding + byte arrays as strings<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int dec64(uchar *out, int lim, char *in, int n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int enc64(char *out, int lim, uchar *in, int n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int dec32(uchar *out, int lim, char *in, int n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int enc32(char *out, int lim, uchar *in, int n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int dec16(uchar *out, int lim, char *in, int n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int enc16(char *out, int lim, uchar *in, int n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int encodefmt(Fmt*)<br> + </font></tt> +</table> +<p><font size=+1><b>DESCRIPTION </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Enc16</i>, <i>enc32</i> and <i>enc64</i> create null terminated strings. They return + the size of the encoded string (without the null) or -1 if the + encoding fails. The encoding fails if <i>lim</i>, the length of the output + buffer, is too small. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Dec16</i>, <i>dec32</i> and <i>dec64</i> return the number of bytes decoded or -1 + if the decoding fails. The decoding fails if the output buffer + is not large enough or, for base 32, if the input buffer length + is not a multiple of 8. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Encodefmt</i> can be used with <a href="../man3/fmtinstall.html"><i>fmtinstall</i>(3)</a> and <a href="../man3/print.html"><i>print</i>(3)</a> to print + encoded representations of byte arrays. The verbs are<br> + <tt><font size=+1>H</font></tt> base 16 (i.e. hexadecimal). The default encoding is in upper + case. The <tt><font size=+1>l</font></tt> flag forces lower case.<br> + <tt><font size=+1><</font></tt> base 32<br> + <tt><font size=+1>[</font></tt> base 64 (same as MIME) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The length of the array is specified as <i>f2</i>. For example, to display + a 15 byte array as hex:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>char x[15];<br> + fmtinstall('H', encodefmt);<br> + print("%.*H\n", sizeof x, x);<br> + </font></tt> + </table> + +</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/lib9/u32.c<br> + /usr/local/plan9/src/lib9/u64.c<br> + </font></tt> +</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> diff --git a/man/man3/errstr.html b/man/man3/errstr.html new file mode 100644 index 00000000..547efc8d --- /dev/null +++ b/man/man3/errstr.html @@ -0,0 +1,121 @@ +<head> +<title>errstr(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>ERRSTR(3)</b><td align=right><b>ERRSTR(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> + + errstr, rerrstr, werrstr – description of last system call error<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int errstr(char *err, uint nerr) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void rerrstr(char *err, uint nerr) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void werrstr(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> + + When a system call fails it returns –1 and records a null terminated + string describing the error in a per-process buffer. <i>Errstr</i> swaps + the contents of that buffer with the contents of the array <i>err</i>. + <i>Errstr</i> will write at most <i>nerr</i> bytes into <i>err</i>; if the per-process + error string does not fit, it is silently truncated at a UTF + character boundary. The returned string is NUL-terminated. Usually + <i>errstr</i> will be called with an empty string, but the exchange property + provides a mechanism for libraries to set the return value for + the next call to <i>errstr</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The per-process buffer is <tt><font size=+1>ERRMAX</font></tt> bytes long. Any error string + provided by the user will be truncated at <tt><font size=+1>ERRMAX−1</font></tt> bytes. <tt><font size=+1>ERRMAX</font></tt> + is defined in <tt><font size=+1><libc.h></font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + If no system call has generated an error since the last call to + <i>errstr</i> with an empty string, the result is an empty string. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The verb <tt><font size=+1>r</font></tt> in <a href="../man3/print.html"><i>print</i>(3)</a> calls <i>errstr</i> and outputs the error string. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Rerrstr</i> reads the error string but does not modify the per-process + buffer, so a subsequent <i>errstr</i> will recover the same string. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Werrstr</i> takes a <i>print</i> style format as its argument and uses it + to format a string to pass to <i>errstr</i>. The string returned from + <i>errstr</i> is discarded. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The error string is maintained in parallel with the Unix error + number <i>errno</i>. Changing <i>errno</i> will reset the error string, and + changing the error string via <i>errstr</i> or <i>werrstr</i> will reset <i>errno</i>.<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/lib9/errstr.c<br> + </font></tt> +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Errstr</i> always returns 0.<br> + +</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/intro.html"><i>intro</i>(3)</a>, <a href="../man3/perror.html"><i>perror</i>(3)</a><br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The implementation sets <i>errno</i> to the (somewhat arbitrary) constant + 0x19283745 when the error string is valid. When <i>errno</i> is set to + other values, the error string is synthesized using <a href="../man3/strerror.html"><i>strerror</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> diff --git a/man/man3/event.html b/man/man3/event.html new file mode 100644 index 00000000..87cff2fd --- /dev/null +++ b/man/man3/event.html @@ -0,0 +1,390 @@ +<head> +<title>event(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>EVENT(3)</b><td align=right><b>EVENT(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> + + event, einit, estart, estartfn, etimer, eread, emouse, ekbd, ecanread, + ecanmouse, ecankbd, ereadmouse, eatomouse, eresized, egetrect, + edrawgetrect, emenuhit, emoveto, esetcursor, Event, Mouse, Menu + – graphics events<br> + +</table> +<p><font size=+1><b>SYNOPSIS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<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 <draw.h><br> + #include <event.h><br> + #include <cursor.h><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void einit(ulong keys)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ulong event(Event *e)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Mouse emouse(void)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int ekbd(void)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int ecanmouse(void)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int ecankbd(void)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int ereadmouse(Mouse *m)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int eatomouse(Mouse *m, char *buf, int n)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ulong estart(ulong key, int fd, int n)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ulong estartfn(int id, ulong key, int fd, int n,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int (*fn)(Event*, uchar*, int))<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>ulong etimer(ulong key, int n)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ulong eread(ulong keys, Event *e)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int ecanread(ulong keys)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void eresized(int new)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rectangle egetrect(int but, Mouse *m)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void edrawgetrect(Rectangle r, int up)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int emenuhit(int but, Mouse *m, Menu *menu)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>int emoveto(Point p)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>int esetcursor(Cursor *c)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>extern Mouse *mouse<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>enum{<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Emouse = 1,<br> + Ekeyboard = 2,<br> + + </table> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </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 routines provide an interface to multiple sources of input + for unthreaded programs. Threaded programs (see <a href="../man3/thread.html"><i>thread</i>(3)</a>) should + instead use the threaded mouse and keyboard interface described + in <a href="../man3/mouse.html"><i>mouse</i>(3)</a> and <a href="../man3/keyboard.html"><i>keyboard</i>(3)</a>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Einit</i> must be called first. If the argument to <i>einit</i> has the <tt><font size=+1>Emouse</font></tt> + and <tt><font size=+1>Ekeyboard</font></tt> bits set, the mouse and keyboard events will be + enabled; in this case, <i>initdraw</i> (see <a href="../man3/graphics.html"><i>graphics</i>(3)</a>) must have already + been called. The user must provide a function called <i>eresized</i> + to be called whenever the window in which the process + is running has been resized; the argument <i>new</i> is a flag specifying + whether the program must call <i>getwindow</i> (see <a href="../man3/graphics.html"><i>graphics</i>(3)</a>) to re-establish + a connection to its window. After resizing (and perhaps calling + <i>getwindow</i>), the global variable <tt><font size=+1>screen</font></tt> will be updated to point + to the new window’s <tt><font size=+1>Image</font></tt> structure. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + As characters are typed on the keyboard, they are read by the + event mechanism and put in a queue. <i>Ekbd</i> returns the next rune + from the queue, blocking until the queue is non-empty. The characters + are read in raw mode, so they are available as soon as a complete + rune is typed. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + When the mouse moves or a mouse button is pressed or released, + a new mouse event is queued by the event mechanism. <i>Emouse</i> returns + the next mouse event from the queue, blocking until the queue + is non-empty. <i>Emouse</i> returns a <tt><font size=+1>Mouse</font></tt> structure:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>struct Mouse<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int buttons;<br> + Point xy;<br> + ulong msec;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + <tt><font size=+1>Buttons&1</font></tt> is set when the left mouse button is pressed, <tt><font size=+1>buttons&2</font></tt> + when the middle button is pressed, and <tt><font size=+1>buttons&4</font></tt> when the right + button is pressed. The current mouse position is always returned + in <tt><font size=+1>xy</font></tt>. <tt><font size=+1>Msec</font></tt> is a time stamp in units of milliseconds. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Ecankbd</i> and <i>ecanmouse</i> return non-zero when there are keyboard + or mouse events available to be read. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Ereadmouse</i> reads the next mouse event from the file descriptor + connected to the mouse, converts the textual data into a <tt><font size=+1>Mouse</font></tt> + structure by calling <i>eatomouse</i> with the buffer and count from + the read call, and returns the number of bytes read, or –1 for + an error. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Estart</i> can be used to register additional file descriptors to + scan for input. It takes as arguments the file descriptor to register, + the maximum length of an event message on that descriptor, and + a key to be used in accessing the event. The key must be a power + of 2 and must not conflict with any previous keys. If a zero + key is given, a key will be allocated and returned. <i>Estartfn</i> is + similar to <i>estart</i>, but processes the data received by calling + <i>fn</i> before returning the event to the user. The function <i>fn</i> is + called with the <tt><font size=+1>id</font></tt> of the event; it should return <tt><font size=+1>id</font></tt> if the event + is to be passed to the user, <tt><font size=+1>0</font></tt> if it is to be ignored. The variable + <tt><font size=+1>Event.v + </font></tt>can be used by <i>fn</i> to attach an arbitrary data item to the returned + <tt><font size=+1>Event</font></tt> structure. <tt><font size=+1> Ekeyboard</font></tt> and <tt><font size=+1>Emouse</font></tt> are the keyboard and mouse + event keys. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Etimer</i> starts a repeating timer with a period of <i>n</i> milliseconds; + it returns the timer event key, or zero if it fails. Only one + timer can be started. Extra timer events are not queued and the + timer channel has no associated data. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Eread</i> waits for the next event specified by the mask <i>keys</i> of event + keys submitted to <i>estart</i>. It fills in the appropriate field of + the argument <tt><font size=+1>Event</font></tt> structure, which looks like:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>struct Event<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int kbdc;<br> + Mouse mouse;<br> + int n;<br> + void *v;<br> + uchar data[EMAXMSG];<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + <tt><font size=+1>Data</font></tt> is an array which is large enough to hold a 9P message. <i>Eread</i> + returns the key for the event which was chosen. For example, if + a mouse event was read, <tt><font size=+1>Emouse</font></tt> will be returned. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Event</i> waits for the next event of any kind. The return is the + same as for <i>eread</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + As described in <a href="../man3/graphics.html"><i>graphics</i>(3)</a>, the graphics functions are buffered. + <i>Event</i>, <i>eread</i>, <i>emouse</i>, and <i>ekbd</i> all cause a buffer flush unless + there is an event of the appropriate type already queued. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Ecanread</i> checks whether a call to <tt><font size=+1>eread(keys)</font></tt> would block, returning + 0 if it would, 1 if it would not. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Getrect</i> prompts the user to sweep a rectangle. It should be called + with <i>m</i> holding the mouse event that triggered the <i>egetrect</i> (or, + if none, a <tt><font size=+1>Mouse</font></tt> with <tt><font size=+1>buttons</font></tt> set to 7). It changes to the sweep + cursor, waits for the buttons all to be released, and then waits + for button number <i>but</i> to be pressed, marking the initial + corner. If another button is pressed instead, <i>egetrect</i> returns + a rectangle with zero for both corners, after waiting for all + the buttons to be released. Otherwise, <i>egetrect</i> continually draws + the swept rectangle until the button is released again, and returns + the swept rectangle. The mouse structure pointed to by <i>m</i> will + contain the final mouse event. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Egetrect</i> uses successive calls to <i>edrawgetrect</i> to maintain the + red rectangle showing the sweep-in-progress. The rectangle to + be drawn is specified by <i>rc</i> and the <i>up</i> parameter says whether + to draw (1) or erase (0) the rectangle. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Emenuhit</i> displays a menu and returns a selected menu item number. + It should be called with <i>m</i> holding the mouse event that triggered + the <i>emenuhit</i>; it will call <i>emouse</i> to update it. A <tt><font size=+1>Menu</font></tt> is a structure:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>struct Menu<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + char **item;<br> + char *(*gen)(int);<br> + int lasthit;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + If <tt><font size=+1>item</font></tt> is nonzero, it should be a null-terminated array of the + character strings to be displayed as menu items. Otherwise, <tt><font size=+1>gen</font></tt> + should be a function that, given an item number, returns the character + string for that item, or zero if the number is past the end of + the list. Items are numbered starting at zero. <i>Menuhit + </i>waits until <i>but</i> is released, and then returns the number of the + selection, or –1 for no selection. The <i>m</i> argument is filled in + with the final mouse event. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Emoveto</i> moves the mouse cursor to the position <tt><font size=+1>p</font></tt> on the screen. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Esetcursor</i> changes the cursor image to that described by the <tt><font size=+1>Cursor</font></tt> + <i>c</i> (see <a href="../man3/mouse.html"><i>mouse</i>(3)</a>). If <tt><font size=+1>c</font></tt> is nil, it restores the image to the default + arrow.<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/libdraw<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="../man1/rio.html"><i>rio</i>(1)</a>, <a href="../man3/graphics.html"><i>graphics</i>(3)</a>, <a href="../man3/plumb.html"><i>plumb</i>(3)</a>, <a href="../man3/draw.html"><i>draw</i>(3)</a><br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Etimer</i> and <i>estart</i> are unimplemented.<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> diff --git a/man/man3/exec.html b/man/man3/exec.html new file mode 100644 index 00000000..e5397352 --- /dev/null +++ b/man/man3/exec.html @@ -0,0 +1,146 @@ +<head> +<title>exec(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>EXEC(3)</b><td align=right><b>EXEC(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> + + exec, execl – execute a file<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int exec(char *name, char* argv[])<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int execl(char *name, ...)<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> + + <i>Exec</i> and <i>execl</i> overlay the calling process with the named file, + then transfer to the entry point of the image of the file. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Name</i> points to the name of the file to be executed; it must not + be a directory, and the permissions must allow the current user + to execute it (see <a href="../man3/stat.html"><i>stat</i>(3)</a>). It should also be a valid binary + image, as defined by the local operating system, or a shell script + (see <a href="../man1/rc.html"><i>rc</i>(1)</a>). The first line of a shell script must begin with + <tt><font size=+1>#!</font></tt> followed + by the name of the program to interpret the file and any initial + arguments to that program, for example<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>#!/bin/rc<br> + ls | mc<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + When a C program is executed, it is called as follows:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>void main(int argc, char *argv[])<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + <i>Argv</i> is a copy of the array of argument pointers passed to <i>exec</i>; + that array must end in a null pointer, and <i>argc</i> is the number + of elements before the null pointer. By convention, the first + argument should be the name of the program to be executed. <i>Execl</i> + is like <i>exec</i> except that <i>argv</i> will be an array of the parameters + that follow <i>name</i> in the call. The last argument to <i>execl</i> must + be a null pointer. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + For a file beginning <tt><font size=+1>#!</font></tt>, the arguments passed to the program (<tt><font size=+1>/bin/rc</font></tt> + in the example above) will be the name of the file being executed, + any arguments on the <tt><font size=+1>#!</font></tt> line, the name of the file again, and + finally the second and subsequent arguments given to the original + <i>exec</i> call. The result honors the two conventions + of a program accepting as argument a file to be interpreted and + <tt><font size=+1>argv[0]</font></tt> naming the file being executed. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Most attributes of the calling process are carried into the result; + in particular, files remain open across <i>exec</i> (except those opened + with <tt><font size=+1>OCEXEC</font></tt> OR’d into the open mode; see <a href="../man3/open.html"><i>open</i>(3)</a>); and the working + directory and environment (see <a href="../man3/getenv.html"><i>getenv</i>(3)</a>) remain the same. However, + a newly <i>exec’ed</i> process has no notification + handlers (see <a href="../man3/notify.html"><i>notify</i>(3)</a>).<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/lib9/exec.c<br> + /usr/local/plan9/src/lib9/execl.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="../man1/prof.html"><i>prof</i>(1)</a>, <a href="../man3/intro.html"><i>intro</i>(3)</a>, <a href="../man3/stat.html"><i>stat</i>(3)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + If these functions fail, they return and set <i>errstr</i>. There can + be no return from a successful <i>exec</i> or <i>execl</i>; the calling image + is lost.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + On Unix, unlike on Plan 9, <i>exec</i> and <i>execl</i> use the user’s current + path to locate <i>prog</i>. This is a clumsy way to deal with Unix’s + lack of a union directory for <tt><font size=+1>/bin</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + To avoid name conflicts with the underlying system, <i>exec</i> and <i>execl</i> + are preprocessor macros defined as <i>p9exec</i> and <i>p9execl</i>; see <a href="../man3/intro.html"><i>intro</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> diff --git a/man/man3/exits.html b/man/man3/exits.html new file mode 100644 index 00000000..cc94a468 --- /dev/null +++ b/man/man3/exits.html @@ -0,0 +1,126 @@ +<head> +<title>exits(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>EXITS(3)</b><td align=right><b>EXITS(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> + + exits, _exits, atexit, atexitdont, terminate – terminate process, + process cleanup<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void _exits(char *msg)<br> + void exits(char *msg)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int atexit(void(*)(void))<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void atexitdont(void(*)(void))<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> + + <i>Exits</i> is the conventional way to terminate a process. <i>_Exits</i> also + terminates a process but does not call the registered <i>atexit</i> handlers + (<i>q.v.</i>). They can never return. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Msg</i> conventionally includes a brief (maximum length <tt><font size=+1>ERRLEN</font></tt>) explanation + of the reason for exiting, or a null pointer or empty string to + indicate normal termination. The string is passed to the parent + process, prefixed by the name and process id of the exiting process, + when the parent does a <a href="../man3/wait.html"><i>wait</i>(3)</a>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Before calling <i>_exits</i> with <i>msg</i> as an argument, <i>exits</i> calls in + reverse order all the functions recorded by <i>atexit</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Atexit</i> records <i>fn</i> as a function to be called by <i>exits</i>. It returns + zero if it failed, nonzero otherwise. A typical use is to register + a cleanup routine for an I/O package. To simplify programs that + fork or share memory, <i>exits</i> only calls those <i>atexit</i>-registered + functions that were registered by the same process as that calling + <i>exits</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Calling <i>atexit</i> twice (or more) with the same function argument + causes <i>exits</i> to invoke the function twice (or more). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + There is a limit to the number of exit functions that will be + recorded; <i>atexit</i> returns 0 if that limit has been reached. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Atexitdont</i> cancels a previous registration of an exit function.<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/lib9/atexit.c<br> + /usr/local/plan9/src/lib9/_exits.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="../man2/fork.html"><i>fork</i>(2)</a>, <a href="../man3/wait.html"><i>wait</i>(3)</a><br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Because of limitations of Unix, the exit status of a process can + only be an 8-bit integer. Exit status 0 is used for empty exit + messages, and 1 for non-empty messages. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Exit codes 97 through 99 are used by the thread library to signal + internal synchronization errors between the main program and a + proxy process that implements backgrounding. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + To avoid name conflicts with the underlying system, <i>atexit</i> and + <i>atexitdont</i> are preprocessor macros defined as <i>p9atexit</i> and <i>p9atexitdont</i>; + see <a href="../man3/intro.html"><i>intro</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> diff --git a/man/man3/fcall.html b/man/man3/fcall.html new file mode 100644 index 00000000..926b47dc --- /dev/null +++ b/man/man3/fcall.html @@ -0,0 +1,274 @@ +<head> +<title>fcall(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>FCALL(3)</b><td align=right><b>FCALL(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> + + Fcall, convS2M, convD2M, convM2S, convM2D, fcallfmt, dirfmt, dirmodefmt, + read9pmsg, statcheck, sizeS2M, sizeD2M – interface to Plan 9 File + protocol<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>uint convS2M(Fcall *f, uchar *ap, uint nap) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>uint convD2M(Dir *d, uchar *ap, uint nap) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>uint convM2S(uchar *ap, uint nap, Fcall *f) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>uint convM2D(uchar *ap, uint nap, Dir *d, char *strs) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int dirfmt(Fmt*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int fcallfmt(Fmt*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int dirmodefmt(Fmt*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int read9pmsg(int fd, uchar *buf, uint nbuf) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int statcheck(uchar *buf, uint nbuf) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>uint sizeS2M(Fcall *f) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>uint sizeD2M(Dir *d)<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 routines convert messages in the machine-independent format + of the Plan 9 file protocol, 9P, to and from a more convenient + form, an <tt><font size=+1>Fcall</font></tt> structure: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>#define MAXWELEM 16<br> + typedef<br> + struct Fcall<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + uchar type;<br> + u32int fid;<br> + ushort tag;<br> + union {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + struct {<br> + u32int msize; /* Tversion, Rversion */<br> + char *version; /* Tversion, Rversion */<br> + };<br> + struct {<br> + ushort oldtag; /* Tflush */<br> + };<br> + struct {<br> + char *ename; /* Rerror */<br> + };<br> + struct {<br> + Qid qid; /* Rattach, Ropen, Rcreate */<br> + u32int iounit; /* Ropen, Rcreate */<br> + };<br> + struct {<br> + Qid aqid; /* Rauth */<br> + };<br> + struct {<br> + u32int afid; /* Tauth, Tattach */<br> + char *uname; /* Tauth, Tattach */<br> + char *aname; /* Tauth, Tattach */<br> + };<br> + struct {<br> + u32int perm; /* Tcreate */ <br> + char *name; /* Tcreate */<br> + uchar mode; /* Tcreate, Topen */<br> + };<br> + struct {<br> + u32int newfid; /* Twalk */<br> + ushort nwname; /* Twalk */<br> + char *wname[MAXWELEM]; /* Twalk */<br> + };<br> + struct {<br> + ushort nwqid; /* Rwalk */<br> + Qid wqid[MAXWELEM]; /* Rwalk */<br> + };<br> + struct {<br> + vlong offset; /* Tread, Twrite */<br> + u32int count; /* Tread, Twrite, Rread */<br> + char *data; /* Twrite, Rread */<br> + };<br> + struct {<br> + ushort nstat; /* Twstat, Rstat */<br> + uchar *stat; /* Twstat, Rstat */<br> + };<br> + + </table> + };<br> + + </table> + } Fcall;<br> + /* these are implemented as macros */<br> + uchar GBIT8(uchar*)<br> + ushort GBIT16(uchar*)<br> + ulong GBIT32(uchar*)<br> + vlong GBIT64(uchar*)<br> + void PBIT8(uchar*, uchar)<br> + void PBIT16(uchar*, ushort)<br> + void PBIT32(uchar*, ulong)<br> + void PBIT64(uchar*, vlong)<br> + #define BIT8SZ 1<br> + #define BIT16SZ 2<br> + #define BIT32SZ 4<br> + #define BIT64SZ 8<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + This structure is defined in <tt><font size=+1><fcall.h></font></tt>. See section 5 for a full + description of 9P messages and their encoding. For all message + types, the <tt><font size=+1>type</font></tt> field of an <tt><font size=+1>Fcall</font></tt> holds one of <tt><font size=+1>Tversion</font></tt>, <tt><font size=+1>Rversion</font></tt>, + <tt><font size=+1>Tattach</font></tt>, <tt><font size=+1>Rattach</font></tt>, etc. (defined in an enumerated type in <tt><font size=+1><fcall.h></font></tt>). + <tt><font size=+1>Fid</font></tt> is used by most messages, and + <tt><font size=+1>tag</font></tt> is used by all messages. The other fields are used selectively + by the message types given in comments. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>ConvM2S</i> takes a 9P message at <i>ap</i> of length <i>nap</i>, and uses it to + fill in <tt><font size=+1>Fcall</font></tt> structure <i>f</i>. If the passed message including any + data for <tt><font size=+1>Twrite</font></tt> and <tt><font size=+1>Rread</font></tt> messages is formatted properly, the + return value is the number of bytes the message occupied in the + buffer <i>ap</i>, which will always be less than or equal to <i>nap</i>; + otherwise it is 0. For <tt><font size=+1>Twrite</font></tt> and <tt><font size=+1>Tread</font></tt> messages, <tt><font size=+1>data</font></tt> is set + to a pointer into the argument message, not a copy. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>ConvS2M</i> does the reverse conversion, turning <i>f</i> into a message + starting at <i>ap</i>. The length of the resulting message is returned. + For <tt><font size=+1>Twrite</font></tt> and <tt><font size=+1>Rread</font></tt> messages, <tt><font size=+1>count</font></tt> bytes starting at <tt><font size=+1>data</font></tt> are + copied into the message. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The constant <tt><font size=+1>IOHDRSZ</font></tt> is a suitable amount of buffer to reserve + for storing the 9P header; the data portion of a <tt><font size=+1>Twrite</font></tt> or <tt><font size=+1>Rread</font></tt> + will be no more than the buffer size negotiated in the <tt><font size=+1>Tversion/Rversion</font></tt> + exchange, minus <tt><font size=+1>IOHDRSZ</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The routine <i>sizeS2M</i> returns the number of bytes required to store + the machine-independent representation of the <tt><font size=+1>Fcall</font></tt> structure + <i>f</i>, including its initial 32-bit size field. In other words, it + reports the number of bytes produced by a successful call to <i>convS2M</i>. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Another structure is <tt><font size=+1>Dir</font></tt>, used by the routines described in <a href="../man3/stat.html"><i>stat</i>(3)</a>. + <i>ConvM2D</i> converts the machine-independent form starting at <i>ap</i> into + <i>d</i> and returns the length of the machine-independent encoding. + The strings in the returned <tt><font size=+1>Dir</font></tt> structure are stored at successive + locations starting at <tt><font size=+1>strs</font></tt>. Usually <tt><font size=+1>strs</font></tt> will + point to storage immediately after the <tt><font size=+1>Dir</font></tt> itself. It can also + be a <tt><font size=+1>nil</font></tt> pointer, in which case the string pointers in the returned + <tt><font size=+1>Dir</font></tt> are all <tt><font size=+1>nil</font></tt>; however, the return value still includes their + length. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>ConvD2M</i> does the reverse translation, also returning the length + of the encoding. If the buffer is too short, the return value + will be <tt><font size=+1>BIT16SZ</font></tt> and the correct size will be returned in the first + <tt><font size=+1>BIT16SZ</font></tt> bytes. (If the buffer is less that <tt><font size=+1>BIT16SZ</font></tt>, the return + value is zero; therefore a correct test for complete packing of + the + message is that the return value is greater than <tt><font size=+1>BIT16SZ</font></tt>). The + macro <tt><font size=+1>GBIT16</font></tt> can be used to extract the correct value. The related + macros with different sizes retrieve the corresponding-sized quantities. + <tt><font size=+1>PBIT16</font></tt> and its brethren place values in messages. With the exception + of handling short buffers in <i>convD2M</i>, + these macros are not usually needed except by internal routines. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Analogous to <i>sizeS2M</i>, <i>sizeD2M</i> returns the number of bytes required + to store the machine-independent representation of the <tt><font size=+1>Dir</font></tt> structure + <i>d</i>, including its initial 16-bit size field. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The routine <tt><font size=+1>statcheck</font></tt> checks whether the <i>nbuf</i> bytes of <i>buf</i> contain + a validly formatted machine-independent <tt><font size=+1>Dir</font></tt> entry suitable as + an argument, for example, for the <tt><font size=+1>wstat</font></tt> (see <a href="../man3/stat.html"><i>stat</i>(3)</a>) system call. + It checks that the sizes of all the elements of the the entry + sum to exactly <i>nbuf</i>, which is a simple but effective test + of validity. <i>Nbuf</i> and <i>buf</i> should include the second two-byte (16-bit) + length field that precedes the entry when formatted in a 9P message + (see <i>stat</i>(9p)); in other words, <i>nbuf</i> is 2 plus the sum of the + sizes of the entry itself. <i>Statcheck</i> also verifies that the length + field has the correct value (that is, <i>nbuf</i><tt><font size=+1>−2</font></tt>). It returns <tt><font size=+1>0 + </font></tt>for a valid entry and <tt><font size=+1>−1</font></tt> for an incorrectly formatted entry. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Dirfmt</i>, <i>fcallfmt</i>, and <i>dirmodefmt</i> are formatting routines, suitable + for <a href="../man3/fmtinstall.html"><i>fmtinstall</i>(3)</a>. They convert <tt><font size=+1>Dir*</font></tt>, <tt><font size=+1>Fcall*</font></tt>, and <tt><font size=+1>long</font></tt> values + into string representations of the directory buffer, <tt><font size=+1>Fcall</font></tt> buffer, + or file mode value. <i>Fcallfmt</i> assumes that <i>dirfmt</i> has been installed + with format letter <tt><font size=+1>D</font></tt> and <i>dirmodefmt</i> with format + letter <tt><font size=+1>M</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Read9pmsg</i> calls <a href="../man3/read.html"><i>read</i>(3)</a> multiple times, if necessary, to read + an entire 9P message into <tt><font size=+1>buf</font></tt>. The return value is 0 for end of + file, or -1 for error; it does not return partial messages.<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/lib9<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/intro.html"><i>intro</i>(3)</a>, <a href="../man3/9p.html"><i>9p</i>(3)</a>, <a href="../man3/stat.html"><i>stat</i>(3)</a>, <i>intro</i>(9p)<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> diff --git a/man/man3/flate.html b/man/man3/flate.html new file mode 100644 index 00000000..41591034 --- /dev/null +++ b/man/man3/flate.html @@ -0,0 +1,333 @@ +<head> +<title>flate(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>FLATE(3)</b><td align=right><b>FLATE(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> + + deflateinit, deflate, deflatezlib, deflateblock, deflatezlibblock, + inflateinit, inflate, inflatezlib, inflateblock, inflatezlibblock, + flateerr, mkcrctab, blockcrc, adler32 – deflate compression<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 <flate.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>int deflateinit(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int deflate(void *wr, int (*w)(void*,void*,int),<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + void *rr, int (*r)(void*,void*,int),<br> + int level, int debug) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>int deflatezlib(void *wr, int (*w)(void*,void*,int),<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + void *rr, int (*r)(void*,void*,int),<br> + int level, int debug) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>int deflateblock(uchar *dst, int dsize,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + uchar *src, int ssize,<br> + int level, int debug) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>int deflatezlibblock(uchar *dst, int dsize,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + uchar *src, int ssize,<br> + int level, int debug) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>int inflateinit(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int inflate(void *wr, int (*w)(void*, void*, int),<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + void *getr, int (*get)(void*)) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>int inflatezlib(void *wr, int (*w)(void*, void*, int),<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + void *getr, int (*get)(void*)) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>int inflateblock(uchar *dst, int dsize,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + uchar *src, int ssize) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>int inflatezlibblock(uchar *dst, int dsize,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + uchar *src, int ssize) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>char *flateerr(int error) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ulong *mkcrctab(ulong poly) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ulong blockcrc(ulong *tab, ulong crc, void *buf, int n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ulong adler32(ulong adler, void *buf, int n)<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 routines compress and decompress data using the deflate + compression algorithm, which is used for most gzip, zip, and zlib + files. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Deflate</i> compresses input data retrieved by calls to <i>r</i> with arguments + <i>rr</i>, an input buffer, and a count of bytes to read. <i>R</i> should return + the number of bytes read; end of input is signaled by returning + zero, an input error by returning a negative number. The compressed + output is written to <i>w</i> with arguments <i>wr</i>, the + output data, and the number of bytes to write. <i>W</i> should return + the number of bytes written; writing fewer than the requested + number of bytes is an error. <i>Level</i> indicates the amount of computation + deflate should do while compressing the data. Higher <i>levels</i> usually + take more time and produce smaller outputs. Valid + values are 1 to 9, inclusive; 6 is a good compromise. If <i>debug</i> + is non-zero, cryptic debugging information is produced on standard + error. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Inflate</i> reverses the process, converting compressed data into + uncompressed output. Input is retrieved one byte at a time by + calling <i>get</i> with the argument <i>getr</i>. End of input of signaled by + returning a negative value. The uncompressed output is written + to <i>w</i>, which has the same interface as for <i>deflate</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Deflateblock</i> and <i>inflateblock</i> operate on blocks of memory but + are otherwise similar to <i>deflate</i> and <i>inflate</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The zlib functions are similar, but operate on files with a zlib + header and trailer. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Deflateinit</i> or <i>inflateinit</i> must be called once before any call + to the corresponding routines. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + If the above routines fail, they return a negative number indicating + the problem. The possible values are <i>FlateNoMem</i>, <i>FlateInputFail</i>, + <i>FlateOutputFail</i>, <i>FlateCorrupted</i>, and <i>FlateInternal</i>. <i>Flateerr</i> converts + the number into a printable message. <i>FlateOk</i> is defined to be + zero, the successful return value for <i>deflateinit</i>, + <i>deflate</i>, <i>deflatezlib</i>, <i>inflateinit</i>, <i>inflate</i>, and <i>inflatezlib</i>. The + block functions return the number of bytes produced when they + succeed. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Mkcrctab</i> allocates (using <a href="../man3/malloc.html"><i>malloc</i>(3)</a>), initializes, and returns + a table for rapid computation of 32 bit CRC values using the polynomial + <i>poly</i>. <i>Blockcrc</i> uses <i>tab</i>, a table returned by <i>mkcrctab</i>, to update + <i>crc</i> for the <i>n</i> bytes of data in <i>buf</i>, and returns the new value. + <i>Crc</i> should initially be zero. <i>Blockcrc</i> pre-conditions and + post-conditions <i>crc</i> by ones complementation. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Adler32</i> updates the Adler 32-bit checksum of the <i>n</i> butes of data + in <i>buf.</i> The initial value of <i>adler</i> (that is, its value after seeing + zero bytes) should be 1.<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/libflate<br> + </font></tt> +</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> diff --git a/man/man3/fmtinstall.html b/man/man3/fmtinstall.html new file mode 100644 index 00000000..848c1333 --- /dev/null +++ b/man/man3/fmtinstall.html @@ -0,0 +1,339 @@ +<head> +<title>fmtinstall(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>FMTINSTALL(3)</b><td align=right><b>FMTINSTALL(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> + + fmtinstall, dofmt, dorfmt, fmtprint, fmtvprint, fmtrune, fmtstrcpy, + fmtrunestrcpy, fmtfdinit, fmtfdflush, fmtstrinit, fmtstrflush, + runefmtstrinit, runefmtstrflush, errfmt – support for user-defined + print formats and output routines<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>typedef struct Fmt Fmt;<br> + struct Fmt{<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + uchar runes; /* output buffer is runes or chars? */<br> + void *start; /* of buffer */<br> + void *to; /* current place in the buffer */<br> + void *stop; /* end of the buffer; overwritten if flush fails */<br> + int (*flush)(Fmt*);/* called when to == stop */<br> + void *farg; /* to make flush a closure */<br> + int nfmt; /* num chars formatted so far */<br> + va_list args; /* args passed to dofmt */<br> + int r; /* % format Rune */<br> + int width;<br> + int prec;<br> + ulong flags;<br> + + </table> + };<br> + enum{<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + FmtWidth = 1,<br> + FmtLeft = FmtWidth << 1,<br> + FmtPrec = FmtLeft << 1,<br> + FmtSharp = FmtPrec << 1,<br> + FmtSpace = FmtSharp << 1,<br> + FmtSign = FmtSpace << 1,<br> + FmtZero = FmtSign << 1,<br> + FmtUnsigned = FmtZero << 1,<br> + FmtShort = FmtUnsigned << 1,<br> + FmtLong = FmtShort << 1,<br> + FmtVLong = FmtLong << 1,<br> + FmtComma = FmtVLong << 1,<br> + FmtFlag = FmtComma << 1<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + int fmtfdinit(Fmt *f, int fd, char *buf, int nbuf); + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int fmtfdflush(Fmt *f); + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int fmtstrinit(Fmt *f); + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* fmtstrflush(Fmt *f); + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int runefmtstrinit(Fmt *f); + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rune* runefmtstrflush(Fmt *f);<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int fmtinstall(int c, int (*fn)(Fmt*)); + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int dofmt(Fmt *f, char *fmt); + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int dorfmt(Fmt*, Rune *fmt); + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int fmtprint(Fmt *f, char *fmt, ...); + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int fmtvprint(Fmt *f, char *fmt, va_list v); + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int fmtrune(Fmt *f, int r); + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int fmtstrcpy(Fmt *f, char *s); + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int fmtrunestrcpy(Fmt *f, Rune *s); + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int errfmt(Fmt *f);<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> + + The interface described here allows the construction of custom + <a href="../man3/print.html"><i>print</i>(3)</a> verbs and output routines. In essence, they provide access + to the workings of the formatted print code. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The <a href="../man3/print.html"><i>print</i>(3)</a> suite maintains its state with a data structure called + <tt><font size=+1>Fmt</font></tt>. A typical call to <a href="../man3/print.html"><i>print</i>(3)</a> or its relatives initializes a + <tt><font size=+1>Fmt</font></tt> structure, passes it to subsidiary routines to process the + output, and finishes by emitting any saved state recorded in the + <tt><font size=+1>Fmt</font></tt>. The details of the <tt><font size=+1>Fmt</font></tt> are unimportant to outside users, + except + insofar as the general design influences the interface. The <tt><font size=+1>Fmt</font></tt> + records whether the output is in runes or bytes, the verb being + processed, its precision and width, and buffering parameters. + Most important, it also records a <i>flush</i> routine that the library + will call if a buffer overflows. When printing to a file descriptor, + the + flush routine will emit saved characters and reset the buffer; + when printing to an allocated string, it will resize the string + to receive more output. The flush routine is nil when printing + to fixed-size buffers. User code need never provide a flush routine; + this is done internally by the library.<br> + <p><font size=+1><b>Custom output routines </b></font><br> + To write a custom output routine, such as an error handler that + formats and prints custom error messages, the output sequence + can be run from outside the library using the routines described + here. There are two main cases: output to an open file descriptor + and output to a string. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + To write to a file descriptor, call <i>fmtfdinit</i> to initialize the + local <tt><font size=+1>Fmt</font></tt> structure <i>f</i>, giving the file descriptor <i>fd</i>, the buffer + <i>buf</i>, and its size <i>nbuf</i>. Then call <i>fmtprint</i> or <i>fmtvprint</i> to generate + the output. These behave like <tt><font size=+1>fprint</font></tt> (see <a href="../man3/print.html"><i>print</i>(3)</a>) or <tt><font size=+1>vfprint</font></tt> + except that the characters are buffered until <i>fmtfdflush</i> is called + and the return value is either 0 or –1. A typical example of this + sequence appears in the Examples section. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The same basic sequence applies when outputting to an allocated + string: call <i>fmtstrinit</i> to initialize the <tt><font size=+1>Fmt</font></tt>, then call <i>fmtprint</i> + and <i>fmtvprint</i> to generate the output. Finally, <i>fmtstrflush</i> will + return the allocated string, which should be freed after use. + To output to a rune string, use <i>runefmtstrinit</i> and <i>runefmtstrflush</i>. + Regardless of the output style or type, <i>fmtprint</i> or <i>fmtvprint</i> + generates the characters.<br> + <p><font size=+1><b>Custom format verbs </b></font><br> + <i>Fmtinstall</i> is used to install custom verbs and flags labeled by + character <i>c</i>, which may be any non-zero Unicode character. <i>Fn</i> should + be declared as<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>int fn(Fmt*)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + <i>Fp</i><tt><font size=+1>−>r</font></tt> is the flag or verb character to cause <i>fn</i> to be called. In + <i>fn</i>, <i>fp</i><tt><font size=+1>−>width</font></tt><i>, fp</i><tt><font size=+1>−>prec</font></tt> are the width and precision, and <i>fp</i><tt><font size=+1>−>flags</font></tt> + the decoded flags for the verb (see <a href="../man3/print.html"><i>print</i>(3)</a> for a description + of these items). The standard flag values are: <tt><font size=+1>FmtSign</font></tt> (<tt><font size=+1>+</font></tt>), <tt><font size=+1>FmtLeft</font></tt> + (<tt><font size=+1>−</font></tt>), <tt><font size=+1>FmtSpace</font></tt> (<tt><font size=+1>' '</font></tt>), <tt><font size=+1>FmtSharp</font></tt> (<tt><font size=+1>#</font></tt>), + <tt><font size=+1>FmtComma</font></tt> (<tt><font size=+1>,</font></tt>), <tt><font size=+1>FmtLong</font></tt> (<tt><font size=+1>l</font></tt>), <tt><font size=+1>FmtShort</font></tt> (<tt><font size=+1>h</font></tt>), <tt><font size=+1>FmtUnsigned</font></tt> (<tt><font size=+1>u</font></tt>), and + <tt><font size=+1>FmtVLong</font></tt> (<tt><font size=+1>ll</font></tt>). The flag bits <tt><font size=+1>FmtWidth</font></tt> and <tt><font size=+1>FmtPrec</font></tt> identify whether + a width and precision were specified. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Fn</i> is passed a pointer to the <tt><font size=+1>Fmt</font></tt> structure recording the state + of the output. If <i>fp</i><tt><font size=+1>−>r</font></tt> is a verb (rather than a flag), <i>fn</i> should + use <tt><font size=+1>Fmt−>args</font></tt> to fetch its argument from the list, then format + it, and return zero. If <i>fp</i><tt><font size=+1>−>r</font></tt> is a flag, <i>fn</i> should return one. + All interpretation of <i>fp</i><tt><font size=+1>−>width</font></tt>, <i>fp</i><tt><font size=+1>−>prec</font></tt>, and <i>fp-></i><tt><font size=+1>flags</font></tt> is + left up to the conversion routine. <i>Fmtinstall</i> returns 0 if the + installation succeeds, –1 if it fails. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Fmtprint</i> and <i>fmtvprint</i> may be called to help prepare output in + custom conversion routines. However, these functions clear the + width, precision, and flags. Both functions return 0 for success + and –1 for failure. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The functions <i>dofmt</i> and <i>dorfmt</i> are the underlying formatters; + they use the existing contents of <tt><font size=+1>Fmt</font></tt> and should be called only + by sophisticated conversion routines. These routines return the + number of characters (bytes of UTF or runes) produced. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Some internal functions may be useful to format primitive types. + They honor the width, precision and flags as described in <a href="../man3/print.html"><i>print</i>(3)</a>. + <i>Fmtrune</i> formats a single character <tt><font size=+1>r</font></tt>. <i>Fmtstrcpy</i> formats a string + <tt><font size=+1>s</font></tt>; <i>fmtrunestrcpy</i> formats a rune string <tt><font size=+1>s</font></tt>. <i>Errfmt</i> formats the system + error string. All these routines return zero for + successful execution. Conversion routines that call these functions + will work properly regardless of whether the output is bytes or + runes.<br> + +</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 function prints an error message with a variable number of + arguments and then quits. Compared to the corresponding example + in <a href="../man3/print.html"><i>print</i>(3)</a>, this version uses a smaller buffer, will never truncate + the output message, but might generate multiple <tt><font size=+1>write</font></tt> system calls + to produce its output. + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>#pragma varargck argpos error 1<br> + void fatal(char *fmt, ...)<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Fmt f;<br> + char buf[64];<br> + va_list arg;<br> + fmtfdinit(&f, 1, buf, sizeof buf);<br> + fmtprint(&f, "fatal: ");<br> + va_start(arg, fmt);<br> + fmtvprint(&f, fmt, arg);<br> + va_end(arg);<br> + fmtprint(&f, "\n");<br> + fmtfdflush(&f);<br> + exits("fatal error");<br> + + </table> + }<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + This example adds a verb to print complex numbers.<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef<br> + struct {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + double r, i;<br> + + </table> + } Complex;<br> + #pragma varargck type "X" Complex<br> + int<br> + Xfmt(Fmt *f)<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Complex c;<br> + c = va_arg(f−>args, Complex);<br> + return fmtprint(f, "(%g,%g)", c.r, c.i);<br> + + </table> + }<br> + main(...)<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Complex x = (Complex){ 1.5, −2.3 };<br> + fmtinstall('X', Xfmt);<br> + print("x = %X\n", x);<br> + + </table> + }<br> + </font></tt> + </table> + +</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/lib9/fmt<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/print.html"><i>print</i>(3)</a>, <a href="../man7/utf.html"><i>utf</i>(7)</a>, <a href="../man3/errstr.html"><i>errstr</i>(3)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + These routines return negative numbers or nil for errors and set + <i>errstr</i>.<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> diff --git a/man/man3/frame.html b/man/man3/frame.html new file mode 100644 index 00000000..4a80453c --- /dev/null +++ b/man/man3/frame.html @@ -0,0 +1,325 @@ +<head> +<title>frame(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>FRAME(3)</b><td align=right><b>FRAME(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> + + frinit, frsetrects, frinittick, frclear, frcharofpt, frptofchar, + frinsert, frdelete, frselect, frtick, frselectpaint, frdrawsel, + frdrawsel0, frgetmouse – frames of text<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 <draw.h><br> + #include <thread.h><br> + #include <mouse.h><br> + #include <frame.h><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void frinit(Frame *f, Rectangle r, Font *ft, Image *b, Image **cols)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void frsetrects(Frame *f, Rectangle r, Image *b)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void frinittick(Frame *f)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void frclear(Frame *f, int resize)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ulong frcharofpt(Frame *f, Point pt)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point frptofchar(Frame *f, ulong p)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void frinsert(Frame *f, Rune *r0, Rune *r1, ulong p)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int frdelete(Frame *f, ulong p0, ulong p1)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void frselect(Frame *f, Mousectl *m)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void frtick(Frame *f, Point pt, int up)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void frselectpaint(Frame *f, Point p0, Point p1, Image *col)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void frdrawsel(Frame *f, Point pt0, ulong p0, ulong p1,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int highlighted)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>void frdrawsel0(Frame *f, Point pt0, ulong p0, ulong p1,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Image *back, Image *text)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>enum{<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + BACK,<br> + HIGH,<br> + BORD,<br> + TEXT,<br> + HTEXT,<br> + NCOL<br> + + </table> + };<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> + + This library supports <i>frames</i> of editable text in a single font + on raster displays, such as in <a href="../man1/sam.html"><i>sam</i>(1)</a> and <a href="../man1/9term.html"><i>9term</i>(1)</a>. Frames may + hold any character except NUL (0). Long lines are folded and tabs + are at fixed intervals. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The user-visible data structure, a <tt><font size=+1>Frame</font></tt>, is defined in <tt><font size=+1><frame.h></font></tt>:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef struct Frame Frame;<br> + struct Frame<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Font *font; /* of chars in the frame */<br> + Display *display; /* on which frame appears */<br> + Image *b; /* on which frame appears */<br> + Image *cols[NCOL]; /* text and background colors */<br> + Rectangle r; /* in which text appears */<br> + Rectangle entire; /* of full frame */<br> + Frbox *box;<br> + ulong p0, p1; /* selection */<br> + ushort nbox, nalloc;<br> + ushort maxtab; /* max size of tab, in pixels */<br> + ushort nchars; /* # runes in frame */<br> + ushort nlines; /* # lines with text */<br> + ushort maxlines; /* total # lines in frame */<br> + ushort lastlinefull; /* last line fills frame */<br> + ushort modified; /* changed since frselect() */<br> + Image *tick; /* typing tick */<br> + Image *tickback; /* saved image under tick */<br> + int ticked; /* flag: is tick onscreen? */<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + <tt><font size=+1>Frbox</font></tt> is an internal type and is not used by the interface. <tt><font size=+1>P0</font></tt> + and <tt><font size=+1>p1</font></tt> may be changed by the application provided the selection + routines are called afterwards to maintain a consistent display. + <i>Maxtab</i> determines the size of tab stops. <i>Frinit</i> sets it to 8 times + the width of a <tt><font size=+1>0</font></tt> (zero) character in the font; it may be + changed before any text is added to the frame. The other elements + of the structure are maintained by the library and should not + be modified directly. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The text within frames is not directly addressable; instead frames + are designed to work alongside another structure that holds the + text. The typical application is to display a section of a longer + document such as a text file or terminal session. Usually the + program will keep its own copy of the text in the window + (probably as an array of <tt><font size=+1>Runes</font></tt>) and pass components of this text + to the frame routines to display the visible portion. Only the + text that is visible is held by the <tt><font size=+1>Frame</font></tt>; the application must + check <tt><font size=+1>maxlines</font></tt>, <tt><font size=+1>nlines</font></tt>, and <tt><font size=+1>lastlinefull</font></tt> to determine, for example, + whether new text needs to be appended at the + end of the <tt><font size=+1>Frame</font></tt> after calling <i>frdelete</i> (q.v.). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + There are no routines in the library to allocate <tt><font size=+1>Frames</font></tt>; instead + the interface assumes that <tt><font size=+1>Frames</font></tt> will be components of larger + structures. <i>Frinit</i> prepares the <tt><font size=+1>Frame</font></tt> <i>f</i> so characters drawn in + it will appear in the single <tt><font size=+1>Font</font></tt> <i>ft</i>. It then calls <i>frsetrects</i> + and <i>frinittick</i> to initialize the geometry for the <tt><font size=+1>Frame</font></tt>. The <tt><font size=+1>Image + </font></tt><i>b</i> is where the <tt><font size=+1>Frame</font></tt> is to be drawn; <tt><font size=+1>Rectangle</font></tt> <i>r</i> defines the limit + of the portion of the <tt><font size=+1>Image</font></tt> the text will occupy. The <tt><font size=+1>Image</font></tt> pointer + may be null, allowing the other routines to be called to maintain + the associated data structure in, for example, an obscured window. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The array of <tt><font size=+1>Images</font></tt> cols sets the colors in which text and borders + will be drawn. The background of the frame will be drawn in <tt><font size=+1>cols[BACK]</font></tt>; + the background of highlighted text in <tt><font size=+1>cols[HIGH]</font></tt>; borders and + scroll bar in <tt><font size=+1>cols[BORD]</font></tt>; regular text in <tt><font size=+1>cols[TEXT]</font></tt>; and highlighted + text in <tt><font size=+1>cols[HTEXT]</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Frclear</i> frees the internal structures associated with <i>f</i>, permitting + another <i>frinit</i> or <i>frsetrects</i> on the <tt><font size=+1>Frame</font></tt>. It does not clear the + associated display. If <i>f</i> is to be deallocated, the associated + <tt><font size=+1>Font</font></tt> and <tt><font size=+1>Image</font></tt> must be freed separately. The <tt><font size=+1>resize</font></tt> argument should + be non-zero if the frame is to be redrawn with a + different font; otherwise the frame will maintain some data structures + associated with the font. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + To resize a <tt><font size=+1>Frame</font></tt>, use <i>frclear</i> and <i>frinit</i> and then <i>frinsert</i> (q.v.) + to recreate the display. If a <tt><font size=+1>Frame</font></tt> is being moved but not resized, + that is, if the shape of its containing rectangle is unchanged, + it is sufficient to use <a href="../man3/draw.html"><i>draw</i>(3)</a> to copy the containing rectangle + from the old to the new location and then call <i>frsetrects</i> to + establish the new geometry. (It is unnecessary to call <i>frinittick</i> + unless the font size has changed.) No redrawing is necessary. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>Frames</font></tt> hold text as runes, not as bytes. <i>Frptofchar</i> returns the + location of the upper left corner of the <i>p’th</i> rune, starting from + 0, in the <tt><font size=+1>Frame</font></tt> <i>f</i>. If <i>f</i> holds fewer than <i>p</i> runes, <i>frptofchar</i> returns + the location of the upper right corner of the last character in + <i>f</i>. <i>Frcharofpt</i> is the inverse: it returns the index of the closest + rune whose image’s upper left corner is up and to the left of + <i>pt</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Frinsert</i> inserts into <tt><font size=+1>Frame</font></tt> <i>f</i> starting at rune index <i>p</i> the runes + between <i>r0</i> and <i>r1</i>. If a NUL (0) character is inserted, chaos will + ensue. Tabs and newlines are handled by the library, but all other + characters, including control characters, are just displayed. + For example, backspaces are printed; to erase a character, use + <i>frdelete</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Frdelete</i> deletes from the <tt><font size=+1>Frame</font></tt> the text between <i>p0</i> and <i>p1</i>; <i>p1</i> + points at the first rune beyond the deletion. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Frselect</i> tracks the mouse to select a contiguous string of text + in the <tt><font size=+1>Frame</font></tt>. When called, a mouse button is typically down. <i>Frselect</i> + will return when the button state has changed (some buttons may + still be down) and will set <i>f</i><tt><font size=+1>−>p0</font></tt> and <i>f</i><tt><font size=+1>−>p1</font></tt> to the selected range + of text. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Programs that wish to manage the selection themselves have several + routines to help. They involve the maintenance of the ‘tick’, + the vertical line indicating a null selection between characters, + and the colored region representing a non-null selection. <i>Frtick</i> + draws (if <i>up</i> is non-zero) or removes (if <i>up</i> is zero) the tick + at + the screen position indicated by <i>pt</i>. <i>Frdrawsel</i> repaints a section + of the frame, delimited by character positions <i>p0</i> and <i>p1</i>, either + with plain background or entirely highlighted, according to the + flag <i>highlighted</i>, managing the tick appropriately. The point <i>pt0</i> + is the geometrical location of <i>p0</i> on the screen; like all of the + selection-helper routines’ <tt><font size=+1>Point</font></tt> arguments, it must be a value + generated by <i>frptofchar</i>. <i>Frdrawsel0</i> is a lower-level routine, + taking as arguments a background color, <i>back</i>, and text color, + <i>text</i>. It assumes that the tick is being handled (removed beforehand, + replaced afterwards, as required) by its caller. <i>Frselectpaint + </i>uses a solid color, <i>col</i>, to paint a region of the frame defined + by the <tt><font size=+1>Points</font></tt> <i>p0</i> and <i>p1</i>.<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/libframe<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/graphics.html"><i>graphics</i>(3)</a>, <a href="../man3/draw.html"><i>draw</i>(3)</a>, <a href="../man3/cachechars.html"><i>cachechars</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> diff --git a/man/man3/genrandom.html b/man/man3/genrandom.html new file mode 100644 index 00000000..0cddd21d --- /dev/null +++ b/man/man3/genrandom.html @@ -0,0 +1,84 @@ +<head> +<title>genrandom(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>GENRANDOM(3)</b><td align=right><b>GENRANDOM(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> + + genrandom, prng – random number generation<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 <mp.h><br> + #include <libsec.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void genrandom(uchar *buf, int nbytes) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void prng(uchar *buf, int nbytes)<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> + + Most security software requires a source of random or, at the + very least, unguessable numbers. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Genrandom</i> fills a buffer with bytes from the X9.17 pseudo-random + number generator. The X9.17 generator is seeded by 24 truly random + bytes read via <i>truerand</i> (see <a href="../man3/rand.html"><i>rand</i>(3)</a>). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Prng</i> uses the native <a href="../man3/rand.html"><i>rand</i>(3)</a> pseudo-random number generator to + fill the buffer. Used with <i>srand</i>, this function can produce a + reproducible stream of pseudo random numbers useful in testing. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Both functions may be passed to <i>mprand</i> (see <a href="../man3/mp.html"><i>mp</i>(3)</a>).<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/libsec<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/mp.html"><i>mp</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> diff --git a/man/man3/get9root.html b/man/man3/get9root.html new file mode 100644 index 00000000..6ca02c02 --- /dev/null +++ b/man/man3/get9root.html @@ -0,0 +1,109 @@ +<head> +<title>get9root(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>GET9ROOT(3)</b><td align=right><b>GET9ROOT(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> + + get9root, unsharp – get path to root of Plan 9 tree<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* get9root(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* unsharp(char *path)<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> + + This tree of Plan 9 software is conventionally installed in <tt><font size=+1>/usr/local/plan9</font></tt> + but may be installed in other places (for example, users without + the ability to write to <tt><font size=+1>/usr/local</font></tt> may with to install it in their + own home directories). The environment variable <tt><font size=+1>$PLAN9</font></tt> should + contain the path to the root. <i>Get9root + </i>returns a static pointer to the pathname of root, first checking + <tt><font size=+1>$PLAN9</font></tt> and defaulting to <tt><font size=+1>/usr/local/plan9</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The lack of a fixed location for the Plan 9 tree makes it difficult + to hard-code paths to files. <i>Unsharp</i> replaces a leading <tt><font size=+1>#9</font></tt> in + <i>path</i> with the root of the tree. <i>Unsharp</i> also replaces a leading + <tt><font size=+1>#d</font></tt> with the path to the underlying system’s file descriptor dup + device, typically <tt><font size=+1>/dev/fd</font></tt>. The string returned from <i>unsharp</i>, if + different from <i>path</i>, should be freed with <i>free</i> (see <a href="../man3/malloc.html"><i>malloc</i>(3)</a>) + when no longer needed. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + As a convention, programs should never <i>unsharp</i> paths obtained + from user input.<br> + +</table> +<p><font size=+1><b>EXAMPLE </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The <a href="../man4/plumber.html"><i>plumber</i>(4)</a> uses this code to find unrooted file names included + by plumb rules.<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>snprint(buf, sizeof buf, "#9/plumb/%s", name);<br> + fd = open(unsharp(buf), OREAD);<br> + </font></tt> + </table> + +</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/lib9/getns.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="../man4/intro.html"><i>intro</i>(4)</a><br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Get9root</i> could be smarter about finding the tree when <tt><font size=+1>$PLAN9</font></tt> is + not set.<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> diff --git a/man/man3/getcallerpc.html b/man/man3/getcallerpc.html new file mode 100644 index 00000000..72a835d1 --- /dev/null +++ b/man/man3/getcallerpc.html @@ -0,0 +1,99 @@ +<head> +<title>getcallerpc(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>GETCALLERPC(3)</b><td align=right><b>GETCALLERPC(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> + + getcallerpc – fetch return PC of current function<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ulong getcallerpc(void *firstarg)<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> + + <i>Getcallerpc</i> is a portable way to discover the PC to which the + current function will return. <i>Firstarg</i> should be a pointer to + the first argument to the function in question.<br> + +</table> +<p><font size=+1><b>EXAMPLE </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>void<br> + printpc(ulong arg)<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + print("Called from %.8lux\n", getcallerpc(&arg));<br> + + </table> + }<br> + void<br> + main(int argc, char *argv[])<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + printpc(0);<br> + printpc(0);<br> + printpc(0);<br> + + </table> + }<br> + </font></tt> + </table> + +</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/lib9/<br> + </font></tt> +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The <i>firstarg</i> parameter should not be necessary.<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> diff --git a/man/man3/getenv.html b/man/man3/getenv.html new file mode 100644 index 00000000..5b51354c --- /dev/null +++ b/man/man3/getenv.html @@ -0,0 +1,79 @@ +<head> +<title>getenv(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>GETENV(3)</b><td align=right><b>GETENV(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> + + getenv, putenv – access environment variables<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* getenv(char *name)<br> + int putenv(char *name, char *val)<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> + + <i>Getenv</i> fetches the environment value associated with <i>name</i> into + memory allocated with <a href="../man3/malloc.html"><i>malloc</i>(3)</a>, 0-terminates it, and returns + a pointer to that area. If no file exists, 0 is returned. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Putenv</i> sets the environment value associated with <i>name</i> to <i>val</i>.<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/lib9/getenv.c<br> + </font></tt> +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Sets <i>errstr</i>.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + To avoid name conflicts with the underlying system, <i>getenv</i> and + <i>putenv</i> are preprocessor macros defined as <i>p9getenv</i> and <i>p9putenv</i>; + see <a href="../man3/intro.html"><i>intro</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> diff --git a/man/man3/getfields.html b/man/man3/getfields.html new file mode 100644 index 00000000..7c1d8f64 --- /dev/null +++ b/man/man3/getfields.html @@ -0,0 +1,136 @@ +<head> +<title>getfields(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>GETFIELDS(3)</b><td align=right><b>GETFIELDS(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> + + getfields, gettokens, tokenize – break a string into fields<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int getfields(char *str, char **args, int maxargs, int multiflag,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + char *delims) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>int gettokens(char *str, char **args, int maxargs, char *delims) + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int tokenize(char *str, char **args, int maxargs)<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> + + <i>Getfields</i> places into the array <i>args</i> pointers to the first <i>maxargs</i> + fields of the null terminated UTF string <i>str</i>. Delimiters between + these fields are set to null. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Fields are substrings of <i>str</i> whose definition depends on the value + of <i>multiflag.</i> If <i>multiflag</i> is zero, adjacent fields are separated + by exactly one delimiter. For example<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>getfields("#alice#bob##charles###", arg, 3, 0, "#");<br> + </font></tt> + </table> + + </table> + yields three substrings: null-string , <tt><font size=+1>alice</font></tt>, and <tt><font size=+1>bob##charles###</font></tt>. + If the <i>multiflag</i> argument is not zero, a field is a non-empty + string of non-delimiters. For example<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>getfields("#alice#bob##charles###", arg, 3, 1, "#");<br> + </font></tt> + </table> + + </table> + yields the three substrings: <tt><font size=+1>alice</font></tt>, <tt><font size=+1>bob</font></tt>, and <tt><font size=+1>charles###</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Getfields returns the number of fields pointed to. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Gettokens</i> is the same as <i>getfields</i> with <i>multiflag</i> non-zero, except + that fields may be quoted using single quotes, in the manner of + <a href="../man1/rc.html"><i>rc</i>(1)</a>. See <a href="../man3/quote.html"><i>quote</i>(3)</a> for related quote-handling software. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Tokenize</i> is <i>gettokens</i> with <i>delims</i> set to <tt><font size=+1>"\t\r\n "</font></tt>.<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/lib9/tokenize.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> + + <i>strtok</i> in <a href="../man3/strcat.html"><i>strcat</i>(3)</a>, <a href="../man3/quote.html"><i>quote</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> diff --git a/man/man3/getns.html b/man/man3/getns.html new file mode 100644 index 00000000..e5da2bb2 --- /dev/null +++ b/man/man3/getns.html @@ -0,0 +1,67 @@ +<head> +<title>getns(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>GETNS(3)</b><td align=right><b>GETNS(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> + + getns – get path to name space directory<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* getns(void)<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> + + <i>Getns</i> returns a pointer to a malloced string that contains the + path to the name space directory for the current process. The + name space directory is a clumsy substitute for Plan 9’s per-process + name spaces; see <a href="../man4/intro.html"><i>intro</i>(4)</a> for details.<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/lib9/getns.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="../man4/intro.html"><i>intro</i>(4)</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> diff --git a/man/man3/getsnarf.html b/man/man3/getsnarf.html new file mode 100644 index 00000000..3f3e7512 --- /dev/null +++ b/man/man3/getsnarf.html @@ -0,0 +1,73 @@ +<head> +<title>getsnarf(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>GETSNARF(3)</b><td align=right><b>GETSNARF(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> + + getsnarf, putsnarf – window system snarf (cut and paste) buffer<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 <draw.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char *getsnarf(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void putsnarf(char *text)<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> + + <i>Getsnarf</i> and <i>putsnarf</i> access the window system’s snarf (cut and + paste) buffer. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Getsnarf</i> returns a copy of the current buffer; the returned pointer + should be freed with <i>free</i> (see <a href="../man3/malloc.html"><i>malloc</i>(3)</a>) when no longer needed. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Putsnarf</i> sets the buffer to the text string <i>text</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Callers should assume that the snarf buffer is UTF. If the window + system does not keep the buffer in UTF, <i>getsnarf</i> and <i>putsnarf</i> + will convert as necessary.<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/libdraw/x11−itrans.c<br> + </font></tt> +</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> diff --git a/man/man3/getuser.html b/man/man3/getuser.html new file mode 100644 index 00000000..c34b23cf --- /dev/null +++ b/man/man3/getuser.html @@ -0,0 +1,75 @@ +<head> +<title>getuser(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>GETUSER(3)</b><td align=right><b>GETUSER(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> + + getuser, sysname – get user or system name<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* getuser(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* sysname(void)<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> + + <i>Getuser</i> returns a pointer to static data which contains the null-terminated + name of the user who owns the current process. <i>Getuser</i> calls <a href="../man2/getuid.html"><i>getuid</i>(2)</a> + and then reads <tt><font size=+1>/etc/passwd</font></tt> to find the corresponding name. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Sysname</i> returns a pointer to static data which contains the name + of the machine on which the current process is running. <i>Sysname</i> + looks first for an environment variable <tt><font size=+1>$sysname</font></tt>. If there is + no such variable, <i>sysname</i> calls <a href="../man2/gethostname.html"><i>gethostname</i>(2)</a> and truncates the + returned name at the first dot. If <i>gethostname</i> fails, + <i>sysname</i> returns the default name <tt><font size=+1>gnot</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Unlike <i>getuser</i>, <i>sysname</i> caches the string, deriving the host name + only once.<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/lib9/getuser.c<br> + /usr/local/plan9/src/lib9/sysname.c<br> + </font></tt> +</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> diff --git a/man/man3/getwd.html b/man/man3/getwd.html new file mode 100644 index 00000000..1f5d2288 --- /dev/null +++ b/man/man3/getwd.html @@ -0,0 +1,84 @@ +<head> +<title>getwd(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>GETWD(3)</b><td align=right><b>GETWD(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> + + getwd – get current directory<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* getwd(char *buf, int size)<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> + + <i>Getwd</i> fills <i>buf</i> with a null-terminated string representing the + current directory and returns <i>buf</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Getwd</i> places no more than <i>size</i> bytes in the buffer provided.<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/lib9/getwd.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="../man1/pwd.html"><i>pwd</i>(1)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + On error, zero is returned. <a href="../man3/Errstr.html"><i>Errstr</i>(3)</a> may be consulted for more + information.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + To avoid name conflicts with the underlying system, <i>getwd</i> is a + preprocessor macro defined as <i>p9getwd</i>; see <a href="../man3/intro.html"><i>intro</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> diff --git a/man/man3/graphics.html b/man/man3/graphics.html new file mode 100644 index 00000000..92f08c00 --- /dev/null +++ b/man/man3/graphics.html @@ -0,0 +1,592 @@ +<head> +<title>graphics(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>GRAPHICS(3)</b><td align=right><b>GRAPHICS(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> + + Display, Point, Rectangle, Cursor, initdraw, geninitdraw, drawerror, + initdisplay, closedisplay, getdefont, getwindow, gengetwindow, + flushimage, bufimage, lockdisplay, unlockdisplay, cursorswitch, + cursorset, openfont, buildfont, freefont, Pfmt, Rfmt, strtochan, + chantostr, chantodepth – interactive graphics + +</table> +<p><font size=+1><b>SYNOPSIS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<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 <draw.h><br> + #include <cursor.h><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int initdraw(void (*errfun)(Display*, char*), char *font,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + char *label)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>int geninitdraw(char *devdir, void(*errfun)(Display*, char*),<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>char *font, char *label, char *mousedir, char *windir,<br> + int ref)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + + </table> + <tt><font size=+1>int newwindow(char *str)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void drawerror(Display *d, char *msg)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Display*initdisplay(char *devdir, char *win, void(*errfun)(Display*, + char*))<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void closedisplay(Display *d)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Font* getdefont(Display *d)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int flushimage(Display *d, int vis)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int bufimage(Display *d, int n)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int lockdisplay(Display *d)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int unlockdisplay(Display *d)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int getwindow(Display *d, int ref)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int gengetwindow(Display *d, char *winname,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Image **ip, Screen **sp, int ref)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>void cursorswitch(Cursor *curs)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void cursorset(Point p)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Font* openfont(Display *d, char *name)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Font* buildfont(Display *d, char *desc, char *name)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void freefont(Font *f)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int Pfmt(Fmt*)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int Rfmt(Fmt*)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ulong strtochan(char *s)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* chantostr(char *s, ulong chan)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int chantodepth(ulong chan)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>extern Display *display<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>extern Image *screen<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>extern Screen *_screen<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>extern Font *font<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> + + A <tt><font size=+1>Display</font></tt> structure represents a connection to the graphics device, + <a href="../man3/draw.html"><i>draw</i>(3)</a>, holding all graphics resources associated with the connection, + including in particular raster image data in use by the client + program. The structure is defined (in part) as:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef<br> + struct Display<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + ...<br> + void (*error)(Display*, char*);<br> + ...<br> + Image *black;<br> + Image *white;<br> + Image *opaque;<br> + Image *transparent;<br> + Image *image;<br> + Font *defaultfont;<br> + Subfont*defaultsubfont;<br> + ...<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + A <tt><font size=+1>Point</font></tt> is a location in an Image (see below and <a href="../man3/draw.html"><i>draw</i>(3)</a>), such + as the display, and is defined as:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef<br> + struct Point {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int x;<br> + int y;<br> + + </table> + } Point;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + The coordinate system has <i>x</i> increasing to the right and <i>y</i> increasing + down. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + A <tt><font size=+1>Rectangle</font></tt> is a rectangular area in an image.<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef<br> + struct Rectangle {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Point min; /* upper left */<br> + Point max; /* lower right */<br> + + </table> + } Rectangle;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + By definition, <tt><font size=+1>min.x</font></tt>≤<tt><font size=+1>max.x</font></tt> and <tt><font size=+1>min.y</font></tt>≤<tt><font size=+1>max.y</font></tt>. By convention, the right + (maximum <i>x</i>) and bottom (maximum <i>y</i>) edges are excluded from the + represented rectangle, so abutting rectangles have no points in + common. Thus, <tt><font size=+1>max</font></tt> contains the coordinates of the first point + beyond the rectangle. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The <tt><font size=+1>Image</font></tt> data structure is defined in <a href="../man3/draw.html"><i>draw</i>(3)</a>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + A <tt><font size=+1>Font</font></tt> is a set of character images, indexed by runes (see <a href="../man7/utf.html"><i>utf</i>(7)</a>). + The images are organized into <tt><font size=+1>Subfonts</font></tt>, each containing the images + for a small, contiguous set of runes. The detailed format of these + data structures, which are described in detail in <a href="../man3/cachechars.html"><i>cachechars</i>(3)</a>, + is immaterial for most applications. <tt><font size=+1>Font</font></tt> and + <tt><font size=+1>Subfont</font></tt> structures contain two interrelated fields: <tt><font size=+1>ascent</font></tt>, the + distance from the top of the highest character (actually the top + of the image holding all the characters) to the baseline, and + <tt><font size=+1>height</font></tt>, the distance from the top of the highest character to + the bottom of the lowest character (and hence, the interline + spacing). See <a href="../man3/cachechars.html"><i>cachechars</i>(3)</a> for more details. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Buildfont</i> parses the font description in the buffer <tt><font size=+1>desc</font></tt>, returning + a <tt><font size=+1>Font*</font></tt> pointer that can be used by <tt><font size=+1>string</font></tt> (see <a href="../man3/draw.html"><i>draw</i>(3)</a>) to draw + characters from the font. <i>Openfont</i> does the same, but reads the + description from the named file. <i>Freefont</i> frees a font. The convention + for naming font files is: + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>/lib/font/bit/</font></tt><i>name</i><tt><font size=+1>/</font></tt><i>range</i><tt><font size=+1>.</font></tt><i>size</i><tt><font size=+1>.font + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + where <i>size</i> is approximately the height in pixels of the lower + case letters (without ascenders or descenders). <i>Range</i> gives some + indication of which characters will be available: for example + <tt><font size=+1>ascii</font></tt>, <tt><font size=+1>latin1</font></tt>, <tt><font size=+1>euro</font></tt>, or <tt><font size=+1>unicode</font></tt>. <tt><font size=+1>Euro</font></tt> includes most European languages, + punctuation marks, the International Phonetic + Alphabet, etc., but no Oriental languages. <tt><font size=+1>Unicode</font></tt> includes every + character for which appropriate-sized images exist on the system. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + A <i>Cursor</i> is defined:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef struct<br> + Cursor {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Point offset;<br> + uchar clr[2*16];<br> + uchar set[2*16];<br> + + </table> + } Cursor;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + The arrays are arranged in rows, two bytes per row, left to right + in big-endian order to give 16 rows of 16 bits each. A cursor + is displayed on the screen by adding <tt><font size=+1>offset</font></tt> to the current mouse + position, using <tt><font size=+1>clr</font></tt> as a mask to draw white at the pixels where + <tt><font size=+1>clr</font></tt> is one, and then drawing black at the pixels where <tt><font size=+1>set + </font></tt>is one. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The routine <i>initdraw</i> connects to the display; it returns –1 if + it fails and sets the error string. <i>Initdraw</i> sets up the global + variables <tt><font size=+1>display</font></tt> (the <tt><font size=+1>Display</font></tt> structure representing the connection), + <tt><font size=+1>screen</font></tt> (an <tt><font size=+1>Image</font></tt> representing the display memory itself or, if + <a href="../man1/rio.html"><i>rio</i>(1)</a> is running, the client’s window), and <tt><font size=+1>font</font></tt> (the + default font for text). The arguments to <i>initdraw</i> include a <i>label</i>, + which is written to <tt><font size=+1>/dev/label</font></tt> if non-nil so that it can be used + to identify the window when hidden (see <a href="../man1/rio.html"><i>rio</i>(1)</a>). The font is created + by reading the named <i>font</i> file. If <tt><font size=+1>font</font></tt> is null, <i>initdraw</i> reads + the file named in the environment variable <tt><font size=+1>$font</font></tt>; if + <tt><font size=+1>$font</font></tt> is not set, it imports the default (usually minimal) font + from the operating system. The global <i>font</i> will be set to point + to the resulting <tt><font size=+1>Font</font></tt> structure. The <i>errfun</i> argument is a <i>graphics + error function</i> to call in the event of a fatal error in the library; + it must never return. Its arguments are the display pointer + and an error string. If <i>errfun</i> is nil, the library provides a + default, called <i>drawerror</i>. Another effect of <i>initdraw</i> is that + it installs <a href="../man3/print.html"><i>print</i>(3)</a> formats <i>Pfmt</i> and <i>Rfmt</i> as <tt><font size=+1>%P</font></tt> and <tt><font size=+1>%R</font></tt> for printing + <tt><font size=+1>Points</font></tt> and <tt><font size=+1>Rectangles</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The <i>geninitdraw</i> function provides a less automated way to establish + a connection, for programs that wish to connect to multiple displays. + <i>Devdir</i> is the name of the directory containing the device files + for the display (if nil, default <tt><font size=+1>/dev</font></tt>); <i>errfun</i>, <i>font</i>, and <i>label</i> + are as in <i>initdraw</i>; <i>mousedir</i> and <i>windir</i> are the directories + holding the <tt><font size=+1>mouse</font></tt> and <tt><font size=+1>winname</font></tt> files; and <i>ref</i> specifies the refresh + function to be used to create the window, if running under <a href="../man1/rio.html"><i>rio</i>(1)</a> + (see <a href="../man3/window.html"><i>window</i>(3)</a>). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Initdisplay</i> is part of <i>geninitdraw</i>; it sets up the display structures + but does not allocate any fonts or call <i>getwindow</i>. The arguments + are similar to those of <i>initdraw</i>; <i>win</i> names the directory, default + <tt><font size=+1>/dev</font></tt>, in which the files associated with the window reside. <i>Closedisplay</i> + disconnects the display and frees the associated + data structures. <i>Getdefont</i> builds a <tt><font size=+1>Font</font></tt> structure from in-core + data describing a default font. None of these routines is needed + by most programs, since <i>initdraw</i> calls them as needed. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The data structures associated with the display must be protected + in a multi-process program, because they assume only one process + will be using them at a time. Multi-process programs should set + <tt><font size=+1>display−>locking</font></tt> to <tt><font size=+1>1</font></tt>, to notify the library to use a locking protocol + for its own accesses, and call <i>lockdisplay</i> and + <i>unlockdisplay</i> around any calls to the graphics library that will + cause messages to be sent to the display device. <i>Initdraw</i> and + <i>geninitdraw</i> initialize the display to the locked state. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Getwindow</i> returns a pointer to the window associated with the + application; it is called automatically by <i>initdraw</i> to establish + the <tt><font size=+1>screen</font></tt> pointer but must be called after each resizing of the + window to restore the library’s connection to the window. If <tt><font size=+1>rio</font></tt> + is not running, it returns <tt><font size=+1>display−>image</font></tt>; otherwise it + negotiates with <tt><font size=+1>rio</font></tt> by looking in <tt><font size=+1>/dev/winname</font></tt> to find the name + of the window and opening it using <tt><font size=+1>namedimage</font></tt> (see <a href="../man3/allocimage.html"><i>allocimage</i>(3)</a>). + The resulting window will be created using the refresh method + <i>ref</i> (see <a href="../man3/window.html"><i>window</i>(3)</a>); this should almost always be <tt><font size=+1>Refnone</font></tt> because + <tt><font size=+1>rio</font></tt> provides backing store for the window. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Getwindow</i> overwrites the global variables <tt><font size=+1>screen</font></tt>, a pointer to + the <tt><font size=+1>Image</font></tt> defining the window (or the overall display, if no window + system is running); and <tt><font size=+1>_screen</font></tt>, a pointer to the <tt><font size=+1>Screen</font></tt> representing + the root of the window’s hierarchy. (See <a href="../man3/window.html"><i>window</i>(3)</a>. The overloading + of the <tt><font size=+1>screen</font></tt> word is an unfortunate + historical accident.) <i>Getwindow</i> arranges that <tt><font size=+1>screen</font></tt> point to + the portion of the window inside the border; sophisticated clients + may use <tt><font size=+1>_screen</font></tt> to make further subwindows. <i>Gengetwindow</i>’s extra + arguments are the full path of the window’s <tt><font size=+1>winname</font></tt> file and pointers + to be overwritten with the values of the + ‘global’ <tt><font size=+1>Image</font></tt> and <tt><font size=+1>Screen</font></tt> variables for the new window. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The mouse cursor is always displayed. The initial cursor is an + arrow. <i>Cursorswitch</i> causes the argument cursor to be displayed + instead. A zero argument causes a switch back to the arrow cursor. + <i>Cursorset</i> moves the mouse cursor to position <i>p</i>, provided (if in + a window) that the requesting program is executing in the + current window and the mouse is within the window boundaries; + otherwise <i>cursorset</i> is a no-op. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The graphics functions described in <a href="../man3/draw.html"><i>draw</i>(3)</a>, <a href="../man3/allocimage.html"><i>allocimage</i>(3)</a>, <a href="../man3/cachechars.html"><i>cachechars</i>(3)</a>, + and <a href="../man3/subfont.html"><i>subfont</i>(3)</a> are implemented by writing commands to files under + <tt><font size=+1>/dev/draw</font></tt> (see <a href="../man3/draw.html"><i>draw</i>(3)</a>); the writes are buffered, so the functions + may not take effect immediately. <i>Flushimage</i> flushes the buffer, + doing all pending graphics operations. If + <i>vis</i> is non-zero, any changes are also copied from the ‘soft screen’ + (if any) in the driver to the visible frame buffer. The various + allocation routines in the library flush automatically, as does + the event package (see <a href="../man3/event.html"><i>event</i>(3)</a>); most programs do not need to + call <i>flushimage</i>. It returns –1 on error. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Bufimage</i> is used to allocate space for <i>n</i> bytes in the display + buffer. It is used by all the graphics routines to send messages + to the display. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The functions <i>strtochan</i> and <i>chantostr</i> convert between the channel + descriptor strings used by <a href="../man7/image.html"><i>image</i>(7)</a> and the internal <tt><font size=+1>ulong</font></tt> representation + used by the graphics protocol (see <a href="../man3/draw.html"><i>draw</i>(3)</a>’s <tt><font size=+1>b</font></tt> message). <tt><font size=+1>Chantostr</font></tt> + writes at most nine bytes into the buffer pointed at by <i>s</i> and + returns <i>s</i> on success, 0 on failure. + <tt><font size=+1>Chantodepth</font></tt> returns the number of bits per pixel used by the format + specified by <i>chan</i>. Both <tt><font size=+1>chantodepth</font></tt> and <tt><font size=+1>strtochan</font></tt> return 0 when + presented with bad input.<br> + +</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> + + To reconnect to the window after a resize event,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>if(getwindow(display, Refnone) < 0)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + sysfatal("resize failed: %r");<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + To create and set up a new <a href="../man1/rio.html"><i>rio</i>(1)</a> window,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>Image *screen2;<br> + Screen *_screen2;<br> + srvwsys = getenv("wsys");<br> + if(srvwsys == nil)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + sysfatal("can't find $wsys: %r");<br> + + </table> + rfork(RFNAMEG); /* keep mount of rio private */<br> + fd = open(srvwsys, ORDWR);<br> + if(fd < 0)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + sysfatal("can't open $wsys: %r");<br> + + </table> + /* mount creates window; see</font></tt> <i>rio</i><tt><font size=+1>(4) */<br> + if(mount(fd, −1, "/tmp", MREPL, "new −dx 300−dy 200") < 0)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + sysfatal("can't mount new window: %r");<br> + + </table> + if(gengetwindow(display, "/tmp/winname",<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + &screen2, &_screen2, Refnone) < 0)<br> + sysfatal("resize failed: %r");<br> + + </table> + /* now open /tmp/cons, /tmp/mouse */<br> + ...<br> + </font></tt> + </table> + +</table> +<p><font size=+1><b>FILES </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/font/bit </font></tt> directory of fonts<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/libdraw<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="../man1/rio.html"><i>rio</i>(1)</a>, <a href="../man3/addpt.html"><i>addpt</i>(3)</a>, <a href="../man3/allocimage.html"><i>allocimage</i>(3)</a>, <a href="../man3/cachechars.html"><i>cachechars</i>(3)</a>, <a href="../man3/subfont.html"><i>subfont</i>(3)</a>, <a href="../man3/draw.html"><i>draw</i>(3)</a>, + <a href="../man3/event.html"><i>event</i>(3)</a>, <a href="../man3/frame.html"><i>frame</i>(3)</a>, <a href="../man3/print.html"><i>print</i>(3)</a>, <a href="../man3/window.html"><i>window</i>(3)</a>, <a href="../man3/draw.html"><i>draw</i>(3)</a>, <a href="../man7/image.html"><i>image</i>(7)</a>, <a href="../man7/font.html"><i>font</i>(7)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + An error function may call <a href="../man3/errstr.html"><i>errstr</i>(3)</a> for further diagnostics.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The names <tt><font size=+1>clr</font></tt> and <tt><font size=+1>set</font></tt> in the <tt><font size=+1>Cursor</font></tt> structure are reminders of + an archaic color map and might be more appropriately called <tt><font size=+1>white</font></tt> + and <tt><font size=+1>black</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + These manual pages contain many references to the now-fictitious + <tt><font size=+1>/dev/draw</font></tt>.<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> diff --git a/man/man3/html.html b/man/man3/html.html new file mode 100644 index 00000000..465edcdb --- /dev/null +++ b/man/man3/html.html @@ -0,0 +1,1206 @@ +<head> +<title>html(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>HTML(3)</b><td align=right><b>HTML(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> + + parsehtml, printitems, validitems, freeitems, freedocinfo, dimenkind, + dimenspec, targetid, targetname, fromStr, toStr – HTML parser<br> + +</table> +<p><font size=+1><b>SYNOPSIS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<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 <html.h><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Item* parsehtml(uchar* data, int datalen, Rune* src, int mtype,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int chset, Docinfo** pdi)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>void printitems(Item* items, char* msg)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int validitems(Item* items)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void freeitems(Item* items)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void freedocinfo(Docinfo* d)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int dimenkind(Dimen d)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int dimenspec(Dimen d)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int targetid(Rune* s)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rune* targetname(int targid)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>uchar* fromStr(Rune* buf, int n, int chset)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rune* toStr(uchar* buf, int n, int chset)<br> + </font></tt> +</table> +<p><font size=+1><b>DESCRIPTION </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + This library implements a parser for HTML 4.0 documents. The parsed + HTML is converted into an intermediate representation that describes + how the formatted HTML should be laid out. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Parsehtml</i> parses an entire HTML document contained in the buffer + <i>data</i> and having length <i>datalen</i>. The URL of the document should + be passed in as <i>src</i>. <i>Mtype</i> is the media type of the document, + which should be either <tt><font size=+1>TextHtml</font></tt> or <tt><font size=+1>TextPlain</font></tt>. The character set + of the document is described in <i>chset</i>, which can be + one of <tt><font size=+1>US_Ascii</font></tt>, <tt><font size=+1>ISO_8859_1</font></tt>, <tt><font size=+1>UTF_8</font></tt> or <tt><font size=+1>Unicode</font></tt>. The return value + is a linked list of <tt><font size=+1>Item</font></tt> structures, described in detail below. + As a side effect, <tt><font size=+1>*</font></tt><i>pdi</i> is set to point to a newly created <tt><font size=+1>Docinfo</font></tt> + structure, containing information pertaining to the entire document. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The library expects two allocation routines to be provided by + the caller, <tt><font size=+1>emalloc</font></tt> and <tt><font size=+1>erealloc</font></tt>. These routines are analogous + to the standard malloc and realloc routines, except that they + should not return if the memory allocation fails. In addition, + <tt><font size=+1>emalloc</font></tt> is required to zero the memory. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + For debugging purposes, <i>printitems</i> may be called to display the + contents of an item list; individual items may be printed using + the <tt><font size=+1>%I</font></tt> print verb, installed on the first call to <i>parsehtml</i>. <i>validitems</i> + traverses the item list, checking that all of the pointers are + valid. It returns <tt><font size=+1>1</font></tt> is everything is ok, and <tt><font size=+1>0</font></tt> if an error was + found. Normally, one would not call these routines directly. Instead, + one sets the global variable <i>dbgbuild</i> and the library calls them + automatically. One can also set <i>warn</i>, to cause the library to + print a warning whenever it finds a problem with the input document, + and <i>dbglex</i>, to print debugging information in the + lexer. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + When an item list is finished with, it should be freed with <i>freeitems</i>. + Then, <i>freedocinfo</i> should be called on the pointer returned in + <tt><font size=+1>*</font></tt><i>pdi</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Dimenkind</i> and <i>dimenspec</i> are provided to interpret the <tt><font size=+1>Dimen</font></tt> type, + as described in the section <i>Dimension Specifications</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Frame target names are mapped to integer ids via a global, permanent + mapping. To find the value for a given name, call <i>targetid</i>, which + allocates a new id if the name hasn’t been seen before. The name + of a given, known id may be retrieved using <i>targetname</i>. The library + predefines <tt><font size=+1>FTtop</font></tt>, <tt><font size=+1>FTself</font></tt>, <tt><font size=+1>FTparent</font></tt> and + <tt><font size=+1>FTblank</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The library handles all text as Unicode strings (type <tt><font size=+1>Rune*</font></tt>). + Character set conversion is provided by <i>fromStr</i> and <i>toStr</i>. <i>FromStr</i> + takes <i>n</i> Unicode characters from <i>buf</i> and converts them to the character + set described by <i>chset</i>. <i>ToStr</i> takes <i>n</i> bytes from <i>buf</i>, interpretted + as belonging to character set <i>chset</i>, and converts + them to a Unicode string. Both routines null-terminate the result, + and use <tt><font size=+1>emalloc</font></tt> to allocate space for it.<br> + <p><font size=+1><b>Items </b></font><br> + The return value of <i>parsehtml</i> is a linked list of variant structures, + with the generic portion described by the following definition: + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>typedef struct Item Item;<br> + struct Item<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Item* next;<br> + int width;<br> + int height;<br> + int ascent;<br> + int anchorid;<br> + int state;<br> + Genattr* genattr;<br> + int tag;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + The field <tt><font size=+1>next</font></tt> points to the successor in the linked list of items, + while <tt><font size=+1>width</font></tt>, <tt><font size=+1>height</font></tt>, and <tt><font size=+1>ascent</font></tt> are intended for use by the caller + as part of the layout process. <tt><font size=+1>Anchorid</font></tt>, if non-zero, gives the + integer id assigned by the parser to the anchor that this item + is in (see section <i>Anchors</i>). <tt><font size=+1>State</font></tt> is a collection of + flags and values described as follows: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>enum<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + IFbrk = 0x80000000,<br> + IFbrksp = 0x40000000,<br> + IFnobrk = 0x20000000,<br> + IFcleft = 0x10000000,<br> + IFcright = 0x08000000,<br> + IFwrap = 0x04000000,<br> + IFhang = 0x02000000,<br> + IFrjust = 0x01000000,<br> + IFcjust = 0x00800000,<br> + IFsmap = 0x00400000,<br> + IFindentshift = 8,<br> + IFindentmask = (255<<IFindentshift),<br> + IFhangmask = 255<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>IFbrk</font></tt> is set if a break is to be forced before placing this item. + <tt><font size=+1>IFbrksp</font></tt> is set if a 1 line space should be added to the break + (in which case <tt><font size=+1>IFbrk</font></tt> is also set). <tt><font size=+1>IFnobrk</font></tt> is set if a break is + not permitted before the item. <tt><font size=+1>IFcleft</font></tt> is set if left floats should + be cleared (that is, if the list of pending left floats should + be placed) before this item is placed, and <tt><font size=+1>IFcright</font></tt> is set for + right floats. In both cases, IFbrk is also set. <tt><font size=+1>IFwrap</font></tt> is set + if the line containing this item is allowed to wrap. <tt><font size=+1>IFhang</font></tt> is + set if this item hangs into the left indent. <tt><font size=+1>IFrjust</font></tt> is set if + the line containing this item should be right justified, and <tt><font size=+1>IFcjust</font></tt> + is + set for center justified lines. <tt><font size=+1>IFsmap</font></tt> is used to indicate that + an image is a server-side map. The low 8 bits, represented by + <tt><font size=+1>IFhangmask</font></tt>, indicate the current hang into left indent, in tenths + of a tabstop. The next 8 bits, represented by <tt><font size=+1>IFindentmask</font></tt> and + <tt><font size=+1>IFindentshift</font></tt>, indicate the current indent in tab + stops. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The field <tt><font size=+1>genattr</font></tt> is an optional pointer to an auxiliary structure, + described in the section <i>Generic Attributes</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Finally, <tt><font size=+1>tag</font></tt> describes which variant type this item has. It can + have one of the values <tt><font size=+1>Itexttag</font></tt>, <tt><font size=+1>Iruletag</font></tt>, <tt><font size=+1>Iimagetag</font></tt>, <tt><font size=+1>Iformfieldtag</font></tt>, + <tt><font size=+1>Itabletag</font></tt>, <tt><font size=+1>Ifloattag</font></tt> or <tt><font size=+1>Ispacertag</font></tt>. For each of these values, + there is an additional structure defined, which includes Item + as an unnamed initial substructure, + and then defines additional fields. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Items of type <tt><font size=+1>Itexttag</font></tt> represent a piece of text, using the following + structure: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>struct Itext<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Item;<br> + Rune* s;<br> + int fnt;<br> + int fg;<br> + uchar voff;<br> + uchar ul;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + Here <tt><font size=+1>s</font></tt> is a null-terminated Unicode string of the actual characters + making up this text item, <tt><font size=+1>fnt</font></tt> is the font number (described in + the section <i>Font Numbers</i>), and <tt><font size=+1>fg</font></tt> is the RGB encoded color for + the text. <tt><font size=+1>Voff</font></tt> measures the vertical offset from the baseline; + subtract <tt><font size=+1>Voffbias</font></tt> to get the actual value (negative values + represent a displacement down the page). The field <tt><font size=+1>ul</font></tt> is the underline + style: <tt><font size=+1>ULnone</font></tt> if no underline, <tt><font size=+1>ULunder</font></tt> for conventional underline, + and <tt><font size=+1>ULmid</font></tt> for strike-through. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Items of type <tt><font size=+1>Iruletag</font></tt> represent a horizontal rule, as follows: + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>struct Irule<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Item;<br> + uchar align;<br> + uchar noshade;<br> + int size;<br> + Dimen wspec;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + Here <tt><font size=+1>align</font></tt> is the alignment specification (described in the corresponding + section), <tt><font size=+1>noshade</font></tt> is set if the rule should not be shaded, <tt><font size=+1>size</font></tt> + is the height of the rule (as set by the size attribute), and + <tt><font size=+1>wspec</font></tt> is the desired width (see section <i>Dimension Specifications</i>). + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Items of type <tt><font size=+1>Iimagetag</font></tt> describe embedded images, for which the + following structure is defined: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>struct Iimage<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Item;<br> + Rune* imsrc;<br> + int imwidth;<br> + int imheight;<br> + Rune* altrep;<br> + Map* map;<br> + int ctlid;<br> + uchar align;<br> + uchar hspace;<br> + uchar vspace;<br> + uchar border;<br> + Iimage* nextimage;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + Here <tt><font size=+1>imsrc</font></tt> is the URL of the image source, <tt><font size=+1>imwidth</font></tt> and <tt><font size=+1>imheight</font></tt>, + if non-zero, contain the specified width and height for the image, + and <tt><font size=+1>altrep</font></tt> is the text to use as an alternative to the image, + if the image is not displayed. <tt><font size=+1>Map</font></tt>, if set, points to a structure + describing an associated client-side image map. + <tt><font size=+1>Ctlid</font></tt> is reserved for use by the application, for handling animated + images. <tt><font size=+1>Align</font></tt> encodes the alignment specification of the image. + <tt><font size=+1>Hspace</font></tt> contains the number of pixels to pad the image with on + either side, and <tt><font size=+1>Vspace</font></tt> the padding above and below. <tt><font size=+1>Border</font></tt> is + the width of the border to draw around the + image. <tt><font size=+1>Nextimage</font></tt> points to the next image in the document (the + head of this list is <tt><font size=+1>Docinfo.images</font></tt>). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + For items of type <tt><font size=+1>Iformfieldtag</font></tt>, the following structure is defined: + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>struct Iformfield<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Item;<br> + Formfield* formfield;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + This adds a single field, <tt><font size=+1>formfield</font></tt>, which points to a structure + describing a field in a form, described in section <i>Forms</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + For items of type <tt><font size=+1>Itabletag</font></tt>, the following structure is defined: + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>struct Itable<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Item;<br> + Table* table;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Table</font></tt> points to a structure describing the table, described in + the section <i>Tables</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + For items of type <tt><font size=+1>Ifloattag</font></tt>, the following structure is defined: + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>struct Ifloat<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Item;<br> + Item* item;<br> + int x;<br> + int y;<br> + uchar side;<br> + uchar infloats;<br> + Ifloat* nextfloat;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + The <tt><font size=+1>item</font></tt> points to a single item (either a table or an image) + that floats (the text of the document flows around it), and <tt><font size=+1>side</font></tt> + indicates the margin that this float sticks to; it is either <tt><font size=+1>ALleft</font></tt> + or <tt><font size=+1>ALright</font></tt>. <tt><font size=+1>X</font></tt> and <tt><font size=+1>y</font></tt> are reserved for use by the caller; these + are typically used for the coordinates of the top of the float. + <tt><font size=+1>Infloats</font></tt> is used by the caller to keep track of whether it has + placed the float. <tt><font size=+1>Nextfloat</font></tt> is used by the caller to link together + all of the floats that it has placed. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + For items of type <tt><font size=+1>Ispacertag</font></tt>, the following structure is defined: + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>struct Ispacer<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Item;<br> + int spkind;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Spkind</font></tt> encodes the kind of spacer, and may be one of <tt><font size=+1>ISPnull</font></tt> (zero + height and width), <tt><font size=+1>ISPvline</font></tt> (takes on height and ascent of the + current font), <tt><font size=+1>ISPhspace</font></tt> (has the width of a space in the current + font) and <tt><font size=+1>ISPgeneral</font></tt> (for all other purposes, such as between + markers and lists). + <p><font size=+1><b>Generic Attributes </b></font><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The genattr field of an item, if non-nil, points to a structure + that holds the values of attributes not specific to any particular + item type, as they occur on a wide variety of underlying HTML + tags. The structure is as follows: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>typedef struct Genattr Genattr;<br> + struct Genattr<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Rune* id;<br> + Rune* class;<br> + Rune* style;<br> + Rune* title;<br> + SEvent* events;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + Fields <tt><font size=+1>id</font></tt>, <tt><font size=+1>class</font></tt>, <tt><font size=+1>style</font></tt> and <tt><font size=+1>title</font></tt>, when non-nil, contain values + of correspondingly named attributes of the HTML tag associated + with this item. <tt><font size=+1>Events</font></tt> is a linked list of events (with corresponding + scripted actions) associated with the item: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>typedef struct SEvent SEvent;<br> + struct SEvent<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + SEvent* next;<br> + int type;<br> + Rune* script;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + Here, <tt><font size=+1>next</font></tt> points to the next event in the list, <tt><font size=+1>type</font></tt> is one of + <tt><font size=+1>SEonblur</font></tt>, <tt><font size=+1>SEonchange</font></tt>, <tt><font size=+1>SEonclick</font></tt>, <tt><font size=+1>SEondblclick</font></tt>, <tt><font size=+1>SEonfocus</font></tt>, <tt><font size=+1>SEonkeypress</font></tt>, + <tt><font size=+1>SEonkeyup</font></tt>, <tt><font size=+1>SEonload</font></tt>, <tt><font size=+1>SEonmousedown</font></tt>, <tt><font size=+1>SEonmousemove</font></tt>, <tt><font size=+1>SEonmouseout</font></tt>, + <tt><font size=+1>SEonmouseover</font></tt>, <tt><font size=+1>SEonmouseup</font></tt>, <tt><font size=+1>SEonreset</font></tt>, <tt><font size=+1>SEonselect</font></tt>, + <tt><font size=+1>SEonsubmit</font></tt> or <tt><font size=+1>SEonunload</font></tt>, and <tt><font size=+1>script</font></tt> is the text of the associated + script.<br> + <p><font size=+1><b>Dimension Specifications </b></font><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Some structures include a dimension specification, used where + a number can be followed by a <tt><font size=+1>%</font></tt> or a <tt><font size=+1>*</font></tt> to indicate percentage + of total or relative weight. This is encoded using the following + structure: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>typedef struct Dimen Dimen;<br> + struct Dimen<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int kindspec;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + Separate kind and spec values are extracted using <i>dimenkind</i> and + <i>dimenspec</i>. <i>Dimenkind</i> returns one of <tt><font size=+1>Dnone</font></tt>, <tt><font size=+1>Dpixels</font></tt>, <tt><font size=+1>Dpercent</font></tt> or + <tt><font size=+1>Drelative</font></tt>. <tt><font size=+1>Dnone</font></tt> means that no dimension was specified. In all + other cases, <i>dimenspec</i> should be called to find the absolute number + of pixels, the percentage of total, or the + relative weight.<br> + <p><font size=+1><b>Background Specifications </b></font><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + It is possible to set the background of the entire document, and + also for some parts of the document (such as tables). This is + encoded as follows: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>typedef struct Background Background;<br> + struct Background<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Rune* image;<br> + int color;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Image</font></tt>, if non-nil, is the URL of an image to use as the background. + If this is nil, <tt><font size=+1>color</font></tt> is used instead, as the RGB value for a + solid fill color.<br> + <p><font size=+1><b>Alignment Specifications </b></font><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Certain items have alignment specifiers taken from the following + enumerated type: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>enum<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + ALnone = 0, ALleft, ALcenter, ALright, ALjustify,<br> + ALchar, ALtop, ALmiddle, ALbottom, ALbaseline<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + These values correspond to the various alignment types named in + the HTML 4.0 standard. If an item has an alignment of <tt><font size=+1>ALleft</font></tt> or + <tt><font size=+1>ALright</font></tt>, the library automatically encapsulates it inside a float + item. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Tables, and the various rows, columns and cells within them, have + a more complex alignment specification, composed of separate vertical + and horizontal alignments: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>typedef struct Align Align;<br> + struct Align<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + uchar halign;<br> + uchar valign;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Halign</font></tt> can be one of <tt><font size=+1>ALnone</font></tt>, <tt><font size=+1>ALleft</font></tt>, <tt><font size=+1>ALcenter</font></tt>, <tt><font size=+1>ALright</font></tt>, <tt><font size=+1>ALjustify</font></tt> + or <tt><font size=+1>ALchar</font></tt>. <tt><font size=+1>Valign</font></tt> can be one of <tt><font size=+1>ALnone</font></tt>, <tt><font size=+1>ALmiddle</font></tt>, <tt><font size=+1>ALbottom</font></tt>, <tt><font size=+1>ALtop</font></tt> + or <tt><font size=+1>ALbaseline</font></tt>.<br> + <p><font size=+1><b>Font Numbers </b></font><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Text items have an associated font number (the <tt><font size=+1>fnt</font></tt> field), which + is encoded as <tt><font size=+1>style*NumSize+size</font></tt>. Here, <tt><font size=+1>style</font></tt> is one of <tt><font size=+1>FntR</font></tt>, + <tt><font size=+1>FntI</font></tt>, <tt><font size=+1>FntB</font></tt> or <tt><font size=+1>FntT</font></tt>, for roman, italic, bold and typewriter font + styles, respectively, and size is <tt><font size=+1>Tiny</font></tt>, <tt><font size=+1>Small</font></tt>, <tt><font size=+1>Normal</font></tt>, <tt><font size=+1>Large</font></tt> or + <tt><font size=+1>Verylarge</font></tt>. The total number of possible + font numbers is <tt><font size=+1>NumFnt</font></tt>, and the default font number is <tt><font size=+1>DefFnt</font></tt> + (which is roman style, normal size).<br> + <p><font size=+1><b>Document Info </b></font><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Global information about an HTML page is stored in the following + structure: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>typedef struct Docinfo Docinfo;<br> + struct Docinfo<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + // stuff from HTTP headers, doc head, and body tag<br> + Rune* src;<br> + Rune* base;<br> + Rune* doctitle;<br> + Background background;<br> + Iimage* backgrounditem;<br> + int text;<br> + int link;<br> + int vlink;<br> + int alink;<br> + int target;<br> + int chset;<br> + int mediatype;<br> + int scripttype;<br> + int hasscripts;<br> + Rune* refresh;<br> + Kidinfo* kidinfo;<br> + int frameid;<br> + // info needed to respond to user actions<br> + Anchor* anchors;<br> + DestAnchor* dests;<br> + Form* forms;<br> + Table* tables;<br> + Map* maps;<br> + Iimage* images;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Src</font></tt> gives the URL of the original source of the document, and + <tt><font size=+1>base</font></tt> is the base URL. <tt><font size=+1>Doctitle</font></tt> is the document’s title, as set + by a <tt><font size=+1><title></font></tt> element. <tt><font size=+1>Background</font></tt> is as described in the section + <i>Background Specifications</i>, and <tt><font size=+1>backgrounditem</font></tt> is set to be an + image item for the document’s background image + (if given as a URL), or else nil. <tt><font size=+1>Text</font></tt> gives the default foregound + text color of the document, <tt><font size=+1>link</font></tt> the unvisited hyperlink color, + <tt><font size=+1>vlink</font></tt> the visited hyperlink color, and <tt><font size=+1>alink</font></tt> the color for highlighting + hyperlinks (all in 24-bit RGB format). <tt><font size=+1>Target</font></tt> is the default target + frame id. <tt><font size=+1>Chset</font></tt> and <tt><font size=+1>mediatype</font></tt> are as for + the <i>chset</i> and <i>mtype</i> parameters to <i>parsehtml</i>. <tt><font size=+1>Scripttype</font></tt> is the + type of any scripts contained in the document, and is always <tt><font size=+1>TextJavascript</font></tt>. + <tt><font size=+1>Hasscripts</font></tt> is set if the document contains any scripts. Scripting + is currently unsupported. <tt><font size=+1>Refresh</font></tt> is the contents of a <tt><font size=+1><meta http−equiv=Refresh + ...></font></tt> tag, if any. <tt><font size=+1>Kidinfo</font></tt> is set if this document is a frameset + (see section <i>Frames</i>). <tt><font size=+1>Frameid</font></tt> is this document’s frame id. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>Anchors</font></tt> is a list of hyperlinks contained in the document, and + <tt><font size=+1>dests</font></tt> is a list of hyperlink destinations within the page (see + the following section for details). <tt><font size=+1>Forms</font></tt>, <tt><font size=+1>tables</font></tt> and <tt><font size=+1>maps</font></tt> are + lists of the various forms, tables and client-side maps contained + in the document, as described in subsequent sections. + <tt><font size=+1>Images</font></tt> is a list of all the image items in the document.<br> + <p><font size=+1><b>Anchors </b></font><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The library builds two lists for all of the <tt><font size=+1><a></font></tt> elements (anchors) + in a document. Each anchor is assigned a unique anchor id within + the document. For anchors which are hyperlinks (the <tt><font size=+1>href</font></tt> attribute + was supplied), the following structure is defined: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>typedef struct Anchor Anchor;<br> + struct Anchor<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Anchor* next;<br> + int index;<br> + Rune* name;<br> + Rune* href;<br> + int target;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Next</font></tt> points to the next anchor in the list (the head of this list + is <tt><font size=+1>Docinfo.anchors</font></tt>). <tt><font size=+1>Index</font></tt> is the anchor id; each item within + this hyperlink is tagged with this value in its <tt><font size=+1>anchorid</font></tt> field. + <tt><font size=+1>Name</font></tt> and <tt><font size=+1>href</font></tt> are the values of the correspondingly named attributes + of the anchor (in particular, href is the URL to go + to). <tt><font size=+1>Target</font></tt> is the value of the target attribute (if provided) + converted to a frame id. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Destinations within the document (anchors with the name attribute + set) are held in the <tt><font size=+1>Docinfo.dests</font></tt> list, using the following structure: + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>typedef struct DestAnchor DestAnchor;<br> + struct DestAnchor<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + DestAnchor* next;<br> + int index;<br> + Rune* name;<br> + Item* item;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Next</font></tt> is the next element of the list, <tt><font size=+1>index</font></tt> is the anchor id, + <tt><font size=+1>name</font></tt> is the value of the name attribute, and <tt><font size=+1>item</font></tt> is points to + the item within the parsed document that should be considered + to be the destination.<br> + <p><font size=+1><b>Forms </b></font><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Any forms within a document are kept in a list, headed by <tt><font size=+1>Docinfo.forms</font></tt>. + The elements of this list are as follows: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>typedef struct Form Form;<br> + struct Form<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Form* next;<br> + int formid;<br> + Rune* name;<br> + Rune* action;<br> + int target;<br> + int method;<br> + int nfields;<br> + Formfield* fields;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Next</font></tt> points to the next form in the list. <tt><font size=+1>Formid</font></tt> is a serial number + for the form within the document. <tt><font size=+1>Name</font></tt> is the value of the form’s + name or id attribute. <tt><font size=+1>Action</font></tt> is the value of any action attribute. + <tt><font size=+1>Target</font></tt> is the value of the target attribute (if any) converted + to a frame target id. <tt><font size=+1>Method</font></tt> is one of <tt><font size=+1>HGet</font></tt> or + <tt><font size=+1>HPost</font></tt>. <tt><font size=+1>Nfields</font></tt> is the number of fields in the form, and <tt><font size=+1>fields</font></tt> + is a linked list of the actual fields. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The individual fields in a form are described by the following + structure: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>typedef struct Formfield Formfield;<br> + struct Formfield<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Formfield* next;<br> + int ftype;<br> + int fieldid;<br> + Form* form;<br> + Rune* name;<br> + Rune* value;<br> + int size;<br> + int maxlength;<br> + int rows;<br> + int cols;<br> + uchar flags;<br> + Option* options;<br> + Item* image;<br> + int ctlid;<br> + SEvent* events;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + Here, <tt><font size=+1>next</font></tt> points to the next field in the list. <tt><font size=+1>Ftype</font></tt> is the + type of the field, which can be one of <tt><font size=+1>Ftext</font></tt>, <tt><font size=+1>Fpassword</font></tt>, <tt><font size=+1>Fcheckbox</font></tt>, + <tt><font size=+1>Fradio</font></tt>, <tt><font size=+1>Fsubmit</font></tt>, <tt><font size=+1>Fhidden</font></tt>, <tt><font size=+1>Fimage</font></tt>, <tt><font size=+1>Freset</font></tt>, <tt><font size=+1>Ffile</font></tt>, <tt><font size=+1>Fbutton</font></tt>, <tt><font size=+1>Fselect</font></tt> + or <tt><font size=+1>Ftextarea</font></tt>. <tt><font size=+1>Fieldid</font></tt> is a serial number for the field within + the form. <tt><font size=+1>Form</font></tt> points back + to the form containing this field. <tt><font size=+1>Name</font></tt>, <tt><font size=+1>value</font></tt>, <tt><font size=+1>size</font></tt>, <tt><font size=+1>maxlength</font></tt>, + <tt><font size=+1>rows</font></tt> and <tt><font size=+1>cols</font></tt> each contain the values of corresponding attributes + of the field, if present. <tt><font size=+1>Flags</font></tt> contains per-field flags, of which + <tt><font size=+1>FFchecked</font></tt> and <tt><font size=+1>FFmultiple</font></tt> are defined. <tt><font size=+1>Image</font></tt> is only used for fields + of type <tt><font size=+1>Fimage</font></tt>; it points to an + image item containing the image to be displayed. <tt><font size=+1>Ctlid</font></tt> is reserved + for use by the caller, typically to store a unique id of an associated + control used to implement the field. <tt><font size=+1>Events</font></tt> is the same as the + corresponding field of the generic attributes associated with + the item containing this field. <tt><font size=+1>Options</font></tt> is only used by + fields of type <tt><font size=+1>Fselect</font></tt>; it consists of a list of possible options + that may be selected for that field, using the following structure: + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>typedef struct Option Option;<br> + struct Option<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Option* next;<br> + int selected;<br> + Rune* value;<br> + Rune* display;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Next</font></tt> points to the next element of the list. <tt><font size=+1>Selected</font></tt> is set if + this option is to be displayed initially. <tt><font size=+1>Value</font></tt> is the value to + send when the form is submitted if this option is selected. <tt><font size=+1>Display</font></tt> + is the string to display on the screen for this option.<br> + <p><font size=+1><b>Tables </b></font><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The library builds a list of all the tables in the document, headed + by <tt><font size=+1>Docinfo.tables</font></tt>. Each element of this list has the following + format: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>typedef struct Table Table;<br> + struct Table<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Table* next;<br> + int tableid;<br> + Tablerow* rows;<br> + int nrow;<br> + Tablecol* cols;<br> + int ncol;<br> + Tablecell* cells;<br> + int ncell;<br> + Tablecell*** grid;<br> + Align align;<br> + Dimen width;<br> + int border;<br> + int cellspacing;<br> + int cellpadding;<br> + Background background;<br> + Item* caption;<br> + uchar caption_place;<br> + Lay* caption_lay;<br> + int totw;<br> + int toth;<br> + int caph;<br> + int availw;<br> + Token* tabletok;<br> + uchar flags;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Next</font></tt> points to the next element in the list of tables. <tt><font size=+1>Tableid</font></tt> + is a serial number for the table within the document. <tt><font size=+1>Rows</font></tt> is + an array of row specifications (described below) and <tt><font size=+1>nrow</font></tt> is the + number of elements in this array. Similarly, <tt><font size=+1>cols</font></tt> is an array + of column specifications, and <tt><font size=+1>ncol</font></tt> the size of this array. + <tt><font size=+1>Cells</font></tt> is a list of all cells within the table (structure described + below) and <tt><font size=+1>ncell</font></tt> is the number of elements in this list. Note + that a cell may span multiple rows and/or columns, thus <tt><font size=+1>ncell</font></tt> + may be smaller than <tt><font size=+1>nrow*ncol</font></tt>. <tt><font size=+1>Grid</font></tt> is a two-dimensional array + of cells within the table; the cell at row <tt><font size=+1>i</font></tt> and column <tt><font size=+1>j</font></tt> is + <tt><font size=+1>Table.grid[i][j]</font></tt>. A cell that spans multiple rows and/or columns + will be referenced by <tt><font size=+1>grid</font></tt> multiple times, however it will only + occur once in <tt><font size=+1>cells</font></tt>. <tt><font size=+1>Align</font></tt> gives the alignment specification for + the entire table, and <tt><font size=+1>width</font></tt> gives the requested width as a dimension + specification. <tt><font size=+1>Border</font></tt>, <tt><font size=+1>cellspacing + </font></tt>and <tt><font size=+1>cellpadding</font></tt> give the values of the corresponding attributes + for the table, and <tt><font size=+1>background</font></tt> gives the requested background for + the table. <tt><font size=+1>Caption</font></tt> is a linked list of items to be displayed as + the caption of the table, either above or below depending on whether + <tt><font size=+1>caption_place</font></tt> is <tt><font size=+1>ALtop</font></tt> or <tt><font size=+1>ALbottom</font></tt>. + Most of the remaining fields are reserved for use by the caller, + except <tt><font size=+1>tabletok</font></tt>, which is reserved for internal use. The type + <tt><font size=+1>Lay</font></tt> is not defined by the library; the caller can provide its + own definition. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The <tt><font size=+1>Tablecol</font></tt> structure is defined for use by the caller. The library + ensures that the correct number of these is allocated, but leaves + them blank. The fields are as follows: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>typedef struct Tablecol Tablecol;<br> + struct Tablecol<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int width;<br> + Align align;<br> + Point pos;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + The rows in the table are specified as follows: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>typedef struct Tablerow Tablerow;<br> + struct Tablerow<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Tablerow* next;<br> + Tablecell* cells;<br> + int height;<br> + int ascent;<br> + Align align;<br> + Background background;<br> + Point pos;<br> + uchar flags;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Next</font></tt> is only used during parsing; it should be ignored by the + caller. <tt><font size=+1>Cells</font></tt> provides a list of all the cells in a row, linked + through their <tt><font size=+1>nextinrow</font></tt> fields (see below). <tt><font size=+1>Height</font></tt>, <tt><font size=+1>ascent</font></tt> and + <tt><font size=+1>pos</font></tt> are reserved for use by the caller. <tt><font size=+1>Align</font></tt> is the alignment + specification for the row, and <tt><font size=+1>background</font></tt> is the + background to use, if specified. <tt><font size=+1>Flags</font></tt> is used by the parser; + ignore this field. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The individual cells of the table are described as follows: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>typedef struct Tablecell Tablecell;<br> + struct Tablecell<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Tablecell* next;<br> + Tablecell* nextinrow;<br> + int cellid;<br> + Item* content;<br> + Lay* lay;<br> + int rowspan;<br> + int colspan;<br> + Align align;<br> + uchar flags;<br> + Dimen wspec;<br> + int hspec;<br> + Background background;<br> + int minw;<br> + int maxw;<br> + int ascent;<br> + int row;<br> + int col;<br> + Point pos;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Next</font></tt> is used to link together the list of all cells within a table + (<tt><font size=+1>Table.cells</font></tt>), whereas <tt><font size=+1>nextinrow</font></tt> is used to link together all + the cells within a single row (<tt><font size=+1>Tablerow.cells</font></tt>). <tt><font size=+1>Cellid</font></tt> provides + a serial number for the cell within the table. <tt><font size=+1>Content</font></tt> is a linked + list of the items to be laid out within the cell. <tt><font size=+1>Lay + </font></tt>is reserved for the user to describe how these items have been + laid out. <tt><font size=+1>Rowspan</font></tt> and <tt><font size=+1>colspan</font></tt> are the number of rows and columns + spanned by this cell, respectively. <tt><font size=+1>Align</font></tt> is the alignment specification + for the cell. <tt><font size=+1>Flags</font></tt> is some combination of <tt><font size=+1>TFparsing</font></tt>, <tt><font size=+1>TFnowrap</font></tt> + and <tt><font size=+1>TFisth</font></tt> or’d together. Here + <tt><font size=+1>TFparsing</font></tt> is used internally by the parser, and should be ignored. + <tt><font size=+1>TFnowrap</font></tt> means that the contents of the cell should not be wrapped + if they don’t fit the available width, rather, the table should + be expanded if need be (this is set when the nowrap attribute + is supplied). <tt><font size=+1>TFisth</font></tt> means that the cell was created + by the <tt><font size=+1><th></font></tt> element (rather than the <tt><font size=+1><td></font></tt> element), indicating that + it is a header cell rather than a data cell. <tt><font size=+1>Wspec</font></tt> provides a + suggested width as a dimension specification, and <tt><font size=+1>hspec</font></tt> provides + a suggested height in pixels. <tt><font size=+1>Background</font></tt> gives a background specification + for the individual cell. <tt><font size=+1>Minw</font></tt>, <tt><font size=+1>maxw</font></tt>, + <tt><font size=+1>ascent</font></tt> and <tt><font size=+1>pos</font></tt> are reserved for use by the caller during layout. + <tt><font size=+1>Row</font></tt> and <tt><font size=+1>col</font></tt> give the indices of the row and column of the top + left-hand corner of the cell within the table grid.<br> + <p><font size=+1><b>Client-side Maps </b></font><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The library builds a list of client-side maps, headed by <tt><font size=+1>Docinfo.maps</font></tt>, + and having the following structure: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>typedef struct Map Map;<br> + struct Map<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Map* next;<br> + Rune* name;<br> + Area* areas;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Next</font></tt> points to the next element in the list, <tt><font size=+1>name</font></tt> is the name + of the map (use to bind it to an image), and <tt><font size=+1>areas</font></tt> is a list of + the areas within the image that comprise the map, using the following + structure: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>typedef struct Area Area;<br> + struct Area<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Area* next;<br> + int shape;<br> + Rune* href;<br> + int target;<br> + Dimen* coords;<br> + int ncoords;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Next</font></tt> points to the next element in the map’s list of areas. <tt><font size=+1>Shape</font></tt> + describes the shape of the area, and is one of <tt><font size=+1>SHrect</font></tt>, <tt><font size=+1>SHcircle</font></tt> + or <tt><font size=+1>SHpoly</font></tt>. <tt><font size=+1>Href</font></tt> is the URL associated with this area in its role + as a hypertext link, and <tt><font size=+1>target</font></tt> is the target frame it should + be loaded in. <tt><font size=+1>Coords</font></tt> is an array of coordinates for + the shape, and <tt><font size=+1>ncoords</font></tt> is the size of this array (number of elements).<br> + <p><font size=+1><b>Frames </b></font><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + If the <tt><font size=+1>Docinfo.kidinfo</font></tt> field is set, the document is a frameset. + In this case, it is typical for <i>parsehtml</i> to return nil, as a + document which is a frameset should have no actual items that + need to be laid out (such will appear only in subsidiary documents). + It is possible that items will be returned by a malformed + document; the caller should check for this and free any such items. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The <tt><font size=+1>Kidinfo</font></tt> structure itself reflects the fact that framesets + can be nested within a document. If is defined as follows: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>typedef struct Kidinfo Kidinfo;<br> + struct Kidinfo<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Kidinfo* next;<br> + int isframeset;<br> + // fields for "frame"<br> + Rune* src;<br> + Rune* name;<br> + int marginw;<br> + int marginh;<br> + int framebd;<br> + int flags;<br> + // fields for "frameset"<br> + Dimen* rows;<br> + int nrows;<br> + Dimen* cols;<br> + int ncols;<br> + Kidinfo* kidinfos;<br> + Kidinfo* nextframeset;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Next</font></tt> is only used if this structure is part of a containing frameset; + it points to the next element in the list of children of that + frameset. <tt><font size=+1>Isframeset</font></tt> is set when this structure represents a frameset; + if clear, it is an individual frame. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Some fields are used only for framesets. <tt><font size=+1>Rows</font></tt> is an array of dimension + specifications for rows in the frameset, and <tt><font size=+1>nrows</font></tt> is the length + of this array. <tt><font size=+1>Cols</font></tt> is the corresponding array for columns, of + length <tt><font size=+1>ncols</font></tt>. <tt><font size=+1>Kidinfos</font></tt> points to a list of components contained + within this frameset, each of which may be a + frameset or a frame. <tt><font size=+1>Nextframeset</font></tt> is only used during parsing, + and should be ignored. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The remaining fields are used if the structure describes a frame, + not a frameset. <tt><font size=+1>Src</font></tt> provides the URL for the document that should + be initially loaded into this frame. Note that this may be a relative + URL, in which case it should be interpretted using the containing + document’s URL as the base. <tt><font size=+1>Name</font></tt> gives the name of + the frame, typically supplied via a name attribute in the HTML. + If no name was given, the library allocates one. <tt><font size=+1>Marginw</font></tt>, <tt><font size=+1>marginh</font></tt> + and <tt><font size=+1>framebd</font></tt> are the values of the marginwidth, marginheight and + frameborder attributes, respectively. <tt><font size=+1>Flags</font></tt> can contain some combination + of the following: <tt><font size=+1>FRnoresize</font></tt> (the + frame had the noresize attribute set, and the user should not + be allowed to resize it), <tt><font size=+1>FRnoscroll</font></tt> (the frame should not have + any scroll bars), <tt><font size=+1>FRhscroll</font></tt> (the frame should have a horizontal + scroll bar), <tt><font size=+1>FRvscroll</font></tt> (the frame should have a vertical scroll + bar), <tt><font size=+1>FRhscrollauto</font></tt> (the frame should be automatically + given a horizontal scroll bar if its contents would not otherwise + fit), and <tt><font size=+1>FRvscrollauto</font></tt> (the frame gets a vertical scrollbar only + if required).<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/libhtml<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="../man1/fmt.html"><i>fmt</i>(1)</a> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + W3C World Wide Web Consortium, “HTML 4.01 Specification”.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The entire HTML document must be loaded into memory before any + of it can be parsed.<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> diff --git a/man/man3/index.html b/man/man3/index.html new file mode 100644 index 00000000..90e8d3cf --- /dev/null +++ b/man/man3/index.html @@ -0,0 +1,647 @@ +<html> +<head> +<title>Manual Section 3 - Plan 9 from User Space</title> +</head> +<body> +<table width=100%> +<tr><td width=20><td> +<center> +<table border=0 cellspacing=0 cellpadding=0 width=100%> +<tr height=1><td width=200><td> +<tr><td colspan=2> + <center> + <b>Manual Section 3 - Plan 9 from User Space</b> + </center> +<tr height=10><td> +<tr><td valign=top><a href="intro.html">intro(3)</a><td>intro – introduction to library functions +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="9p.html">9p(3)</a><td>Srv +dirread9p +emalloc9p +erealloc9p +estrdup9p +postfd +postmountsrv +readbuf +readstr +respond +srv +threadpostmountsrv +walkandclone – 9P file service +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="9p-cmdbuf.html">9p-cmdbuf(3)</a><td>Cmdbuf, parsecmd, respondcmderror, lookupcmd – control message parsing +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="9p-fid.html">9p-fid(3)</a><td>Fid, Fidpool, allocfidpool, freefidpool, allocfid, closefid, lookupfid, removefid +Req, Reqpool, allocreqpool, freereqpool, allocreq, closereq, lookupreq, removereq – 9P fid, request tracking +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="9p-file.html">9p-file(3)</a><td>Tree, alloctree, freetree +File, createfile, closefile, removefile, walkfile +opendirfile, readdirfile, closedirfile, hasperm – in-memory file hierarchy +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="9p-intmap.html">9p-intmap(3)</a><td>Intmap, allocmap, freemap, insertkey, caninsertkey, lookupkey +deletekey – integer to data structure maps +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="9pclient.html">9pclient(3)</a><td>CFid, CFsys, fsinit, fsmount, fsroot, fssetroot, fsunmount, nsmount, fsversion, fsauth, fsattach, fsclose, fscreate, fsdirread, fsdirreadall, fsdirstat, fsdirfstat, fsdirwstat, fsdirfwstat, fsopen, fsopenfd, fspread, fspwrite, fsread, fsreadn, fswrite – 9P client library +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="addpt.html">addpt(3)</a><td>addpt, subpt, mulpt, divpt, rectaddpt, rectsubpt, insetrect, canonrect, eqpt, eqrect, ptinrect, rectinrect, rectXrect, rectclip, combinerect, Dx, Dy, Pt, Rect, Rpt – arithmetic on points and rectangles +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="aes.html">aes(3)</a><td>setupAESstate, aesCBCencrypt, aesCBCdecrypt - advanced encryption standard (rijndael) +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="allocimage.html">allocimage(3)</a><td>allocimage, allocimagemix, freeimage, nameimage, namedimage, setalpha, loadimage, cloadimage, unloadimage, readimage, writeimage, bytesperline, wordsperline – allocating, freeing, reading, writing images +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="arg.html">arg(3)</a><td>ARGBEGIN, ARGEND, ARGC, ARGF, EARGF, arginit, argopt – process option letters from argv +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="arith3.html">arith3(3)</a><td>add3, sub3, neg3, div3, mul3, eqpt3, closept3, dot3, cross3, len3, dist3, unit3, midpt3, lerp3, reflect3, nearseg3, pldist3, vdiv3, vrem3, pn2f3, ppp2f3, fff2p3, pdiv4, add4, sub4 – operations on 3-d points and planes +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="atof.html">atof(3)</a><td>atof, atoi, atol, atoll, charstod, strtod, strtol, strtoll, strtoul, strtoull – convert text to numbers +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="bin.html">bin(3)</a><td>binalloc, bingrow, binfree – grouped memory allocation +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="bio.html">bio(3)</a><td>Bopen, Bfdopen, Binit, Binits, Brdline, Brdstr, Bgetc, Bgetrune, Bgetd, Bungetc, Bungetrune, Bread, Bseek, Boffset, Bfildes, Blinelen, Bputc, Bputrune, Bprint, Bvprint, Bwrite, Bflush, Bterm, Bbuffered – buffered input/output +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="blowfish.html">blowfish(3)</a><td>setupBFstate, bfCBCencrypt, bfCBCdecrypt, bfECBencrypt, bfECBdecrypt - blowfish encryption +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="cachechars.html">cachechars(3)</a><td>cachechars, agefont, loadchar, Subfont, Fontchar, Font – font utilities +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="cleanname.html">cleanname(3)</a><td>cleanname – clean a path name +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="color.html">color(3)</a><td>cmap2rgb, cmap2rgba, rgb2cmap – colors and color maps +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="complete.html">complete(3)</a><td>complete, freecompletion – file name completion +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="cputime.html">cputime(3)</a><td>cputime, times – cpu time in this process and children +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="ctime.html">ctime(3)</a><td>ctime, localtime, gmtime, asctime, tm2sec, timezone – convert date and time +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="des.html">des(3)</a><td>setupDESstate, des_key_setup, block_cipher, desCBCencrypt, desCBCdecrypt, desECBencrypt, desECBdecrypt, des3CBCencrypt, des3CBCdecrypt, des3ECBencrypt, des3ECBdecrypt, key_setup, des56to64, des64to56, setupDES3state, triple_block_cipher, - single and triple digital encryption standard +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="dial.html">dial(3)</a><td>dial, announce, listen, accept, reject, netmkaddr, dialparse – make and break network connections +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="dirread.html">dirread(3)</a><td>dirread, dirreadall – read directory +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="draw.html">draw(3)</a><td>Image, draw, drawop, gendraw, gendrawop, drawreplxy, drawrepl +replclipr, line, lineop, poly, polyop, fillpoly, fillpolyop, bezier, bezierop +bezspline, bezsplineop, bezsplinepts, fillbezier, fillbezierop +fillbezspline, fillbezsplineop, ellipse, ellipseop +fillellipse, fillellipseop, arc, arcop, fillarc, fillarcop +icossin, icossin2, border, string, stringop, stringn, stringnop +runestring, runestringop, runestringn, runestringnop, stringbg +stringbgop, stringnbg, stringnbgop, runestringbg, runestringbgop +runestringnbg, runestringnbgop, _string, ARROW, drawsetdebug – graphics functions +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="dsa.html">dsa(3)</a><td>dsagen, dsasign, dsaverify, dsapuballoc, dsapubfree, dsaprivalloc, dsaprivfree, dsasigalloc, dsasigfree, dsaprivtopub - digital signature algorithm +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="dup.html">dup(3)</a><td>dup – duplicate an open file descriptor +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="elgamal.html">elgamal(3)</a><td>eggen, egencrypt, egdecrypt, egsign, egverify, egpuballoc, egpubfree, egprivalloc, egprivfree, egsigalloc, egsigfree, egprivtopub - elgamal encryption +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="encode.html">encode(3)</a><td>dec64, enc64, dec32, enc32, dec16, enc16, encodefmt – encoding byte arrays as strings +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="errstr.html">errstr(3)</a><td>errstr, rerrstr, werrstr – description of last system call error +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="event.html">event(3)</a><td>event, einit, estart, estartfn, etimer, eread, emouse, ekbd, ecanread, ecanmouse, ecankbd, ereadmouse, eatomouse, eresized, egetrect, edrawgetrect, emenuhit, emoveto, esetcursor, Event, Mouse, Menu – graphics events +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="exec.html">exec(3)</a><td>exec, execl – execute a file +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="exits.html">exits(3)</a><td>exits, _exits, atexit, atexitdont, terminate – terminate process, process cleanup +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="fcall.html">fcall(3)</a><td>Fcall, convS2M, convD2M, convM2S, convM2D, fcallfmt, dirfmt, dirmodefmt, read9pmsg, statcheck, sizeS2M, sizeD2M – interface to Plan 9 File protocol +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="flate.html">flate(3)</a><td>deflateinit, deflate, deflatezlib, deflateblock, deflatezlibblock, inflateinit, inflate, inflatezlib, inflateblock, inflatezlibblock, flateerr, mkcrctab, blockcrc, adler32 – deflate compression +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="fmtinstall.html">fmtinstall(3)</a><td>fmtinstall, dofmt, dorfmt, fmtprint, fmtvprint, fmtrune, fmtstrcpy, fmtrunestrcpy, fmtfdinit, fmtfdflush, fmtstrinit, fmtstrflush, runefmtstrinit, runefmtstrflush, errfmt – support for user-defined print formats and output routines +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="frame.html">frame(3)</a><td>frinit, frsetrects, frinittick, frclear, frcharofpt, frptofchar, frinsert, frdelete, frselect, frtick, frselectpaint, frdrawsel, frdrawsel0, frgetmouse – frames of text +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="genrandom.html">genrandom(3)</a><td>genrandom, prng – random number generation +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="get9root.html">get9root(3)</a><td>get9root, unsharp – get path to root of Plan 9 tree +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="getcallerpc.html">getcallerpc(3)</a><td>getcallerpc – fetch return PC of current function +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="getenv.html">getenv(3)</a><td>getenv, putenv – access environment variables +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="getfields.html">getfields(3)</a><td>getfields, gettokens, tokenize – break a string into fields +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="getns.html">getns(3)</a><td>getns – get path to name space directory +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="getsnarf.html">getsnarf(3)</a><td>getsnarf, putsnarf – window system snarf (cut and paste) buffer +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="getuser.html">getuser(3)</a><td>getuser, sysname – get user or system name +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="getwd.html">getwd(3)</a><td>getwd – get current directory +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="graphics.html">graphics(3)</a><td>Display, Point, Rectangle, Cursor, initdraw, geninitdraw, drawerror, initdisplay, closedisplay, getdefont, getwindow, gengetwindow, flushimage, bufimage, lockdisplay, unlockdisplay, cursorswitch, cursorset, openfont, buildfont, freefont, Pfmt, Rfmt, strtochan, chantostr, chantodepth – interactive graphics +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="html.html">html(3)</a><td>parsehtml +printitems +validitems +freeitems +freedocinfo +dimenkind +dimenspec +targetid +targetname +fromStr +toStr +– HTML parser +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="ioproc.html">ioproc(3)</a><td>closeioproc +iocall +ioclose +iointerrupt +iodial +ioopen +ioproc +ioread +ioread9pmsg +ioreadn +iorecvfd +iosendfd +iosleep +iowrite – slave I/O processes for threaded programs +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="ip.html">ip(3)</a><td>eipfmt, parseip, parseipmask, v4parseip, v4parsecidr, parseether, myipaddr, myetheraddr, maskip, equivip, defmask, isv4, v4tov6, v6tov4, nhgetl, nhgets, nhgetv, hnputl, hnputs, hnputv, ptclbsum, readipifc – Internet protocol +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="isalpharune.html">isalpharune(3)</a><td>isalpharune, islowerrune, isspacerune, istitlerune, isupperrune, tolowerrune, totitlerune, toupperrune – Unicode character classes and cases +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="keyboard.html">keyboard(3)</a><td>initkeyboard, ctlkeyboard, closekeyboard – keyboard control +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="lock.html">lock(3)</a><td>lock, canlock, unlock +qlock, canqlock, qunlock +rlock, canrlock, runlock +wlock, canwlock, wunlock +rsleep, rwakeup, rwakeupall +incref, decref +– spin locks, queueing rendezvous locks, reader-writer locks, rendezvous points, and reference counts +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="mach.html">mach(3)</a><td>machbytype, machbyname – machine-independent access to executables and programs +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="mach-cmd.html">mach-cmd(3)</a><td>attachargs, attachcore, attachdynamic, attachproc, proctextfile – debugging processes and core files +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="mach-file.html">mach-file(3)</a><td>crackhdr, uncrackhdr, mapfile, unmapfile, mapproc, unmapproc, detachproc, ctlproc +procnotes – machine-independent access to exectuable files and running processes +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="mach-map.html">mach-map(3)</a><td>allocmap, addseg, findseg, addrtoseg +addrtosegafter, removeseg, freemap +get1, get2, get4, get8 +put1, put2, put4, put8 +rget, rput, fpformat +locnone, locaddr, locconst, locreg, locindir +loccmp, loceval, locfmt, locsimplify +lget1, lget2, lget4, lget8 +lput1, lput2, lput4, lput8 – machine-independent +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="mach-stack.html">mach-stack(3)</a><td>stacktrace, localaddr, unwindframe, windindex, windreglocs – stack traces +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="mach-swap.html">mach-swap(3)</a><td>beswap2, beswap4, beswap8, beieeeftoa32, beieeeftoa64, beieeeftoa80 +beload2, beload4, beload8 +leswap2, leswap4, leswap8, leieeeftoa32, leieeeftoa64, leieeeftoa80 +leload2, leload4, leload8, ieeeftoa32, ieeeftoa64 – machine-independent access to byte-ordered data +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="mach-symbol.html">mach-symbol(3)</a><td>symopen, symclose, findhdr, indexsym, lookupsym, findsym +findexsym, flookupsym, ffindsym +lookuplsym, indexlsym, findlsym +symoff, pc2file, file2pc, line2pc, fnbound, fileline +pc2line – symbol table access functions +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="malloc.html">malloc(3)</a><td>malloc, mallocz, free, realloc, calloc, setmalloctag, setrealloctag, getmalloctag, getrealloctag – memory allocator +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="matrix.html">matrix(3)</a><td>ident, matmul, matmulr, determinant, adjoint, invertmat, xformpoint, xformpointd, xformplane, pushmat, popmat, rot, qrot, scale, move, xform, ixform, persp, look, viewport – Geometric transformations +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="memdraw.html">memdraw(3)</a><td>Memimage +Memdata +Memdrawparam +memimageinit +wordaddr +byteaddr +memimagemove +allocmemimage +allocmemimaged +readmemimage +creadmemimage +writememimage +freememimage +memsetchan +loadmemimage +cloadmemimage +unloadmemimage +memfillcolor +memarc +mempoly +memellipse +memfillpoly +memimageline +memimagedraw +drawclip +memlinebbox +memlineendsize +allocmemsubfont +openmemsubfont +freememsubfont +memsubfontwidth +getmemdefont +memimagestring +iprint +hwdraw – drawing routines for memory-resident images +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="memlayer.html">memlayer(3)</a><td>memdraw, memlalloc, memldelete, memlexpose, memlfree, memlhide, memline, memlnorefresh, memload, memunload, memlorigin, memlsetrefresh, memltofront, memltofrontn, memltorear, memltorearn – windows of memory-resident images +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="memory.html">memory(3)</a><td>memccpy, memchr, memcmp, memcpy, memmove, memset – memory operations +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="mouse.html">mouse(3)</a><td>initmouse, readmouse, closemouse, moveto, cursorswitch, getrect, drawgetrect, menuhit, setcursor – mouse control +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="mousescrollsize.html">mousescrollsize(3)</a><td>mousescrollsize – compute mouse scroll increment +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="mp.html">mp(3)</a><td>mpsetminbits, mpnew, mpfree, mpbits, mpnorm, mpcopy, mpassign, mprand, strtomp, mpfmt,mptoa, betomp, mptobe, letomp, mptole, mptoui, uitomp, mptoi, itomp, uvtomp, mptouv, vtomp, mptov, mpdigdiv, mpadd, mpsub, mpleft, mpright, mpmul, mpexp, mpmod, mpdiv, mpfactorial, mpcmp, mpextendedgcd, mpinvert, mpsignif, mplowbits0, mpvecdigmuladd, mpvecdigmulsub, mpvecadd, mpvecsub, mpveccmp, mpvecmul, mpmagcmp, mpmagadd, mpmagsub, crtpre, crtin, crtout, crtprefree, crtresfree – extended precision arithmetic +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="muldiv.html">muldiv(3)</a><td>muldiv, umuldiv – high-precision multiplication and division +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="mux.html">mux(3)</a><td>Mux, muxinit, muxrpc, muxthreads – protocol multiplexor +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="nan.html">nan(3)</a><td>NaN, Inf, isNaN, isInf – not-a-number and infinity functions +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="needstack.html">needstack(3)</a><td>needstack – check for execution stack overflow +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="notify.html">notify(3)</a><td>notify, noted, atnotify, noteenable, notedisable, notifyon, notifyoff – handle asynchronous process notification +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="open.html">open(3)</a><td>open, create, close – open a file for reading or writing, create file +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="opentemp.html">opentemp(3)</a><td>opentemp – create a uniquely-named file +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="pipe.html">pipe(3)</a><td>pipe – create an interprocess channel +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="plumb.html">plumb(3)</a><td>eplumb, plumbfree, plumbopen, plumbopenfid, plumbsend, plumbsendtofid, plumbsendtext, plumblookup, plumbpack, plumbpackattr, plumbaddattr, plumbdelattr, plumbrecv, plumbrecvfid, plumbunpack, plumbunpackpartial, plumbunpackattr, Plumbmsg – plumb messages +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="post9pservice.html">post9pservice(3)</a><td>post9pservice – post 9P service for use by clients +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="postnote.html">postnote(3)</a><td>postnote – send a note to a process or process group +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="prime.html">prime(3)</a><td>genprime, gensafeprime, genstrongprime, DSAprimes, probably_prime, smallprimetest – prime number generation +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="print.html">print(3)</a><td>print, fprint, sprint, snprint, seprint, smprint, runesprint, runesnprint, runeseprint, runesmprint, vfprint, vsnprint, vseprint, vsmprint, runevsnprint, runevseprint, runevsmprint – print formatted output +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="proto.html">proto(3)</a><td>rdproto – parse and process a proto file listing +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="pushtls.html">pushtls(3)</a><td>pushtls, tlsClient, tlsServer, initThumbprints, freeThumbprints, okThumbprint, readcert, readcertchain – attach TLS1 or SSL3 encryption to a communication channel +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="qball.html">qball(3)</a><td>qball – 3-d rotation controller +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="quaternion.html">quaternion(3)</a><td>qtom, mtoq, qadd, qsub, qneg, qmul, qdiv, qunit, qinv, qlen, slerp, qmid, qsqrt – Quaternion arithmetic +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="quote.html">quote(3)</a><td>quotestrdup, quoterunestrdup, unquotestrdup, unquoterunestrdup, quotestrfmt, quoterunestrfmt, quotefmtinstall, doquote, needsrcquote – quoted character strings +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="rand.html">rand(3)</a><td>rand, lrand, frand, nrand, lnrand, srand, truerand, ntruerand, fastrand, nfastrand – random number generator +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="rc4.html">rc4(3)</a><td>setupRC4state, rc4, rc4skip, rc4back - alleged rc4 encryption +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="read.html">read(3)</a><td>read, readn, write, pread, pwrite – read or write file +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="regexp.html">regexp(3)</a><td>regcomp, regcomplit, regcompnl, regexec, regsub, rregexec, rregsub, regerror – regular expression +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="rfork.html">rfork(3)</a><td>rfork – manipulate process state +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="rsa.html">rsa(3)</a><td>asn1dump +asn1toRSApriv +decodepem +decodepemchain +rsadecrypt +rsaencrypt +rsafill, +rsagen +rsaprivalloc +rsaprivfree +rsaprivtopub +rsapuballoc +rsapubfree +X509toRSApub +X509dump +X509gen +X509req +X509verify – RSA encryption algorithm +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="rune.html">rune(3)</a><td>runetochar, chartorune, runelen, runenlen, fullrune, utfecpy, utflen, utfnlen, utfrune, utfrrune, utfutf – rune/UTF conversion +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="runestrcat.html">runestrcat(3)</a><td>runestrcat +runestrncat +runestrcmp +runestrncmp +runestrcpy +runestrncpy +runestrecpy +runestrlen +runestrchr +runestrrchr +runestrdup +runestrstr – rune string operations +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="sechash.html">sechash(3)</a><td>md4, md5, sha1, hmac_md5, hmac_sha1, md5pickle, md5unpickle, sha1pickle, sha1unpickle – cryptographically secure hashes +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="seek.html">seek(3)</a><td>seek – change file offset +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="sendfd.html">sendfd(3)</a><td>sendfd, recvfd – pass file descriptors along Unix domain sockets +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="setjmp.html">setjmp(3)</a><td>setjmp, longjmp, notejmp – non-local goto +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="sleep.html">sleep(3)</a><td>sleep, alarm – delay, ask for delayed note +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="stat.html">stat(3)</a><td>stat, fstat, wstat, fwstat, dirstat, dirfstat, dirwstat, dirfwstat, nulldir – get and put file status +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="strcat.html">strcat(3)</a><td>strcat, strncat, strcmp, strncmp, cistrcmp, cistrncmp, strcpy, strncpy, strecpy, strlen, strchr, strrchr, strpbrk, strspn, strcspn, strtok, strdup, strstr, cistrstr – string operations +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="string.html">string(3)</a><td>s_alloc, s_append, s_array, s_copy, s_error, s_free, s_incref, s_memappend, s_nappend, s_new, s_newalloc, s_parse, s_reset, s_restart, s_terminate, s_tolower, s_putc, s_unique, s_grow, s_read, s_read_line, s_getline, s_allocinstack, s_freeinstack, s_rdinstack – extensible strings +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="stringsize.html">stringsize(3)</a><td>stringsize, stringwidth, stringnwidth, runestringsize, runestringwidth, runestringnwidth – graphical size of strings +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="subfont.html">subfont(3)</a><td>allocsubfont, freesubfont, installsubfont, lookupsubfont, uninstallsubfont, subfontname, readsubfont, readsubfonti, writesubfont, stringsubfont, strsubfontwidth, mkfont – subfont manipulation +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="sysfatal.html">sysfatal(3)</a><td>sysfatal – system error messages +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="thread.html">thread(3)</a><td>alt +chancreate +chanfree +chaninit +chanprint +chansetname +mainstacksize +proccreate +procdata +recv +recvp +recvul +send +sendp +sendul +nbrecv +nbrecvp +nbrecvul +nbsend +nbsendp +nbsendul +threadcreate +threaddata +threadexec +threadexecl +threadexits +threadexitsall +threadgetgrp +threadgetname +threadint +threadintgrp +threadkill +threadkillgrp +threadmain +threadnotify +threadid +threadpid +threadsetgrp +threadsetname +threadsetstate +threadspawn +threadwaitchan +yield – thread and proc management +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="time.html">time(3)</a><td>time, nsec – time in seconds and nanoseconds since epoch +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="udpread.html">udpread(3)</a><td>udpread, udpwrite – read and write UDP packets +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="wait.html">wait(3)</a><td>await, awaitnohang, awaitfor, wait, waitnohang, waitfor, waitpid – wait for a process to exit +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="wctl.html">wctl(3)</a><td>drawresizewindow, drawsetlabel, drawtopwindow – window management +<tr height=1><td> +<tr height=1><td colspan=2 bgcolor=#cccccc> +<tr height=1><td> +<tr><td valign=top><a href="window.html">window(3)</a><td>Screen, allocscreen, publicscreen, freescreen, allocwindow, bottomwindow, bottomnwindows, topwindow, topnwindows, originwindow – window management +</table> +</center> +<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> +<td width=20> +</table> +</body> +</html> diff --git a/man/man3/intro.html b/man/man3/intro.html new file mode 100644 index 00000000..f6f4b311 --- /dev/null +++ b/man/man3/intro.html @@ -0,0 +1,288 @@ +<head> +<title>intro(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>INTRO(3)</b><td align=right><b>INTRO(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> + + intro – introduction to library functions<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> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include</font></tt> <i>any Unix headers <br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </i> + <tt><font size=+1>#include <libc.h> <br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include <auth.h> <br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include <bio.h> <br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include <draw.h> <br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include <fcall.h> <br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include <frame.h> <br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include <mach.h> <br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include <regexp.h> <br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include <thread.h> <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> + + This section describes functions in various libraries. For the + most part, each library is defined by a single C include file, + such as those listed above, and a single archive file containing + the library proper. The name of the archive is <tt><font size=+1>/usr/local/plan9/lib/lib</font></tt><i>x</i><tt><font size=+1>.a</font></tt>, + where <i>x</i> is the base of the include file name, + stripped of a leading <tt><font size=+1>lib</font></tt> if present. For example, <tt><font size=+1><draw.h></font></tt> defines + the contents of library <tt><font size=+1>/usr/local/plan9/lib/libdraw.a</font></tt>, which + may be abbreviated when named to the loader as <tt><font size=+1>−ldraw</font></tt>. In practice, + each include file contains a magic pragma that directs the loader + to pick up the associated archive + automatically, so it is rarely necessary to tell the loader which + libraries a program needs; see <a href="../man1/9c.html"><i>9c</i>(1)</a>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The library to which a function belongs is defined by the header + file that defines its interface. The ‘C library’, <i>libc</i>, contains + most of the basic subroutines such as <i>strlen</i>. Declarations for + all of these functions are in <tt><font size=+1><libc.h></font></tt>, which must be preceded by + (<i>needs</i>) an include of <tt><font size=+1><u.h></font></tt>. The graphics library, <i>draw</i>, is + defined by <tt><font size=+1><draw.h></font></tt>, which needs <tt><font size=+1><libc.h></font></tt> and <tt><font size=+1><u.h></font></tt>. The Buffered I/O + library, <i>libbio</i>, is defined by <tt><font size=+1><bio.h></font></tt>, which needs <tt><font size=+1><libc.h></font></tt> and <tt><font size=+1><u.h></font></tt>. + The ANSI C Standard I/O library, <i>libstdio</i>, is defined by <tt><font size=+1><stdio.h></font></tt>, + which needs <tt><font size=+1><u.h></font></tt>. There are a few other, less commonly used libraries + defined on + individual pages of this section. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The include file <tt><font size=+1><u.h></font></tt>, a prerequisite of several other include + files, declares the architecture-dependent and -independent types, + including: <i>uchar</i>, <i>ushort</i>, and <i>ulong</i>, the unsigned integer types; + <i>schar</i>, the signed char type; <i>vlong</i> and <i>uvlong</i>, the signed and + unsigned very long integral types; <i>Rune</i>, the Unicode + character type; <i>u8int</i>, <i>u16int</i>, <i>u32int</i>, and <i>u64int</i>, the unsigned + integral types with specific widths; <i>jmp_buf</i>, the type of the + argument to <i>setjmp</i> and <i>longjmp</i>, plus macros that define the layout + of <i>jmp_buf</i> (see <a href="../man3/setjmp.html"><i>setjmp</i>(3)</a>); and the macros <tt><font size=+1>va_arg</font></tt> and friends + for accessing arguments of variadic functions (identical to the + macros defined in <tt><font size=+1><stdarg.h></font></tt> in ANSI C). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Plan 9 and Unix use many similarly-named functions for different + purposes: for example, Plan 9’s <i>dup</i> is closer to (but not exactly) + Unix’s <i>dup2</i>. To avoid name conflicts, <tt><font size=+1><libc.h></font></tt> defines many of these + names as preprocessor macros to add a <i>p9</i> prefix, so that <i>dup</i> becomes + <i>p9dup</i>. To disable this renaming, + <tt><font size=+1>#define NOPLAN9DEFINES</font></tt> before including <tt><font size=+1><libc.h></font></tt>. If Unix headers + must be included in a program, they should be included after <tt><font size=+1><u.h></font></tt>, + which sets important preprocessor directives (for example, to + enable 64-bit file offsets), but before <tt><font size=+1><libc.h></font></tt>, to avoid renaming + problems. + <p><font size=+1><b>Name space </b></font><br> + Files are collected into a hierarchical organization called a + <i>file tree</i> starting in a <i>directory</i> called the <i>root</i>. File names, + also called <i>paths</i>, consist of a number of <tt><font size=+1>/</font></tt>-separated <i>path elements</i> + with the slashes corresponding to directories. A path element + must contain only printable characters (those outside the control + spaces of ASCII and Latin-1). A path element cannot contain a + slash. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + When a process presents a file name to Plan 9, it is <i>evaluated</i> + by the following algorithm. Start with a directory that depends + on the first character of the path: <tt><font size=+1>/</font></tt> means the root of the main + hierarchy, and anything else means the process’s current working + directory. Then for each path element, look up the element in + the directory, advance to that directory, do a possible translation + (see below), and repeat. The last step may yield a directory or + regular file.<br> + <p><font size=+1><b>File I/O </b></font><br> + Files are opened for input or output by <i>open</i> or <i>create</i> (see <a href="../man3/open.html"><i>open</i>(3)</a>). + These calls return an integer called a <i>file descriptor</i> which identifies + the file to subsequent I/O calls, notably <a href="../man3/read.html"><i>read</i>(3)</a> and <i>write</i>. The + system allocates the numbers by selecting the lowest unused descriptor. + They are allocated dynamically; there is no + visible limit to the number of file descriptors a process may + have open. They may be reassigned using <a href="../man3/dup.html"><i>dup</i>(3)</a>. File descriptors + are indices into a kernel resident <i>file descriptor table</i>. Each + process has an associated file descriptor table. In threaded programs + (see <a href="../man3/thread.html"><i>thread</i>(3)</a>), the file descriptor table is shared by all the + procs. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + By convention, file descriptor 0 is the standard input, 1 is the + standard output, and 2 is the standard error output. With one + exception, the operating system is unaware of these conventions; + it is permissible to close file 0, or even to replace it by a + file open only for writing, but many programs will be confused + by such + chicanery. The exception is that the system prints messages about + broken processes to file descriptor 2. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Files are normally read or written in sequential order. The I/O + position in the file is called the <i>file offset</i> and may be set + arbitrarily using the <a href="../man3/seek.html"><i>seek</i>(3)</a> system call. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Directories may be opened like regular files. Instead of reading + them with <a href="../man3/read.html"><i>read</i>(3)</a>, use the <tt><font size=+1>Dir</font></tt> structure-based routines described + in <a href="../man3/dirread.html"><i>dirread</i>(3)</a>. The entry corresponding to an arbitrary file can + be retrieved by <i>dirstat</i> (see <a href="../man3/stat.html"><i>stat</i>(3)</a>) or <i>dirfstat</i>; <i>dirwstat</i> and + <i>dirfwstat</i> write back entries, thus changing the properties of + a + file. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + New files are made with <i>create</i> (see <a href="../man3/open.html"><i>open</i>(3)</a>) and deleted with + <a href="../man3/remove.html"><i>remove</i>(3)</a>. Directories may not directly be written; <i>create</i>, <i>remove</i>, + <i>wstat</i>, and <i>fwstat</i> alter them. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <a href="../man3/Pipe.html"><i>Pipe</i>(3)</a> creates a connected pair of file descriptors, useful for + bidirectional local communication.<br> + <p><font size=+1><b>Process execution and control </b></font><br> + A new process is created when an existing one calls <a href="../man2/fork.html"><i>fork</i>(2)</a>. The + new (child) process starts out with copies of the address space + and most other attributes of the old (parent) process. In particular, + the child starts out running the same program as the parent; <a href="../man3/exec.html"><i>exec</i>(3)</a> + will bring in a different one. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Each process has a unique integer process id; a set of open files, + indexed by file descriptor; and a current working directory (changed + by <a href="../man2/chdir.html"><i>chdir</i>(2)</a>). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Each process has a set of attributes -- memory, open files, name + space, etc. -- that may be shared or unique. Flags to <i>rfork</i> control + the sharing of these attributes. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + A process terminates by calling <a href="../man3/exits.html"><i>exits</i>(3)</a>. A parent process may + call <a href="../man3/wait.html"><i>wait</i>(3)</a> to wait for some child to terminate. A bit of status + information may be passed from <i>exits</i> to <i>wait</i>. On Plan 9, the status + information is an arbitrary text string, but on Unix it is a single + integer. The Plan 9 interface persists here, although the + functionality does not. Instead, empty strings are converted to + exit status 0 and non-empty strings to 1. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + A process can go to sleep for a specified time by calling <a href="../man3/sleep.html"><i>sleep</i>(3)</a>. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + There is a <i>notification</i> mechanism for telling a process about + events such as address faults, floating point faults, and messages + from other processes. A process uses <a href="../man3/notify.html"><i>notify</i>(3)</a> to register the + function to be called (the <i>notification handler</i>) when such events + occur.<br> + <p><font size=+1><b>Multithreading </b></font><br> + Where possible according to the ANSI C standard, the main C library + works properly in multiprocess programs; <i>malloc</i>, <i>print</i>, and the + other routines use locks (see <a href="../man3/lock.html"><i>lock</i>(3)</a>) to synchronize access to + their data structures. The graphics library defined in <tt><font size=+1><draw.h></font></tt> + is also multi-process capable; details are in <a href="../man3/graphics.html"><i>graphics</i>(3)</a>. + In general, though, multiprocess programs should use some form + of synchronization to protect shared data. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The thread library, defined in <tt><font size=+1><thread.h></font></tt>, provides support for + multiprocess programs. It includes a data structure called a <tt><font size=+1>Channel</font></tt> + that can be used to send messages between processes, and coroutine-like + <i>threads</i>, which enable multiple threads of control within a single + process. The threads within a process + are scheduled by the library, but there is no pre-emptive scheduling + within a process; thread switching occurs only at communication + or synchronization points. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Most programs using the thread library comprise multiple processes + communicating over channels, and within some processes, multiple + threads. Since I/O calls may block, a system call may block all + the threads in a process. Therefore, a program that shouldn’t + block unexpectedly will use a process to serve the I/O + request, passing the result to the main processes over a channel + when the request completes. For examples of this design, see <a href="../man3/ioproc.html"><i>ioproc</i>(3)</a> + or <a href="../man3/mouse.html"><i>mouse</i>(3)</a>.<br> + +</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="../man1/nm.html"><i>nm</i>(1)</a>, <a href="../man1/9c.html"><i>9c</i>(1)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Math functions in <i>libc</i> return special values when the function + is undefined for the given arguments or when the value is not + representable (see <a href="../man3/nan.html"><i>nan</i>(3)</a>). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Some of the functions in <i>libc</i> are system calls and many others + employ system calls in their implementation. All system calls + return integers, with –1 indicating that an error occurred; <a href="../man3/errstr.html"><i>errstr</i>(3)</a> + recovers a string describing the error. Some user-level library + functions also use the <i>errstr</i> mechanism to report errors. + Functions that may affect the value of the error string are said + to “set <i>errstr</i>”; it is understood that the error string is altered + only if an error occurs.<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> diff --git a/man/man3/ioproc.html b/man/man3/ioproc.html new file mode 100644 index 00000000..092bac91 --- /dev/null +++ b/man/man3/ioproc.html @@ -0,0 +1,211 @@ +<head> +<title>ioproc(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>IOPROC(3)</b><td align=right><b>IOPROC(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> + + closeioproc, iocall, ioclose, iointerrupt, iodial, ioopen, ioproc, + ioread, ioread9pmsg, ioreadn, iorecvfd, iosendfd, iosleep, iowrite + – slave I/O processes for threaded programs<br> + +</table> +<p><font size=+1><b>SYNOPSIS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<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 <thread.h><br> + typedef struct Ioproc Ioproc;<br> + Ioproc* ioproc(void);<br> + int ioclose(Ioproc *io, int fd);<br> + int iodial(Ioproc *io, char *addr, char *local, char *dir, char + *cdfp);<br> + int ioopen(Ioproc *io, char *file, int omode);<br> + long ioread(Ioproc *io, int fd, void *a, long n);<br> + int ioread9pmsg(Ioproc *io, int fd, void *a, uint n);<br> + long ioreadn(Ioproc *io, int fd, void *a, long n);<br> + int iorecvfd(int socket);<br> + int iosendfd(int socket, int fd);<br> + int iosleep(int milli);<br> + long iowrite(Ioproc *io, int fd, void *a, long n);<br> + void iointerrupt(Ioproc *io);<br> + void closeioproc(Ioproc *io);<br> + long iocall(Ioproc *io, long (*op)(va_list *arg), ...);<br> + </font></tt> +</table> +<p><font size=+1><b>DESCRIPTION </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + These routines provide access to I/O in slave procs. Since the + I/O itself is done in a slave proc, other threads in the calling + proc can run while the calling thread waits for the I/O to complete. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Ioproc</i> forks a new slave proc and returns a pointer to the <tt><font size=+1>Ioproc</font></tt> + associated with it. <i>Ioproc</i> uses <i>mallocz</i> and <i>proccreate</i>; if either + fails, it calls <i>sysfatal</i> rather than return an error. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Ioclose</i>, <i>iodial</i>, <i>ioopen</i>, <i>ioread</i>, <i>ioread9pmsg</i>, <i>ioreadn</i>, <i>iorecvfd</i>, + <i>iosendfd</i>, <i>iosleep</i>, and <i>iowrite</i> execute the similarly named library + or system calls (see <a href="../man2/close.html"><i>close</i>(2)</a>, <a href="../man3/dial.html"><i>dial</i>(3)</a>, <a href="../man3/open.html"><i>open</i>(3)</a>, <a href="../man3/read.html"><i>read</i>(3)</a>, <a href="../man3/fcall.html"><i>fcall</i>(3)</a>, + <a href="../man3/sendfd.html"><i>sendfd</i>(3)</a>, and <a href="../man3/sleep.html"><i>sleep</i>(3)</a>) in the slave process associated with + <i>io</i>. It is an error to execute more than one call at a time in + an I/O + proc. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Iointerrupt</i> interrupts the call currently executing in the I/O + proc. If no call is executing, <i>iointerrupt</i> is a no-op. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Closeioproc</i> terminates the I/O proc and frees the associated <tt><font size=+1>Ioproc + . + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <i>Iocall</i> is a primitive that may be used to implement more slave + I/O routines. <i>Iocall</i> arranges for <i>op</i> to be called in <i>io</i>’s proc, + with <i>arg</i> set to the variable parameter list, returning the value + that <i>op</i> returns.<br> + +</table> +<p><font size=+1><b>EXAMPLE </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Relay messages between two file descriptors, counting the total + number of bytes seen:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>int tot;<br> + void<br> + relaythread(void *v)<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int *fd, n;<br> + char buf[1024];<br> + Ioproc *io;<br> + fd = v;<br> + io = ioproc();<br> + while((n = ioread(io, fd[0], buf, sizeof buf)) > 0){<br> + if(iowrite(io, fd[1], buf, n) != n)<br> + sysfatal("iowrite: %r");<br> + tot += n;<br> + }<br> + closeioproc(io);<br> + + </table> + }<br> + void<br> + relay(int fd0, int fd1)<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int fd[4];<br> + fd[0] = fd[3] = fd0;<br> + fd[1] = fd[2] = fd1;<br> + threadcreate(relaythread, fd, 8192);<br> + threadcreate(relaythread, fd+2, 8192);<br> + + </table> + }<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + If the two <i>relaythread</i> instances were running in different procs, + the common access to <i>tot</i> would be unsafe. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Implement <i>ioread</i>:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>static long<br> + _ioread(va_list *arg)<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int fd;<br> + void *a;<br> + long n;<br> + fd = va_arg(*arg, int);<br> + a = va_arg(*arg, void*);<br> + n = va_arg(*arg, long);<br> + return read(fd, a, n);<br> + + </table> + }<br> + long<br> + ioread(Ioproc *io, int fd, void *a, long n)<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + return iocall(io, _ioread, fd, a, n);<br> + + </table> + }<br> + </font></tt> + </table> + +</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/libthread<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/dial.html"><i>dial</i>(3)</a>, <a href="../man3/open.html"><i>open</i>(3)</a>, <a href="../man3/read.html"><i>read</i>(3)</a>, <a href="../man3/thread.html"><i>thread</i>(3)</a><br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Iointerrupt</i> is currently unimplemented.<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> diff --git a/man/man3/ip.html b/man/man3/ip.html new file mode 100644 index 00000000..0376fa95 --- /dev/null +++ b/man/man3/ip.html @@ -0,0 +1,345 @@ +<head> +<title>ip(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>IP(3)</b><td align=right><b>IP(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> + + eipfmt, parseip, parseipmask, v4parseip, v4parsecidr, parseether, + myipaddr, myetheraddr, maskip, equivip, defmask, isv4, v4tov6, + v6tov4, nhgetl, nhgets, nhgetv, hnputl, hnputs, hnputv, ptclbsum, + readipifc – Internet protocol<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 <ip.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int eipfmt(Fmt*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ulong parseip(uchar *ipaddr, char *str) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ulong parseipmask(uchar *ipaddr, char *str) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* v4parseip(uchar *ipaddr, char *str) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ulong v4parsecidr(uchar *addr, uchar *mask, char *str) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int parseether(uchar *eaddr, char *str) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int myetheraddr(uchar *eaddr, char *dev) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int myipaddr(uchar *ipaddr, char *net) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void maskip(uchar *from, uchar *mask, uchar *to) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int equivip(uchar *ipaddr1, uchar *ipaddr2) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>uchar* defmask(uchar *ipaddr) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int isv4(uchar *ipaddr) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void v4tov6(uchar *ipv6, uchar *ipv4) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void v6tov4(uchar *ipv4, uchar *ipv6) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ushort nhgets(void *p) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>uint nhgetl(void *p) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>uvlong nhgetv(void *p) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void hnputs(void *p, ushort v) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void hnputl(void *p, uint v) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void hnputv(void *p, uvlong v) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ushort ptclbsum(uchar *a, int n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Ipifc* readipifc(char *net, Ipifc *ifc, int index) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>uchar IPv4bcast[IPaddrlen]; + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>uchar IPv4allsys[IPaddrlen]; + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>uchar IPv4allrouter[IPaddrlen]; + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>uchar IPallbits[IPaddrlen]; + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>uchar IPnoaddr[IPaddrlen]; + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>uchar v4prefix[IPaddrlen];<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 routines are used by Internet Protocol (IP) programs to + manipulate IP and Ethernet addresses. Plan 9, by default, uses + V6 format IP addresses. Since V4 addresses fit into the V6 space, + all IP addresses can be represented. IP addresses are stored as + a string of 16 <tt><font size=+1>unsigned chars</font></tt>, Ethernet addresses as 6 + <tt><font size=+1>unsigned chars</font></tt>. Either V4 or V6 string representation can be used + for IP addresses. For V4 addresses, the representation can be + (up to) 4 decimal integers from 0 to 255 separated by periods. + For V6 addresses, the representation is (up to) 8 hex integers + from 0x0 to 0xFFFF separated by colons. Strings of 0 + integers can be elided using two colons. For example, <tt><font size=+1>FFFF::1111</font></tt> + is equivalent to <tt><font size=+1>FFFF:0:0:0:0:0:0:1111</font></tt>. The string representation + for IP masks is a superset of the address representation. It includes + slash notation that indicates the number of leading 1 bits in + the mask. Thus, a V4 class C mask can be + represented as <tt><font size=+1>FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FF00</font></tt>, <tt><font size=+1>255.255.255.0</font></tt>, + or <tt><font size=+1>/120.</font></tt> The string representation of Ethernet addresses is exactly + 12 hexadecimal digits. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Eipfmt</i> is a <a href="../man3/print.html"><i>print</i>(3)</a> formatter for Ethernet (verb <tt><font size=+1>E</font></tt>) addresses, + IP V6 (verb <tt><font size=+1>I</font></tt>) addresses, IP V4 (verb <tt><font size=+1>V</font></tt>) addresses, and IP V6 + (verb <tt><font size=+1>M</font></tt>) masks. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Parseip</i> converts a string pointed to by <i>str</i> to a 16-byte IP address + starting at <i>ipaddr</i>. As a concession to backwards compatibility, + if the string is a V4 address, the return value is an unsigned + long integer containing the big-endian V4 address. If not, the + return value is 6. <i>Parseipmask</i> converts a string pointed to by + <i>str + </i>to a 6-byte IP mask starting at <i>ipaddr</i>. It too returns an unsigned + long big-endian V4 address or 6. Both routines return -1 on errors. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>V4parseip</i> converts a string pointed to by <i>str</i> to a 4-byte V4 IP + address starting at <i>ipaddr</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>V4parsecidr</i> converts a string of the form addr/mask, pointed to + by <i>str</i>, to a 4-byte V4 IP address starting at <i>ipaddr</i> and a 4-byte + V4 IP mask starting at <i>mask</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Myipaddr</i> returns the first valid IP address in the IP stack rooted + at <i>net</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Parseether</i> converts a string pointed to by <i>str</i> to a 6-byte Ethernet + address starting at <i>eaddr</i>. <i>Myetheraddr</i> reads the Ethernet address + string from file <i>dev</i><tt><font size=+1>/1/stats</font></tt> and parses it into <i>eaddr</i>. Both routines + return a negative number on errors. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Maskip</i> places the bit-wise AND of the IP addresses pointed to + by its first two arguments into the buffer pointed to by the third. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Equivip</i> returns non-zero if the IP addresses pointed to by its + two arguments are equal. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Defmask</i> returns the standard class A, B, or C mask for <i>ipaddr</i>. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Isv4</i> returns non-zero if the V6 address is in the V4 space, that + is, if it starts with <tt><font size=+1>0:0:0:0:0:0:FFFF</font></tt>. <i>V4tov6</i> converts the V4 + address, <i>v4ip</i>, to a V6 address and puts the result in <i>v6ip</i>. <i>V6tov4</i> + converts the V6 address, <i>v6ip</i>, to a V4 address and puts the result + in <i>v4ip</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Hnputs</i>, <i>hnputl</i>, and <i>hnputv</i> are used to store 16-, 32-, and 64-bit + integers into IP big-endian form. <i>Nhgets</i>, <i>nhgetl</i>, and <i>nhgetv</i> convert + big-endian 2-, 4-, and 8-byte quantities into integers. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Pctlbsum</i> returns the one’s complement checksum used in IP protocols, + typically invoked as<br> + <tt><font size=+1>hnputs(hdr−>cksum, ~ptclbsum(data, len) & 0xffff);<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + A number of standard IP addresses in V6 format are also defined. + They are:<br> + <tt><font size=+1>IPv4bcast<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + the V4 broadcast address<br> + + </table> + <tt><font size=+1>IPv4allsys<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + the V4 all systems multicast address<br> + + </table> + <tt><font size=+1>IPv4allrouter<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + the V4 all routers multicast address<br> + + </table> + <tt><font size=+1>IPallbits<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + the V6 all bits on address<br> + + </table> + <tt><font size=+1>IPnoaddr<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + the V6 null address, all zeros<br> + + </table> + <tt><font size=+1>v4prefix<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + the IP V6 prefix to all embedded V4 addresses + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + <i>Readipifc</i> returns information about a particular interface (<i>index + </i>>= 0) or all IP interfaces (<i>index </i>< 0) configured under a mount + point <i>net</i>, default <tt><font size=+1>/net</font></tt>. Each interface is described by one <i>Ipifc</i> + structure which in turn points to a linked list of <i>Iplifc</i> structures + describing the addresses assigned to this interface. If the list + <i>ifc</i> is supplied, that list is freed. Thus, subsequent calls can + be used to free the list returned by the previous call. <i>Ipifc</i> + is: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>typedef struct Ipifc<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Ipifc *next;<br> + Iplifc *lifc; /* local addressses */<br> + /* per ip interface */<br> + int index; /* number of interface in ipifc dir */<br> + char dev[64]; /* associated physical device */<br> + int mtu; /* max transfer unit */<br> + long validlt; /* valid life time */<br> + long preflt; /* preferred life time */<br> + uchar sendra6; /* on == send router adv */<br> + uchar recvra6; /* on == rcv router adv */<br> + ulong pktin; /* packets read */<br> + ulong pktout; /* packets written */<br> + ulong errin; /* read errors */<br> + ulong errout; /* write errors */<br> + Ipv6rp rp; /* route advertisement params */<br> + + </table> + } Ipifc;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <i>Iplifc</i> is: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>struct Iplifc<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Iplifc *next;<br> + uchar ip[IPaddrlen];<br> + uchar mask[IPaddrlen];<br> + uchar net[IPaddrlen]; /* ip & mask */<br> + ulong preflt; /* preferred lifetime */<br> + ulong validlt; /* valid lifetime */<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <i>Ipv6rp</i> is: struct Ipv6rp { int mflag; int oflag; int maxraint; + /* max route adv interval */ int minraint; /* min route adv interval + */ int linkmtu; int reachtime; int rxmitra; int ttl; int routerlt; + }; + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Dev</i> contains the first 64 bytes of the device configured with + this interface. <i>Net</i> is <i>ip</i><tt><font size=+1>&</font></tt><i>mask</i> if the network is multipoint or + the remote address if the network is point to point.<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/libip<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/print.html"><i>print</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> diff --git a/man/man3/isalpharune.html b/man/man3/isalpharune.html new file mode 100644 index 00000000..99c2f387 --- /dev/null +++ b/man/man3/isalpharune.html @@ -0,0 +1,96 @@ +<head> +<title>isalpharune(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>ISALPHARUNE(3)</b><td align=right><b>ISALPHARUNE(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> + + isalpharune, islowerrune, isspacerune, istitlerune, isupperrune, + tolowerrune, totitlerune, toupperrune – Unicode character classes + and cases<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int isalpharune(Rune c) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int islowerrune(Rune c) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int isspacerune(Rune c) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int istitlerune(Rune c) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int isupperrune(Rune c) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rune tolowerrune(Rune c) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rune totitlerune(Rune c) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rune toupperrune(Rune c)<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 routines examine and operate on Unicode characters, in particular + a subset of their properties as defined in the Unicode standard. + Unicode defines some characters as alphabetic and specifies three + cases: upper, lower, and title. Analogously to <a href="../man3/isalpha.html"><i>isalpha</i>(3)</a> for + ASCII, these routines test types and modify cases for + Unicode characters. The names are self-explanatory. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The case-conversion routines return the character unchanged if + it has no case.<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/lib9/utf/runetype.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/isalpha.html"><i>isalpha</i>(3)</a><i>, The Unicode Standard</i>.<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> diff --git a/man/man3/keyboard.html b/man/man3/keyboard.html new file mode 100644 index 00000000..19dc833d --- /dev/null +++ b/man/man3/keyboard.html @@ -0,0 +1,135 @@ +<head> +<title>keyboard(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>KEYBOARD(3)</b><td align=right><b>KEYBOARD(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> + + initkeyboard, ctlkeyboard, closekeyboard – keyboard control<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 <thread.h><br> + #include <keyboard.h><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Keyboardctl *initkeyboard(char *file)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int ctlkeyboard(Keyboardctl *kc, char *msg)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void closekeyboard(Keyboard *kc)<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 functions access and control a keyboard interface for character-at-a-time + I/O in a multi-threaded environment, usually in combination with + <a href="../man3/mouse.html"><i>mouse</i>(3)</a>. They use the message-passing <tt><font size=+1>Channel</font></tt> interface in the + threads library (see <a href="../man3/thread.html"><i>thread</i>(3)</a>); programs that wish a more event-driven, + single-threaded approach + should use <a href="../man3/event.html"><i>event</i>(3)</a>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Initkeyboard</i> opens a connection to the keyboard and returns a + <tt><font size=+1>Keyboardctl</font></tt> structure:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef struct Keyboardct Keyboardctl;<br> + struct Keyboardctl<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Channel *c; /* chan(Rune[20]) */<br> + char *file;<br> + int consfd; /* to cons file */<br> + int ctlfd; /* to ctl file */<br> + int pid; /* of slave proc */<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + The argument to <i>initkeyboard</i> is ignored (on Plan 9, it is the + name of the keyboard device). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Once the <tt><font size=+1>Keyboardctl</font></tt> is set up a message containing a <tt><font size=+1>Rune</font></tt> will + be sent on the <tt><font size=+1>Channel Keyboardctl.c</font></tt> to report each character + read from the device. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Ctlkeyboard</i> is used to set the state of the interface, typically + to turn raw mode on and off. It writes the string <i>msg</i> to the control + file associated with the device, which is assumed to be the regular + device file name with the string <tt><font size=+1>ctl</font></tt> appended. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Closekeyboard</i> closes the file descriptors associated with the + keyboard, kills the slave processes, and frees the <tt><font size=+1>Keyboardctl</font></tt> + structure. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +</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/libdraw<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/graphics.html"><i>graphics</i>(3)</a>, <a href="../man3/draw.html"><i>draw</i>(3)</a>, <a href="../man3/event.html"><i>event</i>(3)</a>, <a href="../man3/thread.html"><i>thread</i>(3)</a>.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Because the interface delivers complete runes, there is no way + to report lesser actions such as shift keys or even individual + bytes.<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> diff --git a/man/man3/lock.html b/man/man3/lock.html new file mode 100644 index 00000000..72d66e12 --- /dev/null +++ b/man/man3/lock.html @@ -0,0 +1,222 @@ +<head> +<title>lock(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>LOCK(3)</b><td align=right><b>LOCK(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> + + lock, canlock, unlock, qlock, canqlock, qunlock, rlock, canrlock, + runlock, wlock, canwlock, wunlock, rsleep, rwakeup, rwakeupall + incref, decref – spin locks, queueing rendezvous locks, reader-writer + locks, rendezvous points, and reference counts<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> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + void lock(Lock *l)<br> + int canlock(Lock *l)<br> + void unlock(Lock *l)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + void qlock(QLock *l)<br> + int canqlock(QLock *l)<br> + void qunlock(QLock *l)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + void rlock(RWLock *l)<br> + int canrlock(RWLock *l)<br> + void runlock(RWLock *l)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + void wlock(RWLock *l)<br> + int canwlock(RWLock *l)<br> + void wunlock(RWLock *l)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + typedef struct Rendez {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + QLock *l;<br> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>...<br> + </i> + </table> + <tt><font size=+1>} Rendez;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + void rsleep(Rendez *r)<br> + int rwakeup(Rendez *r)<br> + int rwakeupall(Rendez *r)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + #include <thread.h><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + typedef struct Ref {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + long ref;<br> + + </table> + } Ref;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + void incref(Ref*)<br> + long decref(Ref*)<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 routines are used to synchronize processes sharing memory. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>Locks</font></tt> are spin locks, <tt><font size=+1>QLocks</font></tt> and <tt><font size=+1>RWLocks</font></tt> are different types of + queueing locks, and <tt><font size=+1>Rendezes</font></tt> are rendezvous points. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Locks and rendezvous points have trivial implementations in programs + not using the thread library (see <a href="../man3/thread.html"><i>thread</i>(3)</a>), since such programs + have no concurrency. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Used carelessly, spin locks can be expensive and can easily generate + deadlocks. Their use is discouraged, especially in programs that + use the thread library because they prevent context switches between + threads. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Lock</i> blocks until the lock has been obtained. <i>Canlock</i> is non-blocking. + It tries to obtain a lock and returns a non-zero value if it was + successful, 0 otherwise. <i>Unlock</i> releases a lock. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>QLocks</font></tt> have the same interface but are not spin locks; instead + if the lock is taken <i>qlock</i> will suspend execution of the calling + thread until it is released. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Although <tt><font size=+1>Locks</font></tt> are the more primitive lock, they have limitations; + for example, they cannot synchronize between tasks in the same + <i>proc</i>. Use <tt><font size=+1>QLocks</font></tt> instead. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>RWLocks</font></tt> manage access to a data structure that has distinct readers + and writers. <i>Rlock</i> grants read access; <i>runlock</i> releases it. <i>Wlock</i> + grants write access; <i>wunlock</i> releases it. <i>Canrlock</i> and <i>canwlock</i> + are the non-blocking versions. There may be any number of simultaneous + readers, but only one writer. Moreover, if + write access is granted no one may have read access until write + access is released. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + All types of lock should be initialized to all zeros before use; + this puts them in the unlocked state. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>Rendezes</font></tt> are rendezvous points. Each <tt><font size=+1>Rendez</font></tt> <i>r</i> is protected by + a <tt><font size=+1>QLock</font></tt> <i>r</i><tt><font size=+1>−></font></tt><i>l</i>, which must be held by the callers of <i>rsleep</i>, <i>rwakeup</i>, + and <i>rwakeupall</i>. <i>Rsleep</i> atomically releases <i>r</i><tt><font size=+1>−></font></tt><i>l</i> and suspends execution + of the calling task. After resuming execution, <i>rsleep</i> will reacquire + <i>r</i><tt><font size=+1>−></font></tt><i>l</i> before returning. If any processes + are sleeping on <i>r</i>, <i>rwakeup</i> wakes one of them. it returns 1 if + a process was awakened, 0 if not. <i>Rwakeupall</i> wakes all processes + sleeping on <i>r</i>, returning the number of processes awakened. <i>Rwakeup</i> + and <i>rwakeupall</i> do not release <i>r</i><tt><font size=+1>−></font></tt><i>l</i> and do not suspend execution + of the current task. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Before use, <tt><font size=+1>Rendezes</font></tt> should be initialized to all zeros except + for <i>r</i><tt><font size=+1>−></font></tt><i>l</i> pointer, which should point at the <tt><font size=+1>QLock</font></tt> that will guard + <i>r</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + A <tt><font size=+1>Ref</font></tt> contains a <tt><font size=+1>long</font></tt> that can be incremented and decremented + atomically: <i>Incref</i> increments the <i>Ref</i> in one atomic operation. + <i>Decref</i> atomically decrements the <tt><font size=+1>Ref</font></tt> and returns zero if the resulting + value is zero, non-zero otherwise.<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/lib9/qlock.c<br> + /usr/local/plan9/src/libthread<br> + </font></tt> +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>Locks</font></tt> are not always spin locks. Instead they are usually implemented + using the <i>pthreads</i> library’s <tt><font size=+1>pthread_mutex_t</font></tt>, whose implementation + method is not defined. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + On <i>pthreads</i>-based systems, the implementation of <tt><font size=+1>Lock</font></tt> never calls + <i>pthread_mutex_destroy</i> to free the <tt><font size=+1>pthread_mutex_t</font></tt>’s. This leads + to resource leaks on FreeBSD 5 (though not on Linux 2.6, where + <i>pthread_mutex_destroy</i> is a no-op). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + On systems that do not have a usable <i>pthreads</i> implementation, + the <tt><font size=+1>Lock</font></tt> implementation provided by <i>libthread</i> is still not exactly + a spin lock. After each unsuccessful attempt, <i>lock</i> calls <tt><font size=+1>sleep(0)</font></tt> + to yield the CPU; this handles the common case where some other + process holds the lock. After a thousand + unsuccessful attempts, <i>lock</i> sleeps for 100ms between attempts. + Another another thousand unsuccessful attempts, <i>lock</i> sleeps for + a full second between attempts. <tt><font size=+1>Locks</font></tt> are not intended to be held + for long periods of time. The 100ms and full second sleeps are + only heuristics to avoid tying up the CPU when a + process deadlocks. As discussed above, if a lock is to be held + for much more than a few instructions, the queueing lock types + should be almost always be used.<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> diff --git a/man/man3/mach-cmd.html b/man/man3/mach-cmd.html new file mode 100644 index 00000000..978e80b5 --- /dev/null +++ b/man/man3/mach-cmd.html @@ -0,0 +1,167 @@ +<head> +<title>mach-cmd(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>MACH-CMD(3)</b><td align=right><b>MACH-CMD(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> + + attachargs, attachcore, attachdynamic, attachproc, proctextfile + – debugging processes and core files<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 <mach.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int attachcore(Fhdr *hdr) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int attachproc(int pid) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int attachdynamic(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* proctextfile(int pid) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int attachargs(int argc, char **argv, int omode) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>extern Fhdr* symhdr;<br> + </font></tt>extern char* symfil;<br> + extern Map* symmap;<br> + extern Fhdr* fhdrlist;<br> + extern Fhdr* corhdr;<br> + extern char* corfil;<br> + extern Map* cormap;<br> + extern int corpid;<br> + extern Regs* correg;<br> + +</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 routines provide access to the objects a typical debugger + manipulates: an executable binary, some number of shared libraries, + a memory image in the form of a core dump or active process, and + a register set. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The maintained state is:<br> + <i>symhdr<br> + </i> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The file header for the main binary.<br> + + </table> + <i>symfil</i>The file name of the main binary.<br> + <i>symmap<br> + </i> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The memory map of the main binary.<br> + + </table> + <i>fhdrlist<br> + </i> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + A linked list (via the <tt><font size=+1>Fhdr.next</font></tt> fields) of all currently open + headers (see <i>symopen</i> in <a href="../man3/mach-symbol.html"><i>mach-symbol</i>(3)</a>). When dynamically linked + objects have been attached, they are present in this linked list, + and therefore included in searches by <i>indexsym</i>, <i>lookupsym</i>, and + <i>findsym</i> (see <a href="../man3/mach-symbol.html"><i>mach-symbol</i>(3)</a>). + + </table> + <i>corhdr</i>The file header for the core dump, if any.<br> + <i>corfil</i>The file name of the core dump, if any.<br> + <i>cormap<br> + </i> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The memory map of the core dump or attached process.<br> + + </table> + <i>corpid</i>The process id of the attached process, if any.<br> + <i>correg</i>The register set of the core dump or attached process. If + these fields are not valid, they are zeroed. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Attachcore</i> and <i>attachproc</i> attach to an opened core file or an + executing process. They set <i>corhdr</i>, <i>corfil</i>, <i>cormap</i>, <i>corpid</i>, and + <i>correg</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Proctextfile</i> returns the name of the main binary for the process + with id <i>pid</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Attachdynamic</i> requires that the memory image already be attached. + It reads the dynamic linker’s internal run-time data structures + and then opens all the dynamic objects that are currently loaded. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Attachargs</i> uses all of these functions while parsing an argument + vector as would be passed to a debugger like <a href="../man1/db.html"><i>db</i>(1)</a> or <a href="../man1/acid.html"><i>acid</i>(1)</a>. + It expects a list of executable files, core dump files, or process + ids, given in any order. If extra arguments are given (for example, + more than one executable, or both a core dump and a + process id), they are ignored and diagnostics are printed to standard + error. If arguments are missing (for example, the process id is + given without an executable file), <i>attachargs</i> fills them in as + best it can.<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/libmach<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/mach.html"><i>mach</i>(3)</a>, <a href="../man3/mach-file.html"><i>mach-file</i>(3)</a>, <a href="../man3/mach-map.html"><i>mach-map</i>(3)</a><br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The interface needs to be changed to support multiple threads, + each with its own register set.<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> diff --git a/man/man3/mach-file.html b/man/man3/mach-file.html new file mode 100644 index 00000000..7fd1a578 --- /dev/null +++ b/man/man3/mach-file.html @@ -0,0 +1,185 @@ +<head> +<title>mach-file(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>MACH-FILE(3)</b><td align=right><b>MACH-FILE(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> + + crackhdr, uncrackhdr, mapfile, unmapfile, mapproc, unmapproc, + detachproc, ctlproc, procnotes – machine-independent access to + exectuable files and running processes<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 <mach.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + int crackhdr(int fd, Fhdr *hdr)<br> + void uncrackhdr(Fhdr *hdr) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + int mapfile(Fhdr *hdr, ulong base, Map *map, Regs **regs)<br> + void unmapfile(Fhdr *hdr, Map *map)<br> + int mapproc(int pid, Map *map, Regs **regs)<br> + void unmapproc(Map *map)<br> + int detachproc(int pid)<br> + int ctlproc(int pid, char *msg)<br> + int procnotes(int pid, char ***notes)<br> + +</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 functions parse executable files and provide access to those + files and to running processes. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Crackhdr</i> opens and parses the named executable file. The returned + data structure <i>hdr</i> is initialized with a machine-independent description + of the header information. The following fields are the most commonly + used:<br> + <tt><font size=+1>mach</font></tt>a pointer to the <tt><font size=+1>Mach</font></tt> structure for the target architecture<br> + <tt><font size=+1>mname<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + the name of the target architecture<br> + + </table> + <tt><font size=+1>fname<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + a description of the kind of file (e.g., executable, core dump)<br> + + </table> + <tt><font size=+1>aname<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + a description of the application binary interface this file uses; + typically it is the name of an operating system If the global + variable <i>mach</i> is nil, <i>crackhdr</i> points it to the same <tt><font size=+1>Mach</font></tt> structure. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + <i>Mapfile</i> adds the segments found in <i>hdr</i> to <i>map</i>. If <i>hdr</i> is an executable + file, there are typically three segments: <i>text</i>, <i>data</i>, and a zero-backed + <i>bss</i>. If <i>hdr</i> is a dynamic shared library, its segments are relocated + by <i>base</i> before being mapping. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + If <i>hdr</i> is a core file, there is one segment named <i>core</i> for each + contiguous section of memory recorded in the core file. There + are often quite a few of these, as most operating systems omit + clean memory pages when writing core files (Mac OS X is the only + exception among the supported systems). Because core files + have such holes, it is typically necessary to construct the core + map by calling <i>mapfile</i> on the executable and then calling it again + on the core file. Newly-added segments are mapped on top of existing + segments, so this arrangement will use the core file for the segments + it contains but fall back to the executable for the + rest. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Unmapfile</i> removes the mappings in <i>map</i> corresponding to <i>hdr</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Mapproc</i> attaches to a running program and adds its segments to + the given map. It adds one segment for each contiguous section + of mapped memory. On systems where this information cannot be + determined, it adds a single segment covering the entire address + space. Accessing areas of this segment that are + actually not mapped in the process address space will cause the + get/put routines to return errors. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Unmapproc</i> removes the mappings in <i>map</i> corresponding to <i>pid</i>. <i>Detachproc</i> + detaches from all previously attached processes. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Ctlproc</i> manipulates the process with id <i>pid</i> according to the message + <i>msg</i>. Valid messages include:<br> + <tt><font size=+1>kill</font></tt>terminate the process<br> + <tt><font size=+1>startstop<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + start the process and wait for it to stop<br> + + </table> + <tt><font size=+1>sysstop<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + arrange for the process to stop at its next system call, start + the process, and then wait for it to stop<br> + + </table> + <tt><font size=+1>waitstop<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + wait for the process to stop<br> + + </table> + <tt><font size=+1>start<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + start the process + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + <i>Procnotes</i> fills <tt><font size=+1>*</font></tt><i>notes</i> with a pointer to an array of strings representing + pending notes waiting for the process. (On Unix, these notes are + textual descriptions of any pending signals.) <i>Procnotes</i> returns + the number of pending notes. The memory at <tt><font size=+1>*</font></tt><i>notes</i> should be freed + via <i>free</i> (see <a href="../man3/malloc.html"><i>malloc</i>(3)</a>) when no longer needed. + +</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/libmach<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/mach.html"><i>mach</i>(3)</a>, <a href="../man3/mach-map.html"><i>mach-map</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> diff --git a/man/man3/mach-map.html b/man/man3/mach-map.html new file mode 100644 index 00000000..ddf7275f --- /dev/null +++ b/man/man3/mach-map.html @@ -0,0 +1,312 @@ +<head> +<title>mach-map(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>MACH-MAP(3)</b><td align=right><b>MACH-MAP(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> + + allocmap, addseg, findseg, addrtoseg, addrtosegafter, removeseg, + freemap, get1, get2, get4, get8, put1, put2, put4, put8, rget, + rput, fpformat, locnone, locaddr, locconst, locreg, locindir, + loccmp, loceval, locfmt, locsimplify, lget1, lget2, lget4, lget8, + lput1, lput2, lput4, lput8 – machine-independent access to address + spaces and register sets<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 <mach.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + typedef struct Map Map;<br> + typedef struct Seg Seg;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + struct Seg<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + char *name;<br> + char *file;<br> + int fd;<br> + ulong base;<br> + ulong size;<br> + ulong offset;<br> + int (*rw)(Map*, Seg*, ulong, void*, uint, int);<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + struct Map<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Seg *seg;<br> + int nseg;<br> + <i>...<br> + </i> + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Map *allocmap(void)<br> + int addseg(Map *map, Seg seg)<br> + int findseg(Map *map, char *name, char *file)<br> + int addrtoseg(Map *map, ulong addr, Seg *seg)<br> + int addrtosegafter(Map *map, ulong addr, Seg *seg)<br> + void removeseg(Map *map, int i)<br> + void freemap(Map *map)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + int get1(Map *map, ulong addr, uchar *a, uint n)<br> + int get2(Map *map, ulong addr, u16int *u)<br> + int get4(Map *map, ulong addr, u32int *u)<br> + int get8(Map *map, ulong addr, u64int *u)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + int put1(Map *map, ulong addr, uchar *a, uint n)<br> + int put2(Map *map, ulong addr, u16int u)<br> + int put4(Map *map, ulong addr, u32int u)<br> + int put8(Map *map, ulong addr, u64int u)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + int rget(Regs *regs, char *reg, ulong *u)<br> + int fpformat(Map *map, char *reg, char *a, uint n, char code);<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + int rput(Regs *regs, char *name, ulong u)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Loc locnone(void)<br> + Loc locaddr(ulong addr)<br> + Loc locconst(ulong con)<br> + Loc locreg(char *reg)<br> + Loc locindir(char *reg, long offset)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + int loccmp(Loc *a, Loc *b)<br> + int loceval(Map *map, Loc loc, ulong *addr)<br> + int locfmt(Fmt *fmt)<br> + int locsimplify(Map *map, Loc *regs, Loc loc, Loc *newloc)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + int lget1(Map *map, Loc loc, uchar *a, uint n)<br> + int lget2(Map *map, Loc loc, u16int *u)<br> + int lget4(Map *map, Loc loc, u32int *u)<br> + int lget8(Map *map, Loc loc, u64int *u)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + int lput1(Map *map, Loc loc, uchar *a, uint n)<br> + int lput2(Map *map, Loc loc, u16int u)<br> + int lput4(Map *map, Loc loc, u32int u)<br> + int lput8(Map *map, Loc loc, u64int u)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +</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 functions provide a processor-independent interface for + accessing executable files, core files, and running processes + via <i>maps</i>, data structures that provides access to an address space + and register set. The functions described in <a href="../man3/mach-file.html"><i>mach-file</i>(3)</a> are + typically used to construct these maps. Related library functions + described in <a href="../man3/mach-symbol.html"><i>mach-symbol</i>(3)</a> provide similar access to symbol tables. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Each <i>map</i> comprises an optional register set and one or more <tt><font size=+1>segments</font></tt>, + each associating a non-overlapping range of memory addresses with + a logical section of an executable file or of a running process’s + address space. Other library functions then use a map and the + architecture-specific data structures to provide + a generic interface to the processor-dependent data. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Each segment has a name (e.g., <tt><font size=+1>text</font></tt> or <tt><font size=+1>data</font></tt>) and may be associated + with a particular file. A segment represents a range of accessible + address space. Segments may be backed an arbitary access function + (if the <tt><font size=+1>rw</font></tt> pointer is non-nil), or by the contents of an open + file (using the <tt><font size=+1>fd</font></tt> file descriptor). Each range has a + starting address in the space (<tt><font size=+1>base</font></tt>) and an extent (<tt><font size=+1>size</font></tt>). In + segments mapped by files, the range begins at byte <tt><font size=+1>offset</font></tt> in the + file. The <tt><font size=+1>rw</font></tt> function is most commonly used to provide access + to executing processes via <a href="../man2/ptrace.html"><i>ptrace</i>(2)</a> and to zeroed segments. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Allocmap</i> creates an empty map; <i>freemap</i> frees a map. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Addseg</i> adds the given segment to the map, resizing the map’s <i>seg</i> + array if necessary. A negative return value indicates an allocation + error. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Findseg</i> returns the index of the segment with the given name (and, + if <i>file</i> is non-nil, the given file), or –1 if no such segment is + found. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Addrtoseg</i> returns the index of the segment containing for the + given address, or –1 if that address is not mapped. Segments may + have overlapping address ranges: <i>addseg</i> appends segments to the + end of the <i>seg</i> array in the map, and <i>addrtoseg</i> searches the map + backwards from the end, so the most recently mapped + segment wins. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Addrtosegafter</i> returns the index of the segment containing the + lowest mapped address greater than <i>addr</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Removeseg</i> removes the segment at the given index. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Get1</i>, <i>get2</i>, <i>get4</i>, and <i>get8</i> retrieve the data stored at address + <i>addr</i> in the address space associated with <i>map</i>. <i>Get1</i> retrieves + <i>n</i> bytes of data beginning at <i>addr</i> into <i>buf</i>. <i>Get2</i>, <i>get4</i> and <i>get8</i> + retrieve 16-bit, 32-bit and 64-bit values respectively, into the + location pointed to by <i>u</i>. The value is byte-swapped if the source + byte order differs from that of the current architecture. This + implies that the value returned by <i>get2</i>, <i>get4</i>, and <i>get8</i> may not + be the same as the byte sequences returned by <i>get1</i> when <i>n</i> is two, + four or eight; the former may be byte-swapped, the latter reflects + the byte order of the target architecture. These functions + return the number of bytes read or a –1 when there is an error. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Put1</i>, <i>put2</i>, <i>put4</i>, and <i>put8</i> write to the address space associated + with <i>map</i>. The address is translated using the map parameters and + multi-byte quantities are byte-swapped, if necessary, before they + are written. <i>Put1</i> transfers <i>n</i> bytes stored at <i>buf</i>; <i>put2</i>, <i>put4</i>, + and <i>put8</i> write the 16-bit, 32-bit or 64-bit quantity + contained in <i>val</i>, respectively. The number of bytes transferred + is returned. A –1 return value indicates an error. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + When representing core files or running programs, maps also provide + access to the register set. <i>Rget</i> and <i>rput</i> read or write the register + named by <i>reg</i>. If the register is smaller than a <tt><font size=+1>ulong</font></tt>, the high + bits are ignored. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Fpformat</i> converts the contents of a floating-point register to + a string. <i>Buf</i> is the address of a buffer of <i>n</i> bytes to hold the + resulting string. <i>Code</i> must be either <tt><font size=+1>F</font></tt> or <tt><font size=+1>f</font></tt>, selecting double + or single precision, respectively. If <i>code</i> is <tt><font size=+1>F</font></tt>, the contents + of the specified register and the following register are interpreted + as a + double-precision floating-point number; this is meaningful only + for architectures that implement double-precision floats by combining + adjacent single-precision registers. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + A <i>location</i> represents a place in an executing image capable of + storing a value. Note that locations are typically passed by value + rather than by reference. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Locnone</i> returns an unreadable, unwritable location. <i>Locaddr</i> returns + a location representing the memory address <i>addr</i>. <i>Locreg</i> returns + a location representing the register <i>reg</i>. <i>Locindir</i> returns an + location representing the memory address at <i>offset</i> added to the + value of <i>reg</i>. <i>Locconst</i> returns an imaginary unwritable + location holding the constant <i>con</i>; such locations are useful for + passing specific constants to functions expect locations, such + as <i>unwind</i> (see <a href="../man3/mach-stack.html"><i>mach-stack</i>(3)</a>). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Loccmp</i> compares two locations, returning negative, zero, or positive + values if <tt><font size=+1>*a</font></tt> is less than, equal to, or greater than <tt><font size=+1>*b</font></tt>, respectively. + Register locations are ordered before memory addresses, which + are ordered before indirections. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Locfmt</i> is a <a href="../man3/print.html"><i>print</i>(3)</a>-verb that formats a <tt><font size=+1>Loc</font></tt> structure (<i>not</i> a + pointer to one). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Indirection locations are needed in some contexts (e.g., when + using <i>findlsym</i> (see <a href="../man3/mach-symbol.html"><i>mach-symbol</i>(3)</a>)), but bothersome in most. + <i>Locsimplify</i> rewrites indirections as absolute memory addresses, + by evaluating the register using the given map and adding the + offset. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The functions <i>lget1</i>, <i>lget2</i>, <i>lget4</i>, <i>lget8</i>, <i>lput1</i>, <i>lput2</i>, <i>lput4</i>, + and <i>lput8</i> read and write the given locations, using the <i>get</i>, <i>put</i>, + <i>rget</i>, and <i>rput</i> function families as necessary.<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/libmach<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/mach.html"><i>mach</i>(3)</a>, <a href="../man3/mach-file.html"><i>mach-file</i>(3)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + These routines set <i>errstr</i>.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + This man page needs to describe <tt><font size=+1>Regs</font></tt> and <tt><font size=+1>Regdesc<br> + </font></tt> +</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> diff --git a/man/man3/mach-stack.html b/man/man3/mach-stack.html new file mode 100644 index 00000000..d08258bd --- /dev/null +++ b/man/man3/mach-stack.html @@ -0,0 +1,232 @@ +<head> +<title>mach-stack(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>MACH-STACK(3)</b><td align=right><b>MACH-STACK(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> + + stacktrace, localaddr, unwindframe, windindex, windreglocs – stack + traces<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 <mach.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + int stacktrace(Map *map, Rgetter rget, Tracer trace) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + int localaddr(Map *map, Regs *regs, char *fn, char *val, ulong + *val) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + int unwindframe(Map *map, Regs *regs, ulong *next, Symbol *sym) + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + int windindex(char *regname) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Loc* windreglocs(void)<br> + +</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> + + <i>Stacktrace</i> provides machine-independent implementations of process + stack traces. They must retrieve data and register contents from + an executing image. Sometimes the desired registers are not the + current registers but rather a set of saved registers stored elsewhere + in memory. The caller may specify an initial + register set in the form of an <i>Rgetter</i> function, of the form + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>ulong rget(Map *map, char *name)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + It returns the contents of a register when given a map and a register + name. It is usually sufficient for the register function to return + meaningful values only for <tt><font size=+1>SP</font></tt> and <tt><font size=+1>PC</font></tt>, and for the link register + (usually <tt><font size=+1>LR</font></tt>) on CISC machines. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Given the map and the rgetter, <i>stacktrace</i> unwinds the stack starting + at the innermost function. At each level in the trace, it calls + the tracer function, which has the form + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>int trace(Map *map, ulong pc, ulong callerpc,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Rgetter rget, Symbol *s)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + The tracer is passed the map, the current program counter, the + program counter of the caller (zero if the caller is unknown), + a new <i>rget</i> function, and a symbol (see <a href="../man3/mach-symbol.html"><i>mach-symbol</i>(3)</a>) describing + the current function (nil if no symbol is known). The value returned + by the tracer controls whether the stack trace continues: a + zero or negative return value stops the trace, while a positive + return value continues it. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The rgetter passed to the tracer is not the rgetter passed to + <tt><font size=+1>stacktrace</font></tt> itself. Instead, it is a function returning the register + values at the time of the call, to the extent that they can be + reconstructed. The most common use for this rgetter is as an argument + to <i>lget4</i>, etc., when evaluating the locations of local + variables. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Localaddr</i> uses <i>stacktrace</i> to walk up the stack looking for the + innermost instance of a function named <i>fn ;</i> once it finds the + function, it looks for the parameter or local variable <i>var</i>, storing + the address of the variable in <i>val</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Unwindframe</i> is the low-level function on which <i>stacktrace</i> is built. + Given the current memory image in <i>map</i> and the current register + set in <i>regs , unwindframe</i> fills in <i>next</i> with the values of the + register set at the time of the call to the function in the current + program counter. <i>Sym</i> should be the symbol corresponding to + the current function, if available. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The <i>next</i> array holds only the <i>winding registers</i>, typically the + caller-save registers and the program counter and stack pointer. + The order of registers in the array is called the <i>winding order</i>. + The winding set can be found in the array <i>mach</i><tt><font size=+1>−></font></tt><i>windreg</i>, which + has <i>mach</i><tt><font size=+1>−></font></tt><i>nwindreg</i> entries. <i>Windindex</i> returns the index of + the named register in the winding order. <i>Windreglocs</i> returns an + array of <i>Loc</i> structures corresponding to the winding registers, + in the winding order.<br> + +</table> +<p><font size=+1><b>EXAMPLE </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The following code writes a simple stack trace to standard output, + stopping after at most 20 stack frames.<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + static int<br> + trace(Map *map, ulong pc, ulong callerpc,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Rgetter rget, Symbol *s, int depth)<br> + + </table> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + char buf[512];<br> + int i, first;<br> + u32int v;<br> + Symbol s2;<br> + if(sym)<br> + print("%s+%lx", s->name, pc - loceval(s->loc));<br> + else<br> + print("%lux", pc);<br> + print("(");<br> + first = 0;<br> + for(i=0; indexlsym(s, &i, &s2)>=0; i++){<br> + if(s.class != CPARAM)<br> + continue;<br> + if(first++)<br> + print(", ");<br> + if(lget4(map, rget, s->loc, &v) >= 0)<br> + print("%s=%#lux", s->name, (ulong)v);<br> + else<br> + print("%s=???", s->name);<br> + }<br> + print(") called from ");<br> + symoff(buf, sizeof buf, callerpc, CTEXT);<br> + print("%s\n", buf);<br> + return depth < 20;<br> + + </table> + }<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + if(stacktrace(map, nil, trace) <= 0)<br> + print("no stack frame0);<br> + + </table> + + </table> + +</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/libmach<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/mach.html"><i>mach</i>(3)</a><br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Need to talk about Regs<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> diff --git a/man/man3/mach-swap.html b/man/man3/mach-swap.html new file mode 100644 index 00000000..5eefd9d6 --- /dev/null +++ b/man/man3/mach-swap.html @@ -0,0 +1,124 @@ +<head> +<title>mach-swap(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>MACH-SWAP(3)</b><td align=right><b>MACH-SWAP(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> + + beswap2, beswap4, beswap8, beieeeftoa32, beieeeftoa64, beieeeftoa80, + beload2, beload4, beload8, leswap2, leswap4, leswap8, leieeeftoa32, + leieeeftoa64, leieeeftoa80, leload2, leload4, leload8, ieeeftoa32, + ieeeftoa64 – machine-independent access to byte-ordered data<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 <mach.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>u16int beswap2(u16int u)<br> + </font></tt>u32int beswap4(u32int u)<br> + u64int beswap8(u64int u) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>int beieeeftoa32(char *a, uint n, void *f)<br> + </font></tt>int beieeeftoa64(char *a, uint n, void *f)<br> + int beieeeftoa80(char *a, uint n, void *f) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>u16int beload2(uchar *p)<br> + </font></tt>u32int beload4(uchar *p)<br> + u64int beload8(uchar *p) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>u16int leswap2(u16int u)<br> + </font></tt>u32int leswap4(u32int u)<br> + u64int leswap8(u64int u) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>int leieeeftoa32(char *a, uint n, void *f)<br> + </font></tt>int leieeeftoa64(char *a, uint n, void *f)<br> + int leieeeftoa80(char *a, uint n, void *f) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>u16int leload2(uchar *p)<br> + </font></tt>u32int leload4(uchar *p)<br> + u64int leload8(uchar *p) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>int ieeeftoa32(char *a, uint n, u32int u)<br> + </font></tt>int ieeeftoa64(char *a, uint n, u32int hi, u32int lo)<br> + +</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 functions provide machine-independent access to data in + a particular byte order. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Beswap2</i>, <i>beswap4</i>, and <i>beswap8</i> return the 2-byte, 4-byte, and 8-byte + big-endian representation of the bytes in <i>val</i>, respectively. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Beload2</i>, <i>beload4</i>, and <i>beload8</i> return the 2-byte, 4-byte, and 8-byte + big-endian interpretation of the bytes at <i>p</i>, respectively. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Beieeeftoa32</i>, <i>beieeeftoa64</i>, and <i>beieeeftoa80</i> format the big-endian + 4-byte, 8-byte, or 10-byte IEEE floating-point value at <i>f</i> into + the <i>n</i>-byte string buffer <i>a</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Leswap2</i>, <i>leswap4</i>, etc. are the little-endian equivalents of the + routines just described. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Ieeeftoa32</i> and <i>ieeeftoa64</i> format a local machine byte-order floating-point + value into the <i>n</i>-byte string buffer <i>a</i>. <i>Ieeeftoa32</i> expects a 32-bit + floating-point value stored in the bits of <i>u</i>. <i>Ieeeftoa64</i> expects + a 64-bit floating-point value whose high 32-bits are in <i>hi</i> and + low 32-bits are in <i>lo</i>. + +</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/libmach<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/mach.html"><i>mach</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> diff --git a/man/man3/mach-symbol.html b/man/man3/mach-symbol.html new file mode 100644 index 00000000..246d51b4 --- /dev/null +++ b/man/man3/mach-symbol.html @@ -0,0 +1,272 @@ +<head> +<title>mach-symbol(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>MACH-SYMBOL(3)</b><td align=right><b>MACH-SYMBOL(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> + + symopen, symclose, findhdr, indexsym, lookupsym, findsym, findexsym, + flookupsym, ffindsym, lookuplsym, indexlsym, findlsym, symoff, + pc2file, file2pc, line2pc, fnbound, fileline, pc2line – symbol + table access functions<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 <mach.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + int symopen(Fhdr *hdr)<br> + void symclose(Fhdr *hdr)<br> + Fhdr *findhdr(char *name)<br> + extern Fhdr* fhdrlist; + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + int indexsym(uint n, Symbol *s)<br> + int lookupsym(char *fn, char *var, Symbol *s)<br> + int findsym(Loc loc, uint class, Symbol *s) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + int findexsym(Fhdr *hdr, uint n, Symbol *s)<br> + Symbol *flookupsym(Fhdr *hdr, char *name)<br> + Symbol *ffindsym(Fhdr *hdr, Loc loc, uint class) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + int indexlsym(Symbol *s1, uint n, Symbol *s2)<br> + int lookuplsym(Symbol *s1, char *name, Symbol *s2)<br> + int findlsym(Symbol *s1, Loc loc, Symbol *s2) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + int symoff(char *a, uint n, ulong addr, uint class) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + int pc2file(ulong pc, char *file, uint n, ulong *line)<br> + int pc2line(ulong pc, ulong *line)<br> + int fileline(ulong pc, char *buf, uint n)<br> + int file2pc(char *file, ulong line, ulong *pc)<br> + int line2pc(ulong basepc, ulong line, ulong *pc)<br> + int fnbound(ulong pc, ulong bounds[2])<br> + +</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 functions provide machine-independent access to the symbol + table of an executable file or executing process. <a href="../man3/Mach.html"><i>Mach</i>(3)</a>, <a href="../man3/mach-file.html"><i>mach-file</i>(3)</a>, + and <a href="../man3/mach-map.html"><i>mach-map</i>(3)</a> describe additional library functions for accessing + executable files and executing processes. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Symopen</i> uses the data in the <tt><font size=+1>Fhdr</font></tt> structure filled by <i>crackhdr</i> + (see <a href="../man3/mach-file.html"><i>mach-file</i>(3)</a>) to initialize in-memory structures used to + access the symbol tables contained in the file. <i>Symclose</i> frees + the structures. The rest of the functions described here access + a composite symbol table made up of all currently open tables. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The set of all currently open <tt><font size=+1>Fhdr</font></tt>s is maintained as a linked + list starting at <i>fhdrlist</i> (chained via <tt><font size=+1>Fhdr.next</font></tt>). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Findhdr</i> searches the currently open <tt><font size=+1>Fhdr</font></tt>s for one whose file name + ends with the path <i>name</i> (that is, <tt><font size=+1>libc.so</font></tt> matches <tt><font size=+1>/usr/lib/libc.so</font></tt> + but not <tt><font size=+1>mylibc.so</font></tt>). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The <tt><font size=+1>Symbol</font></tt> data structure:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + typedef struct Symbol Symbol;<br> + struct Symbol<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + char *name;<br> + Loc loc;<br> + Loc hiloc;<br> + char class;<br> + char type;<br> + <i>...<br> + </i> + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + describes a symbol table entry. The <tt><font size=+1>value</font></tt> field contains the offset + of the symbol within its address space: global variables relative + to the beginning of the data segment, text beyond the start of + the text segment, and automatic variables and parameters relative + to the stack frame. The <tt><font size=+1>type</font></tt> field contains the type of + the symbol:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>T</font></tt> text segment symbol<br> + <tt><font size=+1>t</font></tt> static text segment symbol<br> + <tt><font size=+1>D</font></tt> data segment symbol<br> + <tt><font size=+1>d</font></tt> static data segment symbol<br> + <tt><font size=+1>B</font></tt> bss segment symbol<br> + <tt><font size=+1>b</font></tt> static bss segment symbol<br> + <tt><font size=+1>a</font></tt> automatic (local) variable symbol<br> + <tt><font size=+1>p</font></tt> function parameter symbol<br> + <tt><font size=+1>U</font></tt> undefined symbol<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + The <tt><font size=+1>class</font></tt> field assigns the symbol to a general class; <tt><font size=+1>CTEXT</font></tt>, + <tt><font size=+1>CDATA</font></tt>, <tt><font size=+1>CAUTO</font></tt>, and <tt><font size=+1>CPARAM</font></tt> are the most popular. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Indexsym</i> stores information for the <i>n th</i> symbol into <i>s</i>. The symbols + are ordered by increasing address. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Lookupsym</i> fills a <tt><font size=+1>Symbol</font></tt> structure with symbol table information. + Global variables and functions are represented by a single name; + local variables and parameters are uniquely specified by a function + and variable name pair. Arguments <i>fn</i> and <i>var</i> contain the name + of a function and variable, respectively. If both are + non-zero, the symbol table is searched for a parameter or automatic + variable. If only <i>var</i> is zero, the text symbol table is searched + for function <i>fn</i>. If only <i>fn</i> is zero, the global variable table + is searched for <i>var</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Findsym</i> returns the symbol table entry of type <i>class</i> stored near + <i>addr</i>. The selected symbol is a global variable or function with + address nearest to and less than or equal to <i>addr</i>. Class specification + <tt><font size=+1>CDATA</font></tt> searches only the global variable symbol table; class <tt><font size=+1>CTEXT</font></tt> + limits the search to the text symbol table. Class + specification <tt><font size=+1>CANY</font></tt> searches the text table first, then the global + table. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Findexsym</i>, <i>flookupsym</i>, and <i>ffindsym</i> are similar to <i>indexsym</i>, <i>lookupsym</i>, + and <i>findsym</i>, but operate only on the symbols from <i>hdr</i>. <i>Flookupsym</i> + and <i>ffindsym</i> return pointers to data stored in the <i>hdr</i>, which + must not be modified or freed. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Indexlsym</i>, <i>lookuplsym</i>, and <i>findlsym</i> are similar to <i>indexsym</i>, <i>lookupsym</i>, + and <i>findsym</i>, but operate on the smaller symbol table of parameters + and variables local to the function represented by symbol <i>s1</i>. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Indexlsym</i> writes symbol information for the <i>n</i>th local symbol of + function <i>s1</i> to <i>s2</i>. Function parameters appear first in the ordering, + followed by local symbols. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Lookuplsym</i> writes symbol information for the symbol named <i>name</i> + in function <i>s1</i> to <i>s2</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Findlsym</i> searches for a symbol local to the function <i>s1</i> whose + location is exactly <i>loc</i>, writing its symbol information to <i>s2</i>. + <i>Loc</i> is almost always an indirection through a frame pointer register; + the details vary from architecture to architecture. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Symoff</i> converts a location to a symbol reference. The string containing + that reference is of the form ‘name+offset’, where ‘name’ is the + name of the nearest symbol with an address less than or equal + to the target address, and ‘offset’ is the hexadecimal offset + beyond that symbol. If ‘offset’ is zero, only the name of the + symbol is printed. If no symbol is found within 4096 bytes of + the address, the address is formatted as a hexadecimal address. + <i>Buf</i> is the address of a buffer of <i>n</i> bytes to receive the formatted + string. <i>Addr</i> is the address to be converted. <i>Type</i> is the type + code of the search space: <tt><font size=+1>CTEXT</font></tt>, <tt><font size=+1>CDATA</font></tt>, or <tt><font size=+1>CANY</font></tt>. <i>Symoff + </i>returns the length of the formatted string contained in <i>buf</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Pc2file</i> searches the symbol table to find the file and line number + corresponding to the instruction at program counter <i>pc</i>. <i>File</i> is + the address of a buffer of <i>n</i> bytes to receive the file name. <i>Line</i> + receives the line number. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Pc2line</i> is like <i>pc2file</i> but neglects to return information about + the source file. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Fileline</i> is also like <i>pc2file</i>, but returns the file and line number + in the <i>n</i>-byte text buffer <i>buf</i>, formatted as ‘file:line’. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>File2pc</i> performs the opposite mapping: it stores in <i>pc</i> a text + address associated with line <i>line</i> in file <i>file</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Line2pc</i> is similar: it converts a line number to an instruction + address, storing it in <i>pc</i>. Since a line number does not uniquely + identify an instruction (e.g., every source file has line 1), + <i>basepc</i> specifies a text address from which the search begins. + Usually this is the address of the first function in the file + of interest. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Fnbound</i> returns the start and end addresses of the function containing + the text address supplied as the first argument. The second argument + is an array of two unsigned longs; <i>fnbound</i> places the bounding + addresses of the function in the first and second elements of + this array. The start address is the address of the + first instruction of the function; the end address is the first + address beyond the end of the target function. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + All functions return 0 on success and –1 on error. When an error + occurs, a message describing it is stored in the system error + buffer where it is available via <i>errstr</i>.<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/libmach<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/mach.html"><i>mach</i>(3)</a>, <a href="../man3/mach-file.html"><i>mach-file</i>(3)</a>, <a href="../man3/mach-map.html"><i>mach-map</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> diff --git a/man/man3/mach.html b/man/man3/mach.html new file mode 100644 index 00000000..d69e5929 --- /dev/null +++ b/man/man3/mach.html @@ -0,0 +1,123 @@ +<head> +<title>mach(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>MACH(3)</b><td align=right><b>MACH(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> + + machbytype, machbyname – machine-independent access to executables + and programs<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 <mach.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>void machbytype(int type) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int machbyname(char *name) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>extern Mach *mach;<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> + + <i>Libmach</i> provides an interface for accessing the executable files + and executing images of various architectures and operating systems. + The interface is machine-independent, meaning that, for example, + Mac OS X core dumps may be inspected using an x86 Linux machine + and vice versa. In its current form, the library is + mainly useful for writing debuggers of one sort or another. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + An architecture is described primarily by a <tt><font size=+1>Mach</font></tt> structure, which + contains data structures and parameters describing the particular + architecture. Most library functions assume that the global variable + <i>mach</i> points at the structure for the architecture being debugged. + It is set implicitly by <i>crackhdr</i> (see <a href="../man3/mach-file.html"><i>mach-file</i>(3)</a>) and + can be set explicitly by calling <i>machbyname</i> or <i>machbytype</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + There is no operating system-specific structure akin to <i>mach</i>. + Typically the choice of operating system on a particular architecture + affects only the executable and core dump formats; the various + file parsers deduce the operating system from information in the + binary files themselves and adjust accordingly. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The supported architectures are <tt><font size=+1>386</font></tt> (Intel 32-bit x86) 386 and + later) and <tt><font size=+1>power</font></tt> (IBM PowerPC, typically running Mac OS X). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Other manual pages describe the library functions in detail. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <a href="../man3/Mach-cmd.html"><i>Mach-cmd</i>(3)</a> describes some convenience routines for attaching + to processes and core files. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <a href="../man3/Mach-file.html"><i>Mach-file</i>(3)</a> describes the manipulation of binary files. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <a href="../man3/Mach-map.html"><i>Mach-map</i>(3)</a> describes the interface to address spaces and register + sets in executable files and executing programs. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <a href="../man3/Mach-stack.html"><i>Mach-stack</i>(3)</a> describes support for unwinding the stack. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <a href="../man3/Mach-swap.html"><i>Mach-swap</i>(3)</a> describes helper functions for accessing data in + a particular byte order. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <a href="../man3/Mach-symbol.html"><i>Mach-symbol</i>(3)</a> describes the interface to debugging symbol information.<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/libmach<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/mach-file.html"><i>mach-file</i>(3)</a>, <a href="../man3/mach-map.html"><i>mach-map</i>(3)</a>, <a href="../man3/mach-stack.html"><i>mach-stack</i>(3)</a>, <a href="../man3/mach-swap.html"><i>mach-swap</i>(3)</a>, <a href="../man3/mach-symbol.html"><i>mach-symbol</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> diff --git a/man/man3/malloc.html b/man/man3/malloc.html new file mode 100644 index 00000000..9c30c293 --- /dev/null +++ b/man/man3/malloc.html @@ -0,0 +1,181 @@ +<head> +<title>malloc(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>MALLOC(3)</b><td align=right><b>MALLOC(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> + + malloc, mallocz, free, realloc, calloc, setmalloctag, setrealloctag, + getmalloctag, getrealloctag – memory allocator<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void* malloc(ulong size) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void* mallocz(ulong size, int clr) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void free(void *ptr) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void* realloc(void *ptr, ulong size) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void* calloc(ulong nelem, ulong elsize) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void setmalloctag(void *ptr, ulong tag) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ulong getmalloctag(void *ptr) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void setrealloctag(void *ptr, ulong tag) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ulong getrealloctag(void *ptr)<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> + + <i>Malloc</i> and <i>free</i> provide a simple memory allocation package. <i>Malloc</i> + returns a pointer to a new block of at least <i>size</i> bytes. The block + is suitably aligned for storage of any type of object. No two + active pointers from <i>malloc</i> will have the same value. The call + <tt><font size=+1>malloc(0)</font></tt> returns a valid pointer rather than null. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The argument to <i>free</i> is a pointer to a block previously allocated + by <i>malloc</i>; this space is made available for further allocation. + It is legal to free a null pointer; the effect is a no-op. The + contents of the space returned by <i>malloc</i> are undefined. <i>Mallocz</i> + behaves as <i>malloc</i>, except that if <i>clr</i> is non-zero, the memory + returned will be zeroed. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Realloc</i> changes the size of the block pointed to by <i>ptr</i> to <i>size</i> + bytes and returns a pointer to the (possibly moved) block. The + contents will be unchanged up to the lesser of the new and old + sizes. <i>Realloc</i> takes on special meanings when one or both arguments + are zero:<br> + <tt><font size=+1>realloc(0, size)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + means <tt><font size=+1>malloc(size)</font></tt>; returns a pointer to the newly-allocated memory<br> + + </table> + <tt><font size=+1>realloc(ptr, 0)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + means <tt><font size=+1>free(ptr)</font></tt>; returns null<br> + + </table> + <tt><font size=+1>realloc(0, 0)<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + no-op; returns null + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + <i>Calloc</i> allocates space for an array of <i>nelem</i> elements of size + <i>elsize</i>. The space is initialized to zeros. <i>Free</i> frees such a block. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The memory allocator on Plan 9 maintains two word-sized fields + associated with each block, the “malloc tag” and the “realloc + tag”. By convention, the malloc tag is the PC that allocated the + block, and the realloc tag the PC that last reallocated the block. + These may be set or examined with <i>setmalloctag</i>, <i>getmalloctag</i>, + <i>setrealloctag</i>, and <i>getrealloctag</i>. When allocating blocks directly + with <i>malloc</i> and <i>realloc</i>, these tags will be set properly. If a + custom allocator wrapper is used, the allocator wrapper can set + the tags itself (usually by passing the result of <a href="../man3/getcallerpc.html"><i>getcallerpc</i>(3)</a> + to <i>setmalloctag</i>) to provide more useful information about the + source + of allocation.<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/lib9/malloc.c<br> + /usr/local/plan9/src/lib9/malloctag.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> + + <i>trump</i> (in <a href="../man1/acid.html"><i>acid</i>(1)</a>), <a href="../man3/getcallerpc.html"><i>getcallerpc</i>(3)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Malloc, realloc</i> and <i>calloc</i> return 0 if there is no available memory. + <i>Errstr</i> is likely to be set. If the allocated blocks have no malloc + or realloc tags, <i>getmalloctag</i> and <i>getrealloctag</i> return <tt><font size=+1>~0</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The <i>trump</i> library for <i>acid</i> can be used to obtain traces of malloc + execution; see <a href="../man1/acid.html"><i>acid</i>(1)</a>.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The different specification of <i>calloc</i> is bizarre. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + User errors can corrupt the storage arena. The most common gaffes + are (1) freeing an already freed block, (2) storing beyond the + bounds of an allocated block, and (3) freeing data that was not + obtained from the allocator. When <i>malloc</i> and <i>free</i> detect such + corruption, they abort. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + To avoid name conflicts with the system versions of these functions, + <i>malloc</i>, <i>realloc</i>, <i>calloc</i>, and <i>free</i> are preprocessor macros defined + as <i>p9malloc</i>, <i>p9realloc</i>, <i>p9calloc</i>, and <i>p9free</i>; see <a href="../man3/intro.html"><i>intro</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> diff --git a/man/man3/matrix.html b/man/man3/matrix.html new file mode 100644 index 00000000..ad72d10a --- /dev/null +++ b/man/man3/matrix.html @@ -0,0 +1,263 @@ +<head> +<title>matrix(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>MATRIX(3)</b><td align=right><b>MATRIX(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> + + ident, matmul, matmulr, determinant, adjoint, invertmat, xformpoint, + xformpointd, xformplane, pushmat, popmat, rot, qrot, scale, move, + xform, ixform, persp, look, viewport – Geometric transformations<br> + +</table> +<p><font size=+1><b>SYNOPSIS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>#include <draw.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include <geometry.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void ident(Matrix m) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void matmul(Matrix a, Matrix b) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void matmulr(Matrix a, Matrix b) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>double determinant(Matrix m) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void adjoint(Matrix m, Matrix madj) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>double invertmat(Matrix m, Matrix inv) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point3 xformpoint(Point3 p, Space *to, Space *from) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point3 xformpointd(Point3 p, Space *to, Space *from) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point3 xformplane(Point3 p, Space *to, Space *from) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Space *pushmat(Space *t) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Space *popmat(Space *t) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void rot(Space *t, double theta, int axis) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void qrot(Space *t, Quaternion q) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void scale(Space *t, double x, double y, double z) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void move(Space *t, double x, double y, double z) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void xform(Space *t, Matrix m) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void ixform(Space *t, Matrix m, Matrix inv) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int persp(Space *t, double fov, double n, double f) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void look(Space *t, Point3 eye, Point3 look, Point3 up) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void viewport(Space *t, Rectangle r, double aspect)<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 routines manipulate 3-space affine and projective transformations, + represented as 4×4 matrices, thus:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef double Matrix[4][4];<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + <i>Ident</i> stores an identity matrix in its argument. <i>Matmul</i> stores + <i>a×b</i> in <i>a</i>. <i>Matmulr</i> stores <i>b×a</i> in <i>b</i>. <i>Determinant</i> returns the determinant + of matrix <i>m</i>. <i>Adjoint</i> stores the adjoint (matrix of cofactors) + of <i>m</i> in <i>madj</i>. <i>Invertmat</i> stores the inverse of matrix <i>m</i> in <i>minv</i>, + returning <i>m</i>’s determinant. Should <i>m</i> be singular + (determinant zero), <i>invertmat</i> stores its adjoint in <i>minv</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The rest of the routines described here manipulate <i>Spaces</i> and + transform <i>Point3s</i>. A <i>Point3</i> is a point in three-space, represented + by its homogeneous coordinates:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef struct Point3 Point3;<br> + struct Point3{<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + double x, y, z, w;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + The homogeneous coordinates (<i>x</i>, <i>y</i>, <i>z</i>, <i>w</i>) represent the Euclidean + point (<i>x</i>/<i>w</i>, <i>y</i>/<i>w</i>, <i>z</i>/<i>w</i>) if <i>w</i>!=0, and a “point at infinity” if <i>w</i>=0. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + A <i>Space</i> is just a data structure describing a coordinate system:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef struct Space Space;<br> + struct Space{<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Matrix t;<br> + Matrix tinv;<br> + Space *next;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + It contains a pair of transformation matrices and a pointer to + the <i>Space</i>’s parent. The matrices transform points to and from + the “root coordinate system,” which is represented by a null <i>Space</i> + pointer. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Pushmat</i> creates a new <i>Space</i>. Its argument is a pointer to the + parent space. Its result is a newly allocated copy of the parent, + but with its <tt><font size=+1>next</font></tt> pointer pointing at the parent. <i>Popmat</i> discards + the <tt><font size=+1>Space</font></tt> that is its argument, returning a pointer to the stack. + Nominally, these two functions define a stack of + transformations, but <tt><font size=+1>pushmat</font></tt> can be called multiple times on the + same <tt><font size=+1>Space</font></tt> multiple times, creating a transformation tree. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Xformpoint</i> and <i>Xformpointd</i> both transform points from the <tt><font size=+1>Space</font></tt> + pointed to by <i>from</i> to the space pointed to by <i>to</i>. Either pointer + may be null, indicating the root coordinate system. The difference + between the two functions is that <tt><font size=+1>xformpointd</font></tt> divides <i>x</i>, <i>y</i>, <i>z</i>, + and <i>w</i> by <i>w</i>, if <i>w</i>!=0, making (<i>x</i>, <i>y</i>, <i>z</i>) the Euclidean + coordinates of the point. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Xformplane</i> transforms planes or normal vectors. A plane is specified + by the coefficients (<i>a</i>, <i>b</i>, <i>c</i>, <i>d</i>) of its implicit equation <i>ax+by+cz+d</i>=0. + Since this representation is dual to the homogeneous representation + of points, <tt><font size=+1>libgeometry</font></tt> represents planes by <tt><font size=+1>Point3</font></tt> structures, + with (<i>a</i>, <i>b</i>, <i>c</i>, <i>d</i>) stored in (<i>x</i>, <i>y</i>, <i>z</i>, <i>w</i>). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The remaining functions transform the coordinate system represented + by a <tt><font size=+1>Space</font></tt>. Their <tt><font size=+1>Space *</font></tt> argument must be non-null -- you can’t + modify the root <tt><font size=+1>Space</font></tt>. <i>Rot</i> rotates by angle <i>theta</i> (in radians) + about the given <i>axis</i>, which must be one of <tt><font size=+1>XAXIS</font></tt>, <tt><font size=+1>YAXIS</font></tt> or <tt><font size=+1>ZAXIS</font></tt>. + <i>Qrot</i> transforms by a rotation about an + arbitrary axis, specified by <tt><font size=+1>Quaternion</font></tt> <i>q</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Scale</i> scales the coordinate system by the given scale factors + in the directions of the three axes. <i>Move</i> translates by the given + displacement in the three axial directions. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Xform</i> transforms the coordinate system by the given <tt><font size=+1>Matrix</font></tt>. If + the matrix’s inverse is known <i>a priori</i>, calling <i>ixform</i> will save + the work of recomputing it. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Persp</i> does a perspective transformation. The transformation maps + the frustum with apex at the origin, central axis down the positive + <i>y</i> axis, and apex angle <i>fov</i> and clipping planes <i>y</i>=<i>n</i> and <i>y</i>=<i>f</i> into + the double-unit cube. The plane <i>y</i>=<i>n</i> maps to <i>y</i>’=-1, <i>y</i>=<i>f</i> maps to + <i>y</i>’=1. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Look</i> does a view-pointing transformation. The <tt><font size=+1>eye</font></tt> point is moved + to the origin. The line through the <i>eye</i> and <i>look</i> points is aligned + with the y axis, and the plane containing the <tt><font size=+1>eye</font></tt>, <tt><font size=+1>look</font></tt> and <tt><font size=+1>up</font></tt> + points is rotated into the <i>x</i>-<i>y</i> plane. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Viewport</i> maps the unit-cube window into the given screen viewport. + The viewport rectangle <i>r</i> has <i>r</i><tt><font size=+1>.min</font></tt> at the top left-hand corner, + and <i>r</i><tt><font size=+1>.max</font></tt> just outside the lower right-hand corner. Argument <i>aspect</i> + is the aspect ratio (<i>dx</i>/<i>dy</i>) of the viewport’s pixels (not of the + whole viewport). The whole window is transformed + to fit centered inside the viewport with equal slop on either + top and bottom or left and right, depending on the viewport’s + aspect ratio. The window is viewed down the <i>y</i> axis, with <i>x</i> to + the left and <i>z</i> up. The viewport has <i>x</i> increasing to the right + and <i>y</i> increasing down. The window’s <i>y</i> coordinates are mapped, + unchanged, into the viewport’s <i>z</i> coordinates.<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/libgeometry/matrix.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/arith3.html"><i>arith3</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> diff --git a/man/man3/memdraw.html b/man/man3/memdraw.html new file mode 100644 index 00000000..57a0c96c --- /dev/null +++ b/man/man3/memdraw.html @@ -0,0 +1,466 @@ +<head> +<title>memdraw(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>MEMDRAW(3)</b><td align=right><b>MEMDRAW(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> + + Memimage, Memdata, Memdrawparam, memimageinit, wordaddr, byteaddr, + memimagemove, allocmemimage, allocmemimaged, readmemimage, creadmemimage, + writememimage, freememimage, memsetchan, loadmemimage, cloadmemimage, + unloadmemimage, memfillcolor, memarc, mempoly, memellipse, + memfillpoly, memimageline, memimagedraw, drawclip, memlinebbox, + memlineendsize, allocmemsubfont, openmemsubfont, freememsubfont, + memsubfontwidth, getmemdefont, memimagestring, iprint, hwdraw + – drawing routines for memory-resident images<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 <u.h> <br> + #include <libc.h> <br> + #include <draw.h> <br> + #include <memdraw.h> <br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>typedef struct Memdata<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + ulong *base; /* allocated data pointer */<br> + uchar *bdata; /* first byte of actual data; word−aligned */<br> + int ref; /* number of Memimages using this data */<br> + void* imref; /* last image that pointed at this */<br> + int allocd; /* is this malloc'd? */<br> + + </table> + } Memdata;<br> + enum {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Frepl = 1<<0, /* is replicated */<br> + Fsimple = 1<<1, /* is 1x1 */<br> + Fgrey = 1<<2, /* is grey */<br> + Falpha = 1<<3, /* has explicit alpha */<br> + Fcmap = 1<<4, /* has cmap channel */<br> + Fbytes = 1<<5, /* has only 8−bit channels */<br> + + </table> + };<br> + typedef struct Memimage<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Rectangle r; /* rectangle in data area, local coords */<br> + Rectangle clipr; /* clipping region */<br> + int depth; /* number of bits of storage per pixel */<br> + int nchan; /* number of channels */<br> + ulong chan; /* channel descriptions */<br> + Memdata *data; /* pointer to data */<br> + int zero; /* data−>bdata+zero==&byte containing (0,0) */<br> + ulong width; /* width in words of a single scan line */<br> + Memlayer *layer; /* nil if not a layer*/<br> + ulong flags;<br> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>...<br> + </i> + </table> + <tt><font size=+1>} Memimage;<br> + typedef struct Memdrawparam<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Memimage *dst;<br> + Rectangle r;<br> + Memimage *src;<br> + Rectangle sr;<br> + Memimage *mask;<br> + Rectangle mr;<br> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>...<br> + </i> + </table> + <tt><font size=+1>} Memdrawparam;<br> + int drawdebug;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt><i> + </i><tt><font size=+1>void memimageinit(void)<br> + ulong* wordaddr(Memimage *i, Point p)<br> + uchar* byteaddr(Memimage *i, Point p)<br> + void memimagemove(void *from, void *to)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Memimage* allocmemimage(Rectangle r, ulong chan)<br> + Memimage* allocmemimaged(Rectangle r, ulong chan, Memdata *data)<br> + Memimage* readmemimage(int fd)<br> + Memimage* creadmemimage(int fd)<br> + int writememimage(int fd, Memimage *i)<br> + void freememimage(Memimage *i)<br> + int memsetchan(Memimage*, ulong)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + int loadmemimage(Memimage *i, Rectangle r,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + uchar *buf, int nbuf)<br> + + </table> + + </table> + int cloadmemimage(Memimage *i, Rectangle r,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + uchar *buf, int nbuf)<br> + + </table> + + </table> + int unloadmemimage(Memimage *i, Rectangle r,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + uchar *buf, int nbuf)<br> + + </table> + + </table> + void memfillcolor(Memimage *i, ulong color)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + void memarc(Memimage *dst, Point c, int a, int b, int thick,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Memimage *src, Point sp, int alpha, int phi, Drawop op)<br> + + </table> + + </table> + void mempoly(Memimage *dst, Point *p, int np, int end0,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int end1, int radius, Memimage *src, Point sp, Drawop op)<br> + + </table> + + </table> + void memellipse(Memimage *dst, Point c, int a, int b,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int thick, Memimage *src, Point sp, Drawop op)<br> + + </table> + + </table> + void memfillpoly(Memimage *dst, Point *p, int np, int wind,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Memimage *src, Point sp, Drawop op)<br> + + </table> + + </table> + void memimageline(Memimage *dst, Point p0, Point p1, int end0,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int end1, int radius, Memimage *src, Point sp, Drawop op)<br> + + </table> + + </table> + void memimagedraw(Memimage *dst, Rectangle r, Memimage *src,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Point sp, Memimage *mask, Point mp, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + int drawclip(Memimage *dst, Rectangle *dr, Memimage *src,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Point *sp, Memimage *mask, Point *mp,<br> + Rectangle *sr, Rectangle *mr)<br> + + </table> + + </table> + Rectangle memlinebbox(Point p0, Point p1, int end0, int end1,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int radius)<br> + + </table> + + </table> + int memlineendsize(int end)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Memsubfont* allocmemsubfont(char *name, int n, int height,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int ascent, Fontchar *info, Memimage *i)<br> + + </table> + + </table> + Memsubfont* openmemsubfont(char *name)<br> + void freememsubfont(Memsubfont *f)<br> + Point memsubfontwidth(Memsubfont *f, char *s)<br> + Memsubfont* getmemdefont(void)<br> + Point memimagestring(Memimage *dst, Point p, Memimage *color,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Point cp, Memsubfont *f, char *cs, Drawop op)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + int iprint(char *fmt, ...)<br> + int hwdraw(Memdrawparam *param)<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> + + The <tt><font size=+1>Memimage</font></tt> type defines memory-resident rectangular pictures + and the methods to draw upon them; <tt><font size=+1>Memimage</font></tt>s differ from <tt><font size=+1>Image</font></tt>s + (see <a href="../man3/draw.html"><i>draw</i>(3)</a>) in that they are manipulated directly in user memory + rather than by RPCs to the <tt><font size=+1>/dev/draw</font></tt> hierarchy. The library is + the basis for the kernel <a href="../man3/draw.html"><i>draw</i>(3)</a> driver and also + used by a number of programs that must manipulate images without + a display. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The <tt><font size=+1>r, clipr</font></tt>, <tt><font size=+1>depth</font></tt>, <tt><font size=+1>nchan</font></tt>, and <tt><font size=+1>chan</font></tt> structure elements are identical + to the ones of the same name in the <tt><font size=+1>Image</font></tt> structure. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The <tt><font size=+1>flags</font></tt> element of the <tt><font size=+1>Memimage</font></tt> structure holds a number of + bits of information about the image. In particular, it subsumes + the purpose of the <tt><font size=+1>repl</font></tt> element of <tt><font size=+1>Image</font></tt> structures. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Memimageinit</i> initializes various static data that the library + depends on, as well as the replicated solid color images <tt><font size=+1>memopaque</font></tt>, + <tt><font size=+1>memtransparent</font></tt>, <tt><font size=+1>memblack</font></tt>, and <tt><font size=+1>memwhite</font></tt>. It should be called before + referring to any of these images and before calling any of the + other library functions. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Each <tt><font size=+1>Memimage</font></tt> points at a <tt><font size=+1>Memdata</font></tt> structure that in turn points + at the actual pixel data for the image. This allows multiple images + to be associated with the same <tt><font size=+1>Memdata</font></tt>. The first word of the + data pointed at by the <tt><font size=+1>base</font></tt> element of <tt><font size=+1>Memdata</font></tt> points back at + the <tt><font size=+1>Memdata</font></tt> structure, so that in the Plan 9 kernel, + the memory allocator (see Plan 9’s <i>pool</i>(3)) can compact image + memory using <i>memimagemove</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Because images can have different coordinate systems, the <tt><font size=+1>zero</font></tt> + element of the <tt><font size=+1>Memimage</font></tt> structure contains the offset that must + be added to the <tt><font size=+1>bdata</font></tt> element of the corresponding <tt><font size=+1>Memdata</font></tt> structure + in order to yield a pointer to the data for the pixel (0,0). Adding + <tt><font size=+1>width</font></tt> machine words to this pointer moves it + down one scan line. The <tt><font size=+1>depth</font></tt> element can be used to determine + how to move the pointer horizontally. Note that this method works + even for images whose rectangles do not include the origin, although + one should only dereference pointers corresponding to pixels within + the image rectangle. <i>Wordaddr</i> and + <i>byteaddr</i> perform these calculations, returning pointers to the + word and byte, respectively, that contain the beginning of the + data for a given pixel. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Allocmemimage</i> allocages images with a given rectangle and channel + descriptor (see <tt><font size=+1>strtochan</font></tt> in <a href="../man3/graphics.html"><i>graphics</i>(3)</a>), creating a fresh <tt><font size=+1>Memdata</font></tt> + structure and associated storage. <i>Allocmemimaged</i> is similar but + uses the supplied <i>Memdata</i> structure rather than a new one. The + <i>readmemimage</i> function reads an + uncompressed bitmap from the given file descriptor, while <i>creadmemimage</i> + reads a compressed bitmap. <i>Writememimage</i> writes a compressed representation + of <i>i</i> to file descriptor <i>fd</i>. For more on bitmap formats, see <a href="../man7/image.html"><i>image</i>(7)</a>. + <i>Freememimage</i> frees images returned by any of these routines. The + <tt><font size=+1>Memimage</font></tt> structure + contains some tables that are used to store precomputed values + depending on the channel descriptor. <i>Memsetchan</i> updates the <tt><font size=+1>chan</font></tt> + element of the structure as well as these tables, returning –1 + if passed a bad channel descriptor. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Loadmemimage</i> and <i>cloadmemimage</i> replace the pixel data for a given + rectangle of an image with the given buffer of uncompressed or + compressed data, respectively. When calling <i>cloadmemimage</i>, the + buffer must contain an integral number of compressed chunks of + data that exactly cover the rectangle. + <i>Unloadmemimage</i> retrieves the uncompressed pixel data for a given + rectangle of an image. All three return the number of bytes consumed + on success, and –1 in case of an error. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Memfillcolor</i> fills an image with the given color, a 32-bit number + as described in <a href="../man3/color.html"><i>color</i>(3)</a>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Memarc</i>, <i>mempoly</i>, <i>memellipse</i>, <i>memfillpoly</i>, <i>memimageline</i>, and <i>memimagedraw</i> + are identical to the <i>arc</i>, <i>poly</i>, <i>ellipse</i>, <i>fillpoly</i>, <i>line</i>, and <i>gendraw</i>, + routines described in <a href="../man3/draw.html"><i>draw</i>(3)</a>, except that they operate on <tt><font size=+1>Memimage</font></tt>s + rather than <tt><font size=+1>Image</font></tt>s. Similarly, <i>allocmemsubfont</i>, <i>openmemsubfont</i>, + <i>freememsubfont</i>, + <i>memsubfontwidth</i>, <i>getmemdefont</i>, and <i>memimagestring</i> are the <tt><font size=+1>Memimage</font></tt> + analogues of <i>allocsubfont</i>, <i>openfont</i>, <i>freesubfont</i>, <i>strsubfontwidth</i>, + <i>getdefont</i>, and <tt><font size=+1>string</font></tt> (see <a href="../man3/subfont.html"><i>subfont</i>(3)</a> and <a href="../man3/graphics.html"><i>graphics</i>(3)</a>), except + that they operate only on <tt><font size=+1>Memsubfont</font></tt>s rather than <tt><font size=+1>Font</font></tt>s. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Drawclip</i> takes the images involved in a draw operation, together + with the destination rectangle <tt><font size=+1>dr</font></tt> and source and mask alignment + points <tt><font size=+1>sp</font></tt> and <tt><font size=+1>mp</font></tt>, and clips them according to the clipping rectangles + of the images involved. It also fills in the rectangles <tt><font size=+1>sr</font></tt> and + <tt><font size=+1>mr</font></tt> with rectangles congruent to the returned + destination rectangle but translated so the upper left corners + are the returned <tt><font size=+1>sp</font></tt> and <tt><font size=+1>mp</font></tt>. <i>Drawclip</i> returns zero when the clipped + rectangle is empty. <i>Memlinebbox</i> returns a conservative bounding + box containing a line between two points with given end styles + and radius. <i>Memlineendsize</i> calculates the extra length + added to a line by attaching an end of a given style. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The <i>hwdraw</i> and <i>iprint</i> functions are no-op stubs that may be overridden + by clients of the library. <i>Hwdraw</i> is called at each call to <i>memimagedraw</i> + with the current request’s parameters. If it can satisfy the request, + it should do so and return 1. If it cannot satisfy the request, + it should return 0. This allows (for + instance) the kernel to take advantage of hardware acceleration. + <i>Iprint</i> should format and print its arguments; it is given much + debugging output when the global integer variable <tt><font size=+1>drawdebug</font></tt> is + non-zero. In the kernel, <i>iprint</i> prints to a serial line rather + than the screen, for obvious reasons. + +</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/libdraw<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/addpt.html"><i>addpt</i>(3)</a>, <a href="../man3/color.html"><i>color</i>(3)</a>, <a href="../man3/draw.html"><i>draw</i>(3)</a>, <a href="../man3/graphics.html"><i>graphics</i>(3)</a>, <a href="../man3/memlayer.html"><i>memlayer</i>(3)</a>, <a href="../man3/stringsize.html"><i>stringsize</i>(3)</a>, + <a href="../man3/subfont.html"><i>subfont</i>(3)</a>, <a href="../man7/color.html"><i>color</i>(7)</a>, <a href="../man7/utf.html"><i>utf</i>(7)</a><br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Memimagestring</i> is unusual in using a subfont rather than a font, + and in having no parameter to align the source. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + These functions are archived into <i>libdraw</i>.<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> diff --git a/man/man3/memlayer.html b/man/man3/memlayer.html new file mode 100644 index 00000000..c21f5bf6 --- /dev/null +++ b/man/man3/memlayer.html @@ -0,0 +1,325 @@ +<head> +<title>memlayer(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>MEMLAYER(3)</b><td align=right><b>MEMLAYER(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> + + memdraw, memlalloc, memldelete, memlexpose, memlfree, memlhide, + memline, memlnorefresh, memload, memunload, memlorigin, memlsetrefresh, + memltofront, memltofrontn, memltorear, memltorearn – windows of + memory-resident images<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 <draw.h> <br> + #include <memdraw.h> <br> + #include <memlayer.h> <br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>typedef struct Memscreen Memscreen;<br> + typedef struct Memlayer Memlayer;<br> + typedef void (*Refreshfn)(Memimage*, Rectangle, void*);<br> + struct Memscreen<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Memimage *frontmost; /* frontmost layer on screen */<br> + Memimage *rearmost; /* rearmost layer on screen */<br> + Memimage *image; /* upon which all layers are drawn */<br> + Memimage *fill; /* if non−zero, picture to use when repainting + */<br> + + </table> + };<br> + struct Memlayer<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Rectangle screenr; /* true position of layer on screen */<br> + Point delta; /* add delta to go from image coords to screen */<br> + Memscreen *screen; /* screen this layer belongs to */<br> + Memimage *front; /* window in front of this one */<br> + Memimage *rear; /* window behind this one*/<br> + int clear; /* layer is fully visible */<br> + Memimage *save; /* save area for obscured parts */<br> + Refreshfn refreshfn; /* fn to refresh obscured parts if save==nil + */<br> + void *refreshptr;/* argument to refreshfn */<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Memimage* memlalloc(Memscreen *s, Rectangle r, Refreshfn fn, void + *arg, ulong col)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void memlnorefresh(Memimage *i, Rectangle r, void *arg)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int memlsetrefresh(Memimage *i, Refreshfn fn, void *arg)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int memldelete(Memimage *i)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int memlfree(Memimage *i)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int memlexpose(Memimage *i, Rectangle r)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int memlhide(Memimage *i, Rectangle r)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void memltofront(Memimage *i)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void memltofrontn(Memimage**ia, int n)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void memltorear(Memimage *i)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void memltorearn(Memimage **ia , int n)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int memlorigin(Memimage *i, Point log, Point phys)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void memdraw(Image *dst, Rectangle r,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Image *src, Point sp, Image *mask, Point mp, Drawop op)<br> + + </table> + + </table> + int memload(Memimage *i, Rectangle r,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + uchar *buf, int n, int iscompressed) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>int memunload(Memimage *i, Rectangle r,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + uchar *buf, int n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + +</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 functions build upon the <a href="../man3/memdraw.html"><i>memdraw</i>(3)</a> interface to maintain + overlapping graphical windows on in-memory images. They are used + by the kernel to implement the windows interface presented by + <a href="../man3/draw.html"><i>draw</i>(3)</a> and <a href="../man3/window.html"><i>window</i>(3)</a> and probably have little use outside of + the kernel. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The basic function is to extend the definition of a <tt><font size=+1>Memimage</font></tt> (see + <a href="../man3/memdraw.html"><i>memdraw</i>(3)</a>) to include overlapping windows defined by the <tt><font size=+1>Memlayer</font></tt> + type. The first fields of the <tt><font size=+1>Memlayer</font></tt> structure are identical + to those in <tt><font size=+1>Memimage</font></tt>, permitting a function that expects a <tt><font size=+1>Memimage</font></tt> + to be passed a <tt><font size=+1>Memlayer</font></tt>, and vice versa. + Both structures have a <tt><font size=+1>save</font></tt> field, which is nil in a <tt><font size=+1>Memimage</font></tt> + and points to ‘backing store’ in a <tt><font size=+1>Memlayer</font></tt>. The layer routines + accept <tt><font size=+1>Memimages</font></tt> or <tt><font size=+1>Memlayers</font></tt>; if the image is a <tt><font size=+1>Memimage</font></tt> the + underlying <tt><font size=+1>Memimage</font></tt> routine is called; otherwise the layer routines + recursively subdivide the geometry, reducing the + operation into a smaller component that ultimately can be performed + on a <tt><font size=+1>Memimage</font></tt>, either the display on which the window appears, + or the backing store. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>Memlayers</font></tt> are associated with a <tt><font size=+1>Memscreen</font></tt> that holds the data + structures to maintain the windows and connects them to the associated + <tt><font size=+1>image</font></tt>. The <tt><font size=+1>fill</font></tt> color is used to paint the background when a window + is deleted. There is no function to establish a <tt><font size=+1>Memscreen</font></tt>; to + create one, allocate the memory, zero + <tt><font size=+1>frontmost</font></tt> and <tt><font size=+1>rearmost</font></tt>, set <tt><font size=+1>fill</font></tt> to a valid fill color or image, + and set <tt><font size=+1>image</font></tt> to the <tt><font size=+1>Memimage</font></tt> (or <tt><font size=+1>Memlayer</font></tt>) on which the windows + will be displayed. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Memlalloc</i> allocates a <tt><font size=+1>Memlayer</font></tt> of size <i>r</i> on <tt><font size=+1>Memscreen</font></tt> <i>s</i>. If <i>col</i> + is not <tt><font size=+1>DNofill</font></tt>, the new window will be initialized by painting + it that color. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The refresh function <i>fn</i> and associated argument <i>arg</i> will be called + by routines in the library to restore portions of the window uncovered + due to another window being deleted or this window being pulled + to the front of the stack. The function, when called, receives + a pointer to the image (window) being refreshed, the + rectangle that has been uncovered, and the <i>arg</i> recorded when the + window was created. A couple of predefined functions provide built-in + management methods: <i>memlnorefresh</i> does no backup at all, useful + for making efficient temporary windows; while a <i>nil</i> function specifies + that the backing store + (<tt><font size=+1>Memlayer.save</font></tt>) will be used to keep the obscured data. Other + functions may be provided by the client. <i>Memlsetrefresh</i> allows + one to change the function associated with the window. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Memldelete</i> deletes the window <i>i</i>, restoring the underlying display. + <i>Memlfree</i> frees the data structures without unlinking the window + from the associated <tt><font size=+1>Memscreen</font></tt> or doing any graphics. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Memlexpose</i> restores rectangle <i>r</i> within the window, using the backing + store or appropriate refresh method. <i>Memlhide</i> goes the other way, + backing up <i>r</i> so that that portion of the screen may be modified + without losing the data in this window. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Memltofront</i> pulls <i>i</i> to the front of the stack of windows, making + it fully visible. <i>Memltofrontn</i> pulls the <i>n</i> windows in the array + <i>ia</i> to the front as a group, leaving their internal order unaffected. + <i>Memltorear</i> and <i>memltorearn</i> push the windows to the rear. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Memlorigin</i> changes the coordinate systems associated with the + window <i>i</i>. The points <i>log</i> and <i>phys</i> represent the upper left corner + (<tt><font size=+1>min</font></tt>) of the window’s internal coordinate system and its physical + location on the screen. Changing <i>log</i> changes the interpretation + of coordinates within the window; for example, setting it + to (0, 0) makes the upper left corner of the window appear to + be the origin of the coordinate system, regardless of its position + on the screen. Changing <i>phys</i> changes the physical location of + the window on the screen. When a window is created, its logical + and physical coordinates are the same, so + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>memlorigin(i, i−>r.min, i−>r.min)<br> + </font></tt> + </table> + + </table> + would be a no-op. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Memdraw</i> and <i>memline</i> are implemented in the layer library but provide + the main entry points for drawing on memory-resident windows. + They have the signatures of <i>memimagedraw</i> and <i>memimageline</i> (see + <a href="../man3/memdraw.html"><i>memdraw</i>(3)</a>) but accept <tt><font size=+1>Memlayer</font></tt> or <tt><font size=+1>Memimage</font></tt> arguments both. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Memload</i> and <i>memunload</i> are similarly layer-savvy versions of <i>loadmemimage</i> + and <i>unloadmemimage</i>. The <i>iscompressed</i> flag to <i>memload</i> specifies + whether the <i>n</i> bytes of data in <i>buf</i> are in compressed image format + (see <a href="../man7/image.html"><i>image</i>(7)</a>).<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/libdraw<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/graphics.html"><i>graphics</i>(3)</a>, <a href="../man3/memdraw.html"><i>memdraw</i>(3)</a>, <a href="../man3/stringsize.html"><i>stringsize</i>(3)</a>, <a href="../man3/window.html"><i>window</i>(3)</a>, <a href="../man3/draw.html"><i>draw</i>(3)</a><br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + These functions are archived into <i>libdraw</i>.<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> diff --git a/man/man3/memory.html b/man/man3/memory.html new file mode 100644 index 00000000..a67101b7 --- /dev/null +++ b/man/man3/memory.html @@ -0,0 +1,123 @@ +<head> +<title>memory(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>MEMORY(3)</b><td align=right><b>MEMORY(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> + + memccpy, memchr, memcmp, memcpy, memmove, memset – memory operations<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void* memccpy(void *s1, void *s2, int c, long n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void* memchr(void *s, int c, long n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int memcmp(void *s1, void *s2, long n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void* memcpy(void *s1, void *s2, long n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void* memmove(void *s1, void *s2, long n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void* memset(void *s, int c, long n)<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 functions operate efficiently on memory areas (arrays of + bytes bounded by a count, not terminated by a zero byte). They + do not check for the overflow of any receiving memory area. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Memccpy</i> copies bytes from memory area <i>s2</i> into <i>s1</i>, stopping after + the first occurrence of byte <i>c</i> has been copied, or after <i>n</i> bytes + have been copied, whichever comes first. It returns a pointer + to the byte after the copy of <i>c</i> in <i>s1</i>, or zero if <i>c</i> was not found + in the first <i>n</i> bytes of <i>s2</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Memchr</i> returns a pointer to the first occurrence of byte <i>c</i> in + the first <i>n</i> bytes of memory area <i>s,</i> or zero if <i>c</i> does not occur. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Memcmp</i> compares its arguments, looking at the first <i>n</i> bytes only, + and returns an integer less than, equal to, or greater than 0, + according as <i>s1</i> is lexicographically less than, equal to, or greater + than <i>s2</i>. The comparison is bytewise unsigned. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Memcpy</i> copies <i>n</i> bytes from memory area <i>s2</i> to <i>s1</i>. It returns <i>s1</i>. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Memmove</i> works like <i>memcpy</i>, except that it is guaranteed to work + if <i>s1</i> and <i>s2</i> overlap. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Memset</i> sets the first <i>n</i> bytes in memory area <i>s</i> to the value of + byte <i>c</i>. It returns <i>s</i>.<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> + + All these routines have portable C implementations in <tt><font size=+1>/usr/local/plan9/src/lib9</font></tt>.<br> + +</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/strcat.html"><i>strcat</i>(3)</a><br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + ANSI C does not require <i>memcpy</i> to handle overlapping source and + destination; on Plan 9, it does, so <i>memmove</i> and <i>memcpy</i> behave + identically. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + If <i>memcpy</i> and <i>memmove</i> are handed a negative count, they abort.<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> diff --git a/man/man3/mouse.html b/man/man3/mouse.html new file mode 100644 index 00000000..5e2b278d --- /dev/null +++ b/man/man3/mouse.html @@ -0,0 +1,249 @@ +<head> +<title>mouse(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>MOUSE(3)</b><td align=right><b>MOUSE(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> + + initmouse, readmouse, closemouse, moveto, cursorswitch, getrect, + drawgetrect, menuhit, setcursor – mouse control<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 <draw.h><br> + #include <thread.h><br> + #include <mouse.h><br> + #include <cursor.h><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Mousectl *initmouse(char *file, Image *i)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int readmouse(Mousectl *mc)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int atomouse();<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void closemouse(Mousectl *mc)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void moveto(Mousectl *mc, Point pt)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void setcursor(Mousectl *mc, Cursor *c)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rectangle getrect(int but, Mousectl *mc)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void drawgetrect(Rectangle r, int up)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int menuhit(int but, Mousectl *mc, Menu *menu, Screen *scr)<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 functions access and control a mouse in a multi-threaded + environment. They use the message-passing <tt><font size=+1>Channel</font></tt> interface in + the threads library (see <a href="../man3/thread.html"><i>thread</i>(3)</a>); programs that wish a more + event-driven, single-threaded approach should use <a href="../man3/event.html"><i>event</i>(3)</a>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The state of the mouse is recorded in a structure, <tt><font size=+1>Mouse</font></tt>, defined + in <tt><font size=+1><mouse.h></font></tt>:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef struct Mouse Mouse;<br> + struct Mouse<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int buttons; /* bit array: LMR=124 */<br> + Point xy;<br> + ulong msec;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + The <tt><font size=+1>Point xy</font></tt> records the position of the cursor, <tt><font size=+1>buttons</font></tt> the state + of the buttons (three bits representing, from bit 0 up, the buttons + from left to right, 0 if the button is released, 1 if it is pressed), + and <tt><font size=+1>msec</font></tt>, a millisecond time stamp. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The routine <tt><font size=+1>initmouse</font></tt> returns a structure through which one may + access the mouse:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef struct Mousectl Mousectl;<br> + struct Mousectl<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Mouse;<br> + Channel *c; /* chan(Mouse)[16] */<br> + Channel *resizec; /* chan(int)[2] */<br> + char *file;<br> + int mfd; /* to mouse file */<br> + int cfd; /* to cursor file */<br> + int pid; /* of slave proc */<br> + Image* image; /* of associated window/display */<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + The arguments to <i>initmouse</i> are a <i>file</i> naming the device file connected + to the mouse and an <i>Image</i> (see <a href="../man3/draw.html"><i>draw</i>(3)</a>) on which the mouse will + be visible. Typically the file is nil, which requests the default + <tt><font size=+1>/dev/mouse</font></tt>; and the image is the window in which the program is + running, held in the variable <tt><font size=+1>screen</font></tt> after a call + to <i>initdraw</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Once the <tt><font size=+1>Mousectl</font></tt> is set up, mouse motion will be reported by + messages of type <tt><font size=+1>Mouse</font></tt> sent on the <tt><font size=+1>Channel Mousectl.c</font></tt>. Typically, + a message will be sent every time a read of <tt><font size=+1>/dev/mouse</font></tt> succeeds, + which is every time the state of the mouse changes. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + When the window is resized, a message is sent on <tt><font size=+1>Mousectl.resizec</font></tt>. + The actual value sent may be discarded; the receipt of the message + tells the program that it should call <tt><font size=+1>getwindow</font></tt> (see <a href="../man3/graphics.html"><i>graphics</i>(3)</a>) + to reconnect to the window. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Readmouse</i> updates the <tt><font size=+1>Mouse</font></tt> structure held in the <tt><font size=+1>Mousectl</font></tt>, blocking + if the state has not changed since the last <i>readmouse</i> or message + sent on the channel. It calls <tt><font size=+1>flushimage</font></tt> (see <a href="../man3/graphics.html"><i>graphics</i>(3)</a>) before + blocking, so any buffered graphics requests are displayed. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Closemouse</i> closes the file descriptors associated with the mouse, + kills the slave processes, and frees the <tt><font size=+1>Mousectl</font></tt> structure. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Moveto</i> moves the mouse cursor on the display to the position specified + by <i>pt</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Setcursor</i> sets the image of the cursor to that specified by <i>c</i>. + If <i>c</i> is nil, the cursor is set to the default. The format of the + cursor data is spelled out in <tt><font size=+1><cursor.h></font></tt> and described in <a href="../man3/graphics.html"><i>graphics</i>(3)</a>. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Getrect</i> returns the dimensions of a rectangle swept by the user, + using the mouse, in the manner <a href="../man1/rio.html"><i>rio</i>(1)</a> or <a href="../man1/sam.html"><i>sam</i>(1)</a> uses to create + a new window. The <i>but</i> argument specifies which button the user + must press to sweep the window; any other button press cancels + the action. The returned rectangle is all zeros if the user + cancels. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Getrect</i> uses successive calls to <i>drawgetrect</i> to maintain the red + rectangle showing the sweep-in-progress. The rectangle to be drawn + is specified by <i>rc</i> and the <i>up</i> parameter says whether to draw (1) + or erase (0) the rectangle. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Menuhit</i> provides a simple menu mechanism. It uses a <tt><font size=+1>Menu</font></tt> structure + defined in <tt><font size=+1><mouse.h></font></tt>:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef struct Menu Menu;<br> + struct Menu<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + char **item;<br> + char *(*gen)(int);<br> + int lasthit;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + <i>Menuhit</i> behaves the same as its namesake <i>emenuhit</i> described in + <a href="../man3/event.html"><i>event</i>(3)</a>, with two exceptions. First, it uses a <tt><font size=+1>Mousectl</font></tt> to access + the mouse rather than using the event interface; and second, it + creates the menu as a true window on the <tt><font size=+1>Screen</font></tt> <i>scr</i> (see <a href="../man3/window.html"><i>window</i>(3)</a>), + permitting the menu to be displayed in parallel + with other activities on the display. If <i>scr</i> is null, <i>menuhit</i> + behaves like <i>emenuhit</i>, creating backing store for the menu, writing + the menu directly on the display, and restoring the display when + the menu is removed. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +</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/libdraw<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/graphics.html"><i>graphics</i>(3)</a>, <a href="../man3/draw.html"><i>draw</i>(3)</a>, <a href="../man3/event.html"><i>event</i>(3)</a>, <a href="../man3/keyboard.html"><i>keyboard</i>(3)</a>, <a href="../man3/thread.html"><i>thread</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> diff --git a/man/man3/mousescrollsize.html b/man/man3/mousescrollsize.html new file mode 100644 index 00000000..3aa816fb --- /dev/null +++ b/man/man3/mousescrollsize.html @@ -0,0 +1,108 @@ +<head> +<title>mousescrollsize(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>MOUSESCROLLSIZE(3)</b><td align=right><b>MOUSESCROLLSIZE(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> + + mousescrollsize – compute mouse scroll increment<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 <draw.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + int mousescrollsize(int maxlines)<br> + +</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> + + <i>Mousescrollsize</i> computes the number of lines of text that should + be scrolled in response to a mouse scroll wheel click. <i>Maxlines</i> + is the number of lines visible in the text window. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The default scroll increment is one line. This default can be + overridden by setting the <tt><font size=+1>$mousescrollsize</font></tt> environment variable + to an integer, which specifies a constant number of lines, or + to a real number followed by a percent character, indicating that + the scroll increment should be a percentage of the total + number of lines in the window. For example, setting <tt><font size=+1>$mousescrollsize</font></tt> + to <tt><font size=+1>50%</font></tt> causes a half-window scroll increment. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Mousescrollsize</i> is used by <a href="../man1/9term.html"><i>9term</i>(1)</a> and <a href="../man1/acme.html"><i>acme</i>(1)</a> to set their scrolling + behavior.<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/libdraw/scroll.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="../man1/9term.html"><i>9term</i>(1)</a>, <a href="../man1/acme.html"><i>acme</i>(1)</a><br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Libdraw</i> expects up and down scroll wheel events to be expressed + as clicks of mouse buttons 4 and 5, but the XFree86 default is + to ignore the scroll wheel. To enable the scroll wheel, change + your <tt><font size=+1>InputDevice</font></tt> section of <tt><font size=+1>XF86Config−4</font></tt> to look like:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>Section "InputDevice"<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Identifier "Mouse0"<br> + Driver "mouse"<br> + Option "Device" "/dev/psaux"<br> + # next four lines enable scroll wheel as buttons 4 and 5<br> + Option "Buttons" "5"<br> + Option "Emulate3Buttons" "off"<br> + Option "Protocol" "ImPS/2"<br> + Option "ZAxisMapping" "4 5"<br> + + </table> + EndSection<br> + </font></tt> + </table> + +</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> diff --git a/man/man3/mp.html b/man/man3/mp.html new file mode 100644 index 00000000..86dc7455 --- /dev/null +++ b/man/man3/mp.html @@ -0,0 +1,441 @@ +<head> +<title>mp(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>MP(3)</b><td align=right><b>MP(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> + + mpsetminbits, mpnew, mpfree, mpbits, mpnorm, mpcopy, mpassign, + mprand, strtomp, mpfmt,mptoa, betomp, mptobe, letomp, mptole, + mptoui, uitomp, mptoi, itomp, uvtomp, mptouv, vtomp, mptov, mpdigdiv, + mpadd, mpsub, mpleft, mpright, mpmul, mpexp, mpmod, mpdiv, mpfactorial, + mpcmp, mpextendedgcd, + mpinvert, mpsignif, mplowbits0, mpvecdigmuladd, mpvecdigmulsub, + mpvecadd, mpvecsub, mpveccmp, mpvecmul, mpmagcmp, mpmagadd, mpmagsub, + crtpre, crtin, crtout, crtprefree, crtresfree – extended precision + arithmetic<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 <mp.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>mpint* mpnew(int n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void mpfree(mpint *b) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void mpsetminbits(int n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void mpbits(mpint *b, int n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void mpnorm(mpint *b) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>mpint* mpcopy(mpint *b) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void mpassign(mpint *old, mpint *new) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>mpint* mprand(int bits, void (*gen)(uchar*, int), mpint *b) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>mpint* strtomp(char *buf, char **rptr, int base, mpint *b) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* mptoa(mpint *b, int base, char *buf, int blen) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int mpfmt(Fmt*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>mpint* betomp(uchar *buf, uint blen, mpint *b) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int mptobe(mpint *b, uchar *buf, uint blen, uchar **bufp) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>mpint* letomp(uchar *buf, uint blen, mpint *b) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int mptole(mpint *b, uchar *buf, uint blen, uchar **bufp) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>uint mptoui(mpint*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>mpint* uitomp(uint, mpint*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int mptoi(mpint*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>mpint* itomp(int, mpint*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>mpint* vtomp(vlong, mpint*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>vlong mptov(mpint*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>mpint* uvtomp(uvlong, mpint*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>uvlong mptouv(mpint*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void mpadd(mpint *b1, mpint *b2, mpint *sum) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void mpmagadd(mpint *b1, mpint *b2, mpint *sum) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void mpsub(mpint *b1, mpint *b2, mpint *diff) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void mpmagsub(mpint *b1, mpint *b2, mpint *diff) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void mpleft(mpint *b, int shift, mpint *res) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void mpright(mpint *b, int shift, mpint *res) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void mpmul(mpint *b1, mpint *b2, mpint *prod) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void mpexp(mpint *b, mpint *e, mpint *m, mpint *res) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void mpmod(mpint *b, mpint *m, mpint *remainder) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void mpdiv(mpint *dividend, mpint *divisor, mpint *quotient, mpint + *remainder) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>mpint* mpfactorial(ulong n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int mpcmp(mpint *b1, mpint *b2) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int mpmagcmp(mpint *b1, mpint *b2) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void mpextendedgcd(mpint *a, mpint *b, mpint *d, mpint *x, mpint + *y) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void mpinvert(mpint *b, mpint *m, mpint *res) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int mpsignif(mpint *b) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int mplowbits0(mpint *b) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void mpdigdiv(mpdigit *dividend, mpdigit divisor, mpdigit *quotient) + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void mpvecadd(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit + *sum) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void mpvecsub(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit + *diff) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void mpvecdigmuladd(mpdigit *b, int n, mpdigit m, mpdigit *p) + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int mpvecdigmulsub(mpdigit *b, int n, mpdigit m, mpdigit *p) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void mpvecmul(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit + *p) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int mpveccmp(mpdigit *a, int alen, mpdigit *b, int blen) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>CRTpre* crtpre(int nfactors, mpint **factors) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>CRTres* crtin(CRTpre *crt, mpint *x) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void crtout(CRTpre *crt, CRTres *r, mpint *x) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void crtprefree(CRTpre *cre) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void crtresfree(CRTres *res) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>mpint *mpzero, *mpone, *mptwo<br> + </font></tt> +</table> +<p><font size=+1><b>DESCRIPTION </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + These routines perform extended precision integer arithmetic. + The basic type is <tt><font size=+1>mpint</font></tt>, which points to an array of <tt><font size=+1>mpdigit</font></tt>s, + stored in little-endian order:<br> + <tt><font size=+1>typedef struct mpint mpint;<br> + struct mpint<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int sign; /* +1 or −1 */<br> + int size; /* allocated digits */<br> + int top; /* significant digits */<br> + mpdigit *p;<br> + char flags;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + The sign of 0 is +1. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The size of <tt><font size=+1>mpdigit</font></tt> is architecture-dependent and defined in <tt><font size=+1>/$cputype/include/u.h</font></tt>. + <tt><font size=+1>Mpint</font></tt>s are dynamically allocated and must be explicitly freed. + Operations grow the array of digits as needed. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + In general, the result parameters are last in the argument list. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Routines that return an <tt><font size=+1>mpint</font></tt> will allocate the <tt><font size=+1>mpint</font></tt> if the result + parameter is <tt><font size=+1>nil</font></tt>. This includes <i>strtomp</i>, <i>itomp</i>, <i>uitomp</i>, and <i>btomp</i>. + These functions, in addition to <i>mpnew</i> and <i>mpcopy</i>, will return + <tt><font size=+1>nil</font></tt> if the allocation fails. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Input and result parameters may point to the same <tt><font size=+1>mpint</font></tt>. The routines + check and copy where necessary. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Mpnew</i> creates an <tt><font size=+1>mpint</font></tt> with an initial allocation of <i>n</i> bits. If + <i>n</i> is zero, the allocation will be whatever was specified in the + last call to <i>mpsetminbits</i> or to the initial value, 1056. <i>Mpfree</i> + frees an <tt><font size=+1>mpint</font></tt>. <i>Mpbits</i> grows the allocation of <i>b</i> to fit at least + <i>n</i> bits. If <tt><font size=+1>b−>top</font></tt> doesn’t cover <i>n</i> bits it increases it to do so. + Unless + you are writing new basic operations, you can restrict yourself + to <tt><font size=+1>mpnew(0)</font></tt> and <tt><font size=+1>mpfree(b)</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Mpnorm</i> normalizes the representation by trimming any high order + zero digits. All routines except <tt><font size=+1>mpbits</font></tt> return normalized results. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Mpcopy</i> creates a new <tt><font size=+1>mpint</font></tt> with the same value as <i>b</i> while <i>mpassign</i> + sets the value of <i>new</i> to be that of <i>old</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Mprand</i> creates an <i>n</i> bit random number using the generator <i>gen</i>. + <i>Gen</i> takes a pointer to a string of uchar’s and the number to fill + in. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Strtomp</i> and <i>mptoa</i> convert between ASCII and <tt><font size=+1>mpint</font></tt> representations + using the base indicated. Only the bases 10, 16, 32, and 64 are + supported. Anything else defaults to 16. <i>Strtomp</i> skips any leading + spaces or tabs. <i>Strtomp</i>’s scan stops when encountering a digit + not valid in the base. If <i>rptr</i> is not zero, <i>*rptr</i> is + set to point to the character immediately after the string converted. + If the parse pterminates before any digits are found, <i>strtomp</i> + return <tt><font size=+1>nil</font></tt>. <i>Mptoa</i> returns a pointer to the filled buffer. If the + parameter <i>buf</i> is <tt><font size=+1>nil</font></tt>, the buffer is allocated. <i>Mpfmt</i> can be used + with <a href="../man3/fmtinstall.html"><i>fmtinstall</i>(3)</a> and <a href="../man3/print.html"><i>print</i>(3)</a> to print hexadecimal + representations of <tt><font size=+1>mpint</font></tt>s. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Mptobe</i> and <i>mptole</i> convert an <i>mpint</i> to a byte array. The former + creates a big endian representation, the latter a little endian + one. If the destination <i>buf</i> is not <tt><font size=+1>nil</font></tt>, it specifies the buffer + of length <i>blen</i> for the result. If the representation is less than + <i>blen</i> bytes, the rest of the buffer is zero filled. If <i>buf</i> is <tt><font size=+1>nil</font></tt>, + then a + buffer is allocated and a pointer to it is deposited in the location + pointed to by <i>bufp</i>. Sign is ignored in these conversions, i.e., + the byte array version is always positive. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Betomp</i>, and <i>letomp</i> convert from a big or little endian byte array + at <i>buf</i> of length <i>blen</i> to an <i>mpint</i>. If <i>b</i> is not <i>nil</i>, it refers + to a preallocated <i>mpint</i> for the result. If <i>b</i> is <tt><font size=+1>nil</font></tt>, a new integer + is allocated and returned as the result. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The integer conversions are:<br> + <i>mptoui</i><tt><font size=+1> mpint</font></tt>-><tt><font size=+1>unsigned int<br> + </font></tt><i>uitomp</i><tt><font size=+1> unsigned int</font></tt>-><tt><font size=+1>mpint<br> + </font></tt><i>mptoi</i><tt><font size=+1> mpint</font></tt>-><tt><font size=+1>int<br> + </font></tt><i>itomp</i><tt><font size=+1> int</font></tt>-><tt><font size=+1>mpint<br> + </font></tt><i>mptouv</i><tt><font size=+1> mpint</font></tt>-><tt><font size=+1>unsigned vlong<br> + </font></tt><i>uvtomp</i><tt><font size=+1> unsigned vlong</font></tt>-><tt><font size=+1>mpint<br> + </font></tt><i>mptov</i><tt><font size=+1> mpint</font></tt>-><tt><font size=+1>vlong<br> + </font></tt><i>vtomp</i><tt><font size=+1> vlong</font></tt>-><tt><font size=+1>mpint + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + When converting to the base integer types, if the integer is too + large, the largest integer of the appropriate sign and size is + returned. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The mathematical functions are:<br> + <i>mpadd</i><tt><font size=+1> sum = b1 + b2</font></tt>.<br> + <i>mpmagadd</i><tt><font size=+1> sum = abs(b1) + abs(b2)</font></tt>.<br> + <i>mpsub</i><tt><font size=+1> diff = b1 − b2</font></tt>.<br> + <i>mpmagsub</i><tt><font size=+1> diff = abs(b1) − abs(b2)</font></tt>.<br> + <i>mpleft</i><tt><font size=+1> res = b<<shift</font></tt>.<br> + <i>mpright</i><tt><font size=+1> res = b>>shift</font></tt>.<br> + <i>mpmul</i><tt><font size=+1> prod = b1*b2</font></tt>.<br> + <i>mpexp</i> if <i>m</i> is nil, <tt><font size=+1>res = b**e</font></tt>. Otherwise, <tt><font size=+1>res = b**e mod m</font></tt>.<br> + <i>mpmod</i><tt><font size=+1> remainder = b % m</font></tt>.<br> + <i>mpdiv</i><tt><font size=+1> quotient = dividend/divisor</font></tt>. <tt><font size=+1>remainder = dividend % divisor</font></tt>.<br> + <i>mpfactorial</i> returns factorial of <i>n</i>.<br> + <i>mpcmp</i> returns -1, 0, or +1 as <i>b1</i> is less than, equal to, or greater + than <i>b2</i>.<br> + <i>mpmagcmp</i> the same as <i>mpcmp</i> but ignores the sign and just compares + magnitudes. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Mpextendedgcd</i> computes the greatest common denominator, <i>d</i>, of + <i>a</i> and <i>b</i>. It also computes <i>x</i> and <i>y</i> such that <tt><font size=+1>a*x + b*y = d</font></tt>. Both + <i>a</i> and <i>b</i> are required to be positive. If called with negative arguments, + it will return a gcd of 0. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Mpinverse</i> computes the multiplicative inverse of <i>b</i> <tt><font size=+1>mod</font></tt> <i>m</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Mpsignif</i> returns the bit offset of the left most 1 bit in <i>b</i>. <i>Mplowbits0</i> + returns the bit offset of the right most 1 bit. For example, for + 0x14, <i>mpsignif</i> would return 4 and <i>mplowbits0</i> would return 2. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The remaining routines all work on arrays of <tt><font size=+1>mpdigit</font></tt> rather than + <tt><font size=+1>mpint</font></tt>’s. They are the basis of all the other routines. They are + separated out to allow them to be rewritten in assembler for each + architecture. There is also a portable C version for each one.<br> + <i>mpdigdiv</i><tt><font size=+1> quotient = dividend[0:1] / divisor</font></tt>.<br> + <i>mpvecadd</i><tt><font size=+1> sum[0:alen] = a[0:alen−1] + b[0:blen−1]</font></tt>. We assume alen + >= blen and that sum has room for alen+1 digits.<br> + <i>mpvecsub</i><tt><font size=+1> diff[0:alen−1] = a[0:alen−1] − b[0:blen−1]</font></tt>. We assume + that alen >= blen and that diff has room for alen digits.<br> + <i>mpvecdigmuladd</i><tt><font size=+1> p[0:n] += m * b[0:n−1]</font></tt>. This multiplies a an array + of digits times a scalar and adds it to another array. We assume + p has room for n+1 digits.<br> + <i>mpvecdigmulsub</i><tt><font size=+1> p[0:n] −= m * b[0:n−1]</font></tt>. This multiplies a an array + of digits times a scalar and subtracts it fromo another array. + We assume p has room for n+1 digits. It returns +1 is the result + is positive and -1 if negative.<br> + <i>mpvecmul</i><tt><font size=+1> p[0:alen*blen] = a[0:alen−1] * b[0:blen−1]</font></tt>. We assume + that p has room for alen*blen+1 digits.<br> + <i>mpveccmp</i> This returns -1, 0, or +1 as a - b is negative, 0, or + positive. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>mptwo</i>, <i>mpone</i> and <i>mpzero</i> are the constants 2, 1 and 0. These cannot + be freed.<br> + <p><font size=+1><b>Chinese remainder theorem </b></font><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + When computing in a non-prime modulus, <i>n,</i> it is possible to perform + the computations on the residues modulo the prime factors of <i>n</i> + instead. Since these numbers are smaller, multiplication and exponentiation + can be much faster. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Crtin</i> computes the residues of <i>x</i> and returns them in a newly allocated + structure:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef struct CRTres CRTres; <br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int n; // number of residues<br> + mpint *r[n]; // residues<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + <i>Crtout</i> takes a residue representation of a number and converts + it back into the number. It also frees the residue structure. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Crepre</i> saves a copy of the factors and precomputes the constants + necessary for converting the residue form back into a number modulo + the product of the factors. It returns a newly allocated structure + containing values. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Crtprefree</i> and <i>crtresfree</i> free <i>CRTpre</i> and <i>CRTres</i> structures respectively.<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/libmp<br> + </font></tt> +</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> diff --git a/man/man3/muldiv.html b/man/man3/muldiv.html new file mode 100644 index 00000000..486020ca --- /dev/null +++ b/man/man3/muldiv.html @@ -0,0 +1,61 @@ +<head> +<title>muldiv(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>MULDIV(3)</b><td align=right><b>MULDIV(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> + + muldiv, umuldiv – high-precision multiplication and division<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long muldiv(long a, long b, long c) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ulong umuldiv(ulong a, ulong b, ulong c)<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> + + <i>Muldiv</i> returns <tt><font size=+1>a*b/c</font></tt>, using a <tt><font size=+1>vlong</font></tt> to hold the intermediate result. + <i>Umuldiv</i> is the equivalent for unsigned integers. They can be used + to scale integer values without worry about overflowing the intermediate + result. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + On some architectures, these routines can generate a trap if the + final result does not fit in a <tt><font size=+1>long</font></tt> or <tt><font size=+1>ulong</font></tt>; on others they will + silently truncate.<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> diff --git a/man/man3/mux.html b/man/man3/mux.html new file mode 100644 index 00000000..e3e7e4c8 --- /dev/null +++ b/man/man3/mux.html @@ -0,0 +1,169 @@ +<head> +<title>mux(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>MUX(3)</b><td align=right><b>MUX(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> + + Mux, muxinit, muxrpc, muxthreads – protocol multiplexor<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 <mux.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + struct Mux<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + uint mintag;<br> + uint maxtag;<br> + int (*settag)(Mux *mux, void *msg, uint tag);<br> + int (*gettag)(Mux *mux, void *msg);<br> + int (*send)(Mux *mux, void *msg);<br> + void *(*recv)(Mux *mux);<br> + void *aux;<br> + ... /* private fields follow */<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>void muxinit(Mux *mux);<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void* muxrpc(Mux *mux, void *request);<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void muxprocs(Mux *mux);<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> + + <i>Libmux</i> is a generic protocol multiplexor. A client program initializes + a <tt><font size=+1>Mux</font></tt> structure with information about the protocol (mainly in + the form of helper functions) and can then use <i>muxrpc</i> to execute + individual RPCs without worrying about details of multiplexing + requests and demultiplexing responses. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Libmux</i> assumes that the protocol messages contain a <i>tag</i> (or message + ID) field that exists for the sole purpose of demultiplexing messages. + <i>Libmux</i> chooses the tags and then calls a helper function to put + them in the outgoing messages. <i>Libmux</i> calls another helper function + to retrieve tags from incoming messages. + It also calls helper functions to send and receive packets. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + A client should allocate a <tt><font size=+1>Mux</font></tt> structure and then call <i>muxinit</i> + to initialize the library’s private elements. The client must + initialize the following elements:<br> + <i>mintag</i>, <i>maxtag<br> + </i> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The range of valid tags; <i>maxtag</i> is the maximum valid tag plus + one, so that <i>maxtag</i>–<i>mintag</i> is equal to the number of valid tags. + If <i>libmux</i> runs out of tags (all tags are being used for RPCs currently + in progress), a new call to <i>muxrpc</i> will block until an executing + call finishes.<br> + + </table> + <i>settag</i>, <i>gettag<br> + </i> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Set or get the tag value in a message.<br> + + </table> + <i>send</i>, <i>recv<br> + </i> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Send or receive protocol messages on the connection. <i>Recv</i> should + block until a message is available and should return nil if the + connection is closed. <i>Libmux</i> will arrange that only one call to + <i>recv</i> is active at a time.<br> + + </table> + <i>aux</i> An auxiliary pointer for use by the client. Once a client has + initialized the <tt><font size=+1>Mux</font></tt> structure, it can call <i>muxrpc</i> to execute RPCs. + The <i>request</i> is the message passed to <i>settag</i> and <i>send</i>. The return + value is the response packet, as provided by <i>recv</i>, or nil if an + error occurred. <i>Muxprocs</i> allocates new procs (see + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <a href="../man3/thread.html"><i>thread</i>(3)</a>) in which to run <i>send</i> and <i>recv</i>. After a call to <i>muxprocs</i>, + <i>muxrpc</i> will run <i>send</i> and <i>recv</i> in these procs instead of in the + calling proc. This is useful if the implementation of either (particularly + <i>recv</i>) blocks an entire proc and there are other threads in the + calling proc that need to remain active. + + </table> + +</table> +<p><font size=+1><b>EXAMPLE </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + See <tt><font size=+1>/usr/local/plan9/src/lib9pclient/fs.c</font></tt> for an example of using + <i>libmux</i> with 9P (see <i>intro</i>(9p)).<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/libmux<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/thread.html"><i>thread</i>(3)</a>, <i>intro</i>(9p)<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Libmux</i> does not know how to free protocol messages, so message + arriving with unexpected or invalid tags are leaked. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Using <i>mintag</i> other than zero is not well tested and probably buggy.<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> diff --git a/man/man3/nan.html b/man/man3/nan.html new file mode 100644 index 00000000..e644116b --- /dev/null +++ b/man/man3/nan.html @@ -0,0 +1,79 @@ +<head> +<title>nan(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>NAN(3)</b><td align=right><b>NAN(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> + + NaN, Inf, isNaN, isInf – not-a-number and infinity functions<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>double NaN(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>double Inf(int) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int isNaN(double) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int isInf(double, int)<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> + + The IEEE floating point standard defines values called ‘not-a-number’ + and positive and negative ‘infinity’. These values can be produced + by such things as overflow and division by zero. Also, the library + functions sometimes return them when the arguments are not in + the domain, or the result is out of range. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>NaN</i> returns a double that is not-a-number. <i>IsNaN</i> returns true + if its argument is not-a-number. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Inf</i>(<i>i</i>) returns positive infinity if <i>i</i> is greater than or equal + to zero, else negative infinity. <i>IsInf</i> returns true if its first + argument is infinity with the same sign as the second argument.<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/lib9/nan.c<br> + </font></tt> +</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> diff --git a/man/man3/needstack.html b/man/man3/needstack.html new file mode 100644 index 00000000..bba5fbe8 --- /dev/null +++ b/man/man3/needstack.html @@ -0,0 +1,98 @@ +<head> +<title>needstack(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>NEEDSTACK(3)</b><td align=right><b>NEEDSTACK(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> + + needstack – check for execution stack overflow<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include <libc.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int needstack(int n)<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> + + Stack overflow in the thread library leads to bugs that are difficult + to diagnose. The Plan 9 libraries are careful about not allocating + large structures on the stack, so typically four or eight kilobytes + is plenty of stack for a thread. Other libraries are not always + as careful. Calling <i>needstack</i> indicates to the thread library + that an external routine is about to be called that will require + <i>n</i> bytes of stack space. If there is not enough space left on the + stack, the thread library prints an error and terminates the program. + The call <tt><font size=+1>needstack(0)</font></tt> can be used to check whether the stack is + currently overflowed. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Needstack</i> is defined in <tt><font size=+1>libc.h</font></tt> so that library functions used + in threaded and non-threaded contexts can call it. The implementation + of <i>needstack</i> in <tt><font size=+1>lib9</font></tt> is a no-op. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Needstack</i> should be thought of as a comment checked at run time, + like <a href="../man3/assert.html"><i>assert</i>(3)</a>.<br> + +</table> +<p><font size=+1><b>EXAMPLE </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The X Window library implementation of <i>XLookupString</i> allocates + some very large buffers on the stack, so <tt><font size=+1>/usr/local/plan9/src/libdraw/x11−itrans.c</font></tt> + calls <tt><font size=+1>needstack(20*1024)</font></tt> before making calls to <i>XLookupString</i>. + If a thread (in this case, the keyboard-reading thread used inside + the <a href="../man3/draw.html"><i>draw</i>(3)</a> + library) does not allocate a large enough stack, the problem is + diagnosed immediately rather than left to corrupt memory.<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/lib9/needstack.c<br> + /usr/local/plan9/src/libthread<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/thread.html"><i>thread</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> diff --git a/man/man3/notify.html b/man/man3/notify.html new file mode 100644 index 00000000..9899e701 --- /dev/null +++ b/man/man3/notify.html @@ -0,0 +1,183 @@ +<head> +<title>notify(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>NOTIFY(3)</b><td align=right><b>NOTIFY(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> + + notify, noted, atnotify, noteenable, notedisable, notifyon, notifyoff + – handle asynchronous process notification<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int notify(void (*f)(void*, char*)) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int noted(int v) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int atnotify(int (*f)(void*, char*), int in) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int noteenable(char *msg)<br> + int notedisable(char *msg) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int notifyon(char *msg)<br> + int notifyoff(char *msg)<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> + + When a process raises an exceptional condition such as dividing + by zero or writing on a closed pipe, a <i>note</i> is posted to communicate + the exception. A note may also be posted by another process via + <a href="../man3/postnote.html"><i>postnote</i>(3)</a>. On Unix, notes are implemented as signals. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + When a note is received, the action taken depends on the note. + See <a href="../man7/signal.html"><i>signal</i>(7)</a> for the full description of the defaults. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The default actions may be overridden. The <i>notify</i> function registers + a <i>notification handler</i> to be called within the process when a + note is received. The argument to <i>notify</i> replaces the previous + handler, if any. An argument of zero cancels a previous handler, + restoring the default action. A <a href="../man2/fork.html"><i>fork</i>(2)</a> system call leaves the + handler registered in both the parent and the child; <a href="../man3/exec.html"><i>exec</i>(3)</a> restores + the default behavior. Handlers may not perform floating point + operations. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + After a note is posted, the handler is called with two arguments: + the first is unimplemented and should not be used (on Plan 9 it + is a <tt><font size=+1>Ureg</font></tt> structure giving the current values of registers); the + second is a pointer to the note itself, a null-terminated string. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + A notification handler must finish either by exiting the program + or by calling <i>noted</i>; if the handler returns the behavior is undefined + and probably erroneous. Until the program calls <i>noted</i>, any further + externally-generated notes (e.g., <tt><font size=+1>hangup</font></tt> or <tt><font size=+1>alarm</font></tt>) will be held + off, and any further notes generated by erroneous + behavior by the program (such as divide by zero) will kill the + program. The argument to <i>noted</i> defines the action to take: <tt><font size=+1>NDFLT</font></tt> + instructs the system to perform the default action as if the handler + had never been registered; <tt><font size=+1>NCONT</font></tt> instructs the system to resume + the process at the point it was notified. In neither case + does <i>noted</i> return to the handler. If the note interrupted an incomplete + system call, that call returns an error (with error string <tt><font size=+1>interrupted</font></tt>) + after the process resumes. A notification handler can also jump + out to an environment set up with <i>setjmp</i> using the <i>notejmp</i> function + (see <a href="../man3/setjmp.html"><i>setjmp</i>(3)</a>). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Unix provides a fixed set of notes (typically there are 32) called + <i>signals</i>. It also allows a process to block certain notes from + being delivered (see <a href="../man2/sigprocmask.html"><i>sigprocmask</i>(2)</a>) and to ignore certain notes + by setting the signal hander to the special value <tt><font size=+1>SIG_IGN</font></tt> (see + <a href="../man2/signal.html"><i>signal</i>(2)</a>). <i>Noteenable</i> and <i>notedisable</i> enable or disable receipt + of + a particular note by changing the current process’s blocked signal + mask. Receipt of a disabled note will be postponed until it is + reenabled. <i>Notifyon</i> and <i>notifyoff</i> enable or disable whether the + notification handler is called upon receipt of the note; if the + handler is not called, the note is discarded. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Regardless of the origin of the note or the presence of a handler, + if the process is being debugged (see <a href="../man2/ptrace.html"><i>ptrace</i>(2)</a>) the arrival of + a note puts the process in the <tt><font size=+1>Stopped</font></tt> state and awakens the debugger. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Rather than using the system calls <i>notify</i> and <i>noted</i>, most programs + should use <i>atnotify</i> to register notification handlers. The parameter + <i>in</i> is non-zero to register the function <i>f</i>, and zero to cancel + registration. A handler must return a non-zero number if the note + was recognized (and resolved); otherwise it must return + zero. When the system posts a note to the process, each handler + registered with <i>atnotify</i> is called with arguments as described + above until one of the handlers returns non-zero. Then <i>noted</i> is + called with argument <tt><font size=+1>NCONT</font></tt>. If no registered function returns + non-zero, <i>atnotify</i> calls <i>noted</i> with argument <tt><font size=+1>NDFLT</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The set of notes a process may receive is system-dependent, but + there is a common set that includes: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Note Meaning Unix signal<br> + </i><tt><font size=+1>interrupt </font></tt> user interrupt (DEL key) SIGINTR<br> + <tt><font size=+1>hangup </font></tt> I/O connection closed SIGHUP<br> + <tt><font size=+1>alarm </font></tt> alarm expired SIGLARM<br> + <tt><font size=+1>quit </font></tt> quit from keyboard SIGQUIT<br> + <tt><font size=+1>kill </font></tt> process requested to exit SIGTERM<br> + <tt><font size=+1>sys: kill </font></tt> process forced to exit SIGKILL<br> + <tt><font size=+1>sys: bus error </font></tt> bus error SIGBUS<br> + <tt><font size=+1>sys: segmentation violation </font></tt> segmentation violation SIGSEGV<br> + <tt><font size=+1>sys: write on closed pipe </font></tt> write on closed pipe SIGPIPE<br> + <tt><font size=+1>sys: child </font></tt> child wait status change SIGCHLD<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + See <tt><font size=+1>/usr/local/plan9/src/lib9/await.c</font></tt> (sic) for the full list. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The notes prefixed <tt><font size=+1>sys:</font></tt> are usually generated by the operating + system.<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/lib9/notify.c<br> + /usr/local/plan9/src/lib9/atnotify.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/intro.html"><i>intro</i>(3)</a>, <i>notejmp</i> in <a href="../man3/setjmp.html"><i>setjmp</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> diff --git a/man/man3/open.html b/man/man3/open.html new file mode 100644 index 00000000..64f85c55 --- /dev/null +++ b/man/man3/open.html @@ -0,0 +1,130 @@ +<head> +<title>open(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>OPEN(3)</b><td align=right><b>OPEN(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> + + open, create, close – open a file for reading or writing, create + file<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int open(char *file, int omode) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int create(char *file, int omode, ulong perm) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int close(int fd)<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> + + <i>Open</i> opens the <i>file</i> for I/O and returns an associated file descriptor. + <i>Omode</i> is one of <tt><font size=+1>OREAD</font></tt>, <tt><font size=+1>OWRITE</font></tt>, <tt><font size=+1>ORDWR</font></tt>, or <tt><font size=+1>OEXEC</font></tt>, asking for permission + to read, write, read and write, or execute, respectively. In addition, + there are three values that can be ORed with the <i>omode</i>: <tt><font size=+1>OTRUNC</font></tt> + says to truncate the file to zero length + before opening it; <tt><font size=+1>OCEXEC</font></tt> says to close the file when an <a href="../man3/exec.html"><i>exec</i>(3)</a> + or <i>execl</i> system call is made; and <tt><font size=+1>ORCLOSE</font></tt> says to remove the file + when it is closed (by everyone who has a copy of the file descriptor). + <i>Open</i> fails if the file does not exist or the user does not have + permission to open it for the requested purpose (see + <a href="../man3/stat.html"><i>stat</i>(3)</a> for a description of permissions). The user must have + write permission on the <i>file</i> if the <tt><font size=+1>OTRUNC</font></tt> bit is set. For the + <i>open</i> system call (unlike the implicit <i>open</i> in <a href="../man3/exec.html"><i>exec</i>(3)</a>), <tt><font size=+1>OEXEC</font></tt> + is actually identical to <tt><font size=+1>OREAD</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Create</i> creates a new <i>file</i> or prepares to rewrite an existing <i>file</i>, + opens it according to <i>omode</i> (as described for <i>open</i>), and returns + an associated file descriptor. If the file is new, the owner is + set to the userid of the creating process group; the group to + that of the containing directory; the permissions to <i>perm</i> ANDed + with + the permissions of the containing directory. If the file already + exists, it is truncated to 0 length, and the permissions, owner, + and group remain unchanged. The created file is a directory if + the <tt><font size=+1>DMDIR</font></tt> bit is set in <i>perm</i>, an exclusive-use file if the <tt><font size=+1>DMEXCL</font></tt> + bit is set, and an append-only file if the <tt><font size=+1>DMAPPEND</font></tt> bit is set. + Exclusive-use files may be open for I/O by only one client at + a time, but the file descriptor may become invalid if no I/O is + done for an extended period; see <i>open</i>(9p). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Create</i> fails if the path up to the last element of <i>file</i> cannot + be evaluated, if the user doesn’t have write permission in the + final directory, if the file already exists and does not permit + the access defined by <i>omode</i>, of if there there are no free file + descriptors. In the last case, the file may be created even when + an error is + returned. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Since <i>create</i> may succeed even if the file exists, a special mechanism + is necessary for those applications that require an atomic create + operation. If the <tt><font size=+1>OEXCL</font></tt> (<tt><font size=+1>0x1000</font></tt>) bit is set in the <i>mode</i> for a + <i>create,</i> the call succeeds only if the file does not already exist; + see <i>open</i>(9p) for details. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Close</i> closes the file associated with a file descriptor. Provided + the file descriptor is a valid open descriptor, <i>close</i> is guaranteed + to close it; there will be no error. Files are closed automatically + upon termination of a process; <i>close</i> allows the file descriptor + to be reused.<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/lib9<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/intro.html"><i>intro</i>(3)</a>, <a href="../man3/stat.html"><i>stat</i>(3)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + These functions set <i>errstr</i>.<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> diff --git a/man/man3/opentemp.html b/man/man3/opentemp.html new file mode 100644 index 00000000..9ec47571 --- /dev/null +++ b/man/man3/opentemp.html @@ -0,0 +1,78 @@ +<head> +<title>opentemp(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>OPENTEMP(3)</b><td align=right><b>OPENTEMP(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> + + opentemp – create a uniquely-named file<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int opentemp(char *template)<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> + + <i>Opentemp</i> replaces <i>template</i> by a unique file name, and returns + the address of the template. The template should look like a file + name with eleven trailing <tt><font size=+1>X</font></tt>s. The <tt><font size=+1>X</font></tt>s are replaced by a letter + followed by the current process id. Letters from <tt><font size=+1>a</font></tt> to <tt><font size=+1>z</font></tt> are tried + until the name of a file that does not yet exist (see <a href="../man2/access.html"><i>access</i>(2)</a>) + is + generated. <i>Opentemp</i> then creates the file for reading and writing + and returns the file descriptor. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + If no such name can be generated, <i>opentemp</i> returns –1. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Opentemp</i> avoids races. Two simultaneous calls to <i>opentemp</i> will + never return the same name.<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/lib9/opentemp.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> + + <i>create</i> in <a href="../man3/open.html"><i>open</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> diff --git a/man/man3/pipe.html b/man/man3/pipe.html new file mode 100644 index 00000000..b087ae8b --- /dev/null +++ b/man/man3/pipe.html @@ -0,0 +1,111 @@ +<head> +<title>pipe(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>PIPE(3)</b><td align=right><b>PIPE(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> + + pipe – create an interprocess channel<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int pipe(int fd[2])<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> + + <i>Pipe</i> creates a buffered channel for interprocess I/O communication. + Two file descriptors are returned in <i>fd</i>. Data written to <tt><font size=+1>fd[1]</font></tt> + is available for reading from <tt><font size=+1>fd[0]</font></tt> and data written to <tt><font size=+1>fd[0]</font></tt> + is available for reading from <tt><font size=+1>fd[1]</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + After the pipe has been established, cooperating processes created + by subsequent <a href="../man2/fork.html"><i>fork</i>(2)</a> calls may pass data through the pipe with + <i>read</i> and <i>write</i> calls. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + When all the data has been read from a pipe and the writer has + closed the pipe or exited, <a href="../man3/read.html"><i>read</i>(3)</a> will return 0 bytes. Writes + to a pipe with no reader will generate a note <tt><font size=+1>sys: write on closed + pipe</font></tt>.<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/lib9/pipe.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/intro.html"><i>intro</i>(3)</a>, <a href="../man3/read.html"><i>read</i>(3)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Sets <i>errstr</i>.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + If a read or a write of a pipe is interrupted, some unknown number + of bytes may have been transferred. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Pipe</i> is a macro defined as <i>p9pipe</i> to avoid name conflicts with + Unix’s <i>pipe</i> system call. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Unix pipes are not guaranteed to be bidirectional. In order to + ensure a bidirectional channel, <i>p9pipe</i> creates Unix domain sockets + via the <a href="../man2/socketpair.html"><i>socketpair</i>(2)</a> instead of Unix pipes. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The implementation of pipes as Unix domain sockets causes problems + with some Unix implementations of <tt><font size=+1>/dev/fd</font></tt>, Unix’s dup device. + If a Unix domain socket is open as file descriptor 0, some implementations + disallow the opening of <tt><font size=+1>/dev/fd/0</font></tt>; instead one must <a href="../man2/connect.html"><i>connect</i>(2)</a> + to it. If this functionality is important + (as it is for <a href="../man1/rc.html"><i>rc</i>(1)</a>), one must <tt><font size=+1>#undef pipe</font></tt> and fall back on the + (possibly unidirectional) Unix pipes.<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> diff --git a/man/man3/plumb.html b/man/man3/plumb.html new file mode 100644 index 00000000..d7649698 --- /dev/null +++ b/man/man3/plumb.html @@ -0,0 +1,257 @@ +<head> +<title>plumb(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>PLUMB(3)</b><td align=right><b>PLUMB(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> + + eplumb, plumbfree, plumbopen, plumbopenfid, plumbsend, plumbsendtofid, + plumbsendtext, plumblookup, plumbpack, plumbpackattr, plumbaddattr, + plumbdelattr, plumbrecv, plumbrecvfid, plumbunpack, plumbunpackpartial, + plumbunpackattr, Plumbmsg – plumb messages<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 <plumb.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>int plumbopen(char *port, int omode) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int plumbsend(int fd, Plumbmsg *m) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int plumbsendtext(int fd, char *src, char *dst, char *wdir, char + *data) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void plumbfree(Plumbmsg *m) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Plumbmsg* plumbrecv(int fd) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* plumbpack(Plumbmsg *m, int *np) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Plumbmsg* plumbunpack(char *buf, int n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Plumbmsg* plumbunpackpartial(char *buf, int n, int *morep) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* plumbpackattr(Plumbattr *a) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Plumbattr* plumbunpackattr(char *a) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* plumblookup(Plumbattr *a, char *name) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Plumbattr* plumbaddattr(Plumbattr *a, Plumbattr *new) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Plumbattr* plumbdelattr(Plumbattra *a, char *name) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int eplumb(int key, char *port) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include <9pclient.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>CFid *plumbopenfid(char *port, int omode) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Plumbmsg* plumbrecvfid(CFid *fid) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int plumbsendtofid(CFid *fid, Plumbmsg *m)<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 routines manipulate <a href="../man7/plumb.html"><i>plumb</i>(7)</a> messages, transmitting them, + receiving them, and converting them between text and these data + structures:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef<br> + struct Plumbmsg<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + char *src;<br> + char *dst;<br> + char *wdir;<br> + char *type;<br> + Plumbattr *attr;<br> + int ndata;<br> + char *data;<br> + + </table> + } Plumbmsg;<br> + typedef<br> + struct Plumbattr<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + char *name;<br> + char *value;<br> + Plumbattr *next;<br> + + </table> + } Plumbattr;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + <i>Plumbopen</i> opens the named plumb <i>port</i>, using <a href="../man3/open.html"><i>open</i>(3)</a> mode <i>omode</i>. + If <i>port</i> begins with a slash, it is taken as a literal file name; + otherwise <i>plumbopen</i> searches for the location of the <a href="../man4/plumber.html"><i>plumber</i>(4)</a> + service and opens the port there. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + For programs using the <a href="../man3/event.html"><i>event</i>(3)</a> interface, <i>eplumb</i> registers, using + the given <i>key</i>, receipt of messages from the named <i>port</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Plumbsend</i> formats and writes message <i>m</i> to the file descriptor + <i>fd</i>, which will usually be the result of <tt><font size=+1>plumbopen("send", OWRITE)</font></tt>. + <i>Plumbsendtext</i> is a simplified version for text-only messages; + it assumes <tt><font size=+1>type</font></tt> is <tt><font size=+1>text</font></tt>, sets <tt><font size=+1>attr</font></tt> to nil, and sets <tt><font size=+1>ndata</font></tt> to <tt><font size=+1>strlen(</font></tt><i>data</i><tt><font size=+1>)</font></tt>. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Plumbfree</i> frees all the data associated with the message <i>m</i>, all + the components of which must therefore have been allocated with + <a href="../man3/malloc.html"><i>malloc</i>(3)</a>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Plumbrecv</i> returns the next message available on the file descriptor + <i>fd</i>, or nil for error. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Plumbpack</i> encodes message <i>m</i> as a character string in the format + of <a href="../man7/plumb.html"><i>plumb</i>(7)</a><i>,</i> setting <tt><font size=+1>*</font></tt><i>np</i> to the length in bytes of the string. + <i>Plumbunpack</i> does the inverse, translating the <i>n</i> bytes of <i>buf</i> into + a <tt><font size=+1>Plumbmsg</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Plumbunpackpartial</i> enables unpacking of messages that arrive in + pieces. The first call to <i>plumbunpackpartial</i> for a given message + must be sufficient to unpack the header; subsequent calls permit + unpacking messages with long data sections. For each call, <i>buf</i> + points to the beginning of the complete message received + so far, and <i>n</i> reports the total number of bytes received for that + message. If the message is complete, the return value will be + as in <i>plumbunpack</i>. If not, and <i>morep</i> is not null, the return value + will be <tt><font size=+1>nil</font></tt> and <tt><font size=+1>*</font></tt>morep will be set to the number of bytes remaining + to be read for this message to be complete (recall that + the byte count is in the header). Those bytes should be read by + the caller, placed at location <i>buf</i><tt><font size=+1>+</font></tt><i>n</i>, and the message unpacked + again. If an error is encountered, the return value will be <tt><font size=+1>nil</font></tt> + and <tt><font size=+1>*</font></tt><i>morep</i> will be zero. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Plumbpackattr</i> converts the list <i>a</i> of <tt><font size=+1>Plumbattr</font></tt> structures into + a null-terminated string. If an attribute value contains white + space, quote characters, or equal signs, the value will be quoted + appropriately. A newline character will terminate processing. + <i>Plumbunpackattr</i> converts the null-terminated string <i>a</i> back into + a list of <i>Plumbattr</i> structures. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Plumblookup</i> searches the <tt><font size=+1>Plumbattr</font></tt> list <i>a</i> for an attribute with + the given <i>name</i> and returns the associated value. The returned + string is the original value, not a copy. If the attribute has + no value, the returned value will be the empty string; if the + attribute does not occur in the list at all, the value will be + nil. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Plumbaddattr</i> appends the <i>new</i> <tt><font size=+1>Plumbattr</font></tt> (which may be a list) to + the attribute list <i>a</i> and returns the new list. <i>Plumbattr</i> searches + the list <i>a</i> for the first attribute with name <i>name</i> and deletes + it from the list, returning the resulting list. <i>Plumbdelattr</i> is + a no-op if no such attribute exists. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The file descriptor returned by <i>plumbopen</i> is created with <i>fsopenfd</i> + (see <a href="../man3/9pclient.html"><i>9pclient</i>(3)</a>), which masks information about read and write + errors. This is acceptable for use in <i>plumbrecv</i> but not for <i>plumbsend</i>, + which depends on seeing details of write errors. <i>Plumbopenfid</i>, + <i>plumbrecvfid</i>, and <i>plumbsendtofid</i> provide an + explicit interface to <i>lib9pclient</i> that preserves the exact error + details.<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/libplumb<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="../man1/plumb.html"><i>plumb</i>(1)</a>, <a href="../man3/event.html"><i>event</i>(3)</a>, <a href="../man4/plumber.html"><i>plumber</i>(4)</a>, <a href="../man7/plumb.html"><i>plumb</i>(7)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + When appropriate, including when a <i>plumbsend</i> fails, these routine + set <i>errstr</i>.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + To avoid rewriting clients that use <i>plumbsend</i>, the call <tt><font size=+1>plumbopen("send", + OWRITE)</font></tt> returns a useless file descriptor (it is opened to <tt><font size=+1>/dev/null</font></tt>). + <i>Plumbsend</i> looks for this particular file descriptor and uses a + static copy of the <tt><font size=+1>CFid</font></tt> instead.<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> diff --git a/man/man3/post9pservice.html b/man/man3/post9pservice.html new file mode 100644 index 00000000..62238d0d --- /dev/null +++ b/man/man3/post9pservice.html @@ -0,0 +1,67 @@ +<head> +<title>post9pservice(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>POST9PSERVICE(3)</b><td align=right><b>POST9PSERVICE(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> + + post9pservice – post 9P service for use by clients<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int post9pservice(int fd, char *name)<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> + + <i>Post9pservice</i> invokes <a href="../man4/9pserve.html"><i>9pserve</i>(4)</a> to post a new 9P service in the + current “name space” (see <a href="../man4/intro.html"><i>intro</i>(4)</a>) named <i>name</i>. Clients connecting + to the posted service are multiplexed onto a single 9P conversation + with the server on file descriptor <i>fd</i>.<br> + +</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="../man4/intro.html"><i>intro</i>(4)</a>, <a href="../man4/9pserve.html"><i>9pserve</i>(4)</a><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/lib9/post9p.c<br> + </font></tt> +</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> diff --git a/man/man3/postnote.html b/man/man3/postnote.html new file mode 100644 index 00000000..b08507e5 --- /dev/null +++ b/man/man3/postnote.html @@ -0,0 +1,80 @@ +<head> +<title>postnote(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>POSTNOTE(3)</b><td align=right><b>POSTNOTE(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> + + postnote – send a note to a process or process group<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int postnote(int who, int pid, char *note)<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> + + <i>Postnote</i> sends a note to a process or process group. If <i>who</i> is + <tt><font size=+1>PNPROC</font></tt>, then <i>note</i> is sent to the process with id <i>pid</i>. If <i>who</i> is + <tt><font size=+1>PNGROUP</font></tt><i>,</i> the note is delivered to the process group which has + the process with id <i>pid</i> as a member. For <tt><font size=+1>PNGROUP</font></tt> only, if the + calling process is in the target group, the note is <i>not</i> delivered + to + that process. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + If the write is successful, zero is returned. Otherwise –1 is returned.<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/lib9/postnote.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/notify.html"><i>notify</i>(3)</a>, <a href="../man3/intro.html"><i>intro</i>(3)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Sets <i>errstr</i>.<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> diff --git a/man/man3/prime.html b/man/man3/prime.html new file mode 100644 index 00000000..abaffda0 --- /dev/null +++ b/man/man3/prime.html @@ -0,0 +1,114 @@ +<head> +<title>prime(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>PRIME(3)</b><td align=right><b>PRIME(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> + + genprime, gensafeprime, genstrongprime, DSAprimes, probably_prime, + smallprimetest – prime number generation<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 <mp.h><br> + #include <libsec.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int smallprimetest(mpint *p) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int probably_prime(mpint *p, int nrep) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void genprime(mpint *p, int n, int nrep) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void gensafeprime(mpint *p, mpint *alpha, int n, int accuracy) + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void genstrongprime(mpint *p, int n, int nrep) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void DSAprimes(mpint *q, mpint *p, uchar seed[SHA1dlen])<br> + </font></tt> +</table> +<p><font size=+1><b>DESCRIPTION </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Public key algorithms abound in prime numbers. The following routines + generate primes or test numbers for primality. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Smallprimetest</i> checks for divisibility by the first 10000 primes. + It returns 0 if <i>p</i> is not divisible by the primes and –1 if it is. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Probably_prime</i> uses the Miller-Rabin test to test <i>p</i>. It returns + non-zero if <i>P</i> is probably prime. The probability of it not being + prime is 1/4**<i>nrep</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Genprime</i> generates a random <i>n</i> bit prime. Since it uses the Miller-Rabin + test, <i>nrep</i> is the repetition count passed to <i>probably_prime</i>. <i>Gensafegprime</i> + generates an <i>n</i>-bit prime <i>p</i> and a generator <i>alpha</i> of the multiplicative + group of integers mod <i>p</i>; there is a prime <i>q</i> such that <i>p-1=2*q</i>. + <i>Genstrongprime</i> generates a + prime, <i>p</i>, with the following properties:<br> + – (<i>p</i>-1)/2 is prime. Therefore <i>p</i>-1 has a large prime factor, <i>p</i>’.<br> + –<i>p</i>’-1 has a large prime factor<br> + –<i>p</i>+1 has a large prime factor + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>DSAprimes</i> generates two primes, <i>q</i> and <i>p,</i> using the NIST recommended + algorithm for DSA primes. <i>q</i> divides <i>p</i>-1. The random seed used + is also returned, so that skeptics can later confirm the computation. + Be patient; this is a slow algorithm.<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/libsec<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/aes.html"><i>aes</i>(3)</a> <a href="../man3/blowfish.html"><i>blowfish</i>(3)</a>, <a href="../man3/des.html"><i>des</i>(3)</a>, <a href="../man3/elgamal.html"><i>elgamal</i>(3)</a>, <a href="../man3/rsa.html"><i>rsa</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> diff --git a/man/man3/print.html b/man/man3/print.html new file mode 100644 index 00000000..8640efc7 --- /dev/null +++ b/man/man3/print.html @@ -0,0 +1,309 @@ +<head> +<title>print(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>PRINT(3)</b><td align=right><b>PRINT(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> + + print, fprint, sprint, snprint, seprint, smprint, runesprint, + runesnprint, runeseprint, runesmprint, vfprint, vsnprint, vseprint, + vsmprint, runevsnprint, runevseprint, runevsmprint – print formatted + output<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include <libc.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int print(char *format, ...) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int fprint(int fd, char *format, ...) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int sprint(char *s, char *format, ...) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int snprint(char *s, int len, char *format, ...) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* seprint(char *s, char *e, char *format, ...) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* smprint(char *format, ...) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int runesprint(Rune *s, char *format, ...) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int runesnprint(Rune *s, int len, char *format, ...) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rune* runeseprint(Rune *s, Rune *e, char *format, ...) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rune* runesmprint(char *format, ...) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int vfprint(int fd, char *format, va_list v) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int vsnprint(char *s, int len, char *format, va_list v) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* vseprint(char *s, char *e, char *format, va_list v) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* vsmprint(char *format, va_list v) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int runevsnprint(Rune *s, int len, char *format, va_list v) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rune* runevseprint(Rune *s, Rune *e, char *format, va_list v) + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rune* runevsmprint(Rune *format, va_list v) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </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> + + <i>Print</i> writes text to the standard output. <i>Fprint</i> writes to the + named output file descriptor: a buffered form is described in + <a href="../man3/bio.html"><i>bio</i>(3)</a>. <i>Sprint</i> places text followed by the NUL character (<tt><font size=+1>\0</font></tt>) + in consecutive bytes starting at <i>s</i>; it is the user’s responsibility + to ensure that enough storage is available. Each function returns + the + number of bytes transmitted (not including the NUL in the case + of <i>sprint</i>), or a negative value if an output error was encountered. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Snprint</i> is like <i>sprint</i>, but will not place more than <i>len</i> bytes + in <i>s</i>. Its result is always NUL-terminated and holds the maximal + number of complete UTF-8 characters that can fit. <i>Seprint</i> is like + <i>snprint</i>, except that the end is indicated by a pointer <i>e</i> rather + than a count and the return value points to the terminating NUL + of + the resulting string. <i>Smprint</i> is like <i>sprint</i>, except that it prints + into and returns a string of the required length, which is allocated + by <a href="../man3/malloc.html"><i>malloc</i>(3)</a>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The routines <i>runesprint</i>, <i>runesnprint</i>, <i>runeseprint</i>, and <i>runesmprint</i> + are the same as <i>sprint</i>, <i>snprint</i>, <i>seprint</i> and <i>smprint</i> except that + their output is rune strings instead of byte strings. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Finally, the routines <i>vfprint</i>, <i>vsnprint</i>, <i>vseprint</i>, <i>vsmprint</i>, <i>runevsnprint</i>, + <i>runevseprint</i>, and <i>runevsmprint</i> are like their <tt><font size=+1>v−less</font></tt> relatives + except they take as arguments a <tt><font size=+1>va_list</font></tt> parameter, so they can + be called within a variadic function. The Example section shows + a representative usage. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Each of these functions converts, formats, and prints its trailing + arguments under control of a <i>format</i> string. The format contains + two types of objects: plain characters, which are simply copied + to the output stream, and conversion specifications, each of which + results in fetching of zero or more arguments. The results + are undefined if there are arguments of the wrong type or too + few arguments for the format. If the format is exhausted while + arguments remain, the excess is ignored. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Each conversion specification has the following format:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>% [flags] verb + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + The verb is a single character and each flag is a single character + or a (decimal) numeric string. Up to two numeric strings may be + used; the first is called <i>width</i>, the second <i>precision</i>. A period + can be used to separate them, and if the period is present then + <i>width</i> and <i>precision</i> are taken to be zero if missing, otherwise + they are ‘omitted’. Either or both of the numbers may be replaced + with the character <tt><font size=+1>*</font></tt>, meaning that the actual number will be obtained + from the argument list as an integer. The flags and numbers are + arguments to the <i>verb</i> described below. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The numeric verbs <tt><font size=+1>d</font></tt>, <tt><font size=+1>o</font></tt>, <tt><font size=+1>b</font></tt>, <tt><font size=+1>x</font></tt>, and <tt><font size=+1>X</font></tt> format their arguments in + decimal, octal, binary, hexadecimal, and upper case hexadecimal. + Each interprets the flags <tt><font size=+1>0</font></tt>, <tt><font size=+1>h</font></tt>, <tt><font size=+1>hh</font></tt>, <tt><font size=+1>l</font></tt>, <tt><font size=+1>u</font></tt>, <tt><font size=+1>+</font></tt>, <tt><font size=+1>−</font></tt>, <tt><font size=+1>,</font></tt>, and <tt><font size=+1>#</font></tt> to mean + pad with zeros, short, byte, long, unsigned, always print a sign, + left justified, commas every three digits, and alternate format. + Also, a space character in the flag position is like <tt><font size=+1>+</font></tt>, but prints + a space instead of a plus sign for non-negative values. If neither + short nor long is specified, then the argument is an <tt><font size=+1>int</font></tt>. If unsigned + is specified, then the argument is interpreted as a positive number + and no sign is output. If two <tt><font size=+1>l</font></tt> flags are given, then + the argument is interpreted as a <tt><font size=+1>vlong</font></tt> (usually an 8-byte, sometimes + a 4-byte integer). If <i>precision</i> is not omitted, the number is + padded on the left with zeros until at least <i>precision</i> digits + appear. If <i>precision</i> is explicitly 0, and the number is 0, no + digits are generated, and alternate formatting does not apply. + Then, + if alternate format is specified, for <tt><font size=+1>o</font></tt> conversion, the number + is preceded by a <tt><font size=+1>0</font></tt> if it doesn’t already begin with one; for <tt><font size=+1>x</font></tt> + conversion, the number is preceded by <tt><font size=+1>0x</font></tt>; for <tt><font size=+1>X</font></tt> conversion, the + number is preceded by <tt><font size=+1>0X</font></tt>. Finally, if <i>width</i> is not omitted, the + number is padded on the left (or right, if left justification + is specified) + with enough blanks to make the field at least <i>width</i> characters + long. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The floating point verbs <tt><font size=+1>f</font></tt>, <tt><font size=+1>e</font></tt>, <tt><font size=+1>E</font></tt>, <tt><font size=+1>g</font></tt>, and <tt><font size=+1>G</font></tt> take a <tt><font size=+1>double</font></tt> argument. + Each interprets the flags <tt><font size=+1>0</font></tt>, <tt><font size=+1>L +</font></tt>, <tt><font size=+1>−</font></tt>, and <tt><font size=+1>#</font></tt> to mean pad with zeros, + long double argument, always print a sign, left justified, and + alternate format. <i>Width</i> is the minimum field width and, if the + converted value takes up less than <i>width</i> characters, it is + padded on the left (or right, if ‘left justified’) with spaces. + <i>Precision</i> is the number of digits that are converted after the + decimal place for <tt><font size=+1>e</font></tt>, <tt><font size=+1>E</font></tt>, and <tt><font size=+1>f</font></tt> conversions, and <i>precision</i> is the + maximum number of significant digits for <tt><font size=+1>g</font></tt> and <tt><font size=+1>G</font></tt> conversions. + The <tt><font size=+1>f</font></tt> verb produces output of the form [<tt><font size=+1>−</font></tt>]<tt><font size=+1>digits</font></tt>[<tt><font size=+1>.digits</font></tt>]. <tt><font size=+1>E + </font></tt>conversion appends an exponent <tt><font size=+1>E</font></tt>[<tt><font size=+1>−</font></tt>]<tt><font size=+1>digits</font></tt>, and <tt><font size=+1>e</font></tt> conversion appends + an exponent <tt><font size=+1>e</font></tt>[<tt><font size=+1>−</font></tt>]<tt><font size=+1>digits</font></tt>. The <tt><font size=+1>g</font></tt> verb will output the argument in + either <tt><font size=+1>e</font></tt> or <tt><font size=+1>f</font></tt> with the goal of producing the smallest output. + Also, trailing zeros are omitted from the fraction part of the + output, and a trailing decimal point appears only if it is + followed by a digit. The <tt><font size=+1>G</font></tt> verb is similar, but uses <tt><font size=+1>E</font></tt> format + instead of <tt><font size=+1>e</font></tt>. When alternate format is specified, the result will + always contain a decimal point, and for <tt><font size=+1>g</font></tt> and <tt><font size=+1>G</font></tt> conversions, trailing + zeros are not removed. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The <tt><font size=+1>s</font></tt> verb copies a NUL-terminated string (pointer to <tt><font size=+1>char</font></tt>) to + the output. The number of characters copied (<i>n</i>) is the minimum + of the size of the string and <i>precision</i>. These <i>n</i> characters are + justified within a field of <i>width</i> characters as described above. + If a <i>precision</i> is given, it is safe for the string not to be nul- + terminated as long as it is at least <i>precision</i> characters (not + bytes!) long. The <tt><font size=+1>S</font></tt> verb is similar, but it interprets its pointer + as an array of runes (see <a href="../man7/utf.html"><i>utf</i>(7)</a>); the runes are converted to + UTF before output. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The <tt><font size=+1>c</font></tt> verb copies a single <tt><font size=+1>char</font></tt> (promoted to <tt><font size=+1>int</font></tt>) justified within + a field of <i>width</i> characters as described above. The <tt><font size=+1>C</font></tt> verb is + similar, but works on runes. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The <tt><font size=+1>p</font></tt> verb formats a pointer value. At the moment, it is a synonym + for <tt><font size=+1>x</font></tt>, but that will change if pointers and integers are different + sizes. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The <tt><font size=+1>r</font></tt> verb takes no arguments; it copies the error string returned + by a call to <a href="../man3/errstr.html"><i>errstr</i>(3)</a>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Custom verbs may be installed using <a href="../man3/fmtinstall.html"><i>fmtinstall</i>(3)</a>.<br> + +</table> +<p><font size=+1><b>EXAMPLE </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + This function prints an error message with a variable number of + arguments and then quits.<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>void fatal(char *msg, ...)<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + char buf[1024], *out;<br> + va_list arg;<br> + out = seprint(buf, buf+sizeof buf, "Fatal error: ");<br> + va_start(arg, msg);<br> + out = vseprint(out, buf+sizeof buf, msg, arg);<br> + va_end(arg);<br> + write(2, buf, out−buf);<br> + exits("fatal error");<br> + + </table> + }<br> + </font></tt> + </table> + +</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/lib9/libfmt<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/fmtinstall.html"><i>fmtinstall</i>(3)</a>, <a href="../man3/fprintf.html"><i>fprintf</i>(3)</a>, <a href="../man7/utf.html"><i>utf</i>(7)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Routines that write to a file descriptor or call <i>malloc</i> set <i>errstr</i>.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The formatting is close to that specified for ANSI <a href="../man3/fprintf.html"><i>fprintf</i>(3)</a>; + the main difference is that <tt><font size=+1>b</font></tt> and <tt><font size=+1>r</font></tt> are not in ANSI and <tt><font size=+1>u</font></tt> is a + flag here instead of a verb. Also, and distinctly not a bug, <i>print</i> + and friends generate UTF rather than ASCII. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + There is no <i>runeprint</i>, <i>runefprint</i>, etc. because runes are byte-order + dependent and should not be written directly to a file; use the + UTF output of <i>print</i> or <i>fprint</i> instead. Also, <i>sprint</i> is deprecated + for safety reasons; use <i>snprint</i>, <i>seprint</i>, or <i>smprint</i> instead. + Safety also precludes the existence of <i>runesprint</i>. + +</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> diff --git a/man/man3/proto.html b/man/man3/proto.html new file mode 100644 index 00000000..59e4fccd --- /dev/null +++ b/man/man3/proto.html @@ -0,0 +1,140 @@ +<head> +<title>proto(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>PROTO(3)</b><td align=right><b>PROTO(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> + + rdproto – parse and process a proto file listing<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 <disk.h><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>typedef void Protoenum(char *new, char *old, Dir *d, void *a)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>typedef void Protowarn(char *msg, void *a)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int rdproto(char *proto, char *root, Protoenum *enm,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Protowarn *warn, void *a)<br> + + </table> + + </table> + </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> + + <i>Rdproto</i> reads and interprets the named <i>proto</i> file relative to + the root directory <i>root</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Each line of the <i>proto</i> file specifies a file to copy. Blank lines + and lines beginning with <tt><font size=+1>#</font></tt> are ignored. Indentation (usually tabs) + is significant, with each level of indentation corresponding to + a level in the file tree. Fields within a line are separated by + white space. The first field is the last path element in the destination + file tree. The second field specifies the permissions. The third + field is the owner of the file, and the fourth is the group owning + the file. The fifth field is the name of the file from which to + copy; this file is read from the current name space, not the source + file tree. All fields except the first are optional. Specifying + <tt><font size=+1>−</font></tt> for + permissions, owner, or group causes <i>rdproto</i> to fetch the corresponding + information from the file rather than override it. (This is the + default behavior when the fields are not present; explicitly specifying + <tt><font size=+1>−</font></tt> is useful when one wishes to set, say, the file owner without + setting the permissions.) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Names beginning with a <tt><font size=+1>$</font></tt> are expanded as environment variables. + If the first file specified in a directory is <tt><font size=+1>*</font></tt>, all of the files + in that directory are considered listed. If the first file is + <tt><font size=+1>+</font></tt>, all of the files are copied, and all subdirectories are recursively + considered listed. All files are considered relative to <i>root</i>. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + For each file named by the <i>proto</i>, <i>enm</i> is called with <i>new</i> pointing + at the name of the file (without the root prefix), <i>old</i> pointing + at the name of the source file (with the root prefix, when applicable), + and <i>Dir</i> at the desired directory information for the new file. + Only the <tt><font size=+1>name</font></tt>, <tt><font size=+1>uid</font></tt>, <tt><font size=+1>gid</font></tt>, <tt><font size=+1>mode</font></tt>, <tt><font size=+1>mtime</font></tt>, and <tt><font size=+1>length</font></tt> fields + are guaranteed to be valid. The argument <i>a</i> is the same argument + passed to <i>rdproto</i>; typically it points at some extra state used + by the enumeration function. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + When files or directories do not exist or cannot be read by <i>rdproto</i>, + it formats a warning message, calls <i>warn</i>, and continues processing; + if <i>warn</i> is nil, <i>rdproto</i> prints the warning message to standard + error. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Rdproto</i> returns zero if <i>proto</i> was processed, –1 if it could not + be opened.<br> + +</table> +<p><font size=+1><b>FILES </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>/sys/lib/sysconfig/proto/</font></tt> directory of prototype files.<br> + <tt><font size=+1>/sys/lib/sysconfig/proto/portproto</font></tt> generic prototype file.<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/libdisk/proto.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="../man8/mk9660.html"><i>mk9660</i>(8)</a>, Plan 9’s <i>mkfs</i>(8)<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> diff --git a/man/man3/pushtls.html b/man/man3/pushtls.html new file mode 100644 index 00000000..ee806701 --- /dev/null +++ b/man/man3/pushtls.html @@ -0,0 +1,261 @@ +<head> +<title>pushtls(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>PUSHTLS(3)</b><td align=right><b>PUSHTLS(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> + + pushtls, tlsClient, tlsServer, initThumbprints, freeThumbprints, + okThumbprint, readcert, readcertchain – attach TLS1 or SSL3 encryption + to a communication channel<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int pushtls(int fd, char *hashalg, char *encalg,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int isclient, char *secret, char *dir) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>#include <mp.h><br> + #include <libsec.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int tlsClient(int fd, TLSconn *conn) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int tlsServer(int fd, TLSconn *conn) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>uchar *readcert(char *filename, int *pcertlen) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>PEMchain *readcertchain(char *filename) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Thumbprint* initThumbprints(char *ok, char *crl) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void freeThumbprints(Thumbprint *table) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int okThumbprint(uchar *hash, Thumbprint *table)<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> + + Transport Layer Security (TLS) comprises a record layer protocol, + doing message digesting and encrypting in the kernel, and a handshake + protocol, doing initial authentication and secret creation at + user level and then starting a data channel in the record protocol. + TLS is nearly the same as SSL 3.0, and the software + should interoperate with implementations of either standard. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + To use just the record layer, as described in Plan 9’s <i>tls</i>(3), + call <i>pushtls</i> to open the record layer device, connect to the communications + channel <i>fd</i>, and start up encryption and message authentication + as specified in <i>hashalg</i>, <i>encalg</i>, and <i>secret</i>. These parameters + must have been arranged at the two ends of the + conversation by other means. For example, <i>hashalg</i> could be <tt><font size=+1>sha1</font></tt>, + <i>encalg</i> could be <tt><font size=+1>rc4_128</font></tt>, and <i>secret</i> could be the base-64 encoding + of two (client-to-server and server-to-client) 20-byte digest + keys and two corresponding 16-byte encryption keys. <i>Pushtls</i> returns + a file descriptor for the TLS data channel. + Anything written to this descriptor will get encrypted and authenticated + and then written to the file descriptor, <i>fd</i>. If <i>dir</i> is non-zero, + the path name of the connection directory is copied into <i>dir</i>. + This path name is guaranteed to be less than 40 bytes long. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Alternatively, call <i>tlsClient</i> to speak the full handshake protocol, + negotiate the algorithms and secrets, and return a new data file + descriptor for the data channel. <i>Conn</i> points to a (caller-allocated) + struct<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef struct TLSconn{<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + char dir[40]; // OUT connection directory<br> + uchar *cert; // IN/OUT certificate<br> + uchar *sessionID; // IN/OUT sessionID<br> + int certlen, sessionIDlen;<br> + void (*trace)(char*fmt, ...);<br> + PEMChain *chain;<br> + + </table> + } TLSconn;<br> + </font></tt> + </table> + defined in <i>tls.h</i>. On input, the caller can provide options such + as <i>cert</i>, the local certificate, and <i>sessionID</i>, used by a client + to resume a previously negotiated security association. On output, + the connection directory is set, as with <tt><font size=+1>listen</font></tt> (see <a href="../man3/dial.html"><i>dial</i>(3)</a>). + The input <i>cert</i> is freed and a freshly allocated copy of the remote’s + certificate is returned in <i>conn</i>, to be checked by the caller according + to its needs. One mechanism is supplied by <i>initThumbprints</i> and + <i>freeThumbprints</i> which allocate and free, respectively, a table + of hashes from files of known trusted and revoked certificates. + <i>okThumbprint</i> confirms that a particular hash is in the + table, as computed by + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>uchar hash[SHA1dlen];<br> + conn = (TLSconn*)mallocz(sizeof *conn, 1);<br> + fd = tlsClient(fd, conn);<br> + sha1(conn−>cert, conn−>certlen, hash, nil);<br> + if(!okThumbprint(hash,table))<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + exits("suspect server");<br> + + </table> + ...application begins...<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + Call <i>tlsServer</i> to perform the corresponding function on the server + side: + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>fd = accept(lcfd, ldir);<br> + conn = (TLSconn*)mallocz(sizeof *conn, 1);<br> + conn−>cert = readcert("cert.pem", &conn−>certlen);<br> + fd = tlsServer(fd, conn);<br> + ...application begins...<br> + </font></tt> + </table> + The private key corresponding to <i>cert.pem</i> should have been previously + loaded into factotum. (See <a href="../man3/rsa.html"><i>rsa</i>(3)</a> for more about key generation.) + By setting<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>conn−>chain = readcertchain("intermediate−certs.pem");<br> + </font></tt> + </table> + the server can present extra certificate evidence to establish + the chain of trust to a root authority known to the client. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Conn</i> is not required for the ongoing conversation and may be freed + by the application whenever convenient.<br> + +</table> +<p><font size=+1><b>FILES </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>/sys/lib/tls<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + thumbprints of trusted services<br> + + </table> + <tt><font size=+1>/sys/lib/ssl<br> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + PEM certificate files<br> + + </table> + +</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/libsec/port<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/dial.html"><i>dial</i>(3)</a>, <a href="../man7/thumbprint.html"><i>thumbprint</i>(7)</a>; Plan 9’s <i>factotum</i>(4) and <i>tls</i>(3)<br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + return –1 on failure.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Pushtls</i> is not implemented. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Client certificates and client sessionIDs are not yet implemented. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Note that in the TLS protocol <i>sessionID</i> itself is public; it is + used as a pointer to secrets stored in factotum.<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> diff --git a/man/man3/qball.html b/man/man3/qball.html new file mode 100644 index 00000000..b1403336 --- /dev/null +++ b/man/man3/qball.html @@ -0,0 +1,111 @@ +<head> +<title>qball(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>QBALL(3)</b><td align=right><b>QBALL(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> + + qball – 3-d rotation controller<br> + +</table> +<p><font size=+1><b>SYNOPSIS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>#include <draw.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include <geometry.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void qball(Rectangle r, Mouse *mousep,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Quaternion *orientation,<br> + void (*redraw)(void), Quaternion *ap)<br> + + </table> + </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> + + <i>Qball</i> is an interactive controller that allows arbitrary 3-space + rotations to be specified with the mouse. Imagine a sphere with + its center at the midpoint of rectangle <i>r</i>, and diameter the smaller + of <i>r</i>’s dimensions. Dragging from one point on the sphere to another + specifies the endpoints of a great-circle arc. (Mouse + points outside the sphere are projected to the nearest point on + the sphere.) The axis of rotation is normal to the plane of the + arc, and the angle of rotation is twice the angle of the arc. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Argument <i>mousep</i> is a pointer to the mouse event that triggered + the interaction. It should have some button set. <i>Qball</i> will read + more events into <i>mousep</i>, and return when no buttons are down. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + While <i>qball</i> is reading mouse events, it calls out to the caller-supplied + routine <i>redraw</i>, which is expected to update the screen to reflect + the changing orientation. Argument <i>orientation</i> is the orientation + that <i>redraw</i> should examine, represented as a unit Quaternion (see + <i>quaternion(9.2)).</i> The caller may set it to any + orientation. It will be updated before each call to <i>redraw</i> (and + on return) by multiplying by the rotation specified with the mouse. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + It is possible to restrict <i>qball’s</i> attention to rotations about + a particular axis. If <i>ap</i> is null, the rotation is unconstrained. + Otherwise, the rotation will be about the same axis as <i>*ap</i>. This + is accomplished by projecting points on the sphere to the nearest + point also on the plane through the sphere’s center and normal + to + the axis.<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/libgeometry/qball.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/quaternion.html"><i>quaternion</i>(3)</a><br> + Ken Shoemake, “Animating Rotation with Quaternion Curves”, <i>SIGGRAPH + ’85 Conference Proceedings.<br> + </i> +</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> diff --git a/man/man3/quaternion.html b/man/man3/quaternion.html new file mode 100644 index 00000000..257ebe52 --- /dev/null +++ b/man/man3/quaternion.html @@ -0,0 +1,163 @@ +<head> +<title>quaternion(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>QUATERNION(3)</b><td align=right><b>QUATERNION(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> + + qtom, mtoq, qadd, qsub, qneg, qmul, qdiv, qunit, qinv, qlen, slerp, + qmid, qsqrt – Quaternion arithmetic<br> + +</table> +<p><font size=+1><b>SYNOPSIS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>#include <draw.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include <geometry.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Quaternion qadd(Quaternion q, Quaternion r) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Quaternion qsub(Quaternion q, Quaternion r) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Quaternion qneg(Quaternion q) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Quaternion qmul(Quaternion q, Quaternion r) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Quaternion qdiv(Quaternion q, Quaternion r) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Quaternion qinv(Quaternion q) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>double qlen(Quaternion p) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Quaternion qunit(Quaternion q) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void qtom(Matrix m, Quaternion q) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Quaternion mtoq(Matrix mat) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Quaternion slerp(Quaternion q, Quaternion r, double a) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Quaternion qmid(Quaternion q, Quaternion r) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Quaternion qsqrt(Quaternion q)<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> + + The Quaternions are a non-commutative extension field of the Real + numbers, designed to do for rotations in 3-space what the complex + numbers do for rotations in 2-space. Quaternions have a real component + <i>r</i> and an imaginary vector component <i>v</i>=(<i>i</i>,<i>j</i>,<i>k</i>). Quaternions add + componentwise and multiply according to + the rule (<i>r</i>,<i>v</i>)(<i>s</i>,<i>w</i>)=(<i>rs</i>-<i>v</i>.<i>w</i>, <i>rw</i>+<i>vs</i>+<i>v</i>x<i>w</i>), where . and x are the ordinary + vector dot and cross products. The multiplicative inverse of a + non-zero quaternion (<i>r</i>,<i>v</i>) is (<i>r</i>,<i>-v</i>)/(<i>r</i>2-<i>v</i>.<i>v</i>). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The following routines do arithmetic on quaternions, represented + as<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef struct Quaternion Quaternion;<br> + struct Quaternion{<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + double r, i, j, k;<br> + + </table> + };<br> + </font></tt> + </table> + Name Description<br> + <tt><font size=+1>qadd</font></tt> Add two quaternions.<br> + <tt><font size=+1>qsub</font></tt> Subtract two quaternions.<br> + <tt><font size=+1>qneg</font></tt> Negate a quaternion.<br> + <tt><font size=+1>qmul</font></tt> Multiply two quaternions.<br> + <tt><font size=+1>qdiv</font></tt> Divide two quaternions.<br> + <tt><font size=+1>qinv</font></tt> Return the multiplicative inverse of a quaternion.<br> + <tt><font size=+1>qlen</font></tt> Return <tt><font size=+1>sqrt(q.r*q.r+q.i*q.i+q.j*q.j+q.k*q.k)</font></tt>, the length of + a quaternion.<br> + <tt><font size=+1>qunit</font></tt> Return a unit quaternion (<i>length=1</i>) with components proportional + to <i>q</i>’s. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + A rotation by angle <i>θ</i> about axis <i>A</i> (where <i>A</i> is a unit vector) + can be represented by the unit quaternion <i>q</i>=(cos <i>θ</i>/2, <i>A</i>sin <i>θ</i>/2). + The same rotation is represented by -<i>q</i>; a rotation by -<i>θ</i> about -<i>A</i> + is the same as a rotation by <i>θ</i> about <i>A</i>. The quaternion <i>q</i> transforms + points by (0,<i>x’,y’,z’</i>) = <i>q</i>-1(0,<i>x,y,z</i>)<i>q</i>. Quaternion + multiplication composes rotations. The orientation of an object + in 3-space can be represented by a quaternion giving its rotation + relative to some ‘standard’ orientation. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The following routines operate on rotations or orientations represented + as unit quaternions:<br> + <tt><font size=+1>mtoq</font></tt> Convert a rotation matrix (see <a href="../man3/matrix.html"><i>matrix</i>(3)</a>) to a unit quaternion.<br> + <tt><font size=+1>qtom</font></tt> Convert a unit quaternion to a rotation matrix.<br> + <tt><font size=+1>slerp</font></tt> Spherical lerp. Interpolate between two orientations. The + rotation that carries <i>q</i> to <i>r</i> is <i>q</i>-1<i>r</i>, so <tt><font size=+1>slerp(q, r, t)</font></tt> is <i>q</i>(<i>q</i>-1<i>r</i>)<i>t</i>.<br> + <tt><font size=+1>qmid slerp(q, r, .5)<br> + qsqrt</font></tt> The square root of <i>q</i>. This is just a rotation about the same + axis by half the angle.<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/libgeometry/quaternion.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/matrix.html"><i>matrix</i>(3)</a>, <a href="../man3/qball.html"><i>qball</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> diff --git a/man/man3/quote.html b/man/man3/quote.html new file mode 100644 index 00000000..433c5bfc --- /dev/null +++ b/man/man3/quote.html @@ -0,0 +1,164 @@ +<head> +<title>quote(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>QUOTE(3)</b><td align=right><b>QUOTE(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> + + quotestrdup, quoterunestrdup, unquotestrdup, unquoterunestrdup, + quotestrfmt, quoterunestrfmt, quotefmtinstall, doquote, needsrcquote + – quoted character strings<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char *quotestrdup(char *s) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rune *quoterunestrdup(Rune *s) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char *unquotestrdup(char *s) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rune *unquoterunestrdup(Rune *s) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int quotestrfmt(Fmt*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int quoterunestrfmt(Fmt*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void quotefmtinstall(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int (*doquote)(int c) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int needsrcquote(int c) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </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 routines manipulate character strings, either adding or + removing quotes as necessary. In the quoted form, the strings + are in the style of <a href="../man1/rc.html"><i>rc</i>(1)</a><i>,</i> with single quotes surrounding the + string. Embedded single quotes are indicated by a doubled single + quote. For instance,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>Don't worry!<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + when quoted becomes<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>'Don''t worry!'<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + The empty string is represented by two quotes, <tt><font size=+1>''</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The first four functions act as variants of <tt><font size=+1>strdup</font></tt> (see <a href="../man3/strcat.html"><i>strcat</i>(3)</a>). + Each returns a freshly allocated copy of the string, created using + <a href="../man3/malloc.html"><i>malloc</i>(3)</a>. <i>Quotestrdup</i> returns a quoted copy of <i>s</i>, while <i>unquotestrdup</i> + returns a copy of <i>s</i> with the quotes evaluated. The <i>rune</i> versions + of these functions do the same for strings (see + <a href="../man3/runestrcat.html"><i>runestrcat</i>(3)</a>). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The string returned by <i>quotestrdup</i> or <i>quoterunestrdup</i> has the + following properties:<br> + 1. If the original string <i>s</i> is empty, the returned string is <tt><font size=+1>''</font></tt>.<br> + 2. If <i>s</i> contains no quotes, blanks, or control characters, the + returned string is identical to <i>s</i>.<br> + 3. If <i>s</i> needs quotes to be added, the first character of the returned + string will be a quote. For example, <tt><font size=+1>hello world</font></tt> becomes <tt><font size=+1>'hello + world'</font></tt> not <tt><font size=+1>hello' 'world</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The function pointer <i>doquote</i> is <tt><font size=+1>nil</font></tt> by default. If it is non-nil, + characters are passed to that function to see if they should be + quoted. This mechanism allows programs to specify that characters + other than blanks, control characters, or quotes be quoted. Regardless + of the return value of <i>*doquote</i>, blanks, control + characters, and quotes are always quoted. <i>Needsrcquote</i> is provided + as a <i>doquote</i> function that flags any character special to <a href="../man1/rc.html"><i>rc</i>(1)</a>. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Quotestrfmt</i> and <i>quoterunestrfmt</i> are <a href="../man3/print.html"><i>print</i>(3)</a> formatting routines + that produce quoted strings as output. They may be installed by + hand, but <i>quotefmtinstall</i> installs them under the standard format + characters <tt><font size=+1>q</font></tt> and <tt><font size=+1>Q</font></tt>. (They are not installed automatically.) If + the format string includes the alternate format character <tt><font size=+1>#</font></tt>, + for example <tt><font size=+1>%#q</font></tt>, the printed string will always be quoted; otherwise + quotes will only be provided if necessary to avoid ambiguity. + In <tt><font size=+1><libc.h></font></tt> there are <tt><font size=+1>#pragma</font></tt> statements so the compiler can type-check + uses of <tt><font size=+1>%q</font></tt> and <tt><font size=+1>%Q</font></tt> in <a href="../man3/print.html"><i>print</i>(3)</a> format strings.<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/lib9/quote.c<br> + /usr/local/plan9/src/lib9/fmt/fmtquote.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="../man1/rc.html"><i>rc</i>(1)</a>, <a href="../man3/malloc.html"><i>malloc</i>(3)</a>, <a href="../man3/print.html"><i>print</i>(3)</a>, <a href="../man3/strcat.html"><i>strcat</i>(3)</a><br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Because it is provided by the format library, <i>doquote</i> is a preprocessor + macro defined as <i>fmtdoquote</i>; see <a href="../man3/intro.html"><i>intro</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> diff --git a/man/man3/rand.html b/man/man3/rand.html new file mode 100644 index 00000000..0601c6bf --- /dev/null +++ b/man/man3/rand.html @@ -0,0 +1,190 @@ +<head> +<title>rand(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>RAND(3)</b><td align=right><b>RAND(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> + + rand, lrand, frand, nrand, lnrand, srand, truerand, ntruerand, + fastrand, nfastrand – random number generator<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int rand(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long lrand(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>double frand(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int nrand(int val) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long lnrand(long val) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void srand(long seed) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ulong truerand(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ulong ntruerand(ulong val)<br> + #include <mp.h><br> + #include <libsec.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void genrandom(uchar *buf, int nbytes) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void prng(uchar *buf, int nbytes) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ulong fastrand(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>ulong nfastrand(ulong val)<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> + + <i>Rand</i> returns a uniform pseudo-random number <i>x</i>, 0≤<i>x</i><215. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Lrand</i> returns a uniform <tt><font size=+1>long</font></tt> <i>x</i>, 0≤<i>x</i><231. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Frand</i> returns a uniform <tt><font size=+1>double</font></tt> <i>x</i>, 0.0≤<i>x</i><1.0, This function calls + <i>lrand</i> twice to generate a number with as many as 62 significant + bits of mantissa. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Nrand</i> returns a uniform integer <i>x</i>, 0≤<i>x</i><<i>val. Lnrand</i> is the same, + but returns a <tt><font size=+1>long</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The algorithm is additive feedback with:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + x[n] = (x[n-273] + x[n-607]) mod 231 + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + giving a period of 230 × (2607 – 1). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The generators are initialized by calling <i>srand</i> with whatever + you like as argument. To get a different starting value each time,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>srand(time(0)) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + will work as long as it is not called more often than once per + second. Calling<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>srand(1) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + will initialize the generators to their starting state. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Truerand</i> returns a random unsigned long read from <tt><font size=+1>/dev/random</font></tt>. + Due to the nature of <tt><font size=+1>/dev/random</font></tt>, truerand can only return a few + hundred bits a second. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Ntruerand</i> returns a uniform random integer <i>x</i>, 0≤<i>x</i><<i>val</i>≤<i>232-1. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </i> + <i>Genrandom</i> fills a buffer with bytes from the X9.17 pseudo-random + number generator. The X9.17 generator is seeded by 24 truly random + bytes read from <tt><font size=+1>/dev/random</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Prng</i> uses the native <a href="../man3/rand.html"><i>rand</i>(3)</a> pseudo-random number generator to + fill the buffer. Used with <i>srand</i>, this function can produce a + reproducible stream of pseudo random numbers useful in testing. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Both <i>genrandom</i> and <i>prng</i> may be passed to <i>mprand</i> (see <a href="../man3/mp.html"><i>mp</i>(3)</a>). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Fastrand</i> uses <i>genrandom</i> to return a uniform <tt><font size=+1>unsigned long</font></tt> <i>x</i>, 0≤<i>x</i><<i>232-1. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </i> + <i>Nfastrand</i> uses <i>genrandom</i> to return a uniform <tt><font size=+1>unsigned long</font></tt> <i>x</i>, + 0≤<i>x</i><<i>val</i>≤<i>232-1.<br> + </i> +</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/lib9<br> + /usr/local/plan9/src/libsec/port<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/mp.html"><i>mp</i>(3)</a><br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Truerand</i> and <i>ntruerand</i> maintain a static file descriptor. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + To avoid name conflicts with the underlying system, <i>rand</i>, <i>lrand</i>, + <i>frand</i>, <i>nrand</i>, <i>lnrand</i>, and <i>srand</i> are preprocessor macros defined + as <i>p9rand</i>, <i>p9lrand</i>, and so on; see <a href="../man3/intro.html"><i>intro</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> diff --git a/man/man3/rc4.html b/man/man3/rc4.html new file mode 100644 index 00000000..8c0d374b --- /dev/null +++ b/man/man3/rc4.html @@ -0,0 +1,86 @@ +<head> +<title>rc4(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>RC4(3)</b><td align=right><b>RC4(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> + + setupRC4state, rc4, rc4skip, rc4back - alleged rc4 encryption<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 <mp.h><br> + #include <libsec.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void setupRC4state(RC4state *s, uchar *seed, int slen) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void rc4(RC4state *s, uchar *data, int dlen) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void rc4skip(RC4state *s, int nbytes) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void rc4back(RC4state *s, int nbytes)<br> + </font></tt> +</table> +<p><font size=+1><b>DESCRIPTION </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + This is an algorithm alleged to be Rivest’s RC4 encryption function. + It is a pseudo-random number generator with a 256 byte state and + a long cycle. The input buffer is XOR’d with the output of the + generator both to encrypt and to decrypt. The seed, entered using + <i>setupRC4state</i>, can be any length. The generator can + be run forward using <i>rc4</i>, skip over bytes using <i>rc4skip</i> to account + lost transmissions, or run backwards using <i>rc4back</i> to cover retransmitted + data. The <i>RC4state</i> structure keeps track of the algorithm.<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/libsec<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/mp.html"><i>mp</i>(3)</a>, <a href="../man3/aes.html"><i>aes</i>(3)</a>, <a href="../man3/blowfish.html"><i>blowfish</i>(3)</a>, <a href="../man3/des.html"><i>des</i>(3)</a>, <a href="../man3/dsa.html"><i>dsa</i>(3)</a>, <a href="../man3/elgamal.html"><i>elgamal</i>(3)</a>, <a href="../man3/rsa.html"><i>rsa</i>(3)</a>, + <a href="../man3/sechash.html"><i>sechash</i>(3)</a>, <a href="../man3/prime.html"><i>prime</i>(3)</a>, <a href="../man3/rand.html"><i>rand</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> diff --git a/man/man3/read.html b/man/man3/read.html new file mode 100644 index 00000000..515c3f77 --- /dev/null +++ b/man/man3/read.html @@ -0,0 +1,109 @@ +<head> +<title>read(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>READ(3)</b><td align=right><b>READ(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> + + read, readn, write, pread, pwrite – read or write file<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long read(int fd, void *buf, long nbytes) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long readn(int fd, void *buf, long nbytes) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long write(int fd, void *buf, long nbytes) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long pread(int fd, void *buf, long nbytes, vlong offset) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long pwrite(int fd, void *buf, long nbytes, vlong offset)<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> + + <i>Read</i> reads <i>nbytes</i> bytes of data from the offset in the file associated + with <i>fd</i> into memory at <i>buf</i>. The offset is advanced by the number + of bytes read. It is not guaranteed that all <i>nbytes</i> bytes will + be read; for example if the file refers to the console, at most + one line will be returned. In any event the number of bytes + read is returned. A return value of 0 is conventionally interpreted + as end of file. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Readn</i> is just like read, but does successive <i>read</i> calls until + <i>nbytes</i> have been read, or a read system call returns a non-positive + count. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Write</i> writes <i>nbytes</i> bytes of data starting at <i>buf</i> to the file + associated with <i>fd</i> at the file offset. The offset is advanced + by the number of bytes written. The number of characters actually + written is returned. It should be regarded as an error if this + is not the same as requested. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Pread</i> and <i>Pwrite</i> equivalent to a <a href="../man3/seek.html"><i>seek</i>(3)</a> to <i>offset</i> followed by + a <i>read</i> or <i>write</i>. By combining the operations in a single atomic + call, they more closely match the 9P protocol (see <i>intro</i>(9p)) + and, more important, permit multiprocess programs to execute multiple + concurrent read and write operations on the same file + descriptor without interference.<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/lib9/readn.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/intro.html"><i>intro</i>(3)</a>, <a href="../man3/open.html"><i>open</i>(3)</a>, <a href="../man3/dup.html"><i>dup</i>(3)</a>, <a href="../man3/pipe.html"><i>pipe</i>(3)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + These functions set <i>errstr</i>.<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> diff --git a/man/man3/regexp.html b/man/man3/regexp.html new file mode 100644 index 00000000..21e1849b --- /dev/null +++ b/man/man3/regexp.html @@ -0,0 +1,178 @@ +<head> +<title>regexp(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>REGEXP(3)</b><td align=right><b>REGEXP(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> + + regcomp, regcomplit, regcompnl, regexec, regsub, rregexec, rregsub, + regerror – regular expression<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 <regexp.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Reprog *regcomp(char *exp) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Reprog *regcomplit(char *exp) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Reprog *regcompnl(char *exp) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int regexec(Reprog *prog, char *string, Resub *match, int msize)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void regsub(char *source, char *dest, int dlen, Resub *match, + int msize)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int rregexec(Reprog *prog, Rune *string, Resub *match, int msize)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void rregsub(Rune *source, Rune *dest, int dlen, Resub *match, + int msize)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void regerror(char *msg)<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> + + <i>Regcomp</i> compiles a regular expression and returns a pointer to + the generated description. The space is allocated by <a href="../man3/malloc.html"><i>malloc</i>(3)</a> + and may be released by <i>free</i>. Regular expressions are exactly as + in <a href="../man7/regexp.html"><i>regexp</i>(7)</a>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Regcomplit</i> is like <i>regcomp</i> except that all characters are treated + literally. <i>Regcompnl</i> is like <i>regcomp</i> except that the <tt><font size=+1>.</font></tt> metacharacter + matches all characters, including newlines. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Regexec</i> matches a null-terminated <i>string</i> against the compiled + regular expression in <i>prog</i>. If it matches, <i>regexec</i> returns <tt><font size=+1>1</font></tt> and + fills in the array <i>match</i> with character pointers to the substrings + of <i>string</i> that correspond to the parenthesized subexpressions + of <i>exp</i>: <tt><font size=+1>match[</font></tt><i>i</i><tt><font size=+1>].sp</font></tt> points to the beginning and + <tt><font size=+1>match[</font></tt><i>i</i><tt><font size=+1>].ep</font></tt> points just beyond the end of the <i>i</i>th substring. (Subexpression + <i>i</i> begins at the <i>i</i>th left parenthesis, counting from 1.) Pointers + in <tt><font size=+1>match[0]</font></tt> pick out the substring that corresponds to the whole + regular expression. Unused elements of <i>match</i> are filled with zeros. + Matches involving <tt><font size=+1>*</font></tt>, <tt><font size=+1>+</font></tt>, and <tt><font size=+1>?</font></tt> are + extended as far as possible. The number of array elements in <i>match</i> + is given by <i>msize</i>. The structure of elements of <i>match</i> is:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef struct {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + union {<br> + char *sp;<br> + Rune *rsp;<br> + } s;<br> + union {<br> + char *ep;<br> + Rune *rep;<br> + } e;<br> + + </table> + } Resub;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + If <tt><font size=+1>match[0].s.sp</font></tt> is nonzero on entry, <i>regexec</i> starts matching + at that point within <i>string</i>. If <tt><font size=+1>match[0].e.ep</font></tt> is nonzero on entry, + the last character matched is the one preceding that point. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Regsub</i> places in <i>dest</i> a substitution instance of <i>source</i> in the + context of the last <i>regexec</i> performed using <i>match</i>. Each instance + of <tt><font size=+1>\</font></tt><i>n</i>, where <i>n</i> is a digit, is replaced by the string delimited + by <tt><font size=+1>match[</font></tt><i>n</i><tt><font size=+1>].sp</font></tt> and <tt><font size=+1>match[</font></tt><i>n</i><tt><font size=+1>].ep</font></tt>. Each instance of <tt><font size=+1>&</font></tt> is replaced + by the string delimited by <tt><font size=+1>match[0].sp</font></tt> and + <tt><font size=+1>match[0].ep</font></tt>. The substitution will always be null terminated and + trimmed to fit into dlen bytes. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Regerror</i>, called whenever an error is detected in <i>regcomp</i>, writes + the string <i>msg</i> on the standard error file and exits. <i>Regerror</i> + can be replaced to perform special error processing. If the user + supplied <i>regerror</i> returns rather than exits, <i>regcomp</i> will return + 0. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Rregexec</i> and <i>rregsub</i> are variants of <i>regexec</i> and <i>regsub</i> that use + strings of <tt><font size=+1>Runes</font></tt> instead of strings of <tt><font size=+1>chars</font></tt>. With these routines, + the <i>rsp</i> and <i>rep</i> fields of the <i>match</i> array elements should be used.<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/libregexp<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="../man1/grep.html"><i>grep</i>(1)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Regcomp</i> returns <tt><font size=+1>0</font></tt> for an illegal expression or other failure. + <i>Regexec</i> returns 0 if <i>string</i> is not matched.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + There is no way to specify or match a NUL character; NULs terminate + patterns and strings.<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> diff --git a/man/man3/rfork.html b/man/man3/rfork.html new file mode 100644 index 00000000..f76a61fd --- /dev/null +++ b/man/man3/rfork.html @@ -0,0 +1,118 @@ +<head> +<title>rfork(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>RFORK(3)</b><td align=right><b>RFORK(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> + + rfork – manipulate process state<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int rfork(int flags)<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> + + <i>Rfork</i> is a partial implementation of the Plan 9 system call. It + can be used to manipulate some process state and to create new + processes a la <a href="../man2/fork.html"><i>fork</i>(2)</a>. It cannot be used to create shared-memory + processes (Plan 9’s <tt><font size=+1>RFMEM</font></tt> flag); for that functionality use <i>proccreate</i> + (see <a href="../man3/thread.html"><i>thread</i>(3)</a>). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The <i>flags</i> argument to <i>rfork</i> selects which resources of the invoking + process (parent) are shared by the new process (child) or initialized + to their default values. <i>Flags</i> is the logical OR of some subset + of<br> + <tt><font size=+1>RFPROC</font></tt> If set a new process is created; otherwise changes affect + the current process.<br> + <tt><font size=+1>RFNOWAIT</font></tt> If set, the child process will be dissociated from the + parent. Upon exit the child will leave no <tt><font size=+1>Waitmsg</font></tt> (see <a href="../man3/wait.html"><i>wait</i>(3)</a>) + for the parent to collect.<br> + <tt><font size=+1>RFNOTEG</font></tt> Each process is a member of a group of processes that all + receive notes when a note is sent to the group (see <a href="../man3/postnote.html"><i>postnote</i>(3)</a> + and <a href="../man2/signal.html"><i>signal</i>(2)</a>). The group of a new process is by default the same + as its parent, but if <tt><font size=+1>RFNOTEG</font></tt> is set (regardless of <tt><font size=+1>RFPROC</font></tt>), the + process becomes the first in a new group, isolated + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + from previous processes. In Plan 9, a process can call <tt><font size=+1>rfork(RFNOTEG)</font></tt> + and then be sure that it will no longer receive console interrupts + or other notes. Unix job-control shells put each command in its + own process group and then relay notes to the current foreground + command, making the idiom + less useful.<br> + + </table> + + </table> + <tt><font size=+1>RFFDG</font></tt> If set, the invoker’s file descriptor table (see <i>intro</i>(<i>))</i> + is copied; otherwise the two processes share a single table. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + File descriptors in a shared file descriptor table are kept open + until either they are explicitly closed or all processes sharing + the table exit. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + If <tt><font size=+1>RFPROC</font></tt> is set, the value returned in the parent process is + the process id of the child process; the value returned in the + child is zero. Without <tt><font size=+1>RFPROC</font></tt>, the return value is zero. Process + ids range from 1 to the maximum integer (<tt><font size=+1>int</font></tt>) value. <i>Rfork</i> will + sleep, if necessary, until required process resources are available. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Calling <tt><font size=+1>rfork(RFFDG|RFPROC)</font></tt> is equivalent to calling <a href="../man2/fork.html"><i>fork</i>(2)</a>.<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/lib9/rfork.c<br> + </font></tt> +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Rfork</i> sets <i>errstr</i>.<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> diff --git a/man/man3/rsa.html b/man/man3/rsa.html new file mode 100644 index 00000000..0cfd2949 --- /dev/null +++ b/man/man3/rsa.html @@ -0,0 +1,262 @@ +<head> +<title>rsa(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>RSA(3)</b><td align=right><b>RSA(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> + + asn1dump, asn1toRSApriv, decodepem, decodepemchain, rsadecrypt, + rsaencrypt, rsafill,, rsagen, rsaprivalloc, rsaprivfree, rsaprivtopub, + rsapuballoc, rsapubfree, X509toRSApub, X509dump, X509gen, X509req, + X509verify – RSA encryption algorithm<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 <mp.h><br> + #include <libsec.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>RSApriv* rsagen(int nlen, int elen, int nrep) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>RSApriv* rsafill(mpint *n, mpint *ek, mpint *dk, mpint *p, mpint + *q) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>mpint* rsaencrypt(RSApub *k, mpint *in, mpint *out) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>mpint* rsadecrypt(RSApriv *k, mpint *in, mpint *out) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>RSApub* rsapuballoc(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void rsapubfree(RSApub*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>RSApriv* rsaprivalloc(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void rsaprivfree(RSApriv*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>RSApub* rsaprivtopub(RSApriv*) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>RSApub* X509toRSApub(uchar *cert, int ncert, char *name, int nname) + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>RSApriv* asn1toRSApriv(uchar *priv, int npriv) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void asn1dump(uchar *der, int len) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>uchar* decodepem(char *s, char *type, int *len) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>PEMChain* decodepemchain(char *s, char *type) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void X509dump(uchar *cert, int ncert) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>uchar* X509gen(RSApriv *priv, char *subj, ulong valid[2], int + *certlen); + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>uchar* X509req(RSApriv *priv, char *subj, int *certlen); + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* X509verify(uchar *cert, int ncert, RSApub *pk)<br> + </font></tt> +</table> +<p><font size=+1><b>DESCRIPTION </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + RSA is a public key encryption algorithm. The owner of a key publishes + the public part of the key:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>struct RSApub<br> + {<br> + mpint*n;// modulus<br> + mpint*ek;// exp (encryption key)<br> + };<br> + </font></tt> + </table> + + </table> + This part can be used for encrypting data (with <i>rsaencrypt</i>) to + be sent to the owner. The owner decrypts (with <i>rsadecrypt</i>) using + his private key:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>struct RSApriv<br> + {<br> + RSApubpub;<br> + mpint*dk;// exp (decryption key)<br> + <br> + // precomputed crt values<br> + mpint*p;<br> + mpint*q;<br> + mpint*kp;// k mod p−1<br> + mpint*kq;// k mod q−1<br> + mpint*c2;// for converting residues to number<br> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + + </table> + Keys are generated using <i>rsagen</i>. <i>Rsagen</i> takes both bit length + of the modulus, the bit length of the public key exponent, and + the number of repetitions of the Miller-Rabin primality test to + run. If the latter is 0, it does the default number of rounds. + <i>Rsagen</i> returns a newly allocated structure containing both public + and + private keys. <i>Rsaprivtopub</i> returns a newly allocated copy of the + public key corresponding to the private key. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Rsafill</i> takes as input the bare minimum pieces of an RSA private + key and computes the rest (<tt><font size=+1>kp</font></tt>, <tt><font size=+1>kq</font></tt>, and <tt><font size=+1>c2</font></tt>). It returns a new private + key. All the <tt><font size=+1>mpint</font></tt>s in the key, even the ones that correspond + directly to <i>rsafill</i>’s input parameters, are freshly allocated, + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The routines <i>rsaalloc</i>, <i>rsafree</i>, <i>rsapuballoc</i>, <i>rsapubfree</i>, <i>rsaprivalloc</i>, + and <i>rsaprivfree</i> are provided to aid in user provided key I/O. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Given a binary X.509 <i>cert</i>, the routine <i>X509toRSApub</i> returns the + public key and, if <i>name</i> is not nil, the CN part of the Distinguished + Name of the certificate’s Subject. (This is conventionally a userid + or a host DNS name.) No verification is done of the certificate + signature; the caller should check the fingerprint, + <i>sha1(cert)</i>, against a table or check the certificate by other + means. X.509 certificates are often stored in PEM format; use + <i>dec64</i> to convert to binary before computing the fingerprint or + calling <i>X509toRSApub</i>. For the special case of certificates signed + by a known trusted key (in a single step, without certificate + chains) + <i>X509verify</i> checks the signature on <i>cert</i>. It returns nil if successful, + else an error string. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>X509dump</i> prints an X.509 certificate to standard ouptut. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>X509gen</i> creates a self-signed X.509 certificate, given an RSA + keypair <i>priv</i>, a issuer/subject string <i>subj</i>, and the starting and + ending validity dates, <i>valid</i>. Length of the allocated binary certificate + is stored in <i>certlen</i>. The subject line is conventionally of the + form<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>"C=US ST=NJ L=07922 O=Lucent OU='Bell Labs' CN=Eric"<br> + </font></tt> + </table> + using the quoting conventions of <i>tokenize</i> (see <a href="../man3/getfields.html"><i>getfields</i>(3)</a>). + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>X509req</i> creates an X.509 certification request. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Asn1toRSApriv</i> converts an ASN1 formatted RSA private key into + the corresponding <tt><font size=+1>RSApriv</font></tt> structure. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Asn1dump</i> prints an ASN1 object to standard output. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Decodepem</i> takes a zero terminated string, <i>s</i>, and decodes the PEM + (privacy-enhanced mail) formatted section for <i>type</i> within it. + If successful, it returns the decoded section and sets <tt><font size=+1>*</font></tt><i>len</i> to + its decoded length. If not, it returns <tt><font size=+1>nil</font></tt>, and <tt><font size=+1>*</font></tt><i>len</i> is undefined. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Decodepemchain</i> is similar but expects a sequence of PEM-formatted + sections and returns a linked list of the decodings:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef struct PEMChain PEMChain<br> + struct PEMChain<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + PEMChain *next;<br> + uchar *pem;<br> + int pemlen;<br> + + </table> + };<br> + </font></tt> + </table> + +</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/libsec<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/mp.html"><i>mp</i>(3)</a>, <a href="../man3/aes.html"><i>aes</i>(3)</a>, <a href="../man3/blowfish.html"><i>blowfish</i>(3)</a>, <a href="../man3/des.html"><i>des</i>(3)</a>, <a href="../man3/dsa.html"><i>dsa</i>(3)</a>, <a href="../man3/elgamal.html"><i>elgamal</i>(3)</a>, <a href="../man3/rc4.html"><i>rc4</i>(3)</a>, + <a href="../man3/sechash.html"><i>sechash</i>(3)</a>, <a href="../man3/prime.html"><i>prime</i>(3)</a>, <a href="../man3/rand.html"><i>rand</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> diff --git a/man/man3/rune.html b/man/man3/rune.html new file mode 100644 index 00000000..2fed11f3 --- /dev/null +++ b/man/man3/rune.html @@ -0,0 +1,157 @@ +<head> +<title>rune(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>RUNE(3)</b><td align=right><b>RUNE(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> + + runetochar, chartorune, runelen, runenlen, fullrune, utfecpy, + utflen, utfnlen, utfrune, utfrrune, utfutf – rune/UTF conversion<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int runetochar(char *s, Rune *r) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int chartorune(Rune *r, char *s) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int runelen(long r) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int runenlen(Rune *r, int n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int fullrune(char *s, int n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* utfecpy(char *s1, char *es1, char *s2) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int utflen(char *s) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int utfnlen(char *s, long n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* utfrune(char *s, long c) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* utfrrune(char *s, long c) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* utfutf(char *s1, char *s2)<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 routines convert to and from a UTF byte stream and runes. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Runetochar</i> copies one rune at <i>r</i> to at most <tt><font size=+1>UTFmax</font></tt> bytes starting + at <i>s</i> and returns the number of bytes copied. <tt><font size=+1>UTFmax</font></tt>, defined as + <tt><font size=+1>3</font></tt> in <tt><font size=+1><libc.h></font></tt>, is the maximum number of bytes required to represent + a rune. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Chartorune</i> copies at most <tt><font size=+1>UTFmax</font></tt> bytes starting at <i>s</i> to one rune + at <i>r</i> and returns the number of bytes copied. If the input is not + exactly in UTF format, <i>chartorune</i> will convert to 0x80 and return + 1. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Runelen</i> returns the number of bytes required to convert <i>r</i> into + UTF. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Runenlen</i> returns the number of bytes required to convert the <i>n</i> + runes pointed to by <i>r</i> into UTF. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Fullrune</i> returns 1 if the string <i>s</i> of length <i>n</i> is long enough + to be decoded by <i>chartorune</i> and 0 otherwise. This does not guarantee + that the string contains a legal UTF encoding. This routine is + used by programs that obtain input a byte at a time and need to + know when a full rune has arrived. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The following routines are analogous to the corresponding string + routines with <tt><font size=+1>utf</font></tt> substituted for <tt><font size=+1>str</font></tt> and <tt><font size=+1>rune</font></tt> substituted for + <tt><font size=+1>chr</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Utfecpy</i> copies UTF sequences until a null sequence has been copied, + but writes no sequences beyond <i>es1</i>. If any sequences are copied, + <i>s1</i> is terminated by a null sequence, and a pointer to that sequence + is returned. Otherwise, the original <i>s1</i> is returned. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Utflen</i> returns the number of runes that are represented by the + UTF string <i>s</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Utfnlen</i> returns the number of complete runes that are represented + by the first <i>n</i> bytes of UTF string <i>s</i>. If the last few bytes of + the string contain an incompletely coded rune, <i>utfnlen</i> will not + count them; in this way, it differs from <i>utflen</i>, which includes + every byte of the string. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Utfrune</i> (<i>utfrrune</i>) returns a pointer to the first (last) occurrence + of rune <i>c</i> in the UTF string <i>s</i>, or 0 if <i>c</i> does not occur in the + string. The NUL byte terminating a string is considered to be + part of the string <i>s</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Utfutf</i> returns a pointer to the first occurrence of the UTF string + <i>s2</i> as a UTF substring of <i>s1</i>, or 0 if there is none. If <i>s2</i> is the + null string, <i>utfutf</i> returns <i>s1</i>.<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/lib9/utf/rune.c<br> + /usr/local/plan9/src/lib9/utf/utfrune.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="../man7/utf.html"><i>utf</i>(7)</a>, <a href="../man1/tcs.html"><i>tcs</i>(1)</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> diff --git a/man/man3/runestrcat.html b/man/man3/runestrcat.html new file mode 100644 index 00000000..4774265c --- /dev/null +++ b/man/man3/runestrcat.html @@ -0,0 +1,107 @@ +<head> +<title>runestrcat(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>RUNESTRCAT(3)</b><td align=right><b>RUNESTRCAT(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> + + runestrcat, runestrncat, runestrcmp, runestrncmp, runestrcpy, + runestrncpy, runestrecpy, runestrlen, runestrchr, runestrrchr, + runestrdup, runestrstr – rune string operations<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rune* runestrcat(Rune *s1, Rune *s2) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rune* runestrncat(Rune *s1, Rune *s2, long n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int runestrcmp(Rune *s1, Rune *s2) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int runestrncmp(Rune *s1, Rune *s2, long n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rune* runestrcpy(Rune *s1, Rune *s2) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rune* runestrncpy(Rune *s1, Rune *s2, long n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rune* runestrecpy(Rune *s1, Rune *es1, Rune *s2) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long runestrlen(Rune *s) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rune* runestrchr(Rune *s, Rune c) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rune* runestrrchr(Rune *s, Rune c) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rune* runestrdup(Rune *s) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Rune* runestrstr(Rune *s1, Rune *s2)<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 functions are rune string analogues of the corresponding + functions in <a href="../man3/strcat.html"><i>strcat</i>(3)</a>.<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/lib9<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/memory.html"><i>memory</i>(3)</a>, <a href="../man3/rune.html"><i>rune</i>(3)</a>, <a href="../man3/strcat.html"><i>strcat</i>(3)</a><br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The outcome of overlapping moves varies among implementations.<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> diff --git a/man/man3/sechash.html b/man/man3/sechash.html new file mode 100644 index 00000000..2e055465 --- /dev/null +++ b/man/man3/sechash.html @@ -0,0 +1,195 @@ +<head> +<title>sechash(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>SECHASH(3)</b><td align=right><b>SECHASH(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> + + md4, md5, sha1, hmac_md5, hmac_sha1, md5pickle, md5unpickle, sha1pickle, + sha1unpickle – cryptographically secure hashes<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 <mp.h><br> + #include <libsec.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>DigestState* md4(uchar *data, ulong dlen, uchar *digest, DigestState + *state) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>DigestState* md5(uchar *data, ulong dlen, uchar *digest, DigestState + *state) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* md5pickle(MD5state *state) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>MD5state* md5unpickle(char *p); + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>DigestState* sha1(uchar *data, ulong dlen, uchar *digest, DigestState + *state) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* sha1pickle(MD5state *state) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>MD5state* sha1unpickle(char *p); + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>DigestState* hmac_md5(uchar *data, ulong dlen,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + uchar *key, ulong klen,<br> + uchar *digest, DigestState *state) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>DigestState* hmac_sha1(uchar *data, ulong dlen,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + uchar *key, ulong klen,<br> + uchar *digest, DigestState *state)<br> + + </table> + + </table> + </font></tt> +</table> +<p><font size=+1><b>DESCRIPTION </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + These functions implement the cryptographic hash functions MD4, + MD5, and SHA1. The output of the hash is called a <i>digest</i>. A hash + is secure if, given the hashed data and the digest, it is difficult + to predict the change to the digest resulting from some change + to the data without rehashing the whole data. Therefore, if + a secret is part of the hashed data, the digest can be used as + an integrity check of the data by anyone possessing the secret. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The routines <i>md4</i>, <i>md5</i>, <i>sha1</i>, <i>hmac_md5</i>, and <i>hmac_sha1</i> differ only + in the length of the resulting digest and in the security of the + hash. Usage for each is the same. The first call to the routine + should have <tt><font size=+1>nil</font></tt> as the <i>state</i> parameter. This call returns a state + which can be used to chain subsequent calls. The last call + should have digest non-nil. <i>Digest</i> must point to a buffer of at + least the size of the digest produced. This last call will free + the state and copy the result into <i>digest</i>. For example, to hash + a single buffer using <i>md5</i>:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>uchar digest[MD5dlen];<br> + md5(data, len, digest, nil);<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + To chain a number of buffers together, bounded on each end by + some secret:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>char buf[256];<br> + uchar digest[MD5dlen];<br> + DigestState *s;<br> + s = md5("my password", 11, nil, nil);<br> + while((n = read(fd, buf, 256)) > 0)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + md5(buf, n, nil, s);<br> + + </table> + md5("drowssap ym", 11, digest, s);<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + The constants <i>MD4dlen</i>, <i>MD5dlen</i>, and <i>SHA1dlen</i> define the lengths + of the digests. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Hmac_md5</i> and <i>hmac_sha1</i> are used slightly differently. These hash + algorithms are keyed and require a key to be specified on every + call. The digest lengths for these hashes are <i>MD5dlen</i> and <i>SHA1dlen</i> + respectively. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The functions <i>md5pickle</i> and <i>sha1pickle</i> marshal the state of a + digest for transmission. <i>Md5unpickle</i> and <i>sha1unpickle</i> unmarshal + a pickled digest. All four routines return a pointer to a newly + <a href="../man3/malloc.html"><i>malloc</i>(3)</a>’d object.<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/libsec<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/aes.html"><i>aes</i>(3)</a>, <a href="../man3/blowfish.html"><i>blowfish</i>(3)</a>, <a href="../man3/des.html"><i>des</i>(3)</a>, <a href="../man3/elgamal.html"><i>elgamal</i>(3)</a>, <a href="../man3/rc4.html"><i>rc4</i>(3)</a>, <a href="../man3/rsa.html"><i>rsa</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> diff --git a/man/man3/seek.html b/man/man3/seek.html new file mode 100644 index 00000000..a2c19651 --- /dev/null +++ b/man/man3/seek.html @@ -0,0 +1,96 @@ +<head> +<title>seek(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>SEEK(3)</b><td align=right><b>SEEK(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> + + seek – change file offset<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>vlong seek(int fd, vlong n, int type)<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> + + <i>Seek</i> sets the offset for the file associated with <i>fd</i> as follows:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + If <i>type</i> is 0, the offset is set to <i>n</i> bytes.<br> + If <i>type</i> is 1, the pointer is set to its current location plus + <i>n</i>.<br> + If <i>type</i> is 2, the pointer is set to the size of the file plus + <i>n</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + The new file offset value is returned. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Seeking in a directory is not allowed. Seeking in a pipe is a + no-op.<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/lib9/seek.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/intro.html"><i>intro</i>(3)</a>, <a href="../man3/open.html"><i>open</i>(3)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Sets <i>errstr</i>.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + To avoid name conflicts with the underlying system, <i>seek</i> is a + preprocessor macro defined as <i>p9seek</i>; see <a href="../man3/intro.html"><i>intro</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> diff --git a/man/man3/sendfd.html b/man/man3/sendfd.html new file mode 100644 index 00000000..37007603 --- /dev/null +++ b/man/man3/sendfd.html @@ -0,0 +1,85 @@ +<head> +<title>sendfd(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>SENDFD(3)</b><td align=right><b>SENDFD(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> + + sendfd, recvfd – pass file descriptors along Unix domain sockets<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include <libc.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int sendfd(int socket, int fd) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int recvfd(int socket)<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> + + <i>Recvfd</i> and <i>sendfd</i> can be used to pass an open file descriptor + over a Unix domain socket from one process to another. Since <a href="../man3/pipe.html"><i>pipe</i>(3)</a> + is implemented with <a href="../man2/socketpair.html"><i>socketpair</i>(2)</a> instead of <a href="../man2/pipe.html"><i>pipe</i>(2)</a>, <i>socket</i> can + be a file descriptor obtained from <a href="../man3/pipe.html"><i>pipe</i>(3)</a>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Sendfd</i> sends the file descriptor <i>fd</i> along the socket to a process + calling <i>recvfd</i> on the other end. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + It is assumed that the two sides have coordinated and agreed to + transfer a file descriptor already, so that the <i>sendfd</i> is met + with a <i>recvfd</i> instead of an ordinary <i>read</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The file descriptor number may change on its way between processes, + but the kernel structure it represents will not.<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/lib9/sendfd.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="../man2/socketpair.html"><i>socketpair</i>(2)</a>, <i>sendmsg</i> in <a href="../man2/send.html"><i>send</i>(2)</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> diff --git a/man/man3/setjmp.html b/man/man3/setjmp.html new file mode 100644 index 00000000..b22431fd --- /dev/null +++ b/man/man3/setjmp.html @@ -0,0 +1,110 @@ +<head> +<title>setjmp(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>SETJMP(3)</b><td align=right><b>SETJMP(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> + + setjmp, longjmp, notejmp – non-local goto<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int setjmp(jmp_buf env) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void longjmp(jmp_buf env, int val) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void notejmp(void *uregs, jmp_buf env, int val)<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 routines are useful for dealing with errors and interrupts + encountered in a low-level subroutine of a program. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Setjmp</i> saves its stack environment in <i>env</i> for later use by <i>longjmp</i>. + It returns value 0. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Longjmp</i> restores the environment saved by the last call of <i>setjmp</i>. + It then causes execution to continue as if the call of <i>setjmp</i> + had just returned with value <i>val</i>. The invoker of <i>setjmp</i> must not + itself have returned in the interim. All accessible data have + values as of the time <i>longjmp</i> was called. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Notejmp</i> is the same as <i>longjmp</i> except that it is to be called + from within a note handler (see <a href="../man3/notify.html"><i>notify</i>(3)</a>). The <i>uregs</i> argument + should be the first argument passed to the note handler. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Setjmp</i> and <i>longjmp</i> can also be used to switch stacks.<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/lib9/jmp.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/notify.html"><i>notify</i>(3)</a><br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <i>Notejmp</i> cannot recover from an address trap or bus error (page + fault) on the 680x0 architectures. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + To avoid name conflicts with the underlying system, <i>setjmp</i>, <i>longjmp</i>, + <i>notejmp</i>, and <i>jmp_buf</i> are preprocessor macros defined as <i>p9setjmp</i>, + <i>p9longjmp</i>, <i>p9notejmp</i>, and <i>p9jmp_buf</i>; see <a href="../man3/intro.html"><i>intro</i>(3)</a>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>P9setjmp</i> is implemented as a preprocessor macro that calls <i>sigsetjmp</i> + (see Unix’s <i>setjmp</i>(3)).<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> diff --git a/man/man3/sleep.html b/man/man3/sleep.html new file mode 100644 index 00000000..6614f33a --- /dev/null +++ b/man/man3/sleep.html @@ -0,0 +1,95 @@ +<head> +<title>sleep(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>SLEEP(3)</b><td align=right><b>SLEEP(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> + + sleep, alarm – delay, ask for delayed note<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int sleep(long millisecs) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long alarm(unsigned long millisecs)<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> + + <i>Sleep</i> suspends the current process for the number of milliseconds + specified by the argument. The actual suspension time may be a + little more or less than the requested time. If <i>millisecs</i> is 0, + the process gives up the CPU if another process is waiting to + run, returning immediately if not. Sleep returns –1 if interrupted, + 0 otherwise. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Alarm</i> causes an <tt><font size=+1>alarm</font></tt> note (see <a href="../man3/notify.html"><i>notify</i>(3)</a>) to be sent to the invoking + process after the number of milliseconds given by the argument. + Successive calls to <i>alarm</i> reset the alarm clock. A zero argument + clears the alarm. The return value is the amount of time previously + remaining in the alarm clock. + +</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/lib9/sleep.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/intro.html"><i>intro</i>(3)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + These functions set <i>errstr</i>.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + To avoid name conflicts with the underlying system, <i>sleep</i> and + <i>alarm</i> are preprocessor macros defined as <i>p9sleep</i> and <i>p9alarm</i>; + see <a href="../man3/intro.html"><i>intro</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> diff --git a/man/man3/stat.html b/man/man3/stat.html new file mode 100644 index 00000000..fb79a647 --- /dev/null +++ b/man/man3/stat.html @@ -0,0 +1,244 @@ +<head> +<title>stat(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>STAT(3)</b><td align=right><b>STAT(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> + + stat, fstat, wstat, fwstat, dirstat, dirfstat, dirwstat, dirfwstat, + nulldir – get and put file status<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int stat(char *name, uchar *edir, int nedir) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int fstat(int fd, uchar *edir, int nedir) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int wstat(char *name, uchar *edir, int nedir) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int fwstat(int fd, uchar *edir, int nedir) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Dir* dirstat(char *name) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Dir* dirfstat(int fd) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int dirwstat(char *name, Dir *dir) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int dirfwstat(int fd, Dir *dir) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void nulldir(Dir *d)<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> + + Given a file’s <i>name</i>, or an open file descriptor <i>fd</i>, these routines + retrieve or modify file status information. <i>Stat</i>, <i>fstat</i>, <i>wstat</i>, + and <i>fwstat</i> are the system calls; they deal with machine-independent + <i>directory entries</i>. Their format is defined by <i>stat</i>(9p). <i>Stat</i> and + <i>fstat</i> retrieve information about <i>name</i> or <i>fd</i> into <i>edir</i>, a buffer + of length <i>nedir</i>, defined in <tt><font size=+1><libc.h></font></tt>. <i>Wstat</i> and <i>fwstat</i> write information + back, thus changing file attributes according to the contents + of <i>edir</i>. The data returned from the kernel includes its leading + 16-bit length field as described in <i>intro</i>(9p). For symmetry, this + field must also be present when passing data to the + kernel in a call to <i>wstat</i> and <i>fwstat</i>, but its value is ignored. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Dirstat</i>, <i>dirfstat</i>, <i>dirwstat</i>, and <i>dirfwstat</i> are similar to their + counterparts, except that they operate on <i>Dir</i> structures:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef<br> + struct Dir {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + /* system−modified data */<br> + uint type; /* server type */<br> + uint dev; /* server subtype */<br> + /* file data */<br> + Qid qid; /* unique id from server */<br> + ulong mode; /* permissions */<br> + ulong atime; /* last read time */<br> + ulong mtime; /* last write time */<br> + vlong length; /* file length: see <u.h> */<br> + char *name; /* last element of path */<br> + char *uid; /* owner name */<br> + char *gid; /* group name */<br> + char *muid; /* last modifier name */<br> + + </table> + } Dir;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + The returned structure is allocated by <a href="../man3/malloc.html"><i>malloc</i>(3)</a>; freeing it also + frees the associated strings. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + This structure and the <tt><font size=+1>Qid</font></tt> structure are defined in <tt><font size=+1><libc.h></font></tt>. If + the file resides on permanent storage and is not a directory, + the length returned by <i>stat</i> is the number of bytes in the file. + For directories, the length returned is zero. For files that are + streams (e.g., pipes and network connections), the length is the + number of bytes that can be read without blocking. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Each file is the responsibility of some <i>server</i>: it could be a + file server, a kernel device, or a user process. <tt><font size=+1>Type</font></tt> identifies + the server type, and <tt><font size=+1>dev</font></tt> says which of a group of servers of the + same type is the one responsible for this file. <tt><font size=+1>Qid</font></tt> is a structure + containing <tt><font size=+1>path</font></tt> and <tt><font size=+1>vers</font></tt> fields: <tt><font size=+1>path</font></tt> is guaranteed to be + unique among all path names currently on the file server, and + <tt><font size=+1>vers</font></tt> changes each time the file is modified. The <tt><font size=+1>path</font></tt> is a <tt><font size=+1>long + long</font></tt> (64 bits, <tt><font size=+1>vlong</font></tt>) and the <tt><font size=+1>vers</font></tt> is an <tt><font size=+1>unsigned long</font></tt> (32 bits, + <tt><font size=+1>ulong</font></tt>). Thus, if two files have the same <tt><font size=+1>type</font></tt>, <tt><font size=+1>dev</font></tt>, and <tt><font size=+1>qid</font></tt> they + are the same file. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The bits in <tt><font size=+1>mode</font></tt> are defined by + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>0x80000000 </font></tt> directory<br> + <tt><font size=+1>0x40000000 </font></tt> append only<br> + <tt><font size=+1>0x20000000 </font></tt> exclusive use (locked)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>0400 </font></tt> read permission by owner<br> + <tt><font size=+1>0200 </font></tt> write permission by owner<br> + <tt><font size=+1>0100 </font></tt> execute permission (search on directory) by owner<br> + <tt><font size=+1>0070 </font></tt> read, write, execute (search) by group<br> + <tt><font size=+1>0007 </font></tt> read, write, execute (search) by others<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + + </table> + + </table> + There are constants defined in <tt><font size=+1><libc.h></font></tt> for these bits: <tt><font size=+1>DMDIR</font></tt>, <tt><font size=+1>DMAPPEND</font></tt>, + and <tt><font size=+1>DMEXCL</font></tt> for the first three; and <tt><font size=+1>DMREAD</font></tt>, <tt><font size=+1>DMWRITE</font></tt>, and <tt><font size=+1>DMEXEC</font></tt> + for the read, write, and execute bits for others. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The two time fields are measured in seconds since the epoch (Jan + 1 00:00 1970 GMT). <tt><font size=+1>Mtime</font></tt> is the time of the last change of content. + Similarly, <tt><font size=+1>atime</font></tt> is set whenever the contents are accessed; also, + it is set whenever <tt><font size=+1>mtime</font></tt> is set. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>Uid</font></tt> and <tt><font size=+1>gid</font></tt> are the names of the owner and group of the file; + <tt><font size=+1>muid</font></tt> is the name of the user that last modified the file (setting + <tt><font size=+1>mtime</font></tt>). Groups are also users, but each server is free to associate + a list of users with any user name <i>g</i>, and that list is the set + of users in the group <i>g</i>. When an initial attachment is made to + a + server, the user string in the process group is communicated to + the server. Thus, the server knows, for any given file access, + whether the accessing process is the owner of, or in the group + of, the file. This selects which sets of three bits in <tt><font size=+1>mode</font></tt> is + used to check permissions. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Only some of the fields may be changed with the <i>wstat</i> calls. The + <tt><font size=+1>name</font></tt> can be changed by anyone with write permission in the parent + directory. The <tt><font size=+1>mode</font></tt> and <tt><font size=+1>mtime</font></tt> can be changed by the owner or the + group leader of the file’s current group. The <i>gid</i> can be changed: + by the owner if also a member of the new + group; or by the group leader of the file’s current group if also + leader of the new group (see <i>intro</i>(9p) for more information about + permissions, users, and groups). The <tt><font size=+1>length</font></tt> can be changed by + anyone with write permission, provided the operation is implemented + by the server. (See <i>intro</i>(9p) for permission, user, + and group information). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Special values in the fields of the <tt><font size=+1>Dir</font></tt> passed to <i>wstat</i> indicate + that the field is not intended to be changed by the call. The + values are the maximum unsigned integer of appropriate size for + integral values (usually <tt><font size=+1>~0</font></tt>, but beware of conversions and size + mismatches when comparing values) and the empty or nil string + for string values. The routine <i>nulldir</i> initializes all the elements + of <i>d</i> to these “don’t care” values. Thus one may change the mode, + for example, by using <i>nulldir</i> to initialize a <tt><font size=+1>Dir</font></tt>, then setting + the mode, and then doing <i>wstat</i>; it is not necessary to use <i>stat</i> + to retrieve the initial values first. + +</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/lib9/dirstat.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/intro.html"><i>intro</i>(3)</a>, <a href="../man3/fcall.html"><i>fcall</i>(3)</a>, <a href="../man3/dirread.html"><i>dirread</i>(3)</a>, <i>stat</i>(9p)<br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The <i>dir</i> functions return a pointer to the data for a successful + call, or <tt><font size=+1>nil</font></tt> on error. The others return the number of bytes copied + on success, or –1 on error. All set <i>errstr</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + If the buffer for <i>stat</i> or <i>fstat</i> is too short for the returned + data, the return value will be <tt><font size=+1>BIT16SZ</font></tt> (see <a href="../man3/fcall.html"><i>fcall</i>(3)</a>) and the + two bytes returned will contain the initial count field of the + returned data; retrying with <tt><font size=+1>nedir</font></tt> equal to that value plus <tt><font size=+1>BIT16SZ</font></tt> + (for the count itself) should succeed.<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> diff --git a/man/man3/strcat.html b/man/man3/strcat.html new file mode 100644 index 00000000..542ebd25 --- /dev/null +++ b/man/man3/strcat.html @@ -0,0 +1,203 @@ +<head> +<title>strcat(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>STRCAT(3)</b><td align=right><b>STRCAT(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> + + strcat, strncat, strcmp, strncmp, cistrcmp, cistrncmp, strcpy, + strncpy, strecpy, strlen, strchr, strrchr, strpbrk, strspn, strcspn, + strtok, strdup, strstr, cistrstr – string operations<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* strcat(char *s1, char *s2) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* strncat(char *s1, char *s2, long n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int strcmp(char *s1, char *s2) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int strncmp(char *s1, char *s2, long n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int cistrcmp(char *s1, char *s2) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int cistrncmp(char *s1, char *s2, long n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* strcpy(char *s1, char *s2) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* strecpy(char *s1, char *es1, char *s2) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* strncpy(char *s1, char *s2, long n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long strlen(char *s) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* strchr(char *s, char c) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* strrchr(char *s, char c) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* strpbrk(char *s1, char *s2) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long strspn(char *s1, char *s2) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long strcspn(char *s1, char *s2) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* strtok(char *s1, char *s2) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* strdup(char *s) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* strstr(char *s1, char *s2) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>char* cistrstr(char *s1, char *s2)<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> + + The arguments <i>s1, s2</i> and <i>s</i> point to null-terminated strings. The + functions <i>strcat</i>, <i>strncat</i>, <i>strcpy</i>, <i>strecpy</i>, and <i>strncpy</i> all alter + <i>s1</i>. <i>Strcat</i> and <i>strcpy</i> do not check for overflow of the array pointed + to by <i>s1</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Strcat</i> appends a copy of string <i>s2</i> to the end of string <i>s1</i>. <i>Strncat</i> + appends at most <i>n</i> bytes. Each returns a pointer to the null-terminated + result. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Strcmp</i> compares its arguments and returns an integer less than, + equal to, or greater than 0, according as <i>s1</i> is lexicographically + less than, equal to, or greater than <i>s2</i>. <i>Strncmp</i> makes the same + comparison but examines at most <i>n</i> bytes. <i>Cistrcmp</i> and <i>cistrncmp</i> + ignore ASCII case distinctions when comparing strings. + The comparisons are made with unsigned bytes. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Strcpy</i> copies string <i>s2</i> to <i>s1</i>, stopping after the null byte has + been copied. <i>Strncpy</i> copies exactly <i>n</i> bytes, truncating <i>s2</i> or + adding null bytes to <i>s1</i> if necessary. The result will not be null-terminated + if the length of <i>s2</i> is <i>n</i> or more. Each function returns <i>s1</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Strecpy</i> copies bytes until a null byte has been copied, but writes + no bytes beyond <i>es1</i>. If any bytes are copied, <i>s1</i> is terminated + by a null byte, and a pointer to that byte is returned. Otherwise, + the original <i>s1</i> is returned. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Strlen</i> returns the number of bytes in <i>s</i>, not including the terminating + null byte. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Strchr</i> (<i>strrchr</i>) returns a pointer to the first (last) occurrence + of byte <i>c</i> in string <i>s</i>, or <tt><font size=+1>0</font></tt> if <i>c</i> does not occur in the string. + The null byte terminating a string is considered to be part of + the string. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Strpbrk</i> returns a pointer to the first occurrence in string <i>s1</i> + of any byte from string <i>s2</i>, <tt><font size=+1>0</font></tt> if no byte from <i>s2</i> exists in <i>s1</i>. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Strspn</i> (<i>strcspn</i>) returns the length of the initial segment of + string <i>s1</i> which consists entirely of bytes from (not from) string + <i>s2</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Strtok</i> considers the string <i>s1</i> to consist of a sequence of zero + or more text tokens separated by spans of one or more bytes from + the separator string <i>s2</i>. The first call, with pointer <i>s1</i> specified, + returns a pointer to the first byte of the first token, and will + have written a null byte into <i>s1</i> immediately following the returned + token. The function keeps track of its position in the string + between separate calls; subsequent calls, signified by <i>s1</i> being + <tt><font size=+1>0</font></tt>, will work through the string <i>s1</i> immediately following that + token. The separator string <i>s2</i> may be different from call to call. + When no token remains in <i>s1</i>, <tt><font size=+1>0</font></tt> is returned. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Strdup</i> returns a pointer to a distinct copy of the null-terminated + string <i>s</i> in space obtained from <a href="../man3/malloc.html"><i>malloc</i>(3)</a> or <tt><font size=+1>0</font></tt> if no space can + be obtained. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Strstr</i> returns a pointer to the first occurrence of <i>s2</i> as a substring + of <i>s1</i>, or 0 if there is none. If <i>s2</i> is the null string, <i>strstr</i> + returns <i>s1</i>. <i>Cistrstr</i> operates analogously, but ignores ASCII case + differences when comparing strings.<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/lib9<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/memory.html"><i>memory</i>(3)</a>, <a href="../man3/rune.html"><i>rune</i>(3)</a>, <a href="../man3/runestrcat.html"><i>runestrcat</i>(3)</a><br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + These routines know nothing about UTF. Use the routines in <a href="../man3/rune.html"><i>rune</i>(3)</a> + as appropriate. Note, however, that the definition of UTF guarantees + that <i>strcmp</i> compares UTF strings correctly. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The outcome of overlapping moves varies among implementations.<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> diff --git a/man/man3/string.html b/man/man3/string.html new file mode 100644 index 00000000..55a1673b --- /dev/null +++ b/man/man3/string.html @@ -0,0 +1,244 @@ +<head> +<title>string(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>STRING(3)</b><td align=right><b>STRING(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> + + s_alloc, s_append, s_array, s_copy, s_error, s_free, s_incref, + s_memappend, s_nappend, s_new, s_newalloc, s_parse, s_reset, s_restart, + s_terminate, s_tolower, s_putc, s_unique, s_grow, s_read, s_read_line, + s_getline, s_allocinstack, s_freeinstack, s_rdinstack – extensible + strings<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 <String.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>String* s_new(void)<br> + void s_free(String *s)<br> + String* s_newalloc(int n)<br> + String* s_array(char *p, int n)<br> + String* s_grow(String *s, int n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void s_putc(String *s, int c)<br> + void s_terminate(String *s)<br> + String* s_reset(String *s)<br> + String* s_restart(String *s)<br> + String* s_append(String *s, char *p)<br> + String* s_nappend(String *s, char *p, int n)<br> + String* s_memappend(String *s, char *p, int n)<br> + String* s_copy(char *p)<br> + String* s_parse(String *s1, String *s2)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void s_tolower(String *s) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>String* s_incref(String *s)<br> + String* s_unique(String *s) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Sinstack* s_allocinstack(char *file)<br> + void s_freeinstack(Sinstack *stack)<br> + char* s_rdinstack(Sinstack *stack, String *s) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include <bio.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int s_read(Biobuf *b, String *s, int n)<br> + char* s_read_line(Biobuf *b, String *s)<br> + char* s_getline(Biobuf *b, String *s)<br> + </font></tt> +</table> +<p><font size=+1><b>DESCRIPTION </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + These routines manipulate extensible strings. The basic type is + <tt><font size=+1>String</font></tt>, which points to an array of characters. The string maintains + pointers to the beginning and end of the allocated array. In addition + a finger pointer keeps track of where parsing will start (for + <i>s_parse</i>) or new characters will be added (for <i>s_putc</i>, + <i>s_append</i>, and <i>s_nappend</i>). The structure, and a few useful macros + are:<br> + <tt><font size=+1>typedef struct String {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Lock;<br> + char*base;/* base of String */<br> + char*end;/* end of allocated space+1 */<br> + char*ptr;/* ptr into String */<br> + ...<br> + + </table> + + </table> + } String;<br> + #define s_to_c(s) ((s)−>base)<br> + #define s_len(s) ((s)−>ptr−(s)−>base)<br> + #define s_clone(s) s_copy((s)−>base)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <i>S_to_c</i> is used when code needs a reference to the character array. + Using <tt><font size=+1>s−>base</font></tt> directly is frowned upon since it exposes too much + of the implementation.<br> + <p><font size=+1><b>Allocation and freeing </b></font><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + A string must be allocated before it can be used. One normally + does this using <i>s_new</i>, giving the string an initial allocation + of 128 bytes. If you know that the string will need to grow much + longer, you can use <i>s_newalloc</i> instead, specifying the number + of bytes in the initial allocation. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>S_free</i> causes both the string and its character array to be freed. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>S_grow</i> grows a string’s allocation by a fixed amount. It is useful + if you are reading directly into a string’s character array but + should be avoided if possible. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>S_array</i> is used to create a constant array, that is, one whose + contents won’t change. It points directly to the character array + given as an argument. Tread lightly when using this call.<br> + <p><font size=+1><b>Filling the string </b></font><br> + After its initial allocation, the string points to the beginning + of an allocated array of characters starting with NUL. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>S_putc</i> writes a character into the string at the pointer and advances + the pointer to point after it. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>S_terminate</i> writes a NUL at the pointer but doesn’t advance it. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>S_restart</i> resets the pointer to the begining of the string but + doesn’t change the contents. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>S_reset</i> is equivalent to <i>s_restart</i> followed by <i>s_terminate</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>S_append</i> and <i>s_nappend</i> copy characters into the string at the + pointer and advance the pointer. They also write a NUL at the + pointer without advancing the pointer beyond it. Both routines + stop copying on encountering a NUL. <i>S_memappend</i> is like <i>s_nappend</i> + but doesn’t stop at a NUL. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + If you know the initial character array to be copied into a string, + you can allocate a string and copy in the bytes using <i>s_copy</i>. + This is the equivalent of a <i>s_new</i> followed by an <i>s_append</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>S_parse</i> copies the next white space terminated token from <i>s1</i> to + the end of <i>s2</i>. White space is defined as space, tab, and newline. + Both single and double quoted strings are treated as a single + token. The bounding quotes are not copied. There is no escape + mechanism. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>S_tolower</i> converts all ASCII characters in the string to lower + case.<br> + <p><font size=+1><b>Multithreading </b></font><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>S_incref</i> is used by multithreaded programs to avoid having the + string memory released until the last user of the string performs + an <i>s_free</i>. <i>S_unique</i> returns a unique copy of the string: if the + reference count it 1 it returns the string, otherwise it returns + an <i>s_clone</i> of the string.<br> + <p><font size=+1><b>Bio interaction </b></font><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>S_read</i> reads the requested number of characters through a <i>Biobuf</i> + into a string. The string is grown as necessary. An eof or error + terminates the read. The number of bytes read is returned. The + string is null terminated. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>S_read_line</i> reads up to and including the next newline and returns + a pointer to the beginning of the bytes read. An eof or error + terminates the read. The string is null terminated. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>S_getline</i> reads up to the next newline, appends the input to <i>s</i>, + and returns a pointer to the beginning of the bytes read. Leading + spaces and tabs and the trailing newline are all discarded. <i>S_getline</i> + discards blank lines and lines beginning with <tt><font size=+1>#</font></tt>. <i>S_getline</i> ignores + newlines escaped by immediately-preceding + backslashes. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>S_allocinstack</i> allocates an input stack with the single file <i>file</i> + open for reading. <i>S_freeinstack</i> frees an input stack. <i>S_rdinstack</i> + reads a line from an input stack. It follows the same rules as + <i>s_getline</i> except that when it encounters a line of the form <tt><font size=+1>#include</font></tt> + <i>newfile</i>, <i>s_getline</i> pushes <i>newfile</i> onto the input stack, + postponing further reading of the current file until <i>newfile</i> has + been read. The input stack has a maximum depth of 32 nested include + files.<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/libString<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/bio.html"><i>bio</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> diff --git a/man/man3/stringsize.html b/man/man3/stringsize.html new file mode 100644 index 00000000..1e8c4e91 --- /dev/null +++ b/man/man3/stringsize.html @@ -0,0 +1,116 @@ +<head> +<title>stringsize(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>STRINGSIZE(3)</b><td align=right><b>STRINGSIZE(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> + + stringsize, stringwidth, stringnwidth, runestringsize, runestringwidth, + runestringnwidth – graphical size of strings<br> + +</table> +<p><font size=+1><b>SYNOPSIS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<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 <draw.h><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point stringsize(Font *f, char *s)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int stringwidth(Font *f, char *s)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int stringnwidth(Font *f, char *s, int n)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point runestringsize(Font *f, Rune *s)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int runestringwidth(Font *f, Rune *s)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int runestringnwidth(Font *f, Rune *s, int n)<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 routines compute the geometrical extent of character strings + when drawn on the display. The most straightforward, <tt><font size=+1>stringsize</font></tt>, + returns a <tt><font size=+1>Point</font></tt> representing the vector from upper left to lower + right of the NUL-terminated string <i>s</i> drawn in font <i>f</i>. <tt><font size=+1>Stringwidth</font></tt> + returns just the <i>x</i> component. + <tt><font size=+1>Stringnwidth</font></tt> returns the width of the first <i>n</i> characters of <i>s</i>. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The routines beginning with <tt><font size=+1>rune</font></tt> are analogous, but accept an + array of runes rather than UTF-encoded bytes.<br> + +</table> +<p><font size=+1><b>FILES </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>/lib/font/bit </font></tt> directory of fonts<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/libdraw<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/addpt.html"><i>addpt</i>(3)</a>, <a href="../man3/cachechars.html"><i>cachechars</i>(3)</a>, <a href="../man3/subfont.html"><i>subfont</i>(3)</a>, <a href="../man3/draw.html"><i>draw</i>(3)</a>, <a href="../man3/draw.html"><i>draw</i>(3)</a>, <a href="../man7/image.html"><i>image</i>(7)</a>, + <a href="../man7/font.html"><i>font</i>(7)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Because strings are loaded dynamically, these routines may generate + I/O to the server and produce calls to the graphics error function.<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> diff --git a/man/man3/subfont.html b/man/man3/subfont.html new file mode 100644 index 00000000..16dc216d --- /dev/null +++ b/man/man3/subfont.html @@ -0,0 +1,260 @@ +<head> +<title>subfont(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>SUBFONT(3)</b><td align=right><b>SUBFONT(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> + + allocsubfont, freesubfont, installsubfont, lookupsubfont, uninstallsubfont, + subfontname, readsubfont, readsubfonti, writesubfont, stringsubfont, + strsubfontwidth, mkfont – subfont manipulation<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 <draw.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Subfont* allocsubfont(char *name, int n, int height, int ascent,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Fontchar *info, Image *i) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>void freesubfont(Subfont *f) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void installsubfont(char *name, Subfont *f) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Subfont* lookupsubfont(Subfont *f) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void uninstallsubfont(Subfont *f) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Subfont* readsubfont(Display *d, char *name, int fd, int dolock) + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Subfont* readsubfonti(Display *d, char *name, int fd, Image *im,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int dolock) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>int writesubfont(int fd, Subfont *f) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Point stringsubfont(Image *dst, Point p, Image *src,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Subfont *f, char *str) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + </table> + + </table> + </font></tt> + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + + </table> + + </table> + <tt><font size=+1>Point strsubfontwidth(Subfont *f, char *s) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Font* mkfont(Subfont *f, Rune min)<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> + + Subfonts are the components of fonts that hold the character images. + A font comprises an array of subfonts; see <a href="../man3/cachechars.html"><i>cachechars</i>(3)</a>. A new + <tt><font size=+1>Subfont</font></tt> is allocated and initialized with <i>allocsubfont</i>. See <a href="../man3/cachechars.html"><i>cachechars</i>(3)</a> + for the meaning of <i>n</i>, <i>height</i>, <i>ascent</i>, and <i>info</i>, and the arrangement + of characters in image <i>i</i>. The <i>name</i> is + used to identify the subfont in the subfont cache; see the descriptions + <i>lookupsubfont</i> and <i>installsubfont</i> (<i>q.v.</i>). The appropriate fields + of the returned <tt><font size=+1>Subfont</font></tt> structure are set to the passed arguments, + and the image is registered as a subfont with the graphics device + <a href="../man3/draw.html"><i>draw</i>(3)</a>. <i>Allocsubfont</i> returns 0 on failure. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Freesubfont</i> frees a subfont and all its associated structure including + the associated image. Since <i>freesbufont</i> calls <i>free</i> on <tt><font size=+1>f−>info</font></tt>, + if <tt><font size=+1>f−>info</font></tt> was not allocated by <a href="../man3/malloc.html"><i>malloc</i>(3)</a> it should be zeroed before + calling <i>subffree</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + A number of subfonts are kept in external files. The convention + for naming subfont files is:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>/usr/local/plan9/font/</font></tt><i>name</i><tt><font size=+1>/</font></tt><i>class</i><tt><font size=+1>.</font></tt><i>size</i><tt><font size=+1>.</font></tt><i>depth + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </i> + + </table> + where <i>size</i> is approximately the height in pixels of the lower + case letters (without ascenders or descenders). If there is only + one version of the subfont, the <tt><font size=+1>.</font></tt><i>depth</i> extension is elided. <i>Class</i> + describes the range of runes encoded in the subfont: <tt><font size=+1>ascii</font></tt>, <tt><font size=+1>latin1</font></tt>, + <tt><font size=+1>greek</font></tt>, etc. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Subfonts are cached within the program, so a subfont shared between + fonts will be loaded only once. <i>Installsubfont</i> stores subfont + <i>f</i> under the given <i>name</i>, typically the file name from which it + was read. <i>Uninstallsubfont</i> removes the subfont from the cache. + Finally, <i>lookupsubfont</i> searches for a subfont with the given + <i>name</i> in the cache and returns it, or nil if no such subfont exists. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Subfontname</i> is used to locate subfonts given their names within + the fonts. The default version constructs a name given the <i>cfname</i>, + its name within the font, <i>fname</i>, the name of the font, and the + maximum depth suitable for this subfont. This interface allows + a partially specified name within a font to be resolved at + run-time to the name of a file holding a suitable subfont. Although + it is principally a routine internal to the library, <i>subfontname</i> + may be substituted by the application to provide a less file-oriented + subfont naming scheme. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The format of a subfont file is described in <a href="../man7/font.html"><i>font</i>(7)</a>. Briefly, + it contains a image with all the characters in it, followed by + a subfont header, followed by character information. <i>Readsubfont</i> + reads a subfont from the file descriptor <i>fd</i>. The <i>name</i> is used + to identify the font in the cache. The <i>dolock</i> argument specifies + whether + the routine should synchronize use of the <i>Display</i> with other processes; + for single-threaded applications it may always be zero. <i>Readsubfonti</i> + does the same for a subfont whose associated image is already + in memory; it is passed as the argument <i>im</i>. In other words, <i>readsubfonti</i> + reads only the header and character + information from the file descriptor. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Writesubfont</i> writes on <i>fd</i> the part of a subfont file that comes + after the image. It should be preceded by a call to <i>writeimage</i> + (see <a href="../man3/allocimage.html"><i>allocimage</i>(3)</a>). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Stringsubfont</i> is analogous to <tt><font size=+1>string</font></tt> (see <a href="../man3/draw.html"><i>draw</i>(3)</a>) for subfonts. + Rather than use the underlying font caching primitives, it calls + <tt><font size=+1>draw</font></tt> for each character. It is intended for stand-alone environments + such as operating system kernels. <i>Strsubfontwidth</i> returns the + width of the string <i>s</i> in as it would appear if drawn with + <i>stringsubfont</i> in <tt><font size=+1>Subfont f</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Mkfont</i> takes as argument a <tt><font size=+1>Subfont</font></tt> <i>s</i> and returns a pointer to + a <tt><font size=+1>Font</font></tt> that maps the character images in <i>s</i> into the <tt><font size=+1>Runes</font></tt> <i>min</i> + to <i>min</i><tt><font size=+1>+</font></tt><i>s</i><tt><font size=+1>−>n−1</font></tt>.<br> + +</table> +<p><font size=+1><b>FILES </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/font</font></tt> bitmap font file tree<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/libdraw<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/graphics.html"><i>graphics</i>(3)</a>, <a href="../man3/allocimage.html"><i>allocimage</i>(3)</a>, <a href="../man3/draw.html"><i>draw</i>(3)</a>, <a href="../man3/cachechars.html"><i>cachechars</i>(3)</a>, <a href="../man7/image.html"><i>image</i>(7)</a>, + <a href="../man7/font.html"><i>font</i>(7)</a><br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + All of the functions use the graphics error function (see <a href="../man3/graphics.html"><i>graphics</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> diff --git a/man/man3/sysfatal.html b/man/man3/sysfatal.html new file mode 100644 index 00000000..15ceb0ca --- /dev/null +++ b/man/man3/sysfatal.html @@ -0,0 +1,71 @@ +<head> +<title>sysfatal(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>SYSFATAL(3)</b><td align=right><b>SYSFATAL(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> + + sysfatal – system error messages<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void sysfatal(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> + + <i>Sysfatal</i> prints to standard error the name of the running program, + a colon and a space, the message described by the <a href="../man3/print.html"><i>print</i>(3)</a> format + string <i>fmt</i> and subsequent arguments, and a newline. It then calls + <a href="../man3/exits.html"><i>exits</i>(3)</a> with the formatted message as argument. The program’s + name is the value of <tt><font size=+1>argv0</font></tt>, which will be set if the + program uses the <a href="../man3/arg.html"><i>arg</i>(3)</a> interface to process its arguments. If + <tt><font size=+1>argv0</font></tt> is null, it is ignored and the following colon and space + are suppressed.<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/lib9/sysfatal.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/intro.html"><i>intro</i>(3)</a>, <a href="../man3/errstr.html"><i>errstr</i>(3)</a>, the <tt><font size=+1>%r</font></tt> format in <a href="../man3/print.html"><i>print</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> diff --git a/man/man3/thread.html b/man/man3/thread.html new file mode 100644 index 00000000..b14d97e6 --- /dev/null +++ b/man/man3/thread.html @@ -0,0 +1,383 @@ +<head> +<title>thread(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>THREAD(3)</b><td align=right><b>THREAD(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> + + alt, chancreate, chanfree, chaninit, chanprint, chansetname, mainstacksize, + proccreate, procdata, recv, recvp, recvul, send, sendp, sendul, + nbrecv, nbrecvp, nbrecvul, nbsend, nbsendp, nbsendul, threadcreate, + threaddata, threadexec, threadexecl, threadexits, threadexitsall, + threadgetgrp, threadgetname, threadint, + threadintgrp, threadkill, threadkillgrp, threadmain, threadnotify, + threadid, threadpid, threadsetgrp, threadsetname, threadsetstate, + threadspawn, threadwaitchan, yield – thread and proc management<br> + +</table> +<p><font size=+1><b>SYNOPSIS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<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 <thread.h><br> + #define CHANEND 0<br> + #define CHANSND 1<br> + #define CHANRCV 2<br> + #define CHANNOP 3<br> + #define CHANNOBLK 4<br> + typedef struct Alt Alt;<br> + struct Alt {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Channel *c;<br> + void *v;<br> + int op;<br> + Channel **tag;<br> + int entryno;<br> + char *name;<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + void threadmain(int argc, char *argv[])<br> + int mainstacksize<br> + int proccreate(void (*fn)(void*), void *arg, uint stacksize)<br> + int threadcreate(void (*fn)(void*), void *arg, uint stacksize)<br> + void threadexits(char *status)<br> + void threadexitsall(char *status)<br> + void yield(void)<br> + int threadid(void)<br> + int threadgrp(void)<br> + int threadsetgrp(int group)<br> + int threadpid(int id)<br> + int threadint(int id)<br> + int threadintgrp(int group)<br> + int threadkill(int id)<br> + int threadkillgrp(int group)<br> + void threadsetname(char *name)<br> + char* threadgetname(void)<br> + void** threaddata(void)<br> + void** procdata(void)<br> + int chaninit(Channel *c, int elsize, int nel)<br> + Channel* chancreate(int elsize, int nel)<br> + void chanfree(Channel *c)<br> + int alt(Alt *alts)<br> + int recv(Channel *c, void *v)<br> + void* recvp(Channel *c)<br> + ulong recvul(Channel *c)<br> + int nbrecv(Channel *c, void *v)<br> + void* nbrecvp(Channel *c)<br> + ulong nbrecvul(Channel *c)<br> + int send(Channel *c, void *v)<br> + int sendp(Channel *c, void *v)<br> + int sendul(Channel *c, ulong v)<br> + int nbsend(Channel *c, void *v)<br> + int nbsendp(Channel *c, void *v)<br> + int nbsendul(Channel *c, ulong v)<br> + int chanprint(Channel *c, char *fmt, ...)<br> + int threadspawn(int fd[3], char *file, char *args[])<br> + int threadexecl(Channel *cpid, int fd[3], char *file, ...)<br> + int threadexec(Channel *cpid, int fd[3], char *file, char *args[])<br> + Channel* threadwaitchan(void)<br> + int threadnotify(int (*f)(void*, char*), int in)<br> + </font></tt> +</table> +<p><font size=+1><b>DESCRIPTION </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The thread library provides parallel programming support similar + to that of the languages Alef and Newsqueak. Threads and procs + occupy a shared address space, communicating and synchronizing + through <i>channels</i> and shared variables. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + A <i>proc</i> is a Plan 9 process that contains one or more cooperatively + scheduled <i>threads</i>. Programs using threads must replace <i>main</i> by + <i>threadmain</i>. The thread library provides a <i>main</i> function that sets + up a proc with a single thread executing <i>threadmain</i> on a stack + of size <i>mainstacksize</i> (default eight kilobytes). To set + <i>mainstacksize</i>, declare a global variable initialized to the desired + value (<i>e.g.</i>, <tt><font size=+1>int mainstacksize = 1024</font></tt>). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Threadcreate</i> creates a new thread in the calling proc, returning + a unique integer identifying the thread; the thread executes <i>fn(arg)</i> + on a stack of size <i>stacksize</i>. Thread stacks are allocated in shared + memory, making it valid to pass pointers to stack variables between + threads and procs. <i>Proccreate</i> creates a new proc, + and inside that proc creates a single thread as <i>threadcreate</i> would, + returning the id of the created thread. Be aware that the calling + thread may continue execution before the newly created proc and + thread are scheduled. Because of this, <i>arg</i> should not point to + data on the stack of a function that could return before the + new process is scheduled. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Threadexits</i> terminates the calling thread. If the thread is the + last in its proc, <i>threadexits</i> also terminates the proc, using + <i>status</i> as the exit status. <i>Threadexitsall</i> terminates all procs + in the program, using <i>status</i> as the exit status. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + When the last thread in <i>threadmain</i>’s proc exits, the program will + appear to its parent to have exited. The remaining procs will + still run together, but as a background program. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The threads in a proc are coroutines, scheduled nonpreemptively + in a round-robin fashion. A thread must explicitly relinquish + control of the processor before another thread in the same proc + is run. Calls that do this are <i>yield</i>, <i>proccreate</i>, <i>threadexec</i>, + <i>threadexecl</i>, <i>threadexits</i>, <i>threadspawn</i>, <i>alt</i>, <i>send</i>, and <i>recv</i> (and + the + calls related to <i>send</i> and <i>recv</i>--see their descriptions further on). + Procs are scheduled by the operating system. Therefore, threads + in different procs can preempt one another in arbitrary ways and + should synchronize their actions using <tt><font size=+1>qlocks</font></tt> (see <a href="../man3/lock.html"><i>lock</i>(3)</a>) or + channel communication. System calls such as <a href="../man3/read.html"><i>read</i>(3)</a> + block the entire proc; all threads in a proc block until the system + call finishes. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + As mentioned above, each thread has a unique integer thread id. + Thread ids are not reused; they are unique across the life of + the program. <i>Threadid</i> returns the id for the current thread. Each + thread also has a thread group id. The initial thread has a group + id of zero. Each new thread inherits the group id of the + thread that created it. <i>Threadgrp</i> returns the group id for the + current thread; <i>threadsetgrp</i> sets it. <i>Threadpid</i> returns the pid + of the Plan 9 process containing the thread identified by <i>id</i>, + or –1 if no such thread is found. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Threadint</i> interrupts a thread that is blocked in a channel operation + or system call. <i>Threadintgrp</i> interrupts all threads with the given + group id. <i>Threadkill</i> marks a thread to die when it next relinquishes + the processor (via one of the calls listed above). If the thread + is blocked in a channel operation or system call, it is + also interrupted. <i>Threadkillgrp</i> kills all threads with the given + group id. Note that <i>threadkill</i> and <i>threadkillgrp</i> will not terminate + a thread that never relinquishes the processor. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Primarily for debugging, threads can have string names associated + with them. <i>Threadgetname</i> returns the current thread’s name; <i>threadsetname</i> + sets it. The pointer returned by <i>threadgetname</i> is only valid until + the next call to <i>threadsetname</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Also for debugging, threads have a string state associated with + them. <i>Threadsetstate</i> sets the state string. There is no <i>threadgetstate</i>; + since the thread scheduler resets the state to <tt><font size=+1>Running</font></tt> every time + it runs the thread, it is only useful for debuggers to inspect + the state. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Threaddata</i> returns a pointer to a per-thread pointer that may + be modified by threaded programs for per-thread storage. Similarly, + <i>procdata</i> returns a pointer to a per-proc pointer. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Threadexecl</i> and <i>threadexec</i> are threaded analogues of <i>exec</i> and + <i>execl</i> (see <a href="../man3/exec.html"><i>exec</i>(3)</a>); on success, they replace the calling thread + and invoke the external program, never returning. (Unlike on Plan + 9, the calling thread need not be the only thread in its proc--the + other threads will continue executing.) On error, they return + –1. If <i>cpid</i> is not null, the pid of the invoked program will be + sent along <i>cpid</i> (using <i>sendul</i>) once the program has been started, + or –1 will be sent if an error occurs. <i>Threadexec</i> and <i>threadexecl</i> + will not access their arguments after sending a result along <i>cpid</i>. + Thus, programs that malloc the <i>argv</i> passed to <i>threadexec + </i>can safely free it once they have received the <i>cpid</i> response. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Threadexecl</i> and <i>threadexec</i> will duplicate (see <a href="../man3/dup.html"><i>dup</i>(3)</a>) the three + file descriptors in <i>fd</i> onto standard input, output, and error + for the external program and then close them in the calling thread. + Beware of code that sets<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>fd[0] = 0;<br> + fd[1] = 1;<br> + fd[2] = 2;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + to use the current standard files. The correct code is<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>fd[0] = dup(0, −1);<br> + fd[1] = dup(1, −1);<br> + fd[2] = dup(2, −1);<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + <i>Threadspawn</i> is like <i>threadexec</i> but does not replace the current + thread. It returns the pid of the invoked program on success, + or –1 on error. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Threadwaitchan</i> returns a channel of pointers to <tt><font size=+1>Waitmsg</font></tt> structures + (see <a href="../man3/wait.html"><i>wait</i>(3)</a>). When an exec’ed process exits, a pointer to a <tt><font size=+1>Waitmsg</font></tt> + is sent to this channel. These <tt><font size=+1>Waitmsg</font></tt> structures have been allocated + with <a href="../man3/malloc.html"><i>malloc</i>(3)</a> and should be freed after use. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + A <tt><font size=+1>Channel</font></tt> is a buffered or unbuffered queue for fixed-size messages. + Procs and threads <i>send</i> messages into the channel and <i>recv</i> messages + from the channel. If the channel is unbuffered, a <i>send</i> operation + blocks until the corresponding <i>recv</i> operation occurs and <i>vice + versa</i>. <i>Chaninit</i> initializes a <tt><font size=+1>Channel</font></tt> for + messages of size <i>elsize</i> and with a buffer holding <i>nel</i> messages. + If <i>nel</i> is zero, the channel is unbuffered. <i>Chancreate</i> allocates + a new channel and initializes it. <i>Chanfree</i> frees a channel that + is no longer used. <i>Chanfree</i> can be called by either sender or + receiver after the last item has been sent or received. Freeing + the + channel will be delayed if there is a thread blocked on it until + that thread unblocks (but <i>chanfree</i> returns immediately). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The <tt><font size=+1>name</font></tt> element in the <tt><font size=+1>Channel</font></tt> structure is a description intended + for use in debugging. <i>Chansetname</i> sets the name. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Send</i> sends the element pointed at by <i>v</i> to the channel <i>c</i>. If <i>v</i> + is null, zeros are sent. <i>Recv</i> receives an element from <i>c</i> and stores + it in <i>v</i>. If <i>v</i> is null, the received value is discarded. <i>Send</i> and + <i>recv</i> return 1 on success, –1 if interrupted. <i>Nbsend</i> and <i>nbrecv</i> + behave similarly, but return 0 rather than blocking. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Sendp</i>, <i>nbsendp</i>, <i>sendul</i>, and <i>nbsendul</i> send a pointer or an unsigned + long; the channel must have been initialized with the appropriate + <i>elsize</i>. <i>Recvp</i>, <i>nbrecvp</i>, <i>recvul</i>, and <i>nbrecvul</i> receive a pointer + or an unsigned long; they return zero when a zero is received, + when interrupted, or (for <i>nbrecvp</i> and <i>nbrecvul</i>) when the + operation would have blocked. To distinguish between these three + cases, use <i>recv</i> or <i>nbrecv</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Alt</i> can be used to recv from or send to one of a number of channels, + as directed by an array of <tt><font size=+1>Alt</font></tt> structures, each of which describes + a potential send or receive operation. In an <tt><font size=+1>Alt</font></tt> structure, <tt><font size=+1>c</font></tt> + is the channel; <tt><font size=+1>v</font></tt> the value pointer (which may be null); and <tt><font size=+1>op</font></tt> + the operation: <tt><font size=+1>CHANSND</font></tt> for a send operation, + <tt><font size=+1>CHANRECV</font></tt> for a recv operation; <tt><font size=+1>CHANNOP</font></tt> for no operation (useful + when <i>alt</i> is called with a varying set of operations). The array + of <tt><font size=+1>Alt</font></tt> structures is terminated by an entry with <i>op</i> <tt><font size=+1>CHANEND</font></tt> or + <tt><font size=+1>CHANNOBLK</font></tt>. If at least one <tt><font size=+1>Alt</font></tt> structure can proceed, one of them + is chosen at random to be executed. <i>Alt</i> returns the + index of the chosen structure. If no operations can proceed and + the list is terminated with <tt><font size=+1>CHANNOBLK</font></tt>, <i>alt</i> returns the index of + the terminating <tt><font size=+1>CHANNOBLK</font></tt> structure. Otherwise, <i>alt</i> blocks until + one of the operations can proceed, eventually returning the index + of the structure executes. <i>Alt</i> returns –1 when + interrupted. The <tt><font size=+1>tag</font></tt> and <tt><font size=+1>entryno</font></tt> fields in the <tt><font size=+1>Alt</font></tt> structure are + used internally by <i>alt</i> and need not be initialized. They are not + used between <i>alt</i> calls. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Chanprint</i> formats its arguments in the manner of <a href="../man3/print.html"><i>print</i>(3)</a> and + sends the result to the channel <i>c.</i> The string delivered by <i>chanprint</i> + is allocated with <a href="../man3/malloc.html"><i>malloc</i>(3)</a> and should be freed upon receipt. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Thread library functions do not return on failure; if errors occur, + the entire program is aborted. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Threaded programs should use <i>threadnotify</i> in place of <i>atnotify</i> + (see <a href="../man3/notify.html"><i>notify</i>(3)</a>). + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + It is safe to use <a href="../man3/sysfatal.html"><i>sysfatal</i>(3)</a> in threaded programs. <i>Sysfatal</i> will + print the error string and call <i>threadexitsall</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + It is not safe to call <i>rfork</i> in a threaded program, except to + call <tt><font size=+1>rfork(RFNOTEG)</font></tt> from the main proc before any other procs + have been created. To create new processes, use <i>proccreate</i>.<br> + +</table> +<p><font size=+1><b>FILES </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/acid/thread</font></tt> contains useful <a href="../man1/acid.html"><i>acid</i>(1)</a> functions + for debugging threaded programs. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>/usr/local/plan9/src/libthread/test</font></tt> contains some example programs.<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/libthread<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/intro.html"><i>intro</i>(3)</a>, <a href="../man3/ioproc.html"><i>ioproc</i>(3)</a><br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + To avoid name conflicts, <i>alt</i>, <i>nbrecv</i>, <i>nbrecvp</i>, <i>nbrecvul</i>, <i>nbsend</i>, + <i>nbsendp</i>, <i>nbsendul</i>, <i>recv</i>, <i>recvp</i>, <i>recvul</i>, <i>send</i>, <i>sendp</i>, and <i>sendul</i> + are defined as macros that expand to <i>chanalt</i>, <i>channbrecv</i>, and + so on. <i>Yield</i> is defined as a macro that expands to <i>threadyield</i>. + See <a href="../man3/intro.html"><i>intro</i>(3)</a>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The implementation of <i>threadnotify</i> may not be correct.<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> diff --git a/man/man3/time.html b/man/man3/time.html new file mode 100644 index 00000000..de0de468 --- /dev/null +++ b/man/man3/time.html @@ -0,0 +1,79 @@ +<head> +<title>time(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>TIME(3)</b><td align=right><b>TIME(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> + + time, nsec – time in seconds and nanoseconds since epoch<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long time(long *tp)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>vlong nsec(void)<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> + + Both <i>time</i> and <i>nsec</i> return the time since the epoch 00:00:00 GMT, + Jan. 1, 1970. The return value of the former is in seconds and + the latter in nanoseconds. For <i>time</i>, if <i>tp</i> is not zero then <tt><font size=+1>*</font></tt><i>tp</i> + is also set to the answer.<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/lib9/time.c<br> + </font></tt> +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + These functions set <i>errstr</i>.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + To avoid name conflicts with the underlying system, <i>time</i> and <i>nsec</i> + are preprocessor macros defined as <i>p9time</i> and <i>p9nsec</i>; see <a href="../man3/intro.html"><i>intro</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> diff --git a/man/man3/udpread.html b/man/man3/udpread.html new file mode 100644 index 00000000..e8f0d37b --- /dev/null +++ b/man/man3/udpread.html @@ -0,0 +1,105 @@ +<head> +<title>udpread(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>UDPREAD(3)</b><td align=right><b>UDPREAD(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> + + udpread, udpwrite – read and write UDP packets<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include <libc.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>#include <ip.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>typedef struct Udphdr Udphdr;<br> + </font></tt>struct Udphdr<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + uchar raddr[IPaddrlen];/* remote address and port */<br> + uchar laddr[IPaddrlen];/* local address and port */<br> + uchar rport[2];<br> + uchar lport[2];<br> + + </table> + };<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>long udpread(int fd, Udphdr *hdr, void *data, long n)<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>long udpwrite(int fd, Udphdr *hdr, void *data, long n)<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> + + <i>Udpread</i> and <i>udpwrite</i> read and write UDP packets from the UDP network + connection established on file descriptor <i>fd</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Udpread</i> reads at most <i>n</i> bytes of packet body into <i>data ,</i> stores + the header in <i>hdr</i>, and returns the number of bytes stored in <i>data</i>. + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Udpwrite</i> writes the <i>n</i> bytes stored in <i>data</i> in a UDP packet with + header <i>hdr</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Note that the <tt><font size=+1>Udphdr</font></tt> frames the addresses as local and remote + instead of source and destination. Thus the <i>hdr</i> filled in for + a packet read by <i>udpread</i> can be used unchanged in <i>udpwrite</i> to + send a response back to the sender of the original packet.<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/lib9/udp.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/ip.html"><i>ip</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> diff --git a/man/man3/wait.html b/man/man3/wait.html new file mode 100644 index 00000000..84322bc2 --- /dev/null +++ b/man/man3/wait.html @@ -0,0 +1,170 @@ +<head> +<title>wait(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>WAIT(3)</b><td align=right><b>WAIT(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> + + await, awaitnohang, awaitfor, wait, waitnohang, waitfor, waitpid + – wait for a process to exit<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> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Waitmsg* wait(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Waitmsg* waitnohang(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Waitmsg* waitfor(int pid) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int waitpid(void) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int await(char *s, int n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int awaitnohang(char *s, int n) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int awaitfor(int pid, char *s, int n)<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> + + <i>Wait</i> causes a process to wait for any child process (see <a href="../man2/fork.html"><i>fork</i>(2)</a> + and <a href="../man3/rfork.html"><i>rfork</i>(3)</a>) to exit. It returns a <tt><font size=+1>Waitmsg</font></tt> holding information + about the exited child. A <tt><font size=+1>Waitmsg</font></tt> has this structure:<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>typedef<br> + struct Waitmsg<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + int pid; /* of loved one */<br> + ulong time[3]; /* of loved one & descendants */<br> + char *msg;<br> + + </table> + } Waitmsg;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + + </table> + <tt><font size=+1>Pid</font></tt> is the child’s process id. The <tt><font size=+1>time</font></tt> array contains the time + the child and its descendants spent in user code, the time spent + in system calls, and the child’s elapsed real time, all in units + of milliseconds. <tt><font size=+1>Msg</font></tt> contains the message that the child specified + in <a href="../man3/exits.html"><i>exits</i>(3)</a>. For a normal exit, <tt><font size=+1>msg[0]</font></tt> is zero, otherwise <tt><font size=+1>msg + </font></tt>is the exit string prefixed by the process name, a blank, the + process id, and a colon. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + If there are no more children to wait for, <i>wait</i> returns immediately, + with return value nil. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The <tt><font size=+1>Waitmsg</font></tt> structure is allocated by <a href="../man3/malloc.html"><i>malloc</i>(3)</a> and should be + freed after use. For programs that only need the pid of the exiting + program, <i>waitpid</i> returns just the pid and discards the rest of + the information. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Waitnohang</i> is like <i>wait</i> but does not block if there are no more + children to wait for. Instead it returns immediately and sets + <i>errstr</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Waitfor</i> is like <i>wait</i> but waits for a particular <i>pid</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The underlying calls are <i>await</i>, <i>awaitnohang</i>, and <i>awaitfor</i>, which + fill in the <i>n</i>-byte buffer <i>s</i> with a textual representation of the + pid, times, and exit string. There is no terminal NUL. The return + value is the length, in bytes, of the data. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The filled-in buffer may be parsed (after appending a NUL) using + <i>tokenize</i> (see <a href="../man3/getfields.html"><i>getfields</i>(3)</a>); the resulting fields are, in order, + pid, the three times, and the exit string, which will be <tt><font size=+1>''</font></tt> for + normal exit. If the representation is longer than <i>n</i> bytes, it + is truncated but, if possible, properly formatted. The information + that + does not fit in the buffer is discarded, so a subsequent call + to <i>await</i> will return the information about the next exiting child, + not the remainder of the truncated message. In other words, each + call to <i>await</i> returns the information about one child, blocking + if necessary if no child has exited. If the calling process has + no + living children, <i>await</i> returns <tt><font size=+1>−1</font></tt>.<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/lib9/wait.c + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>/usr/local/plan9/src/lib9/await.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/rfork.html"><i>rfork</i>(3)</a>, <a href="../man3/exits.html"><i>exits</i>(3)</a>,<br> + +</table> +<p><font size=+1><b>DIAGNOSTICS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + These routines set <i>errstr</i>.<br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + To avoid name conflicts with the underlying system, <i>wait</i>, <i>waitpid</i>, + and <i>waitfor</i> are preprocessor macros defined as <i>p9wait</i>, <i>p9waitpid</i>, + and <i>p9waitfor</i>; see <a href="../man3/intro.html"><i>intro</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> diff --git a/man/man3/wctl.html b/man/man3/wctl.html new file mode 100644 index 00000000..071217e2 --- /dev/null +++ b/man/man3/wctl.html @@ -0,0 +1,78 @@ +<head> +<title>wctl(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>WCTL(3)</b><td align=right><b>WCTL(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> + + drawresizewindow, drawsetlabel, drawtopwindow – window management<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 <draw.h> + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void drawresizewindow(Rectangle r) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int drawsetlabel(Display *d, char *name) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void drawtopwindow(void)<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 routines interact with a window manager to set the properties + of the window running the current program. They substitute for + interacting directly with the Plan 9 <i>rio</i>’s <tt><font size=+1>/dev/wctl</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Drawresizewindow</i> requests that the program’s window be resized + to have the width and height of the rectangle <i>r</i>. Only the width + and height are important; the offset is ignored. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Drawsetlabel</i> requests that the program’s window title be set to + <i>name</i>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <i>Drawtopwindow</i> requests that the program’s window be moved above + all other windows and given the input focus.<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/libdraw/x11−init.c<br> + /usr/local/plan9/src/libdraw/x11−wsys.c<br> + </font></tt> +</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> diff --git a/man/man3/window.html b/man/man3/window.html new file mode 100644 index 00000000..83355bdd --- /dev/null +++ b/man/man3/window.html @@ -0,0 +1,241 @@ +<head> +<title>window(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>WINDOW(3)</b><td align=right><b>WINDOW(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> + + Screen, allocscreen, publicscreen, freescreen, allocwindow, bottomwindow, + bottomnwindows, topwindow, topnwindows, originwindow – window management<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 <draw.h><br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>typedef<br> + struct Screen<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + Display *display; /* display holding data */<br> + int id; /* id of system−held Screen */<br> + Image *image; /* unused; for reference only */<br> + Image *fill; /* color to paint behind windows */<br> + + </table> + } Screen;<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Screen* allocscreen(Image *image, Image *fill, int public) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Screen* publicscreen(Display *d, int id, ulong chan) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int freescreen(Screen *s) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>Image* allocwindow(Screen *s, Rectangle r, int ref, int val) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void bottomwindow(Image *w) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void bottomnwindows(Image **wp, int nw) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void topwindow(Image *w) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>void topnwindows(Image **wp, int nw) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>int originwindow(Image *w, Point log, Point scr) + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + </font></tt> + <tt><font size=+1>enum<br> + {<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + /* refresh methods */<br> + Refbackup= 0,<br> + Refnone= 1,<br> + Refmesg= 2<br> + + </table> + + </table> + };<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> + + Windows are represented as <tt><font size=+1>Images</font></tt> and may be treated as regular + images for all drawing operations. The routines discussed here + permit the creation, deletion, and shuffling of windows, facilities + that do not apply to regular images. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + To create windows, it is first necessary to allocate a <tt><font size=+1>Screen</font></tt> + data structure to gather them together. A <tt><font size=+1>Screen</font></tt> turns an arbitrary + image into something that may have windows upon it. It is created + by <tt><font size=+1>allocscreen</font></tt>, which takes an <i>image</i> upon which to place the windows + (typically <tt><font size=+1>display−>image</font></tt>), a <i>fill</i> image + to paint the background behind all the windows on the image, and + a flag specifying whether the result should be publicly visible. + If it is public, an arbitrary other program connected to the same + display may acquire a pointer to the same screen by calling <tt><font size=+1>publicscreen</font></tt> + with the <tt><font size=+1>Display</font></tt> pointer and the <i>id</i> of the + published <tt><font size=+1>Screen</font></tt>, as well as the expected channel descriptor, + as a safety check. It will usually require some out-of-band coordination + for programs to share a screen profitably. <tt><font size=+1>Freescreen</font></tt> releases + a <tt><font size=+1>Screen</font></tt>, although it may not actually disappear from view until + all the windows upon it have also been + deallocated. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Unlike <tt><font size=+1>allocwindow</font></tt>, <tt><font size=+1>allocscreen</font></tt> does <i>not</i> initialize the appearance + of the <tt><font size=+1>Screen</font></tt>. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Windows are created by <tt><font size=+1>allocwindow</font></tt>, which takes a pointer to the + <tt><font size=+1>Screen</font></tt> upon which to create the window, a rectangle <i>r</i> defining + its geometry, an integer pixel value <i>val</i> to color the window initially, + and a refresh method <tt><font size=+1>ref</font></tt>. The refresh methods are <tt><font size=+1>Refbackup</font></tt>, which + provides backing store and is the + method used by <a href="../man1/rio.html"><i>rio</i>(1)</a> for its clients; <tt><font size=+1>Refnone</font></tt>, which provides + no refresh and is designed for temporary uses such as sweeping + a display rectangle, for windows that are completely covered by + other windows, and for windows that are already protected by backing + store; and <tt><font size=+1>Refmesg</font></tt>, which causes messages to be + delivered to the owner of the window when it needs to be repainted. + <tt><font size=+1>Refmesg</font></tt> is not fully implemented. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + The result of <tt><font size=+1>allocwindow</font></tt> is an <tt><font size=+1>Image</font></tt> pointer that may be treated + like any other image. In particular, it is freed by calling <tt><font size=+1>freeimage</font></tt> + (see <a href="../man3/allocimage.html"><i>allocimage</i>(3)</a>). The following functions, however, apply only + to windows, not regular images. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <tt><font size=+1>Bottomwindow</font></tt> pushes window <i>w</i> to the bottom of the stack of windows + on its <tt><font size=+1>Screen</font></tt>, perhaps obscuring it. <tt><font size=+1>Topwindow</font></tt> pulls window <i>w</i> + to the top, making it fully visible on its <tt><font size=+1>Screen</font></tt>. (This <tt><font size=+1>Screen</font></tt> + may itself be within a window that is not fully visible; <tt><font size=+1>topwindow</font></tt> + will not affect the stacking of this parent + window.) <tt><font size=+1>Bottomnwindows</font></tt> and <tt><font size=+1>Topnwindows</font></tt> are analogous, but push + or pull a group of <i>nw</i> windows listed in the array <i>wp</i>. The order + within <i>wp</i> is unaffected. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + Each window is created as an <tt><font size=+1>Image</font></tt> whose <tt><font size=+1>Rectangle r</font></tt> corresponds + to the rectangle given to <tt><font size=+1>allocwindow</font></tt> when it was created. Thus, + a newly created window <i>w</i> resides on its <tt><font size=+1>Screen−>image</font></tt> at <i>w</i><tt><font size=+1>−>r</font></tt> and + has internal coordinates <i>w</i><tt><font size=+1>−>r</font></tt><i>.</i> Both these may be changed by a call + to <tt><font size=+1>originwindow</font></tt>. The two + <tt><font size=+1>Point</font></tt> arguments to <tt><font size=+1>originwindow</font></tt> define the upper left corner of + the logical coordinate system (<i>log</i>) and screen position (<i>scr</i>). + Their usage is shown in the Examples section. + <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> + + <a href="../man1/Rio.html"><i>Rio</i>(1)</a> creates its client windows with backing store, <tt><font size=+1>Refbackup</font></tt>. + The graphics initialization routine, <tt><font size=+1>initdraw</font></tt> (see <a href="../man3/graphics.html"><i>graphics</i>(3)</a>), + builds a <tt><font size=+1>Screen</font></tt> upon this, and then allocates upon that another + window indented to protect the border. That window is created + <tt><font size=+1>Refnone</font></tt>, since the backing store created by <tt><font size=+1>rio + </font></tt>protects its contents. That window is the one known in the library + by the global name <tt><font size=+1>screen</font></tt> (a historic but confusing choice).<br> + +</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> + + To move a window to the upper left corner of the display,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>originwindow(w, w−>r.min, Pt(0, 0));<br> + </font></tt> + </table> + + </table> + To leave a window where it is on the screen but change its internal + coordinate system so (0, 0) is the upper left corner of the window,<br> + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + + <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + <tt><font size=+1>originwindow(w, Pt(0, 0), w−>r.min);<br> + </font></tt> + </table> + + </table> + After this is done, <tt><font size=+1>w−>r</font></tt> is translated to the origin and there + will be no way to discover the actual screen position of the window + unless it is recorded separately.<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/libdraw<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/graphics.html"><i>graphics</i>(3)</a>, <a href="../man3/draw.html"><i>draw</i>(3)</a>, <a href="../man3/cachechars.html"><i>cachechars</i>(3)</a>, <a href="../man3/draw.html"><i>draw</i>(3)</a><br> + +</table> +<p><font size=+1><b>BUGS </b></font><br> + +<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> + + The refresh method <tt><font size=+1>Refmesg</font></tt> should be finished.<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> |