Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The following code (SwapIOB) is used in Testbenches that want to store the stdout stream for comparison to an expected results file.</p> <p>Background: File streams are managed using an _IOB structure that is stored in an array of 20 _IOB entries. This includes stdout stream. The IOBs are stored in an array. When a file is created the application code gets a ptr to an element in that array. The application code then passes that ptr to the OS for processing I/O calls. Thus, the OS does NOT itself contain or rely on its own pointers to the application's IOB. </p> <p>Requirement: When running a testbench the stdout messages issued by an application should be re-directed to a file. However, after the module under test has completed then stdout messages should be re-redirected to the console. </p> <p>This routine was tested and is currently used on Windows XP/Pro system.</p> <pre><code>void SwapIOB(FILE *A, FILE *B) { FILE temp; // make a copy of IOB A (usually this is "stdout") memcpy(&amp;temp, A, sizeof(struct _iobuf)); // copy IOB B to A's location, now any output // sent to A is redirected thru B's IOB. memcpy(A, B, sizeof(struct _iobuf)); // copy A into B, the swap is complete memcpy(B, &amp;temp, sizeof(struct _iobuf)); } // end SwapIOB; </code></pre> <p>Application code uses SwapIOB() similar to:</p> <pre><code>FILE *fp; fp = fopen("X", "w"); SwapIOB(stdout, fp); printf("text to file X"); SwapIOB(stdout, fp); fclose(fp); printf("text to console works, again!"); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload