Inept-excess-verbiage.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <html lang="en">
  2. <head>
  3. <title>Inept excess verbiage - avram - a virtual machine code interpreter</title>
  4. <meta http-equiv="Content-Type" content="text/html">
  5. <meta name="description" content="avram - a virtual machine code interpreter">
  6. <meta name="generator" content="makeinfo 4.13">
  7. <link title="Top" rel="start" href="index.html#Top">
  8. <link rel="up" href="Working-around-library-misfeatures.html#Working-around-library-misfeatures" title="Working around library misfeatures">
  9. <link rel="prev" href="Working-around-library-misfeatures.html#Working-around-library-misfeatures" title="Working around library misfeatures">
  10. <link rel="next" href="Memory-leaks.html#Memory-leaks" title="Memory leaks">
  11. <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
  12. <meta http-equiv="Content-Style-Type" content="text/css">
  13. <style type="text/css"><!--
  14. pre.display { font-family:inherit }
  15. pre.format { font-family:inherit }
  16. pre.smalldisplay { font-family:inherit; font-size:smaller }
  17. pre.smallformat { font-family:inherit; font-size:smaller }
  18. pre.smallexample { font-size:smaller }
  19. pre.smalllisp { font-size:smaller }
  20. span.sc { font-variant:small-caps }
  21. span.roman { font-family:serif; font-weight:normal; }
  22. span.sansserif { font-family:sans-serif; font-weight:normal; }
  23. --></style>
  24. </head>
  25. <body>
  26. <div class="node">
  27. <a name="Inept-excess-verbiage"></a>
  28. <p>
  29. Next:&nbsp;<a rel="next" accesskey="n" href="Memory-leaks.html#Memory-leaks">Memory leaks</a>,
  30. Previous:&nbsp;<a rel="previous" accesskey="p" href="Working-around-library-misfeatures.html#Working-around-library-misfeatures">Working around library misfeatures</a>,
  31. Up:&nbsp;<a rel="up" accesskey="u" href="Working-around-library-misfeatures.html#Working-around-library-misfeatures">Working around library misfeatures</a>
  32. <hr>
  33. </div>
  34. <h5 class="subsubsection">3.9.3.1 Inept excess verbiage</h5>
  35. <p>Although the author of a library function may take pride in putting
  36. its activities on display, it should be assumed that virtual code
  37. applications running on <code>avram</code> have other agendas for the
  38. console, so the library interface module should prevent direct output
  39. from the external library.
  40. <p>More thoughtful API's may have a verbosity setting, which should be
  41. <a name="index-verbosity-setting-677"></a>used in preference to this workaround, but failing that, it is easy to
  42. dispense with console output generated by calls to external library
  43. functions by using some combination of the following functions.
  44. <div class="defun">
  45. &mdash; Function: void <b>avm_turn_off_stdout</b> ()<var><a name="index-avm_005fturn_005foff_005fstdout-678"></a></var><br>
  46. <blockquote><p>Calling this function will suppress all output to the standard output
  47. stream until the next time <code>avm_turn_on_stdout</code> is called.
  48. Additional calls to this function without intervening calls to
  49. <code>avm_turn_on_stdout</code> may be made safely with no effect. The
  50. standard output stream is flushed as a side effect of calling this
  51. function.
  52. </p></blockquote></div>
  53. <div class="defun">
  54. &mdash; Function: void <b>avm_turn_on_stdout</b> ()<var><a name="index-avm_005fturn_005fon_005fstdout-679"></a></var><br>
  55. <blockquote><p>Calling this function will allow output to the standard output
  56. stream to resume if it has been suppressed previously by a call to
  57. <code>avm_turn_off_stdout</code>. If <code>avm_turn_off_stdout</code> has not been
  58. previously called, this function has no effect. Any output that would
  59. have been sent to <code>stdout</code> during the time it was turned off will
  60. be lost.
  61. </p></blockquote></div>
  62. <div class="defun">
  63. &mdash; Function: void <b>avm_turn_off_stderr</b> ()<var><a name="index-avm_005fturn_005foff_005fstderr-680"></a></var><br>
  64. <blockquote><p>This function performs a similar service to that of
  65. <code>avm_turn_off_stdout</code> but pertains to the standard error stream.
  66. The standard error and the standard output streams are controlled
  67. independently even if both of them are piped to the same console.
  68. </p></blockquote></div>
  69. <div class="defun">
  70. &mdash; Function: void <b>avm_turn_on_stderr</b> ()<var><a name="index-avm_005fturn_005fon_005fstderr-681"></a></var><br>
  71. <blockquote><p>This function performs a similar service to that of
  72. <code>avm_turn_on_stdout</code> but pertains to the standard error stream.
  73. </p></blockquote></div>
  74. <p>As an example, the following code fragment will prevent any output to
  75. standard output taking place as a side effect of <code>blather</code>, but
  76. will allow error messages to standard error. Note that ouput should
  77. not be left permanently turned off.
  78. <pre class="example"> ...
  79. #include &lt;avm/mwrap.h&gt;
  80. ...
  81. x = y + z;
  82. avm_turn_off_stdout ();
  83. w = blather (foo, bar, baz);
  84. avm_turn_on_stdout ();
  85. return w;
  86. ...
  87. </pre>
  88. <p>One possible issue with these functions is that they rely on a
  89. feature of the GNU C library that might not be portable to non-GNU
  90. <a name="index-portability-682"></a>systems and has not been widely tested on other platforms.
  91. <p>Another issue is that a library function could be both careless enough
  92. to clutter the console unconditionally and meticulous enough to check
  93. for I/O errors after each attempted write. Writing while the output
  94. stream is disabled will return an I/O error to the caller (i.e., to
  95. the verbose library function) for appropriate action, which could
  96. include terminating the process.
  97. </body></html>