aboutsummaryrefslogtreecommitdiff
path: root/sys/libc/stgio.c
blob: 498a020ac3e9e393d91b7a40cc95263f2747290e (plain) (blame)
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
/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
*/

#define	import_spp
#define	import_libc
#define	import_xnames
#include <iraf.h>


/* STGIO.C -- STDGRAPH graphics terminal i/o interface.  This is a C binding
** for the VOS STDGRAPH graphics kernel text i/o routines.  These are used to
** do direct i/o to the graphics terminal, whether or not the terminal is in
** graphics mode.  When the terminal is not in graphics mode, i.e., when the
** "workstation is deactivated", these routines are equivalent to the FIO
** putline and getline procedures.
**
**	nchars|EOF = c_stggetline (STDIN, buf)
**		     c_stgputline (STDOUT, buf)
*/


/* C_STGGETLINE -- Get a line of text from the graphics terminal.
*/
int
c_stggetline (
  XINT	fd,			/* input stream		*/
  char	*buf,			/* user string buffer	*/
  int   maxch			/* max bufer size	*/
)
{
	XCHAR	xbuf[maxch+1];
	XINT    x_fd = fd;
	int	status;

	iferr (status = STG_GETLINE (&x_fd, xbuf))
	    return (EOF);
	else {
	    c_strpak (xbuf, buf, maxch);
	    return (status);
	}
}


/* C_STGPUTLINE -- Put a line of text to the graphics terminal.
*/
int
c_stgputline (
  XINT	fd,			/* input stream		*/
  char	*buf			/* user string buffer	*/
)
{
	XCHAR	xbuf[SZ_LINE+1];
	XINT    x_fd = fd;

	c_strupk (buf, xbuf, SZ_LINE);
	iferr (STG_PUTLINE (&x_fd, xbuf))
	    return (ERR);
	else
	    return (OK);
}