home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / AZTEC-C / COMND004.ARK / CMDOSS.CPM next >
Text File  |  1986-06-17  |  2KB  |  124 lines

  1. /*    cmdoss.cpm    COMND module; OS-specific routines for CP/M-80
  2.  
  3.     Copyright (C) 1985 Mark E. Mallett
  4.  
  5.     Permission is hereby granted to distribute this file indiscriminately.
  6.  
  7. Edit history
  8.  
  9. When    Who    What
  10. ------    ---    --------------------------------
  11. 84xxxx    MEM    Create file.
  12.  
  13.  
  14.     Routines included are:
  15.  
  16.         CMDfob        Flush terminal output buffer.
  17.         CMDgtc        Get character from terminal without echo
  18.         CMDptc        Output character to terminal (buffered)
  19.         CMDpzs        Put NUL-terminated string to terminal
  20. */
  21.  
  22.  
  23. #include "stdio.h"            /* Standard system defs */
  24. #include "mem.h"            /* Include my standard names */
  25.  
  26.  
  27. /* External routines */
  28.  
  29.  
  30. /* External data */
  31.  
  32.  
  33. /* Internal (public) routines */
  34.  
  35.  
  36.  
  37. /* Internal (public) data */
  38.  
  39.  
  40. /* Local (static) data */
  41.  
  42. BYTE        Coline[201] = {0};    /* Output line */
  43. int        Colpos = {0};        /* Position in output line */
  44.  
  45. /*
  46.  
  47. *//* CMDgtc()
  48.  
  49.     Get terminal input character, no echo.
  50.  
  51. */
  52.  
  53. CMDgtc()
  54.  
  55. {
  56. IND    int        c;
  57.  
  58. while ((c = CPM(6,0xffff)&0xff) == 0)
  59.     ;
  60. return (c&0x7f);
  61. }
  62. /*
  63. *//* CMDpzs (sptr)
  64.  
  65.     Output a zero-terminated string to the console.
  66.  
  67.  
  68. Inputs
  69.  
  70.     sptr        Address of the zero-terminated string
  71.  
  72.  
  73. Outputs
  74.  
  75.         The string (buffered) out to the terminal.
  76.  
  77.  
  78. Notes
  79.  
  80.     CMDfob() can be called to flush the output.
  81.  
  82. */
  83.  
  84. CMDpzs (sptr)
  85.  
  86. BYTE            *sptr;        /* Address of string to output */
  87.  
  88. {
  89. while (*sptr != NUL)            /* Until end.. */
  90.     CMDpoc (*sptr++);            /* Output. */
  91. }
  92. /*
  93.  
  94. *//* CMDptc(c)
  95.  
  96.     Output c to the terminal, buffered.
  97.  
  98. */
  99.  
  100. CMDptc(c)
  101.  
  102. {
  103. Coline[Colpos++] = c;            /* Store char */
  104. if ((c == '\n') || (Colpos == 200))    /* If read to break */
  105.     CMDfob();                /*  break */
  106. }
  107. /*
  108.  
  109. *//* CMDfob()
  110.  
  111.     Break console output.
  112.  
  113. */
  114.  
  115. CMDfob()
  116.  
  117. {
  118. if (Colpos)
  119.     {
  120.     write (fileno(stdout),Coline,Colpos);    /* Write the line */
  121.     Colpos = 0;                /* Reset pointer */
  122.     }
  123. }
  124.