Debian Codegraph @

gui/GraphLib/libsrc/uimxR5/include/sp_pty.h

raw
1 /*---------------------------------------------------------------------
2 * $Date: 2005-05-12 07:32:35 $ $Revision: 1.2 $
3 *---------------------------------------------------------------------
4 * Copyright (c) 1992, Visual Edge Software Ltd.
5 *
6 * ALL RIGHTS RESERVED. Permission to use, copy, modify, and
7 * distribute this software and its documentation for any purpose
8 * and without fee is hereby granted, provided that the above
9 * copyright notice appear in all copies and that both that
10 * copyright notice and this permission notice appear in supporting
11 * documentation, and that the name of Visual Edge Software not be
12 * used in advertising or publicity pertaining to distribution of
13 * the software without specific, written prior permission. The year
14 * included in the notice is the year of the creation of the work.
15 *---------------------------------------------------------------------
16 * File_Description_Section
17 *--------------------------------------------------------------------
18
19 050512 last modif
20 */
21
22 #ifndef SP_PTY_H
23 #define SP_PTY_H
24
25 /*--- include files ---*/
26 #include "uxproto.h"
27 #include <signal.h>
28 #include <setjmp.h>
29
30 #ifdef Cygwin
31 #include <termio.h>
32 #endif
33
34 #ifdef SYSV
35 #include <sys/ioctl.h>
36 #include <sys/termio.h>
37 #if !defined(m88k) && !defined(sgi) && !defined(magnum) && !defined(sco) && !defined(dg88) && !defined(ibmr2)
38 #include <sys/ptyio.h>
39 #if defined(SIGTSTP)
40 #include <sys/bsdtty.h>
41 #endif /* SIGTSTP */
42 #endif /* (m88k) && (sgi) && (magnum) && (sco) && (dg88) && (ibmr2) */
43 #endif /* SYSV */
44
45 #if defined(USES_SGTTY_H)
46 # include <sys/sgtty.h>
47 # include <sys/termio.h>
48 #endif /* USES_SGTTY_H */
49
50 #if defined(_TEK88) || defined(_MOTOR88)
51 # include <sys/pty.h>
52 #endif /* _TEK88 */
53
54 /* For Solaris, in design time, use BSD library and in runtime use SYSV */
55 #if (defined (SOLARIS))
56 # ifdef DESIGN_TIME
57 # define BSD_COMP
58 # endif
59 # include <sys/ttold.h>
60 # include <sys/ttychars.h>
61 # ifdef DESIGN_TIME
62 # include <sys/termios.h>
63 # endif
64 #endif
65
66 #if defined(__FreeBSD__) || defined(__Darwin__)
67 #include <sys/ioctl_compat.h>
68 #else
69 #include <sys/ioctl.h>
70 #endif
71
72 #include <sys/types.h>
73 #include <sys/wait.h>
74
75 #if !defined(_TEK88) && !defined(_MOTOR88)
76 # include <sys/file.h>
77 #endif
78
79 #include <errno.h>
80 #include <fcntl.h>
81
82 #if defined(sgi) || defined(ibmr2)
83 # include <sys/stat.h>
84 # include <sys/sysmacros.h>
85 #endif /* sgi */
86
87 /* for DG, use SYSV pty code */
88 #if defined(dg88)
89 # define USE_SYSV_TERMIO
90 # define USE_SYSV_PGRP
91 #endif /* dg88 */
92
93 #ifdef __cplusplus
94 extern "C" { /* C++ compatability */
95 #endif /* __cplusplus */
96
97 /*--- macro symbolic constants ---*/
98
99 /*--- macro functions ---*/
100
101 /*--- types ---*/
102 struct _pty_dirs {
103 char *pty_dir; /* pty slave directory... */
104 char *ptym_dir; /* pty master directory... */
105 char *char_1; /* string of first characters in pty name... */
106 char *char_2; /* string of second characters in pty name... */
107 char *char_3; /* string of third characters in pty name... */
108 int fast; /* true->skip all if first does not exist... */
109 };
110
111 /* WHAT IS MISSING
112 * either a new pty slave name, or a "sorry, no more ptys -- terminate"
113 * message.
114 */
115 typedef enum {
116 PTY_BAD, /* c->p: can't open pty slave for some reason */
117 PTY_GOOD, /* c->p: we have a good pty, let's go on */
118 PTY_NEW, /* p->c: here is a new pty slave, try this */
119 PTY_NOMORE, /* p->c: no more pty's, terminate */
120 SUBPROC_ERROR, /* c->p: here is an error msg to display */
121 SUBPROC_EXEC_ERROR
122 /* c->p: unable to exec subprocess */
123 } status_t;
124
125 typedef struct {
126 status_t status; /* packet type... */
127 int error; /* open error... */
128 char buffer[1024]; /* name of pty slave... */
129 } handshake_t;
130
131
132 /*--- external functions ---*/
133 extern void UxPtyExitHandler UXPROTO(( void ));
134 extern int UxGetPtty UXPROTO(( int *pty, int reset ));
135 extern int UxSetTty UXPROTO(( void ));
136 extern void UxPtyChildCommSetup UXPROTO(( int tty, int echo ));
137 extern int UxPtyStartChild UXPROTO(( int pty, int echo, char **args ));
138 extern int UxSetPseudo UXPROTO(( int pty ));
139 extern char ** UxPtyPrepareCommand UXPROTO(( char *command ));
140 extern int UxPtyExecSubprocess UXPROTO(( char *cmd, int echo, int *t_pty, int
141 *t_pid ));
142
143 /*--- external variables ---*/
144
145
146 #ifdef __cplusplus
147 } /* Close scope of 'extern "C"' declaration which encloses file. */
148 #endif /* __cplusplus */
149
150 #endif