home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / communic / sercom / inttest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-06-18  |  1.6 KB  |  47 lines

  1. /*--------------------------- INTTEST.C -----------------------------------*/
  2. #include "stdio.h";
  3.  
  4. typedef struct {
  5.    int count;                          /* number of chars now in the buffer*/
  6.    int start;                          /* offset of next character to take */
  7.    int size;                           /* size of the buffer               */
  8.    char *buffer;                       /* Address of the buffer            */
  9. } RING;
  10.  
  11. extern RING ibuf;                      /* input buffer                     */
  12. extern RING obuf;                      /* output buffer                    */
  13.  
  14. char *calloc();
  15. /*-------------------------------------------------------------------------*/
  16. main()
  17. {
  18. int chgot;
  19. char *ispace, *ospace;
  20.  
  21.    ispace = calloc(256, 1);            /* Space for input buffer           */
  22.    ospace = calloc(256, 1);
  23.  
  24.    initbuf(&ibuf, ispace, 256);        /* See Figure 16.11                 */
  25.    initbuf(&obuf, ospace, 256);
  26.  
  27.    intinit();                          /* intinit.asm                      */
  28.  
  29.    comparm(1200, 0, 1, 8);             /* See Figure 16.5                  */
  30.  
  31.    printf("%s \n", "Done intinit");
  32.  
  33.    for (;;) {
  34.  
  35.       if (kbhit()) {                   /* User can terminate with esc      */
  36.          if (getch() == 27)
  37.             exit();
  38.       }
  39.  
  40.       if (getbuf(&ibuf, &chgot)) {     /* We have got a character          */
  41.          fputc(chgot, stdout);         /* Show it                          */
  42.       }
  43.    }
  44. }
  45.  
  46. /*-------------------------------------------------------------------------*/
  47.