1 |
578 |
markom |
/* expectcomm.h - public symbols common to both expect.h and expect_tcl.h
|
2 |
|
|
|
3 |
|
|
Written by: Don Libes, libes@cme.nist.gov, NIST, 12/3/90
|
4 |
|
|
|
5 |
|
|
Design and implementation of this program was paid for by U.S. tax
|
6 |
|
|
dollars. Therefore it is public domain. However, the author and NIST
|
7 |
|
|
would appreciate credit if this program or parts of it are used.
|
8 |
|
|
*/
|
9 |
|
|
|
10 |
|
|
#ifndef _EXPECT_COMM_H
|
11 |
|
|
#define _EXPECT_COMM_H
|
12 |
|
|
|
13 |
|
|
#if 0
|
14 |
|
|
#include "expect_cf.h"
|
15 |
|
|
#endif
|
16 |
|
|
|
17 |
|
|
#include <stdio.h>
|
18 |
|
|
#include <setjmp.h>
|
19 |
|
|
|
20 |
|
|
/* since it's possible that the caller may include tcl.h before including
|
21 |
|
|
this file, we cannot include varargs/stdargs ourselves */
|
22 |
|
|
|
23 |
|
|
/* Much of the following stdarg/prototype support is taken from tcl.h
|
24 |
|
|
* (7.5) with modifications. What's going on here is that don't want
|
25 |
|
|
* to simply include tcl.h everywhere, because one of the files is the
|
26 |
|
|
* Tcl-less Expect library.)
|
27 |
|
|
*/
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
/* Definitions that allow Tcl functions with variable numbers of
|
31 |
|
|
* arguments to be used with either varargs.h or stdarg.h.
|
32 |
|
|
* TCL_VARARGS is used in procedure prototypes. TCL_VARARGS_DEF is
|
33 |
|
|
* used to declare the arguments in a function definiton: it takes the
|
34 |
|
|
* type and name of the first argument and supplies the appropriate
|
35 |
|
|
* argument declaration string for use in the function definition.
|
36 |
|
|
* TCL_VARARGS_START initializes the va_list data structure and
|
37 |
|
|
* returns the first argument. */
|
38 |
|
|
|
39 |
|
|
/* in Tcl 7.5, Tcl now supplies these definitions */
|
40 |
|
|
#if !defined(TCL_VARARGS)
|
41 |
|
|
# if defined(__STDC__) || defined(HAVE_STDARG_H)
|
42 |
|
|
# include <stdarg.h>
|
43 |
|
|
# define TCL_VARARGS(type, name) (type name, ...)
|
44 |
|
|
# define TCL_VARARGS_DEF(type, name) (type name, ...)
|
45 |
|
|
# define TCL_VARARGS_START(type, name, list) (va_start(list, name), name)
|
46 |
|
|
# else
|
47 |
|
|
# include <varargs.h>
|
48 |
|
|
# ifdef __cplusplus
|
49 |
|
|
# define TCL_VARARGS(type, name) (type name, ...)
|
50 |
|
|
# define TCL_VARARGS_DEF(type, name) (type va_alist, ...)
|
51 |
|
|
# else
|
52 |
|
|
# define TCL_VARARGS(type, name) ()
|
53 |
|
|
# define TCL_VARARGS_DEF(type, name) (va_alist)
|
54 |
|
|
# endif
|
55 |
|
|
# define TCL_VARARGS_START(type, name, list) \
|
56 |
|
|
(va_start(list), va_arg(list, type))
|
57 |
|
|
# endif /* use stdarg.h */
|
58 |
|
|
|
59 |
|
|
/*
|
60 |
|
|
* Definitions that allow this header file to be used either with or
|
61 |
|
|
* without ANSI C features like function prototypes.
|
62 |
|
|
*/
|
63 |
|
|
|
64 |
|
|
# undef _ANSI_ARGS_
|
65 |
|
|
# undef CONST
|
66 |
|
|
|
67 |
|
|
# if ((defined(__STDC__) || defined(SABER)) && !defined(NO_PROTOTYPE)) || defined(__cplusplus) || defined(USE_PROTOTYPE)
|
68 |
|
|
# define _USING_PROTOTYPES_ 1
|
69 |
|
|
# define _ANSI_ARGS_(x) x
|
70 |
|
|
# define CONST const
|
71 |
|
|
# else
|
72 |
|
|
# define _ANSI_ARGS_(x) ()
|
73 |
|
|
# define CONST
|
74 |
|
|
# endif
|
75 |
|
|
|
76 |
|
|
# ifdef __cplusplus
|
77 |
|
|
# define EXTERN extern "C"
|
78 |
|
|
# else
|
79 |
|
|
# define EXTERN extern
|
80 |
|
|
# endif
|
81 |
|
|
|
82 |
|
|
#endif /* defined(TCL_VARARGS) */
|
83 |
|
|
|
84 |
|
|
/* Arghhh! Tcl pulls in all of tcl.h in order to get the regexp funcs */
|
85 |
|
|
/* Tcl offers us a way to avoid this: temporarily define _TCL. Here goes: */
|
86 |
|
|
|
87 |
|
|
#ifdef EXP_AVOID_INCLUDING_TCL_H
|
88 |
|
|
# ifdef _TCL
|
89 |
|
|
# define EXP__TCL_WAS_DEFINED
|
90 |
|
|
# else
|
91 |
|
|
# define _TCL
|
92 |
|
|
# endif
|
93 |
|
|
#endif
|
94 |
|
|
|
95 |
|
|
#include "tclRegexp.h"
|
96 |
|
|
|
97 |
|
|
/* clean up the mess */
|
98 |
|
|
#ifdef EXP_AVOID_INCLUDING_TCL_H
|
99 |
|
|
# ifdef EXP__TCL_WAS_DEFINED
|
100 |
|
|
# undef EXP__TCL_WAS_DEFINED
|
101 |
|
|
# else
|
102 |
|
|
# undef _TCL
|
103 |
|
|
# endif
|
104 |
|
|
#endif
|
105 |
|
|
|
106 |
|
|
#if 0
|
107 |
|
|
/* moved to exp_int.h so expect_cf.h no longer needs to be installed */
|
108 |
|
|
#ifdef NO_STDLIB_H
|
109 |
|
|
# include "../compat/stdlib.h"
|
110 |
|
|
#else
|
111 |
|
|
# include <stdlib.h> /* for malloc */
|
112 |
|
|
#endif /*NO_STDLIB_H*/
|
113 |
|
|
#endif
|
114 |
|
|
|
115 |
|
|
/* common return codes for Expect functions */
|
116 |
|
|
/* The library actually only uses TIMEOUT and EOF */
|
117 |
|
|
#define EXP_ABEOF -1 /* abnormal eof in Expect */
|
118 |
|
|
/* when in library, this define is not used. */
|
119 |
|
|
/* Instead "-1" is used literally in the */
|
120 |
|
|
/* usual sense to check errors in system */
|
121 |
|
|
/* calls */
|
122 |
|
|
#define EXP_TIMEOUT -2
|
123 |
|
|
#define EXP_TCLERROR -3
|
124 |
|
|
#define EXP_FULLBUFFER -5
|
125 |
|
|
#define EXP_MATCH -6
|
126 |
|
|
#define EXP_NOMATCH -7
|
127 |
|
|
#define EXP_CANTMATCH EXP_NOMATCH
|
128 |
|
|
#define EXP_CANMATCH -8
|
129 |
|
|
#define EXP_DATA_NEW -9 /* if select says there is new data */
|
130 |
|
|
#define EXP_DATA_OLD -10 /* if we already read data in another cmd */
|
131 |
|
|
#define EXP_EOF -11
|
132 |
|
|
#define EXP_RECONFIGURE -12 /* changes to indirect spawn id lists */
|
133 |
|
|
/* require us to reconfigure things */
|
134 |
|
|
|
135 |
|
|
/* in the unlikely event that a signal handler forces us to return this */
|
136 |
|
|
/* through expect's read() routine, we temporarily convert it to this. */
|
137 |
|
|
#define EXP_TCLRET -20
|
138 |
|
|
#define EXP_TCLCNT -21
|
139 |
|
|
#define EXP_TCLCNTTIMER -22
|
140 |
|
|
#define EXP_TCLBRK -23
|
141 |
|
|
#define EXP_TCLCNTEXP -24
|
142 |
|
|
#define EXP_TCLRETTCL -25
|
143 |
|
|
|
144 |
|
|
/* yet more TCL return codes */
|
145 |
|
|
/* Tcl does not safely provide a way to define the values of these, so */
|
146 |
|
|
/* use ridiculously numbers for safety */
|
147 |
|
|
#define EXP_CONTINUE -101 /* continue expect command */
|
148 |
|
|
/* and restart timer */
|
149 |
|
|
#define EXP_CONTINUE_TIMER -102 /* continue expect command */
|
150 |
|
|
/* and continue timer */
|
151 |
|
|
#define EXP_TCL_RETURN -103 /* converted by interact */
|
152 |
|
|
/* and interpeter from */
|
153 |
|
|
/* inter_return into */
|
154 |
|
|
/* TCL_RETURN*/
|
155 |
|
|
|
156 |
|
|
#define EXP_TIME_INFINITY -1
|
157 |
|
|
#define EXP_SPAWN_ID_BAD -1
|
158 |
|
|
|
159 |
|
|
EXTERN int exp_is_debugging;
|
160 |
|
|
EXTERN int exp_loguser;
|
161 |
|
|
EXTERN int exp_disconnected; /* proc. disc'd from controlling tty */
|
162 |
|
|
|
163 |
|
|
EXTERN void (*exp_close_in_child)(); /* procedure to close files in child */
|
164 |
|
|
EXTERN void exp_close_tcl_files(); /* deflt proc: close all Tcl's files */
|
165 |
|
|
|
166 |
|
|
EXTERN void exp_slave_control _ANSI_ARGS_((int,int));
|
167 |
|
|
|
168 |
|
|
EXTERN char *exp_pty_error; /* place to pass a string generated */
|
169 |
|
|
/* deep in the innards of the pty */
|
170 |
|
|
/* code but needed by anyone */
|
171 |
|
|
|
172 |
|
|
#endif /* _EXPECT_COMM_H */
|