File: rtio.c

package info (click to toggle)
saoimage 1.29.3-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 3,952 kB
  • ctags: 4,265
  • sloc: ansic: 50,317; makefile: 243; sh: 35
file content (98 lines) | stat: -rw-r--r-- 2,347 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#ifndef lint
static char SccsId[] = "%W%  %G%";
#endif

/* Module:	rtio.c (Real Time Input Output)
 * Purpose:	Read commands from a Berkeley Socket
 * Subroutine:	open_rtsock_connection()	returns: void
 * Subroutine:	open_rtfifo_connection()	returns: void
 * Subroutine:	sock_output()			returns: int
 * Copyright:	1989 Smithsonian Astrophysical Observatory
 *		You may do anything you like with this file except remove
 *		this copyright.  The Smithsonian Astrophysical Observatory
 *		makes no representations about the suitability of this
 *		software for any purpose.  It is provided "as is" without
 *		express or implied warranty.
 * Modified:	{0] Initial version	John Roll : May 90
 *		{n} <who> -- <does what> -- <when>
 */

#include <stdio.h>		/* stderr, FILE, NULL, etc. */

#ifndef VMS
#ifdef SYSV
#include <string.h>
#else
#include <strings.h>		/* strlen, etc. for unenlightened BSD's */
#endif
#else
#include <string.h>
#endif

#include <X11/Xlib.h>		/* X window stuff */
#include "hfiles/control.h"	/* define struct connectRec */
#include "hfiles/rtcmd.h"	/* command protocol and ID's */

extern struct controlRec control;


/*
 * Subroutine:	open_rtsock_connection
 * Purpose:	open the connection for Sockets
 */
void open_rtsock_connection ()
{
  int open_connection();
  void read_rtio_packet();

  control.aux_in.func = read_rtio_packet;
  control.aux_in.type = IOP_socket;

  if( open_connection(&control.aux_in) != -1 ) {
    if( control.verbose )
      (void)printf("Open to accept real time Socket io\n");
  }
}


/*
 * Subroutine:	open_rtfifo_connection
 * Purpose:	open the connection for FiFo
 */
void open_rtfifo_connection ()
{
  int open_connection();
  void read_rtio_packet();

  control.aux_in.func = read_rtio_packet;
  control.aux_in.type = IOP_pipe;

  if( open_connection(&control.aux_in) != -1 ) {
    if( control.verbose )
      (void)printf("Open to accept feal time FiFo io\n");
  }
}

/*
 * Subroutine:	read_rtio_packet
 * Purpose:	read and decode a socket protical packet
 * Called by:	
 * Returns:	void
 */
void read_rtio_packet ( port )
     struct connectRec *port;
{
		int	bytes;
		cmdrec	cmd;

    bytes = read_connection(port, (char *)&cmd, sizeof(cmdrec));

    if ( bytes != sizeof(cmdrec) )
	if ( bytes == 0 )
	    close_connection(port);
	else
	  flush_connection(port);


    si_command(&cmd);
}