home *** CD-ROM | disk | FTP | other *** search
/ ftp.ee.pdx.edu / 2014.02.ftp.ee.pdx.edu.tar / ftp.ee.pdx.edu / pub / users / Harry / Blitz / version-1-0 / OSProject / p8 / cat.c < prev    next >
Text File  |  2006-05-17  |  767b  |  35 lines

  1. code cat
  2.  
  3.   -----------------------------------
  4.   ----                           ----
  5.   ----    BLITZ "cat" Program    ----
  6.   ----                           ----
  7.   -----------------------------------
  8.  
  9. -----------------------------  main  ---------------------------------
  10.   const stdin  = 0
  11.         stdout = 1
  12.  
  13.   const BUFF_MAX = 30
  14.  
  15.   var buffer: array [BUFF_MAX] of char
  16.  
  17.   function main ()
  18.     --
  19.     -- This is a simplified version of the 'cat' program found in Unix.
  20.     --
  21.       var i: int
  22.       *((& buffer) asPtrTo int) = BUFF_MAX
  23.       while true
  24.         i = Sys_Read (stdin, &buffer[0], BUFF_MAX)
  25.         if i <= 0
  26.           break
  27.         endIf
  28.         i = Sys_Write (stdout, &buffer[0], i)
  29.       endWhile
  30.       Sys_Close (stdout)
  31.  
  32.     endFunction
  33.  
  34. endCode
  35.