home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / security / xinetd / sio.1.5.6 / suite / buftest.c next >
Encoding:
C/C++ Source or Header  |  1992-12-09  |  1.1 KB  |  51 lines

  1. /*
  2.  * (c) Copyright 1992 by Panagiotis Tsirigotis
  3.  * All rights reserved.  The file named COPYRIGHT specifies the terms 
  4.  * and conditions for redistribution.
  5.  */
  6.  
  7. static char RCSid[] = "$Id: buftest.c,v 7.1 1992/06/01 21:38:57 panos Exp $" ;
  8.  
  9. /*
  10.  * This program is used to test the Sbuftype system call.
  11.  * It prints two groups of lines. The first group is printed
  12.  * using line-buffering while the seconde group is printed using
  13.  * full-buffering.
  14.  *
  15.  * The first group of lines should appear one line at a time every
  16.  * 3 seconds. The second group of lines should appear all lines together
  17.  * after about 10 seconds.
  18.  */
  19.  
  20. #include "sio.h"
  21.  
  22. main()
  23. {
  24.     int i ;
  25.     int sleep_interval = 3 ;
  26.  
  27.     if ( Sbuftype( 1, SIO_LINEBUF ) == SIO_ERR )
  28.     {
  29.         Sprint( 2, "Sbuftype failed\n" ) ;
  30.         exit( 1 ) ;
  31.     }
  32.  
  33.     for ( i = 0 ; i < 10 ; i++ )
  34.     {
  35.         Sprint( 1, "Line %d\n", i ) ;
  36.         if ( i == 5 )
  37.         {
  38.             Sprint( 1, "Now switching to full buffering\n" ) ;
  39.             sleep_interval = 2 ;
  40.             if ( Sbuftype( 1, SIO_FULLBUF ) == SIO_ERR )
  41.             {
  42.                 Sprint( 2, "2nd Sbuftype failed\n" ) ;
  43.                 exit( 1 ) ;
  44.             }
  45.         }
  46.         sleep( sleep_interval ) ;
  47.     }
  48.     exit( 0 ) ;
  49. }
  50.  
  51.