123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <html lang="en">
- <head>
- <title>Inept excess verbiage - avram - a virtual machine code interpreter</title>
- <meta http-equiv="Content-Type" content="text/html">
- <meta name="description" content="avram - a virtual machine code interpreter">
- <meta name="generator" content="makeinfo 4.13">
- <link title="Top" rel="start" href="index.html#Top">
- <link rel="up" href="Working-around-library-misfeatures.html#Working-around-library-misfeatures" title="Working around library misfeatures">
- <link rel="prev" href="Working-around-library-misfeatures.html#Working-around-library-misfeatures" title="Working around library misfeatures">
- <link rel="next" href="Memory-leaks.html#Memory-leaks" title="Memory leaks">
- <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
- <meta http-equiv="Content-Style-Type" content="text/css">
- <style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
- span.sansserif { font-family:sans-serif; font-weight:normal; }
- --></style>
- </head>
- <body>
- <div class="node">
- <a name="Inept-excess-verbiage"></a>
- <p>
- Next: <a rel="next" accesskey="n" href="Memory-leaks.html#Memory-leaks">Memory leaks</a>,
- Previous: <a rel="previous" accesskey="p" href="Working-around-library-misfeatures.html#Working-around-library-misfeatures">Working around library misfeatures</a>,
- Up: <a rel="up" accesskey="u" href="Working-around-library-misfeatures.html#Working-around-library-misfeatures">Working around library misfeatures</a>
- <hr>
- </div>
- <h5 class="subsubsection">3.9.3.1 Inept excess verbiage</h5>
- <p>Although the author of a library function may take pride in putting
- its activities on display, it should be assumed that virtual code
- applications running on <code>avram</code> have other agendas for the
- console, so the library interface module should prevent direct output
- from the external library.
- <p>More thoughtful API's may have a verbosity setting, which should be
- <a name="index-verbosity-setting-677"></a>used in preference to this workaround, but failing that, it is easy to
- dispense with console output generated by calls to external library
- functions by using some combination of the following functions.
- <div class="defun">
- — Function: void <b>avm_turn_off_stdout</b> ()<var><a name="index-avm_005fturn_005foff_005fstdout-678"></a></var><br>
- <blockquote><p>Calling this function will suppress all output to the standard output
- stream until the next time <code>avm_turn_on_stdout</code> is called.
- Additional calls to this function without intervening calls to
- <code>avm_turn_on_stdout</code> may be made safely with no effect. The
- standard output stream is flushed as a side effect of calling this
- function.
- </p></blockquote></div>
- <div class="defun">
- — Function: void <b>avm_turn_on_stdout</b> ()<var><a name="index-avm_005fturn_005fon_005fstdout-679"></a></var><br>
- <blockquote><p>Calling this function will allow output to the standard output
- stream to resume if it has been suppressed previously by a call to
- <code>avm_turn_off_stdout</code>. If <code>avm_turn_off_stdout</code> has not been
- previously called, this function has no effect. Any output that would
- have been sent to <code>stdout</code> during the time it was turned off will
- be lost.
- </p></blockquote></div>
- <div class="defun">
- — Function: void <b>avm_turn_off_stderr</b> ()<var><a name="index-avm_005fturn_005foff_005fstderr-680"></a></var><br>
- <blockquote><p>This function performs a similar service to that of
- <code>avm_turn_off_stdout</code> but pertains to the standard error stream.
- The standard error and the standard output streams are controlled
- independently even if both of them are piped to the same console.
- </p></blockquote></div>
- <div class="defun">
- — Function: void <b>avm_turn_on_stderr</b> ()<var><a name="index-avm_005fturn_005fon_005fstderr-681"></a></var><br>
- <blockquote><p>This function performs a similar service to that of
- <code>avm_turn_on_stdout</code> but pertains to the standard error stream.
- </p></blockquote></div>
- <p>As an example, the following code fragment will prevent any output to
- standard output taking place as a side effect of <code>blather</code>, but
- will allow error messages to standard error. Note that ouput should
- not be left permanently turned off.
- <pre class="example"> ...
- #include <avm/mwrap.h>
- ...
-
- x = y + z;
- avm_turn_off_stdout ();
- w = blather (foo, bar, baz);
- avm_turn_on_stdout ();
- return w;
- ...
- </pre>
- <p>One possible issue with these functions is that they rely on a
- feature of the GNU C library that might not be portable to non-GNU
- <a name="index-portability-682"></a>systems and has not been widely tested on other platforms.
- <p>Another issue is that a library function could be both careless enough
- to clutter the console unconditionally and meticulous enough to check
- for I/O errors after each attempted write. Writing while the output
- stream is disabled will return an I/O error to the caller (i.e., to
- the verbose library function) for appropriate action, which could
- include terminating the process.
- </body></html>
|