Index: exp_command.c ================================================================================ --- exp_clib.c +++ exp_clib.c @@ -10,6 +10,7 @@ #include "expect_cf.h" #include #include +#include #ifdef HAVE_INTTYPES_H # include #endif --- exp_command.c +++ exp_command.c @@ -29,7 +29,6 @@ # include #endif #include -#include "exp_tty.h" #include #include @@ -66,6 +65,7 @@ #include "tcl.h" #include "string.h" +#include "expect.h" #include "expect_tcl.h" #include "exp_rename.h" #include "exp_prog.h" @@ -73,6 +73,7 @@ #include "exp_log.h" #include "exp_event.h" #include "exp_pty.h" +#include "exp_tty_in.h" #ifdef TCL_DEBUGGER #include "tcldbg.h" #endif @@ -86,8 +87,8 @@ #define SPAWN_ID_VARNAME "spawn_id" -int exp_getptymaster(); -int exp_getptyslave(); +void exp_ecmd_remove_state_direct_and_indirect(Tcl_Interp *interp, ExpState *esPtr); + int exp_forked = FALSE; /* whether we are child process */ @@ -151,8 +152,7 @@ #ifdef FULLTRAPS static void -init_traps(traps) - RETSIGTYPE (*traps[])(); +init_traps(RETSIGTYPE (*traps[])()) { int i; @@ -183,11 +183,11 @@ /* returns current ExpState or 0. If 0, may be immediately followed by return TCL_ERROR. */ struct ExpState * -expStateCurrent(interp,opened,adjust,any) - Tcl_Interp *interp; - int opened; - int adjust; - int any; +expStateCurrent( + Tcl_Interp *interp, + int opened, + int adjust, + int any) { static char *user_spawn_id = "exp0"; @@ -198,12 +198,12 @@ } ExpState * -expStateCheck(interp,esPtr,open,adjust,msg) - Tcl_Interp *interp; - ExpState *esPtr; - int open; - int adjust; - char *msg; +expStateCheck( + Tcl_Interp *interp, + ExpState *esPtr, + int open, + int adjust, + char *msg) { if (open && !esPtr->open) { exp_error(interp,"%s: spawn id %s not open",msg,esPtr->name); @@ -214,12 +214,13 @@ } ExpState * -expStateFromChannelName(interp,name,open,adjust,any,msg) - Tcl_Interp *interp; - char *name; - int open; - int adjust; - char *msg; +expStateFromChannelName( + Tcl_Interp *interp, + char *name, + int open, + int adjust, + int any, + char *msg) { ExpState *esPtr; Tcl_Channel channel; @@ -248,8 +249,7 @@ /* zero out the wait status field */ static void -exp_wait_zero(status) -WAIT_STATUS_TYPE *status; +exp_wait_zero(WAIT_STATUS_TYPE *status) { int i; @@ -260,9 +260,9 @@ /* called just before an ExpState entry is about to be invalidated */ void -exp_state_prep_for_invalidation(interp,esPtr) -Tcl_Interp *interp; -ExpState *esPtr; +exp_state_prep_for_invalidation( + Tcl_Interp *interp, + ExpState *esPtr) { exp_ecmd_remove_state_direct_and_indirect(interp,esPtr); @@ -275,8 +275,7 @@ /*ARGSUSED*/ void -exp_trap_on(master) -int master; +exp_trap_on(int master) { #ifdef HAVE_PTYTRAP if (master == -1) return; @@ -285,8 +284,7 @@ } int -exp_trap_off(name) -char *name; +exp_trap_off(char *name) { #ifdef HAVE_PTYTRAP ExpState *esPtr; @@ -310,8 +308,7 @@ static void -expBusy(esPtr) - ExpState *esPtr; +expBusy(ExpState *esPtr) { int x = open("/dev/null",0); if (x != esPtr->fdin) { @@ -323,9 +320,9 @@ } int -exp_close(interp,esPtr) - Tcl_Interp *interp; - ExpState *esPtr; +exp_close( + Tcl_Interp *interp, + ExpState *esPtr) { if (0 == expStateCheck(interp,esPtr,1,0,"close")) return TCL_ERROR; esPtr->open = FALSE; @@ -404,8 +401,7 @@ /* we need a separate function because spawn_id_any is thread-specific */ /* and can't be seen outside this file */ int -expStateAnyIs(esPtr) - ExpState *esPtr; +expStateAnyIs(ExpState *esPtr) { ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); @@ -413,8 +409,7 @@ } int -expDevttyIs(esPtr) - ExpState *esPtr; +expDevttyIs(ExpState *esPtr) { ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); @@ -422,8 +417,7 @@ } int -expStdinoutIs(esPtr) - ExpState *esPtr; +expStdinoutIs(ExpState *esPtr) { ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); @@ -447,8 +441,7 @@ } void -exp_init_spawn_id_vars(interp) - Tcl_Interp *interp; +exp_init_spawn_id_vars(Tcl_Interp *interp) { ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); @@ -467,8 +460,7 @@ } void -exp_init_spawn_ids(interp) - Tcl_Interp *interp; +exp_init_spawn_ids(Tcl_Interp *interp) { static ExpState any_placeholder; /* can be shared process-wide */ @@ -504,8 +496,7 @@ } void -expCloseOnExec(fd) - int fd; +expCloseOnExec(int fd) { (void) fcntl(fd,F_SETFD,1); } @@ -516,9 +507,9 @@ /* * DEBUGGING UTILITIES - DON'T DELETE */ static void -show_pgrp(fd,string) - int fd; - char *string; +show_pgrp( + int fd, + char *string) { int pgrp; @@ -532,8 +523,7 @@ } static void -set_pgrp(fd) - int fd; +set_pgrp(int fd) { int pgrp = getpgrp(0); if (-1 == ioctl(fd,TIOCSETPGRP,&pgrp)) perror("TIOCSETPGRP"); @@ -562,9 +552,9 @@ /*ARGSUSED*/ static void -set_slave_name(esPtr,name) - ExpState *esPtr; - char *name; +set_slave_name( + ExpState *esPtr, + char *name) { #ifdef HAVE_PTYTRAP int newptr; @@ -582,11 +572,11 @@ /* arguments are passed verbatim to execvp() */ /*ARGSUSED*/ static int -Exp_SpawnObjCmd(clientData,interp,objc,objv) - ClientData clientData; - Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_SpawnObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { ExpState *esPtr = 0; int slave; @@ -910,16 +900,16 @@ return TCL_ERROR; } if (mode & TCL_READABLE) { - if (TCL_ERROR == Tcl_GetChannelHandle(channel, TCL_READABLE, (ClientData *) &rfdc)) { + if (TCL_ERROR == Tcl_GetChannelHandle(channel, TCL_READABLE, &rfdc)) { return TCL_ERROR; } - rfd = (int) rfdc; + rfd = (int)(long) rfdc; } if (mode & TCL_WRITABLE) { - if (TCL_ERROR == Tcl_GetChannelHandle(channel, TCL_WRITABLE, (ClientData *) &wfdc)) { + if (TCL_ERROR == Tcl_GetChannelHandle(channel, TCL_WRITABLE, &wfdc)) { return TCL_ERROR; } - wfd = (int) wfdc; + wfd = (int)(long) wfdc; } master = ((mode & TCL_READABLE)?rfd:wfd); @@ -1346,7 +1336,7 @@ } argv[k] = NULL; - (void) execvp(command,argv); + execvp(command,argv); for (k=0,i=cmdIndex;inext = exp_state_list_pool; exp_state_list_pool = fd; } void -exp_free_i(interp,i,updateproc) - Tcl_Interp *interp; - struct exp_i *i; - Tcl_VarTraceProc *updateproc; /* proc to invoke if indirect is written */ +exp_free_i( + Tcl_Interp *interp, + struct exp_i *i, + Tcl_VarTraceProc *updateproc)/* proc to invoke if indirect is written */ { if (i->next) exp_free_i(interp,i->next,updateproc); @@ -1781,12 +1768,12 @@ /* can only fail on bad direct descriptors */ /* indirect descriptors always succeed */ struct exp_i * -exp_new_i_complex(interp,arg,duration,updateproc) - Tcl_Interp *interp; - char *arg; /* spawn id list or a variable containing a list */ - int duration; /* if we have to copy the args */ +exp_new_i_complex( + Tcl_Interp *interp, + char *arg, /* spawn id list or a variable containing a list */ + int duration, /* if we have to copy the args */ /* should only need do this in expect_before/after */ - Tcl_VarTraceProc *updateproc; /* proc to invoke if indirect is written */ + Tcl_VarTraceProc *updateproc) /* proc to invoke if indirect is written */ { struct exp_i *i; char **stringp; @@ -1829,9 +1816,9 @@ } void -exp_i_add_state(i,esPtr) - struct exp_i *i; - ExpState *esPtr; +exp_i_add_state( + struct exp_i *i, + ExpState *esPtr) { struct exp_state_list *new_state; @@ -1844,9 +1831,9 @@ /* returns TCL_ERROR only on direct */ /* indirects always succeed */ static int -exp_i_parse_states(interp,i) /* INTL */ - Tcl_Interp *interp; - struct exp_i *i; +exp_i_parse_states( + Tcl_Interp *interp, + struct exp_i *i) { struct ExpState *esPtr; char *p = i->value; @@ -1873,9 +1860,9 @@ /* return TCL_ERROR only on direct variables */ /* indirect variables always succeed */ int -exp_i_update(interp,i) - Tcl_Interp *interp; - struct exp_i *i; +exp_i_update( + Tcl_Interp *interp, + struct exp_i *i) { char *p; /* string representation of list of spawn ids */ @@ -1907,9 +1894,9 @@ } struct exp_i * -exp_new_i_simple(esPtr,duration) - ExpState *esPtr; - int duration; /* if we have to copy the args */ +exp_new_i_simple( + ExpState *esPtr, + int duration) /* if we have to copy the args */ /* should only need do this in expect_before/after */ { struct exp_i *i; @@ -1926,11 +1913,11 @@ /*ARGSUSED*/ static int -Exp_SendLogObjCmd(clientData, interp, objc, objv) - ClientData clientData; - Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_SendLogObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { static char* options[] = { "--", NULL }; enum options { LOG_QUOTE }; @@ -1970,11 +1957,11 @@ /* you should quote all your send args to make them one single argument. */ /*ARGSUSED*/ static int -Exp_SendObjCmd(clientData, interp, objc, objv) /* INTL */ - ClientData clientData; - Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; +Exp_SendObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) { ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); ExpState *esPtr = 0; @@ -2168,11 +2155,11 @@ /*ARGSUSED*/ static int -Exp_LogFileObjCmd(clientData, interp, objc, objv) - ClientData clientData; - Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_LogFileObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { static char resultbuf[1000]; char *chanName = 0; @@ -2301,11 +2288,11 @@ /*ARGSUSED*/ static int -Exp_LogUserObjCmd(clientData, interp, objc, objv) - ClientData clientData; - Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_LogUserObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { int old_loguser = expLogUserGet(); @@ -2333,11 +2320,11 @@ #ifdef TCL_DEBUGGER /*ARGSUSED*/ static int -Exp_DebugObjCmd(clientData, interp, objc, objv) - ClientData clientData; - Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_DebugObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { int now = FALSE; /* soon if FALSE, now if TRUE */ int exp_tcl_debugger_was_available = exp_tcl_debugger_available; @@ -2403,11 +2390,11 @@ /*ARGSUSED*/ static int -Exp_ExpInternalObjCmd(clientData, interp, objc, objv) - ClientData clientData; - Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_ExpInternalObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { int newChannel = FALSE; Tcl_Channel oldChannel; @@ -2483,11 +2470,11 @@ /*ARGSUSED*/ static int -Exp_ExitObjCmd(clientData, interp, objc, objv) - ClientData clientData; - Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_ExitObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { int value = 0; @@ -2534,20 +2521,21 @@ Tcl_Eval(interp, "rename _close.pre_expect close"); Tcl_Exit(value); /*NOTREACHED*/ + return TCL_ERROR; } /*ARGSUSED*/ static int -Exp_ConfigureObjCmd(clientData, interp, objc, objv) - ClientData clientData; - Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_ConfigureObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { /* Magic configuration stuff. */ int i, opt, val; - static CONST char* options [] = { + static CONST84 char* options [] = { "-strictwrite", NULL }; enum options { @@ -2579,11 +2567,11 @@ /*ARGSUSED*/ static int -Exp_CloseObjCmd(clientData, interp, objc, objv) - ClientData clientData; - Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_CloseObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { int onexec_flag = FALSE; /* true if -onexec seen */ int close_onexec; @@ -2690,14 +2678,14 @@ /*ARGSUSED*/ static int -tcl_tracer(clientData,interp,level,command,cmdInfo,objc,objv) - ClientData clientData; - Tcl_Interp *interp; - int level; - CONST char *command; - Tcl_Command cmdInfo; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +tcl_tracer( + ClientData clientData, + Tcl_Interp *interp, + int level, + CONST char *command, + Tcl_Command cmdInfo, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { int i; @@ -2710,19 +2698,18 @@ } static void -tcl_tracer_del(clientData) - ClientData clientData; +tcl_tracer_del(ClientData clientData) { /* Nothing */ } /*ARGSUSED*/ static int -Exp_StraceObjCmd(clientData, interp, objc, objv) - ClientData clientData; - Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_StraceObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { static int trace_level = 0; static Tcl_Trace trace_handle; @@ -2829,9 +2816,9 @@ } void -fork_init(f,pid) - struct forked_proc *f; - int pid; +fork_init( + struct forked_proc *f, + int pid) { f->pid = pid; f->link_status = wait_not_done; @@ -2839,8 +2826,7 @@ /* make an entry for a new proc */ void -fork_add(pid) - int pid; +fork_add(int pid) { struct forked_proc *f; @@ -2873,11 +2859,11 @@ */ /*ARGSUSED*/ static int -Exp_WaitObjCmd(clientData, interp, objc, objv) - ClientData clientData; - Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_WaitObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { char *chanName = 0; struct ExpState *esPtr; @@ -2940,7 +2926,7 @@ /* are marked sys_waited already */ if (!esPtr->sys_waited) { if (nowait) { - Tcl_Pid pid = (Tcl_Pid)esPtr->pid; + Tcl_Pid pid = (Tcl_Pid)(long)esPtr->pid; /* should probably generate an error */ /* if SIGCHLD is trapped. */ @@ -3086,11 +3072,11 @@ /*ARGSUSED*/ static int -Exp_ForkObjCmd(clientData, interp, objc, objv) - ClientData clientData; - Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_ForkObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { int rc; if (objc > 1) { @@ -3120,11 +3106,11 @@ /*ARGSUSED*/ static int -Exp_DisconnectObjCmd(clientData, interp, objc, objv) - ClientData clientData; - Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_DisconnectObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); @@ -3230,11 +3216,11 @@ /*ARGSUSED*/ static int -Exp_OverlayObjCmd(clientData, interp, objc, objv) - ClientData clientData; - Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_OverlayObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { int newfd, oldfd; int dash_name = 0; @@ -3317,11 +3303,11 @@ /*ARGSUSED*/ int -Exp_InterpreterObjCmd(clientData, interp, objc, objv) - ClientData clientData; - Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_InterpreterObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { Tcl_Obj *eofObj = 0; int i; @@ -3365,11 +3351,11 @@ /* this command supercede's Tcl's builtin CONTINUE command */ /*ARGSUSED*/ int -Exp_ExpContinueObjCmd(clientData, interp, objc, objv) - ClientData clientData; - Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_ExpContinueObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { if (objc == 1) { return EXP_CONTINUE; @@ -3385,11 +3371,11 @@ /* most of this is directly from Tcl's definition for return */ /*ARGSUSED*/ int -Exp_InterReturnObjCmd(clientData, interp, objc, objv) - ClientData clientData; - Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; +Exp_InterReturnObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) { /* let Tcl's return command worry about args */ /* if successful (i.e., TCL_RETURN is returned) */ @@ -3406,11 +3392,11 @@ /*ARGSUSED*/ int -Exp_OpenObjCmd(clientData, interp, objc, objv) - ClientData clientData; - Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_OpenObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { ExpState *esPtr; char *chanName = 0; @@ -3469,7 +3455,7 @@ if (!leaveopen) { /* remove from Expect's memory in anticipation of passing to Tcl */ if (esPtr->pid != EXP_NOPID) { - Tcl_Pid pid = (Tcl_Pid)esPtr->pid; + Tcl_Pid pid = (Tcl_Pid)(long)esPtr->pid; Tcl_DetachPids(1,&pid); esPtr->pid = EXP_NOPID; esPtr->sys_waited = esPtr->user_waited = TRUE; @@ -3486,7 +3472,7 @@ * Oh, and we're also being rather cavalier with the permissions here, * but they're likely to be right for the same reasons. */ - channel = Tcl_MakeFileChannel((ClientData)newfd,TCL_READABLE|TCL_WRITABLE); + channel = Tcl_MakeFileChannel((ClientData)(long)newfd,TCL_READABLE|TCL_WRITABLE); Tcl_RegisterChannel(interp, channel); Tcl_AppendResult(interp, Tcl_GetChannelName(channel), (char *) NULL); return TCL_OK; @@ -3499,10 +3485,10 @@ /* return 1 if a string is substring of a flag */ /* this version is the code used by the macro that everyone calls */ int -exp_flageq_code(flag,string,minlen) - char *flag; - char *string; - int minlen; /* at least this many chars must match */ +exp_flageq_code( + char *flag, + char *string, + int minlen) /* at least this many chars must match */ { for (;*flag;flag++,string++,minlen--) { if (*string == '\0') break; @@ -3579,8 +3565,7 @@ {0}}; void -exp_init_most_cmds(interp) - Tcl_Interp *interp; +exp_init_most_cmds(Tcl_Interp *interp) { exp_create_commands(interp,cmd_data); --- exp_command.h +++ exp_command.h @@ -220,7 +220,7 @@ EXTERN void exp_trap_on _ANSI_ARGS_((int)); EXTERN int exp_trap_off _ANSI_ARGS_((char *)); -EXTERN void exp_strftime(); +EXTERN void exp_strftime(char *format, const struct tm *timeptr,Tcl_DString *dstring); #define exp_deleteProc (void (*)())0 #define exp_deleteObjProc (void (*)())0 --- exp_inter.c +++ exp_inter.c @@ -125,9 +125,9 @@ */ struct input * -expStateToInput(hash,esPtr) - ExpState *esPtr; - Tcl_HashTable *hash; +expStateToInput( + Tcl_HashTable *hash, + ExpState *esPtr) { Tcl_HashEntry *entry = Tcl_FindHashEntry(hash,(char *)esPtr); @@ -139,10 +139,10 @@ } void -expCreateStateToInput(hash,esPtr,inp) - ExpState *esPtr; - Tcl_HashTable *hash; - struct input *inp; +expCreateStateToInput( + Tcl_HashTable *hash, + ExpState *esPtr, + struct input *inp) { Tcl_HashEntry *entry; int newPtr; @@ -151,12 +151,15 @@ Tcl_SetHashValue(entry,(ClientData)inp); } -static void free_input(); -static void free_keymap(); -static void free_output(); -static void free_action(); -static struct action *new_action(); -static int inter_eval(); +static void free_input(Tcl_Interp *interp, struct input *i); +static void free_keymap(struct keymap *km); +static void free_output(Tcl_Interp *interp, struct output *o); +static void free_action(struct action *a); +static struct action *new_action(struct action **base); +static int inter_eval( + Tcl_Interp *interp, + struct action *action, + ExpState *esPtr); /* intMatch() accepts user keystrokes and returns one of MATCH, CANMATCH, or CANTMATCH. These describe whether the keystrokes match a @@ -187,13 +190,13 @@ */ static int -intMatch(esPtr,keymap,km_match,matchLen,skip,info) - ExpState *esPtr; - struct keymap *keymap; /* linked list of keymaps */ - struct keymap **km_match; /* keymap that matches or can match */ - int *matchLen; /* # of bytes that matched */ - int *skip; /* # of chars to skip */ - Tcl_RegExpInfo *info; +intMatch( + ExpState *esPtr, + struct keymap *keymap, /* linked list of keymaps */ + struct keymap **km_match, /* keymap that matches or can match */ + int *matchLen, /* # of bytes that matched */ + int *skip, /* # of chars to skip */ + Tcl_RegExpInfo *info) { Tcl_UniChar *string; struct keymap *km; @@ -344,12 +347,12 @@ /* put regexp result in variables */ static void -intRegExpMatchProcess(interp,esPtr,km,info,offset) - Tcl_Interp *interp; - ExpState *esPtr; - struct keymap *km; /* ptr for above while parsing */ - Tcl_RegExpInfo *info; - int offset; +intRegExpMatchProcess( + Tcl_Interp *interp, + ExpState *esPtr, + struct keymap *km, /* ptr for above while parsing */ + Tcl_RegExpInfo *info, + int offset) { char name[20], value[20]; int i; @@ -390,10 +393,10 @@ * echo chars */ static void -intEcho(esPtr,skipBytes,matchBytes) - ExpState *esPtr; - int skipBytes; - int matchBytes; +intEcho( + ExpState *esPtr, + int skipBytes, + int matchBytes) { int seenBytes; /* either printed or echoed */ int echoBytes; @@ -421,12 +424,12 @@ * Returns # of bytes read or negative number (EXP_XXX) indicating unusual event. */ static int -intRead(interp,esPtr,warnOnBufferFull,interruptible,key) - Tcl_Interp *interp; - ExpState *esPtr; - int warnOnBufferFull; - int interruptible; - int key; +intRead( + Tcl_Interp *interp, + ExpState *esPtr, + int warnOnBufferFull, + int interruptible, + int key) { Tcl_UniChar *eobOld; /* old end of buffer */ int cc; @@ -549,11 +552,11 @@ * process or the child (surrogate). */ static int -intIRead(channel,obj,size,flags); -Tcl_Channel channel; -Tcl_Obj *obj; -int size; -int flags; +intIRead( + Tcl_Channel channel, + Tcl_Obj *obj, + int size, + int flags) { int cc = EXP_CHILD_EOF; @@ -578,9 +581,9 @@ #define SPAWNED_PROCESS_DIED -3 static void -clean_up_after_child(interp,esPtr) -Tcl_Interp *interp; -ExpState *esPtr; +clean_up_after_child( + Tcl_Interp *interp, + ExpState *esPtr) { expWaitOnOne(); /* wait for slave */ expWaitOnOne(); /* wait for child */ @@ -593,16 +596,15 @@ #endif /*SIMPLE_EVENT*/ static int -update_interact_fds(interp,esPtrCount,esPtrToInput,esPtrs,input_base, - do_indirect,config_count,real_tty_caller) -Tcl_Interp *interp; -int *esPtrCount; -Tcl_HashTable **esPtrToInput; /* map from ExpStates to "struct inputs" */ -ExpState ***esPtrs; -struct input *input_base; -int do_indirect; /* if true do indirects */ -int *config_count; -int *real_tty_caller; +update_interact_fds( + Tcl_Interp *interp, + int *esPtrCount, + Tcl_HashTable **esPtrToInput, /* map from ExpStates to "struct inputs" */ + ExpState ***esPtrs, + struct input *input_base, + int do_indirect, /* if true do indirects */ + int *config_count, + int *real_tty_caller) { struct input *inp; struct output *outp; @@ -686,12 +688,12 @@ /*ARGSUSED*/ static char * -inter_updateproc(clientData, interp, name1, name2, flags) -ClientData clientData; -Tcl_Interp *interp; /* Interpreter containing variable. */ -char *name1; /* Name of variable. */ -char *name2; /* Second part of variable name. */ -int flags; /* Information about what happened. */ +inter_updateproc( + ClientData clientData, + Tcl_Interp *interp, /* Interpreter containing variable. */ + char *name1, /* Name of variable. */ + char *name2, /* Second part of variable name. */ + int flags) /* Information about what happened. */ { exp_configure_count++; return 0; @@ -704,15 +706,16 @@ /*ARGSUSED*/ int -Exp_InteractObjCmd(clientData, interp, objc, objv) -ClientData clientData; -Tcl_Interp *interp; -int objc; -Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_InteractObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST initial_objv[]) /* Argument objects. */ { ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); Tcl_Obj *CONST *objv_copy; /* original, for error messages */ + Tcl_Obj **objv = (Tcl_Obj **) initial_objv; char *string; Tcl_UniChar *ustring; @@ -2146,10 +2149,10 @@ /* version of Tcl_Eval for interact */ static int -inter_eval(interp,action,esPtr) -Tcl_Interp *interp; -struct action *action; -ExpState *esPtr; +inter_eval( + Tcl_Interp *interp, + struct action *action, + ExpState *esPtr) { int status; @@ -2168,8 +2171,7 @@ } static void -free_keymap(km) -struct keymap *km; +free_keymap(struct keymap *km) { if (km == 0) return; free_keymap(km->next); @@ -2178,8 +2180,7 @@ } static void -free_action(a) -struct action *a; +free_action(struct action *a) { struct action *next; @@ -2191,9 +2192,9 @@ } static void -free_input(interp,i) -Tcl_Interp *interp; -struct input *i; +free_input( + Tcl_Interp *interp, + struct input *i) { if (i == 0) return; free_input(interp,i->next); @@ -2205,8 +2206,7 @@ } static struct action * -new_action(base) -struct action **base; +new_action(struct action **base) { struct action *o = new(struct action); @@ -2218,9 +2218,9 @@ } static void -free_output(interp,o) -Tcl_Interp *interp; -struct output *o; +free_output( + Tcl_Interp *interp, + struct output *o) { if (o == 0) return; free_output(interp,o->next); @@ -2235,8 +2235,7 @@ {0}}; void -exp_init_interact_cmds(interp) -Tcl_Interp *interp; +exp_init_interact_cmds(Tcl_Interp *interp) { ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); --- exp_main_exp.c +++ exp_main_exp.c @@ -14,6 +14,7 @@ #include #include "tcl.h" #include "expect_tcl.h" +#include int main(argc, argv) --- exp_main_sub.c +++ exp_main_sub.c @@ -471,6 +471,7 @@ Tcl_Eval(interp, buffer); } /*NOTREACHED*/ + return(TCL_ERROR); } static char init_auto_path[] = "\ --- exp_pty.h +++ exp_pty.h @@ -8,10 +8,12 @@ */ -int exp_pty_test_start(); -void exp_pty_test_end(); -int exp_pty_test(); -void exp_pty_unlock(); -int exp_pty_lock(); +int exp_pty_test_start(void); +void exp_pty_test_end(void); +int exp_pty_test(char *master_name, char *slave_name, char bank, char *num); +void exp_pty_unlock(void); +int exp_pty_lock(char bank, char *num); +int exp_getptymaster(void); +int exp_getptyslave(int ttycopy, int ttyinit, CONST char *stty_args); extern char *exp_pty_slave_name; --- exp_strf.c +++ exp_strf.c @@ -148,7 +148,7 @@ void /*size_t*/ #ifndef __STDC__ -exp_strftime(/*s,*/ format, timeptr, dstring) +exp_strftime( /*char *s;*/ char *format; const struct tm *timeptr; --- exp_trap.c +++ exp_trap.c @@ -12,6 +12,7 @@ #include #include +#include #include #ifdef HAVE_SYS_WAIT_H --- exp_tty.c +++ exp_tty.c @@ -50,21 +50,20 @@ #define tty_cooked exp_tty_cooked int -exp_israw() +exp_israw(void) { return is_raw; } int -exp_isecho() +exp_isecho(void) { return !is_noecho; } /* if set == 1, set it to raw, else unset it */ void -exp_tty_raw(set) -int set; +exp_tty_raw(int set) { if (set == 1) { is_raw = TRUE; @@ -95,8 +94,7 @@ } void -exp_tty_echo(set) -int set; +exp_tty_echo(int set) { if (set == 1) { is_noecho = FALSE; @@ -114,8 +112,7 @@ } int -exp_tty_set_simple(tty) -exp_tty *tty; +exp_tty_set_simple(exp_tty *tty) { #ifdef HAVE_TCSETATTR return(tcsetattr(exp_dev_tty, TCSADRAIN,tty)); @@ -125,8 +122,7 @@ } int -exp_tty_get_simple(tty) -exp_tty *tty; +exp_tty_get_simple(exp_tty *tty) { #ifdef HAVE_TCSETATTR return(tcgetattr(exp_dev_tty, tty)); @@ -138,10 +134,11 @@ /* returns 0 if nothing changed */ /* if something changed, the out parameters are changed as well */ int -exp_tty_raw_noecho(interp,tty_old,was_raw,was_echo) -Tcl_Interp *interp; -exp_tty *tty_old; -int *was_raw, *was_echo; +exp_tty_raw_noecho( + Tcl_Interp *interp, + exp_tty *tty_old, + int *was_raw, + int *was_echo) { if (exp_disconnected) return(0); if (is_raw && is_noecho) return(0); @@ -173,10 +170,11 @@ /* returns 0 if nothing changed */ /* if something changed, the out parameters are changed as well */ int -exp_tty_cooked_echo(interp,tty_old,was_raw,was_echo) -Tcl_Interp *interp; -exp_tty *tty_old; -int *was_raw, *was_echo; +exp_tty_cooked_echo( + Tcl_Interp *interp, + exp_tty *tty_old, + int *was_raw, + int *was_echo) { if (exp_disconnected) return(0); if (!is_raw && !is_noecho) return(0); @@ -206,11 +204,11 @@ } void -exp_tty_set(interp,tty,raw,echo) -Tcl_Interp *interp; -exp_tty *tty; -int raw; -int echo; +exp_tty_set( + Tcl_Interp *interp, + exp_tty *tty, + int raw, + int echo) { if (exp_tty_set_simple(tty) == -1) { expErrorLog("ioctl(set): %s\r\n",Tcl_PosixError(interp)); @@ -258,9 +256,9 @@ /*ARGSUSED*/ void -exp_tty_break(interp,fd) -Tcl_Interp *interp; -int fd; +exp_tty_break( + Tcl_Interp *interp, + int fd) { #ifdef POSIX tcsendbreak(fd,0); @@ -280,9 +278,9 @@ /* If len == 0, use strlen to compute it */ /* NB: if terminal is not in raw mode, nothing is done. */ char * -exp_cook(s,len) -char *s; -int *len; /* current and new length of s */ +exp_cook( + char *s, + int *len) /* current and new length of s */ { static int destlen = 0; static char *dest = 0; @@ -315,11 +313,11 @@ } static int /* returns TCL_whatever */ -exec_stty(interp,argc,argv,devtty) -Tcl_Interp *interp; -int argc; -char **argv; -int devtty; /* if true, redirect to /dev/tty */ +exec_stty( + Tcl_Interp *interp, + int argc, + char **argv, + int devtty) /* if true, redirect to /dev/tty */ { int i; int rc; @@ -368,11 +366,11 @@ /*ARGSUSED*/ static int -Exp_SttyCmd(clientData, interp, argc, argv) -ClientData clientData; -Tcl_Interp *interp; -int argc; -char **argv; +Exp_SttyCmd( + ClientData clientData, + Tcl_Interp *interp, + int argc, + char **argv) { /* redirection symbol is not counted as a stty arg in terms */ /* of recognition. */ @@ -567,11 +565,11 @@ /*ARGSUSED*/ static int -Exp_SystemCmd(clientData, interp, argc, argv) -ClientData clientData; -Tcl_Interp *interp; -int argc; -char **argv; +Exp_SystemCmd( + ClientData clientData, + Tcl_Interp *interp, + int argc, + char **argv) { int result = TCL_OK; RETSIGTYPE (*old)(); /* save old sigalarm handler */ @@ -799,8 +797,7 @@ {0}}; void -exp_init_tty_cmds(interp) -struct Tcl_Interp *interp; +exp_init_tty_cmds(struct Tcl_Interp *interp) { exp_create_commands(interp,cmd_data); } --- exp_tty.h +++ exp_tty.h @@ -15,15 +15,15 @@ extern int exp_stdin_is_tty; extern int exp_stdout_is_tty; -void exp_tty_raw(); -void exp_tty_echo(); -void exp_tty_break(); -int exp_tty_raw_noecho(); -int exp_israw(); -int exp_isecho(); +void exp_tty_raw(int set); +void exp_tty_echo(int set); +void exp_tty_break(Tcl_Interp *interp, int fd); +int exp_tty_raw_noecho(Tcl_Interp *interp, exp_tty *tty_old, int *was_raw, int *was_echo); +int exp_israw(void); +int exp_isecho(void); -void exp_tty_set(); -int exp_tty_set_simple(); -int exp_tty_get_simple(); +void exp_tty_set(Tcl_Interp *interp, exp_tty *tty, int raw, int echo); +int exp_tty_set_simple(exp_tty *tty); +int exp_tty_get_simple(exp_tty *tty); #endif /* __EXP_TTY_H__ */ --- exp_win.c +++ exp_win.c @@ -51,7 +51,7 @@ # include #endif /* HAVE_SYS_PTEM_H */ -#include "exp_tty.h" +#include "exp_tty_in.h" #include "exp_win.h" #ifdef TIOCGWINSZ @@ -87,6 +87,7 @@ #if defined(TIOCSSIZE) && !defined(TIOCSWINSZ) ioctl(fd,TIOCSSIZE,&winsize); #endif + return 0; } int exp_window_size_get(fd) @@ -102,6 +103,7 @@ winsize.rows = 0; winsize.columns = 0; #endif + return 0; } void @@ -151,6 +153,7 @@ #if defined(TIOCSSIZE) && !defined(TIOCSWINSZ) ioctl(fd,TIOCSSIZE,&win2size); #endif + return 0; } int exp_win2_size_get(fd) @@ -162,6 +165,7 @@ #if defined(TIOCGSIZE) && !defined(TIOCGWINSZ) ioctl(fd,TIOCGSIZE,&win2size); #endif + return 0; } void --- expect.c +++ expect.c @@ -34,7 +34,7 @@ #include "exp_command.h" #include "exp_log.h" #include "exp_event.h" -#include "exp_tty.h" +#include "exp_tty_in.h" #include "exp_tstamp.h" /* this should disappear when interact */ /* loses ref's to it */ #ifdef TCL_DEBUGGER @@ -134,10 +134,10 @@ */ static void -exp_cmd_init(cmd,cmdtype,duration) -struct exp_cmd_descriptor *cmd; -int duration; -int cmdtype; +exp_cmd_init( + struct exp_cmd_descriptor *cmd, + int cmdtype, + int duration) { cmd->duration = duration; cmd->cmdtype = cmdtype; @@ -156,14 +156,21 @@ void exp_background_channelhandlers_run_all(); /* exp_indirect_updateX is called by Tcl when an indirect variable is set */ -static char *exp_indirect_update1(); /* 1-part Tcl variable names */ -static char *exp_indirect_update2(); /* 2-part Tcl variable names */ +static char *exp_indirect_update1( /* 1-part Tcl variable names */ + Tcl_Interp *interp, + struct exp_cmd_descriptor *ecmd, + struct exp_i *exp_i); +static char *exp_indirect_update2( /* 2-part Tcl variable names */ + ClientData clientData, + Tcl_Interp *interp, /* Interpreter containing variable. */ + char *name1, /* Name of variable. */ + char *name2, /* Second part of variable name. */ + int flags); /* Information about what happened. */ #ifdef SIMPLE_EVENT /*ARGSUSED*/ static RETSIGTYPE -sigalarm_handler(n) -int n; /* unused, for compatibility with STDC */ +sigalarm_handler(int n) /* unused, for compatibility with STDC */ { alarm_fired = TRUE; } @@ -171,10 +178,10 @@ /* free up everything in ecase */ static void -free_ecase(interp,ec,free_ilist) -Tcl_Interp *interp; -struct ecase *ec; -int free_ilist; /* if we should free ilist */ +free_ecase( + Tcl_Interp *interp, + struct ecase *ec, + int free_ilist) /* if we should free ilist */ { if (ec->i_list->duration == EXP_PERMANENT) { if (ec->pat) { Tcl_DecrRefCount(ec->pat); } @@ -194,10 +201,10 @@ /* free up any argv structures in the ecases */ static void -free_ecases(interp,eg,free_ilist) -Tcl_Interp *interp; -struct exp_cmd_descriptor *eg; -int free_ilist; /* if true, free ilists */ +free_ecases( + Tcl_Interp *interp, + struct exp_cmd_descriptor *eg, + int free_ilist) /* if true, free ilists */ { int i; @@ -216,8 +223,7 @@ #if 0 /* no standard defn for this, and some systems don't even have it, so avoid */ /* the whole quagmire by calling it something else */ -static char *exp_strdup(s) -char *s; +static char *exp_strdup(char *s) { char *news = ckalloc(strlen(s) + 1); strcpy(news,s); @@ -242,8 +248,7 @@ Current test is very cheap and almost always right :-) */ int -exp_one_arg_braced(objPtr) /* INTL */ -Tcl_Obj *objPtr; +exp_one_arg_braced(Tcl_Obj *objPtr) /* INTL */ { int seen_nl = FALSE; char *p = Tcl_GetString(objPtr); @@ -268,10 +273,10 @@ * its current argumnts */ /*ARGSUSED*/ Tcl_Obj* -exp_eval_with_one_arg(clientData,interp,objv) /* INTL */ -ClientData clientData; -Tcl_Interp *interp; -Tcl_Obj *CONST objv[]; /* Argument objects. */ +exp_eval_with_one_arg( + ClientData clientData, + Tcl_Interp *interp, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { Tcl_Obj* res = Tcl_NewListObj (1,objv); @@ -348,8 +353,7 @@ } static void -ecase_clear(ec) -struct ecase *ec; +ecase_clear(struct ecase *ec) { ec->i_list = 0; ec->pat = 0; @@ -365,7 +369,7 @@ } static struct ecase * -ecase_new() +ecase_new(void) { struct ecase *ec = (struct ecase *)ckalloc(sizeof(struct ecase)); @@ -400,12 +404,12 @@ */ static int -parse_expect_args(interp,eg,default_esPtr,objc,objv) -Tcl_Interp *interp; -struct exp_cmd_descriptor *eg; -ExpState *default_esPtr; /* suggested ExpState if called as expect_user or _tty */ -int objc; -Tcl_Obj *CONST objv[]; /* Argument objects. */ +parse_expect_args( + Tcl_Interp *interp, + struct exp_cmd_descriptor *eg, + ExpState *default_esPtr, /* suggested ExpState if called as expect_user or _tty */ + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { int i; char *string; @@ -718,9 +722,9 @@ */ Tcl_UniChar * -string_case_first(string,pattern) /* INTL */ - register Tcl_UniChar *string; /* String (unicode). */ - register char *pattern; /* Pattern, which may contain +string_case_first( /* INTL */ + register Tcl_UniChar *string, /* String (unicode). */ + register char *pattern) /* Pattern, which may contain * special characters (utf8). */ { Tcl_UniChar *s; @@ -748,9 +752,9 @@ } Tcl_UniChar * -string_first(string,pattern) /* INTL */ - register Tcl_UniChar *string; /* String (unicode). */ - register char *pattern; /* Pattern, which may contain +string_first( /* INTL */ + register Tcl_UniChar *string, /* String (unicode). */ + register char *pattern) /* Pattern, which may contain * special characters (utf8). */ { Tcl_UniChar *s; @@ -778,9 +782,9 @@ } Tcl_UniChar * -string_first_char(string,pattern) /* INTL */ - register Tcl_UniChar *string; /* String. */ - register Tcl_UniChar pattern; +string_first_char( /* INTL */ + register Tcl_UniChar *string, /* String. */ + register Tcl_UniChar pattern) { /* unicode based Tcl_UtfFindFirst */ @@ -803,15 +807,15 @@ /* string match */ /* returns EXP_X where X is MATCH, NOMATCH, FULLBUFFER, TCLERRROR */ static int -eval_case_string(interp,e,esPtr,o,last_esPtr,last_case,suffix) -Tcl_Interp *interp; -struct ecase *e; -ExpState *esPtr; -struct eval_out *o; /* 'output' - i.e., final case of interest */ +eval_case_string( + Tcl_Interp *interp, + struct ecase *e, + ExpState *esPtr, + struct eval_out *o, /* 'output' - i.e., final case of interest */ /* next two args are for debugging, when they change, reprint buffer */ -ExpState **last_esPtr; -int *last_case; -char *suffix; + ExpState **last_esPtr, + int *last_case, + char *suffix) { Tcl_RegExp re; Tcl_RegExpInfo info; @@ -977,18 +981,18 @@ /* sets o.e if successfully finds a matching pattern, eof, timeout or deflt */ /* returns original status arg or EXP_TCLERROR */ static int -eval_cases(interp,eg,esPtr,o,last_esPtr,last_case,status,esPtrs,mcount,suffix) -Tcl_Interp *interp; -struct exp_cmd_descriptor *eg; -ExpState *esPtr; -struct eval_out *o; /* 'output' - i.e., final case of interest */ +eval_cases( + Tcl_Interp *interp, + struct exp_cmd_descriptor *eg, + ExpState *esPtr, + struct eval_out *o, /* 'output' - i.e., final case of interest */ /* next two args are for debugging, when they change, reprint buffer */ -ExpState **last_esPtr; -int *last_case; -int status; -ExpState *(esPtrs[]); -int mcount; -char *suffix; + ExpState **last_esPtr, + int *last_case, + int status, + ExpState *(esPtrs[]), + int mcount, + char *suffix) { int i; ExpState *em; /* ExpState of ecase */ @@ -1061,10 +1065,10 @@ } static void -ecases_remove_by_expi(interp,ecmd,exp_i) -Tcl_Interp *interp; -struct exp_cmd_descriptor *ecmd; -struct exp_i *exp_i; +ecases_remove_by_expi( + Tcl_Interp *interp, + struct exp_cmd_descriptor *ecmd, + struct exp_i *exp_i) { int i; @@ -1095,10 +1099,10 @@ /* remove exp_i from list */ static void -exp_i_remove(interp,ei,exp_i) -Tcl_Interp *interp; -struct exp_i **ei; /* list to remove from */ -struct exp_i *exp_i; /* element to remove */ +exp_i_remove( + Tcl_Interp *interp, + struct exp_i **ei, /* list to remove from */ + struct exp_i *exp_i) /* element to remove */ { /* since it's in middle of list, free exp_i by hand */ for (;*ei; ei = &(*ei)->next) { @@ -1113,10 +1117,10 @@ /* remove exp_i from list and remove any dependent ecases */ static void -exp_i_remove_with_ecases(interp,ecmd,exp_i) -Tcl_Interp *interp; -struct exp_cmd_descriptor *ecmd; -struct exp_i *exp_i; +exp_i_remove_with_ecases( + Tcl_Interp *interp, + struct exp_cmd_descriptor *ecmd, + struct exp_i *exp_i) { ecases_remove_by_expi(interp,ecmd,exp_i); exp_i_remove(interp,&ecmd->i_list,exp_i); @@ -1124,11 +1128,11 @@ /* remove ecases tied to a single direct spawn id */ static void -ecmd_remove_state(interp,ecmd,esPtr,direct) -Tcl_Interp *interp; -struct exp_cmd_descriptor *ecmd; -ExpState *esPtr; -int direct; +ecmd_remove_state( + Tcl_Interp *interp, + struct exp_cmd_descriptor *ecmd, + ExpState *esPtr, + int direct) { struct exp_i *exp_i, *next; struct exp_state_list **slPtr; @@ -1168,9 +1172,9 @@ /* this is called from exp_close to clean up the ExpState */ void -exp_ecmd_remove_state_direct_and_indirect(interp,esPtr) -Tcl_Interp *interp; -ExpState *esPtr; +exp_ecmd_remove_state_direct_and_indirect( + Tcl_Interp *interp, + ExpState *esPtr) { ecmd_remove_state(interp,&exp_cmds[EXP_CMD_BEFORE],esPtr,EXP_DIRECT|EXP_INDIRECT); ecmd_remove_state(interp,&exp_cmds[EXP_CMD_AFTER],esPtr,EXP_DIRECT|EXP_INDIRECT); @@ -1182,9 +1186,9 @@ /* arm a list of background ExpState's */ static void -state_list_arm(interp,slPtr) -Tcl_Interp *interp; -struct exp_state_list *slPtr; +state_list_arm( + Tcl_Interp *interp, + struct exp_state_list *slPtr) { /* for each spawn id in list, arm if necessary */ for (;slPtr;slPtr=slPtr->next) { @@ -1201,9 +1205,9 @@ /* return TRUE if this ecase is used by this fd */ static int -exp_i_uses_state(exp_i,esPtr) -struct exp_i *exp_i; -ExpState *esPtr; +exp_i_uses_state( + struct exp_i *exp_i, + ExpState *esPtr) { struct exp_state_list *fdp; @@ -1214,9 +1218,9 @@ } static void -ecase_append(interp,ec) -Tcl_Interp *interp; -struct ecase *ec; +ecase_append( + Tcl_Interp *interp, + struct ecase *ec) { if (!ec->transfer) Tcl_AppendElement(interp,"-notransfer"); if (ec->indices) Tcl_AppendElement(interp,"-indices"); @@ -1231,10 +1235,10 @@ /* append all ecases that match this exp_i */ static void -ecase_by_exp_i_append(interp,ecmd,exp_i) -Tcl_Interp *interp; -struct exp_cmd_descriptor *ecmd; -struct exp_i *exp_i; +ecase_by_exp_i_append( + Tcl_Interp *interp, + struct exp_cmd_descriptor *ecmd, + struct exp_i *exp_i) { int i; for (i=0;iecd.count;i++) { @@ -1245,9 +1249,9 @@ } static void -exp_i_append(interp,exp_i) -Tcl_Interp *interp; -struct exp_i *exp_i; +exp_i_append( + Tcl_Interp *interp, + struct exp_i *exp_i) { Tcl_AppendElement(interp,"-i"); if (exp_i->direct == EXP_INDIRECT) { @@ -1261,8 +1265,8 @@ } for (fdp = exp_i->state_list;fdp;fdp=fdp->next) { - char buf[10]; /* big enough for a small int */ - sprintf(buf,"%d",fdp->esPtr); + char buf[25]; /* big enough for a small int */ + sprintf(buf,"%ld", (long)fdp->esPtr); Tcl_AppendElement(interp,buf); } @@ -1274,11 +1278,11 @@ /* return current setting of the permanent expect_before/after/bg */ int -expect_info(interp,ecmd,objc,objv) -Tcl_Interp *interp; -struct exp_cmd_descriptor *ecmd; -int objc; -Tcl_Obj *CONST objv[]; /* Argument objects. */ +expect_info( + Tcl_Interp *interp, + struct exp_cmd_descriptor *ecmd, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { struct exp_i *exp_i; int i; @@ -1362,11 +1366,11 @@ /* Exp_ExpectGlobalObjCmd is invoked to process expect_before/after/background */ /*ARGSUSED*/ int -Exp_ExpectGlobalObjCmd(clientData, interp, objc, objv) -ClientData clientData; -Tcl_Interp *interp; -int objc; -Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_ExpectGlobalObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { int result = TCL_OK; struct exp_i *exp_i, **eip; @@ -1574,8 +1578,7 @@ /* adjusts file according to user's size request */ void -expAdjust(esPtr) -ExpState *esPtr; +expAdjust(ExpState *esPtr) { int new_msize, excess; Tcl_UniChar *string; @@ -1632,9 +1635,9 @@ #if OBSOLETE /* Strip parity */ static void -expParityStrip(obj,offsetBytes) - Tcl_Obj *obj; - int offsetBytes; +expParityStrip( + Tcl_Obj *obj, + int offsetBytes) { char *p, ch; @@ -1659,9 +1662,9 @@ be at a UTF boundary. */ static void -expValid(obj,offset) - Tcl_Obj *obj; - int offset; +expValid( + Tcl_Obj *obj, + int offset) { char *s, *end; int len; @@ -1709,9 +1712,9 @@ /* Strip nulls from object, beginning at offset */ static int -expNullStrip(buf,offsetChars) - ExpUniBuf* buf; - int offsetChars; +expNullStrip( + ExpUniBuf* buf, + int offsetChars) { Tcl_UniChar *src, *src2, *dest, *end; int newsize; /* size of obj after all nulls removed */ @@ -1737,11 +1740,11 @@ /* the read will complete immediately. */ /*ARGSUSED*/ static int -expIRead(interp,esPtr,timeout,save_flags) /* INTL */ -Tcl_Interp *interp; -ExpState *esPtr; -int timeout; -int save_flags; +expIRead( /* INTL */ + Tcl_Interp *interp, + ExpState *esPtr, + int timeout, + int save_flags) { int cc = EXP_TIMEOUT; int size; @@ -1812,13 +1815,13 @@ /* if it returns a non-negative number, it means there is data */ /* (0 means nothing new was actually read, but it should be looked at again) */ int -expRead(interp,esPtrs,esPtrsMax,esPtrOut,timeout,key) -Tcl_Interp *interp; -ExpState *(esPtrs[]); /* If 0, then esPtrOut already known and set */ -int esPtrsMax; /* number of esPtrs */ -ExpState **esPtrOut; /* Out variable to leave new ExpState. */ -int timeout; -int key; +expRead( + Tcl_Interp *interp, + ExpState *(esPtrs[]), /* If 0, then esPtrOut already known and set */ + int esPtrsMax, /* number of esPtrs */ + ExpState **esPtrOut, /* Out variable to leave new ExpState. */ + int timeout, + int key) { ExpState *esPtr; @@ -1920,12 +1923,12 @@ /* when buffer fills, copy second half over first and */ /* continue, so we can do matches over multiple buffers */ void -exp_buffer_shuffle(interp,esPtr,save_flags,array_name,caller_name) /* INTL */ -Tcl_Interp *interp; -ExpState *esPtr; -int save_flags; -char *array_name; -char *caller_name; +exp_buffer_shuffle( /* INTL */ + Tcl_Interp *interp, + ExpState *esPtr, + int save_flags, + char *array_name, + char *caller_name) { Tcl_UniChar *str; Tcl_UniChar *p; @@ -1989,8 +1992,7 @@ /* map EXP_ style return value to TCL_ style return value */ /* not defined to work on TCL_OK */ int -exp_tcl2_returnvalue(x) -int x; +exp_tcl2_returnvalue(int x) { switch (x) { case TCL_ERROR: return EXP_TCLERROR; @@ -2009,8 +2011,7 @@ /* map from EXP_ style return value to TCL_ style return values */ int -exp_2tcl_returnvalue(x) -int x; +exp_2tcl_returnvalue(int x) { switch (x) { case EXP_TCLERROR: return TCL_ERROR; @@ -2033,9 +2034,9 @@ avoid having to put "global" in procedure definitions. */ char * -exp_get_var(interp,var) -Tcl_Interp *interp; -char *var; +exp_get_var( + Tcl_Interp *interp, + char *var) { char *val; @@ -2045,8 +2046,7 @@ } static int -get_timeout(interp) -Tcl_Interp *interp; +get_timeout(Tcl_Interp *interp) { ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); CONST char *t; @@ -2060,9 +2060,9 @@ /* make a copy of a linked list (1st arg) and attach to end of another (2nd arg) */ static int -update_expect_states(i_list,i_union) -struct exp_i *i_list; -struct exp_state_list **i_union; +update_expect_states( + struct exp_i *i_list, + struct exp_state_list **i_union) { struct exp_i *p; @@ -2092,8 +2092,7 @@ } char * -exp_cmdtype_printable(cmdtype) -int cmdtype; +exp_cmdtype_printable(int cmdtype) { switch (cmdtype) { case EXP_CMD_FG: return("expect"); @@ -2110,12 +2109,12 @@ /* an indirect spawn id list is changed */ /*ARGSUSED*/ static char * -exp_indirect_update2(clientData, interp, name1, name2, flags) -ClientData clientData; -Tcl_Interp *interp; /* Interpreter containing variable. */ -char *name1; /* Name of variable. */ -char *name2; /* Second part of variable name. */ -int flags; /* Information about what happened. */ +exp_indirect_update2( + ClientData clientData, + Tcl_Interp *interp, /* Interpreter containing variable. */ + char *name1, /* Name of variable. */ + char *name2, /* Second part of variable name. */ + int flags) /* Information about what happened. */ { char *msg; @@ -2129,10 +2128,10 @@ } static char * -exp_indirect_update1(interp,ecmd,exp_i) -Tcl_Interp *interp; -struct exp_cmd_descriptor *ecmd; -struct exp_i *exp_i; +exp_indirect_update1( + Tcl_Interp *interp, + struct exp_cmd_descriptor *ecmd, + struct exp_i *exp_i) { struct exp_state_list *slPtr; /* temp for interating over state_list */ @@ -2205,13 +2204,13 @@ } int -expMatchProcess(interp, eo, cc, bg, detail) - Tcl_Interp *interp; - struct eval_out *eo; /* final case of interest */ - int cc; /* EOF, TIMEOUT, etc... */ - int bg; /* 1 if called from background handler, */ +expMatchProcess( + Tcl_Interp *interp, + struct eval_out *eo, /* final case of interest */ + int cc, /* EOF, TIMEOUT, etc... */ + int bg, /* 1 if called from background handler, */ /* else 0 */ - char *detail; + char *detail) { ExpState *esPtr = 0; Tcl_Obj *body = 0; @@ -2385,9 +2384,9 @@ /* this function is called from the background when input arrives */ /*ARGSUSED*/ void -exp_background_channelhandler(clientData,mask) /* INTL */ -ClientData clientData; -int mask; +exp_background_channelhandler( /* INTL */ + ClientData clientData, + int mask) { char backup[EXP_CHANNELNAMELEN+1]; /* backup copy of esPtr channel name! */ @@ -2510,11 +2509,11 @@ /*ARGSUSED*/ int -Exp_ExpectObjCmd(clientData, interp, objc, objv) -ClientData clientData; -Tcl_Interp *interp; -int objc; -Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_ExpectObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { int cc; /* number of chars returned in a single read */ /* or negative EXP_whatever */ @@ -2767,11 +2766,11 @@ /*ARGSUSED*/ static int -Exp_TimestampObjCmd(clientData, interp, objc, objv) -ClientData clientData; -Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_TimestampObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { char *format = 0; time_t seconds = -1; @@ -2866,14 +2865,14 @@ CONST char* cmd)); static int -process_di (interp,objc,objv,at,Default,esOut,cmd) -Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ - int* at; - int* Default; - CONST char* cmd; - ExpState **esOut; +process_di ( + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[], /* Argument objects. */ + int* at, + int* Default, + ExpState **esOut, + CONST char* cmd) { static char* options[] = { "-d", @@ -2947,11 +2946,11 @@ /*ARGSUSED*/ int -Exp_MatchMaxObjCmd(clientData,interp,objc,objv) - ClientData clientData; - Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_MatchMaxObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { int size = -1; ExpState *esPtr = 0; @@ -2993,11 +2992,11 @@ /*ARGSUSED*/ int -Exp_RemoveNullsObjCmd(clientData,interp,objc,objv) -ClientData clientData; -Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_RemoveNullsObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { int value = -1; ExpState *esPtr = 0; @@ -3037,11 +3036,11 @@ /*ARGSUSED*/ int -Exp_ParityObjCmd(clientData,interp,objc,objv) -ClientData clientData; -Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_ParityObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { int parity; ExpState *esPtr = 0; @@ -3076,11 +3075,11 @@ /*ARGSUSED*/ int -Exp_CloseOnEofObjCmd(clientData,interp,objc,objv) -ClientData clientData; -Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +Exp_CloseOnEofObjCmd( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { int close_on_eof; ExpState *esPtr = 0; @@ -3117,8 +3116,7 @@ /* This big chunk of code is just for debugging the permanent */ /* expect cases */ void -exp_fd_print(slPtr) -struct exp_state_list *slPtr; +exp_fd_print(struct exp_state_list *slPtr) { if (!slPtr) return; printf("%d ",slPtr->esPtr); @@ -3126,8 +3124,7 @@ } void -exp_i_print(exp_i) -struct exp_i *exp_i; +exp_i_print(struct exp_i *exp_i) { if (!exp_i) return; printf("exp_i %x",exp_i); @@ -3143,16 +3140,14 @@ } void -exp_ecase_print(ecase) -struct ecase *ecase; +exp_ecase_print(struct ecase *ecase) { printf("pat <%s>\n",ecase->pat); printf("exp_i = %x\n",ecase->i_list); } void -exp_ecases_print(ecd) -struct exp_cases_descriptor *ecd; +exp_ecases_print(struct exp_cases_descriptor *ecd) { int i; @@ -3161,8 +3156,7 @@ } void -exp_cmd_print(ecmd) -struct exp_cmd_descriptor *ecmd; +exp_cmd_print(struct exp_cmd_descriptor *ecmd) { printf("expect cmd type: %17s",exp_cmdtype_printable(ecmd->cmdtype)); printf((ecmd->duration==EXP_PERMANENT)?" perm ": "tmp "); @@ -3172,7 +3166,7 @@ } void -exp_cmds_print() +exp_cmds_print(void) { exp_cmd_print(&exp_cmds[EXP_CMD_BEFORE]); exp_cmd_print(&exp_cmds[EXP_CMD_AFTER]); @@ -3181,11 +3175,11 @@ /*ARGSUSED*/ int -cmdX(clientData, interp, objc, objv) -ClientData clientData; -Tcl_Interp *interp; - int objc; - Tcl_Obj *CONST objv[]; /* Argument objects. */ +cmdX( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[]) /* Argument objects. */ { exp_cmds_print(); return TCL_OK; @@ -3193,7 +3187,7 @@ #endif /*DEBUG_PERM_ECASES*/ void -expExpectVarsInit() +expExpectVarsInit(void) { ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); @@ -3216,8 +3210,7 @@ {0}}; void -exp_init_expect_cmds(interp) -Tcl_Interp *interp; +exp_init_expect_cmds(Tcl_Interp *interp) { exp_create_commands(interp,cmd_data); @@ -3248,7 +3241,7 @@ } void -exp_init_sig() { +exp_init_sig(void) { #if 0 signal(SIGALRM,sigalarm_handler); signal(SIGINT,sigint_handler); --- pty_termios.c +++ pty_termios.c @@ -9,6 +9,7 @@ #include #include +#include #if defined(SIGCLD) && !defined(SIGCHLD) #define SIGCHLD SIGCLD @@ -627,10 +628,10 @@ } int -exp_getptyslave(ttycopy,ttyinit,stty_args) -int ttycopy; -int ttyinit; -char *stty_args; +exp_getptyslave( + int ttycopy, + int ttyinit, + CONST char *stty_args) { int slave, slave2; char buf[10240]; --- retoglob.c +++ retoglob.c @@ -44,9 +44,9 @@ Tcl_Obj* -exp_retoglob (str,strlen) - Tcl_UniChar* str; - int strlen; +exp_retoglob ( + Tcl_UniChar* str, + int strlen) { /* * Output: x2 size of input (literal where every character has to be