/* expect.h - include file for using the expect library, libexpect.a
from C or C++ (i.e., without Tcl)
Written by: Don Libes, libes@cme.nist.gov, NIST, 12/3/90
Design and implementation of this program was paid for by U.S. tax
dollars. Therefore it is public domain. However, the author and NIST
would appreciate credit if this program or parts of it are used.
* This header file describes the externally-visible facilities
* of the Tcl interpreter.
* Copyright (c) 1987-1994 The Regents of the University of California.
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
* Copyright (c) 1993-1996 Lucent Technologies.
* Copyright (c) 1998-1999 Scriptics Corporation.
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
* RCS: @(#) $Id: expect.h,v 5.30 2001/11/09 19:36:18 andreas_kupries Exp $
# if defined(_WIN32) || defined(WIN32)
* Under Windows we need to call Tcl_Alloc in all cases to avoid competing
* C run-time library issues.
* The following definitions set up the proper options for Macintosh
* compilers. We use this method because there is no autoconf equivalent.
* Utility macros: STRINGIFY takes an argument and wraps it in "" (double
* quotation marks), JOIN joins two arguments.
# define STRINGIFY(x) STRINGIFY1(x)
# define STRINGIFY1(x) #x
# define JOIN(a,b) JOIN1(a,b)
# ifdef RESOURCE_INCLUDED
# define STRINGIFY(x) STRINGIFY1(x)
# define STRINGIFY1(x) #x
# define JOIN(a,b) JOIN1(a,b)
# define STRINGIFY(x) "x"
# define JOIN(a,b) VERBATIM(a)VERBATIM(b)
* A special definition used to allow this header file to be included
* in resource files so that they can get obtain version information from
* this file. Resource compilers don't like all the C stuff, like typedefs
* and procedure declarations, that occur below.
#ifndef RESOURCE_INCLUDED
* Definitions that allow Tcl functions with variable numbers of
* arguments to be used with either varargs.h or stdarg.h. TCL_VARARGS
* is used in procedure prototypes. TCL_VARARGS_DEF is used to declare
* the arguments in a function definiton: it takes the type and name of
* the first argument and supplies the appropriate argument declaration
* string for use in the function definition. TCL_VARARGS_START
* initializes the va_list data structure and returns the first argument.
#if defined(__STDC__) || defined(HAS_STDARG)
# define TCL_VARARGS(type, name) (type name, ...)
# define TCL_VARARGS_DEF(type, name) (type name, ...)
# define TCL_VARARGS_START(type, name, list) (va_start(list, name), name)
# define TCL_VARARGS(type, name) (type name, ...)
# define TCL_VARARGS_DEF(type, name) (type va_alist, ...)
# define TCL_VARARGS(type, name) ()
# define TCL_VARARGS_DEF(type, name) (va_alist)
# define TCL_VARARGS_START(type, name, list) \
(va_start(list), va_arg(list, type))
* Macros used to declare a function to be exported by a DLL.
* Used by Windows, maps to no-op declarations on non-Windows systems.
* The default build on windows is for a DLL, which causes the DLLIMPORT
* and DLLEXPORT macros to be nonempty. To build a static library, the
* macro STATIC_BUILD should be defined.
# if defined(__WIN32__) && (defined(_MSC_VER) || (defined(__GNUC__) && defined(__declspec)))
# define DLLIMPORT __declspec(dllimport)
# define DLLEXPORT __declspec(dllexport)
* These macros are used to control whether functions are being declared for
* import or export. If a function is being declared while it is being built
* to be included in a shared library, then it should have the DLLEXPORT
* storage class. If is being declared for use by a module that is going to
* link against the shared library, then it should have the DLLIMPORT storage
* class. If the symbol is beind declared for a static build or for use from a
* stub library, then the storage class should be empty.
* The convention is that a macro called BUILD_xxxx, where xxxx is the
* name of a library we are building, is set on the compile line for sources
* that are to be placed in the library. When this macro is set, the
* storage class will be set to DLLEXPORT. At the end of the header file, the
* storage class will be reset to DLLIMPORt.
# define TCL_STORAGE_CLASS DLLEXPORT
# define TCL_STORAGE_CLASS
# define TCL_STORAGE_CLASS DLLIMPORT
* Definitions that allow this header file to be used either with or
* without ANSI C features like function prototypes. */
#if ((defined(__STDC__) || defined(SABER)) && !defined(NO_PROTOTYPE)) || defined(__cplusplus) || defined(USE_PROTOTYPE)
# define _USING_PROTOTYPES_ 1
# define _ANSI_ARGS_(x) x
# define _ANSI_ARGS_(x) ()
# define EXTERN extern "C" TCL_STORAGE_CLASS
# define EXTERN extern TCL_STORAGE_CLASS
* Macro to use instead of "void" for arguments that must have
* type "void *" in ANSI C; maps them to type "char *" in
* The following code is copied from winnt.h
* Miscellaneous declarations.
typedef struct Tcl_RegExp_
*Tcl_RegExp
;
* The following declarations either map ckalloc and ckfree to
* malloc and free, or they map them to procedures with all sorts
* of debugging hooks defined in tclCkalloc.c.
# define Tcl_Alloc(x) Tcl_DbCkalloc(x, __FILE__, __LINE__)
# define Tcl_Free(x) Tcl_DbCkfree(x, __FILE__, __LINE__)
# define Tcl_Realloc(x,y) Tcl_DbCkrealloc((x), (y),__FILE__, __LINE__)
# define ckalloc(x) Tcl_DbCkalloc(x, __FILE__, __LINE__)
# define ckfree(x) Tcl_DbCkfree(x, __FILE__, __LINE__)
# define ckrealloc(x,y) Tcl_DbCkrealloc((x), (y),__FILE__, __LINE__)
* If USE_TCLALLOC is true, then we need to call Tcl_Alloc instead of
* the native malloc/free. The only time USE_TCLALLOC should not be
* true is when compiling the Tcl/Tk libraries on Unix systems. In this
* case we can safely call the native malloc/free directly as a performance
# define ckalloc(x) Tcl_Alloc(x)
# define ckfree(x) Tcl_Free(x)
# define ckrealloc(x,y) Tcl_Realloc(x,y)
# define ckalloc(x) malloc(x)
# define ckfree(x) free(x)
# define ckrealloc(x,y) realloc(x,y)
# define Tcl_DumpActiveMemory(x)
# define Tcl_ValidateAllMemory(x,y)
#endif /* !TCL_MEM_DEBUG */
* These function have been renamed. The old names are deprecated, but we
* define these macros for backwards compatibilty.
#define Tcl_Ckalloc Tcl_Alloc
#define Tcl_Ckfree Tcl_Free
#define Tcl_Ckrealloc Tcl_Realloc
#define Tcl_Return Tcl_SetResult
#define Tcl_TildeSubst Tcl_TranslateFileName
* In later releases, Tcl_Panic will be the correct name to use. For now
* we leave it as panic to avoid breaking existing binaries.
#define Tcl_PanicVA panicVA
#endif /* RESOURCE_INCLUDED */
#define TCL_STORAGE_CLASS DLLIMPORT
* end of tcl.h definitions
* regexp definitions - from tcl8.0/tclRegexp.h
* Definitions etc. for regexp(3) routines.
* Caveat: this is V8 regexp(3) [actually, a reimplementation thereof],
* RCS: @(#) $Id: expect.h,v 5.30 2001/11/09 19:36:18 andreas_kupries Exp $
# undef TCL_STORAGE_CLASS
# define TCL_STORAGE_CLASS DLLEXPORT
* NSUBEXP must be at least 10, and no greater than 117 or the parser
* will not work properly.
char regstart
; /* Internal use only. */
char reganch
; /* Internal use only. */
char *regmust
; /* Internal use only. */
int regmlen
; /* Internal use only. */
char program
[1]; /* Unwarranted chumminess with compiler. */
EXTERN regexp
*TclRegComp
_ANSI_ARGS_((char *exp
));
EXTERN
int TclRegExec
_ANSI_ARGS_((regexp
*prog
, char *string
, char *start
));
EXTERN
void TclRegSub
_ANSI_ARGS_((regexp
*prog
, char *source
, char *dest
));
EXTERN
void exp_TclRegError
_ANSI_ARGS_((char *msg
));
EXTERN
char *TclGetRegError
_ANSI_ARGS_((void));
# undef TCL_STORAGE_CLASS
# define TCL_STORAGE_CLASS DLLIMPORT
* end of regexp definitions
* finally - expect-specific definitions
exp_end
= 0, /* placeholder - no more cases */
exp_glob
, /* glob-style */
exp_exact
, /* exact string */
exp_regexp
, /* regexp-style, uncompiled */
exp_compiled
, /* regexp-style, compiled */
exp_null
, /* matches binary 0 */
exp_bogus
/* aid in reporting compatibility problems */
struct exp_case
{ /* case for expect command */
int value
; /* value to be returned upon match */
EXTERN
char *exp_buffer
; /* buffer of matchable chars */
EXTERN
char *exp_buffer_end
; /* one beyond end of matchable chars */
EXTERN
char *exp_match
; /* start of matched string */
EXTERN
char *exp_match_end
; /* one beyond end of matched string */
EXTERN
int exp_match_max
; /* bytes */
EXTERN
int exp_timeout
; /* seconds */
EXTERN
int exp_full_buffer
; /* if true, return on full buffer */
EXTERN
int exp_remove_nulls
; /* if true, remove nulls */
EXTERN
int exp_pty_timeout
; /* see Cray hooks in source */
EXTERN
int exp_pid
; /* process-id of spawned process */
EXTERN
int exp_autoallocpty
; /* if TRUE, we do allocation */
EXTERN
int exp_pty
[2]; /* master is [0], slave is [1] */
EXTERN
char *exp_pty_slave_name
; /* name of pty slave device if we */
EXTERN
char *exp_stty_init
; /* initial stty args */
EXTERN
int exp_ttycopy
; /* copy tty parms from /dev/tty */
EXTERN
int exp_ttyinit
; /* set tty parms to sane state */
EXTERN
int exp_console
; /* redirect console */
EXTERN sigjmp_buf exp_readenv
; /* for interruptable read() */
EXTERN
jmp_buf exp_readenv
; /* for interruptable read() */
#endif /* HAVE_SIGLONGJMP */
EXTERN
int exp_reading
; /* whether we can longjmp or not */
#define EXP_ABORT 1 /* abort read */
#define EXP_RESTART 2 /* restart read */
EXTERN
int exp_is_debugging
;
EXTERN
void (*exp_close_in_child
)(); /* procedure to close files in child */
EXTERN
void exp_slave_control
_ANSI_ARGS_((int,int));
EXTERN
int exp_logfile_all
;
EXTERN
FILE *exp_debugfile
;
EXTERN
FILE *exp_logfile
;
extern void exp_debuglog
_ANSI_ARGS_(TCL_VARARGS(char *,fmt
));
extern void exp_errorlog
_ANSI_ARGS_(TCL_VARARGS(char *,fmt
));
EXTERN
int exp_disconnect
_ANSI_ARGS_((void));
EXTERN
FILE *exp_popen
_ANSI_ARGS_((char *command
));
EXTERN
void (*exp_child_exec_prelude
) _ANSI_ARGS_((void));
EXTERN
int exp_spawnl
_ANSI_ARGS_(TCL_VARARGS(char *,file
));
EXTERN
int exp_expectl
_ANSI_ARGS_(TCL_VARARGS(int,fd
));
EXTERN
int exp_fexpectl
_ANSI_ARGS_(TCL_VARARGS(FILE *,fp
));
EXTERN
int exp_spawnv
_ANSI_ARGS_((char *file
, char *argv
[]));
EXTERN
int exp_expectv
_ANSI_ARGS_((int fd
, struct exp_case
*cases
));
EXTERN
int exp_fexpectv
_ANSI_ARGS_((FILE *fp
, struct exp_case
*cases
));
EXTERN
int exp_spawnfd
_ANSI_ARGS_((int fd
));