9699552002-03-12Martin Nilsson <!doctype html><html><head><title>Pike Reference Manual</title> <meta charset='utf-8'></head>
9add812019-07-04Henrik Grubbström (Grubba) <body><dl><dt><h1 class='header'>9. I/O</h1></dt><dd></dd> <dt><a name='9.1'></a> <h2 class='header'>9.1. File system manipulation</h2></dt> <dd> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>access</b></span> </dt> <dd><p><code><code class='datatype'>int</code> <b><span class='method'>access</span>(</b><code class='datatype'>string</code> <code class='argument'>path</code>, <code class='datatype'>string</code>|<code class='datatype'>void</code> <code class='argument'>mode</code><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>access() checks if the calling process can access the file <code>path</code>. Symbolic links are dereferenced.</p> </dd> <dt class='head--doc'><span id='p-mode'></span>Parameter <code class='parameter'>mode</code></dt> <dd></dd><dd class='body--doc'><p>The <code>mode</code> specifies the accessibility checks to be performed, and is either not specified or empty, in which case access() just tests if the file exists, or one or more of the characters <code class='expr'>"rwx"</code>.</p> <p> r, w, and x test whether the file exists and grants read, write, and execute permissions, respectively.</p> <p> The check is done using the calling process's real UID and GID, rather than the effective IDs as is done when actually attempting an operation (e.g., open(2)) on the file. This allows set-user-ID programs to easily determine the invoking user's authority.</p> <p> If the calling process is privileged (i.e., its real UID is zero), then an X_OK check is successful for a regular file if execute permission is enabled for any of the file owner, group, or other.</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><table class='box'><tr><td><code><code class='key'>1</code></code></td><td><p>When the file is accessible using the given permissions.</p> </td></tr> <tr><td><code><code class='key'>0</code></code></td><td><p>When the file is not accessible, in which case <code>errno</code> is set to one of the following values:</p> <table class='box'><tr><td><code><code class='key'>EACCESS</code></code></td><td><p>Access denied.</p> </td></tr> <tr><td><code><code class='key'>ELOOP</code></code></td><td><p>Too many symbolic links.</p> </td></tr> <tr><td><code><code class='key'>ENAMETOOLONG</code></code></td><td><p>The path is too long.</p> </td></tr> <tr><td><code><code class='key'>ENOENT</code></code></td><td><p>The file does not exist.</p> </td></tr> <tr><td><code><code class='key'>ENOTDIR</code></code></td><td><p>One of the directories used in <code>path</code> is not, in fact, a directory.</p> </td></tr> <tr><td><code><code class='key'>EROFS</code></code></td><td><p>The filesystem is read only and write access was requested.</p> </td></tr> </table><p>Other errors can occur, but are not directly related to the requested path, such as <code class='expr'>ENOMEM</code>, etc.</p> </td></tr> </table> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>errno()</code>, <code>Stdio.File</code></p> </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>cd</b></span> </dt> <dd><p><code><code class='datatype'>int</code> <b><span class='method'>cd</span>(</b><code class='datatype'>string</code> <code class='argument'>s</code><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Change the current directory for the whole Pike process.</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>Returns <code class='expr'>1</code> for success, <code class='expr'>0</code> (zero) otherwise.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>getcwd()</code></p> </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>getcwd</b></span> </dt> <dd><p><code><code class='datatype'>string</code> <b><span class='method'>getcwd</span>(</b><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Returns the current working directory.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>cd()</code></p> </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>get_dir</b></span> </dt> <dd><p><code><code class='datatype'>array</code>(<code class='datatype'>string</code>) <b><span class='method'>get_dir</span>(</b><code class='datatype'>void</code>|<code class='datatype'>string</code> <code class='argument'>dirname</code><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Returns an array of all filenames in the directory <code>dirname</code>, or <code class='expr'>0</code> (zero) if the directory does not exist. When no <code>dirname</code> is given, current work directory is used.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>mkdir()</code>, <code>cd()</code></p> </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>mkdir</b></span> </dt> <dd><p><code><code class='datatype'>int</code> <b><span class='method'>mkdir</span>(</b><code class='datatype'>string</code> <code class='argument'>dirname</code>, <code class='datatype'>void</code>|<code class='datatype'>int</code> <code class='argument'>mode</code><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Create a directory.</p> <p> If <code>mode</code> is specified, it's will be used for the new directory after being <code class='expr'>&amp;</code>'ed with the current umask (on OS'es that support this).</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>Returns <code class='expr'>0</code> (zero) on failure, <code class='expr'>1</code> otherwise.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>rm()</code>, <code>cd()</code>, <code>Stdio.mkdirhier()</code></p> </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>cp</b></span> </dt> <dd><p><code><code class='datatype'>int</code> <b><span class='method'>cp</span>(</b><code class='datatype'>string</code> <code class='argument'>from</code>, <code class='datatype'>string</code> <code class='argument'>to</code><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Copies the file <code>from</code> to the new position <code>to</code>. This is an alias for <code>Stdio.cp</code>.</p> </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>mv</b></span> </dt> <dd><p><code><code class='datatype'>int</code> <b><span class='method'>mv</span>(</b><code class='datatype'>string</code> <code class='argument'>from</code>, <code class='datatype'>string</code> <code class='argument'>to</code><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Rename or move a file or directory.</p> <p> If the destination already exists, it will be replaced. Replacement often only works if <code>to</code> is of the same type as <code>from</code>, i.e. a file can only be replaced by another file and so on. Also, a directory will commonly be replaced only if it's empty.</p> <p> On some OSs this function can't move directories, only rename them.</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>Returns <code class='expr'>0</code> (zero) on failure, <code class='expr'>1</code> otherwise. Call <code>errno()</code> to get more error info on failure.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>rm()</code></p> </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>rm</b></span> </dt> <dd><p><code><code class='datatype'>int</code> <b><span class='method'>rm</span>(</b><code class='datatype'>string</code> <code class='argument'>f</code><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Remove a file or directory.</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>Returns <code class='expr'>0</code> (zero) on failure, <code class='expr'>1</code> otherwise.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>May fail with <code>errno()</code> set to <code>EISDIR</code> or <code>ENOTDIR</code> if the file has changed to a directory during the call or the reverse.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>Stdio.File()-&gt;unlinkat()</code>, <code>mkdir()</code>, <code>Stdio.recursive_rm()</code></p> </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>file_truncate</b></span> </dt> <dd><p><code><code class='datatype'>int</code> <b><span class='method'>file_truncate</span>(</b><code class='datatype'>string</code> <code class='argument'>file</code>, <code class='datatype'>int</code> <code class='argument'>length</code><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Truncates the file <code>file</code> to the length specified in <code>length</code>.</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>Returns 1 if ok, 0 if failed.</p> </dd></dl> </dd> <dt><a name='9.2'></a> <h2 class='header'>9.2. Path manipulation</h2></dt> <dd> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>basename</b></span> </dt> <dd><p><code><code class='datatype'>string</code> <b><span class='method'>basename</span>(</b><code class='datatype'>string</code> <code class='argument'>path</code><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Returns the last segment of a path.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>dirname()</code>, <code>explode_path()</code></p> </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>dirname</b></span> </dt> <dd><p><code><code class='datatype'>string</code> <b><span class='method'>dirname</span>(</b><code class='datatype'>string</code> <code class='argument'>path</code><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Returns all but the last segment of a path. Some example inputs and outputs:</p> <p> <table class='box'> <tr><td><b>Expression</b></td><td><b>Value</b></td></tr> <tr><td>dirname("/a/b")</td><td>"/a"</td></tr> <tr><td>dirname("/a/")</td><td>"/a"</td></tr> <tr><td>dirname("/a")</td><td>"/"</td></tr> <tr><td>dirname("/")</td><td>"/"</td></tr> <tr><td>dirname("")</td><td>""</td></tr> </table> </p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>basename()</code>, <code>explode_path()</code></p> </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>combine_path</b></span><br> <span class='homogen--type'>Method</span> <span class='homogen--name'><b>combine_path_unix</b></span><br> <span class='homogen--type'>Method</span> <span class='homogen--name'><b>combine_path_nt</b></span><br> <span class='homogen--type'>Method</span> <span class='homogen--name'><b>combine_path_amigaos</b></span><br> </dt> <dd><p><code><code class='datatype'>string</code> <b><span class='method'>combine_path</span>(</b><code class='datatype'>string</code> <code class='argument'>path</code>, <code class='datatype'>string</code> ... <code class='argument'>paths</code><b>)</b></code><br> <code><code class='datatype'>string</code> <b><span class='method'>combine_path_unix</span>(</b><code class='datatype'>string</code> <code class='argument'>path</code>, <code class='datatype'>string</code> ... <code class='argument'>paths</code><b>)</b></code><br> <code><code class='datatype'>string</code> <b><span class='method'>combine_path_nt</span>(</b><code class='datatype'>string</code> <code class='argument'>path</code>, <code class='datatype'>string</code> ... <code class='argument'>paths</code><b>)</b></code><br> <code><code class='datatype'>string</code> <b><span class='method'>combine_path_amigaos</span>(</b><code class='datatype'>string</code> <code class='argument'>path</code>, <code class='datatype'>string</code> ... <code class='argument'>paths</code><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Concatenate a number of paths to a straightforward path without any <code class='expr'>"//"</code>, <code class='expr'>"/.."</code> or <code class='expr'>"/."</code>. If any path argument is absolute then the result is absolute and the preceding arguments are ignored. If the result is relative then it might have leading <code class='expr'>".."</code> components. If the last nonempty argument ends with a directory separator then the result ends with that too. If all components in a relative path disappear due to subsequent <code class='expr'>".."</code> components then the result is <code class='expr'>"."</code>.</p> <p> <code>combine_path_unix()</code> concatenates in UNIX style, which also is appropriate for e.g. URL:s ("/" separates path components and absolute paths start with "/"). <code>combine_path_nt()</code> concatenates according to NT filesystem conventions ("/" and "\" separates path components and there might be a drive letter in front of absolute paths). <code>combine_path_amigaos()</code> concatenates according to AmigaOS filesystem conventions.</p> <p> <code>combine_path()</code> is equivalent to <code>combine_path_unix()</code> on UNIX-like operating systems, and equivalent to <code>combine_path_nt()</code> on NT-like operating systems, and equivalent to <code>combine_path_amigaos()</code> on AmigaOS-like operating systems.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>getcwd()</code>, <code>Stdio.append_path()</code></p> </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>explode_path</b></span> </dt> <dd><p><code><code class='datatype'>array</code>(<code class='datatype'>string</code>) <b><span class='method'>explode_path</span>(</b><code class='datatype'>string</code> <code class='argument'>p</code><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Split a path <code>p</code> into its components.</p> <p> This function divides a path into its components. This might seem like it could be done by dividing the string on &lt;tt&gt;"/"&lt;/tt&gt;, but that will not work on some operating systems. To turn the components back into a path again, use <code>combine_path()</code>.</p> </dd></dl> </dd> <dt><a name='9.3'></a> <h2 class='header'>9.3. Status</h2></dt> <dd> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>file_stat</b></span> </dt> <dd><p><code><code class='object unresolved'>Stdio.Stat</code> <b><span class='method'>file_stat</span>(</b><code class='datatype'>string</code> <code class='argument'>path</code>, <code class='datatype'>void</code>|<code class='datatype'>bool</code> <code class='argument'>symlink</code><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Stat a file.</p> <p> If the argument <code>symlink</code> is <code class='expr'>1</code> symlinks will not be followed.</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>If the path specified by <code>path</code> doesn't exist <code class='expr'>0</code> (zero) will be returned.</p> <p> Otherwise an object describing the properties of <code>path</code> will be returned.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>In Pike 7.0 and earlier this function returned an array with 7 elements. The old behaviour can be simulated with the following function:</p> <pre><code><span class='type'>array</span><span class='delim'>(</span><span class='type'>int</span><span class='delim'>)</span> file_stat<span class='delim'>(</span><span class='type'>string</span> path<span class='delim'>,</span> <span class='type'>void</span><span class='delim'>|</span><span class='type'>int</span><span class='delim'>(</span>0..1<span class='delim'>)</span> symlink<span class='delim'>)</span> <span class='delim'>{</span> File<span class='delim'>.</span>Stat st <span class='delim'>=</span> predef::file_stat<span class='delim'>(</span>path<span class='delim'>,</span> symlink<span class='delim'>)</span><span class='delim'>;</span> <span class='lang'>if</span> <span class='delim'>(</span><span class='delim'>!</span>st<span class='delim'>)</span> <span class='lang'>return</span> 0<span class='delim'>;</span> <span class='lang'>return</span> <span class='delim'>(</span><span class='type'>array</span><span class='delim'>(</span><span class='type'>int</span><span class='delim'>)</span><span class='delim'>)</span>st<span class='delim'>;</span> <span class='delim'>}</span> </code></pre> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>Stdio.Stat</code>, <code>Stdio.File-&gt;stat()</code></p> </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>filesystem_stat</b></span> </dt> <dd><p><code><code class='datatype'>mapping</code>(<code class='datatype'>string</code>:<code class='datatype'>int</code>) <b><span class='method'>filesystem_stat</span>(</b><code class='datatype'>string</code> <code class='argument'>path</code><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Returns a mapping describing the properties of the filesystem containing the path specified by <code>path</code>.</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>If a filesystem cannot be determined <code class='expr'>0</code> (zero) will be returned.</p> <p> Otherwise a mapping(string:int) with the following fields will be returned:</p> <table class='box'><tr><td><code><code class='key'>"blocksize"</code> : <code class='datatype'>int</code></code></td><td><p>Size in bytes of the filesystem blocks.</p> </td></tr> <tr><td><code><code class='key'>"blocks"</code> : <code class='datatype'>int</code></code></td><td><p>Size of the entire filesystem in blocks.</p> </td></tr> <tr><td><code><code class='key'>"bfree"</code> : <code class='datatype'>int</code></code></td><td><p>Number of free blocks in the filesystem.</p> </td></tr> <tr><td><code><code class='key'>"bavail"</code> : <code class='datatype'>int</code></code></td><td><p>Number of available blocks in the filesystem. This is usually somewhat less than the <code class='expr'>"bfree"</code> value, and can usually be adjusted with eg tunefs(1M).</p> </td></tr> <tr><td><code><code class='key'>"files"</code> : <code class='datatype'>int</code></code></td><td><p>Total number of files (aka inodes) allowed by this filesystem.</p> </td></tr> <tr><td><code><code class='key'>"ffree"</code> : <code class='datatype'>int</code></code></td><td><p>Number of free files in the filesystem.</p> </td></tr> <tr><td><code><code class='key'>"favail"</code> : <code class='datatype'>int</code></code></td><td><p>Number of available files in the filesystem. This is usually the same as the <code class='expr'>"ffree"</code> value, and can usually be adjusted with eg tunefs(1M).</p> </td></tr> <tr><td><code><code class='key'>"fsname"</code> : <code class='datatype'>string</code></code></td><td><p>Name assigned to the filesystem. This item is not available on all systems.</p> </td></tr> <tr><td><code><code class='key'>"fstype"</code> : <code class='datatype'>string</code></code></td><td><p>Type of filesystem (eg <code class='expr'>"nfs"</code>). This item is not available on all systems. For some more uncommon filesystems this may be an integer representing the magic number for the filesystem type (cf <tt>statfs(2)</tt> on eg Linux systems).</p> </td></tr> </table> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>Please note that not all members are present on all OSs.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>file_stat()</code></p> </dd></dl> <dl><dt><h2 class='header'>Class <b class='ms datatype'>Stdio.Stat</b></h2> </dt><dd><dl class='group--doc'> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>This object is used to represent file status information from e.g. <code>file_stat()</code>.</p> <p> It contains the following items usually found in a C <tt>struct stat</tt>:</p> <dl class='group--doc'><dt>mode</dt> <dd><p>File mode (see <tt>mknod(2)</tt>).</p> </dd> <dt>size</dt> <dd><p>File size in bytes.</p> </dd> <dt>uid</dt> <dd><p>User ID of the file's owner.</p> </dd> <dt>gid</dt> <dd><p>Group ID of the file's owner.</p> </dd> <dt>atime</dt> <dd><p>Time of last access in seconds since 00:00:00 UTC, 1970-01-01.</p> </dd> <dt>mtime</dt> <dd><p>Time of last data modification.</p> </dd> <dt>ctime</dt> <dd><p>Time of last file status change.</p> </dd> <dt>atime_nsec</dt> <dd><p>Time of last access in nanoseconds, added to atime to get sub-second time</p> </dd> <dt>mtime_nsec</dt> <dd><p>Time of last modification in nanoseconds, added to mtime to get sub-second time</p> </dd> <dt>ctime_nsec</dt> <dd><p>Time of last file status change in nanoseconds, added to ctime to get sub-second time</p> </dd> <dt>ino</dt> <dd><p>Inode number.</p> </dd> <dt>nlink</dt> <dd><p>Number of links.</p> </dd> <dt>dev</dt> <dd><p>ID of the device containing a directory entry for this file.</p> </dd> <dt>rdev</dt> <dd><p>ID of the device.</p> </dd> </dl><p>It also contains some items that correspond to the C <tt>IS*</tt> macros:</p> <dl class='group--doc'><dt>isreg</dt> <dd><p>Set if the file is a regular file.</p> </dd> <dt>isdir</dt> <dd><p>Set if the file is a directory.</p> </dd> <dt>islnk</dt> <dd><p>Set if the file is a symbolic link. Note that symbolic links are normally followed by the stat functions, so this might only be set if you turn that off, e.g. by giving a nonzero second argument to <code>file_stat()</code>.</p> </dd> <dt>isfifo</dt> <dd><p>Set if the file is a FIFO (aka named pipe).</p> </dd> <dt>issock</dt> <dd><p>Set if the file is a socket.</p> </dd> <dt>ischr</dt> <dd><p>Set if the file is a character device.</p> </dd> <dt>isblk</dt> <dd><p>Set if the file is a block device.</p> </dd> </dl><p>There are also some items that provide alternative representations of the above:</p> <dl class='group--doc'><dt>type</dt> <dd><p>The type as a string, can be any of <code class='expr'>"reg"</code>, <code class='expr'>"dir"</code>, <code class='expr'>"lnk"</code>, <code class='expr'>"fifo"</code>, <code class='expr'>"sock"</code>, <code class='expr'>"chr"</code>, <code class='expr'>"blk"</code>, and <code class='expr'>"unknown"</code>.</p> </dd> <dt>mode_string</dt> <dd><p>The file mode encoded as a string in <tt>ls -l</tt> style, e.g. <code class='expr'>"drwxr-xr-x"</code>.</p> </dd> </dl><p>Note that some items might not exist or have meaningful values on some platforms.</p> <p> Additionally, the object may be initialized from or casted to an <code class='expr'>array</code> on the form of a 'traditional' LPC stat-array, and it's also possible to index the object directly with integers as if it were such an array. The stat-array has this format:</p> <table class='box'><tr><td colspan='2'>Array</td></tr> <tr><td><code><code class='datatype'>int</code> <code class='key'>0</code></code></td><td><p>File mode, same as <tt>mode</tt>.</p> </td></tr> <tr><td><code><code class='datatype'>int</code> <code class='key'>1</code></code></td><td><p>If zero or greater, the file is a regular file and this is its size in bytes. If less than zero it gives the type: -2=directory, -3=symlink and -4=device.</p> </td></tr> <tr><td><code><code class='datatype'>int</code> <code class='key'>2</code></code></td><td><p>Time of last access, same as <tt>atime</tt>.</p> </td></tr> <tr><td><code><code class='datatype'>int</code> <code class='key'>3</code></code></td><td><p>Time of last data modification, same as <tt>mtime</tt>.</p> </td></tr> <tr><td><code><code class='datatype'>int</code> <code class='key'>4</code></code></td><td><p>Time of last file status change, same as <tt>ctime</tt>.</p> </td></tr> <tr><td><code><code class='datatype'>int</code> <code class='key'>5</code></code></td><td><p>User ID of the file's owner, same as <tt>uid</tt>.</p> </td></tr> <tr><td><code><code class='datatype'>int</code> <code class='key'>6</code></code></td><td><p>Group ID of the file's owner, same as <tt>gid</tt>.</p> </td></tr> </table><p>It's possible to modify the stat struct by assigning values to the items. They essentially work as variables, although some of them affect others, e.g. setting <code class='expr'>isdir</code> clears <code class='expr'>isreg</code> and setting <code class='expr'>mode_string</code> changes many of the other items.</p> </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>_equal</b></span> </dt> <dd><p><code><code class='datatype'>bool</code> <b><span class='method'>equal</span>(</b><span class='class'>Stdio.Stat</span> <span class='argument'>from</span>, <code class='datatype'>mixed</code> <code class='argument'>other</code><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Compare this object with another <code>Stat</code> object.</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>Returns <code class='expr'>1</code> if <code>other</code> is a <code>Stat</code> object with the same content, and <code class='expr'>0</code> (zero) otherwise.</p> </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>cast</b></span> </dt> <dd><p><code><b>(</b><span class='datatype'><code class='datatype'>mapping</code>(<code class='datatype'>string</code>:<code class='datatype'>int</code>)</span><b>)</b><span class='class'>Stdio.Stat</span>()<br><b>(</b><span class='datatype'><code class='datatype'>array</code></span><b>)</b><span class='class'>Stdio.Stat</span>()<br></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Convert the stat object to a mapping or array.</p> </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>create</b></span> </dt> <dd><p><code><span class='object'>Stdio.Stat</span> <span class='class'>Stdio.Stat</span><b>(</b><code class='datatype'>void</code>|<code class='datatype'>object</code>|<code class='datatype'>array</code> <code class='argument'>stat</code><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>A new <code>Stdio.Stat</code> object can be initialized in two ways:</p> <ul> <li><p><code>stat</code> is an object, typically another <code>Stdio.Stat</code>. The stat info is copied from the object by getting the values of <code class='expr'>mode</code>, <code class='expr'>size</code>, <code class='expr'>atime</code>, <code class='expr'>mtime</code>, <code class='expr'>ctime</code>, <code class='expr'>uid</code>, <code class='expr'>gid</code>, <code class='expr'>dev</code>, <code class='expr'>ino</code>, <code class='expr'>nlink</code>, and <code class='expr'>rdev</code>.</p> </li><li><p><code>stat</code> is a seven element array on the 'traditional' LPC stat-array form (see the class doc).</p> </li></ul></dd></dl> </dd></dl></dd> <dt><a name='9.4'></a> <h2 class='header'>9.4. Error handling</h2></dt> <dd> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>errno</b></span> </dt> <dd><p><code><code class='datatype'>int</code> <b><span class='method'>errno</span>(</b><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>This function returns the system error from the last file operation.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>Note that you should normally use <code>Stdio.File-&gt;errno()</code> instead.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>Stdio.File-&gt;errno()</code>, <code>strerror()</code></p> </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>strerror</b></span> </dt> <dd><p><code><code class='datatype'>string</code> <b><span class='method'>strerror</span>(</b><code class='datatype'>int</code> <code class='argument'>errno</code><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>This function returns a description of an error code. The error code is usually obtained from eg <code>Stdio.File-&gt;errno()</code>.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>On some platforms the string returned can be somewhat nondescriptive.</p> </dd></dl> </dd> <dt><a name='9.5'></a> <h2 class='header'>9.5. Files and sockets</h2></dt> <dd><dl><dt><h2 class='header'>Class <b class='ms datatype'>Stdio.File</b></h2>
ed0ac82017-07-21Pontus Östlund </dt><dd><dl class='group--doc'>
e4e3f32002-04-06Martin Nilsson <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>This is the basic I/O object, it provides socket and pipe communication as well as file access. It does not buffer reads and writes by default, and provides no line-by-line reading, that is done with <code>Stdio.FILE</code> object.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>The file or stream will normally be closed when this object is destructed (unless there are more objects that refer to the same file through use of <code>assign</code> or <code>dup</code>). Objects do not contain cyclic references in themselves, so they will be destructed timely when they run out of references.</p>
e4e3f32002-04-06Martin Nilsson </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>Stdio.FILE</code></p>
e4e3f32002-04-06Martin Nilsson </dd></dl> <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>assign</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>assign</span>(</b><code class='object unresolved'>File</code>|<code class='object unresolved'>Fd</code> <code class='argument'>o</code><b>)</b></code></p></dd>
e4e3f32002-04-06Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>This function takes a clone of Stdio.File and assigns all variables of this file from it. It can be used together with <code>dup()</code> to move files around.</p>
c3fe742003-02-05Martin Nilsson </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>dup()</code></p>
e4e3f32002-04-06Martin Nilsson </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>async_connect</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>async_connect</span>(</b><code class='datatype'>string</code> <code class='argument'>host</code>, <code class='datatype'>int</code>|<code class='datatype'>string</code> <code class='argument'>port</code>, <code class='datatype'>function</code>(<code class='datatype'>int</code>, <code class='datatype'>mixed</code> ... :<code class='datatype'>void</code>) <code class='argument'>callback</code>, <code class='datatype'>mixed</code> ... <code class='argument'>args</code><b>)</b></code></p></dd>
e4e3f32002-04-06Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Open a TCP/IP connection asynchronously.</p> <p> This function is similar to <code>connect()</code>, but works asynchronously.</p> </dd> <dt class='head--doc'><span id='p-host'></span>Parameter <code class='parameter'>host</code></dt> <dd></dd><dd class='body--doc'><p>Hostname or IP to connect to.</p> </dd> <dt class='head--doc'><span id='p-port'></span>Parameter <code class='parameter'>port</code></dt> <dd></dd><dd class='body--doc'><p>Port number or service name to connect to.</p> </dd> <dt class='head--doc'><span id='p-callback'></span>Parameter <code class='parameter'>callback</code></dt> <dd></dd><dd class='body--doc'><p>Function to be called on completion. The first argument will be <code class='expr'>1</code> if a connection was successfully established, and <code class='expr'>0</code> (zero) on failure. The rest of the arguments to <code>callback</code> are passed verbatim from <code>args</code>.</p> </dd> <dt class='head--doc'><span id='p-args'></span>Parameter <code class='parameter'>args</code></dt> <dd></dd><dd class='body--doc'><p>Extra arguments to pass to <code>callback</code>.</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>Returns <code class='expr'>0</code> on failure to open a socket, and <code class='expr'>1</code> if <code>callback</code> will be used.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>The socket may be opened with <code>open_socket()</code> ahead of the call to this function, but it is not required.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>This object is put in callback mode by this function. For <code>callback</code> to be called, the backend must be active. See e.g. <code>set_read_callback</code> for more details about backends and callback mode.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>The socket will be in nonblocking state if the connection is successful, and any callbacks will be cleared.</p>
c3fe742003-02-05Martin Nilsson </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>connect()</code>, <code>open_socket()</code>, <code>set_nonblocking()</code></p>
e4e3f32002-04-06Martin Nilsson </dd></dl>
1f918f2002-05-26Martin Nilsson 
e4e3f32002-04-06Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>close</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>close</span>(</b><b>)</b></code><br> <code><code class='datatype'>int</code> <b><span class='method'>close</span>(</b><code class='datatype'>string</code> <code class='argument'>direction</code><b>)</b></code></p></dd>
e4e3f32002-04-06Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Close the file. Optionally, specify "r", "w" or "rw" to close just the read, just the write or both read and write directions of the file respectively.</p> <p> An exception is thrown if an I/O error occurs.</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>Nonzero is returned if the file wasn't open in the specified direction, zero otherwise.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>This function will not call the <tt>close_callback</tt>.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>open</code>, <code>open_socket</code></p>
e4e3f32002-04-06Martin Nilsson </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>connect</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='modifier'>variant</code> <code class='datatype'>int</code> <b><span class='method'>connect</span>(</b><code class='datatype'>string</code> <code class='argument'>host</code>, <code class='datatype'>int(0..)</code>|<code class='datatype'>string</code> <code class='argument'>port</code><b>)</b></code><br> <code><code class='modifier'>variant</code> <code class='datatype'>int</code> <b><span class='method'>connect</span>(</b><code class='datatype'>string</code> <code class='argument'>host</code>, <code class='datatype'>int(0..)</code>|<code class='datatype'>string</code> <code class='argument'>port</code>, <code class='datatype'>string</code> <code class='argument'>client</code>, <code class='datatype'>int(0..)</code>|<code class='datatype'>string</code> <code class='argument'>client_port</code><b>)</b></code><br> <code><code class='modifier'>variant</code> <code class='datatype'>string</code> <b><span class='method'>connect</span>(</b><code class='datatype'>string</code> <code class='argument'>host</code>, <code class='datatype'>int(0..)</code>|<code class='datatype'>string</code> <code class='argument'>port</code>, <code class='datatype'>string</code> <code class='argument'>data</code><b>)</b></code><br> <code><code class='modifier'>variant</code> <code class='datatype'>string</code> <b><span class='method'>connect</span>(</b><code class='datatype'>string</code> <code class='argument'>host</code>, <code class='datatype'>int(0..)</code>|<code class='datatype'>string</code> <code class='argument'>port</code>, <code class='datatype'>int(0..0)</code>|<code class='datatype'>string</code> <code class='argument'>client</code>, <code class='datatype'>int(0..)</code>|<code class='datatype'>string</code> <code class='argument'>client_port</code>, <code class='datatype'>string</code> <code class='argument'>data</code><b>)</b></code></p></dd>
e4e3f32002-04-06Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Open a TCP/IP connection to the specified destination.</p> <p> In nonblocking mode, success is indicated with the write-callback, and failure with the close-callback or the read_oob-callback.</p> <p> The <code>host</code> argument is the hostname or IP number of the remote machine.</p> <p> A local IP and port can be explicitly bound by specifying <code>client</code> and <code>client_port</code>.</p> <p> If the <code>data</code> argument is included the socket will use TCP_FAST_OPEN if posible. In this mode the the function will return the part of the data that has not been sent to the remote server yet instead of 1 (you will have to use <code>write</code> to send this data).</p> <p> Note that TCP_FAST_OPEN requires server support, the connection might fail even though the remote server exists. It might be advisable to retry without TCP_FAST_OPEN (and remember this fact)</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>This function returns 1 or the remaining <code>data</code> for success, 0 otherwise.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>In nonblocking mode <code class='expr'>0</code> (zero) may be returned and <code>errno()</code> set to <code class='expr'>EWOULDBLOCK</code> or <code class='expr'>WSAEWOULDBLOCK</code>.</p> <p> This should not be regarded as a connection failure. In nonblocking mode you need to wait for a write or close callback before you know if the connection failed or not.</p>
c3fe742003-02-05Martin Nilsson </dd>
f6a4222017-07-10Henrik Grubbström (Grubba) <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>query_address()</code>, <code>async_connect()</code>, <code>connect_unix()</code></p>
1f918f2002-05-26Martin Nilsson </dd></dl>
e4e3f32002-04-06Martin Nilsson  <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>connect_unix</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>connect_unix</span>(</b><code class='datatype'>string</code> <code class='argument'>path</code><b>)</b></code></p></dd>
f6a4222017-07-10Henrik Grubbström (Grubba)  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Open a UNIX domain socket connection to the specified destination.</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>Returns <code class='expr'>1</code> on success, and <code class='expr'>0</code> on failure.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>Nonblocking mode is not supported while connecting</p>
1f918f2002-05-26Martin Nilsson </dd></dl>
e4e3f32002-04-06Martin Nilsson  <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>create</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><span class='object'>Stdio.File</span> <span class='class'>Stdio.File</span><b>(</b><b>)</b></code><br> <code><span class='object'>Stdio.File</span> <span class='class'>Stdio.File</span><b>(</b><code class='datatype'>string</code> <code class='argument'>filename</code><b>)</b></code><br> <code><span class='object'>Stdio.File</span> <span class='class'>Stdio.File</span><b>(</b><code class='datatype'>string</code> <code class='argument'>filename</code>, <code class='datatype'>string</code> <code class='argument'>mode</code><b>)</b></code><br> <code><span class='object'>Stdio.File</span> <span class='class'>Stdio.File</span><b>(</b><code class='datatype'>string</code> <code class='argument'>filename</code>, <code class='datatype'>string</code> <code class='argument'>mode</code>, <code class='datatype'>int</code> <code class='argument'>mask</code><b>)</b></code><br> <code><span class='object'>Stdio.File</span> <span class='class'>Stdio.File</span><b>(</b><code class='datatype'>string</code> <code class='argument'>descriptorname</code><b>)</b></code><br> <code><span class='object'>Stdio.File</span> <span class='class'>Stdio.File</span><b>(</b><code class='datatype'>int</code> <code class='argument'>fd</code><b>)</b></code><br> <code><span class='object'>Stdio.File</span> <span class='class'>Stdio.File</span><b>(</b><code class='datatype'>int</code> <code class='argument'>fd</code>, <code class='datatype'>string</code> <code class='argument'>mode</code><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>There are four basic ways to create a Stdio.File object. The first is calling it without any arguments, in which case the you'd have to call <code>open()</code>, <code>connect()</code> or some other method which connects the File object with a stream.</p> <p> The second way is calling it with a <code>filename</code> and open <code>mode</code>. This is the same thing as cloning and then calling <code>open()</code>, except shorter and faster.</p> <p> The third way is to call it with <code>descriptorname</code> of <code class='expr'>"stdin"</code>, <code class='expr'>"stdout"</code> or <code class='expr'>"stderr"</code>. This will open the specified standard stream.</p> <p> For the advanced users, you can use the file descriptors of the systems (note: emulated by pike on some systems - like NT). This is only useful for streaming purposes on unix systems. This is <b>not recommended at all</b> if you don't know what you're into. Default <code>mode</code> for this is <code class='expr'>"rw"</code>.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>Open mode will be filtered through the system UMASK. You might need to use <code>chmod()</code> later.</p>
c3fe742003-02-05Martin Nilsson </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>open()</code>, <code>connect()</code>, <code>Stdio.FILE</code>,</p>
e4e3f32002-04-06Martin Nilsson </dd></dl>
f228872013-06-17Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>dup</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='object unresolved'>File</code> <b><span class='method'>dup</span>(</b><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>This function returns a clone of Stdio.File with all variables copied from this file.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>All variables, even <tt>id</tt>, are copied.</p>
f6a4222017-07-10Henrik Grubbström (Grubba) </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>assign()</code></p>
f228872013-06-17Martin Nilsson </dd></dl>
e4e3f32002-04-06Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>errno</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>errno</span>(</b><b>)</b></code></p></dd>
e4e3f32002-04-06Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Returns the error code for the last command on this file. Error code is normally cleared when a command is successful.</p>
1f918f2002-05-26Martin Nilsson </dd></dl>
e4e3f32002-04-06Martin Nilsson 
ed0ac82017-07-21Pontus Östlund <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Inherit</span> <span class='homogen--name'><b>Fd</b></span> </dt> <dd><p><code><span class='datatype'><code class='modifier'>optional</code> inherit Fd</span> : <span class='inherit'>Fd</span></code></p></dd> </dl>
f228872013-06-17Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>line_iterator</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='object unresolved'>String.SplitIterator</code>|<code class='object unresolved'>LineIterator</code> <b><span class='method'>line_iterator</span>(</b><code class='datatype'>int</code>|<code class='datatype'>void</code> <code class='argument'>trim</code><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Returns an iterator that will loop over the lines in this file. If trim is true, all <tt>'\r'</tt> characters will be removed from the input.</p>
f228872013-06-17Martin Nilsson </dd></dl>
4e6acb2014-03-03Henrik Grubbström (Grubba) <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>open</b></span>
4e6acb2014-03-03Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>open</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code>, <code class='datatype'>string</code> <code class='argument'>mode</code><b>)</b></code><br> <code><code class='datatype'>int</code> <b><span class='method'>open</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code>, <code class='datatype'>string</code> <code class='argument'>mode</code>, <code class='datatype'>int</code> <code class='argument'>mask</code><b>)</b></code></p></dd>
4e6acb2014-03-03Henrik Grubbström (Grubba)  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Open a file for read, write or append. The parameter <code>mode</code> should contain one or more of the following letters:</p> <table class='box'><tr><td><code><code class='key'>"r"</code></code></td><td><p>Open file for reading.</p> </td></tr> <tr><td><code><code class='key'>"w"</code></code></td><td><p>Open file for writing.</p> </td></tr> <tr><td><code><code class='key'>"a"</code></code></td><td><p>Open file for append (use with <code class='expr'>"w"</code>).</p> </td></tr> <tr><td><code><code class='key'>"t"</code></code></td><td><p>Truncate file at open (use with <code class='expr'>"w"</code>).</p> </td></tr> <tr><td><code><code class='key'>"c"</code></code></td><td><p>Create file if it doesn't exist (use with <code class='expr'>"w"</code>).</p> </td></tr> <tr><td><code><code class='key'>"x"</code></code></td><td><p>Fail if file already exists (use with <code class='expr'>"c"</code>).</p> </td></tr> </table><p><code>mode</code> should always contain at least one of the letters <code class='expr'>"r"</code> or <code class='expr'>"w"</code>.</p> <p> The parameter <code>mask</code> is protection bits to use if the file is created. Default is <code class='expr'>0666</code> (read+write for all in octal notation).</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>This function returns <code class='expr'>1</code> for success, <code class='expr'>0</code> otherwise.</p>
4e6acb2014-03-03Henrik Grubbström (Grubba) </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>close()</code>, <code>create()</code></p>
4e6acb2014-03-03Henrik Grubbström (Grubba) </dd></dl>
f228872013-06-17Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>open_socket</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>open_socket</span>(</b><code class='datatype'>int</code>|<code class='datatype'>string</code>|<code class='datatype'>void</code> <code class='argument'>port</code>, <code class='datatype'>string</code>|<code class='datatype'>void</code> <code class='argument'>address</code>, <code class='datatype'>int</code>|<code class='datatype'>string</code>|<code class='datatype'>void</code> <code class='argument'>family_hint</code><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>This makes this file into a socket ready for connections. The reason for this function is so that you can set the socket to nonblocking or blocking (default is blocking) before you call <code>connect()</code>.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'><span id='p-port'></span>Parameter <code class='parameter'>port</code></dt> <dd></dd><dd class='body--doc'><p>If you give a port number to this function, the socket will be bound to this port locally before connecting anywhere. This is only useful for some silly protocols like <b>FTP</b>. The port can also be specified as a string, giving the name of the service associated with the port. Pass -1 to not specify a port (eg to bind only to an address).</p> </dd> <dt class='head--doc'><span id='p-address'></span>Parameter <code class='parameter'>address</code></dt> <dd></dd><dd class='body--doc'><p>You may specify an address to bind to if your machine has many IP numbers.</p> </dd> <dt class='head--doc'><span id='p-family_hint'></span>Parameter <code class='parameter'>family_hint</code></dt> <dd></dd><dd class='body--doc'><p>A protocol family for the socket can be specified. If no family is specified, one which is appropriate for the address is automatically selected. Thus, there is normally no need to specify it. If you do not want to specify a bind address, you can provide the address as a hint here instead, to allow the automatic selection to work anyway.</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>This function returns 1 for success, 0 otherwise.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>connect()</code>, <code>set_nonblocking()</code>, <code>set_blocking()</code></p>
f228872013-06-17Martin Nilsson </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>openat</b></span>
f228872013-06-17Martin Nilsson </dt>
6d0bde2019-06-02Stephen R. van den Berg <dd><p><code><code class='object unresolved'>File</code> <b><span class='method'>openat</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code><b>)</b></code><br> <code><code class='object unresolved'>File</code> <b><span class='method'>openat</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code>, <code class='datatype'>string</code> <code class='argument'>mode</code><b>)</b></code><br>
ed0ac82017-07-21Pontus Östlund <code><code class='object unresolved'>File</code> <b><span class='method'>openat</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code>, <code class='datatype'>string</code> <code class='argument'>mode</code>, <code class='datatype'>int</code> <code class='argument'>mask</code><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Open a file relative to an open directory.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>File.statat()</code>, <code>File.unlinkat()</code></p>
f228872013-06-17Martin Nilsson </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>openpt</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>openpt</span>(</b><code class='datatype'>string</code> <code class='argument'>mode</code><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Open the master end of a pseudo-terminal pair. The parameter <code>mode</code> should contain one or more of the following letters:</p> <table class='box'><tr><td><code><code class='key'>"r"</code></code></td><td><p>Open terminal for reading.</p> </td></tr> <tr><td><code><code class='key'>"w"</code></code></td><td><p>Open terminal for writing.</p> </td></tr> </table><p><code>mode</code> should always contain at least one of the letters <code class='expr'>"r"</code> or <code class='expr'>"w"</code>.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>grantpt()</code></p>
f228872013-06-17Martin Nilsson </dd></dl>
e31eaa2014-10-04Henrik Grubbström (Grubba) <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>pipe</b></span>
e31eaa2014-10-04Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='object unresolved'>File</code> <b><span class='method'>pipe</span>(</b><code class='datatype'>void</code>|<code class='datatype'>int</code> <code class='argument'>required_properties</code><b>)</b></code></p></dd>
e31eaa2014-10-04Henrik Grubbström (Grubba) 
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>This function creates a pipe between the object it was called in and an object that is returned.</p>
e31eaa2014-10-04Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'><span id='p-required_properties'></span>Parameter <code class='parameter'>required_properties</code></dt> <dd></dd><dd class='body--doc'><p>Binary or (<code>predef::`|()</code>) of required <code class='expr'>PROP_</code> properties.</p> <table class='box'><tr><td><code><code class='key'>PROP_IPC</code></code></td><td><p>The resulting pipe may be used for inter process communication.</p> </td></tr> <tr><td><code><code class='key'>PROP_NONBLOCK</code></code></td><td><p>The resulting pipe supports nonblocking I/O.</p> </td></tr> <tr><td><code><code class='key'>PROP_SHUTDOWN</code></code></td><td><p>The resulting pipe supports shutting down transmission in either direction (see <code>close()</code>).</p> </td></tr> <tr><td><code><code class='key'>PROP_BUFFERED</code></code></td><td><p>The resulting pipe is buffered (usually 4KB).</p> </td></tr> <tr><td><code><code class='key'>PROP_BIDIRECTIONAL</code></code></td><td><p>The resulting pipe is bi-directional.</p> </td></tr> <tr><td><code><code class='key'>PROP_SEND_FD</code></code></td><td><p>The resulting pipe might support sending of file descriptors (see <code>send_fd()</code> and <code>receive_fd()</code> for details).</p> </td></tr>
688eae2020-01-20Henrik Grubbström (Grubba) <tr><td><code><code class='key'>PROP_TTY</code></code></td><td><p>The resulting pipe is a pseudo-tty.</p> </td></tr>
ed0ac82017-07-21Pontus Östlund <tr><td><code><code class='key'>PROP_REVERSE</code></code></td><td><p>The resulting pipe supports communication "backwards" (but not necessarily "forwards", see <code>PROP_BIDIRECTIONAL</code>).</p> </td></tr> </table><p>The default is <code class='expr'>PROP_NONBLOCK|PROP_BIDIRECTIONAL</code>.</p> <p> If <code>PROP_BIDIRECTIONAL</code> isn't specified, the read-end is this object, and the write-end is the returned object (unless <code>PROP_REVERSE</code> has been specified, in which case it is the other way around).</p> <p> The two ends of a bi-directional pipe are indistinguishable.</p>
688eae2020-01-20Henrik Grubbström (Grubba) <p> For <code>PROP_TTY</code> the returned object is the slave (unless <code>PROP_REVERSE</code> has been specified).</p>
ed0ac82017-07-21Pontus Östlund <p> If the File object this function is called in was open to begin with, it will be closed before the pipe is created.</p>
e31eaa2014-10-04Henrik Grubbström (Grubba) </dd>
f6a4222017-07-10Henrik Grubbström (Grubba) <dt class='head--doc'>Note</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Calling this function with an argument of <tt>0</tt> is not the same as calling it with no arguments.</p>
f6a4222017-07-10Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>Process.create_process()</code>, <code>send_fd()</code>, <code>receive_fd()</code>, <code>PROP_IPC</code>, <code>PROP_NONBLOCK</code>, <code>PROP_SEND_FD</code>, <code>PROP_SHUTDOWN</code>, <code>PROP_BUFFERED</code>, <code>PROP_REVERSE</code>,
688eae2020-01-20Henrik Grubbström (Grubba)  <code>PROP_BIDIRECTIONAL</code>, <code>PROP_TTY</code></p>
e31eaa2014-10-04Henrik Grubbström (Grubba) </dd></dl>
e4e3f32002-04-06Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>query_buffer_mode</b></span>
1f918f2002-05-26Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>array</code>(<code class='object unresolved'>Stdio.Buffer</code>|<code class='datatype'>int(0..0)</code>) <b><span class='method'>query_buffer_mode</span>(</b><b>)</b></code></p></dd>
c3fe742003-02-05Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Get the active input and output buffers that have been set with <code>set_buffer_mode()</code> (if any).</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>Returns an array with two elements:</p> <table class='box'><tr><td colspan='2'>Array</td></tr> <tr><td><code><code class='object unresolved'>Stdio.Buffer</code> <code class='key'>0</code></code></td><td><p>The current input buffer.</p> </td></tr> <tr><td><code><code class='object unresolved'>Stdio.Buffer</code> <code class='key'>1</code></code></td><td><p>The current output buffer.</p> </td></tr> </table> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>set_buffer_mode()</code></p>
c3fe742003-02-05Martin Nilsson </dd></dl>
e4e3f32002-04-06Martin Nilsson 
d961e22013-05-29Henrik Grubbström (Grubba) <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>query_read_callback</b></span><br> <span class='homogen--type'>Method</span> <span class='homogen--name'><b>query_write_callback</b></span><br> <span class='homogen--type'>Method</span> <span class='homogen--name'><b>query_read_oob_callback</b></span><br> <span class='homogen--type'>Method</span> <span class='homogen--name'><b>query_write_oob_callback</b></span><br> <span class='homogen--type'>Method</span> <span class='homogen--name'><b>query_close_callback</b></span><br> <span class='homogen--type'>Method</span> <span class='homogen--name'><b>query_callbacks</b></span><br>
d961e22013-05-29Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='object unresolved'>read_callback_t</code> <b><span class='method'>query_read_callback</span>(</b><b>)</b></code><br> <code><code class='object unresolved'>write_callback_t</code> <b><span class='method'>query_write_callback</span>(</b><b>)</b></code><br> <code><code class='datatype'>function</code>(<code class='datatype'>mixed</code>, <code class='datatype'>string</code>:<code class='datatype'>int</code>) <b><span class='method'>query_read_oob_callback</span>(</b><b>)</b></code><br> <code><code class='datatype'>function</code>(<code class='datatype'>mixed</code>:<code class='datatype'>int</code>) <b><span class='method'>query_write_oob_callback</span>(</b><b>)</b></code><br> <code><code class='datatype'>function</code>(<code class='datatype'>mixed</code>:<code class='datatype'>int</code>) <b><span class='method'>query_close_callback</span>(</b><b>)</b></code><br> <code><code class='datatype'>array</code>(<code class='datatype'>function</code>(<code class='datatype'>mixed</code>, <code class='datatype'>void</code>|<code class='datatype'>string</code>:<code class='datatype'>int</code>)) <b><span class='method'>query_callbacks</span>(</b><b>)</b></code></p></dd>
d961e22013-05-29Henrik Grubbström (Grubba)  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>These functions return the currently installed callbacks for the respective events.</p> <p> <code>query_callbacks</code> returns the callbacks in the same order as <code>set_callbacks</code> and <code>set_nonblocking</code> expect them.</p>
d961e22013-05-29Henrik Grubbström (Grubba) </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>set_nonblocking()</code>, <code>set_read_callback</code>, <code>set_write_callback</code>, <code>set_read_oob_callback</code>, <code>set_write_oob_callback</code>, <code>set_close_callback</code>, <code>set_callbacks</code></p>
d961e22013-05-29Henrik Grubbström (Grubba) </dd></dl>
2ca0cf2014-09-29Henrik Grubbström (Grubba) <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>query_id</b></span>
2ca0cf2014-09-29Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>mixed</code> <b><span class='method'>query_id</span>(</b><b>)</b></code></p></dd>
2ca0cf2014-09-29Henrik Grubbström (Grubba)  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>This function returns the <tt>id</tt> that has been set with <code>set_id()</code>.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>set_id()</code></p>
2ca0cf2014-09-29Henrik Grubbström (Grubba) </dd></dl>
5465692008-06-13Martin Bähr <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>read</b></span>
5465692008-06-13Martin Bähr </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>string(8bit)</code> <b><span class='method'>read</span>(</b><code class='datatype'>int</code>|<code class='datatype'>void</code> <code class='argument'>nbytes</code>, <code class='datatype'>bool</code>|<code class='datatype'>void</code> <code class='argument'>not_all</code><b>)</b></code></p></dd>
5465692008-06-13Martin Bähr  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Read (optionally buffered) data from a file or a stream.</p> <p> Proxy function for <code>Fd::read()</code>, that adds support for the buffering configured by <code>set_buffer_mode()</code></p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>read_function()</code>, <code>write()</code>, <code>Fd::read()</code></p>
5465692008-06-13Martin Bähr </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>read_function</b></span>
5465692008-06-13Martin Bähr </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>function</code>(:<code class='datatype'>string</code>) <b><span class='method'>read_function</span>(</b><code class='datatype'>int</code> <code class='argument'>nbytes</code><b>)</b></code></p></dd>
f6a4222017-07-10Henrik Grubbström (Grubba)  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Returns a function that when called will call <code>read</code> with nbytes as argument. Can be used to get various callback functions, eg for the fourth argument to <code>String.SplitIterator</code>.</p>
f6a4222017-07-10Henrik Grubbström (Grubba) </dd></dl>
5465692008-06-13Martin Bähr 
f228872013-06-17Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>send_fd</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>send_fd</span>(</b><code class='object unresolved'>File</code>|<code class='object unresolved'>Fd</code> <code class='argument'>file</code><b>)</b></code></p></dd> </dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>set_blocking</b></span> </dt> <dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_blocking</span>(</b><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>This function clears all callbacks and sets a stream to blocking mode. i.e. reading, writing and closing will wait until data has been transferred before returning.</p>
f228872013-06-17Martin Nilsson </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>The callbacks are cleared and blocking mode is set in one atomic operation, so no callback gets called in between if the backend is running in another thread.</p> <p> Even so, if the stream is in callback mode (i.e. if any callbacks are installed) then only the backend thread can use this function reliably; it might otherwise already be running in a callback which is about to call e.g. <code>write</code> when the stream becomes blocking.</p>
f228872013-06-17Martin Nilsson </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>set_nonblocking()</code>, <code>set_nonblocking_keep_callbacks()</code>, <code>set_blocking_keep_callbacks()</code></p>
f228872013-06-17Martin Nilsson </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>set_nonblocking_keep_callbacks</b></span><br> <span class='homogen--type'>Method</span> <span class='homogen--name'><b>set_blocking_keep_callbacks</b></span><br>
70bc302014-09-28Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_nonblocking_keep_callbacks</span>(</b><b>)</b></code><br> <code><code class='datatype'>void</code> <b><span class='method'>set_blocking_keep_callbacks</span>(</b><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Toggle between blocking and nonblocking, without changing the callbacks.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>set_nonblocking()</code>, <code>set_blocking()</code></p>
f228872013-06-17Martin Nilsson </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>set_buffer_mode</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_buffer_mode</span>(</b><code class='object unresolved'>Stdio.Buffer</code>|<code class='datatype'>int(0..0)</code> <code class='argument'>in</code>, <code class='object unresolved'>Stdio.Buffer</code>|<code class='datatype'>int(0..0)</code> <code class='argument'>out</code><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Toggle the file to Buffer mode.</p> <p> In this mode reading and writing will be done via Buffer objects, in the directions you included buffers.</p> </dd> <dt class='head--doc'><span id='p-in'></span>Parameter <code class='parameter'>in</code></dt> <dd></dd><dd class='body--doc'><p>Input buffer. If this buffer is non-empty, its contents will be returned after any already received data.</p> </dd> <dt class='head--doc'><span id='p-out'></span>Parameter <code class='parameter'>out</code></dt> <dd></dd><dd class='body--doc'><p>Output buffer. If this buffer is non-empty, its contents will be sent after any data already queued for sending.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>Normally you call <code>write</code> to re-trigger the write callback if you do not output anything in it (which will stop it from re-occuring again).</p> <p> This will work with buffered output mode as well, but simply adding more data to the output buffer will work as well.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>query_buffer_mode()</code></p>
f228872013-06-17Martin Nilsson </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>set_callbacks</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_callbacks</span>(</b><code class='object unresolved'>read_callback_t</code>|<code class='datatype'>void</code> <code class='argument'>read_cb</code>, <code class='object unresolved'>write_callback_t</code>|<code class='datatype'>void</code> <code class='argument'>write_cb</code>, <code class='datatype'>void</code>|<code class='datatype'>function</code>(<code class='datatype'>mixed</code>:<code class='datatype'>int</code>) <code class='argument'>close_cb</code>, <code class='datatype'>void</code>|<code class='datatype'>function</code>(<code class='datatype'>mixed</code>, <code class='datatype'>string</code>:<code class='datatype'>int</code>) <code class='argument'>read_oob_cb</code>, <code class='datatype'>void</code>|<code class='datatype'>function</code>(<code class='datatype'>mixed</code>:<code class='datatype'>int</code>) <code class='argument'>write_oob_cb</code><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Installs all the specified callbacks at once. Use <code>UNDEFINED</code> to keep the current setting for a callback.</p> <p> Like <code>set_nonblocking</code>, the callbacks are installed atomically. As opposed to <code>set_nonblocking</code>, this function does not do anything with the stream, and it doesn't even have to be open.</p>
f6a4222017-07-10Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>set_read_callback</code>, <code>set_write_callback</code>, <code>set_read_oob_callback</code>, <code>set_write_oob_callback</code>, <code>set_close_callback</code>, <code>query_callbacks</code></p>
f228872013-06-17Martin Nilsson </dd></dl>
ed0ac82017-07-21Pontus Östlund 
f228872013-06-17Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>set_read_callback</b></span><br> <span class='homogen--type'>Method</span> <span class='homogen--name'><b>set_write_callback</b></span><br> <span class='homogen--type'>Method</span> <span class='homogen--name'><b>set_read_oob_callback</b></span><br> <span class='homogen--type'>Method</span> <span class='homogen--name'><b>set_write_oob_callback</b></span><br> <span class='homogen--type'>Method</span> <span class='homogen--name'><b>set_close_callback</b></span><br> <span class='homogen--type'>Method</span> <span class='homogen--name'><b>set_fs_event_callback</b></span><br> </dt> <dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_read_callback</span>(</b><code class='datatype'>function</code>(<code class='datatype'>mixed</code>, <code class='datatype'>string</code>:<code class='datatype'>int</code>) <code class='argument'>read_cb</code><b>)</b></code><br> <code><code class='datatype'>void</code> <b><span class='method'>set_read_callback</span>(</b><code class='datatype'>function</code>(<code class='datatype'>mixed</code>, <code class='object unresolved'>Buffer</code>:<code class='datatype'>int</code>) <code class='argument'>read_cb</code><b>)</b></code><br> <code><code class='datatype'>void</code> <b><span class='method'>set_write_callback</span>(</b><code class='datatype'>function</code>(<code class='datatype'>mixed</code>:<code class='datatype'>int</code>) <code class='argument'>write_cb</code><b>)</b></code><br> <code><code class='datatype'>void</code> <b><span class='method'>set_write_callback</span>(</b><code class='datatype'>function</code>(<code class='datatype'>mixed</code>, <code class='object unresolved'>Buffer</code>:<code class='datatype'>int</code>) <code class='argument'>write_cb</code><b>)</b></code><br> <code><code class='datatype'>void</code> <b><span class='method'>set_read_oob_callback</span>(</b><code class='datatype'>function</code>(<code class='datatype'>mixed</code>, <code class='datatype'>string</code>:<code class='datatype'>int</code>) <code class='argument'>read_oob_cb</code><b>)</b></code><br> <code><code class='datatype'>void</code> <b><span class='method'>set_write_oob_callback</span>(</b><code class='datatype'>function</code>(<code class='datatype'>mixed</code>:<code class='datatype'>int</code>) <code class='argument'>write_oob_cb</code><b>)</b></code><br> <code><code class='datatype'>void</code> <b><span class='method'>set_close_callback</span>(</b><code class='datatype'>function</code>(<code class='datatype'>mixed</code>:<code class='datatype'>int</code>) <code class='argument'>close_cb</code><b>)</b></code><br> <code><code class='datatype'>void</code> <b><span class='method'>set_fs_event_callback</span>(</b><code class='datatype'>function</code>(<code class='datatype'>mixed</code>, <code class='datatype'>int</code>:<code class='datatype'>int</code>) <code class='argument'>fs_event_cb</code>, <code class='datatype'>int</code> <code class='argument'>event_mask</code><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>These functions set the various callbacks, which will be called when various events occur on the stream. A zero as argument will remove the callback.</p> <p> A <code>Pike.Backend</code> object is responsible for calling the callbacks. It requires a thread to be waiting in it to execute the calls. That means that only one of the callbacks will be running at a time, so you don't need mutexes between them.</p> <p> Unless you've specified otherwise with the <code>set_backend</code> function, the default backend <code>Pike.DefaultBackend</code> will be used. It's normally activated by returning <code class='expr'>-1</code> from the <tt>main</tt> function and will then execute in the main thread.</p> <ul> <li><p>When data arrives on the stream, <code>read_cb</code> will be called with some or all of that data as the second argument.</p> <p> If the file is in buffer mode, the second argument will be a Buffer.</p> <p> This will always be the same buffer, so data you do not use in one read callback can be simply left in the buffer, when new data arrives it will be appended</p> </li><li><p>When the stream has buffer space over for writing, <code>write_cb</code> will be called so that you can write more data to it.</p> <p> This callback is also called after the remote end of a socket connection has closed the write direction. An attempt to write data to it in that case will generate a <code>System.EPIPE</code> errno. If the remote end has closed both directions simultaneously (the usual case), Pike will first attempt to call <code>close_cb</code>, then this callback (unless <code>close_cb</code> has closed the stream).</p> <p> If the file is in buffer mode, the second argument will be a Buffer.</p> <p> You should add data to write to this buffer.</p> </li><li><p>When out-of-band data arrives on the stream, <code>read_oob_cb</code> will be called with some or all of that data as the second argument.</p> </li><li><p>When the stream allows out-of-band data to be sent, <code>write_oob_cb</code> will be called so that you can write more out-of-band data to it.</p> <p> If the OS doesn't separate the write events for normal and out-of-band data, Pike will try to call <code>write_oob_cb</code> first. If it doesn't write anything, then <code>write_cb</code> will be tried. This also means that <code>write_oob_cb</code> might get called when the remote end of a connection has closed the write direction.</p> </li><li><p>When an error or an end-of-stream in the read direction occurs, <code>close_cb</code> will be called. <code>errno</code> will return the error, or zero in the case of an end-of-stream.</p> <p> The name of this callback is rather unfortunate since it really has nothing to do with a close: The stream is still open when <code>close_cb</code> is called (you might not be able to read and/or write to it, but you can still use things like <code>query_address</code>, and the underlying file descriptor is still allocated). Also, this callback will not be called for a local close, neither by a call to <code>close</code> or by destructing this object.</p> <p> Also, <code>close_cb</code> will not be called if a remote close only occurs in the write direction; that is handled by <code>write_cb</code> (or possibly <code>write_oob_cb</code>).</p> <p> Events to <code>read_cb</code> and <code>close_cb</code> will be automatically deregistered if an end-of-stream occurs, and all events in the case of an error. I.e. there won't be any more calls to the callbacks unless they are reinstalled. This doesn't affect the callback settings - <code>query_read_callback</code> et al will still return the installed callbacks.</p> </li></ul><p>If the stream is a socket performing a nonblocking connect (see <code>open_socket</code> and <code>connect</code>), a connection failure will call <code>close_cb</code>, and a successful connect will call either <code>read_cb</code> or <code>write_cb</code> as above.</p> <p> All callbacks will receive the <tt>id</tt> set by <code>set_id</code> as first argument.</p> <p> If a callback returns <code class='expr'>-1</code>, no other callback or call out will be called by the backend in that round. I.e. the caller of the backend will get control back right away. For the default backend that means it will immediately start another round and check files and call outs anew.</p> </dd> <dt class='head--doc'><span id='p-event_mask'></span>Parameter <code class='parameter'>event_mask</code></dt> <dd></dd><dd class='body--doc'><p>An event mask specifing bitwise OR of one or more event types to monitor, selected from <code>Stdio.NOTE_WRITE</code> and friends.</p>
f228872013-06-17Martin Nilsson </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>These functions do not set the file nonblocking.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>Callbacks are also set by <code>set_callbacks</code> and <code>set_nonblocking()</code>.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>After a callback has been called, it's disabled until it has accessed the stream accordingly, i.e. the <code>write_cb</code> callback is disabled after it's been called until something has been written with <code>write</code>, and the <code>write_oob_cb</code> callback is likewise disabled until something has been written with <code>write_oob</code>. Since the data already has been read when the read callbacks are called, this effect is not noticeable for them.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>Installing callbacks means that you will start doing I/O on the stream from the thread running the backend. If you are running these set functions from another thread you must be prepared that the callbacks can be called immediately by the backend thread, so it might not be safe to continue using the stream in this thread.</p> <p> Because of that, it's useful to talk about "callback mode" when any callback is installed. In callback mode the stream should be seen as "bound" to the backend thread. For instance, it's only the backend thread that reliably can end callback mode before the stream is "handed over" to another thread.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>Callback mode has nothing to do with nonblocking mode - although the two often are used together they don't have to be.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>The file object will stay referenced from the backend object as long as there are callbacks that can receive events.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>Bugs</dt> <dd class='body--doc'><p>Setting a close callback without a read callback currently only works when there's no risk of getting more data on the stream. Otherwise the close callback will be silently deregistered if data arrives.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>fs_event callbacks only trigger on systems that support these events. Currently, this includes systems that use kqueue, such as Mac OS X, and various flavours of BSD.</p>
f228872013-06-17Martin Nilsson </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>set_callbacks</code>, <code>set_nonblocking()</code>, <code>set_id()</code>, <code>set_backend</code>, <code>query_read_callback</code>, <code>query_write_callback</code>, <code>query_read_oob_callback</code>, <code>query_write_oob_callback</code>, <code>query_close_callback</code></p>
f228872013-06-17Martin Nilsson </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>set_id</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_id</span>(</b><code class='datatype'>mixed</code> <code class='argument'>id</code><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>This function sets the <tt>id</tt> of this file. The <tt>id</tt> is mainly used as an identifier that is sent as the first argument to all callbacks. The default <tt>id</tt> is <code class='expr'>0</code> (zero). Another possible use of the <tt>id</tt> is to hold all data related to this file in a mapping or array.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>query_id()</code></p>
f228872013-06-17Martin Nilsson </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>set_nonblocking</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_nonblocking</span>(</b><code class='object unresolved'>read_callback_t</code> <code class='argument'>read_callback</code>, <code class='object unresolved'>write_callback_t</code> <code class='argument'>write_callback</code>, <code class='datatype'>function</code>(<code class='datatype'>mixed</code>:<code class='datatype'>int</code>) <code class='argument'>close_callback</code><b>)</b></code><br> <code><code class='datatype'>void</code> <b><span class='method'>set_nonblocking</span>(</b><code class='object unresolved'>read_callback_t</code> <code class='argument'>read_callback</code>, <code class='object unresolved'>write_callback_t</code> <code class='argument'>write_callback</code>, <code class='datatype'>function</code>(<code class='datatype'>mixed</code>:<code class='datatype'>int</code>) <code class='argument'>close_callback</code>, <code class='datatype'>function</code>(<code class='datatype'>mixed</code>, <code class='datatype'>string</code>:<code class='datatype'>int</code>) <code class='argument'>read_oob_callback</code>, <code class='datatype'>function</code>(<code class='datatype'>mixed</code>:<code class='datatype'>int</code>) <code class='argument'>write_oob_callback</code><b>)</b></code><br> <code><code class='datatype'>void</code> <b><span class='method'>set_nonblocking</span>(</b><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>This function sets a stream to nonblocking mode and installs the specified callbacks. See the <code class='expr'>set_*_callback</code> functions for details about them. If no arguments are given, the callbacks will be cleared.</p>
f6a4222017-07-10Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>As opposed to calling the set callback functions separately, this function will set all the callbacks and nonblocking mode atomically so that no callback gets called in between. That avoids races in case the backend is executed by another thread.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>Out-of-band data was not be supported on Pike 0.5 and earlier, and not on Pike 0.6 through 7.4 if they were compiled with the option <tt>'--without-oob'</tt>.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>set_blocking()</code>, <code>set_callbacks</code>, <code>set_read_callback()</code>, <code>set_write_callback()</code>, <code>set_read_oob_callback()</code>, <code>set_write_oob_callback()</code>, <code>set_close_callback()</code> <code>set_nonblocking_keep_callbacks()</code>, <code>set_blocking_keep_callbacks()</code></p> </dd></dl> </dd></dl><dl><dt><h2 class='header'>Class <b class='ms datatype'>Stdio.FILE</b></h2> </dt><dd><dl class='group--doc'> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p><code>Stdio.FILE</code> is a buffered version of <code>Stdio.File</code>, it inherits <code>Stdio.File</code> and has most of the functionality of <code>Stdio.File</code>. However, it has an input buffer that allows line-by-line input.</p> <p> It also has support for automatic charset conversion for both input and output (see <code>Stdio.FILE()-&gt;set_charset()</code>).</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>The output part of <code>Stdio.FILE</code> is currently not buffered.</p>
5465692008-06-13Martin Bähr </dd></dl>
f6a4222017-07-10Henrik Grubbström (Grubba) 
f228872013-06-17Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>_get_iterator</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><span class='class'>Stdio.FILE</span> <span class='method'>a</span>;<br> foreach( a; index; value ) or<br></code><code><code class='modifier'>protected</code> <code class='datatype'>object</code> <b><span class='method'>_get_iterator</span>(</b><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Returns an iterator that will loop over the lines in this file.</p>
f228872013-06-17Martin Nilsson </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>line_iterator()</code></p>
f228872013-06-17Martin Nilsson </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>getchar</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='modifier'>local</code> <code class='datatype'>int</code> <b><span class='method'>getchar</span>(</b><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>This function returns one character from the input stream.</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>Returns the ISO-10646 (Unicode) value of the character.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>Returns an <code class='expr'>int</code> and not a <code class='expr'>string</code> of length 1.</p>
f228872013-06-17Martin Nilsson </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>gets</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>string</code> <b><span class='method'>gets</span>(</b><code class='datatype'>bool</code>|<code class='datatype'>void</code> <code class='argument'>not_all</code><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Read one line of input with support for input conversion.</p> </dd> <dt class='head--doc'><span id='p-not_all'></span>Parameter <code class='parameter'>not_all</code></dt> <dd></dd><dd class='body--doc'><p>Set this parameter to ignore partial lines at EOF. This is useful for eg monitoring a growing logfile.</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>This function returns the line read if successful, and <code class='expr'>0</code> if no more lines are available.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>ngets()</code>, <code>read()</code>, <code>line_iterator()</code>, <code>set_charset()</code></p>
f228872013-06-17Martin Nilsson </dd></dl>
70bc302014-09-28Henrik Grubbström (Grubba) <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Inherit</span> <span class='homogen--name'><b>file</b></span>
70bc302014-09-28Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><span class='datatype'>inherit File</span> : <span class='inherit'>file</span></code></p></dd>
70bc302014-09-28Henrik Grubbström (Grubba) </dl>
5465692008-06-13Martin Bähr <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>line_iterator</b></span>
5465692008-06-13Martin Bähr </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>object</code> <b><span class='method'>line_iterator</span>(</b><code class='datatype'>int</code>|<code class='datatype'>void</code> <code class='argument'>trim</code><b>)</b></code></p></dd>
5465692008-06-13Martin Bähr  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Returns an iterator that will loop over the lines in this file. If <code>trim</code> is true, all <tt>'\r'</tt> characters will be removed from the input.</p>
5465692008-06-13Martin Bähr </dd>
f6a4222017-07-10Henrik Grubbström (Grubba) <dt class='head--doc'>Note</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>It's not supported to call this method more than once unless a call to <code>seek</code> is done in advance. Also note that it's not possible to intermingle calls to <code>read</code>, <code>gets</code> or other functions that read data with the line iterator, it will produce unexpected results since the internal buffer in the iterator will not contain sequential file-data in those cases.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>_get_iterator()</code></p>
5465692008-06-13Martin Bähr </dd></dl>
f228872013-06-17Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>ngets</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>array</code>(<code class='datatype'>string</code>) <b><span class='method'>ngets</span>(</b><code class='datatype'>void</code>|<code class='datatype'>int(1..)</code> <code class='argument'>n</code>, <code class='datatype'>bool</code>|<code class='datatype'>void</code> <code class='argument'>not_all</code><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Get <code>n</code> lines.</p> </dd> <dt class='head--doc'><span id='p-n'></span>Parameter <code class='parameter'>n</code></dt> <dd></dd><dd class='body--doc'><p>Number of lines to get, or all remaining if zero.</p> </dd> <dt class='head--doc'><span id='p-not_all'></span>Parameter <code class='parameter'>not_all</code></dt> <dd></dd><dd class='body--doc'><p>Set this parameter to ignore partial lines at EOF. This is useful for eg monitoring a growing logfile.</p>
f228872013-06-17Martin Nilsson </dd></dl>
5465692008-06-13Martin Bähr <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>openat</b></span>
5465692008-06-13Martin Bähr </dt>
6d0bde2019-06-02Stephen R. van den Berg <dd><p><code><code class='object unresolved'>FILE</code> <b><span class='method'>openat</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code><b>)</b></code><br> <code><code class='object unresolved'>FILE</code> <b><span class='method'>openat</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code>, <code class='datatype'>string</code> <code class='argument'>mode</code><b>)</b></code><br>
ed0ac82017-07-21Pontus Östlund <code><code class='object unresolved'>FILE</code> <b><span class='method'>openat</span>(</b><code class='datatype'>string</code> <code class='argument'>filename</code>, <code class='datatype'>string</code> <code class='argument'>mode</code>, <code class='datatype'>int</code> <code class='argument'>mask</code><b>)</b></code></p></dd>
5465692008-06-13Martin Bähr  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Same as <code>Stdio.File()-&gt;openat()</code>, but returns an <code>Stdio.FILE</code> object.</p>
5465692008-06-13Martin Bähr </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>Stdio.File()-&gt;openat()</code></p>
5465692008-06-13Martin Bähr </dd></dl>
f228872013-06-17Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>pipe</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='object unresolved'>FILE</code> <b><span class='method'>pipe</span>(</b><code class='datatype'>void</code>|<code class='datatype'>int</code> <code class='argument'>flags</code><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Same as <code>Stdio.File()-&gt;pipe()</code>, but returns an <code>Stdio.FILE</code> object.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>Stdio.File()-&gt;pipe()</code></p>
f228872013-06-17Martin Nilsson </dd></dl>
b34a222014-09-15Per Hedbor <hr /> <dl class='group--doc'>
70bc302014-09-28Henrik Grubbström (Grubba) <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>printf</b></span>
b34a222014-09-15Per Hedbor </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>printf</span>(</b><code class='datatype'>string</code> <code class='argument'>format</code>, <code class='datatype'>mixed</code> ... <code class='argument'>data</code><b>)</b></code></p></dd>
b34a222014-09-15Per Hedbor  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>This function does approximately the same as: <code class='expr'><code>write</code>(<code>sprintf</code>(<code>format</code>,@<code>data</code>))</code>.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>write()</code>, <code>sprintf()</code></p>
b34a222014-09-15Per Hedbor </dd></dl>
5465692008-06-13Martin Bähr <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>read</b></span>
5465692008-06-13Martin Bähr </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>string</code> <b><span class='method'>read</span>(</b><code class='datatype'>int</code>|<code class='datatype'>void</code> <code class='argument'>bytes</code>, <code class='datatype'>void</code>|<code class='datatype'>bool</code> <code class='argument'>now</code><b>)</b></code></p></dd>
5465692008-06-13Martin Bähr  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Read <code>bytes</code> (wide-) characters with buffering and support for input conversion.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>Stdio.File()-&gt;read()</code>, <code>set_charset()</code>, <code>unread()</code></p>
5465692008-06-13Martin Bähr </dd></dl>
f228872013-06-17Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>set_charset</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_charset</span>(</b><code class='datatype'>string</code>|<code class='datatype'>void</code> <code class='argument'>charset</code><b>)</b></code></p></dd>
70bc302014-09-28Henrik Grubbström (Grubba)  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Sets the input and output charset of this file to the specified <code>charset</code>. If <code>charset</code> is 0 or not specified the environment is used to try to detect a suitable charset.</p> <p> The default charset if this function is not called is <tt>"ISO-8859-1"</tt>.</p> </dd><dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Consider using one of ISO-IR-196 (<tt>"\e%G"</tt> - switch to UTF-8 with return) or ISO-IR-190 (<tt>"\e%/G"</tt> - switch to UTF-8 level 1 no return) or ISO-IR-191 (<tt>"\e%/H"</tt> - switch to UTF-8 level 2 no return) or ISO-IR-192 (<tt>"\e%/I"</tt> - switch to UTF-8 level 3 no return) or ISO-IR-193 (<tt>"\e%/J"</tt> - switch to UTF-16 level 1 no return) or ISO-IR-194 (<tt>"\e%/K"</tt> - switch to UTF-16 level 2 no return) or ISO-IR-195 (<tt>"\e%/L"</tt> - switch to UTF-16 level 3 no return) or ISO-IR-162 (<tt>"\e%/@"</tt> - switch to UCS-2 level 1) or ISO-IR-163 (<tt>"\e%/A"</tt> - switch to UCS-4 level 1) or ISO-IR-174 (<tt>"\e%/C"</tt> - switch to UCS-2 level 2) or ISO-IR-175 (<tt>"\e%/D"</tt> - switch to UCS-4 level 2) or ISO-IR-176 (<tt>"\e%/E"</tt> - switch to UCS-2 level 3) or ISO-IR-177 (<tt>"\e%/F"</tt> - switch to UCS-4 level 3) or ISO-IR-178 (<tt>"\e%B"</tt> - switch to UTF-1) automatically to encode wide strings.</p>
f228872013-06-17Martin Nilsson </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>ungets</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>ungets</span>(</b><code class='datatype'>string</code> <code class='argument'>s</code><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>This function puts a line back in the input buffer. The line can then be read with eg <code>read()</code>, <code>gets()</code> or <code>getchar()</code>.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>The string is autoterminated by an extra line-feed.</p>
f228872013-06-17Martin Nilsson </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>read()</code>, <code>gets()</code>, <code>getchar()</code>, <code>unread()</code></p>
f228872013-06-17Martin Nilsson </dd></dl>
ed0ac82017-07-21Pontus Östlund 
f228872013-06-17Martin Nilsson <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>unread</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>unread</span>(</b><code class='datatype'>string</code> <code class='argument'>s</code><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>This function puts a string back in the input buffer. The string can then be read with eg <code>read()</code>, <code>gets()</code> or <code>getchar()</code>.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>read()</code>, <code>gets()</code>, <code>getchar()</code>, <code>ungets()</code></p>
f228872013-06-17Martin Nilsson </dd></dl>
ed0ac82017-07-21Pontus Östlund 
f228872013-06-17Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>write</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>write</span>(</b><code class='datatype'>array</code>(<code class='datatype'>string</code>)|<code class='datatype'>string</code> <code class='argument'>what</code>, <code class='datatype'>mixed</code> ... <code class='argument'>fmt</code><b>)</b></code></p></dd>
f6a4222017-07-10Henrik Grubbström (Grubba) 
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Write <code>what</code> with support for output_conversion.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>Stdio.File()-&gt;write()</code></p> </dd></dl>
9add812019-07-04Henrik Grubbström (Grubba) </dd></dl></dd> <dt><a name='9.6'></a> <h2 class='header'>9.6. Ports and UDP</h2></dt> <dd><dl><dt><h2 class='header'>Class <b class='ms datatype'>Stdio.Port</b></h2>
70bc302014-09-28Henrik Grubbström (Grubba) </dt><dd><dl class='group--doc'> <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Handles listening to socket ports. Whenever you need a bound socket that is open and listens for connections you should use this program.</p>
f228872013-06-17Martin Nilsson </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>accept</b></span>
f6a4222017-07-10Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='object unresolved'>File</code> <b><span class='method'>accept</span>(</b><b>)</b></code></p></dd>
f6a4222017-07-10Henrik Grubbström (Grubba) 
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>This function completes a connection made from a remote machine to this port. It returns a two-way stream in the form of a clone of <code>Stdio.File</code>. The new file is by initially set to blocking mode.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>Stdio.File</code></p> </dd></dl>
f228872013-06-17Martin Nilsson  <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>accept</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='object unresolved'>Stdio.File</code> <b><span class='method'>accept</span>(</b><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Get the first connection request waiting for this port and return it as a connected socket.</p> <p> If no connection request is waiting and the port is in nonblocking mode (i.e. an accept callback is installed) then zero is returned. Otherwise this function waits until a connection has arrived.</p> <p> In Pike 7.8 and later the returned object is created via <code>fd_factory()</code>.</p>
f228872013-06-17Martin Nilsson </dd> <dt class='head--doc'>Note</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>In Pike 7.7 and later the resulting file object will be assigned to the same backend as the port object.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd></dl>
60c5b22010-11-19Henrik Grubbström (Grubba) 
f228872013-06-17Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>bind</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>bind</span>(</b><code class='datatype'>int</code>|<code class='datatype'>string</code> <code class='argument'>port</code>, <code class='datatype'>void</code>|<code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>accept_callback</code>, <code class='datatype'>void</code>|<code class='datatype'>string</code> <code class='argument'>ip</code>, <code class='datatype'>void</code>|<code class='datatype'>string</code> <code class='argument'>reuse_port</code><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Opens a socket and binds it to port number on the local machine. If the second argument is present, the socket is set to nonblocking and the callback funcition is called whenever something connects to it. The callback will receive the id for this port as argument and should typically call <code>accept</code> to establish a connection.</p> <p> If the optional argument <code>ip</code> is given, <code>bind</code> will try to bind to an interface with that host name or IP number. Omitting this will bind to all available IPv4 addresses; specifying "::" will bind to all IPv4 and IPv6 addresses.</p> <p> If the OS supports TCP_FASTOPEN it is enabled automatically.</p> <p> If the OS supports SO_REUSEPORT it is enabled if the fourth argument is true.</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>1 is returned on success, zero on failure. <code>errno</code> provides further details about the error in the latter case.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>accept</code>, <code>set_id</code></p>
f228872013-06-17Martin Nilsson </dd></dl>
e4e3f32002-04-06Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>bind_unix</b></span>
f6a4222017-07-10Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>bind_unix</span>(</b><code class='datatype'>string</code> <code class='argument'>path</code>, <code class='datatype'>void</code>|<code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>accept_callback</code><b>)</b></code></p></dd>
f6a4222017-07-10Henrik Grubbström (Grubba)  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Opens a Unix domain socket at the given path in the file system. If the second argument is present, the socket is set to nonblocking and the callback funcition is called whenever something connects to it. The callback will receive the id for this port as argument and should typically call <code>accept</code> to establish a connection.</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>1 is returned on success, zero on failure. <code>errno</code> provides further details about the error in the latter case.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>This function is only available on systems that support Unix domain sockets.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p><code>path</code> had a quite restrictive length limit (~100 characters) prior to Pike 7.8.334.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>accept</code>, <code>set_id</code></p>
f6a4222017-07-10Henrik Grubbström (Grubba) </dd></dl>
ed0ac82017-07-21Pontus Östlund 
f6a4222017-07-10Henrik Grubbström (Grubba) <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>close</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>close</span>(</b><b>)</b></code></p></dd>
1f918f2002-05-26Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Closes the socket.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>create</b></span>
70bc302014-09-28Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><span class='object'>Stdio.Port</span> <span class='class'>Stdio.Port</span><b>(</b><b>)</b></code><br> <code><span class='object'>Stdio.Port</span> <span class='class'>Stdio.Port</span><b>(</b><code class='datatype'>int</code>|<code class='datatype'>string</code> <code class='argument'>port</code><b>)</b></code><br> <code><span class='object'>Stdio.Port</span> <span class='class'>Stdio.Port</span><b>(</b><code class='datatype'>int</code>|<code class='datatype'>string</code> <code class='argument'>port</code>, <code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>accept_callback</code><b>)</b></code><br> <code><span class='object'>Stdio.Port</span> <span class='class'>Stdio.Port</span><b>(</b><code class='datatype'>int</code>|<code class='datatype'>string</code> <code class='argument'>port</code>, <code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>accept_callback</code>, <code class='datatype'>string</code> <code class='argument'>ip</code><b>)</b></code><br> <code><span class='object'>Stdio.Port</span> <span class='class'>Stdio.Port</span><b>(</b><code class='argument'>"stdin"</code><b>)</b></code><br> <code><span class='object'>Stdio.Port</span> <span class='class'>Stdio.Port</span><b>(</b><code class='argument'>"stdin"</code>, <code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>accept_callback</code><b>)</b></code></p></dd>
70bc302014-09-28Henrik Grubbström (Grubba)  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>If the first argument is other than <code class='expr'>"stdin"</code> the arguments will be passed to <code>bind()</code>.</p> <p> When create is called with <code class='expr'>"stdin"</code> as the first argument, a socket is created out of the file descriptor <code class='expr'>0</code>. This is only useful if it actually is a socket to begin with, and is equivalent to creating a port and initializing it with <code>listen_fd</code>(0).</p>
f6a4222017-07-10Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>bind</code></p> </dd></dl>
f228872013-06-17Martin Nilsson  <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>create</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><span class='object'>Stdio.Port</span> <span class='class'>Stdio.Port</span><b>(</b><code class='datatype'>int</code>|<code class='datatype'>string</code> <code class='argument'>port</code>, <code class='datatype'>void</code>|<code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>accept_callback</code>, <code class='datatype'>void</code>|<code class='datatype'>string</code> <code class='argument'>ip</code><b>)</b></code><br> <code><span class='object'>Stdio.Port</span> <span class='class'>Stdio.Port</span><b>(</b><code class='argument'>"stdin"</code>, <code class='datatype'>void</code>|<code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>accept_callback</code><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>When called with an int or any string except <code class='expr'>"stdin"</code> as first argument, this function does the same as <code>bind()</code> would do with the same arguments.</p> <p> When called with <code class='expr'>"stdin"</code> as argument, a socket is created out of the file descriptor 0. This is only useful if that actually IS a socket to begin with, and is equivalent to creating a port and initializing it with <code>listen_fd</code>(0).</p>
f228872013-06-17Martin Nilsson </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>bind</code>, <code>listen_fd</code></p>
5465692008-06-13Martin Bähr </dd></dl>
ed0ac82017-07-21Pontus Östlund 
e4e3f32002-04-06Martin Nilsson <hr /> <dl class='group--doc'>
50af352002-07-15Martin Nilsson <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>errno</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>errno</span>(</b><b>)</b></code></p></dd>
1f918f2002-05-26Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>If the last call done on this port failed, this function will return an integer describing what went wrong. Refer to your unix manual for further information.</p>
1f918f2002-05-26Martin Nilsson </dd></dl>
e4e3f32002-04-06Martin Nilsson 
f228872013-06-17Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>fd_factory</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='modifier'>protected</code> <code class='object unresolved'>Fd</code> <b><span class='method'>fd_factory</span>(</b><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Factory creating empty <code>Fd</code> objects.</p> <p> This function is called by <code>accept()</code> when it needs to create a new file.</p>
f228872013-06-17Martin Nilsson </dd></dl>
2326c02014-09-03Per Hedbor <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Inherit</span> <span class='homogen--name'><b>_port</b></span>
2326c02014-09-03Per Hedbor </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><span class='datatype'>inherit _port</span> : <span class='inherit'>_port</span></code></p></dd> </dl>
2326c02014-09-03Per Hedbor 
f7261b2009-04-25Martin Stjernholm <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>listen_fd</b></span>
f7261b2009-04-25Martin Stjernholm </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>listen_fd</span>(</b><code class='datatype'>int</code> <code class='argument'>fd</code>, <code class='datatype'>void</code>|<code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>accept_callback</code><b>)</b></code></p></dd>
f7261b2009-04-25Martin Stjernholm  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>This function does the same as <code>bind</code>, except that instead of creating a new socket and bind it to a port, it expects the file descriptor <code>fd</code> to be an already open port.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>This function is only for the advanced user, and is generally used when sockets are passed to Pike at exec time.</p>
f6a4222017-07-10Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>bind</code>, <code>accept</code></p>
f7261b2009-04-25Martin Stjernholm </dd></dl>
e4e3f32002-04-06Martin Nilsson <hr /> <dl class='group--doc'>
50af352002-07-15Martin Nilsson <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>query_address</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>string</code> <b><span class='method'>query_address</span>(</b><b>)</b></code></p></dd>
c3fe742003-02-05Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Get the address and port of the local socket end-point.</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>This function returns the address and port of a socket end-point on the form <code class='expr'>"x.x.x.x&nbsp;port"</code> (IPv4) or <code class='expr'>"x:x:x:x:x:x:x:x&nbsp;port"</code> (IPv6).</p> <p> If there is some error querying or formatting the address, <code class='expr'>0</code> (zero) is returned and <code>errno()</code> will return the error code.</p> </dd> <dt class='head--doc'>Throws</dt> <dd class='body--doc'><p>An error is thrown if the socket isn't bound.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>query_backend</b></span>
70bc302014-09-28Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='object unresolved'>Pike.Backend</code> <b><span class='method'>query_backend</span>(</b><b>)</b></code></p></dd>
70bc302014-09-28Henrik Grubbström (Grubba)  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Return the backend used for the accept callback.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>set_backend</code></p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd></dl>
f03c622015-05-18Henrik Grubbström (Grubba) <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>query_fd</b></span>
f03c622015-05-18Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>query_fd</span>(</b><b>)</b></code></p></dd>
f03c622015-05-18Henrik Grubbström (Grubba)  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Returns the file descriptor number associated with this object.</p>
f03c622015-05-18Henrik Grubbström (Grubba) </dd></dl>
70bc302014-09-28Henrik Grubbström (Grubba) <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>query_id</b></span>
70bc302014-09-28Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>mixed</code> <b><span class='method'>query_id</span>(</b><b>)</b></code></p></dd>
70bc302014-09-28Henrik Grubbström (Grubba)  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>This function returns the id for this port. The id is normally the first argument to accept_callback.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>set_id</code></p>
c3fe742003-02-05Martin Nilsson </dd></dl>
e4e3f32002-04-06Martin Nilsson 
f228872013-06-17Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>set_backend</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_backend</span>(</b><code class='object unresolved'>Pike.Backend</code> <code class='argument'>backend</code><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Set the backend used for the accept callback.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>The backend keeps a reference to this object as long as the port is accepting connections, but this object does not keep a reference to the backend.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>query_backend</code></p>
f228872013-06-17Martin Nilsson </dd></dl>
e4e3f32002-04-06Martin Nilsson <hr /> <dl class='group--doc'>
50af352002-07-15Martin Nilsson <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>set_id</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>mixed</code> <b><span class='method'>set_id</span>(</b><code class='datatype'>mixed</code> <code class='argument'>id</code><b>)</b></code></p></dd>
e4e3f32002-04-06Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>This function sets the id used for accept_callback by this port. The default id is <code>this_object()</code>.</p> </dd>
0831ad2020-03-07Henrik Grubbström (Grubba) <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>In Pike 8.0 and earlier the default value was <code class='expr'>0</code> (zero) (even though it was documented as above).</p> </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>query_id</code></p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd></dl>
ed0ac82017-07-21Pontus Östlund </dd></dl><dl><dt><h2 class='header'>Class <b class='ms datatype'>Stdio.UDP</b></h2>
70bc302014-09-28Henrik Grubbström (Grubba) </dt><dd><dl class='group--doc'> <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>UDP (User Datagram Protocol) handling.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd></dl> <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Constant</span> <span class='homogen--name'><b>MSG_OOB</b></span>
70bc302014-09-28Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>constant</code> Stdio.UDP.<code class='constant'>MSG_OOB</code></code></p></dd>
115afe2020-04-17Henrik Grubbström (Grubba)  <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Flag to specify to <code>read()</code> to read out of band packets.</p>
ed0ac82017-07-21Pontus Östlund </dd></dl>
e4e3f32002-04-06Martin Nilsson 
ed0ac82017-07-21Pontus Östlund  <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Constant</span> <span class='homogen--name'><b>MSG_PEEK</b></span> </dt> <dd><p><code><code class='datatype'>constant</code> Stdio.UDP.<code class='constant'>MSG_PEEK</code></code></p></dd>
115afe2020-04-17Henrik Grubbström (Grubba)  <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Flag to specify to <code>read()</code> to cause it to not remove the packet from the input buffer.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd></dl>
f228872013-06-17Martin Nilsson  <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>add_membership</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>add_membership</span>(</b><code class='datatype'>string</code> <code class='argument'>group</code>, <code class='datatype'>void</code>|<code class='datatype'>string</code> <code class='argument'>address</code><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Join a multicast group.</p> </dd> <dt class='head--doc'><span id='p-group'></span>Parameter <code class='parameter'>group</code></dt> <dd></dd><dd class='body--doc'><p><code>group</code> contains the address of the multicast group the application wants to join. It must be a valid multicast address.</p> </dd> <dt class='head--doc'><span id='p-address'></span>Parameter <code class='parameter'>address</code></dt> <dd></dd><dd class='body--doc'><p><code>address</code> is the address of the local interface with which the system should join to the multicast group. If not provided the system will select an appropriate interface.</p> <p> See also the Unix man page for setsocketopt IPPROTO_IP IP_ADD_MEMBERSHIP and IPPROTO_IPV6 IPV6_JOIN_GROUP.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>The <code>address</code> parameter is currently not supported for IPv6.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>This function did not support IPv6 in Pike 7.8 and earlier.</p>
f228872013-06-17Martin Nilsson </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>drop_membership()</code></p>
f228872013-06-17Martin Nilsson </dd></dl>
45eff82002-06-11Johan Sundström <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>bind</b></span>
45eff82002-06-11Johan Sundström </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='object unresolved'>UDP</code> <b><span class='method'>bind</span>(</b><code class='datatype'>int</code>|<code class='datatype'>string</code> <code class='argument'>port</code>, <code class='datatype'>string</code>|<code class='datatype'>void</code> <code class='argument'>address</code>, <code class='datatype'>string</code>|<code class='datatype'>bool</code> <code class='argument'>no_reuseaddr</code><b>)</b></code></p></dd>
45eff82002-06-11Johan Sundström 
50af352002-07-15Martin Nilsson <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Binds a port for receiving or transmitting UDP.</p>
afee992015-10-13Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'><span id='p-port'></span>Parameter <code class='parameter'>port</code></dt> <dd></dd><dd class='body--doc'><p>Either a port number or the name of a service as listed in <tt>/etc/services</tt>.</p>
afee992015-10-13Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'><span id='p-address'></span>Parameter <code class='parameter'>address</code></dt> <dd></dd><dd class='body--doc'><p>Local address to bind to.</p>
0f4adf2003-07-22Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'><span id='p-no_reuseaddr'></span>Parameter <code class='parameter'>no_reuseaddr</code></dt> <dd></dd><dd class='body--doc'><p>If set to <code class='expr'>1</code>, Pike will not set the <code class='expr'>SO_REUSEADDR</code> option on the UDP port.</p>
c3fe742003-02-05Martin Nilsson </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>Note</dt> <dd class='body--doc'><p><code class='expr'>SO_REUSEADDR</code> is never applied when binding a random port (<code class='expr'>bind(0)</code>).</p> <p> In general, <code class='expr'>SO_REUSEADDR</code> is not desirable on UDP ports. Unless used for receiving multicast, be sure to never bind a non-random port without setting <code class='expr'>no_reuseaddr</code> to <code class='expr'>1</code>.</p> </dd> <dt class='head--doc'>Throws</dt> <dd class='body--doc'><p>Throws error when unable to bind port.</p>
c3fe742003-02-05Martin Nilsson </dd></dl>
45eff82002-06-11Johan Sundström 
f228872013-06-17Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>close</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>bool</code> <b><span class='method'>close</span>(</b><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Closes an open UDP port.</p>
f228872013-06-17Martin Nilsson </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>This method was introduced in Pike 7.5.</p>
f228872013-06-17Martin Nilsson </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>connect</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>bool</code> <b><span class='method'>connect</span>(</b><code class='datatype'>string</code> <code class='argument'>address</code>, <code class='datatype'>int</code>|<code class='datatype'>string</code> <code class='argument'>port</code><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Establish an UDP connection.</p> <p> This function connects an UDP socket previously created with <code>Stdio.UDP()</code> to a remote socket. The <code>address</code> is the IP name or number for the remote machine.</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>Returns <code class='expr'>1</code> on success, <code class='expr'>0</code> (zero) otherwise.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>If the socket is in nonblocking mode, you have to wait for a write or close callback before you know if the connection failed or not.</p>
f228872013-06-17Martin Nilsson </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>bind()</code>, <code>query_address()</code></p>
f228872013-06-17Martin Nilsson </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>drop_membership</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>drop_membership</span>(</b><code class='datatype'>string</code> <code class='argument'>group</code>, <code class='datatype'>void</code>|<code class='datatype'>string</code> <code class='argument'>address</code><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Leave a multicast group.</p> </dd> <dt class='head--doc'><span id='p-group'></span>Parameter <code class='parameter'>group</code></dt> <dd></dd><dd class='body--doc'><p><code>group</code> contains the address of the multicast group the application wants to join. It must be a valid multicast address.</p> </dd> <dt class='head--doc'><span id='p-address'></span>Parameter <code class='parameter'>address</code></dt> <dd></dd><dd class='body--doc'><p><code>address</code> is the address of the local interface with which the system should join to the multicast group. If not provided the system will select an appropriate interface.</p> <p> See also the Unix man page for setsocketopt IPPROTO_IP IP_DROP_MEMBERSHIP and IPPROTO_IPV6 IPV6_LEAVE_GROUP.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>The <code>address</code> parameter is currently not supported for IPv6.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>This function did not support IPv6 in Pike 7.8 and earlier.</p>
f228872013-06-17Martin Nilsson </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>add_membership()</code></p>
f228872013-06-17Martin Nilsson </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>enable_broadcast</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>bool</code> <b><span class='method'>enable_broadcast</span>(</b><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Set the broadcast flag. If enabled then sockets receive packets sent to a broadcast address and they are allowed to send packets to a broadcast address.</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>Returns <code class='expr'>1</code> on success, <code class='expr'>0</code> (zero) otherwise.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>This is normally only avalable to root users.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>enable_multicast</b></span>
70bc302014-09-28Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>bool</code> <b><span class='method'>enable_multicast</span>(</b><code class='datatype'>string</code> <code class='argument'>reply_address</code><b>)</b></code></p></dd>
70bc302014-09-28Henrik Grubbström (Grubba)  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Set the local device for a multicast socket.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'><span id='p-reply_address'></span>Parameter <code class='parameter'>reply_address</code></dt> <dd></dd><dd class='body--doc'><p>Local address that should appear in the multicast packets.</p> <p> See also the Unix man page for setsocketopt IPPROTO_IP IP_MULTICAST_IF and IPPROTO_IPV6 IPV6_MULTICAST_IF.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>This function did not support IPv6 in Pike 7.8.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>errno</b></span>
70bc302014-09-28Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>errno</span>(</b><b>)</b></code></p></dd>
70bc302014-09-28Henrik Grubbström (Grubba)  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Returns the error code for the last command on this object. Error code is normally cleared when a command is successful.</p>
f228872013-06-17Martin Nilsson </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>get_type</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>array</code>(<code class='datatype'>int</code>) <b><span class='method'>get_type</span>(</b><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Returns socket type and protocol family.</p>
f228872013-06-17Martin Nilsson </dd></dl>
70bc302014-09-28Henrik Grubbström (Grubba) <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Inherit</span> <span class='homogen--name'><b>UDP</b></span>
70bc302014-09-28Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><span class='datatype'>inherit _Stdio.UDP</span> : <span class='inherit'>UDP</span></code></p></dd> </dl>
70bc302014-09-28Henrik Grubbström (Grubba) 
c3fe742003-02-05Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>query_address</b></span>
c3fe742003-02-05Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>string</code> <b><span class='method'>query_address</span>(</b><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Returns the local address of a socket on the form "x.x.x.x port". If this file is not a socket, not connected or some other error occurs, zero is returned.</p>
f228872013-06-17Martin Nilsson </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>query_backend</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='object unresolved'>Pike.Backend</code> <b><span class='method'>query_backend</span>(</b><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Return the backend used for the read callback.</p>
f228872013-06-17Martin Nilsson </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>set_backend</code></p>
f228872013-06-17Martin Nilsson </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>query_fd</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>query_fd</span>(</b><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Gets the file descriptor for this UDP port.</p>
f228872013-06-17Martin Nilsson </dd></dl>
74709c2020-04-24Henrik Grubbström (Grubba) <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>query_mtu</b></span> </dt> <dd><p><code><code class='datatype'>int</code> <b><span class='method'>query_mtu</span>(</b><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Get the Max Transfer Unit for the object (if any).</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><table class='box'><tr><td><code><code class='key'>-1</code></code></td><td><p>Returns <code class='expr'>-1</code> if the object is not a socket or if the mtu is unknown.</p> </td></tr> <tr><td><code><code class='key'>(1..)</code></code></td><td><p>Returns a positive value with the mtu on success.</p> </td></tr>
f9de972020-04-25Henrik Grubbström (Grubba) </table> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>The returned value is adjusted to take account for the IP and UDP headers, so that it should be usable without further adjustment unless further IP options are in use.</p> </dd></dl>
74709c2020-04-24Henrik Grubbström (Grubba) 
f228872013-06-17Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>read</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>mapping</code>(<code class='datatype'>string</code>:<code class='datatype'>int</code>|<code class='datatype'>string</code>) <b><span class='method'>read</span>(</b><b>)</b></code><br> <code><code class='datatype'>mapping</code>(<code class='datatype'>string</code>:<code class='datatype'>int</code>|<code class='datatype'>string</code>) <b><span class='method'>read</span>(</b><code class='datatype'>int</code> <code class='argument'>flag</code><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Read from the UDP socket.</p> <p> Flag <code>flag</code> is a bitfield, 1 for out of band data and 2 for peek</p> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>mapping(string:int|string) in the form ([ "data" : string received data "ip" : string received from this ip "port" : int ...and this port ])</p>
f228872013-06-17Martin Nilsson </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>set_read_callback()</code>, <code>MSG_OOB</code>, <code>MSG_PEEK</code></p>
f228872013-06-17Martin Nilsson </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>send</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>send</span>(</b><code class='datatype'>string</code> <code class='argument'>to</code>, <code class='datatype'>int</code>|<code class='datatype'>string</code> <code class='argument'>port</code>, <code class='datatype'>string</code> <code class='argument'>message</code><b>)</b></code><br> <code><code class='datatype'>int</code> <b><span class='method'>send</span>(</b><code class='datatype'>string</code> <code class='argument'>to</code>, <code class='datatype'>int</code>|<code class='datatype'>string</code> <code class='argument'>port</code>, <code class='datatype'>string</code> <code class='argument'>message</code>, <code class='datatype'>int</code> <code class='argument'>flags</code><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
1cb9732020-04-26Henrik Grubbström (Grubba) <dd class='body--doc'><p>Send data to a UDP socket.</p> </dd> <dt class='head--doc'><span id='p-to'></span>Parameter <code class='parameter'>to</code></dt> <dd></dd><dd class='body--doc'><p>The recipient address. For <code>connect()</code>ed objects specifying a recipient of either <code>UNDEFINED</code> or <code class='expr'>""</code> causes the default recipient to be used.</p> </dd> <dt class='head--doc'><span id='p-port'></span>Parameter <code class='parameter'>port</code></dt> <dd></dd><dd class='body--doc'><p>The recipient port number. For <code>connect()</code>ed objects specifying port number <code class='expr'>0</code> casues the default recipient port to be used.</p> </dd> <dt class='head--doc'><span id='p-flag'></span>Parameter <code class='parameter'>flag</code></dt> <dd></dd><dd class='body--doc'><p>A flag bitfield with <code class='expr'>1</code> for out of band data and <code class='expr'>2</code> for don't route flag.</p>
ed0ac82017-07-21Pontus Östlund </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><table class='box'><tr><td><code><code class='key'>(0..)</code></code></td><td><p>The number of bytes that were actually written.</p> </td></tr> <tr><td><code><code class='key'>(..-1)</code></code></td><td><p>Failed to send the <code>message</code>. Check <code>errno()</code> for the cause. Common causes are:</p> <table class='box'><tr><td><code><code class='key'>System.EMSGSIZE</code></code></td><td><p>The <code>message</code> is too large to send unfragmented.</p> </td></tr> <tr><td><code><code class='key'>System.EWOULDBLOCK</code></code></td><td><p>The send buffers are full.</p> </td></tr> </table></td></tr> </table> </dd> <dt class='head--doc'>Throws</dt> <dd class='body--doc'><p>Throws errors on invalid arguments and uninitialized object.</p>
4ac5952016-07-20Henrik Grubbström (Grubba) </dd> <dt class='head--doc'>Note</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Versions of Pike prior to 8.1.5 threw errors also on EMSGSIZE (<code class='expr'>"Too&nbsp;big&nbsp;message"</code>) and EWOULDBLOCK
1cb9732020-04-26Henrik Grubbström (Grubba)  (<code class='expr'>"Message&nbsp;would&nbsp;block."</code>). These versions of Pike also
ed0ac82017-07-21Pontus Östlund  did not update the object errno on this function failing.</p>
1cb9732020-04-26Henrik Grubbström (Grubba) </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>Versions of Pike prior to 8.1.13 did not support the default recipient for <code>connect()</code>ed objects.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>connect()</code>, <code>errno()</code>, <code>query_mtu()</code></p>
f228872013-06-17Martin Nilsson </dd></dl> <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>set_backend</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_backend</span>(</b><code class='object unresolved'>Pike.Backend</code> <code class='argument'>backend</code><b>)</b></code></p></dd>
f228872013-06-17Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Set the backend used for the read callback.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>The backend keeps a reference to this object as long as there can be calls to the read callback, but this object does not keep a reference to the backend.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>query_backend</code></p>
f228872013-06-17Martin Nilsson </dd></dl>
b34a222014-09-15Per Hedbor <hr /> <dl class='group--doc'>
70bc302014-09-28Henrik Grubbström (Grubba) <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>set_blocking</b></span>
b34a222014-09-15Per Hedbor </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>object</code> <b><span class='method'>set_blocking</span>(</b><b>)</b></code></p></dd>
b34a222014-09-15Per Hedbor  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Sets this object to be blocking.</p>
b34a222014-09-15Per Hedbor </dd></dl>
f228872013-06-17Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>set_buffer</b></span>
f228872013-06-17Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_buffer</span>(</b><code class='datatype'>int</code> <code class='argument'>bufsize</code>, <code class='datatype'>string</code> <code class='argument'>mode</code><b>)</b></code><br> <code><code class='datatype'>void</code> <b><span class='method'>set_buffer</span>(</b><code class='datatype'>int</code> <code class='argument'>bufsize</code><b>)</b></code></p></dd>
70bc302014-09-28Henrik Grubbström (Grubba)  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Set internal socket buffer.</p> <p> This function sets the internal buffer size of a socket or stream.</p> <p> The second argument allows you to set the read or write buffer by specifying <code class='expr'>"r"</code> or <code class='expr'>"w"</code>.</p> </dd> <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>It is not guaranteed that this function actually does anything, but it certainly helps to increase data transfer speed when it does.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>open_socket()</code>, <code>accept()</code></p>
45eff82002-06-11Johan Sundström </dd></dl>
70bc302014-09-28Henrik Grubbström (Grubba) 
45eff82002-06-11Johan Sundström <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>set_fd</b></span>
45eff82002-06-11Johan Sundström </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='object unresolved'>UDP</code> <b><span class='method'>set_fd</span>(</b><code class='datatype'>int</code> <code class='argument'>fd</code><b>)</b></code></p></dd>
45eff82002-06-11Johan Sundström  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Use the file descriptor <code>fd</code> for UDP.</p> </dd> <dt class='head--doc'>See also</dt> <dd class='body--doc'><p><code>bind</code></p>
45eff82002-06-11Johan Sundström </dd></dl>
84d5df2002-09-16Johan Schön <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>set_multicast_ttl</b></span>
84d5df2002-09-16Johan Schön </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>set_multicast_ttl</span>(</b><code class='datatype'>int</code> <code class='argument'>ttl</code><b>)</b></code></p></dd>
84d5df2002-09-16Johan Schön  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Set the time-to-live value of outgoing multicast packets for this socket.</p> </dd> <dt class='head--doc'><span id='p-ttl'></span>Parameter <code class='parameter'>ttl</code></dt> <dd></dd><dd class='body--doc'><p>The number of router hops sent multicast packets should survive.</p> <p> It is very important for multicast packets to set the smallest TTL possible. The default before calling this function is 1 which means that multicast packets don't leak from the local network unless the user program explicitly requests it.</p> <p> See also the Unix man page for setsocketopt IPPROTO_IP IP_MULTICAST_TTL and IPPROTO_IPV6 IPV6_MULTICAST_HOPS.</p>
c3fe742003-02-05Martin Nilsson </dd> <dt class='head--doc'>Note</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>This function did not support IPv6 in Pike 7.8 and earlier.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>add_membership()</code></p>
84d5df2002-09-16Johan Schön </dd></dl>
45eff82002-06-11Johan Sundström <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>set_nonblocking</b></span>
45eff82002-06-11Johan Sundström </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='object unresolved'>UDP</code> <b><span class='method'>set_nonblocking</span>(</b><b>)</b></code><br> <code><code class='object unresolved'>UDP</code> <b><span class='method'>set_nonblocking</span>(</b><code class='datatype'>function</code>(<code class='datatype'>mapping</code>(<code class='datatype'>string</code>:<code class='datatype'>int</code>|<code class='datatype'>string</code>), <code class='datatype'>mixed</code> ... :<code class='datatype'>void</code>) <code class='argument'>read_cb</code>, <code class='datatype'>mixed</code> ... <code class='argument'>extra_args</code><b>)</b></code></p></dd>
45eff82002-06-11Johan Sundström  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Set this object to nonblocking mode.</p> <p> If <code>read_cb</code> and <code>extra_args</code> are specified, they will be passed on to <code>set_read_callback()</code>.</p>
da06012008-12-09Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>The called object.</p>
45eff82002-06-11Johan Sundström </dd></dl> <hr /> <dl class='group--doc'>
70bc302014-09-28Henrik Grubbström (Grubba) <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>set_read_callback</b></span>
45eff82002-06-11Johan Sundström </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='object unresolved'>UDP</code> <b><span class='method'>set_read_callback</span>(</b><code class='datatype'>function</code>(<code class='datatype'>mapping</code>(<code class='datatype'>string</code>:<code class='datatype'>int</code>|<code class='datatype'>string</code>), <code class='datatype'>mixed</code> ... :<code class='datatype void'>void</code>) <code class='argument'>read_cb</code>, <code class='datatype'>mixed</code> ... <code class='argument'>extra_args</code><b>)</b></code></p></dd>
70bc302014-09-28Henrik Grubbström (Grubba)  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>The <code>read_cb</code> function will receive a mapping similar to the mapping returned by <code>read()</code>:</p> <table class='box'><tr><td><code><code class='key'>"data"</code> : <code class='datatype'>string</code></code></td><td><p>Received data.</p> </td></tr> <tr><td><code><code class='key'>"ip"</code> : <code class='datatype'>string</code></code></td><td><p>Data was sent from this IP.</p> </td></tr> <tr><td><code><code class='key'>"port"</code> : <code class='datatype'>int</code></code></td><td><p>Data was sent from this port.</p> </td></tr> </table> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>The called object.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p><code>read()</code></p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd></dl>
e4e3f32002-04-06Martin Nilsson 
50af352002-07-15Martin Nilsson 
e4e3f32002-04-06Martin Nilsson <hr /> <dl class='group--doc'>
50af352002-07-15Martin Nilsson <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>set_type</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='object unresolved'>UDP</code> <b><span class='method'>set_type</span>(</b><code class='datatype'>int</code> <code class='argument'>sock_type</code><b>)</b></code><br> <code><code class='object unresolved'>UDP</code> <b><span class='method'>set_type</span>(</b><code class='datatype'>int</code> <code class='argument'>sock_type</code>, <code class='datatype'>int</code> <code class='argument'>family</code><b>)</b></code></p></dd>
e4e3f32002-04-06Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Sets socket type and protocol family.</p>
e4e3f32002-04-06Martin Nilsson </dd></dl>
ab1f522003-07-10Henrik Grubbström (Grubba) <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>wait</b></span>
ab1f522003-07-10Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>bool</code> <b><span class='method'>wait</span>(</b><code class='datatype'>int</code>|<code class='datatype'>float</code> <code class='argument'>timeout</code><b>)</b></code></p></dd>
ab1f522003-07-10Henrik Grubbström (Grubba)  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Check for data and wait max. <code>timeout</code> seconds.</p>
da06012008-12-09Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>Returns <code class='expr'>1</code> if data are ready, <code class='expr'>0</code> (zero) otherwise.</p>
ab1f522003-07-10Henrik Grubbström (Grubba) </dd></dl>
9add812019-07-04Henrik Grubbström (Grubba) </dd></dl></dd> <dt><a name='9.7'></a> <h2 class='header'>9.7. Terminal I/O</h2></dt> <dd><dl><dt><h2 class='header'>Module <b class='ms datatype'>Stdio.Terminfo</b></h2>
ed0ac82017-07-21Pontus Östlund </dt><dd>
ab1f522003-07-10Henrik Grubbström (Grubba) 
f7707e2008-03-07Henrik Grubbström (Grubba) <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>getFallbackTerm</b></span>
f7707e2008-03-07Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='modifier'>protected</code> <code class='object unresolved'>Termcap</code> <b><span class='method'>getFallbackTerm</span>(</b><code class='datatype'>string</code> <code class='argument'>term</code><b>)</b></code></p></dd>
f7707e2008-03-07Henrik Grubbström (Grubba)  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Returns an object describing the fallback terminal for the terminal
82f7b82018-01-12Stephen R. van den Berg  <code>term</code>. This is usually equivalent to <code>Stdio.Terminfo.getTerm("dumb")</code>.</p>
f7707e2008-03-07Henrik Grubbström (Grubba) </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Stdio.Terminfo.getTerm</p>
f7707e2008-03-07Henrik Grubbström (Grubba) </dd></dl>
0f4adf2003-07-22Henrik Grubbström (Grubba) <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>getTerm</b></span>
0f4adf2003-07-22Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='object unresolved'>Termcap</code> <b><span class='method'>getTerm</span>(</b><code class='datatype'>string</code>|<code class='datatype'>void</code> <code class='argument'>term</code><b>)</b></code></p></dd>
0f4adf2003-07-22Henrik Grubbström (Grubba)  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Returns an object describing the terminal term. If term is not specified, it will default to <code>getenv("TERM")</code> or if that fails to "dumb".</p> <p> Lookup of terminal information will first be done in the systems terminfo database, and if that fails in the termcap database. If neither database exists, a hardcoded entry for "dumb" will be used.</p>
0f4adf2003-07-22Henrik Grubbström (Grubba) </dd>
16892e2014-05-26Martin Nilsson <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Stdio.Terminfo.getTerminfo, Stdio.Terminfo.getTermcap, Stdio.getFallbackTerm</p>
0f4adf2003-07-22Henrik Grubbström (Grubba) </dd></dl>
e4e3f32002-04-06Martin Nilsson <hr /> <dl class='group--doc'>
50af352002-07-15Martin Nilsson <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>getTermcap</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='object unresolved'>Termcap</code> <b><span class='method'>getTermcap</span>(</b><code class='datatype'>string</code> <code class='argument'>term</code><b>)</b></code></p></dd>
e4e3f32002-04-06Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Returns the terminal description object for <code>term</code> from the systems termcap database. Returns 0 if not found.</p>
c3fe742003-02-05Martin Nilsson </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Stdio.Terminfo.getTerm, Stdio.Terminfo.getTerminfo</p>
e4e3f32002-04-06Martin Nilsson </dd></dl>
1f918f2002-05-26Martin Nilsson <hr /> <dl class='group--doc'>
50af352002-07-15Martin Nilsson <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>getTerminfo</b></span>
1f918f2002-05-26Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='object unresolved'>Terminfo</code> <b><span class='method'>getTerminfo</span>(</b><code class='datatype'>string</code> <code class='argument'>term</code><b>)</b></code></p></dd>
e4e3f32002-04-06Martin Nilsson 
1f918f2002-05-26Martin Nilsson <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Returns the terminal description object for <code>term</code> from the systems terminfo database. Returns 0 if not found.</p>
c3fe742003-02-05Martin Nilsson </dd> <dt class='head--doc'>See also</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Stdio.Terminfo.getTerm, Stdio.Terminfo.getTermcap</p>
1f918f2002-05-26Martin Nilsson </dd></dl>
e4e3f32002-04-06Martin Nilsson  <hr /> <dl class='group--doc'>
50af352002-07-15Martin Nilsson <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>is_tty</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>is_tty</span>(</b><b>)</b></code></p></dd>
e4e3f32002-04-06Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Returns 1 if <code>Stdio.stdin</code> is connected to an interactive terminal that can handle backspacing, carriage return without linefeed, and the like.</p> </dd></dl> <dl><dt><h2 class='header'>Class <b class='ms datatype'>Stdio.Terminfo.MetaTerminfoDB</b></h2> </dt><dd><dl class='group--doc'> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p><code>TerminfoDB</code> that merges several directorys.</p>
e4e3f32002-04-06Martin Nilsson </dd></dl>
f6a4222017-07-10Henrik Grubbström (Grubba) 
429e502008-07-12Stephen R. van den Berg <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>create</b></span>
429e502008-07-12Stephen R. van den Berg </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><span class='object'>Stdio.Terminfo.MetaTerminfoDB</span> <span class='class'>Stdio.Terminfo.MetaTerminfoDB</span><b>(</b><code class='datatype'>array</code>(<code class='object unresolved'>TerminfoDB</code>|<code class='datatype'>string</code>)|<code class='datatype'>void</code> <code class='argument'>dbs</code><b>)</b></code></p></dd>
429e502008-07-12Stephen R. van den Berg  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Create a new Meta <code>TerminfoDB</code>.</p>
b4418a2008-07-14Stephen R. van den Berg </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'><span id='p-dbs'></span>Parameter <code class='parameter'>dbs</code></dt> <dd></dd><dd class='body--doc'><p>Array with elements in priority order. Elements may be either</p> <table class='box'><tr><td><code><code class='object unresolved'>TerminfoDB</code></code></td><td><p>An active <code>TerminfoDB</code>.</p> </td></tr> <tr><td><code><code class='datatype'>string</code></code></td><td><p>A directory that may exist and contain a terminfo database.</p> </td></tr> </table> </dd> <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>If the resulting set of <code>TerminfoDB</code>'s is empty, the object will be destructed.</p>
429e502008-07-12Stephen R. van den Berg </dd></dl>
ed0ac82017-07-21Pontus Östlund </dd></dl><dl><dt><h2 class='header'>Class <b class='ms datatype'>Stdio.Terminfo.Termcap</b></h2> </dt><dd><dl class='group--doc'>
f6a4222017-07-10Henrik Grubbström (Grubba) <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Termcap terminal description object.</p>
f6a4222017-07-10Henrik Grubbström (Grubba) </dd></dl>
70bc302014-09-28Henrik Grubbström (Grubba) 
1f918f2002-05-26Martin Nilsson <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Variable</span> <span class='homogen--name'><b>aliases</b></span>
1f918f2002-05-26Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>array</code>(<code class='datatype'>string</code>) Stdio.Terminfo.Termcap.<b><span class='variable'>aliases</span></b></code></p></dd> </dl>
e4e3f32002-04-06Martin Nilsson 
70bc302014-09-28Henrik Grubbström (Grubba)  <hr /> <dl class='group--doc'>
f6a4222017-07-10Henrik Grubbström (Grubba) <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>create</b></span>
70bc302014-09-28Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><span class='object'>Stdio.Terminfo.Termcap</span> <span class='class'>Stdio.Terminfo.Termcap</span><b>(</b><code class='datatype'>string</code> <code class='argument'>cap</code>, <code class='object unresolved'>TermcapDB</code>|<code class='datatype'>void</code> <code class='argument'>tcdb</code>, <code class='datatype'>int</code>|<code class='datatype'>void</code> <code class='argument'>maxrecurse</code><b>)</b></code></p></dd> </dl>
e4e3f32002-04-06Martin Nilsson  <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Inherit</span> <span class='homogen--name'><b>TermMachine</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><span class='datatype'>inherit TermMachine</span> : <span class='inherit'>TermMachine</span></code></p></dd> </dl>
f6a4222017-07-10Henrik Grubbström (Grubba)  <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>tputs</b></span>
f6a4222017-07-10Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>string</code> <b><span class='method'>tputs</span>(</b><code class='datatype'>string</code> <code class='argument'>s</code><b>)</b></code></p></dd>
f6a4222017-07-10Henrik Grubbström (Grubba) 
70bc302014-09-28Henrik Grubbström (Grubba) <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Put termcap string</p> </dd></dl> </dd></dl><dl><dt><h2 class='header'>Class <b class='ms datatype'>Stdio.Terminfo.TermcapDB</b></h2> </dt><dd><dl class='group--doc'> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Termcap database</p> </dd></dl></dd></dl><dl><dt><h2 class='header'>Class <b class='ms datatype'>Stdio.Terminfo.Terminfo</b></h2> </dt><dd><dl class='group--doc'> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Terminfo terminal description object</p>
e4e3f32002-04-06Martin Nilsson </dd></dl>
f6a4222017-07-10Henrik Grubbström (Grubba) 
e4e3f32002-04-06Martin Nilsson <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Variable</span> <span class='homogen--name'><b>aliases</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>array</code>(<code class='datatype'>string</code>) Stdio.Terminfo.Terminfo.<b><span class='variable'>aliases</span></b></code></p></dd> </dl>
9699552002-03-12Martin Nilsson 
2d83192003-10-30Martin Stjernholm <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>create</b></span>
2d83192003-10-30Martin Stjernholm </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><span class='object'>Stdio.Terminfo.Terminfo</span> <span class='class'>Stdio.Terminfo.Terminfo</span><b>(</b><code class='datatype'>string</code> <code class='argument'>filename</code><b>)</b></code></p></dd> </dl>
2d83192003-10-30Martin Stjernholm 
e4e3f32002-04-06Martin Nilsson <hr /> <dl class='group--doc'>
70bc302014-09-28Henrik Grubbström (Grubba) <dt class='head--type'><span class='homogen--type'>Inherit</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>TermMachine</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><span class='datatype'>inherit TermMachine</span> : <span class='inherit'>TermMachine</span></code></p></dd>
70bc302014-09-28Henrik Grubbström (Grubba) </dl>
ed0ac82017-07-21Pontus Östlund 
e4e3f32002-04-06Martin Nilsson 
4856ea2004-05-13H. William Welliver III <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>tputs</b></span>
4856ea2004-05-13H. William Welliver III </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>string</code> <b><span class='method'>tputs</span>(</b><code class='datatype'>string</code> <code class='argument'>s</code><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p>
4856ea2004-05-13H. William Welliver III </dd></dl>
ed0ac82017-07-21Pontus Östlund </dd></dl><dl><dt><h2 class='header'>Class <b class='ms datatype'>Stdio.Terminfo.TerminfoDB</b></h2>
70bc302014-09-28Henrik Grubbström (Grubba) </dt><dd><dl class='group--doc'> <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Terminfo database for a single directory.</p> </dd></dl></dd></dl></dd></dl><dl><dt><h2 class='header'>Class <b class='ms datatype'>Stdio.Readline</b></h2> </dt><dd>
4856ea2004-05-13H. William Welliver III 
e0c2812004-04-04Martin Stjernholm <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>add_to_kill_ring</b></span>
e0c2812004-04-04Martin Stjernholm </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>add_to_kill_ring</span>(</b><code class='datatype'>string</code> <code class='argument'>s</code><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p>
e0c2812004-04-04Martin Stjernholm </dd></dl>
ed0ac82017-07-21Pontus Östlund 
e4e3f32002-04-06Martin Nilsson <hr /> <dl class='group--doc'>
50af352002-07-15Martin Nilsson <dt class='head--type'><span class='homogen--type'>Method</span>
c3fe742003-02-05Martin Nilsson <span class='homogen--name'><b>create</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><span class='object'>Stdio.Readline</span> <span class='class'>Stdio.Readline</span><b>(</b><code class='datatype'>object</code>|<code class='datatype'>void</code> <code class='argument'>infd</code>, <code class='datatype'>object</code>|<code class='datatype'>string</code>|<code class='datatype'>void</code> <code class='argument'>interm</code>, <code class='datatype'>object</code>|<code class='datatype'>void</code> <code class='argument'>outfd</code>, <code class='datatype'>object</code>|<code class='datatype'>string</code>|<code class='datatype'>void</code> <code class='argument'>outterm</code><b>)</b></code></p></dd>
e4e3f32002-04-06Martin Nilsson 
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Creates a Readline object, that takes input from <code>infd</code> and has output on <code>outfd</code>.</p> </dd> <dt class='head--doc'><span id='p-infd'></span>Parameter <code class='parameter'>infd</code></dt> <dd></dd><dd class='body--doc'><p>Defaults to <code>Stdio.stdin</code>.</p> </dd> <dt class='head--doc'><span id='p-interm'></span>Parameter <code class='parameter'>interm</code></dt> <dd></dd><dd class='body--doc'><p>Defaults to <code>Stdio.Terminfo.getTerm()</code>.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'><span id='p-outfd'></span>Parameter <code class='parameter'>outfd</code></dt> <dd></dd><dd class='body--doc'><p>Defaults to <code>infd</code>, unless <code>infd</code> is 0, in which case <code>outfd</code> defaults to <code>Stdio.stdout</code>.</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'><span id='p-outterm'></span>Parameter <code class='parameter'>outterm</code></dt> <dd></dd><dd class='body--doc'><p>Defaults to <code>interm</code>.</p>
1f918f2002-05-26Martin Nilsson </dd></dl>
e4e3f32002-04-06Martin Nilsson 
388ed92005-02-01Martin Stjernholm <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>delete</b></span>
388ed92005-02-01Martin Stjernholm </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>delete</span>(</b><code class='datatype'>int</code> <code class='argument'>p1</code>, <code class='datatype'>int</code> <code class='argument'>p2</code><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p> </dd></dl>
388ed92005-02-01Martin Stjernholm 
e4e3f32002-04-06Martin Nilsson <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>delta_history</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>delta_history</span>(</b><code class='datatype'>int</code> <code class='argument'>d</code><b>)</b></code></p></dd>
e4e3f32002-04-06Martin Nilsson <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Changes the line to a line from the history <code>d</code> steps from the current entry (0 being the current line, negative values older, and positive values newer).</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>Note</dt> <dd class='body--doc'><p>Only effective if you have a history object.</p>
1f918f2002-05-26Martin Nilsson </dd></dl>
e4e3f32002-04-06Martin Nilsson 
ed0ac82017-07-21Pontus Östlund 
5af4c12009-02-24Henrik Grubbström (Grubba) <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>edit</b></span>
5af4c12009-02-24Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>string</code> <b><span class='method'>edit</span>(</b><code class='datatype'>string</code> <code class='argument'>data</code>, <code class='datatype'>string</code>|<code class='datatype'>void</code> <code class='argument'>local_prompt</code>, <code class='datatype'>array</code>(<code class='datatype'>string</code>)|<code class='datatype'>void</code> <code class='argument'>attrs</code><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p> </dd></dl>
5af4c12009-02-24Henrik Grubbström (Grubba) 
e4e3f32002-04-06Martin Nilsson <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>enable_history</b></span> </dt> <dd><p><code><code class='datatype'>void</code> <b><span class='method'>enable_history</span>(</b><code class='datatype'>array</code>(<code class='datatype'>string</code>)|<code class='object unresolved'>History</code>|<code class='datatype'>int</code> <code class='argument'>hist</code><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd></dl>
e4e3f32002-04-06Martin Nilsson  <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>eof</b></span>
1f918f2002-05-26Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>eof</span>(</b><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p>
e4e3f32002-04-06Martin Nilsson </dd></dl>
c3fe742003-02-05Martin Nilsson 
e4e3f32002-04-06Martin Nilsson 
50af352002-07-15Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>get_history</b></span>
50af352002-07-15Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='object unresolved'>History</code> <b><span class='method'>get_history</span>(</b><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p>
1f918f2002-05-26Martin Nilsson </dd></dl>
e4e3f32002-04-06Martin Nilsson 
dea86c2004-04-05Martin Stjernholm <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>get_input_controller</b></span>
dea86c2004-04-05Martin Stjernholm </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='object unresolved'>InputController</code> <b><span class='method'>get_input_controller</span>(</b><b>)</b></code></p></dd>
dea86c2004-04-05Martin Stjernholm  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>get current input control object</p>
f6a4222017-07-10Henrik Grubbström (Grubba) </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>Terminal input controller object</p>
dea86c2004-04-05Martin Stjernholm </dd></dl>
1f918f2002-05-26Martin Nilsson <hr /> <dl class='group--doc'>
50af352002-07-15Martin Nilsson <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>get_output_controller</b></span>
1f918f2002-05-26Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='object unresolved'>OutputController</code> <b><span class='method'>get_output_controller</span>(</b><b>)</b></code></p></dd>
1f918f2002-05-26Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>get current output control object</p>
1f918f2002-05-26Martin Nilsson </dd>
ed0ac82017-07-21Pontus Östlund <dt class='head--doc'>Returns</dt> <dd class='body--doc'><p>Terminal output controller object</p>
c3fe742003-02-05Martin Nilsson </dd></dl>
e4e3f32002-04-06Martin Nilsson 
dea86c2004-04-05Martin Stjernholm <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>get_prompt</b></span>
dea86c2004-04-05Martin Stjernholm </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>string</code> <b><span class='method'>get_prompt</span>(</b><b>)</b></code></p></dd>
dea86c2004-04-05Martin Stjernholm  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Return the current prompt string.</p>
dea86c2004-04-05Martin Stjernholm </dd></dl>
ed0ac82017-07-21Pontus Östlund 
dea86c2004-04-05Martin Stjernholm 
e4e3f32002-04-06Martin Nilsson <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>getcursorpos</b></span> </dt> <dd><p><code><code class='datatype'>int</code> <b><span class='method'>getcursorpos</span>(</b><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p>
c3fe742003-02-05Martin Nilsson </dd></dl>
e4e3f32002-04-06Martin Nilsson 
70bc302014-09-28Henrik Grubbström (Grubba) 
e4e3f32002-04-06Martin Nilsson <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>getmark</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>getmark</span>(</b><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p>
1f918f2002-05-26Martin Nilsson </dd></dl>
50af352002-07-15Martin Nilsson  <hr /> <dl class='group--doc'>
70bc302014-09-28Henrik Grubbström (Grubba) <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>gettext</b></span>
50af352002-07-15Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>string</code> <b><span class='method'>gettext</span>(</b><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p>
f6a4222017-07-10Henrik Grubbström (Grubba) </dd></dl>
ed0ac82017-07-21Pontus Östlund 
50af352002-07-15Martin Nilsson 
1f72bf2004-09-18Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>history</b></span>
1f72bf2004-09-18Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>history</span>(</b><code class='datatype'>int</code> <code class='argument'>n</code><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p>
1f72bf2004-09-18Martin Nilsson </dd></dl>
1f918f2002-05-26Martin Nilsson <hr /> <dl class='group--doc'>
50af352002-07-15Martin Nilsson <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>insert</b></span>
1f918f2002-05-26Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>insert</span>(</b><code class='datatype'>string</code> <code class='argument'>s</code>, <code class='datatype'>int</code> <code class='argument'>p</code><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p> </dd></dl>
e4e3f32002-04-06Martin Nilsson 
c3fe742003-02-05Martin Nilsson 
8ae0032003-10-29Henrik Grubbström (Grubba) <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>kill</b></span>
8ae0032003-10-29Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>kill</span>(</b><code class='datatype'>int</code> <code class='argument'>p1</code>, <code class='datatype'>int</code> <code class='argument'>p2</code><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p> </dd></dl>
8ae0032003-10-29Henrik Grubbström (Grubba) 
c628122002-10-19Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>kill_ring_yank</b></span>
c628122002-10-19Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>string</code> <b><span class='method'>kill_ring_yank</span>(</b><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p> </dd></dl>
c628122002-10-19Martin Nilsson 
8831a42004-09-18Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>list_completions</b></span>
8831a42004-09-18Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>list_completions</span>(</b><code class='datatype'>array</code>(<code class='datatype'>string</code>) <code class='argument'>c</code><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p>
8831a42004-09-18Martin Nilsson </dd></dl>
e4e3f32002-04-06Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>message</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>message</span>(</b><code class='datatype'>string</code> <code class='argument'>msg</code><b>)</b></code></p></dd>
e4e3f32002-04-06Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Print a message to the output device</p> </dd></dl>
1f918f2002-05-26Martin Nilsson 
e4e3f32002-04-06Martin Nilsson 
1f72bf2004-09-18Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>newline</b></span>
1f72bf2004-09-18Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>string</code> <b><span class='method'>newline</span>(</b><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p> </dd></dl>
1f72bf2004-09-18Martin Nilsson 
c628122002-10-19Martin Nilsson <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>pointmark</b></span>
c628122002-10-19Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>array</code>(<code class='datatype'>int</code>) <b><span class='method'>pointmark</span>(</b><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p> </dd></dl>
c628122002-10-19Martin Nilsson 
e4e3f32002-04-06Martin Nilsson <hr /> <dl class='group--doc'>
50af352002-07-15Martin Nilsson <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>read</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>string</code> <b><span class='method'>read</span>(</b><code class='datatype'>string</code>|<code class='datatype'>void</code> <code class='argument'>prompt</code>, <code class='datatype'>array</code>(<code class='datatype'>string</code>)|<code class='datatype'>void</code> <code class='argument'>attrs</code><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p>
1f918f2002-05-26Martin Nilsson </dd></dl>
e4e3f32002-04-06Martin Nilsson 
ed0ac82017-07-21Pontus Östlund 
c3fe742003-02-05Martin Nilsson <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>redisplay</b></span> </dt> <dd><p><code><code class='datatype'>void</code> <b><span class='method'>redisplay</span>(</b><code class='datatype'>int</code> <code class='argument'>clear</code>, <code class='datatype'>int</code>|<code class='datatype'>void</code> <code class='argument'>nobackup</code><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p>
70bc302014-09-28Henrik Grubbström (Grubba) </dd></dl>
c3fe742003-02-05Martin Nilsson 
c628122002-10-19Martin Nilsson <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>region</b></span>
c628122002-10-19Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>string</code> <b><span class='method'>region</span>(</b><code class='datatype'>int</code> ... <code class='argument'>args</code><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p>
f6a4222017-07-10Henrik Grubbström (Grubba) </dd></dl>
70bc302014-09-28Henrik Grubbström (Grubba) 
ed0ac82017-07-21Pontus Östlund 
70bc302014-09-28Henrik Grubbström (Grubba) <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>set_blocking</b></span>
70bc302014-09-28Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_blocking</span>(</b><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p> </dd></dl>
c628122002-10-19Martin Nilsson 
dea86c2004-04-05Martin Stjernholm <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>set_echo</b></span>
dea86c2004-04-05Martin Stjernholm </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_echo</span>(</b><code class='datatype'>int</code> <code class='argument'>onoff</code><b>)</b></code></p></dd> <dt class='head--doc'>Description</dt> <dd class='body--doc'><p>Set text echo on or off.</p> </dd> <dt class='head--doc'><span id='p-onoff'></span>Parameter <code class='parameter'>onoff</code></dt> <dd></dd><dd class='body--doc'><p>1 for echo, 0 for no echo.</p> </dd></dl>
dea86c2004-04-05Martin Stjernholm 
ac9c552013-12-06Henrik Grubbström (Grubba) <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>set_nonblocking</b></span>
ac9c552013-12-06Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>set_nonblocking</span>(</b><code class='datatype'>function</code>(:<code class='datatype void'>void</code>) <code class='argument'>f</code><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p> </dd></dl>
ac9c552013-12-06Henrik Grubbström (Grubba) 
e4e3f32002-04-06Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>set_prompt</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>string</code> <b><span class='method'>set_prompt</span>(</b><code class='datatype'>string</code> <code class='argument'>newp</code>, <code class='datatype'>array</code>(<code class='datatype'>string</code>)|<code class='datatype'>void</code> <code class='argument'>newattrs</code><b>)</b></code></p></dd>
e4e3f32002-04-06Martin Nilsson  <dt class='head--doc'>Description</dt>
ed0ac82017-07-21Pontus Östlund <dd class='body--doc'><p>Set the prompt string.</p> </dd> <dt class='head--doc'><span id='p-newp'></span>Parameter <code class='parameter'>newp</code></dt> <dd></dd><dd class='body--doc'><p>New prompt string</p> </dd> <dt class='head--doc'><span id='p-newattrs'></span>Parameter <code class='parameter'>newattrs</code></dt> <dd></dd><dd class='body--doc'><p>Terminal attributes</p>
e4e3f32002-04-06Martin Nilsson </dd></dl>
ed0ac82017-07-21Pontus Östlund 
e4e3f32002-04-06Martin Nilsson <hr /> <dl class='group--doc'>
ed0ac82017-07-21Pontus Östlund <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>setcursorpos</b></span>
e4e3f32002-04-06Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>setcursorpos</span>(</b><code class='datatype'>int</code> <code class='argument'>p</code><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p> </dd></dl>
e4e3f32002-04-06Martin Nilsson 
dea86c2004-04-05Martin Stjernholm <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>setmark</b></span>
dea86c2004-04-05Martin Stjernholm </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>int</code> <b><span class='method'>setmark</span>(</b><code class='datatype'>int</code> <code class='argument'>p</code><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p> </dd></dl>
e4e3f32002-04-06Martin Nilsson 
1f918f2002-05-26Martin Nilsson <hr /> <dl class='group--doc'>
50af352002-07-15Martin Nilsson <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>write</b></span>
f6a4222017-07-10Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>write</span>(</b><code class='datatype'>string</code> <code class='argument'>msg</code>, <code class='datatype'>void</code>|<code class='datatype'>int</code> <code class='argument'>word_wrap</code><b>)</b></code></p></dd> <dt class='head--fixme'>FIXME</dt> <dd class='body--fixme'><p>Document this function</p>
f6a4222017-07-10Henrik Grubbström (Grubba) </dd></dl>
ed0ac82017-07-21Pontus Östlund <dl><dt><h2 class='header'>Class <b class='ms datatype'>Stdio.Readline.DefaultEditKeys</b></h2> </dt><dd>
f6a4222017-07-10Henrik Grubbström (Grubba)  <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>backward_char</b></span>
f6a4222017-07-10Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>backward_char</span>(</b><b>)</b></code></p></dd> </dl>
f6a4222017-07-10Henrik Grubbström (Grubba)  <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>backward_delete_char</b></span>
f6a4222017-07-10Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>backward_delete_char</span>(</b><b>)</b></code></p></dd> </dl>
f6a4222017-07-10Henrik Grubbström (Grubba)  <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>backward_kill_word</b></span>
f6a4222017-07-10Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>backward_kill_word</span>(</b><b>)</b></code></p></dd> </dl>
f6a4222017-07-10Henrik Grubbström (Grubba)  <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>backward_word</b></span>
f6a4222017-07-10Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>backward_word</span>(</b><b>)</b></code></p></dd> </dl>
e4e3f32002-04-06Martin Nilsson 
c628122002-10-19Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>beginning_of_line</b></span>
c628122002-10-19Martin Nilsson </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>beginning_of_line</span>(</b><b>)</b></code></p></dd>
70bc302014-09-28Henrik Grubbström (Grubba) </dl>
c628122002-10-19Martin Nilsson 
e4e3f32002-04-06Martin Nilsson <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>capitalize_word</b></span>
f6a4222017-07-10Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>capitalize_word</span>(</b><b>)</b></code></p></dd> </dl>
f6a4222017-07-10Henrik Grubbström (Grubba)  <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>clear_screen</b></span>
f6a4222017-07-10Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>clear_screen</span>(</b><b>)</b></code></p></dd> </dl>
f6a4222017-07-10Henrik Grubbström (Grubba)  <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span> <span class='homogen--name'><b>create</b></span> </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><span class='object'>Stdio.Readline.DefaultEditKeys</span> <span class='class'>Stdio.Readline.DefaultEditKeys</span><b>(</b><code class='datatype'>object</code> <code class='argument'>readline</code><b>)</b></code></p></dd> </dl>
6f7a292003-06-02Martin Stjernholm  <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>delete_char</b></span>
6f7a292003-06-02Martin Stjernholm </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><span class='method'>delete_char</span>(</b><b>)</b></code></p></dd> </dl>
6f7a292003-06-02Martin Stjernholm 
b361662010-06-05Henrik Grubbström (Grubba)  <hr /> <dl class='group--doc'> <dt class='head--type'><span class='homogen--type'>Method</span>
ed0ac82017-07-21Pontus Östlund <span class='homogen--name'><b>delete_char_or_eof</b></span>
b361662010-06-05Henrik Grubbström (Grubba) </dt>
ed0ac82017-07-21Pontus Östlund <dd><p><code><code class='datatype'>void</code> <b><