home *** CD-ROM | disk | FTP | other *** search
/ Encyclopedia of Graphics File Formats Companion / GFF_CD.ISO / software / unix / saoimage / sao1_07.tar / rtio.c < prev    next >
C/C++ Source or Header  |  1990-05-11  |  2KB  |  99 lines

  1. #ifndef lint
  2. static char SccsId[] = "%W%  %G%";
  3. #endif
  4.  
  5. /* Module:    rtio.c (Real Time Input Output)
  6.  * Purpose:    Read commands from a Berkeley Socket
  7.  * Subroutine:    open_rtsock_connection()    returns: void
  8.  * Subroutine:    open_rtfifo_connection()    returns: void
  9.  * Subroutine:    sock_output()            returns: int
  10.  * Copyright:    1989 Smithsonian Astrophysical Observatory
  11.  *        You may do anything you like with this file except remove
  12.  *        this copyright.  The Smithsonian Astrophysical Observatory
  13.  *        makes no representations about the suitability of this
  14.  *        software for any purpose.  It is provided "as is" without
  15.  *        express or implied warranty.
  16.  * Modified:    {0] Initial version    John Roll : May 90
  17.  *        {n} <who> -- <does what> -- <when>
  18.  */
  19.  
  20. #include <stdio.h>        /* stderr, FILE, NULL, etc. */
  21.  
  22. #ifndef VMS
  23. #ifdef SYSV
  24. #include <string.h>
  25. #else
  26. #include <strings.h>        /* strlen, etc. for unenlightened BSD's */
  27. #endif
  28. #else
  29. #include <string.h>
  30. #endif
  31.  
  32. #include <X11/Xlib.h>        /* X window stuff */
  33. #include "hfiles/control.h"    /* define struct connectRec */
  34. #include "hfiles/rtcmd.h"    /* command protocol and ID's */
  35.  
  36. extern struct controlRec control;
  37.  
  38.  
  39. /*
  40.  * Subroutine:    open_rtsock_connection
  41.  * Purpose:    open the connection for Sockets
  42.  */
  43. void open_rtsock_connection ()
  44. {
  45.   int open_connection();
  46.   void read_rtio_packet();
  47.  
  48.   control.aux_in.func = read_rtio_packet;
  49.   control.aux_in.type = IOP_socket;
  50.  
  51.   if( open_connection(&control.aux_in) != -1 ) {
  52.     if( control.verbose )
  53.       (void)printf("Open to accept real time Socket io\n");
  54.   }
  55. }
  56.  
  57.  
  58. /*
  59.  * Subroutine:    open_rtfifo_connection
  60.  * Purpose:    open the connection for FiFo
  61.  */
  62. void open_rtfifo_connection ()
  63. {
  64.   int open_connection();
  65.   void read_rtio_packet();
  66.  
  67.   control.aux_in.func = read_rtio_packet;
  68.   control.aux_in.type = IOP_pipe;
  69.  
  70.   if( open_connection(&control.aux_in) != -1 ) {
  71.     if( control.verbose )
  72.       (void)printf("Open to accept feal time FiFo io\n");
  73.   }
  74. }
  75.  
  76. /*
  77.  * Subroutine:    read_rtio_packet
  78.  * Purpose:    read and decode a socket protical packet
  79.  * Called by:    
  80.  * Returns:    void
  81.  */
  82. void read_rtio_packet ( port )
  83.      struct connectRec *port;
  84. {
  85.         int    bytes;
  86.         cmdrec    cmd;
  87.  
  88.     bytes = read_connection(port, (char *)&cmd, sizeof(cmdrec));
  89.  
  90.     if ( bytes != sizeof(cmdrec) )
  91.     if ( bytes == 0 )
  92.         close_connection(port);
  93.     else
  94.       flush_connection(port);
  95.  
  96.  
  97.     si_command(&cmd);
  98. }
  99.