+++ /dev/null
-If you used to use Expect version 2 (any version written before
-September '91) you will find that the current version of Expect (3)
-introduced minor but significant incompatibilities.
-
-The HISTORY file describes these briefly. They are described at
-length in the man page.
-
-I'm sorry if you feel annoyed at the incompatibilities, but Expect has
-been out for a year and a half, Tcl even longer. Both Tcl and Expect
-are using this as a last chance to make significant changes, so that
-we will not disturb even more users in the future.
-
-There is no automated conversion procedure (although see note below)
-for Expect or even raw Tcl. For now, I suggest that you not bother
-fixing things that already work - just keep the old Expect around.
-The binary isn't very big after all. If you do write a translation
-script, let me know. Thanks.
-
-Of course, I felt obligated to convert the examples distributed with
-expect. I did this by hand while writing the new version itself,
-partly as an aid but mostly to test lots of variations. In 90% of the
-scripts, all I had to do was change:
-
-(changes due to Tcl)
- 'index' to 'lindex'
- 'range' to 'lrange'
- 'length' to 'llength'
- 'print' to 'send_user' or 'puts' depending on how you use it
- 'function .... c' with '[join [function [split string ""]] ""]'
-(changes due to Expect)
- 'expect_match' to 'expect_out(buffer)'
- 'set match_max' to 'match_max' (perhaps with -d flag)
- '*' to '-re .+'
-
-If anyone wants to write a script to do this, note the pitfalls:
-
-1) functions and variables do not share the same namespace, so it is a
-inappropriate to just globally rename things.
-
-A number of optimizations can be made:
-
-1) If you are doing multiple split/joins, you should probably cache the
-split string.
-
-2) Virtually all uses of scan are unnecessary now, due to exec's automatic
-stripping of terminating newlines, and expect's support of regexps.
-
-3) String manipulation can be reduced or avoided entirely if you use
-expect -re.
-
-4) exec is no longer necessary to retrieve environment variables, since
-they can now be retrieved from $env.
-
-5) If you have been really anal about testing for timeout and eof, you
-can dramatically reduce the size of your scripts by using expect_before
-and expect_after. This is more efficient, as well, since those actions
-are only parsed once.
-
+++ /dev/null
-This file describes the changes from Expect 3 to Expect 4.
-
-The improvements that people will find most interesting are:
-
-1) Expect version 4 is designed to work with Tcl 6.7 and Tk 3.2.
- (Earlier versions of Expect will not work with Tcl 6.7)
- Expect can now be layered in with any Tcl program.
- Note that in Tk, Expect's send command is called "exp_send".
- (It used to be called "send_spawn" but this bit the dust.)
-2) A debugger is provided.
-3) The interact command has been totally rewritten and supports regular
- expressions, timeout/eof patterns, and a number of other new things.
-4) The default behavior of ^C (SIGINT) is exit whether or not you are in
- a read.
-5) Expect uses "sane" terminal parameters by default, allowing scripts
- to work the same whether inside emacs shell mode or not. (See man
- page on "spawn" for more info.)
-6) All the hard parts of the installation process are automated. This
- was done primarily by Rob Savoye at Cygnus. Thank you, Rob!
-7) It is now possible to buy a support contract for Expect from Cygnus.
-
-The changes that people will find most annoying are:
-
-1) send now only sends a single string. (It used to send any number of
- strings with spaces jammed in between.)
-2) getpid was renamed pid.
-3) interact's -flush was renamed -nobuffer (much more descriptive).
-4) interact now runs all actions in raw mode unless the flag -reset
- is used. -f and -F are ignored. send automatically understands
- how to do the right thing. The most likely thing to watch out for
- are actions like "exec kill -STOP 0" which almost certainly need
- the -reset flag.
-5) argv0 is initialized to script name. argv no longer contains it.
- argc is initialized [llength $argv]. This follows new Tcl style.
-
-All differences are described in the man page. Some of the less
-significant differences are described in the HISTORY file. The
-debugger is described in a separate document (see the README).
-
-This version also introduces one incompatibility that may require
-changes to scripts. While this may initially annoy you, the final
-result will simplify the process of writing scripts. Namely:
-
-In version 3, the expect command accepted lists of glob-style patterns
-such as:
-
- expect "a\ b c" action
-
-where "a b" or "c" would cause action to be executed. The problem
-with this is that the pattern list is hard to write and hard to read.
-Patterns with control-characters, backslashes and dollar signs were
-very difficult to deal with.
-
-Regular-expression patterns provide a much simpler solution. Via the
-alternation feature (using a "|") the above pattern can be written as:
-
- expect -re "a b|c" action
-
-I was concerned about people having a significant investment in code
-that depended on the old syntax but responders to a comp.lang.tcl poll
-about such a change in pattern handling were 100% in favor of it. (I
-even proposed hooks for backward compatibility, but there was no
-interest in it.)
-
-Fortunately, most simple things will work as before including:
-
- expect foobar
- expect {foobar}
- expect "foobar"
- expect "foo\ bar"
-
-However, some things won't work as before. For example, the following
-will behave differently - now the braces will be considered as part of
-the pattern.
-
- expect "{foo bar}"
-
-Here are examples of patterns in my own code that I had to change:
-
- was changed to
- Version 3 pattern list Version 4 pattern
-
- {Whois:\ } "Whois: "
- {No\ match} "No match"
- {250*ftp>* 200*ftp>*} -re "2(5|0)0.*ftp>.*"
- {{Press Return to continue*}} "Press Return to continue*"
- {*\r\n*\\\\\r\n} "\r\n*\\\r\n"
-
-
-
-Future Change Alert
-
-John Ousterhout has pre-announced a future change in Tcl that may
-affect you. In particular, backslash sequences other than those
-explicitly listed in the Tcl documentation will be handled as if the
-backslash was not present.
-
-The likely place this arises is when quoting characters that are
-special to the pattern matcher but not to Tcl.
-
-For example in Tcl 6.7, the following command matches a period.
-
- expect -re "\."
-
-In Tcl 7.0, it will match any character, because Tcl will throw away
-the backslash. If you want to match a period, you will have to say:
-
- expect -re "\\."
-or
- expect -re {\.}
-
-The following command will find occurrences of this. (It may find
-other things, but it will at least find the problem cases.)
-
- egrep '(\\$)|(\\[^][bfnrtv\0-9{}$ ;"])' *.exp
+++ /dev/null
-This file describes the changes from Expect 4 to Expect 5.
-
-The changes that people will find most interesting or annoying are as
-follows. Some of them may seem rather arbitrary but fix inconsistencies
-leading to much cleaner coding both internally and externally.
-
-
--- Expect version 5.20 and above is designed to work with Tcl 7.5 and
-Tk 4.1. Expect 5.20 and above will not work with earlier versions.
-
--- Glob-style patterns do longest-possible matches (from the earliest
-possible position) just like regexps. Previously, they matched the
-shortest-possible strings. However, the documentation didn't actually
-say this (it didn't say anything)
-
--- Exact patterns are now supported from expect. Use the "-ex" flag.
-Exact patterns work just like those in interact. No special handling
-is made of *, ^, etc.
-
--- The new command "expect_background" registers patterns that are to
-be tested against spawned process output whenever it appears (i.e.,
-asynchronously). This only works in the Tk environment. The
-arguments are the same as the expect command.
-
--- expect_before and expect_after now handle their arguments like
-expect_background. Previously, a command such as "expect_before"
-with no arguments deleted patterns for all spawn ids. Now, it only
-deletes patterns for the current spawn id. Similarly with the "-i"
-form.
-
--- expect_background/before/after support an -info flag to query what
-the current patterns are. The results are returned in such a way that
-they can be re-used by a new expect command.
-
-The -info flag must be the first flag in the command. With no other
-arguments, it returns the setting for the current spawn id. With a -i
-descriptor, information is returned for that spawn id. The argument
--noindirect may be used to suppress indirects which also match a
-direct spawn id. Only a single -i specification may be given with
--info. With the argument "-all", all spawn id specifications are
-reported.
-
--- There is now a sleep command. It understands decimal values such as
-
- sleep .5
-
-Interrupts and other asynchronous events are processed while Expect sleeps.
-
--- Traps now use Tcl's "Async" support. This has advantages and
-disadvantages. One advantage is that traps have no chance of screwing
-up the Tcl internals. One disadvantage is that trap handlers are
-delayed at certain specific times and places. For example, a handler
-cannot occur inside another handler. While one handler is running,
-all other handlers are blocked. This is probably the most noticable
-place where handlers are blocked. Others are generally small windows,
-so you shouldn't notice the delay in executing the handlers.
-
-Several traps are initially defined:
-
- trap exit {SIGINT SIGTERM}
-
-If you use the -D flag to start the debugger, the following trap is
-defined:
-
- trap {exp_debug 1} SIGINT
-
-You can, of course, override these. In particular, if you have your
-own "trap exit SIGINT", this will override the debugger trap. Because
-SIGINT is tied to exit (see above) by default anyway, you should
-remove your own "trap exit SIGINT" unless you specifically do not want
-to be able to get to the debugger by ^C.
-
-If you want to define your own trap on SIGINT but still trap to the
-debugger when it is running, use:
-
- if ![exp_debug] {trap mystuff SIGINT}
-
-Alternatively, you can trap to the debugger using some other signal.
-
-The ONEXIT trap is no longer available. Instead, say "exit -onexit ..."
-
-Traps are now deleted by using the empty ({}) handler. The current
-handler is returned if no action is supplied. With no arguments, trap
-returns the signal number of the trap command currently being executed.
-
--- The wait command now returns a four element list if a valid child
-was waited on.
-Element 1: pid
-Element 2: spawn id
-Element 3: 0 (or -1 if there was an OS error)
-Element 4: status (or errno if element 3 == -1)
-
--- expect and interact notes:
-
-The timeout and eof patterns were initially named "-timeout" and
-"-eof" but have been renamed "timeout" and "eof" to match those of
-expect. The ability to define default timeout/eof actions has been
-removed. (You can do this more easily by grouping spawn ids.)
-
-expect and interact now support a "null" keyword to match an ASCII 0.
-send supports -null and -break keywords.
-
-Since a large number of special keywords have been added to interact,
-a new keyword "-ex" for "exact" was added descriptive of its default
-treatment of patterns. This protects the next token from being
-misinterpreted as a keyword. The expect command provides "-gl" for
-"glob" for analogous reasons.
-
-Any string starting with "-" should be protected by the "-ex" or "-gl"
-flag, even those that are not keywords currently. (All strings
-starting with "-" are reserved for future options.)
-
-String start/end indices are no longer written to expect_out and
-interact_out unless the -indices flag is given.
-
-expect_out(spawn_id) is set to the spawn id associated with the spawn
-id that produced the last output in an expect command. For example,
-you can use this to delete files that have closed, by removing this
-element from an indirect spawn ids spec. The same effect is
-reproducable with interact (and interact_out(spawn_id)) but for
-efficiency reasons, it requires the -iwrite flag before each pattern.
-
-Expect's -i and interact's -i, -u, -input, and -output flags can now
-describe a list of spawn ids. So you can say things like:
-
- interact -input "$id1 $id2 $id3" .... -output "$id1 $id2" ...
-
-In this case, id1, 2, 3 would be sent to id1, and 2.
-
-The spawn id may be given as a global variable name (called an
-"indirect spawn id specification"), in which case, the variable
-contains the list of spawn ids. Whenever the variable is changed, the
-new list of spawn ids is automatically used. This is particularly
-useful with any long running expect command such as expect_before,
-expect_after, expect_background, and interact.
-
-The -update flag was removed. Use indirect spawn ids (see previous
-paragraph).
-
--- interact notes:
-
-Interact now support -input and -output flags that provide very
-flexible means of moving data from/to multiple spawn ids in complex
-ways (but very quickly). It is possible to write most expect loops
-using a simple interact statement. For instance, the three way
-interaction inside kibitz (between two users and a process) is written
-this way:
-
- interact {
- -output $shell
- -input $userin eof { . . . } -output $shell
- -input $shell -output "$user_spawn_id $userout"
- }
-
--- send command notes:
-
-It is possible to send a break by using the "-break" flag.
-
-Any string starting with "-" should be protected by preceding it with
-the "--" flag, even those that are not keywords currently. (All
-strings starting "-" are reserved for future options.)
-
--- The spawn command now takes an "-open" flag which in turns takes a
-Tcl file as an argument. This lets you treat raw devices, files, and
-pipelines as spawned processes without using a pty.
-
-This was actually in Expect 4, but I forgot to document it. Oops!
-
--- The old "debug" command (which describes what Expect is doing
-internally) was renamed "exp_internal". "debug" (and "exp_debug") now
-invoke the interactive debugger.
-
--- The new command "stty" now takes over the job of "system stty". It
-works much better, allowing POSIX-style redirection to affect other
-ttys. It otherwise takes arguments as "system stty" did.
-
--- The "-tcl" option to "return" has gone away. (This was dangerous
-to anyone that actually happened to return the value "-tcl".)
-Instead, use inter_return.
-
--- Added exp_timestamp command to produce very fast timestamps.
-
--- Added exp_pid command to return pid of given spawn id.
-
--- The close command now takes an argument of "-onexec" with a following
-0 or non-zero value. For example, the follow command stops the
-current spawn id from being closed when another process is exec'd or
-spawn'd.
-
- close -onexec 0
-
-While "-onexec 1" returns it to the default condition where it will be
-closed upon exec or spawn.
-
--- log_user now returns previous value. It is acceptable to call now,
-without arguments just to get the value.
-
--- The following forms are deprecated. They will be allowed
-indefinitely but not advertised or supported if they break.
-
- -eof, -timeout in interact (reason: didn't match expect.
- Instead, use eof or timeout.)
-
- -- in expect or interact (reason: no easier to read.
- Instead, use -gl in expect or -ex in interact.)
-
- continue -expect (reason: when mixing in extensions, you have
- to use exp_continue, so -expect becomes irrelevant.
- Instead, use exp_continue.)
-
- getpid (reason: Tcl now supplies same functionality as "pid".
- Instead, use pid.)
-
- expect_version and expect_library (reason: the name implies
- they have something to do with the expect command,
- which they doesn't.
- Instead, use exp_version and exp_library.)
-
- -timestamp for obtaining tm and ctime in expect and interact
- (reason: separate command now exists for this purpose.
- Instead, use exp_timestamp.)
-
- system stty (reason: bad interaction with redirection.
- Instead, use stty.)
-
--- New examples have been added:
-
-"dislocate" lets you disconnect and reconnect to processes.
-
-"tkpasswd" illustrates passwd embedded in a GUI.
-
-They may not be overwhelmingly useful, but run them once to see what
-they do. If you ever need to do anything similar, you can look back
-at them.
-
-"tknewsbiff" pops up a window or plays a audio clip when you have
-unread news.
-
--- Changes to the Expect libraries:
-
-The expect-tcl library (libexpectcl.a) has been integrated with the
-expect library (libexpect.a). So references to libexpectcl.a should
-be removed.
-
-The Expect C library now supports buffering, multiplexing, null
-matching, full buffer matching. Basically, all of the features in
-Expect are now in the library.
-
-Buffering and multiplexing has caused the biggest change to the
-library. Previously, exp_match contained the entire buffer that
-matched. Now exp_match just points to where in the buffer the match
-started. exp_buffer points to the beginning of the buffer.
-Previously, the previous buffer was thrown away at the beginning of
-each expect function call. Now, previously unmatched characters are
-eligible for matching.
-
-To match on different file descriptors, exp_match, exp_match_end,
-exp_buffer_end must be restored to their previous values. Initially,
-they should be zero.
-
-The meaning of timeout == 0 in the Expect library has been changed.
-See the man page for more info.
-
+++ /dev/null
-2003-10-02 Chris Demetriou <cgd@broadcom.com>
-
- * configure.in (EXP_LIB_SPEC): Use ${libdir} rather than
- ${exec_prefix}/lib.
- * configure: Regenerate.
-
-2003-07-15 Alexandre Oliva <aoliva@redhat.com>
-
- * aclocal.m4 (CY_AC_PATH_TCLCONFIG): Use .../tcl/win, not cygwin.
- * configure, Dbgconfigure, testsuite/configure: Rebuilt.
-
-2003-07-14 Alexandre Oliva <aoliva@redhat.com>
-
- * aclocal.m4 (CY_AC_PATH_TKCONFIG): Look for it in .../tk/win.
- * configure: Rebuilt.
- * Dbgconfigure: Rebuilt to pick up 2002-07-30's change.
-
-2003-01-29 Andrew Cagney <ac131313@redhat.com>
-
- * configure.in (EXP_AND_TCL_LIBS): Set to TCL_CC_SEARCH_FLAGS
- instead of TCL_LD_SEARCH_FLAGS.
- (EXP_AND_TK_LIBS): Ditto.
-
-2002-11-19 Andrew Cagney <ac131313@redhat.com>
-
- * exp_clib.c (ecases;): Cast value returned by TclRegComp to a
- void pointer.
- * exp_command.c (Exp_SpawnCmd): Cast `wfd' to an int before
- passing to `dup'. Pass `rfd' and `wfd' to an int before assigning
- to `master'.
-
-2002-07-30 Keith Seitz <keiths@redhat.com>
-
- From Mo DeJong <supermo@bayarea.net>
- * aclocal.m4 (CY_AC_PATH_TCLCONFIG): Check for a
- tclConfig.sh file in tcl/cygwin if one can't
- be found in tcl/unix. Update Itcl header check.
- * configure: Regenerated.
-
-2002-04-11 Christopher Faylor <cgf@redhat.com>
-
- * configure.in: Don't use libutil.a on cygwin.
- * configure: Regenerate.
-
-2002-03-06 Alexandre Oliva <aoliva@redhat.com>
-
- * exp_command.c (STARARGV): Indent #defines properly.
-
-2001-09-28 Kevin Buettner <kevinb@redhat.com>
-
- * configure.in (_XOPEN_SOURCE): Permit definition of _NSIG to
- define _XOPEN_SOURCE too.
- * configure: Regenerated.
-
-Thu Sep 20 16:00:44 2001 Andrew Cagney <cagney@b1.cygnus.com>
-
- * Makefile.in (shared/tcl_regexp.o, tcl_regexp.o): Add explict
- build rules that include @TCL_DEFS@ in the list of compiler flags.
-
-Tue Sep 11 15:24:00 2001 Christopher Faylor <cgf@cygnus.com>
-
- Remove unneeded CYGWIN code throughout.
- Change CYGWIN32 to CYGWIN throughout.
- * configure.in: Use gcc -mno-win32 option under Cygwin.
- * configure: Regenerate.
-
-2001-07-09 Ian Roxborough <irox@redhat.com>
-
- * tclParse-compat.c: New file.
- * tcl_regexp.c:
- * tcl_regexp.h: New file. Contains Tcl8.0's regexp.
- * Makefile.in: Added new files to be compiled and linked.
- * exp_clib.c (exp_expectl, exp_fexpectl):
- * exp_inter.c (in_keymap, Exp_InteractCmd ):
- * exp_regexp.c (regtry, regdump, regprop):
- * expect.c (parse_expect_args, eval_case_string,
- exp_background_filehandler, Exp_ExpectCmd):
- * expect.h:
- * expect_comm.h:
- * Dbg.c (breakpoint_test, cmdBreak): Use newly built in
- regexp, not external Tcl regexp.
- * exp_tty.c (exec_stty):
- * exp_command.c (Exp_CloseCmd, Tcl_CloseCmd): Handle Tcl API
- changes in Tcl8.3.
-
-2001-05-11 Andrew Cagney <ac131313@redhat.com>
-
- From 2001-04-24 Rodney Brown <RDBrown@mira.net>:
- * configure.in: Only define _XOPEN_SOURCE if NSIG remains defined.
- * configure: Regenerate.
-
-2000-07-06 Jim Wilson <wilson@cygnus.com>
-
- * pty_termios.c: Include expect_cf.h before stdio.h.
-
-2000-05-15 Tom Tromey <tromey@cygnus.com>
-
- * expect_cf.h.in (_XOPEN_SOURCE): Added.
- * configure: Rebuilt.
- * configure.in: Define _XOPEN_SOURCE when using ptsname.
-
-2000-03-31 Alexandre Oliva <oliva@lsd.ic.unicamp.br>
-
- * Makefile.in (expect-bld.sh): New wrapper script.
- (all): Depend on it.
- (LOCAL_EXPECT): Use it.
-
-1999-11-11 DJ Delorie <dj@cygnus.com>
-
- * configure.in: use new library name, provide define for sources
- * configure: regenerate
- * exp_event.c: only take win-specific parts out if we did detect
- the unix/cygwin special version of libtcl.
-
-1999-10-29 Frank Ch. Eigler <fche@cygnus.com>
-
- * configure.in: For cygwin host, also override TCL_LIB_SPEC.
- * configure: Regenerated.
-
-1999-10-27 DJ Delorie <dj@cygnus.com>
-
- * configure.in: Use $host, not results of build, to detect
- cygwin-specific tcl library
-
-1999-10-26 DJ Delorie <dj@cygnus.com>
-
- * configure.in: If we detect a cygwin-specific version of tcl,
- use it.
- * exp_event.c: don't need the extra functions any more.
-
-Wed Oct 6 04:12:08 1999 Brendan Kehoe <brendan@cygnus.com>
-
- * configure.in (EXP_LD_SEARCH_FLAGS): If $GCC is "yes", don't do
- the substitution translating -Wl,-rpath,foo into just -rpath,
- since we're not using just the linker.
- * configure: Regenerated.
-
-1999-09-17 DJ Delorie <dj@cygnus.com>
-
- * expect.c: define SIMPLE_EVENT so that timeouts work
-
-Wed Sep 15 19:29:13 1999 Jeffrey A Law (law@cygnus.com)
-
- * exp_command.c (Exp_SpawnCmd): Make wfd and rfd wide enough and
- aligned enough so that they can hold pointer values.
-
-1999-09-14 Felix Lee <flee@cygnus.com>
-
- * exp_main_exp.c (main): call Tcl_FindExecutable.
-
-1999-06-01 Angela Marie Thomas <angela@cygnus.com>
-
- * Makefile.in: Add install-minimal target.
-
-1999-05-18 Fred Fish <fnf@cygnus.com>
-
- * exp_strf.c (strchr): Do not try to declare if defined
- already with a #define.
-
-1999-05-03 Tom Tromey <tromey@cygnus.com>
-
- * configure, Dbgconfigure: Rebuilt with newer autoconf.
-
-Mon Nov 2 15:05:33 1998 Geoffrey Noer <noer@cygnus.com>
-
- * configure.in: detect cygwin* instead of cygwin32*
- * configure: regenerate
-
-Fri Oct 16 22:26:59 1998 <dj@cygnus.com>
-
- * exp_event.c (pipe_thread): don't select or WFSO forever,
- else you hang when pipe_close is called.
-
-Thu Oct 08 16:08:57 1998 <dj@cygnus.com>
-
- * exp_command.c (cygwin_pipe_dup): use this instead of dup()
- because sometimes we try to dup() a handle instead of a fd
- * exp_event.c (pipe_thread): check for "forgotten" threads
- and clean them up properly (else leaks).
-
-Thu Oct 1 13:22:28 1998 DJ Delorie <dj@indy.delorie.com>
-
- * exp_event.c (pipe_watch): close a thread handle leak.
-
-1998-09-28 Rob Savoye <rob@chinadoll.cygnus.com>
-
- * configure.in: Comment out not using -g on Linux.
- * configure: Regenerated.
-
-Thu Sep 24 12:04:39 1998 DJ Delorie <dj@indy.delorie.com>
-
- * exp_command.c (fd_new): move cygwin init outside of tcl version
- check.
-
-Thu Sep 17 18:08:42 1998 Christopher Faylor <cgf@cygnus.com>
-
- * exp_event.c (pipe_info): Reorganize for better cygwin
- functionality.
- (pipe_thread): Use cygwin select() to detect pipe activity
- since it now correctly handles EOF conditions.
- (pipe_close): Reorganize for better operation with pipe_thread
- change.
- (pipe_get_handle): Return cygwin fd since Windows handle is
- no longer required.
- (make_pipe_channel): Remove initialization of obsolete fields.
-
-1998-08-28 Rob Savoye <rob@chinadoll.cygnus.com>
-
- * aclocal.m4(CY_AC_LOAD_TCLCONFIG): Don't look for
- Tcl_CreateCommand(), cause libtcl hasn't been built yet. All this
- did was try to make sure you haven't removed your Tcl build
- directory.
- * configure: Regenerated.
-
-1998-08-21 Rob Savoye <rob@chinadoll.cygnus.com>
-
- * Most files: Merge in expect 5.26 to get better tcl8.x
- support. See HISTORY for more details.
-
- * aclocal.m4 (CY_AC_INTTYPES_H): Find inttypes.h, but if it's
- definitions conflict with sys/types.h, then don't include
- it.
-
-Wed Jul 15 11:06:50 1998 Bob Manson <manson@charmed.cygnus.com>
-
- * configure.in: Fix typo.
- * configure: Regenerated.
-
-Tue Jul 14 13:27:30 1998 Bob Manson <manson@charmed.cygnus.com>
-
- * configure.in (EXP_BUILD_LIB_SPEC): Always link expect against
- the static library.
- (EXP_LIB_FILE): Always set to EXP_NONSHARED_LIB_FILE.
-
- * configure: Regenerated.
-
-Tue Apr 28 18:54:13 1998 Geoffrey Noer <noer@cygnus.com>
-
- * aclocal.m4: add autoconf macros AM_EXEEXT and AM_CYGWIN32
- * configure.in: call AM_EXEEXT
- * Makefile.in: add EXEEXT variables
- * configure: regenerate
-
-Thu Mar 19 09:12:04 1998 Jeffrey A Law (law@cygnus.com)
-
- * configure.in: Handle hpux11 just like hpux10 for now.
-
-Sat Feb 28 17:24:38 1998 Richard Henderson <rth@cygnus.com>
-
- * exp_command.c: Use _NSIG if NSIG not present.
- * exp_trap.c: Likewise.
-
-Sun Feb 22 17:39:35 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * exp_event.c: Extensive additions to support
- Tcl_CreateFileHandler and Tcl_DeleteFileHandler on cygwin32.
- Define a new pipe channel type, based on code in tclWinPipe.c.
- * exp_command.h (struct exp_f): If __CYGWIN32__, add channel,
- fileproc, and procdata fields.
- * exp_command.c (fd_new): If __CYGWIN32__, initialize channel and
- fileproc fields.
- (Exp_SpawnCmd): If __CYGWIN32__, don't accept -open or -leaveopen
- argumnents.
- (Exp_LogFileCmd): Likewise.
- (Tcl_CloseCmd): Use Tcl_Alloc instead of ckalloc. Use
- Tcl_NewStringObj instead of TclNewObj and TclInitStringRep. Use
- Tcl_Free instead of ckfree.
- * expect.c (exp_i_read): If __CYGWIN32__, call
- exp_reading_from_descriptor.
- * pty_termios.c: If __CYGWIN32__, don't include <sys/stropts.h>.
- (pty_stty): If __CYGWIN32__, just exec stty, not /bin/stty.
- (getptyslave): If __CYGWIN32__, don't I_PUSH anything.
- * configure.in: Add many checks for cross_compiling to avoid doing
- the wrong thing when building with a cross compiler. Add several
- cases to specifically handle a cygwin32 host when building with a
- cross compiler. On cygwin32, link against -luser32.
- * configure: Rebuild.
-
-Fri Jan 30 16:48:35 1998 Ian Lance Taylor <ian@cygnus.com>
-
- * configure.in: Don't check for openpty on Linux. It exists on
- Alpha Linux Red Hat 4.2, but it doesn't work correctly.
-
-Thu Jan 22 17:29:27 1998 Fred Fish <fnf@cygnus.com>
-
- * exp_clib.c (exp_spawnv): Provide reason for error message if we
- fail to get the controlling terminal using TIOCSCTTY.
- * exp_command.c (Exp_SpawnCmd): Ditto.
-
-Sun Dec 7 20:39:33 1997 Bob Manson <manson@charmed.cygnus.com>
-
- * exp_command.c(Exp_SpawnCmd): Use ClientData instead of
- int for file descriptors.
-
-Wed Oct 15 12:14:26 1997 Jeffrey A Law (law@cygnus.com)
-
- * testsuite/config/default.exp (eprompt): Tweak again for new
- prompt variant.
-
-Fri Sep 12 12:57:10 1997 Jeffrey A Law (law@cygnus.com)
-
- * testsuite/config/default.exp (eprompt): Accept new prompt
- variant.
-
-Fri Sep 12 10:40:56 1997 Bob Manson <manson@charmed.cygnus.com>
-
- * exp_main_sub.c: Instead of using -1 for an invalid value, use 1
- instead--this will allow the "testsuite" to pass.
-
-Thu Sep 4 11:49:44 1997 Jeffrey A Law (law@cygnus.com)
-
- * exp_command.c (NUM_ARGS): Move start of cpp #define to
- column zero.
-
-Thu Aug 28 16:42:58 1997 Bob Manson <manson@charmed.cygnus.com>
-
- * exp_command.c (Tcl_CloseCmd): Function to call Tcl_CloseObjCmd
- with appropriate arguments, mostly stolen from tclBasic.c.
-
- * Dbg.c (simple_interactor): There doesn't appear to be any
- equivalent for curEventNum, so replace with -1 for now. (It only
- appears in the prompt anyway).
- * exp_main_sub.c (Exp_Prompt1Cmd): Ditto.
- * exp_main_sub.c (exp_interpreter): Ditto.
-
-Wed Aug 13 12:57:20 1997 Bob Manson <manson@charmed.cygnus.com>
-
- * Makefile.in (X11_PROGS): Commented out until expectk is working
- with tcl8.
- (X11_PROGS_INSTALLED): Ditto.
-
-Mon Aug 11 20:56:56 1997 Bob Manson <manson@charmed.cygnus.com>
-
- * Changes to get expect working under tcl8.
-
- * expect.c: Include tclInt.h to get a definition of TclWordEnd.
- (exp_eval_with_one_arg): Under Tcl8 TclWordEnd takes an additional
- parameter. Don't go past the end of the string.
-
- * exp_main_exp.c: If USE_ITCL is defined, include a call to
- Itcl_Init.
-
- * exp_command.c: Tcl8 uses an OS-specific type for "file handles".
- This code will NOT work under anything that doesn't use an int;
- it requires cleanup to make it reasonably portable.
- * exp_command.h: Ditto.
-
- * aclocal.m4: Check for itcl headers.
- * configure.in: Ditto.
-
- * Makefile.in: Add expecti target.
-
- * Dbg.c (print_argv): Tcl8 has a new argument to TclFindElement
- specifying the length of the string.
- (PrintStackBelow): Tcl8 uses objc/objv in the stack frame
- instead of argc/argv; this change is woefully incomplete.
-
-Tue Apr 1 13:55:15 1997 Bob Manson <manson@charmed.cygnus.com>
-
- * exp_event.c(exp_get_next_event): Don't delete the
- timeout timer until we actually return.
-
-Thu Mar 20 14:27:45 1997 Geoffrey Noer <noer@cygnus.com>
-
- * configure.in: don't check if stty reads stdout for
- i[[3456]]86-*-sysv4.2MP during config; hard code instead
- * configure: regenerated
-
-Thu Mar 13 10:43:06 1997 Tom Tromey <tromey@cygnus.com>
-
- * Makefile.in (FLAGS_TO_PASS): Removed RUNTEST, RUNTESTFLAGS.
- (RUNTESTFLAGS): Removed.
- (RUNTEST): Removed.
-
- * configure: Regenerated.
- * configure.in: Always set EXP_CFLAGS to "".
-
- * configure.in (AC_CONFIG_AUX_DIR): Look in srcdir.
-
-Wed Nov 20 10:42:03 1996 Tom Tromey <tromey@cygnus.com>
-
- * configure.in: Always respect CFLAGS as passed in environment.
- If not set, let AC_PROG_CC set it.
-
-Tue Nov 19 09:22:08 1996 Tom Tromey <tromey@cygnus.com>
-
- * Makefile.in (install_shared_lib): Put else clause onto each if.
-
-Fri Nov 15 11:23:43 1996 Tom Tromey <tromey@cygnus.com>
-
- * Makefile.in (XCFLAGS): Use EXP_SHLIB_CFLAGS, not
- TCL_SHLIB_CFLAGS.
- (TCL_SHLIB_CFLAGS): Define.
-
- * configure.in: Allow arguments to --enable-blah to work.
- Compute and AC_SUBST EXP_SHLIB_CFLAGS.
- Added missing AC_MSG_CHECKING.
-
-Thu Nov 7 13:30:39 1996 Tom Tromey <tromey@cygnus.com>
-
- * Dbg.c, exp_clib.c, exp_command.c, exp_command.h, exp_glob.c,
- exp_int.h, exp_inter.c, exp_main_sub.c, exp_printify.c,
- exp_printify.h, exp_pty.h, exp_trap.c, exp_tty.c, exp_tty.h,
- exp_win.c, exp_win.h, expect.c, expect_comm.h, pty_termios.c:
- Changes to make gcc -Wall complain less.
-
-Mon Nov 4 14:01:03 1996 Tom Tromey <tromey@cygnus.com>
-
- * exp_clib.c (exp_disconnect): #if condition fix.
- (exp_spawnv): Ditto.
-
- * exp_command.c (Exp_SpawnCmd): #if condition fix.
- (Exp_DisconnectCmd): Ditto.
-
-Tue Oct 15 12:38:50 1996 Tom Tromey <tromey@cygnus.com>
-
- * configure: Regenerated.
- * configure.in: Make sure to pass --cache-file argument to
- sub-configure.
-
-Wed Oct 9 11:24:17 1996 Tom Tromey <tromey@cygnus.com>
-
- * configure: Regenerated.
- * configure.in (stty_reads_stdout): /bin/stty on OSF 4.0 fails.
-
-Wed Oct 2 10:13:37 1996 Tom Tromey <tromey@cygnus.com>
-
- * configure: Regenerated.
- * configure.in (stty_reads_stdout): /bin/stty on DG/UX fails.
-
-Tue Oct 1 10:40:11 1996 Tom Tromey <tromey@cygnus.com>
-
- * Dbg.c, exp_clib.c, exp_closetcl.c, exp_command.c, exp_console.c,
- exp_event.c, exp_inter.c, exp_main_tk.c, exp_pty.c, exp_strf.c,
- exp_trap.c, exp_win.c, exp_win.h, expect.c, pty_termios.c: Patches
- to make "gcc -Wall" be more quiet. From Fred Fish.
-
-Fri Sep 27 10:15:48 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * expect.c (exp_i_read): Pass interp as first arg to exp_error.
- * configure.in (stty_reads_stdout): /bin/stty on OSF2.0, OSF3.2,
- HPUX 9.X, HPUX 10.X guesses wrong, so set value explicitly.
-
-Mon Sep 9 10:29:32 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * configure: Regenerated.
- * configure.in: Added code to actually handle --with-x.
-
- * configure: Regenerated.
- * configure.in: Don't bother looking for Tk if --with-x=no
- specified.
-
-Thu Sep 5 11:01:09 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * configure: Regenerated.
- * configure.in (stty_reads_stdout): AIX fails "stty" test in
- background, so set explicitly. Ditto HPUX 9 and 10.
-
-Thu Aug 29 17:04:55 1996 Michael Meissner <meissner@tiktok.cygnus.com>
-
- * configure.in (i[345]86-*-*): Recognize i686 for pentium pro.
- * configure: Regenerate.
-
-Mon Aug 26 12:33:58 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * Makefile.in (install): Depend on install_shared_lib.
-
-Fri Aug 23 10:17:45 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * configure: Regenerated.
- * configure.in: Look in `..' for aux files. Re-enable caching.
-
-Fri Aug 16 12:54:39 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * exp_main_tk.c (print_version): New variable.
- (argTable): Added -version.
- (Tk_Init2): Print version if required.
-
- * exp_main_sub.c (exp_parse_argv): Added `-v' support again.
-
-Wed Aug 14 12:02:26 1996 Tom Tromey <tromey@rtl.cygnus.com>
-
- * Makefile.in (X11_PROGS_INSTALLED): Now the same as X11_PROGS.
- (install): Don't depend on expect_installed.
- (clean): Don't remove expect_installed or expectk_installed.
- (mostlyclean): Ditto.
-
-Mon Aug 5 12:55:06 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * Makefile.in (XCFLAGS): New macro.
- (CFLAGS): Define to just @CFLAGS@.
- (CFLAGS_INT): Use $(XCFLAGS).
- (expect, expect_installed, expect.tc, expectk, expectk_installed,
- expectk.tc): Use $(XCFLAGS).
-
-Tue Jul 23 14:00:56 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * expect_comm.h: Don't include expect_cf.h.
-
- * Makefile.in (install): Don't install expect_cf.h.
-
-Thu Jul 18 17:27:12 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * Makefile.in (install-scripts): Install cat-buffers here.
-
-Mon Jul 15 13:50:52 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * Makefile.in (configure): Don't automatically rebuild.
- (Dbgconfigure): Don't automatically rebuild.
-
-Mon Jun 24 17:47:52 1996 Jason Molenda (crash@godzilla.cygnus.co.jp)
-
- * Makefile.in (bindir, libdir, datadir, mandir, infodir, includedir,
- execdatadir): Uset autoconf set values.
- (docdir, oldincludedir): Removed.
- * configure.in (AC_PREREQ): autoconf 2.5 or higher.
- * configure: Rebuilt.
-
-Wed Jun 12 14:18:09 1996 Tom Tromey <tromey@thepub.cygnus.com>
-
- * configure: Regenerated.
- * aclocal.m4 (CY_AC_PATH_TCLH, CY_AC_PATH_TKH): Use odd names to
- avoid name clashes with SunOS headers.
-
-Tue Jun 4 17:54:06 1996 Gordon Irlam <gordoni@snuffle.cygnus.com>
-
- * install-sh: Add MIT copyright. Fix typo.
-
-Tue May 28 13:09:26 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * Makefile.in (Dbgconfigure): Removed broken srcdir test.
-
- * Dbgconfigure: Regenerated.
- * Dbgconfig.in: Use CY_AC_C_WORKS.
-
- * configure: Regenerated.
- * aclocal.m4 (CY_AC_PATH_TCLH): Don't use AC_TRY_RUN.
- (CY_AC_PATH_TKH): Don't use AC_TRY_RUN.
-
-Tue May 21 10:14:24 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * configure: Regenerated.
- * aclocal.m4: Typo fix.
-
-Thu May 16 09:54:18 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * configure: Regenerated.
- * configure.in: Use CY_AC_C_WORKS instead of CY_AC_C_CROSS.
- * aclocal.m4: Replaced CY_AC_C_CROSS with CY_AC_C_WORKS.
-
-Fri May 10 16:59:46 1996 Doug Evans <dje@canuck.cygnus.com>
-
- * exp_pty.c (errno): Delete. Include errno.h instead.
-
-Tue Apr 30 10:17:41 1996 Tom Tromey <tromey@snuffle.cygnus.com>
-
- * exp_main_tk.c (main): Removed "-inet-1.0".
-
- * exp_main_sub.c (exp_parse_argv): Removed "-inet-1.0".
-
- * configure: Regenerated.
- * configure.in: Append $XLIBS to X_LIBS.
- (have_nsl): Only check for -lnsl once.
- Run AC_CANONICAL_SYSTEM.
-
- * Makefile.in (install): Don't install scripts.
- (install-scripts): New target.
-
- * exp_main_tk.c (print_version): New global.
- (argTable): Added -version.
- (main): Handle -version option.
-
- * exp_main_exp.c (argv): Run Tcl_FindExecutable.
-
- * exp_main_tk.c (main): Run Tcl_FindExecutable.
-
- * exp_main_sub.c (exp_parse_argv): Added -v argument.
- (exp_version): No longer static.
-
-Thu Apr 25 12:31:21 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * Makefile.in: Removed "$(srcdir)/" from all dependencies, to work
- around problem with Sun make's VPATH.
-
-Mon Feb 12 23:11:38 1996 Rob Savoye <rob@chinadoll>
-
- * aclocal.m4: Fix typo of ac_cv_tkh to be ac_cv_tclh so it works
- on all systems.
- * configure, DBGconfigure, testsuite/configure: Regenerated with
- autoconf 2.7.
-
-Tue Feb 6 11:48:05 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * exp_clib.c, exp_printify.c, expect_comm.h: For Tcl 7.5 and
- greater, use ../compat/stdlib.h, not compat/stdlib.h.
-
-Tue Jan 30 12:21:37 1996 Fred Fish <fnf@kalessin.cygnus.com>
-
- * exp_regexp.c (regmatch, regrepeat): Only declare strchr if it is not
- a macro.
-
-Mon Jan 22 11:17:06 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * configure.in: Check for -lieee, -ldl, and -ldld.
-
- * Makefile.in (OFILES): Include @LIBOBJS@.
- (strerror.o): New target.
-
- * strerror.c: New file.
-
- * configure.in: Test for strerror.
-
-Fri Jan 19 11:08:11 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * Makefile.in (install, ${SCRIPT_LIST}, test): Find new Tcl libraries.
-
-Thu Jan 18 13:43:13 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * Most files: Update to expect 5.19.
-
-Fri Jan 12 16:22:12 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * exp_closetcl.c (exp_close_tcl_files): Skip stdin, stdout,
- stderr.
- * expect_comm.h: Declare exp_close_files_interp.
- * exp_command.c (exp_init_most_cmds): Set exp_close_files_interp.
-
-Thu Jan 11 09:43:14 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * exp_closetcl.c (exp_close_files_interp): New variable for Tcl
- 7.5.
- (exp_close_tcl_files): Updated for Tcl 7.5.
-
- Prototype and varargs changes:
- * expect.c: Don't include <varargs.h>.
- * Dbg.c: Copied in many defines from expect_comm.h.
- (print): Use new varargs defines.
- * exp_clib.c (exp_fexpectl): Use EXP_VARARGS_START.
- * expect_comm.h: Include "tclInt.h".
- * exp_console.c (exp_console_manipulation_failed): First arg to
- errorlog is char*, not FILE*.
- * exp_log.c (debuglog): Pass name of last argument to
- EXP_VARARGS_START.
- * expect_cf.h.in (tcl_AsyncReady): Removed define.
- * expect.c (Exp_ExpectGlobalCmd): Added cast.
- * exp_command.c (exp_i_update): First arg to exp_debuglog is
- * exp_poll.c (exp_get_next_event): Likewise.
- char*, not Tcl_Interp*.
- * exp_log.h: Use prototypes everywhere. Include "expect_comm.h".
- * expect_tcl.h: Use EXP_VARARGS, not VARARGS.
- (tcl_AsyncReady): New define for Tcl 7.5.
-
- * aclocal.m4 (CY_AC_PATH_TCLH): Handle Tcl 7.5 and greater.
- (CY_AC_PATH_TCLLIB): Handle Tcl 7.5 and greater.
- (CY_AC_PATH_TKH): Handle Tk 4.1 and greater.
- (CY_AC_PATH_TKLIB): Handle Tk 4.1 and greater. Properly quote
- argument to AC_REQUIRE.
- * configure: Regenerated.
-
-Tue Jan 9 16:26:47 1996 Rob Savoye <rob@chinadoll.cygnus.com>
-
- * Makefile.in: Change SHORT_BINDIR to $prefix, rather than
- exec_prefix. This is only used to store the platform independant
- expect scripts.
-
-Dec 18 17:22:05 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
-
- * configure.in, configure: For a solaris2 machine doing a static
- build, add `-ldl -lw' to avoid unresolved refs using the
- OpenWindows libraries.
-
-Wed Nov 22 08:49:01 1995 Rob Savoye <rob@chinadollchinadoll.cygnus.com>
-
- * Most files: Update to expect 5.18.1.
-
-Fri Nov 17 17:31:55 1995 Rob Savoye <rob@chinadoll.cygnus.com>
-
- * configure.in: Add support for SCO OpenServer. It doesn't like
- the trap either.
-
-Thu Nov 16 09:28:53 1995 Rob Savoye <rob@chinadoll.cygnus.com>
-
- * configure.in: Use $host to get the OS type rather than trying to
- get the host name ourselves. Use the $host to set the
- STTY_READS_STDOUT for hosts were the test is known to fail. It
- also now configures in the background.
- * configure.in, Dbgconfig.in, testsuite/configure.in: Use
- AC_PROG_CC again since Cygnus configure now does the sames thing.
-
-Mon Oct 30 18:16:48 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * configure.in (no_tk): zero out X_PROGS if we can't find tk
- libraries.
-
-Tue Oct 24 18:25:09 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * Makefile.in (X11HDIR): Changed to X11_CFLAGS.
- (X11_LIB_FLAGS): Changed to X11_LDFLAGS.
- (X11_LIB): Changed to X11_LIBS.
- (CPPFLAGS_SIMPLE): Use X11_CFLAGS.
- (expectk, expectk.tc, tk): use X11_LDFLAGS & X11_LIBS.
-
- * configure.in (X11HDIR, X11_LIB_FLAGS, X11_LIB): Use X11_CFLAGS,
- X11_LDFLAGS, X11_LIBS. Link X11 statically on Solaris, SunOS and
- HPUX.
-
-Thu Oct 19 20:55:54 1995 Fred Fish <fnf@cygnus.com>
-
- * Makefile.in: Remove extraneous tabs and blanks in otherwise
- empty lines. That confuses older non-GNU versions of "make".
-
-Mon Oct 9 20:58:50 1995 Jason Molenda (crash@phydeaux.cygnus.com)
-
- * testsuite/aclocal.m4: New file. Include ../aclocal.m4.
-
-Thu Aug 31 00:16:26 1995 Rob Savoye <rob@darkstar.cygnus.com>
-
- * HISTORY, Makefile.in, aclocal.m4, exp_command.h, exp_inter.c,
- exp_main_tk.c, exp_pty.c, expect.c, tests/all,
- testsuite/Makefile.in. Update to the 5.18.0 release. Minor
- changes.
-
-Thu Aug 17 18:47:21 1995 Rob Savoye <rob@darkstar.cygnus.com>
-
- * Most files: Update to the 5.17.7 release.
-
-Thu Aug 3 22:47:36 1995 Jeff Law (law@snake.cs.utah.edu)
-
- * pty_termios.c (HAVE_PTMX): Undefine if both HAVE_PTYM and
- HAVE_PTMX are defined (as happens for hpux10).
-
-Thu Jul 27 16:31:23 1995 J.T. Conklin <jtc@cygnus.com>
-
- * Makefile.in (configure): Removed rule that automatically
- rebuilds configure script. Users might not have autoconf.
-
-Tue Jul 18 23:15:03 1995 Fred Fish <fnf@fishbowl>
-
- * expect.c (Exp_ExpectGlobalCmd): Cast ckrealloc first arg to char*.
-
-Sun Jun 18 13:02:41 1995 Fred Fish <fnf@amigalib.com>
-
- * configure, configure.in (XLIBS): When adding -lX11, also preserve
- the previous libraries that we went to the trouble of finding.
-
-Sun Jun 18 12:15:44 1995 Fred Fish <fnf@amigalib.com>
-
- * Makefile.in (exp_clib.o): Add dependencies.
-
-Mon May 1 16:50:22 1995 Rob Savoye <rob@darkstar.cygnus.com>
-
- * configure.in: Also set XINCLUDES in the Makefile.
-
-Fri Apr 28 18:56:02 1995 Rob Savoye <rob@darkstar.cygnus.com>
-
- * aclocal.m4: Create a clone of AC_C_CROSS called CY_C_CROSS that
- has better error handling in case the native compiler is hosed.
- * aclocal.m4: Look for tcl and tk directories as just tcl (and tk)
- or tcl[0-9] (and tk[0-9)] so it doesn't match the tclX
- release. Print an error and exit if any of the --with-{tcl,tk}*
- options are used and point to bogus paths. Based Tcl header search
- on tclInt./h rather than tcl.h.
- * Makefile.in: Add dependancies for back in for configure and
- Dbgconfigure targets.
-
-Mon Apr 24 16:46:01 1995 Rob Savoye <rob@darkstar.cygnus.com>
-
- * exp_command.c, exp_event.h, exp_inter.c, exp_main_tk.c,
- exp_poll.c, exp_select.c, exp_simple.c, exp_tk.c, exp_trap.c,
- exp_tty.c, FAQ, README, HISTORY: Update to expect 5.16.3.
-
-Fri Apr 14 12:00:39 1995 Rob Savoye <rob@darkstar.cygnus.com>
-
- * configure.in: Copy Dbg_cf.h to objdir, not srcdir.
-
-Tue Apr 11 18:52:24 1995 Rob Savoye <rob@darkstar.cygnus.com>
-
- * aclocal.m4: Split the macros so header and library searches are
- seperate macros. AC_PATH_{TCL,TK} nows only calls the macros. Lots
- of optimization to the AC_PATH_T* macros. Supports the use of
- --with-tclinclude, --with-tcllib, --with-tkinclude, --with-tklib
- to specify alternative search dirs for tcl and tk stuff.
- * Makefile.in, testsuite/Makefile.in: Re-write targets for
- configure, Dbgconfigure so they work in an unconfigured srcdir.
- * configure.in: Put AC_PATH_X before AC_PATH_TK and make the TK
- test conditional. Fix how Dbgconfigure gets passed the Tcl header
- dir to use --with-PACKAGE which is much simpler. Removed the test
- for user override of X search paths since AC_PATH_X uses.
- --x-includes and --x-libraries instead.
- * Dbgconfig.in: Use AC_PATH_TCLH to find just the headers, and
- test for LynxOS.
- * debugger/: Remove directory. Recursive configuring is so much
- easier...
- * DbgMkfl.in, Dbg_cf.h.in, Dbg.c, Dbg.h, Dbgconfigure,
- Dbgconfig.in: Sigh, moved back to the top-level expect directory.
-
-Wed Apr 5 17:25:45 1995 Rob Savoye <rob@darkstar.cygnus.com>
-
- * configure.in: Add a trap so the configure runs in the
- background.
-
-Thu Mar 16 16:56:08 1995 Rob Savoye <rob@darkstar.cygnus.com>
-
- * debugger: New directory for the Tcl debugger.
- * debugger/Dbg.c, debugger/Dbg.h, debugger/Dbg_cf.h.in: Moved from
- the top level expect directory so it builds standalone.
- * DbgMkfl.in, debugger/Makefile.in: Moved to debugger dir and
- renamed.
- * install-sh, mkinstalldirs: New files borrowed from the autoconf
- distribution.
- * aclocal.m4: New autoconf macros.
- * Makefile.in: Tweaked so it's recursive.
- * configure.in: Use new macros in aclocal.m4 rather than hunting
- for the Tcl and Tk stuff ourseleves.
- * debugger/Makefile.in: Build debugger standalone.
- * testsuite/Makefile.in, testsuite/configure.in: New files for
- autoconf support.
- * exp_test.c, testsuite/exp_test.c: Move test file.
-
-Fri Jan 13 15:30:30 1995 Ian Lance Taylor <ian@sanguine.cygnus.com>
-
- * Makefile.in (check): Pass EXPECT correctly to runtest.
-
-Thu Oct 20 18:04:06 1994 Rob Savoye <rob@darkstar.cygnus.com>
-
- * Makefile.in: Add X11_INCLUDE_FLAGS so top level flags get used
- too.
-
-Tue Jun 14 12:32:07 1994 David J. Mackenzie (djm@rtl.cygnus.com)
-
- * aclocal.m4: Copy from TCL directory.
- * configure.in: Improve checks for installed Tcl and Tk.
- * configure: Rebuilt.
-
-Tue Jun 7 13:52:34 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * Makefile.in (mostlyclean, realclean): New targets.
-
-Wed May 18 12:21:06 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * Makefile.in (install): Add another ``else true''.
-
-Fri Apr 29 16:49:36 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
-
- * Makefile.in (install): Always use else in if conditional to
- avoid Ultrix sh bug.
-
-Mon Apr 11 15:22:12 1994 Rob Savoye (rob@cirdan.cygnus.com)
-
- * Upgrade to the new "official" beta release of expect 5.7.
-
-Wed Mar 30 17:15:28 1994 Rob Savoye (rob@cirdan.cygnus.com)
-
- * testsuite/expect.tests/expect-test.exp: Just run the new expect
- tests and format the outout under DejaGnu.
-
-Mon Mar 28 14:33:55 1994 Rob Savoye (rob@cirdan.cygnus.com)
-
- * Upgrade to expect 5.6.3.
-
-Thu Dec 2 16:26:54 1993 Rob Savoye (rob@darkstar.cygnus.com)
-
- * configure.in: Add tests to find Tcl and Tk headers and
- libraries.
-
-Thu Aug 19 18:26:49 1993 Rob Savoye (rob@darkstar.cygnus.com)
-
- * upgraded to version 4.7.6, add OSF/1 patches in again.
-
-Wed Aug 18 20:10:16 1993 Rob Savoye (rob@rtl.cygnus.com)
-
- * upgraded to version 4.7.4, add OSF/1 patches in again.
-
-Tue Aug 17 20:17:40 1993 Rob Savoye (rob@darkstar.cygnus.com)
-
- * pty_termios.c, exp_command.c, configure.in: Add support for
- using ptmx_bsd's if they exist. Only found on OSF/1. (patch
- applied from Gregory Depp <depp@osf.org>
-
-Thu Jun 10 11:36:09 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * exp_main.h: fix prototype for exp_cook
-
-Fri Jun 4 08:55:22 1993 Ian Lance Taylor (ian@cygnus.com)
-
- * Makefile.in (TCLLIB): If ../tcl/libtcl.a does not exist, use
- -ltcl.
-
-Tue May 25 14:45:12 1993 Rob Savoye (rob@darkstar.cygnus.com)
-
- * Makefile.in, configure.in: Add some support for autoconfiguring
- for X.
-
-Sun May 23 22:32:09 1993 Rob Savoye (rob at darkstar.cygnus.com)
-
- * exp_command.c: Fix so send_log still works when master is out of
- bounds. (ok since it doesn't get used).
-
-Mon May 17 19:51:52 1993 Rob Savoye (rob@cygnus.com)
-
- * configure.in: Change test for ranlib so it kicks out "true"
- rather than "@:" if it can't be found.
-
-Thu Apr 15 14:11:50 1993 Rob Savoye (rob@cygnus.com)
-
- * configure.in, Makefile.in: If using ptmx's (SVR4 style pty's)
- then check for libpt.a too.
-
-Thu Apr 8 17:13:39 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in: all doesn't depend on $(SCRIPTS). When building
- $(SCRIPTS) using fixline & sources in $(srcdir), not the current
- directory. When installing manpages, install from $(srcdir).
- Don't install like "install foo $(bindir)" but rather "install foo
- $(bindir)/foo".
-
-Mon Mar 22 23:56:29 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in: add check & installcheck targets
-
-Tue Mar 2 20:28:30 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * configure.in, configure: declare SETUID to be @: instead of echo
-
- * pty_termios.c: declare ptynum
-
- * Makefile.in: a number of changes, including use of the AR and
- ARFLAGS variables, the appropriate variables for X11 (as passed
- down from the top level Makefile), clean up some doc lines
-
-Mon Mar 1 15:05:40 1993 Rob Savoye (rob at darkstar.cygnus.com)
-
- * configure.in, defs.h.in: Fixed problem for systems that think
- getpty() should be _getpty().
-
-Thu Feb 25 15:34:34 1993 Rob Savoye (rob at darkstar.cygnus.com)
-
- * exp_tty.h: Defines portable tty macros.
- * pty_termios.c: New file, slightly based on pty_usg.c. Uses
- portable macros and also supports termio.
- * pty_sgttyb.c: Was pty_bsd.c.
- * configure.in, Makefile.in, configure: autoconf support for
- expect.
-
-Sun Feb 21 17:42:28 1993 Rob Savoye (rob at darkstar.cygnus.com)
-
- * exp_tty.h: Removed and renamed the macros to use configure's.
-
-Wed Feb 17 18:56:36 1993 Rob Savoye (rob at darkstar.cygnus.com)
-
- * expect.c, Makefile.in: Changed SIG_FN_RETURN to RETSIGTYPE
- since that's what autoconf kicks out.
-
-Thu Dec 24 15:07:32 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * Makefile.in: added dummy dvi target
-
-Wed Dec 16 11:26:16 1992 Ian Lance Taylor (ian@cygnus.com)
-
- * inter_select.c (init_interact): if SCO is defined, use sysconf
- to get maxfds, rather than getdtablesize.
- * configure.in (*-*-sco*): Use mh-sco.
- * mh-sco: New file; like mh-sysv, but pass -DSCO in HDEFS.
-
-Tue Nov 17 14:28:20 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
-
- * config/mh-{hpux,aix,irix4,sysv*}: updated with appropriate
- values for the host machine (HDEFS, RANLIB, etc)
-
- * configure.in: use that
-
- * Makefile.in: use $(HDEFS) in compiling C files
-
-Sun Nov 15 21:46:16 1992 Fred Fish (fnf@cygnus.com)
-
- * Update to base 3.24.0 release, merging back in changes made
- by cygnus to 3.22.12 release.
-
-Sat Nov 14 20:16:26 1992 Fred Fish (fnf@cygnus.com)
-
- * Makefile.in (CFLAGS): Rework use of CFLAGS to fit in better with
- cygnus configuration standard.
- * config/mh-svr4: Removed.
- * config/mh-sysv4: New file, renamed from mh-svr4.
- * configure.in (*-sysv4): New configuration.
- * configure.in (*-sun-solaris2, *-sysv4): Use mh-sysv4.
- * expect.c (sigwinch_handler): Fix #if without any condition.
- * command.c, expect.c, global.h, lib_exp.c, main.c, term.h:
- Test for SYSV4 as well as SYSV3.
- * inter_select.c (sys/sysconfig.h): Include when SYSV4 defined.
- * inter_select.c (init_interact): Add sysconf call for SYSV4.
- * pty_svr4.c (ptsname): Declare for SYSV4.
-
-Thu Oct 22 17:35:07 1992 Rob Savoye (rob@cygnus.com)
-
- * command.c: Added a "send_log" command. It only writes to a log
- file if one was opened by the "log_file" command.
-
- * main.c: Added setbuf commands for stdin, stdout, stderr to turn
- off buffering.
-
+++ /dev/null
-/* Dbg.c - Tcl Debugger - See cmdHelp() for commands
-
-Written by: Don Libes, NIST, 3/23/93
-
-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.
-
-*/
-
-#include <stdio.h>
-
-#include "Dbg_cf.h"
-#if 0
-/* tclInt.h drags in stdlib. By claiming no-stdlib, force it to drag in */
-/* Tcl's compat version. This avoids having to test for its presence */
-/* which is too tricky - configure can't generate two cf files, so when */
-/* Expect (or any app) uses the debugger, there's no way to get the info */
-/* about whether stdlib exists or not, except pointing the debugger at */
-/* an app-dependent .h file and I don't want to do that. */
-#define NO_STDLIB_H
-#endif
-
-
-#include "tclInt.h"
-#include "tcl_regexp.h"
-/*#include <varargs.h> tclInt.h drags in varargs.h. Since Pyramid */
-/* objects to including varargs.h twice, just */
-/* omit this one. */
-/*#include "string.h" tclInt.h drags this in, too! */
-#include "Dbg.h"
-
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
-
-static int simple_interactor();
-static int zero();
-
-/* most of the static variables in this file may be */
-/* moved into Tcl_Interp */
-
-static Dbg_InterProc *interactor = simple_interactor;
-static ClientData interdata = 0;
-static Dbg_IgnoreFuncsProc *ignoreproc = zero;
-static Dbg_OutputProc *printproc = 0;
-static ClientData printdata = 0;
-
-static void print _ANSI_ARGS_(TCL_VARARGS(Tcl_Interp *,interp));
-
-static int debugger_active = FALSE;
-
-/* this is not externally documented anywhere as of yet */
-char *Dbg_VarName = "dbg";
-
-#define DEFAULT_COMPRESS 0
-static int compress = DEFAULT_COMPRESS;
-#define DEFAULT_WIDTH 75 /* leave a little space for printing */
- /* stack level */
-static int buf_width = DEFAULT_WIDTH;
-
-static int main_argc = 1;
-static char *default_argv = "application";
-static char **main_argv = &default_argv;
-
-static Tcl_Trace debug_handle;
-static int step_count = 1; /* count next/step */
-
-#define FRAMENAMELEN 10 /* enough to hold strings like "#4" */
-static char viewFrameName[FRAMENAMELEN];/* destination frame name for up/down */
-
-static CallFrame *goalFramePtr; /* destination for next/return */
-static int goalNumLevel; /* destination for Next */
-
-static enum debug_cmd {
- none, step, next, ret, cont, up, down, where, Next
-} debug_cmd;
-
-/* info about last action to use as a default */
-static enum debug_cmd last_action_cmd = next;
-static int last_step_count = 1;
-
-/* this acts as a strobe (while testing breakpoints). It is set to true */
-/* every time a new debugger command is issued that is an action */
-static debug_new_action;
-
-#define NO_LINE -1 /* if break point is not set by line number */
-
-struct breakpoint {
- int id;
- char *file; /* file where breakpoint is */
- int line; /* line where breakpoint is */
- char *pat; /* pattern defining where breakpoint can be */
- Expect_regexp *re; /* regular expression to trigger breakpoint */
- char *expr; /* expr to trigger breakpoint */
- char *cmd; /* cmd to eval at breakpoint */
- struct breakpoint *next, *previous;
-};
-
-static struct breakpoint *break_base = 0;
-static int breakpoint_max_id = 0;
-
-static struct breakpoint *
-breakpoint_new()
-{
- struct breakpoint *b = (struct breakpoint *)ckalloc(sizeof(struct breakpoint));
- if (break_base) break_base->previous = b;
- b->next = break_base;
- b->previous = 0;
- b->id = breakpoint_max_id++;
- b->file = 0;
- b->line = NO_LINE;
- b->pat = 0;
- b->re = 0;
- b->expr = 0;
- b->cmd = 0;
- break_base = b;
- return(b);
-}
-
-static
-void
-breakpoint_print(interp,b)
-Tcl_Interp *interp;
-struct breakpoint *b;
-{
- print(interp,"breakpoint %d: ",b->id);
-
- if (b->re) {
- print(interp,"-re \"%s\" ",b->pat);
- } else if (b->pat) {
- print(interp,"-glob \"%s\" ",b->pat);
- } else if (b->line != NO_LINE) {
- if (b->file) {
- print(interp,"%s:",b->file);
- }
- print(interp,"%d ",b->line);
- }
-
- if (b->expr)
- print(interp,"if {%s} ",b->expr);
-
- if (b->cmd)
- print(interp,"then {%s}",b->cmd);
-
- print(interp,"\n");
-}
-
-static void
-save_re_matches(interp,re)
-Tcl_Interp *interp;
-Expect_regexp *re;
-{
- int i;
- char name[20];
- char match_char;/* place to hold char temporarily */
- /* uprooted by a NULL */
-
- for (i=0;i<NSUBEXP;i++) {
- if (re->startp[i] == 0) break;
-
- sprintf(name,"%d",i);
- /* temporarily null-terminate in middle */
- match_char = *re->endp[i];
- *re->endp[i] = 0;
- Tcl_SetVar2(interp,Dbg_VarName,name,re->startp[i],0);
-
- /* undo temporary null-terminator */
- *re->endp[i] = match_char;
- }
-}
-
-/* return 1 to break, 0 to continue */
-static int
-breakpoint_test(interp,cmd,bp)
-Tcl_Interp *interp;
-char *cmd; /* command about to be executed */
-struct breakpoint *bp; /* breakpoint to test */
-{
- if (bp->re) {
- if (0 == Expect_TclRegExec(bp->re,cmd,cmd)) return 0;
- save_re_matches(interp,bp->re);
- } else if (bp->pat) {
- if (0 == Tcl_StringMatch(cmd,bp->pat)) return 0;
- } else if (bp->line != NO_LINE) {
- /* not yet implemented - awaiting support from Tcl */
- return 0;
- }
-
- if (bp->expr) {
- int value;
-
- /* ignore errors, since they are likely due to */
- /* simply being out of scope a lot */
- if (TCL_OK != Tcl_ExprBoolean(interp,bp->expr,&value)
- || (value == 0)) return 0;
- }
-
- if (bp->cmd) {
- Tcl_Eval(interp,bp->cmd);
- } else {
- breakpoint_print(interp,bp);
- }
-
- return 1;
-}
-
-static char *already_at_top_level = "already at top level";
-
-/* similar to TclGetFrame but takes two frame ptrs and a direction.
-If direction is up, search up stack from curFrame
-If direction is down, simulate searching down stack by
- seaching up stack from origFrame
-*/
-static
-int
-TclGetFrame2(interp, origFramePtr, string, framePtrPtr, dir)
- Tcl_Interp *interp;
- CallFrame *origFramePtr; /* frame that is true top-of-stack */
- char *string; /* String describing frame. */
- CallFrame **framePtrPtr; /* Store pointer to frame here (or NULL
- * if global frame indicated). */
- enum debug_cmd dir; /* look up or down the stack */
-{
- Interp *iPtr = (Interp *) interp;
- int level, result;
- CallFrame *framePtr; /* frame currently being searched */
-
- CallFrame *curFramePtr = iPtr->varFramePtr;
-
- /*
- * Parse string to figure out which level number to go to.
- */
-
- result = 1;
- if (*string == '#') {
- if (Tcl_GetInt(interp, string+1, &level) != TCL_OK) {
- return TCL_ERROR;
- }
- if (level < 0) {
- levelError:
- Tcl_AppendResult(interp, "bad level \"", string, "\"",
- (char *) NULL);
- return TCL_ERROR;
- }
- framePtr = origFramePtr; /* start search here */
-
- } else if (isdigit(*string)) {
- if (Tcl_GetInt(interp, string, &level) != TCL_OK) {
- return TCL_ERROR;
- }
- if (dir == up) {
- if (curFramePtr == 0) {
- Tcl_SetResult(interp,already_at_top_level,TCL_STATIC);
- return TCL_ERROR;
- }
- level = curFramePtr->level - level;
- framePtr = curFramePtr; /* start search here */
- } else {
- if (curFramePtr != 0) {
- level = curFramePtr->level + level;
- }
- framePtr = origFramePtr; /* start search here */
- }
- } else {
- level = curFramePtr->level - 1;
- result = 0;
- }
-
- /*
- * Figure out which frame to use.
- */
-
- if (level == 0) {
- framePtr = NULL;
- } else {
- for (;framePtr != NULL; framePtr = framePtr->callerVarPtr) {
- if (framePtr->level == level) {
- break;
- }
- }
- if (framePtr == NULL) {
- goto levelError;
- }
- }
- *framePtrPtr = framePtr;
- return result;
-}
-
-
-static char *printify(s)
-char *s;
-{
- static int destlen = 0;
- char *d; /* ptr into dest */
- unsigned int need;
- static char buf_basic[DEFAULT_WIDTH+1];
- static char *dest = buf_basic;
-
- if (s == 0) return("<null>");
-
- /* worst case is every character takes 4 to printify */
- need = strlen(s)*4;
- if (need > destlen) {
- if (dest && (dest != buf_basic)) ckfree(dest);
- dest = (char *)ckalloc(need+1);
- destlen = need;
- }
-
- for (d = dest;*s;s++) {
- /* since we check at worst by every 4 bytes, play */
- /* conservative and subtract 4 from the limit */
- if (d-dest > destlen-4) break;
-
- if (*s == '\b') {
- strcpy(d,"\\b"); d += 2;
- } else if (*s == '\f') {
- strcpy(d,"\\f"); d += 2;
- } else if (*s == '\v') {
- strcpy(d,"\\v"); d += 2;
- } else if (*s == '\r') {
- strcpy(d,"\\r"); d += 2;
- } else if (*s == '\n') {
- strcpy(d,"\\n"); d += 2;
- } else if (*s == '\t') {
- strcpy(d,"\\t"); d += 2;
- } else if ((unsigned)*s < 0x20) { /* unsigned strips parity */
- sprintf(d,"\\%03o",*s); d += 4;
- } else if (*s == 0177) {
- strcpy(d,"\\177"); d += 4;
- } else {
- *d = *s; d += 1;
- }
- }
- *d = '\0';
- return(dest);
-}
-
-static
-char *
-print_argv(interp,argc,argv)
-Tcl_Interp *interp;
-int argc;
-char *argv[];
-{
- static int buf_width_max = DEFAULT_WIDTH;
- static char buf_basic[DEFAULT_WIDTH+1]; /* basic buffer */
- static char *buf = buf_basic;
- int space; /* space remaining in buf */
- int len;
- char *bufp;
- int proc; /* if current command is "proc" */
- int arg_index;
-
- if (buf_width > buf_width_max) {
- if (buf && (buf != buf_basic)) ckfree(buf);
- buf = (char *)ckalloc(buf_width + 1);
- buf_width_max = buf_width;
- }
-
- proc = (0 == strcmp("proc",argv[0]));
- sprintf(buf,"%.*s",buf_width,argv[0]);
- len = strlen(buf);
- space = buf_width - len;
- bufp = buf + len;
- argc--; argv++;
- arg_index = 1;
-
- while (argc && (space > 0)) {
- char *elementPtr;
- char *nextPtr;
- int wrap;
-
- /* braces/quotes have been stripped off arguments */
- /* so put them back. We wrap everything except lists */
- /* with one argument. One exception is to always wrap */
- /* proc's 2nd arg (the arg list), since people are */
- /* used to always seeing it this way. */
-
- if (proc && (arg_index > 1)) wrap = TRUE;
- else {
- (void) TclFindElement(interp,*argv,
-#if TCL_MAJOR_VERSION >= 8
- -1,
-#endif
- &elementPtr,&nextPtr,(int *)0,(int *)0);
- if (*elementPtr == '\0') wrap = TRUE;
- else if (*nextPtr == '\0') wrap = FALSE;
- else wrap = TRUE;
- }
-
- /* wrap lists (or null) in braces */
- if (wrap) {
- sprintf(bufp," {%.*s}",space-3,*argv);
- } else {
- sprintf(bufp," %.*s",space-1,*argv);
- }
- len = strlen(buf);
- space = buf_width - len;
- bufp = buf + len;
- argc--; argv++;
- arg_index++;
- }
-
- if (compress) {
- /* this copies from our static buf to printify's static buf */
- /* and back to our static buf */
- strncpy(buf,printify(buf),buf_width);
- }
-
- /* usually but not always right, but assume truncation if buffer is */
- /* full. this avoids tiny but odd-looking problem of appending "}" */
- /* to truncated lists during {}-wrapping earlier */
- if (strlen(buf) == buf_width) {
- buf[buf_width-1] = buf[buf_width-2] = buf[buf_width-3] = '.';
- }
-
- return(buf);
-}
-
-#if TCL_MAJOR_VERSION >= 8
-static
-char *
-print_objv(interp,objc,objv)
-Tcl_Interp *interp;
-int objc;
-Tcl_Obj *objv[];
-{
- char **argv;
- int argc;
- int len;
- argv = (char **)ckalloc(objc+1 * sizeof(char *));
- for (argc=0 ; argc<objc ; argc++) {
- argv[argc] = Tcl_GetStringFromObj(objv[argc],&len);
- }
- argv[argc] = NULL;
- print_argv(interp,argc,argv);
-}
-#endif
-
-static
-void
-PrintStackBelow(interp,curf,viewf)
-Tcl_Interp *interp;
-CallFrame *curf; /* current FramePtr */
-CallFrame *viewf; /* view FramePtr */
-{
- char ptr; /* graphically indicate where we are in the stack */
-
- /* indicate where we are in the stack */
- ptr = ((curf == viewf)?'*':' ');
-
- if (curf == 0) {
- print(interp,"%c0: %s\n",
- ptr,print_argv(interp,main_argc,main_argv));
- } else {
- PrintStackBelow(interp,curf->callerVarPtr,viewf);
- print(interp,"%c%d: %s\n",ptr,curf->level,
-#if TCL_MAJOR_VERSION >= 8
- print_objv(interp,curf->objc,curf->objv));
-#else
- print_argv(interp,curf->argc,curf->argv));
-#endif
- }
-}
-
-static
-void
-PrintStack(interp,curf,viewf,argc,argv,level)
-Tcl_Interp *interp;
-CallFrame *curf; /* current FramePtr */
-CallFrame *viewf; /* view FramePtr */
-int argc;
-char *argv[];
-char *level;
-{
- PrintStackBelow(interp,curf,viewf);
-
- print(interp," %s: %s\n",level,print_argv(interp,argc,argv));
-}
-
-/* return 0 if goal matches current frame or goal can't be found */
-/* anywere in frame stack */
-/* else return 1 */
-/* This catches things like a proc called from a Tcl_Eval which in */
-/* turn was not called from a proc but some builtin such as source */
-/* or Tcl_Eval. These builtin calls to Tcl_Eval lose any knowledge */
-/* the FramePtr from the proc, so we have to search the entire */
-/* stack frame to see if it's still there. */
-static int
-GoalFrame(goal,iptr)
-CallFrame *goal;
-Interp *iptr;
-{
- CallFrame *cf = iptr->varFramePtr;
-
- /* if at current level, return success immediately */
- if (goal == cf) return 0;
-
- while (cf) {
- cf = cf->callerVarPtr;
- if (goal == cf) {
- /* found, but since it's above us, fail */
- return 1;
- }
- }
- return 0;
-}
-
-/* debugger's trace handler */
-/*ARGSUSED*/
-static void
-debugger_trap(clientData,interp,level,command,cmdProc,cmdClientData,argc,argv)
-ClientData clientData; /* not used */
-Tcl_Interp *interp;
-int level; /* positive number if called by Tcl, -1 if */
- /* called by Dbg_On in which case we don't */
- /* know the level */
-char *command;
-int (*cmdProc)(); /* not used */
-ClientData cmdClientData;
-int argc;
-char *argv[];
-{
- char level_text[6]; /* textual representation of level */
-
- int break_status;
- Interp *iPtr = (Interp *)interp;
-
- CallFrame *trueFramePtr; /* where the pc is */
- CallFrame *viewFramePtr; /* where up/down are */
-
- int print_command_first_time = TRUE;
- static int debug_suspended = FALSE;
-
- struct breakpoint *b;
-
- /* skip commands that are invoked interactively */
- if (debug_suspended) return;
-
- /* skip debugger commands */
- if (argv[0][1] == '\0') {
- switch (argv[0][0]) {
- case 'n':
- case 's':
- case 'c':
- case 'r':
- case 'w':
- case 'b':
- case 'u':
- case 'd': return;
- }
- }
-
- if ((*ignoreproc)(interp,argv[0])) return;
-
- /* if level is unknown, use "?" */
- sprintf(level_text,(level == -1)?"?":"%d",level);
-
- /* save so we can restore later */
- trueFramePtr = iPtr->varFramePtr;
-
- /* do not allow breaking while testing breakpoints */
- debug_suspended = TRUE;
-
- /* test all breakpoints to see if we should break */
- /* if any successful breakpoints, start interactor */
- debug_new_action = FALSE; /* reset strobe */
- break_status = FALSE; /* no successful breakpoints yet */
- for (b = break_base;b;b=b->next) {
- break_status |= breakpoint_test(interp,command,b);
- }
- if (break_status) {
- if (!debug_new_action) goto start_interact;
-
- /* if s or n triggered by breakpoint, make "s 1" */
- /* (and so on) refer to next command, not this one */
-/* step_count++;*/
- goto end_interact;
- }
-
- switch (debug_cmd) {
- case cont:
- goto finish;
- case step:
- step_count--;
- if (step_count > 0) goto finish;
- goto start_interact;
- case next:
- /* check if we are back at the same level where the next */
- /* command was issued. Also test */
- /* against all FramePtrs and if no match, assume that */
- /* we've missed a return, and so we should break */
-/* if (goalFramePtr != iPtr->varFramePtr) goto finish;*/
- if (GoalFrame(goalFramePtr,iPtr)) goto finish;
- step_count--;
- if (step_count > 0) goto finish;
- goto start_interact;
- case Next:
- /* check if we are back at the same level where the next */
- /* command was issued. */
- if (goalNumLevel < iPtr->numLevels) goto finish;
- step_count--;
- if (step_count > 0) goto finish;
- goto start_interact;
- case ret:
- /* same comment as in "case next" */
- if (goalFramePtr != iPtr->varFramePtr) goto finish;
- goto start_interact;
- }
-
-start_interact:
- if (print_command_first_time) {
- print(interp,"%s: %s\n",
- level_text,print_argv(interp,1,&command));
- print_command_first_time = FALSE;
- }
- /* since user is typing a command, don't interrupt it immediately */
- debug_cmd = cont;
- debug_suspended = TRUE;
-
- /* interactor won't return until user gives a debugger cmd */
- (*interactor)(interp,interdata);
-end_interact:
-
- /* save this so it can be restored after "w" command */
- viewFramePtr = iPtr->varFramePtr;
-
- if (debug_cmd == up || debug_cmd == down) {
- /* calculate new frame */
- if (-1 == TclGetFrame2(interp,trueFramePtr,viewFrameName,
- &iPtr->varFramePtr,debug_cmd)) {
- print(interp,"%s\n",interp->result);
- Tcl_ResetResult(interp);
- }
- goto start_interact;
- }
-
- /* reset view back to normal */
- iPtr->varFramePtr = trueFramePtr;
-
-#if 0
- /* allow trapping */
- debug_suspended = FALSE;
-#endif
-
- switch (debug_cmd) {
- case cont:
- case step:
- goto finish;
- case next:
- goalFramePtr = iPtr->varFramePtr;
- goto finish;
- case Next:
- goalNumLevel = iPtr->numLevels;
- goto finish;
- case ret:
- goalFramePtr = iPtr->varFramePtr;
- if (goalFramePtr == 0) {
- print(interp,"nowhere to return to\n");
- break;
- }
- goalFramePtr = goalFramePtr->callerVarPtr;
- goto finish;
- case where:
- PrintStack(interp,iPtr->varFramePtr,viewFramePtr,argc,argv,level_text);
- break;
- }
-
- /* restore view and restart interactor */
- iPtr->varFramePtr = viewFramePtr;
- goto start_interact;
-
- finish:
- debug_suspended = FALSE;
-}
-
-/*ARGSUSED*/
-static
-int
-cmdNext(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- debug_new_action = TRUE;
- debug_cmd = *(enum debug_cmd *)clientData;
- last_action_cmd = debug_cmd;
-
- step_count = (argc == 1)?1:atoi(argv[1]);
- last_step_count = step_count;
- return(TCL_RETURN);
-}
-
-/*ARGSUSED*/
-static
-int
-cmdDir(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- debug_cmd = *(enum debug_cmd *)clientData;
-
- if (argc == 1) argv[1] = "1";
- strncpy(viewFrameName,argv[1],FRAMENAMELEN);
-
- return TCL_RETURN;
-}
-
-/*ARGSUSED*/
-static
-int
-cmdSimple(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- debug_new_action = TRUE;
- debug_cmd = *(enum debug_cmd *)clientData;
- last_action_cmd = debug_cmd;
-
- return TCL_RETURN;
-}
-
-static
-void
-breakpoint_destroy(b)
-struct breakpoint *b;
-{
- if (b->file) ckfree(b->file);
- if (b->pat) ckfree(b->pat);
- if (b->re) ckfree((char *)b->re);
- if (b->cmd) ckfree(b->cmd);
-
- /* unlink from chain */
- if ((b->previous == 0) && (b->next == 0)) {
- break_base = 0;
- } else if (b->previous == 0) {
- break_base = b->next;
- b->next->previous = 0;
- } else if (b->next == 0) {
- b->previous->next = 0;
- } else {
- b->previous->next = b->next;
- b->next->previous = b->previous;
- }
-
- ckfree((char *)b);
-}
-
-static void
-savestr(straddr,str)
-char **straddr;
-char *str;
-{
- *straddr = ckalloc(strlen(str)+1);
- strcpy(*straddr,str);
-}
-
-/* return 1 if a string is substring of a flag */
-static int
-flageq(flag,string,minlen)
-char *flag;
-char *string;
-int minlen; /* at least this many chars must match */
-{
- for (;*flag;flag++,string++,minlen--) {
- if (*string == '\0') break;
- if (*string != *flag) return 0;
- }
- if (*string == '\0' && minlen <= 0) return 1;
- return 0;
-}
-
-/*ARGSUSED*/
-static
-int
-cmdWhere(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- if (argc == 1) {
- debug_cmd = where;
- return TCL_RETURN;
- }
-
- argc--; argv++;
-
- while (argc) {
- if (flageq("-width",*argv,2)) {
- argc--; argv++;
- if (*argv) {
- buf_width = atoi(*argv);
- argc--; argv++;
- } else print(interp,"%d\n",buf_width);
- } else if (flageq("-compress",*argv,2)) {
- argc--; argv++;
- if (*argv) {
- compress = atoi(*argv);
- argc--; argv++;
- } else print(interp,"%d\n",compress);
- } else {
- print(interp,"usage: w [-width #] [-compress 0|1]\n");
- return TCL_ERROR;
- }
- }
- return TCL_OK;
-}
-
-#define breakpoint_fail(msg) {error_msg = msg; goto break_fail;}
-
-/*ARGSUSED*/
-static
-int
-cmdBreak(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- struct breakpoint *b;
- char *error_msg;
-
- argc--; argv++;
-
- if (argc < 1) {
- for (b = break_base;b;b=b->next) breakpoint_print(interp,b);
- return(TCL_OK);
- }
-
- if (argv[0][0] == '-') {
- if (argv[0][1] == '\0') {
- while (break_base) {
- breakpoint_destroy(break_base);
- }
- breakpoint_max_id = 0;
- return(TCL_OK);
- } else if (isdigit(argv[0][1])) {
- int id = atoi(argv[0]+1);
-
- for (b = break_base;b;b=b->next) {
- if (b->id == id) {
- breakpoint_destroy(b);
- if (!break_base) breakpoint_max_id = 0;
- return(TCL_OK);
- }
- }
- Tcl_SetResult(interp,"no such breakpoint",TCL_STATIC);
- return(TCL_ERROR);
- }
- }
-
- b = breakpoint_new();
-
- if (flageq("-regexp",argv[0],2)) {
- argc--; argv++;
- if ((argc > 0) && (b->re = Expect_TclRegComp(argv[0]))) {
- savestr(&b->pat,argv[0]);
- argc--; argv++;
- } else {
- breakpoint_fail("bad regular expression")
- }
- } else if (flageq("-glob",argv[0],2)) {
- argc--; argv++;
- if (argc > 0) {
- savestr(&b->pat,argv[0]);
- argc--; argv++;
- } else {
- breakpoint_fail("no pattern?");
- }
- } else if ((!(flageq("if",*argv,1)) && (!(flageq("then",*argv,1))))) {
- /* look for [file:]line */
- char *colon;
- char *linep; /* pointer to beginning of line number */
-
- colon = strchr(argv[0],':');
- if (colon) {
- *colon = '\0';
- savestr(&b->file,argv[0]);
- *colon = ':';
- linep = colon + 1;
- } else {
- linep = argv[0];
- /* get file from current scope */
- /* savestr(&b->file, ?); */
- }
-
- if (TCL_OK == Tcl_GetInt(interp,linep,&b->line)) {
- argc--; argv++;
- print(interp,"setting breakpoints by line number is currently unimplemented - use patterns or expressions\n");
- } else {
- /* not an int? - unwind & assume it is an expression */
-
- if (b->file) ckfree(b->file);
- }
- }
-
- if (argc > 0) {
- int do_if = FALSE;
-
- if (flageq("if",argv[0],1)) {
- argc--; argv++;
- do_if = TRUE;
- } else if (!flageq("then",argv[0],1)) {
- do_if = TRUE;
- }
-
- if (do_if) {
- if (argc < 1) {
- breakpoint_fail("if what");
- }
-
- savestr(&b->expr,argv[0]);
- argc--; argv++;
- }
- }
-
- if (argc > 0) {
- if (flageq("then",argv[0],1)) {
- argc--; argv++;
- }
-
- if (argc < 1) {
- breakpoint_fail("then what?");
- }
-
- savestr(&b->cmd,argv[0]);
- }
-
- sprintf(interp->result,"%d",b->id);
- return(TCL_OK);
-
- break_fail:
- breakpoint_destroy(b);
- Tcl_SetResult(interp,error_msg,TCL_STATIC);
- return(TCL_ERROR);
-}
-
-static char *help[] = {
-"s [#] step into procedure",
-"n [#] step over procedure",
-"N [#] step over procedures, commands, and arguments",
-"c continue",
-"r continue until return to caller",
-"u [#] move scope up level",
-"d [#] move scope down level",
-" go to absolute frame if # is prefaced by \"#\"",
-"w show stack (\"where\")",
-"w -w [#] show/set width",
-"w -c [0|1] show/set compress",
-"b show breakpoints",
-"b [-r regexp-pattern] [if expr] [then command]",
-"b [-g glob-pattern] [if expr] [then command]",
-"b [[file:]#] [if expr] [then command]",
-" if pattern given, break if command resembles pattern",
-" if # given, break on line #",
-" if expr given, break if expr true",
-" if command given, execute command at breakpoint",
-"b -# delete breakpoint",
-"b - delete all breakpoints",
-0};
-
-/*ARGSUSED*/
-static
-int
-cmdHelp(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- char **hp;
-
- for (hp=help;*hp;hp++) {
- print(interp,"%s\n",*hp);
- }
-
- return(TCL_OK);
-}
-
-/* occasionally, we print things larger buf_max but not by much */
-/* see print statements in PrintStack routines for examples */
-#define PAD 80
-
-/*VARARGS*/
-static void
-print TCL_VARARGS_DEF(Tcl_Interp *,arg1)
-{
- Tcl_Interp *interp;
- char *fmt;
- va_list args;
-
- interp = TCL_VARARGS_START(Tcl_Interp *,arg1,args);
- fmt = va_arg(args,char *);
- if (!printproc) vprintf(fmt,args);
- else {
- static int buf_width_max = DEFAULT_WIDTH+PAD;
- static char buf_basic[DEFAULT_WIDTH+PAD+1];
- static char *buf = buf_basic;
-
- if (buf_width+PAD > buf_width_max) {
- if (buf && (buf != buf_basic)) ckfree(buf);
- buf = (char *)ckalloc(buf_width+PAD+1);
- buf_width_max = buf_width+PAD;
- }
-
- vsprintf(buf,fmt,args);
- (*printproc)(interp,buf,printdata);
- }
- va_end(args);
-}
-
-/*ARGSUSED*/
-Dbg_InterStruct
-Dbg_Interactor(interp,inter_proc,data)
-Tcl_Interp *interp;
-Dbg_InterProc *inter_proc;
-ClientData data;
-{
- Dbg_InterStruct tmp;
-
- tmp.func = interactor;
- tmp.data = interdata;
- interactor = (inter_proc?inter_proc:simple_interactor);
- interdata = data;
- return tmp;
-}
-
-/*ARGSUSED*/
-Dbg_IgnoreFuncsProc *
-Dbg_IgnoreFuncs(interp,proc)
-Tcl_Interp *interp;
-Dbg_IgnoreFuncsProc *proc;
-{
- Dbg_IgnoreFuncsProc *tmp = ignoreproc;
- ignoreproc = (proc?proc:zero);
- return tmp;
-}
-
-/*ARGSUSED*/
-Dbg_OutputStruct
-Dbg_Output(interp,proc,data)
-Tcl_Interp *interp;
-Dbg_OutputProc *proc;
-ClientData data;
-{
- Dbg_OutputStruct tmp;
-
- tmp.func = printproc;
- tmp.data = printdata;
- printproc = proc;
- printdata = data;
- return tmp;
-}
-
-/*ARGSUSED*/
-int
-Dbg_Active(interp)
-Tcl_Interp *interp;
-{
- return debugger_active;
-}
-
-char **
-Dbg_ArgcArgv(argc,argv,copy)
-int argc;
-char *argv[];
-int copy;
-{
- char **alloc;
-
- main_argc = argc;
-
- if (!copy) {
- main_argv = argv;
- alloc = 0;
- } else {
- main_argv = alloc = (char **)ckalloc((argc+1)*sizeof(char *));
- while (argc-- >= 0) {
- *main_argv++ = *argv++;
- }
- main_argv = alloc;
- }
- return alloc;
-}
-
-static struct cmd_list {
- char *cmdname;
- Tcl_CmdProc *cmdproc;
- enum debug_cmd cmdtype;
-} cmd_list[] = {
- {"n", cmdNext, next},
- {"s", cmdNext, step},
- {"N", cmdNext, Next},
- {"c", cmdSimple, cont},
- {"r", cmdSimple, ret},
- {"w", cmdWhere, none},
- {"b", cmdBreak, none},
- {"u", cmdDir, up},
- {"d", cmdDir, down},
- {"h", cmdHelp, none},
- {0}
-};
-
-/* this may seem excessive, but this avoids the explicit test for non-zero */
-/* in the caller, and chances are that that test will always be pointless */
-/*ARGSUSED*/
-static int zero(interp,string)
-Tcl_Interp *interp;
-char *string;
-{
- return 0;
-}
-
-static int
-simple_interactor(interp)
-Tcl_Interp *interp;
-{
- int rc;
- char *ccmd; /* pointer to complete command */
- char line[BUFSIZ+1]; /* space for partial command */
- int newcmd = TRUE;
- Interp *iPtr = (Interp *)interp;
-
- Tcl_DString dstring;
- Tcl_DStringInit(&dstring);
-
- newcmd = TRUE;
- while (TRUE) {
- struct cmd_list *c;
-
- if (newcmd) {
-#if TCL_MAJOR_VERSION < 8
- print(interp,"dbg%d.%d> ",iPtr->numLevels,iPtr->curEventNum+1);
-#else
- /* unncessarily tricky coding - if nextid
- isn't defined, maintain our own static
- version */
-
- static int nextid = 0;
- char *nextidstr = Tcl_GetVar2(interp,"tcl::history","nextid",0);
- if (nextidstr) {
- sscanf(nextidstr,"%d",&nextid);
- }
- print(interp,"dbg%d.%d> ",iPtr->numLevels,nextid++);
-#endif
- } else {
- print(interp,"dbg+> ");
- }
- fflush(stdout);
-
- if (0 >= (rc = read(0,line,BUFSIZ))) {
- if (!newcmd) line[0] = 0;
- else exit(0);
- } else line[rc] = '\0';
-
- ccmd = Tcl_DStringAppend(&dstring,line,rc);
- if (!Tcl_CommandComplete(ccmd)) {
- newcmd = FALSE;
- continue; /* continue collecting command */
- }
- newcmd = TRUE;
-
- /* if user pressed return with no cmd, use previous one */
- if ((ccmd[0] == '\n' || ccmd[0] == '\r') && ccmd[1] == '\0') {
-
- /* this loop is guaranteed to exit through break */
- for (c = cmd_list;c->cmdname;c++) {
- if (c->cmdtype == last_action_cmd) break;
- }
-
- /* recreate textual version of command */
- Tcl_DStringAppend(&dstring,c->cmdname,-1);
-
- if (c->cmdtype == step ||
- c->cmdtype == next ||
- c->cmdtype == Next) {
- char num[10];
-
- sprintf(num," %d",last_step_count);
- Tcl_DStringAppend(&dstring,num,-1);
- }
- }
-
-#if TCL_MAJOR_VERSION == 7 && TCL_MINOR_VERSION < 4
- rc = Tcl_RecordAndEval(interp,ccmd,0);
-#else
- rc = Tcl_RecordAndEval(interp,ccmd,TCL_NO_EVAL);
- rc = Tcl_Eval(interp,ccmd);
-#endif
- Tcl_DStringFree(&dstring);
-
- switch (rc) {
- case TCL_OK:
- if (*interp->result != 0)
- print(interp,"%s\n",interp->result);
- continue;
- case TCL_ERROR:
- print(interp,"%s\n",Tcl_GetVar(interp,"errorInfo",TCL_GLOBAL_ONLY));
- /* since user is typing by hand, we expect lots
- of errors, and want to give another chance */
- continue;
- case TCL_BREAK:
- case TCL_CONTINUE:
-#define finish(x) {rc = x; goto done;}
- finish(rc);
- case TCL_RETURN:
- finish(TCL_OK);
- default:
- /* note that ccmd has trailing newline */
- print(interp,"error %d: %s\n",rc,ccmd);
- continue;
- }
- }
- /* cannot fall thru here, must jump to label */
- done:
- Tcl_DStringFree(&dstring);
-
- return(rc);
-}
-
-static char init_auto_path[] = "lappend auto_path $dbg_library";
-
-static void
-init_debugger(interp)
-Tcl_Interp *interp;
-{
- struct cmd_list *c;
-
- for (c = cmd_list;c->cmdname;c++) {
- Tcl_CreateCommand(interp,c->cmdname,c->cmdproc,
- (ClientData)&c->cmdtype,(Tcl_CmdDeleteProc *)0);
- }
-
- debug_handle = Tcl_CreateTrace(interp,
- 10000,debugger_trap,(ClientData)0);
-
- debugger_active = TRUE;
- Tcl_SetVar2(interp,Dbg_VarName,"active","1",0);
-#ifdef DBG_SCRIPTDIR
- Tcl_SetVar(interp,"dbg_library",DBG_SCRIPTDIR,0);
-#endif
- Tcl_Eval(interp,init_auto_path);
-
-}
-
-/* allows any other part of the application to jump to the debugger */
-/*ARGSUSED*/
-void
-Dbg_On(interp,immediate)
-Tcl_Interp *interp;
-int immediate; /* if true, stop immediately */
- /* should only be used in safe places */
- /* i.e., when Tcl_Eval can be called */
-{
- if (!debugger_active) init_debugger(interp);
-
- debug_cmd = step;
- step_count = 1;
-
- if (immediate) {
- static char *fake_cmd = "--interrupted-- (command_unknown)";
-
- debugger_trap((ClientData)0,interp,-1,fake_cmd,(int (*)())0,
- (ClientData)0,1,&fake_cmd);
-/* (*interactor)(interp);*/
- }
-}
-
-void
-Dbg_Off(interp)
-Tcl_Interp *interp;
-{
- struct cmd_list *c;
-
- if (!debugger_active) return;
-
- for (c = cmd_list;c->cmdname;c++) {
- Tcl_DeleteCommand(interp,c->cmdname);
- }
-
- Tcl_DeleteTrace(interp,debug_handle);
- debugger_active = FALSE;
- Tcl_UnsetVar(interp,Dbg_VarName,TCL_GLOBAL_ONLY);
-}
+++ /dev/null
-/* Dbg.h - Tcl Debugger include file
-
-Written by: Don Libes, NIST, 3/23/93
-
-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.
-
-*/
-
-/* _DEBUG or _DBG is just too likely, use something more unique */
-#ifndef _NIST_DBG
-#define _NIST_DBG
-
-#include "tcl.h"
-
-typedef int (Dbg_InterProc) _ANSI_ARGS_((Tcl_Interp *interp, ClientData data));
-typedef int (Dbg_IgnoreFuncsProc) _ANSI_ARGS_((
- Tcl_Interp *interp,
- char *funcname));
-typedef void (Dbg_OutputProc) _ANSI_ARGS_((
- Tcl_Interp *interp,
- char *output,
- ClientData data));
-
-typedef struct {
- Dbg_InterProc *func;
- ClientData data;
-} Dbg_InterStruct;
-
-typedef struct {
- Dbg_OutputProc *func;
- ClientData data;
-} Dbg_OutputStruct;
-
-EXTERN char *Dbg_VarName;
-EXTERN char *Dbg_DefaultCmdName;
-
-/* trivial interface, creates a "debug" command in your interp */
-EXTERN int Dbg_Init _ANSI_ARGS_((Tcl_Interp *));
-
-EXTERN void Dbg_On _ANSI_ARGS_((Tcl_Interp *interp,
- int immediate));
-EXTERN void Dbg_Off _ANSI_ARGS_((Tcl_Interp *interp));
-EXTERN char **Dbg_ArgcArgv _ANSI_ARGS_((int argc,char *argv[],
- int copy));
-EXTERN int Dbg_Active _ANSI_ARGS_((Tcl_Interp *interp));
-EXTERN Dbg_InterStruct Dbg_Interactor _ANSI_ARGS_((
- Tcl_Interp *interp,
- Dbg_InterProc *interactor,
- ClientData data));
-EXTERN Dbg_IgnoreFuncsProc *Dbg_IgnoreFuncs _ANSI_ARGS_((
- Tcl_Interp *interp,
- Dbg_IgnoreFuncsProc *));
-EXTERN Dbg_OutputStruct Dbg_Output _ANSI_ARGS_((
- Tcl_Interp *interp,
- Dbg_OutputProc *,
- ClientData data));
-
-#endif /* _NIST_DBG */
+++ /dev/null
-#
-# Makefile for tcl debugger
-#
-
-VERSION = \"@DBG_VERSION_FULL@\"
-SHORT_VERSION = @DBG_VERSION@
-
-# Compatible with Tcl version 7.5
-# Compatible with Tk version 4.1
-
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-######################################################################
-# The following lines are things you are likely to want to change
-######################################################################
-
-# Tcl include files. (If you haven't installed Tcl yet, read the README file).
-# This must point to the directory that contains ALL of Tcl's include
-# files, not just the public ones.
-TCLHDIR = @TCLHDIRDASHI@
-
-# flags to pass to cc
-# You should be able to leave this just the way it is. However, here are some
-# note if you run into problems:
-#
-# Avoid -O (optimize) unless you are convinced your optimizer is flawless
-# (hint: not a chance). I have heard many reports of -O causing Expect to
-# misbehave.
-# I encourage you to use -g (debugging). While it is unlikely you will
-# encounter an internal error in Expect, should this happen, I may just need
-# the -g information and then you will need to recompile Expect. As an aside,
-# Expect is not a space or time pig, so this won't affect the performance of
-# your Expect scripts.
-# Note: On Linux systems which only have dynamic X libraries, the -g prevents
-# the linker from using them. So do not use -g on such systems.
-CFLAGS = @DBG_CFLAGS@ @DBG_SHLIB_CFLAGS@
-
-# which C compiler to use
-CC = @CC@
-
-# By default, `make install' will install the appropriate files in
-# /usr/local/bin, /usr/local/lib, /usr/local/man, etc. You can specify
-# an installation prefix other than /usr/local here:
-prefix = @prefix@
-
-# You can specify a separate installation prefix for architecture-specific
-# files such as binaries and libraries.
-exec_prefix = @exec_prefix@
-
-# If you have ranlib but it should be avoided, change this from "ranlib" #
-# to something innocuous like "echo". Known systems with this problem:
-# older SCO boxes.
-UNSHARED_RANLIB = @UNSHARED_RANLIB@
-
-######################################################################
-# End of things you are likely to want to change
-######################################################################
-
-libdir = $(exec_prefix)/lib
-datadir = $(prefix)/lib
-
-mandir = @mandir@
-man1dir = $(mandir)/man1
-includedir = $(prefix)/include
-
-# Where to store utility scripts. This corresponds to the variable
-# "dbg_library".
-DBG_SCRIPTDIR = $(datadir)/dbg
-
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_DATA = @INSTALL_DATA@
-
-AR = ar
-ARFLAGS = cr
-
-# TCLHDIR includes "-I"
-CPPFLAGS = -I. -I$(srcdir) $(TCLHDIR) \
- -DDBG_VERSION=$(VERSION) \
- -DDBG_SCRIPTDIR=\"$(DBG_SCRIPTDIR)\"
-
-CFLAGS_INT = $(MH_CFLAGS) $(CPPFLAGS) $(CFLAGS)
-
-.c.o:
- $(CC) -c $(CFLAGS_INT) $(HDEFS) $<
-
-CFILES = Dbg.c Dbg_cmd.c
-OFILES = Dbg.o Dbg_cmd.o
-
-# libraries (both .a and shared)
-DBG_LIB_FILES = @DBG_LIB_FILES@
-# default Dbg library (shared if possible, otherwise static)
-DBG_LIB_FILE = @DBG_LIB_FILE@
-# Dbg object library (.a)
-DBG_UNSHARED_LIB_FILE = @DBG_UNSHARED_LIB_FILE@
-# Dbg object library (shared, if possible)
-DBG_SHARED_LIB_FILE = @DBG_SHARED_LIB_FILE@
-
-all: $(DBG_LIB_FILES)
-
-$(DBG_UNSHARED_LIB_FILE): $(OFILES)
- -rm -f $(DBG_UNSHARED_LIB_FILE)
- $(AR) $(ARFLAGS) $(DBG_UNSHARED_LIB_FILE) $(OFILES)
- -$(UNSHARED_RANLIB) $(DBG_UNSHARED_LIB_FILE)
-
-$(DBG_SHARED_LIB_FILE): $(OFILES)
- -rm -f $(DBG_SHARED_LIB_FILE)
- @TCL_SHLIB_LD@ -o $(DBG_SHARED_LIB_FILE) $(OFILES)
-
-# Delete all the installed files that the `install' target creates
-# (but not the noninstalled files such as `make all' creates)
-uninstall:
- -rm -f $(man1dir)/tcldbg.1 \
- $(libdir)/$(DBG_SHARED_LIB_FILE) \
- $(libdir)/$(DBG_UNSHARED_LIB_FILE) \
- $(includedir)/Dbg.h \
- $(DBG_SCRIPTDIR)/pkgIndex.tcl
-
-install: $(DBG_LIB_FILES)
- ${srcdir}/mkinstalldirs $(man1dir) $(libdir) $(includedir) $(DBG_SCRIPTDIR)
- $(INSTALL_DATA) $(srcdir)/tcldbg.man $(man1dir)/tcldbg.1
- if [ -s $(DBG_UNSHARED_LIB_FILE) ] ; then \
- $(INSTALL_DATA) $(DBG_UNSHARED_LIB_FILE) $(libdir)/$(DBG_UNSHARED_LIB_FILE) ; \
- $(UNSHARED_RANLIB) $(libdir)/$(DBG_UNSHARED_LIB_FILE) ; \
- fi
- if [ -s $(DBG_SHARED_LIB_FILE) ] ; then \
- $(INSTALL_DATA) $(DBG_SHARED_LIB_FILE) $(libdir)/$(DBG_SHARED_LIB_FILE) ; \
- fi
- $(INSTALL_DATA) $(srcdir)/Dbg.h $(includedir)
-# create utility-script directory
- $(INSTALL_DATA) $(srcdir)/Dbg_lib.tcl $(DBG_SCRIPTDIR)
- $(INSTALL_DATA) $(srcdir)/tclIndex $(DBG_SCRIPTDIR)
-
-
-###################################
-# Targets for Makefile and configure
-###################################
-
-Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) config.status
- @echo "Rebuilding the Makefile..."
- $(SHELL) config.status
-
-configure: $(srcdir)/configure.in $(srcdir)/Makefile.in $(srcdir)/aclocal.m4
- autoconf configure.in > configure
- -@chmod a+x configure
- -rm -f config.cache
-
-config.status: $(srcdir)/configure
- @echo "Rebuilding config.status..."
- $(SHELL) ./config.status --recheck
-
-################################################
-# Various "clean" targets follow GNU conventions
-################################################
-
-clean:
- -rm -f *~ *.o core \
- $(DBG_UNSHARED_LIB_FILE) $(DBG_SHARED_LIB_FILE)
-
-# like "clean", but also delete files created by "configure"
-distclean: clean
- -rm -f Makefile config.status config.cache config.log Dbg_cf.h
-
-# like "clean", but doesn't delete test utilities or massaged scripts
-# because most people don't have to worry about them
-mostlyclean:
- -rm -f *~ *.o core \
- $(DBG_UNSHARED_LIB_FILE) $(DBG_SHARED_LIB_FILE)
-
-# delete everything from current directory that can be reconstructed
-# except for configure
-realclean: distclean
-
-tclIndex: Dbg_lib.tcl
- expect -c "auto_mkindex . *.tcl;exit"
-
-LINTFLAGS = -h -q -x
-
-lint:
- lint $(LINTFLAGS) $(CPPFLAGS) $(CFILES) $(TCLLINTLIB) | tee debug.lint
-
-##################################
-# Targets for development at NIST
-##################################
-
-nist:
- configure --verbose --prefix=/depot/tcl --exec-prefix=/depot/tcl/arch
-
-# report globals that shouldn't be public but are
-bad_globals:
- nm $(DBG_UNSHARED_LIB_FILE) | egrep -v " [a-zU] | _Dbg"
-
-# after copying source directory, restablish all links
-symlink:
- rm -f aclocal.m4
- ln -s ../expect/aclocal.m4
-
-######################################
-# Targets for pushing out releases
-######################################
-
-FTPDIR = /proj/itl/www/div826/subject/expect/tcl-debug
-
-ftp: tcl-debug-$(SHORT_VERSION).tar.Z tcl-debug-$(SHORT_VERSION).tar.gz
- cp tcl-debug-$(SHORT_VERSION).tar.Z $(FTPDIR)/tcl-debug.tar.Z
- cp tcl-debug-$(SHORT_VERSION).tar.gz $(FTPDIR)/tcl-debug.tar.gz
- cp HISTORY $(FTPDIR)
- cp README $(FTPDIR)/README.distribution
- rm tcl-debug-$(SHORT_VERSION).tar*
- ls -l $(FTPDIR)/tcl-debug.tar*
-
-# make an alpha relase and install it on ftp server
-alpha: tcl-debug-$(SHORT_VERSION).tar.Z tcl-debug-$(SHORT_VERSION).tar.gz
- cp tcl-debug-$(SHORT_VERSION).tar.Z $(FTPDIR)/tcl-debug-alpha.tar.Z
- cp tcl-debug-$(SHORT_VERSION).tar.gz $(FTPDIR)/tcl-debug-alpha.tar.gz
- rm tcl-debug-$(SHORT_VERSION).tar*
- ls -l $(FTPDIR)/tcl-debug-alpha.tar*
-
-tcl-debug-$(SHORT_VERSION).tar:
- rm -f ../tcl-debug-$(SHORT_VERSION)
- ln -s `pwd` ../tcl-debug-$(SHORT_VERSION)
- cd ..;tar cvfh $@ `pubfile tcl-debug-$(SHORT_VERSION)`
- mv ../$@ .
-
-tcl-debug-$(SHORT_VERSION).tar.Z: tcl-debug-$(SHORT_VERSION).tar
- compress -fc tcl-debug-$(SHORT_VERSION).tar > $@
-
-tcl-debug-$(SHORT_VERSION).tar.gz: tcl-debug-$(SHORT_VERSION).tar
- gzip -fc tcl-debug-$(SHORT_VERSION).tar > $@
-
-Dbg.o: $(srcdir)/Dbg.c $(srcdir)/Dbg.h
+++ /dev/null
-/* This file is only to be included by the Debugger itself. */
-/* Applications should only include Dbg.h. */
-
-/*
- * Check for headers
- */
-#ifndef __NIST_DBG_CF_H__
-#define __NIST_DBG_CF_H__
-
-#undef NO_STDLIB_H /* Tcl requires this name */
-
-/*
- * Check for functions
- */
-#undef HAVE_STRCHR
-
-#ifndef HAVE_STRCHR
-#define strchr(s,c) index(s,c)
-#endif /* HAVE_STRCHR */
-
-#endif /* __NIST_DBG_CF_H__ */
+++ /dev/null
-dnl Process this file with autoconf to produce a configure script.
-
-AC_INIT(Dbg.h)
-
-DBG_MAJOR_VERSION=1
-DBG_MINOR_VERSION=7
-DBG_MICRO_VERSION=0
-DBG_VERSION=$DBG_MAJOR_VERSION.$DBG_MINOR_VERSION
-DBG_VERSION_FULL=$DBG_VERSION.$DBG_MICRO_VERSION
-# Tcl's handling of shared_lib_suffix requires this symbol exist
-VERSION=$DBG_MAJOR_VERSION.$DBG_MINOR_VERSION
-
-AC_CONFIG_HEADER(Dbg_cf.h)
-
-CY_AC_PATH_TCLCONFIG
-CY_AC_LOAD_TCLCONFIG
-CC=$TCL_CC
-AC_PROG_CC
-CY_AC_C_WORKS
-
-# this'll use a BSD compatible install or our included install-sh
-AC_PROG_INSTALL
-
-# Tcl sets TCL_RANLIB appropriately for shared library if --enable-shared
-AC_PROG_RANLIB
-UNSHARED_RANLIB=$RANLIB
-
-# This is for LynxOS, which needs a flag to force true POSIX when
-# building. It's weirder than that, cause the flag varies depending
-# how old the compiler is. So...
-# -X is for the old "cc" and "gcc" (based on 1.42)
-# -mposix is for the new gcc (at least 2.5.8)
-# This modifies the value of $CC to have the POSIX flag added
-# so it'll configure correctly
-CY_AC_TCL_LYNX_POSIX
-
-# we really only need the header files
-CY_AC_PATH_TCLH
-if test x"$no_tcl" = x"true" ; then
- echo " ERROR: Can't find Tcl directory"
- echo " See README for information on how to obtain Tcl."
- echo " If Tcl is installed, see INSTALL on how to tell"
- echo " configure where Tcl is installed."
- exit 1
-fi
-
-# Use -g on all systems but Linux where it upsets the dynamic X libraries.
-AC_MSG_CHECKING([if we are running Linux])
-if test "x`(uname) 2>/dev/null`" = xLinux; then
- AC_MSG_RESULT(yes)
- linux=1
- DBG_CFLAGS=
-else
- AC_MSG_RESULT(no)
- linux=0
- DBG_CFLAGS=-g
-fi
-
-#
-# Look for functions that may be missing
-#
-AC_FUNC_CHECK(strchr, AC_DEFINE(HAVE_STRCHR))
-
-#
-# Look for various header files
-#
-AC_HEADER_CHECK(stdlib.h, ,AC_DEFINE(NO_STDLIB_H))
-
-# consume these flags so that user can invoke tcl-debug's configure with
-# the same command as Tcl's configure
-AC_ARG_ENABLE(load,
- [ --disable-load disallow dynamic loading],
- [disable_dl=yes], [disable_dl=no])
-
-AC_ARG_ENABLE(gcc,
- [ --enable-gcc allow use of gcc if available],
- [enable_gcc=yes], [enable_gcc=no])
-
-DBG_UNSHARED_LIB_FILE=libtcldbg.a
-
-AC_MSG_CHECKING([type of library to build])
-AC_ARG_ENABLE(shared,
- [ --enable-shared build libtcldbg as a shared library],
- [enable_shared=yes], [enable_shared=no])
-if test "$enable_shared" = "yes" -a "x${TCL_SHLIB_SUFFIX}" != "x" ; then
- DBG_SHLIB_CFLAGS=$TCL_SHLIB_CFLAGS
-# DBG_SHARED_LIB_FILE=libtcldbg$DBG_VERSION$TCL_SHLIB_SUFFIX
- eval "DBG_SHARED_LIB_FILE=libdbg${TCL_SHARED_LIB_SUFFIX}"
- DBG_LIB_FILE=$DBG_SHARED_LIB_FILE
- DBG_LIB_FILES="$DBG_SHARED_LIB_FILE $DBG_UNSHARED_LIB_FILE"
- AC_MSG_RESULT(both shared and unshared)
-else
- DBG_SHLIB_CFLAGS=
- DBG_SHARED_LIB_FILE="reconfigure_Tcl_for_shared_library"
- DBG_LIB_FILE=$DBG_UNSHARED_LIB_FILE
- DBG_LIB_FILES="$DBG_UNSHARED_LIB_FILE"
- AC_MSG_RESULT(unshared)
-fi
-
-#
-# Set up makefile substitutions
-#
-AC_SUBST(DBG_MAJOR_VERSION)
-AC_SUBST(DBG_MINOR_VERSION)
-AC_SUBST(DBG_MICRO_VERSION)
-AC_SUBST(DBG_VERSION_FULL)
-AC_SUBST(DBG_VERSION)
-AC_SUBST(CC)
-AC_SUBST(DBG_SHARED_LIB_FILE)
-AC_SUBST(DBG_UNSHARED_LIB_FILE)
-AC_SUBST(DBG_SHLIB_CFLAGS)
-AC_SUBST(DBG_LIB_FILE)
-AC_SUBST(DBG_LIB_FILES)
-AC_SUBST(DBG_CFLAGS)
-AC_SUBST(UNSHARED_RANLIB)
-AC_OUTPUT(Makefile)
-
+++ /dev/null
-#! /bin/sh
-
-# Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.13
-# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
-#
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-
-# Defaults:
-ac_help=
-ac_default_prefix=/usr/local
-# Any additions from configure.in:
-ac_help="$ac_help
- --with-tclconfig directory containing tcl configuration (tclConfig.sh)"
-ac_help="$ac_help
- --with-tclinclude directory where tcl private headers are"
-ac_help="$ac_help
- --disable-load disallow dynamic loading"
-ac_help="$ac_help
- --enable-gcc allow use of gcc if available"
-ac_help="$ac_help
- --enable-shared build libtcldbg as a shared library"
-
-# Initialize some variables set by options.
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-build=NONE
-cache_file=./config.cache
-exec_prefix=NONE
-host=NONE
-no_create=
-nonopt=NONE
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-target=NONE
-verbose=
-x_includes=NONE
-x_libraries=NONE
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datadir='${prefix}/share'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-libdir='${exec_prefix}/lib'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-infodir='${prefix}/info'
-mandir='${prefix}/man'
-
-# Initialize some other variables.
-subdirs=
-MFLAGS= MAKEFLAGS=
-SHELL=${CONFIG_SHELL-/bin/sh}
-# Maximum number of lines to put in a shell here document.
-ac_max_here_lines=12
-
-ac_prev=
-for ac_option
-do
-
- # If the previous option needs an argument, assign it.
- if test -n "$ac_prev"; then
- eval "$ac_prev=\$ac_option"
- ac_prev=
- continue
- fi
-
- case "$ac_option" in
- -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
- *) ac_optarg= ;;
- esac
-
- # Accept the important Cygnus configure options, so we can diagnose typos.
-
- case "$ac_option" in
-
- -bindir | --bindir | --bindi | --bind | --bin | --bi)
- ac_prev=bindir ;;
- -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
- bindir="$ac_optarg" ;;
-
- -build | --build | --buil | --bui | --bu)
- ac_prev=build ;;
- -build=* | --build=* | --buil=* | --bui=* | --bu=*)
- build="$ac_optarg" ;;
-
- -cache-file | --cache-file | --cache-fil | --cache-fi \
- | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
- ac_prev=cache_file ;;
- -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
- | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
- cache_file="$ac_optarg" ;;
-
- -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
- ac_prev=datadir ;;
- -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
- | --da=*)
- datadir="$ac_optarg" ;;
-
- -disable-* | --disable-*)
- ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
- fi
- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
- eval "enable_${ac_feature}=no" ;;
-
- -enable-* | --enable-*)
- ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
- fi
- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes ;;
- esac
- eval "enable_${ac_feature}='$ac_optarg'" ;;
-
- -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
- | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
- | --exec | --exe | --ex)
- ac_prev=exec_prefix ;;
- -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
- | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
- | --exec=* | --exe=* | --ex=*)
- exec_prefix="$ac_optarg" ;;
-
- -gas | --gas | --ga | --g)
- # Obsolete; use --with-gas.
- with_gas=yes ;;
-
- -help | --help | --hel | --he)
- # Omit some internal or obsolete options to make the list less imposing.
- # This message is too long to be a string in the A/UX 3.1 sh.
- cat << EOF
-Usage: configure [options] [host]
-Options: [defaults in brackets after descriptions]
-Configuration:
- --cache-file=FILE cache test results in FILE
- --help print this message
- --no-create do not create output files
- --quiet, --silent do not print \`checking...' messages
- --version print the version of autoconf that created configure
-Directory and file names:
- --prefix=PREFIX install architecture-independent files in PREFIX
- [$ac_default_prefix]
- --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
- [same as prefix]
- --bindir=DIR user executables in DIR [EPREFIX/bin]
- --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
- --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
- --datadir=DIR read-only architecture-independent data in DIR
- [PREFIX/share]
- --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
- --sharedstatedir=DIR modifiable architecture-independent data in DIR
- [PREFIX/com]
- --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
- --libdir=DIR object code libraries in DIR [EPREFIX/lib]
- --includedir=DIR C header files in DIR [PREFIX/include]
- --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
- --infodir=DIR info documentation in DIR [PREFIX/info]
- --mandir=DIR man documentation in DIR [PREFIX/man]
- --srcdir=DIR find the sources in DIR [configure dir or ..]
- --program-prefix=PREFIX prepend PREFIX to installed program names
- --program-suffix=SUFFIX append SUFFIX to installed program names
- --program-transform-name=PROGRAM
- run sed PROGRAM on installed program names
-EOF
- cat << EOF
-Host type:
- --build=BUILD configure for building on BUILD [BUILD=HOST]
- --host=HOST configure for HOST [guessed]
- --target=TARGET configure for TARGET [TARGET=HOST]
-Features and packages:
- --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
- --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
- --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
- --x-includes=DIR X include files are in DIR
- --x-libraries=DIR X library files are in DIR
-EOF
- if test -n "$ac_help"; then
- echo "--enable and --with options recognized:$ac_help"
- fi
- exit 0 ;;
-
- -host | --host | --hos | --ho)
- ac_prev=host ;;
- -host=* | --host=* | --hos=* | --ho=*)
- host="$ac_optarg" ;;
-
- -includedir | --includedir | --includedi | --included | --include \
- | --includ | --inclu | --incl | --inc)
- ac_prev=includedir ;;
- -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
- | --includ=* | --inclu=* | --incl=* | --inc=*)
- includedir="$ac_optarg" ;;
-
- -infodir | --infodir | --infodi | --infod | --info | --inf)
- ac_prev=infodir ;;
- -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
- infodir="$ac_optarg" ;;
-
- -libdir | --libdir | --libdi | --libd)
- ac_prev=libdir ;;
- -libdir=* | --libdir=* | --libdi=* | --libd=*)
- libdir="$ac_optarg" ;;
-
- -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
- | --libexe | --libex | --libe)
- ac_prev=libexecdir ;;
- -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
- | --libexe=* | --libex=* | --libe=*)
- libexecdir="$ac_optarg" ;;
-
- -localstatedir | --localstatedir | --localstatedi | --localstated \
- | --localstate | --localstat | --localsta | --localst \
- | --locals | --local | --loca | --loc | --lo)
- ac_prev=localstatedir ;;
- -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
- | --localstate=* | --localstat=* | --localsta=* | --localst=* \
- | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
- localstatedir="$ac_optarg" ;;
-
- -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
- ac_prev=mandir ;;
- -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
- mandir="$ac_optarg" ;;
-
- -nfp | --nfp | --nf)
- # Obsolete; use --without-fp.
- with_fp=no ;;
-
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c)
- no_create=yes ;;
-
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
- no_recursion=yes ;;
-
- -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
- | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
- | --oldin | --oldi | --old | --ol | --o)
- ac_prev=oldincludedir ;;
- -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
- | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
- | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
- oldincludedir="$ac_optarg" ;;
-
- -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
- ac_prev=prefix ;;
- -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
- prefix="$ac_optarg" ;;
-
- -program-prefix | --program-prefix | --program-prefi | --program-pref \
- | --program-pre | --program-pr | --program-p)
- ac_prev=program_prefix ;;
- -program-prefix=* | --program-prefix=* | --program-prefi=* \
- | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
- program_prefix="$ac_optarg" ;;
-
- -program-suffix | --program-suffix | --program-suffi | --program-suff \
- | --program-suf | --program-su | --program-s)
- ac_prev=program_suffix ;;
- -program-suffix=* | --program-suffix=* | --program-suffi=* \
- | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
- program_suffix="$ac_optarg" ;;
-
- -program-transform-name | --program-transform-name \
- | --program-transform-nam | --program-transform-na \
- | --program-transform-n | --program-transform- \
- | --program-transform | --program-transfor \
- | --program-transfo | --program-transf \
- | --program-trans | --program-tran \
- | --progr-tra | --program-tr | --program-t)
- ac_prev=program_transform_name ;;
- -program-transform-name=* | --program-transform-name=* \
- | --program-transform-nam=* | --program-transform-na=* \
- | --program-transform-n=* | --program-transform-=* \
- | --program-transform=* | --program-transfor=* \
- | --program-transfo=* | --program-transf=* \
- | --program-trans=* | --program-tran=* \
- | --progr-tra=* | --program-tr=* | --program-t=*)
- program_transform_name="$ac_optarg" ;;
-
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- silent=yes ;;
-
- -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
- ac_prev=sbindir ;;
- -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
- | --sbi=* | --sb=*)
- sbindir="$ac_optarg" ;;
-
- -sharedstatedir | --sharedstatedir | --sharedstatedi \
- | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
- | --sharedst | --shareds | --shared | --share | --shar \
- | --sha | --sh)
- ac_prev=sharedstatedir ;;
- -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
- | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
- | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
- | --sha=* | --sh=*)
- sharedstatedir="$ac_optarg" ;;
-
- -site | --site | --sit)
- ac_prev=site ;;
- -site=* | --site=* | --sit=*)
- site="$ac_optarg" ;;
-
- -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
- ac_prev=srcdir ;;
- -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
- srcdir="$ac_optarg" ;;
-
- -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
- | --syscon | --sysco | --sysc | --sys | --sy)
- ac_prev=sysconfdir ;;
- -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
- | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
- sysconfdir="$ac_optarg" ;;
-
- -target | --target | --targe | --targ | --tar | --ta | --t)
- ac_prev=target ;;
- -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
- target="$ac_optarg" ;;
-
- -v | -verbose | --verbose | --verbos | --verbo | --verb)
- verbose=yes ;;
-
- -version | --version | --versio | --versi | --vers)
- echo "configure generated by autoconf version 2.13"
- exit 0 ;;
-
- -with-* | --with-*)
- ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
- fi
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes ;;
- esac
- eval "with_${ac_package}='$ac_optarg'" ;;
-
- -without-* | --without-*)
- ac_package=`echo $ac_option|sed -e 's/-*without-//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
- fi
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- eval "with_${ac_package}=no" ;;
-
- --x)
- # Obsolete; use --with-x.
- with_x=yes ;;
-
- -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
- | --x-incl | --x-inc | --x-in | --x-i)
- ac_prev=x_includes ;;
- -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
- | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
- x_includes="$ac_optarg" ;;
-
- -x-libraries | --x-libraries | --x-librarie | --x-librari \
- | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
- ac_prev=x_libraries ;;
- -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
- | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
- x_libraries="$ac_optarg" ;;
-
- -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
- ;;
-
- *)
- if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
- echo "configure: warning: $ac_option: invalid host type" 1>&2
- fi
- if test "x$nonopt" != xNONE; then
- { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
- fi
- nonopt="$ac_option"
- ;;
-
- esac
-done
-
-if test -n "$ac_prev"; then
- { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
-fi
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-# File descriptor usage:
-# 0 standard input
-# 1 file creation
-# 2 errors and warnings
-# 3 some systems may open it to /dev/tty
-# 4 used on the Kubota Titan
-# 6 checking for... messages and results
-# 5 compiler messages saved in config.log
-if test "$silent" = yes; then
- exec 6>/dev/null
-else
- exec 6>&1
-fi
-exec 5>./config.log
-
-echo "\
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-" 1>&5
-
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Also quote any args containing shell metacharacters.
-ac_configure_args=
-for ac_arg
-do
- case "$ac_arg" in
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c) ;;
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
- ac_configure_args="$ac_configure_args '$ac_arg'" ;;
- *) ac_configure_args="$ac_configure_args $ac_arg" ;;
- esac
-done
-
-# NLS nuisances.
-# Only set these to C if already set. These must not be set unconditionally
-# because not all systems understand e.g. LANG=C (notably SCO).
-# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
-# Non-C LC_CTYPE values break the ctype check.
-if test "${LANG+set}" = set; then LANG=C; export LANG; fi
-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
-if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
-if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -rf conftest* confdefs.h
-# AIX cpp loses on an empty file, so make sure it contains at least a newline.
-echo > confdefs.h
-
-# A filename unique to this package, relative to the directory that
-# configure is in, which we can look for to find out if srcdir is correct.
-ac_unique_file=Dbg.h
-
-# Find the source files, if location was not specified.
-if test -z "$srcdir"; then
- ac_srcdir_defaulted=yes
- # Try the directory containing this script, then its parent.
- ac_prog=$0
- ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
- test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
- srcdir=$ac_confdir
- if test ! -r $srcdir/$ac_unique_file; then
- srcdir=..
- fi
-else
- ac_srcdir_defaulted=no
-fi
-if test ! -r $srcdir/$ac_unique_file; then
- if test "$ac_srcdir_defaulted" = yes; then
- { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
- else
- { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
- fi
-fi
-srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
-
-# Prefer explicitly selected file to automatically selected ones.
-if test -z "$CONFIG_SITE"; then
- if test "x$prefix" != xNONE; then
- CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
- else
- CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
- fi
-fi
-for ac_site_file in $CONFIG_SITE; do
- if test -r "$ac_site_file"; then
- echo "loading site script $ac_site_file"
- . "$ac_site_file"
- fi
-done
-
-if test -r "$cache_file"; then
- echo "loading cache $cache_file"
- . $cache_file
-else
- echo "creating cache $cache_file"
- > $cache_file
-fi
-
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-ac_exeext=
-ac_objext=o
-if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
- # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
- if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
- ac_n= ac_c='
-' ac_t=' '
- else
- ac_n=-n ac_c= ac_t=
- fi
-else
- ac_n= ac_c='\c' ac_t=
-fi
-
-
-
-DBG_MAJOR_VERSION=1
-DBG_MINOR_VERSION=7
-DBG_MICRO_VERSION=0
-DBG_VERSION=$DBG_MAJOR_VERSION.$DBG_MINOR_VERSION
-DBG_VERSION_FULL=$DBG_VERSION.$DBG_MICRO_VERSION
-# Tcl's handling of shared_lib_suffix requires this symbol exist
-VERSION=$DBG_MAJOR_VERSION.$DBG_MINOR_VERSION
-
-
-
-
-#
-# Ok, lets find the tcl configuration
-# First, look for one uninstalled.
-# the alternative search directory is invoked by --with-tclconfig
-#
-
-if test x"${no_tcl}" = x ; then
- # we reset no_tcl in case something fails here
- no_tcl=true
- # Check whether --with-tclconfig or --without-tclconfig was given.
-if test "${with_tclconfig+set}" = set; then
- withval="$with_tclconfig"
- with_tclconfig=${withval}
-fi
-
- echo $ac_n "checking for Tcl configuration""... $ac_c" 1>&6
-echo "configure:563: checking for Tcl configuration" >&5
- if eval "test \"`echo '$''{'ac_cv_c_tclconfig'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
-
-
- # First check to see if --with-tclconfig was specified.
- if test x"${with_tclconfig}" != x ; then
- if test -f "${with_tclconfig}/tclConfig.sh" ; then
- ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
- else
- { echo "configure: error: ${with_tclconfig} directory doesn't contain tclConfig.sh" 1>&2; exit 1; }
- fi
- fi
-
- # then check for a private Tcl installation
-
- if test x"${ac_cv_c_tclconfig}" = x ; then
- for i in \
- ../tcl \
- `ls -dr ../tcl[7-9].[0-9] 2>/dev/null` \
- ../../tcl \
- `ls -dr ../../tcl[7-9].[0-9] 2>/dev/null` \
- ../../../tcl \
- `ls -dr ../../../tcl[7-9].[0-9] 2>/dev/null` ; do
- if test -f "$i/unix/tclConfig.sh" ; then
- ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
- break
- fi
- if test -f "$i/win/tclConfig.sh" ; then
- ac_cv_c_tclconfig=`(cd $i/win; pwd)`
- break
- fi
- done
- fi
-
- # check in a few common install locations
- if test x"${ac_cv_c_tclconfig}" = x ; then
- for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
- if test -f "$i/tclConfig.sh" ; then
- ac_cv_c_tclconfig=`(cd $i; pwd)`
- break
- fi
- done
- fi
- # check in a few other private locations
-
- if test x"${ac_cv_c_tclconfig}" = x ; then
- for i in \
- ${srcdir}/../tcl \
- `ls -dr ${srcdir}/../tcl[7-9].[0-9] 2>/dev/null` ; do
- if test -f "$i/unix/tclConfig.sh" ; then
- ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
- break
- fi
- done
- fi
-
-
-fi
-
- if test x"${ac_cv_c_tclconfig}" = x ; then
- TCLCONFIG="# no Tcl configs found"
- echo "configure: warning: Can't find Tcl configuration definitions" 1>&2
- else
- no_tcl=
- TCLCONFIG=${ac_cv_c_tclconfig}/tclConfig.sh
- echo "$ac_t""found $TCLCONFIG" 1>&6
- fi
-fi
-
-
- . $TCLCONFIG
-
-
-
-
-
-
-
-
-# Tcl defines TCL_SHLIB_SUFFIX but TCL_SHARED_LIB_SUFFIX then looks for it
-# as just SHLIB_SUFFIX. How bizarre.
- SHLIB_SUFFIX=$TCL_SHLIB_SUFFIX
-
-
-
-
-
-
-
-
-
-
-
-
-CC=$TCL_CC
-# Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:663: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_dummy="$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_CC="gcc"
- break
- fi
- done
- IFS="$ac_save_ifs"
-fi
-fi
-CC="$ac_cv_prog_CC"
-if test -n "$CC"; then
- echo "$ac_t""$CC" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-if test -z "$CC"; then
- # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:693: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_prog_rejected=no
- ac_dummy="$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
- ac_prog_rejected=yes
- continue
- fi
- ac_cv_prog_CC="cc"
- break
- fi
- done
- IFS="$ac_save_ifs"
-if test $ac_prog_rejected = yes; then
- # We found a bogon in the path, so make sure we never use it.
- set dummy $ac_cv_prog_CC
- shift
- if test $# -gt 0; then
- # We chose a different compiler from the bogus one.
- # However, it has the same basename, so the bogon will be chosen
- # first if we set CC to just the basename; use the full file name.
- shift
- set dummy "$ac_dir/$ac_word" "$@"
- shift
- ac_cv_prog_CC="$@"
- fi
-fi
-fi
-fi
-CC="$ac_cv_prog_CC"
-if test -n "$CC"; then
- echo "$ac_t""$CC" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
- if test -z "$CC"; then
- case "`uname -s`" in
- *win32* | *WIN32*)
- # Extract the first word of "cl", so it can be a program name with args.
-set dummy cl; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:744: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_dummy="$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_CC="cl"
- break
- fi
- done
- IFS="$ac_save_ifs"
-fi
-fi
-CC="$ac_cv_prog_CC"
-if test -n "$CC"; then
- echo "$ac_t""$CC" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
- ;;
- esac
- fi
- test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
-fi
-
-echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:776: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
-
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-cat > conftest.$ac_ext << EOF
-
-#line 787 "configure"
-#include "confdefs.h"
-
-main(){return(0);}
-EOF
-if { (eval echo configure:792: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- ac_cv_prog_cc_works=yes
- # If we can't run a trivial program, we are probably using a cross compiler.
- if (./conftest; exit) 2>/dev/null; then
- ac_cv_prog_cc_cross=no
- else
- ac_cv_prog_cc_cross=yes
- fi
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- ac_cv_prog_cc_works=no
-fi
-rm -fr conftest*
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
-if test $ac_cv_prog_cc_works = no; then
- { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
-fi
-echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:818: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
-echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
-cross_compiling=$ac_cv_prog_cc_cross
-
-echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:823: checking whether we are using GNU C" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.c <<EOF
-#ifdef __GNUC__
- yes;
-#endif
-EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:832: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
- ac_cv_prog_gcc=yes
-else
- ac_cv_prog_gcc=no
-fi
-fi
-
-echo "$ac_t""$ac_cv_prog_gcc" 1>&6
-
-if test $ac_cv_prog_gcc = yes; then
- GCC=yes
-else
- GCC=
-fi
-
-ac_test_CFLAGS="${CFLAGS+set}"
-ac_save_CFLAGS="$CFLAGS"
-CFLAGS=
-echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:851: checking whether ${CC-cc} accepts -g" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- echo 'void f(){}' > conftest.c
-if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
- ac_cv_prog_cc_g=yes
-else
- ac_cv_prog_cc_g=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
-if test "$ac_test_CFLAGS" = set; then
- CFLAGS="$ac_save_CFLAGS"
-elif test $ac_cv_prog_cc_g = yes; then
- if test "$GCC" = yes; then
- CFLAGS="-g -O2"
- else
- CFLAGS="-g"
- fi
-else
- if test "$GCC" = yes; then
- CFLAGS="-O2"
- else
- CFLAGS=
- fi
-fi
-
-# If we cannot compile and link a trivial program, we can't expect anything to work
-echo $ac_n "checking whether the compiler ($CC) actually works""... $ac_c" 1>&6
-echo "configure:884: checking whether the compiler ($CC) actually works" >&5
-cat > conftest.$ac_ext <<EOF
-#line 886 "configure"
-#include "confdefs.h"
-
-int main() {
-/* don't need anything here */
-; return 0; }
-EOF
-if { (eval echo configure:893: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- c_compiles=yes
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- c_compiles=no
-fi
-rm -f conftest*
-
-cat > conftest.$ac_ext <<EOF
-#line 905 "configure"
-#include "confdefs.h"
-
-int main() {
-/* don't need anything here */
-; return 0; }
-EOF
-if { (eval echo configure:912: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- c_links=yes
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- c_links=no
-fi
-rm -f conftest*
-
-if test x"${c_compiles}" = x"no" ; then
- { echo "configure: error: the native compiler is broken and won't compile." 1>&2; exit 1; }
-fi
-
-if test x"${c_links}" = x"no" ; then
- { echo "configure: error: the native compiler is broken and won't link." 1>&2; exit 1; }
-fi
-echo "$ac_t""yes" 1>&6
-
-
-# this'll use a BSD compatible install or our included install-sh
-ac_aux_dir=
-for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
- if test -f $ac_dir/install-sh; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/install-sh -c"
- break
- elif test -f $ac_dir/install.sh; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/install.sh -c"
- break
- fi
-done
-if test -z "$ac_aux_dir"; then
- { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
-fi
-ac_config_guess=$ac_aux_dir/config.guess
-ac_config_sub=$ac_aux_dir/config.sub
-ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
-
-# Find a good install program. We prefer a C program (faster),
-# so one script is as good as another. But avoid the broken or
-# incompatible versions:
-# SysV /etc/install, /usr/sbin/install
-# SunOS /usr/etc/install
-# IRIX /sbin/install
-# AIX /bin/install
-# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
-# AFS /usr/afsws/bin/install, which mishandles nonexistent args
-# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
-# ./install, which can be erroneously created by make from ./install.sh.
-echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:965: checking for a BSD compatible install" >&5
-if test -z "$INSTALL"; then
-if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
- for ac_dir in $PATH; do
- # Account for people who put trailing slashes in PATH elements.
- case "$ac_dir/" in
- /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
- *)
- # OSF1 and SCO ODT 3.0 have their own names for install.
- # Don't use installbsd from OSF since it installs stuff as root
- # by default.
- for ac_prog in ginstall scoinst install; do
- if test -f $ac_dir/$ac_prog; then
- if test $ac_prog = install &&
- grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
- # AIX install. It has an incompatible calling convention.
- :
- else
- ac_cv_path_install="$ac_dir/$ac_prog -c"
- break 2
- fi
- fi
- done
- ;;
- esac
- done
- IFS="$ac_save_IFS"
-
-fi
- if test "${ac_cv_path_install+set}" = set; then
- INSTALL="$ac_cv_path_install"
- else
- # As a last resort, use the slow shell script. We don't cache a
- # path for INSTALL within a source directory, because that will
- # break other packages using the cache if that directory is
- # removed, or if the path is relative.
- INSTALL="$ac_install_sh"
- fi
-fi
-echo "$ac_t""$INSTALL" 1>&6
-
-# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
-# It thinks the first close brace ends the variable substitution.
-test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
-
-test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
-
-test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
-
-
-# Tcl sets TCL_RANLIB appropriately for shared library if --enable-shared
-# Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1022: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$RANLIB"; then
- ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_dummy="$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_RANLIB="ranlib"
- break
- fi
- done
- IFS="$ac_save_ifs"
- test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
-fi
-fi
-RANLIB="$ac_cv_prog_RANLIB"
-if test -n "$RANLIB"; then
- echo "$ac_t""$RANLIB" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-UNSHARED_RANLIB=$RANLIB
-
-# This is for LynxOS, which needs a flag to force true POSIX when
-# building. It's weirder than that, cause the flag varies depending
-# how old the compiler is. So...
-# -X is for the old "cc" and "gcc" (based on 1.42)
-# -mposix is for the new gcc (at least 2.5.8)
-# This modifies the value of $CC to have the POSIX flag added
-# so it'll configure correctly
-echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1059: checking how to run the C preprocessor" >&5
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
- CPP=
-fi
-if test -z "$CPP"; then
-if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- # This must be in double quotes, not single quotes, because CPP may get
- # substituted into the Makefile and "${CC-cc}" will confuse make.
- CPP="${CC-cc} -E"
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp.
- cat > conftest.$ac_ext <<EOF
-#line 1074 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1080: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- CPP="${CC-cc} -E -traditional-cpp"
- cat > conftest.$ac_ext <<EOF
-#line 1091 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1097: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- CPP="${CC-cc} -nologo -E"
- cat > conftest.$ac_ext <<EOF
-#line 1108 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1114: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- CPP=/lib/cpp
-fi
-rm -f conftest*
-fi
-rm -f conftest*
-fi
-rm -f conftest*
- ac_cv_prog_CPP="$CPP"
-fi
- CPP="$ac_cv_prog_CPP"
-else
- ac_cv_prog_CPP="$CPP"
-fi
-echo "$ac_t""$CPP" 1>&6
-
-
-echo $ac_n "checking if running LynxOS""... $ac_c" 1>&6
-echo "configure:1140: checking if running LynxOS" >&5
-if eval "test \"`echo '$''{'ac_cv_os_lynx'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1145 "configure"
-#include "confdefs.h"
-/*
- * The old Lynx "cc" only defines "Lynx", but the newer one uses "__Lynx__"
- */
-#if defined(__Lynx__) || defined(Lynx)
-yes
-#endif
-
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "yes" >/dev/null 2>&1; then
- rm -rf conftest*
- ac_cv_os_lynx=yes
-else
- rm -rf conftest*
- ac_cv_os_lynx=no
-fi
-rm -f conftest*
-
-fi
-
-#
-if test "$ac_cv_os_lynx" = "yes" ; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define LYNX 1
-EOF
-
- echo $ac_n "checking whether -mposix or -X is available""... $ac_c" 1>&6
-echo "configure:1175: checking whether -mposix or -X is available" >&5
- if eval "test \"`echo '$''{'ac_cv_c_posix_flag'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1180 "configure"
-#include "confdefs.h"
-
-int main() {
-
- /*
- * This flag varies depending on how old the compiler is.
- * -X is for the old "cc" and "gcc" (based on 1.42).
- * -mposix is for the new gcc (at least 2.5.8).
- */
- #if defined(__GNUC__) && __GNUC__ >= 2
- choke me
- #endif
-
-; return 0; }
-EOF
-if { (eval echo configure:1196: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- ac_cv_c_posix_flag=" -mposix"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- ac_cv_c_posix_flag=" -X"
-fi
-rm -f conftest*
-fi
-
- CC="$CC $ac_cv_c_posix_flag"
- echo "$ac_t""$ac_cv_c_posix_flag" 1>&6
- else
- echo "$ac_t""no" 1>&6
-fi
-
-
-# we really only need the header files
-
-#
-# Ok, lets find the tcl source trees so we can use the headers
-# Warning: transition of version 9 to 10 will break this algorithm
-# because 10 sorts before 9. We also look for just tcl. We have to
-# be careful that we don't match stuff like tclX by accident.
-# the alternative search directory is involked by --with-tclinclude
-#
-no_tcl=true
-echo $ac_n "checking for Tcl private headers""... $ac_c" 1>&6
-echo "configure:1226: checking for Tcl private headers" >&5
-# Check whether --with-tclinclude or --without-tclinclude was given.
-if test "${with_tclinclude+set}" = set; then
- withval="$with_tclinclude"
- with_tclinclude=${withval}
-fi
-
-if eval "test \"`echo '$''{'ac_cv_c_tclh'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
-
-# first check to see if --with-tclinclude was specified
-if test x"${with_tclinclude}" != x ; then
- if test -f ${with_tclinclude}/tclInt.h ; then
- ac_cv_c_tclh=`(cd ${with_tclinclude}; pwd)`
- elif test -f ${with_tclinclude}/generic/tclInt.h ; then
- ac_cv_c_tclh=`(cd ${with_tclinclude}/generic; pwd)`
- else
- { echo "configure: error: ${with_tclinclude} directory doesn't contain private headers" 1>&2; exit 1; }
- fi
-fi
-
-# next check if it came with Tcl configuration file
-if test x"${ac_cv_c_tclconfig}" != x ; then
- if test -f $ac_cv_c_tclconfig/../generic/tclInt.h ; then
- ac_cv_c_tclh=`(cd $ac_cv_c_tclconfig/../generic; pwd)`
- fi
-fi
-
-# next check in private source directory
-#
-# since ls returns lowest version numbers first, reverse its output
-
-if test x"${ac_cv_c_tclh}" = x ; then
- for i in \
- ${srcdir}/../tcl \
- `ls -dr ${srcdir}/../tcl[7-9].[0-9] 2>/dev/null` \
- ${srcdir}/../../tcl \
- `ls -dr ${srcdir}/../../tcl[7-9].[0-9] 2>/dev/null` \
- ${srcdir}/../../../tcl \
- `ls -dr ${srcdir}/../../../tcl[7-9].[0-9] 2>/dev/null ` ; do
- if test -f $i/generic/tclInt.h ; then
- ac_cv_c_tclh=`(cd $i/generic; pwd)`
- break
- fi
- done
-fi
-
-# finally check in a few common install locations
-#
-# since ls returns lowest version numbers first, reverse its output
-
-if test x"${ac_cv_c_tclh}" = x ; then
- for i in \
- `ls -dr /usr/local/src/tcl[7-9].[0-9] 2>/dev/null` \
- `ls -dr /usr/local/lib/tcl[7-9].[0-9] 2>/dev/null` \
- /usr/local/src/tcl \
- /usr/local/lib/tcl \
- ${prefix}/include ; do
- if test -f $i/generic/tclInt.h ; then
- ac_cv_c_tclh=`(cd $i/generic; pwd)`
- break
- fi
- done
-fi
-
-# see if one is installed
-if test x"${ac_cv_c_tclh}" = x ; then
- ac_safe=`echo "tclInt.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for tclInt.h""... $ac_c" 1>&6
-echo "configure:1296: checking for tclInt.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1301 "configure"
-#include "confdefs.h"
-#include <tclInt.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1306: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_cv_c_tclh=installed
-else
- echo "$ac_t""no" 1>&6
-ac_cv_c_tclh=""
-fi
-
-fi
-
-fi
-
-if test x"${ac_cv_c_tclh}" = x ; then
- TCLHDIR="# no Tcl private headers found"
- TCLHDIRDASHI="# no Tcl private headers found"
- { echo "configure: error: Can't find Tcl private headers" 1>&2; exit 1; }
-fi
-if test x"${ac_cv_c_tclh}" != x ; then
- no_tcl=""
- if test x"${ac_cv_c_tclh}" = x"installed" ; then
- echo "$ac_t""is installed" 1>&6
- TCLHDIR=""
- TCLHDIRDASHI=""
- TCL_LIBRARY=""
- else
- echo "$ac_t""found in ${ac_cv_c_tclh}" 1>&6
- # this hack is cause the TCLHDIR won't print if there is a "-I" in it.
- TCLHDIR="${ac_cv_c_tclh}"
- TCLHDIRDASHI="-I${ac_cv_c_tclh}"
- TCL_LIBRARY=`echo $TCLHDIR | sed -e 's/generic//'`library
- fi
-fi
-
-
-
-
-
-if test x"$no_tcl" = x"true" ; then
- echo " ERROR: Can't find Tcl directory"
- echo " See README for information on how to obtain Tcl."
- echo " If Tcl is installed, see INSTALL on how to tell"
- echo " configure where Tcl is installed."
- exit 1
-fi
-
-# Use -g on all systems but Linux where it upsets the dynamic X libraries.
-echo $ac_n "checking if we are running Linux""... $ac_c" 1>&6
-echo "configure:1367: checking if we are running Linux" >&5
-if test "x`(uname) 2>/dev/null`" = xLinux; then
- echo "$ac_t""yes" 1>&6
- linux=1
- DBG_CFLAGS=
-else
- echo "$ac_t""no" 1>&6
- linux=0
- DBG_CFLAGS=-g
-fi
-
-#
-# Look for functions that may be missing
-#
-echo $ac_n "checking for strchr""... $ac_c" 1>&6
-echo "configure:1382: checking for strchr" >&5
-if eval "test \"`echo '$''{'ac_cv_func_strchr'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1387 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char strchr(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char strchr();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_strchr) || defined (__stub___strchr)
-choke me
-#else
-strchr();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:1410: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_strchr=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_strchr=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'strchr`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_STRCHR 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-
-#
-# Look for various header files
-#
-ac_safe=`echo "stdlib.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for stdlib.h""... $ac_c" 1>&6
-echo "configure:1438: checking for stdlib.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1443 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1448: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- :
-else
- echo "$ac_t""no" 1>&6
-cat >> confdefs.h <<\EOF
-#define NO_STDLIB_H 1
-EOF
-
-fi
-
-
-# consume these flags so that user can invoke tcl-debug's configure with
-# the same command as Tcl's configure
-# Check whether --enable-load or --disable-load was given.
-if test "${enable_load+set}" = set; then
- enableval="$enable_load"
- disable_dl=yes
-else
- disable_dl=no
-fi
-
-
-# Check whether --enable-gcc or --disable-gcc was given.
-if test "${enable_gcc+set}" = set; then
- enableval="$enable_gcc"
- enable_gcc=yes
-else
- enable_gcc=no
-fi
-
-
-DBG_UNSHARED_LIB_FILE=libtcldbg.a
-
-echo $ac_n "checking type of library to build""... $ac_c" 1>&6
-echo "configure:1497: checking type of library to build" >&5
-# Check whether --enable-shared or --disable-shared was given.
-if test "${enable_shared+set}" = set; then
- enableval="$enable_shared"
- enable_shared=yes
-else
- enable_shared=no
-fi
-
-if test "$enable_shared" = "yes" -a "x${TCL_SHLIB_SUFFIX}" != "x" ; then
- DBG_SHLIB_CFLAGS=$TCL_SHLIB_CFLAGS
-# DBG_SHARED_LIB_FILE=libtcldbg$DBG_VERSION$TCL_SHLIB_SUFFIX
- eval "DBG_SHARED_LIB_FILE=libdbg${TCL_SHARED_LIB_SUFFIX}"
- DBG_LIB_FILE=$DBG_SHARED_LIB_FILE
- DBG_LIB_FILES="$DBG_SHARED_LIB_FILE $DBG_UNSHARED_LIB_FILE"
- echo "$ac_t""both shared and unshared" 1>&6
-else
- DBG_SHLIB_CFLAGS=
- DBG_SHARED_LIB_FILE="reconfigure_Tcl_for_shared_library"
- DBG_LIB_FILE=$DBG_UNSHARED_LIB_FILE
- DBG_LIB_FILES="$DBG_UNSHARED_LIB_FILE"
- echo "$ac_t""unshared" 1>&6
-fi
-
-#
-# Set up makefile substitutions
-#
-
-
-
-
-
-
-
-
-
-
-
-
-
-trap '' 1 2 15
-cat > confcache <<\EOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs. It is not useful on other systems.
-# If it contains results you don't want to keep, you may remove or edit it.
-#
-# By default, configure uses ./config.cache as the cache file,
-# creating it if it does not exist already. You can give configure
-# the --cache-file=FILE option to use a different cache file; that is
-# what configure does when it calls configure scripts in
-# subdirectories, so they share the cache.
-# Giving --cache-file=/dev/null disables caching, for debugging configure.
-# config.status only pays attention to the cache file if you give it the
-# --recheck option to rerun configure.
-#
-EOF
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, don't put newlines in cache variables' values.
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-(set) 2>&1 |
- case `(ac_space=' '; set | grep ac_space) 2>&1` in
- *ac_space=\ *)
- # `set' does not quote correctly, so add quotes (double-quote substitution
- # turns \\\\ into \\, and sed turns \\ into \).
- sed -n \
- -e "s/'/'\\\\''/g" \
- -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
- ;;
- *)
- # `set' quotes correctly as required by POSIX, so do not add quotes.
- sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
- ;;
- esac >> confcache
-if cmp -s $cache_file confcache; then
- :
-else
- if test -w $cache_file; then
- echo "updating cache $cache_file"
- cat confcache > $cache_file
- else
- echo "not updating unwritable cache $cache_file"
- fi
-fi
-rm -f confcache
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-# Any assignment to VPATH causes Sun make to only execute
-# the first set of double-colon rules, so remove it if not needed.
-# If there is a colon in the path, we need to keep it.
-if test "x$srcdir" = x.; then
- ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
-fi
-
-trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
-
-DEFS=-DHAVE_CONFIG_H
-
-# Without the "./", some shells look in PATH for config.status.
-: ${CONFIG_STATUS=./config.status}
-
-echo creating $CONFIG_STATUS
-rm -f $CONFIG_STATUS
-cat > $CONFIG_STATUS <<EOF
-#! /bin/sh
-# Generated automatically by configure.
-# Run this file to recreate the current configuration.
-# This directory was configured as follows,
-# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-#
-# $0 $ac_configure_args
-#
-# Compiler output produced by configure, useful for debugging
-# configure, is in ./config.log if it exists.
-
-ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
-for ac_option
-do
- case "\$ac_option" in
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
- exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
- -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
- echo "$CONFIG_STATUS generated by autoconf version 2.13"
- exit 0 ;;
- -help | --help | --hel | --he | --h)
- echo "\$ac_cs_usage"; exit 0 ;;
- *) echo "\$ac_cs_usage"; exit 1 ;;
- esac
-done
-
-ac_given_srcdir=$srcdir
-ac_given_INSTALL="$INSTALL"
-
-trap 'rm -fr `echo "Makefile Dbg_cf.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-# Protect against being on the right side of a sed subst in config.status.
-sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
- s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
-$ac_vpsub
-$extrasub
-s%@SHELL@%$SHELL%g
-s%@CFLAGS@%$CFLAGS%g
-s%@CPPFLAGS@%$CPPFLAGS%g
-s%@CXXFLAGS@%$CXXFLAGS%g
-s%@FFLAGS@%$FFLAGS%g
-s%@DEFS@%$DEFS%g
-s%@LDFLAGS@%$LDFLAGS%g
-s%@LIBS@%$LIBS%g
-s%@exec_prefix@%$exec_prefix%g
-s%@prefix@%$prefix%g
-s%@program_transform_name@%$program_transform_name%g
-s%@bindir@%$bindir%g
-s%@sbindir@%$sbindir%g
-s%@libexecdir@%$libexecdir%g
-s%@datadir@%$datadir%g
-s%@sysconfdir@%$sysconfdir%g
-s%@sharedstatedir@%$sharedstatedir%g
-s%@localstatedir@%$localstatedir%g
-s%@libdir@%$libdir%g
-s%@includedir@%$includedir%g
-s%@oldincludedir@%$oldincludedir%g
-s%@infodir@%$infodir%g
-s%@mandir@%$mandir%g
-s%@TCL_DEFS@%$TCL_DEFS%g
-s%@TCL_SHLIB_LD@%$TCL_SHLIB_LD%g
-s%@SHLIB_SUFFIX@%$SHLIB_SUFFIX%g
-s%@TCL_LD_FLAGS@%$TCL_LD_FLAGS%g
-s%@TCL_RANLIB@%$TCL_RANLIB%g
-s%@TCL_BUILD_LIB_SPEC@%$TCL_BUILD_LIB_SPEC%g
-s%@TCL_LIB_SPEC@%$TCL_LIB_SPEC%g
-s%@TCL_SHARED_LIB_SUFFIX@%$TCL_SHARED_LIB_SUFFIX%g
-s%@CC@%$CC%g
-s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
-s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
-s%@INSTALL_DATA@%$INSTALL_DATA%g
-s%@RANLIB@%$RANLIB%g
-s%@CPP@%$CPP%g
-s%@TCLHDIR@%$TCLHDIR%g
-s%@TCLHDIRDASHI@%$TCLHDIRDASHI%g
-s%@TCL_LIBRARY@%$TCL_LIBRARY%g
-s%@DBG_MAJOR_VERSION@%$DBG_MAJOR_VERSION%g
-s%@DBG_MINOR_VERSION@%$DBG_MINOR_VERSION%g
-s%@DBG_MICRO_VERSION@%$DBG_MICRO_VERSION%g
-s%@DBG_VERSION_FULL@%$DBG_VERSION_FULL%g
-s%@DBG_VERSION@%$DBG_VERSION%g
-s%@DBG_SHARED_LIB_FILE@%$DBG_SHARED_LIB_FILE%g
-s%@DBG_UNSHARED_LIB_FILE@%$DBG_UNSHARED_LIB_FILE%g
-s%@DBG_SHLIB_CFLAGS@%$DBG_SHLIB_CFLAGS%g
-s%@DBG_LIB_FILE@%$DBG_LIB_FILE%g
-s%@DBG_LIB_FILES@%$DBG_LIB_FILES%g
-s%@DBG_CFLAGS@%$DBG_CFLAGS%g
-s%@UNSHARED_RANLIB@%$UNSHARED_RANLIB%g
-
-CEOF
-EOF
-
-cat >> $CONFIG_STATUS <<\EOF
-
-# Split the substitutions into bite-sized pieces for seds with
-# small command number limits, like on Digital OSF/1 and HP-UX.
-ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
-ac_file=1 # Number of current file.
-ac_beg=1 # First line for current file.
-ac_end=$ac_max_sed_cmds # Line after last line for current file.
-ac_more_lines=:
-ac_sed_cmds=""
-while $ac_more_lines; do
- if test $ac_beg -gt 1; then
- sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
- else
- sed "${ac_end}q" conftest.subs > conftest.s$ac_file
- fi
- if test ! -s conftest.s$ac_file; then
- ac_more_lines=false
- rm -f conftest.s$ac_file
- else
- if test -z "$ac_sed_cmds"; then
- ac_sed_cmds="sed -f conftest.s$ac_file"
- else
- ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
- fi
- ac_file=`expr $ac_file + 1`
- ac_beg=$ac_end
- ac_end=`expr $ac_end + $ac_max_sed_cmds`
- fi
-done
-if test -z "$ac_sed_cmds"; then
- ac_sed_cmds=cat
-fi
-EOF
-
-cat >> $CONFIG_STATUS <<EOF
-
-CONFIG_FILES=\${CONFIG_FILES-"Makefile"}
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
- # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
- case "$ac_file" in
- *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
- ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
- *) ac_file_in="${ac_file}.in" ;;
- esac
-
- # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
-
- # Remove last slash and all that follows it. Not all systems have dirname.
- ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
- if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
- # The file is in a subdirectory.
- test ! -d "$ac_dir" && mkdir "$ac_dir"
- ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
- # A "../" for each directory in $ac_dir_suffix.
- ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
- else
- ac_dir_suffix= ac_dots=
- fi
-
- case "$ac_given_srcdir" in
- .) srcdir=.
- if test -z "$ac_dots"; then top_srcdir=.
- else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
- /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
- *) # Relative path.
- srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
- top_srcdir="$ac_dots$ac_given_srcdir" ;;
- esac
-
- case "$ac_given_INSTALL" in
- [/$]*) INSTALL="$ac_given_INSTALL" ;;
- *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
- esac
-
- echo creating "$ac_file"
- rm -f "$ac_file"
- configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
- case "$ac_file" in
- *Makefile*) ac_comsub="1i\\
-# $configure_input" ;;
- *) ac_comsub= ;;
- esac
-
- ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
- sed -e "$ac_comsub
-s%@configure_input@%$configure_input%g
-s%@srcdir@%$srcdir%g
-s%@top_srcdir@%$top_srcdir%g
-s%@INSTALL@%$INSTALL%g
-" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
-fi; done
-rm -f conftest.s*
-
-# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
-# NAME is the cpp macro being defined and VALUE is the value it is being given.
-#
-# ac_d sets the value in "#define NAME VALUE" lines.
-ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
-ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
-ac_dC='\3'
-ac_dD='%g'
-# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
-ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_uB='\([ ]\)%\1#\2define\3'
-ac_uC=' '
-ac_uD='\4%g'
-# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
-ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_eB='$%\1#\2define\3'
-ac_eC=' '
-ac_eD='%g'
-
-if test "${CONFIG_HEADERS+set}" != set; then
-EOF
-cat >> $CONFIG_STATUS <<EOF
- CONFIG_HEADERS="Dbg_cf.h"
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-fi
-for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
- # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
- case "$ac_file" in
- *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
- ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
- *) ac_file_in="${ac_file}.in" ;;
- esac
-
- echo creating $ac_file
-
- rm -f conftest.frag conftest.in conftest.out
- ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
- cat $ac_file_inputs > conftest.in
-
-EOF
-
-# Transform confdefs.h into a sed script conftest.vals that substitutes
-# the proper values into config.h.in to produce config.h. And first:
-# Protect against being on the right side of a sed subst in config.status.
-# Protect against being in an unquoted here document in config.status.
-rm -f conftest.vals
-cat > conftest.hdr <<\EOF
-s/[\\&%]/\\&/g
-s%[\\$`]%\\&%g
-s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
-s%ac_d%ac_u%gp
-s%ac_u%ac_e%gp
-EOF
-sed -n -f conftest.hdr confdefs.h > conftest.vals
-rm -f conftest.hdr
-
-# This sed command replaces #undef with comments. This is necessary, for
-# example, in the case of _POSIX_SOURCE, which is predefined and required
-# on some systems where configure will not decide to define it.
-cat >> conftest.vals <<\EOF
-s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
-EOF
-
-# Break up conftest.vals because some shells have a limit on
-# the size of here documents, and old seds have small limits too.
-
-rm -f conftest.tail
-while :
-do
- ac_lines=`grep -c . conftest.vals`
- # grep -c gives empty output for an empty file on some AIX systems.
- if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
- # Write a limited-size here document to conftest.frag.
- echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
- sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
- echo 'CEOF
- sed -f conftest.frag conftest.in > conftest.out
- rm -f conftest.in
- mv conftest.out conftest.in
-' >> $CONFIG_STATUS
- sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
- rm -f conftest.vals
- mv conftest.tail conftest.vals
-done
-rm -f conftest.vals
-
-cat >> $CONFIG_STATUS <<\EOF
- rm -f conftest.frag conftest.h
- echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
- cat conftest.in >> conftest.h
- rm -f conftest.in
- if cmp -s $ac_file conftest.h 2>/dev/null; then
- echo "$ac_file is unchanged"
- rm -f conftest.h
- else
- # Remove last slash and all that follows it. Not all systems have dirname.
- ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
- if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
- # The file is in a subdirectory.
- test ! -d "$ac_dir" && mkdir "$ac_dir"
- fi
- rm -f $ac_file
- mv conftest.h $ac_file
- fi
-fi; done
-
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-
-exit 0
-EOF
-chmod +x $CONFIG_STATUS
-rm -fr confdefs* $ac_clean_files
-test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
-
-
+++ /dev/null
-Expect FAQ (Frequently Asked Questions)
-
-An HTML version of this FAQ can be found in http://elib.cme.nist.gov/pub/expect/FAQ.html
-
-This FAQ lists common questions, usually about subjects that didn't
-fit well in the book for one reason or another (or weren't
-indexed sufficiently well so that people can't find the answers easily
-enough). In some cases, I've left the original questions. I suppose
-I could've stripped off the headers, but it seems more realistic to
-see actual people who've asked the questions. Thanks to everyone who
-asked.
-
-The man page and the papers listed in the README file should
-also be consulted for highly technical or philosophical discussion of
-the implementation, design, and practical application of Expect.
-
-Don
-
-======================================================================
-
- Here is the list of questions. You can search for the corresponding
- answer by searching for the question number. For example searching
- for "#3." will get you that answer.
-
-
-**** General ****
-
-#1. I keep hearing about Expect. So what is it?
-#2. How do you pronounce "Ousterhout" anyway? (Or "Libes" for that matter?)
-
-#3. Why should I learn yet another language (Tcl) instead of
-writing my interaction in <a language I already know>.
-#4. What about Perl?
-#5. Do we need to pay or ask for permission to distribute Expect?
-#6. Since Expect is free, can we give you a gift?
-#7. Are there any hidden dangers in using Expect?
-
-**** Book, newsgroup, FAQ, README, ... ****
-
-#8. Why is this FAQ so short?
-#9. The FAQ background makes the FAQ hard to read.
-#10. Why isn't there an Expect mailing list?
-#11. Why isn't overlay covered in Exploring Expect?
-#12. Is the front cover of your book a self portrait (ha ha)?
-#13. How are your daughter's kidneys?
-#14. Are you going to have a book signing?
-#15. How many books have you sold?
-#16. I just want to tell you how much I like your book!
-#17. Why don't the examples in your USENIX papers work?
-#18. Can you put the examples in your book into an anonymous ftp site?
-#19. Do you have ideas for more articles on Expect?
-
-**** Can Expect do this? ****
-
-#20. Can Expect automatically generate a script from watching a session?
-#21. Can Expect understand screen-oriented (Curses) programs?
-#22. Can Expect be run as a CGI script?
-#23. Can Expect be run from cron?
-
-**** Compilation or porting questions ****
-
-#24. Why can't I compile Expect with Tcl 7.5?
-#25. Why does Expect need to be setuid root on Cray?
-#26. Does Expect run on VMS?
-#27. Is it possible to use Expect and TclX together?
-#28. Is it possible to use Expect and <lots of random extensions> together?
-#29. Why does configure complain about "cross-compiling"?
-#30. make/configure seems to be looping endlessly
-#31. Compile fails with: Don't know how to make pty_.c
-#32. Does Expect run on MSDOS, Win95, WinNT, MacOS, etc...
-
-**** Other... ****
-
-#33. Is it possible to prevent Expect from printing out its interactions?
-#34. Why does it send back the same string twice?
-#35. Why can't I send the line "user@hostname\r"?
-#36. How do I hide the output of the send command?
-#37. Why does "talk" fail with "Who are you? You have no entry utmp" or
- "You don't exist. Go away".
-#38. Why does . match a newline?
-#39. Why doesn't Expect kill telnet (or other programs) sometimes?
-#40. How come I get "ioctl(set): Inappropriate ..., bye recursed" ...
-#41. How come there's no interact function in the Expect library?
-
-
-*
-* Questions and Answers
-*
-
-
-
-**** General ****
-
-
-#1. I keep hearing about Expect. So what is it?
-
-From: libes (Don Libes)
-To: Charles Hymes <chymes@crew.umich.edu>
-Subject: I keep hearing about Expect. So what is it?
-
-Charles Hymes writes:
->
->So, what is Expect?
-
-Expect is a tool primarily for automating interactive applications
-such as telnet, ftp, passwd, fsck, rlogin, tip, etc. Expect really
-makes this stuff trivial. Expect is also useful for testing these
-same applications. Expect is described in many books, articles,
-papers, and FAQs. There is an entire book on it available from
-O'Reilly.
-
-You can ftp Expect from ftp.cme.nist.gov as pub/expect/expect.tar.Z or ...gz
-
-Expect requires Tcl. If you don't already have Tcl, you can get it
-in the same directory (above) as pub/expect/tcl.tar.Z or ...gz.
-
-Expect is free and in the public domain.
-
-Don
-
-======================================================================
-
-#2. How do you pronounce "Ousterhout" anyway? (Or "Libes" for that matter?)
-
-
-From: ouster@sprite.Berkeley.EDU (John Ousterhout)
-To: libes@cme.nist.gov
-Subject: Re: pronunciation?
-Date: Tue, 29 May 90 21:26:10 PDT
-
-Those of us in the family pronounce it "OH-stir-howt", where the
-first syllable rhymes with "low", the second with "purr", and the
-third with "doubt". Unfortunately this isn't the correct Dutch
-pronounciation for a name spelled this way (someplace along
-the line it got misspelled: it was originally "Oosterhout"), nor
-is it what you'd guess if you use common sense. So, we've gotten
-used to responding to almost anything.
-
- -John-
-
-I suppose I should say something in kind. "Libes" is pronounced
-"Lee-bis" with stress on the first syllable. Like John though, I've
-gotten used to responding to anything close.
-
-By the way, notice the date on this message. I had only written
-the first cut of Expect four months earlier. I asked John how to
-pronounce his name because I had already got a paper accepted into
-USENIX and needed to be able to say his name correctly while giving
-the talk!
-
-Don
-
-======================================================================
-
-#3. Why should I learn yet another language (Tcl) instead of
-writing my interaction in <a language I already know>.
-
-From: libes (Don Libes)
-To: Aamod Sane <sane@cs.uiuc.edu>
-Subject: Re: Expect, Tcl, programmed dialogue etc.
-Date: Mon, 2 Sep 91 15:47:14 EDT
-
-> >>A friend told me about "Expect". But then, I have to know the
-> >>idiocies of "tcl". I would like to know if there is an alternative
-> >>to Expect that is also useful in other places, so that I do not
-> >>have to spend time getting used to tcl for just this one tool.
->
-> Your reasoning is shortsighted. Tcl is a language that can be used in
-> other applications. It won't be a waste of your time to learn it.
->
->I have nothing against tcl as such.
->The reluctance to learn it comes mainly from the feeling that half my
->life seems to be spent learning new languages that differ very little
->from existing ones, and differ in annoying little details at that.
->To add to the misery, every implementation has its own
->idiosyncracies...:-(
-
-Ironically, Tcl was written specifically to halt this very problem.
-
-The author recognized that every utility seems to have its own
-idiosyncratic .rc file or programming language. Tcl was designed as a
-general-purpose language that could be included with any utility, to
-avoid having everyone hack up their own new language.
-
- In this context, your statements do Tcl a great disservice.
-
-Don
-
-======================================================================
-
-#4. What about Perl?
-
-From: libes (Don Libes)
-To: Joe McGuckin <joe@ns.via.net>
-Subject: Re: Need Perl examples
-Date: Sun, 22 Jan 95 20:17:39 EST
-
-Joe McGuckin writes:
->
->Yeah, I've scanned through your book a couple of times in the last
->week, trying to make up my mind if I should buy it.
-
-I spent three years writing it - so I'm glad to hear you're spending a
-little time considering its merit!
-
->Pro:
-> Looks like implementing some sort of telnet daemon would be trivial.
-
-Once you see it as an Expect script, you'll realize how trivial
-these things can really be.
-
->Con:
-> Yet another language to learn. I know perl reasonably well & would
-> like to stick with it.
-
-Good point. While I'm not a Perl guru, I've used it quite a bit
-and it's nice for many things. But I wouldn't have bothered writing
-Expect in the first place if I thought Perl was ideal. And many Perl
-experts agree - I know a lot of them who call out to Expect scripts
-rather than do this stuff in Perl - it's that much easier with Expect.
-Expect is also much more mature. It's portable, stable, robust, and
-it's fully documented - with lots of examples and a complete tutorial,
-too.
-
-In response to someone complaining about how difficult it was to do
-something in Perl, Larry Wall once remarked: "The key to using
-Perl is to focus on its strengths and avoid its weaknesses." That
-definitely applies here.
-
-Even if you do proceed with Perl, you will find the book
-helpful. Automating interactive applications has unique pitfalls to
-it and many of the descriptions and solutions in the book transcend
-the choice of language that you use to implement them.
-
-Don
-
-======================================================================
-
-#5. Do we need to pay or ask for permission to distribute Expect?
-
-From: libes (Don Libes)
-To: Mohammad Reza Jahanbin <mrj@CIS.Prime.COM>
-Subject: Copyright Question.
-Date: Tue, 26 Jan 93 23:46:24 EST
-
-Mohammad Reza Jahanbin writes:
->Before anything let me thank you on behalf of ComputeVision R&D for
->putting so much effort into Expect. Part of CV has been using Expect
->for the past two years or so to build variety of tools including an
->automated testbed for a product.
->
->CV is currently considering shipping the automated testbed to some of its
->retailers, to enable them to perform their own tests before distributing
->the product.
->
->The Question is, are we allowed to ship Expect? Do we need to ask
->anyone for permission? Do we need to say or write anything in the
->documentation? Do we need to pay for it?
->
->I have not been able to find any copyright (or indeed copyleft) notices
->in the usual Expect distribution. Would you be able to clarify our position.
-
-Sorry to delay in responding. I sent your request to my management
-and they had to discuss it (if they didn't, there would be no reason
-to pay them). While they continue to discuss it, I can tell you
-informally the gist of what they will eventually say:
-
-You are allowed to do just about anything with Expect. You can even
-sell it. You need not ask our permission. You need not pay for it.
-(It is my understanding that your tax dollars, in effect, already have
-paid for it.)
-
-You should not claim that you wrote it (since this would be a lie), nor
-should you attempt to copyright it (this would be fruitless as it is a
-work of the US government and therefore not subject to copyright).
-
-NIST would appreciate any credit you can give for this work. One line
-may suffice (as far as I'm concerned) although there should be
-something to the effect that this software was produced for research
-purposes. No warantee, guarantee, or liability is implied.
-
-My management is always interested in feedback on our work. If you
-would like to send letters of praise describing how Expect has helped
-your business, we would be delighted. Letters (on letterhead please)
-are strong evidence used by policy makers when deciding where every
-dollar goes. If you want to send these letters to NIST directly, you
-may send them to the following individuals:
-
-Arati Prabahkar, Director
-NIST
-Admin Bldg, Rm A-1134
-Gaithersburg, MD 20899
-
-Ric Jackson, Manufacturing Engineering Laboratory
-NIST
-Bldg 220, Rm B-322
-Gaithersburg, MD 20899
-
-Howard Bloom, Manufacturing Systems Integration Division
-NIST
-Bldg 220, Rm A-127
-Gaithersburg, MD 20899
-
-Steve Ray, Manufacturing Collaboration Technologies Group
-NIST
-Bldg 220, Rm A-127
-Gaithersburg, MD 20899
-
-In case you're wondering about the uninformative titles, Arati Prabahkar is the
-director of all of NIST (about 3000 people) and Steve Ray (way down there
-at the bottom) is my immediate supervisor (and of 10 other very lucky people).
-
-I hope this has answered your questions. Let me know if you have
-further questions.
-
-Don
-
-======================================================================
-
-#6. Since Expect is free, can we give you a gift?
-
-This is not an actual letter but represents the gist of several
-that I've received.
-
->>>Expect has saved us many thousands of dollars. We'd like to send
->>>you a free copy of our product.
->>
->>Thanks, but please don't. As a federal employee, I'm not
->>allowed to accept gifts of any significant value.
->
->But, what if it is for personal use (like at home)? I assume
->that would be okay.
-
-It doesn't matter (much). What the rules address is whether a gift
-might cause me to make an official decision differently. This is
-especially a concern because I may very well have to decide whether or
-not to buy products from your company in the future.
-
-There is a clause that says "you may accept gifts from friends,
-regardless of value ... but you should be careful to avoid accepting
-gifts which may create an appearance of impropriety, even if permitted
-as an exception to the gift rules."
-
-I'm still permitted to accept small token gifts, such as a t-shirt
-or reasonably-priced dinner (under $20 per gift to a maximum of $50
-per year from any person or company) - so things are not totally
-ridiculous. Although the precise values in the gift rules seem rather
-arbitrary, I actually like the gift rules. They stop a lot of the
-nonsense that used to go on involving gifts.
-
-Don
-
-======================================================================
-
-#7. Are there any hidden dangers in using Expect?
-
-From: Charlton Henry Harrison <charlton@cs.utexas.edu>
-To: libes@NIST.GOV
-Date: Fri, 27 Jan 1995 23:30:56 -0600
-
->>>Dear Don:
->>>
->>> I've been a fan of Expect ever since I first learned of UNIX back
->>>in late '93. I'm young and don't have my CS degree just yet, but I worked
->>>a while back at Texas Instruments in their Telecom Customer Support dept.
->>>I started in late '93 (and hence, that's where I first started exploring
->>>the UNIX environment) and immediately forsaw the need of automating a lot
->>>of my redundant and mindless duties, but I didn't know how since we were
->>>working over a heterogeneous LAN with multiple OSs.
->>> Then I found out about Expect. I automated everything! My boss didn't
->>>like hearing that I was working on something else in order to get out of
->>>work, and I got tired of explaining it to him.
->>> Although I accomplished all the aspects of my duties, I was infamous
->>>for being the laziest person at work, and it showed (I made my job SO easy).
->>>I got a new boss after a while, and he hated me from the start and fired
->>>me soon after. Oh well, I guess my mentality didn't click with theirs.
->>> There are a lot of people like that: they believe life is putting
->>>in a hard day's work to get by. I hate that.
->>> So the point is, thank you for the wonderful 'Expect'. I bought
->>>your book and now I have the most recent version of it on my Linux system
->>>at home. Needless to say I'm looking for another job, though.
->>>
->>> Charlton
->>>
->> Thanks very much for your nice letter. Sorry to hear about your
->> automating yourself out of a job. Actually, I think most computer
->> scientists have to face this dilemma. In some ways, it's a
->> self-defeating occupation.
->>
->> Don
->
->Yeah, I'd be interested in hearing if you have a personal philosophy on
->how to handle this kind of thing. I plan on pursuing a career in Artificial
->Intelligence for similar reason of making life easier for everyone (me
->in particular!) What the future holds in this category is a great
->mystery.
-
-I'm glad you asked. My personal philosophy on this kind of thing is:
-Find someone really rich and marry them.
-
-Don
-
-======================================================================
-
-**** Book, newsgroup, FAQ, README, ... ****
-
-
-#8. Why is this FAQ so short?
-
-From: libes (Don Libes)
-To: Wade Holst <wade@cs.ualberta.ca>
-Subject: Expect question
-
-Wade Holst writes:
->
-> 1) Is there a more up-to-date version of the FAQ than what
-> comes with expect-5.5? (For such a useful application, I
-> would expect more than 12 questions).
-
-I know that a lot of other packages have *huge* FAQs but I
-have always believed that this is an indication that their regular
-documentation sucks. As questions arise that are not addressed well
-by the original docs, the docs themselves should be fixed rather than
-new ones created.
-
-In contrast, I believe that an FAQ should literally be a list of
-frequently asked questions and little else. An FAQ should not be a
-replacement for good documentation.
-
-In that sense, I have tried to use this FAQ as a second place to
-look rather than a first place. The place you should always look
-first is Exploring Expect. At over 600 pages, the book is very
-comprehensive, well-organized, and includes three indices and two
-tables-of-contents to make it very easy to find what you want to know.
-
-The book was not a rush job. During the three years I spent
-writing it, virtually every question I was asked became incorporated
-as subject material for the book. I wanted to make sure that the book
-wouldn't need much of an FAQ!
-
-It would not make sense to try and distill the entire book into an
-FAQ (that is actually comprehensive rather that truly frequently asked
-questions). There's simply too much material there.
-
-So this FAQ is short. It really tries to stick just to *truly*
-frequently asked questions.
-
-Don
-
-======================================================================
-
-#9. The FAQ background makes the FAQ hard to read.
-
-To: bonneau@mudd.csap.af.mil (Allen Bonneau)
-Subject: FAQ background colors
-Date: Wed, 10 Apr 96 10:24:52 EDT
-
-Allen Bonneau writes:
->... the white and gray background makes the FAQ difficult to read.
-
-It's not white and gray. It's several very close shades of gray.
-It's supposed to be very subtle. Sounds like you have your browser in
-a mode where it is mishandling colors. Try turning on dithering.
-
-Don
-
-======================================================================
-
-#10. Why isn't there an Expect mailing list?
-
-From: libes (Don Libes)
-To: dclark@nas.nasa.gov (David R. Clark)
-Subject: Mailing list for Expect
-Date: Mon, 23 Sep 91 18:21:28 EDT
-
->Would be nice if their were an Expect mailing list. I would use it more
->often, and be made aware of other users.
-
-Perhaps I'm too myopic, but I don't see the need for it. Most of
-the questions about Expect posted to Usenet every day can be found in
-the various FAQs or in the book, so it's pretty easy getting
-answers to them.
-
-For one reason or another (occasionally a bug fix, but often, just
-adding a neat example), I update Expect every couple of weeks.
-Personally, I'd hate being on the other end of something like this.
-Who needs patches every two weeks for problems that are likely not
-even relevant to you? (Most patches these days are either extremely
-esoteric or are related to porting Expect to some unusual machine.)
-
->It would be helpful, too, if this served as an area for swapping programs.
->Many of the things that I want to do are done by others already.
-
-Send me things that you'd like to distribute. I can include it
-with Expect or put it in a publicly accessible directory so other
-people can get it. I'm also willing to list links in Expect's home
-page to other web pages about projects that use Expect.
-
-There is a Tcl newsgroup, comp.lang.tcl, which many Expect users
-read. It's pretty good for asking questions about Tcl, and many of
-the readers use Expect so Expect questions are encouraged. The
-newsgroup is gatewayed to a mailing list (tcl@sprite.berkeley.edu)
-which is further described in the Tcl documentation.
-
-Don
-
-======================================================================
-
-#11. Why isn't overlay covered in Exploring Expect?
-
-From: libes (Don Libes)
-To: spaf@cs.purdue.edu
-Subject: Your book
-
-Gene Spafford writes:
->I'm curious as to why the "overlay" command is not mentioned anywhere
->in the book. Is that a recent addition? A deprecated feature? I
->ended up using it in one of my scripts....
-
-The overlay command has been in Expect for a long time. In all that
-time no one has ever asked me about it and I have never used it.
-Well, I used it once but I really didn't like the result, and so I
-rewrote the script to not use it. I left the overlay command in
-Expect because it seemed like an interesting idea, but I never really
-finished it - in the sense that I believe it needs some more options
-and controls. In comparison, the interact command is very flexible
-and makes the need for overlay pretty moot.
-
-Don
-
-======================================================================
-
-#12. Is the front cover of your book a self portrait (ha ha)?
-
-From: libes (Don Libes)
-To: pkinz@cougar.tandem.com (kinzelman_paul)
-Subject: the cover?
-
-kinzelman paul writes:
->The book finally came in. I tried to buy 4 copies but they had only 2
->left and they came in last Saturday. Move over Stephen King! :-)
-
-4 copies!? Wow. That's more than my mother bought!
-
->I was discussing your book with somebody who stopped in and we began
->to speculate about the monkey on the cover. I don't suppose it's a
->self portrait? :-)
-
-There is some real humor here. There seems to be considerable
-debate over what the creature is! The colophon at the end of
-the book says that it is a chimpanzee. I like that idea much more
-than a monkey which is what it looks like to me. My wife, who has a
-degree in zoology, explained to me that chimps are actually the second
-smartest of primates (humans are the smartest). Chimps are very
-intelligent and can do many things (but not everything) that humans
-do. Perfect for describing Expect. Anyway, she says I should be
-honored to have it grace the book cover - even in theory.
-
-I remarked to Edie (the cover designer at O'Reilly) that even though
-the cover was nice looking, everyone was going to stare at it and say,
-"Gee, but it looks like a monkey." She replied "The purpose of the
-cover is just to get people to pick the book up. This cover will do
-that. Don't worry. If you get any rude comments from anyone, at least
-you know they are paying attention."
-
-[After being inundated by people pointing out that the animal
-really is a monkey, O'Reilly subsequently decided to acquiesce and has
-changed the colophon to admit that yes it is a rhesus monkey.
-Evidentally, the book from which O'Reilly has been taking those
-pictures from was wrong on this one.]
-
-Don
-
-======================================================================
-
-#13. How are your daughter's kidneys?
-
-From: libes
-To: olav@emerson.physics.ubc.ca
-Subject: How are your daughter's kidneys?
-B. Olav Anderson writes:
->Don,
->
->I bought your book regarding expect and it's great and so is Expect.
->
->P.S. How's your daughters kidneys? I hope the're well hydrated :-)
-
-In retrospect, I probably should have said that her "diapers" were
-what was well-hydrated. Glad to see that you found something in the
-book worth reading!
-
-Don
-
-======================================================================
-
-#14. Are you going to have a book signing?
-
-From: libes (Don Libes)
-To: Josef Sachs <sachs@panix.com>
-Subject: Expect
-
-Josef Sachs writes:
->Do you have any book-signing sessions planned?
-
-That's very ego-boosting to contemplate but I doubt that my name
-is enough to draw the kind of crowd that would make it worthwhile.
-I'll leave that kind of thing to Howard Stern. Anyway, I have a
-full-time job working for the government. I doubt they would take too
-kindly to me taking time off for self-aggrandizing. (They weren't
-particularly encouraging to have me write a book in the first place -
-as you'll read in the Preface.)
-
-I've written a couple of other books and people have mailed me those
-for signatures. (One guy sent me an entire box of books for
-signatures - he was giving them to friends as Christmas gifts.) If
-you're similarly inclined, my address is in Expect's README file. Or
-if you're ever in my neck of the woods, feel free to stop by for a
-chat (and bring your copy).
-
-Don
-
-======================================================================
-
-#15. How many books have you sold?
-
-From: Don Libes
-To: Thomas Ragland <rags@noc.ans.net>
-Subject: Re: AIX smit automation
-In-Reply-To: <199601092106.VAA19276@bugsy.aa.ans.net>
-References: <199601092106.VAA19276@bugsy.aa.ans.net>
---text follows this line--
-Thomas Ragland writes:
-> btw approximately how many books were sold? I just bought
-> it and it is quite helpful. Once again, thanks.
->
->Thomas
-
-Glad you liked the book. Sorry to disappoint you but I have no
-idea about how many have been sold. (I made my mother buy a couple,
-so I know it's a positive number.) Believe it or not, I try *not*
-to pay attention to that type of thing. I did with my first book
-and was very disappointed. (It sold well but it didn't earn that
-first million that I was dreaming about...) I've learned that I don't
-write to sell books or make money. If I did, I'd be better off
-writing "Yet Another Book on HTML" or a romance novel. No, the
-real reason that I write is - I enjoy it.
-
-Don
-
-======================================================================
-
-#16. I just want to tell you how much I like your book!
-
-To: Joe Pasko <pasko@hp7.scri.fsu.edu>
-Subject: Re: ***Expect spawn questions*****
-Date: Thu, 15 Feb 96 14:52:23 EST
-Joe Pasko writes:
->
->Thanks Don,
->
->I just took your advice and it was the tty settings. Thanks a bunch !
->
->As a side note: Great book !! It's the best howto for tcl-type stuff
->that I've seen around.
-
-Thanks for the kind words. But don't tell me (gee, I already like my
-book!) - post your opinion to a newsgroup and send a review to a
-magazine. I regret that many Tcl users don't pick up the book simply
-because they think it isn't of any use to the general Tcl user - which
-of course isn't true.
-
-Don
-
-======================================================================
-
-#17. Why don't the examples in your USENIX papers work?
-
-From: libes (Don Libes)
-To: Will Smith (AC) <william@ritchie.acomp.usf.edu>
-Subject: Expect
-
-Will Smith (AC) writes:
->I just entered some scripts from a USENIX paper that my boss had. I get
->errors about my quotes in the script. Also, it doesn't seem to know
->about expect_match. Thanks in advance for any insight you could offer.
-
-The USENIX papers are old and out-of-date as far as quoting goes. A
-couple years ago, I cleaned up and simplified this aspect of Expect.
-Similarly, expect_out is now where the results of expect's pattern
-matching are saved.
-
-The man page is always the best reference on what Expect currently
-supports. Alternatively, you can read the CHANGES files. These files
-document the changes from one major version to another.
-
-Don
-
-======================================================================
-
-#18. Can you put the examples in your book into an anonymous ftp site?
-
-From: libes (Don Libes)
-To: pren@cs.umass.edu
-Subject: Examples in your book "Exploring Expect"
-
-Peifong Ren writes:
->
->Hi,
->
->I bought your book "Exploring Expect" from O'Reilly.
->I wonder can you put the eamples in your book into an anonymous ftp
->site?
-
-All of the substantive examples come with recent versions of Expect.
-Just look in the example directory.
-
-The remaining 50 or so examples are short enough that typing them
-in only takes a minute or two. If I put them online, you'd spend more
-time looking for them (reading my online catalog, figuring out what
-the online descriptions meant, mapping them back to the file, etc.)
-then it would take to type them in. And since you're likely to want
-to change the examples anyway, there's nothing to be gained for short
-ones.
-
-Don
-
-======================================================================
-
-#19. Do you have ideas for more articles on Expect?
-
-From: libes (Don Libes)
-To: faught@zeppelin.convex.com (Danny R. Faught)
-Cc: libes
-Subject: Re: SQA Quarterly articles
-Date: Thu, 21 Dec 95 13:31:01 EST
-
-Danny R. Faught writes:
->I just arranged to write an article on automating interactive
->processes for an issue early next year. You have so many good pieces
->on expect out there, it's going to be hard to add anything original.
-
-One thing I've never written is a good mini-tutorial. Magazine
-editors love these types of pieces and there's certainly a need for
-it. So I'd encourage that type of article.
-
-Another possibility is an article on how you or your colleagues
-personally applied Expect to solve your particular problem. Application-
-oriented papers are the kind that necessarily have to be written by
-people in the field who are applying the technology. People love this
-kind of practical paper. For example, a good paper might be "Writing
-a pager". This is a nice topic because you can start with a simple
-5-line script that solves the problem and then show progressive
-refinements that handle different twists on the same problem. (And
-"how to write a pager" is a very frequently asked question on Usenet.)
-
-Don
-
-======================================================================
-
-**** Can Expect do this? ****
-
-
-#20. Can Expect automatically generate a script from watching a session?
-
-From: libes (Don Libes)
-To: pete@willow24.cray.com
-Subject: Expect
-Date: Fri, 12 Oct 90 17:16:47 EDT
-
->I like "Expect" and am thinking of using it to help automate the
->testing of interactive programs. It would be useful if Expect had a
->"watch me" mode, where it "looks over the shoulder" of the user and
->records his keystrokes for later use in an Expect script.
->
->(Red Ryder and other Macintosh telecommunications packages offer this
->sort of thing. You log onto Compuserve once in "watch me" mode, and
->RR keeps track of the keystrokes/prompts. When you're done you have a
->script that can be used to log onto Compuserve automatically.)
->
->Before I look into adding a "watch me" feature, I thought I should
->ask: has this been done already?
->
->I'll say again that I like the tool a lot--nice work! There are other
->people here using it for things like the testing of ksh, which
->responds differently to signals when not used interactively.
->
->-- Pete
-
-The autoexpect script in Expect's example directory does what you
-want.
-
-Don
-
-======================================================================
-
-#21. Can Expect understand screen-oriented (Curses) programs?
-
-Yes, it can - with a little clever scripting. Look at the
-term_expect script for an example. It uses a Tk text widget to
-support screen-oriented Expect commands. This technique is described
-very thoroughly in Chapter 19 of Exploring Expect.
-
-Adrian Mariano (adrian@cam.cornell.edu) converted the term_expect
-code (see above) so that it runs without Tk (exercise 4 in Chapter
-19!) Both term_expect and virterm can be found in the example
-directory that comes with Expect.
-
-An alternative approach to screen-handling was demonstrated by Mark
-Weissman (weissman@gte.com) and Christopher Matheus who modified a
-version of Expect to include a built-in Curses emulator. It can be
-ftp'd from the Tcl archive as expecTerm1.0beta.tar.Z. (Note that
-Expecterm does not run with the current version of Expect.)
-
-I like the idea of keeping the curses emulator outside of Expect
-itself. It leaves the interface entirely defineable by the user. And
-you can do things such as define your own terminal types if you want.
-For these reasons and several others, I'm not likely to return to
-Expecterm.
-
-Don
-
-======================================================================
-
-#22. Can Expect be run as a CGI script?
-
-Expect scripts work fine as CGI scripts. A couple pointers might
-help to get you going:
-
-Many Expect scripts can be run directly with one change - the
-following line should be inserted before any other output:
-
-puts "Content-type: text/html\n"
-
-Be sure not to forget that extra newline at the end of the puts.
-
-Next, make sure you invoke external programs using full paths. For
-example, instead of "spawn telnet", use "spawn /usr/ucb/telnet" (or
-whatever). Remember that the PATH and other environment variables are
-going to be different than what you are used to. This is very similar
-to dealing with cron and you can get other good tips and advice from
-reading the Background chapter in the book.
-
- One last tip: If a script runs fine by hand but not from CGI, just
-log in as "nobody" to the host on which your CGI script runs. Then
-try running it by hand. This generally makes it very obvious what's
-going on. (If you can't log in to the server or can't log in as
-"nobody", use the kibitz trick described in the Background chapter.)
-
-Don
-
-======================================================================
-
-#23. Can Expect be run from cron?
-
-Expect itself works fine from cron - however, you can cause
-problems if you do things that don't make sense in cron - such as
-assume that there is a terminal type predefined. There are a number
-of other pitfalls to watch out for. The list and explanations aren't
-short - which is why there's a whole chapter ("Background") on the
-subject in the book.
-
-Here's one that someone tried to stump me with recently: They told
-me that their program started up and then Expect immediately exited.
-We spent a lot of time tracking this down (Was the spawned program
-really starting up but then hanging - which would indicate a bug in
-the program; or was the program NOT starting up - which would indicate
-a bug in the environment; etc.) Turned out that Expect wasn't even
-running their program. They had assumed cron honored the #! line
-(which it doesn't) and so the first line in their script (exec date)
-was being interpreted by the shell and of course, the script did
-nothing after that - because that's what the shell's exec is supposed
-to do!)
-
-Don
-
-======================================================================
-
-**** Compilation or porting questions ****
-
-
-#24. Why can't I compile Expect with Tcl 7.5?
-
-You can - you just need a newer version of Expect. Note that the
-production release of Tcl 7.5 was just released and a compatible
-Expect is still in beta. So you shouldn't do this without
-caution.
-
-Expect 5.19 works fine with Tcl 7.4. If you stay with Tcl 7.4, I
-encourage you to upgrade to Expect 5.19 if you haven't already.
-
-Don
-
-======================================================================
-
-#25. Why does Expect need to be setuid root on Cray?
-
-From: libes (Don Libes)
-To: u70217@f.nersc.gov (Lori Wong)
-Subject: setuid in Expect
-Date: Thu, 24 Oct 91 16:15:20 EDT
-
-> I have been running Expect now under UNICOS 6.1 and CSOS 1.0 (Cray
->Computer Corporation's OS). The two machines that I am running Expect
->on have stringent security features, one of which is to limit setuid
->privileges to specific individuals. I was wondering if you would be
->kind enough to explain the purpose of the setuid that is needed by Expect
->and whether it could be compiled to run without having to have setuid
->privilege? I know it has to do with spawning and communicating with
->the various spawned tasks, but don't know enough of the details to be
->able to explain why Expect specifically needs setuid and whether or not
->it could cause a security problem (could someone use it to enter into
->the system and wreak havoc, for example?). Right now, I've limited
->the access of Expect to my group, but need to know what the security
->implications are if I open it to all users. I'd appreciate any light
->you can shed on this subject...
-
-Root-access is needed to open a pty under Unicos. Thus, all programs
-accessing ptys must be setuid root. If you do an "ls -l" of programs
-like "script", "xterm", etc, you'll see this.
-
-I have no idea why this is. The requirement was probably for security
-reasons to begin with, but it has the ironic effect of making more
-programs require setuid and therefore greater possibility of errant
-setuid programs.
-
-In fact, there is one known Unicos bug relating to the way uids are
-switched at exec time which requires further special coding. If you
-search for "Cray" in the Expect source you will see significant chunks
-of code to get around the problem.
-
-I don't know if this reassures you any. All I can tell you is that a
-number of Cray experts have looked into the situation and are happy
-with the current implementation of Expect.
-
-Don
-
-======================================================================
-
-#26. Does Expect run on VMS?
-
-From: libes (Don Libes)
-To: Cameron Laird <claird@Starbase.NeoSoft.COM>
-Subject: VMS question.
-
-Cameron Laird writes:
->Do you know of anyone working with Expect and VMS?
->I'd like not to re-invent wheels, but, if I'm to be
->the first one, I want others to benefit.
-
-No, I'm not aware of anyone doing it. Since VMS claims POSIX
-conformance, it shouldn't be that hard - Expect uses the POSIX calls
-if it can. Probably the hardest part will just be modifying the Makefile
-and the configure script!
-
-However, that there might be a simpler solution. The neat thing
-about Expect is that you can control other computers easily. Run
-Expect on your UNIX box and have it log in to the VMS box and do its
-thing. (You can bypass the login garbage by using an inet daemon.)
-We've done exactly this to a number of weird pieces of hardware we
-have around the lab (robots, Lisp machines, embedded controllers, and,
-of course, a VAX running VMS). It saves time porting!
-
-Don
-
-======================================================================
-
-#27. Is it possible to use Expect and TclX together?
-
-Is it possible to use Expect and TclX together?
-From: bfriesen@iphase.com (Bob Friesenhahn)
-Date: 20 Jul 1994 04:09:43 GMT
-Organization: Interphase Corporation, Dallas TX - USA
-
-Jeffery A. Echtenkamp (echtenka@michigan.nb.rockwell.com) wrote:
-: Do Expect and tclX work together? If so, must anything special be done to
-: get them to work together?
-
-This answer courtesy of Bob Friesenhahn, Interphase (bfriesen@iphase.com):
-
-They work fine together. However, you should prepend "exp_" to your Expect
-command names. This will ensure that there are no conflicts between Expect
-commands and tclX commands of the same name (like wait).
-
-Just pick up the "make-a-wish" package, follow the instructions, and you will
-be all set. I have built a wish based on tcl, tk, Expect, tclX, and dp using
-this technique with no observed problems.
-
-Bob
-
-[If you need additional information, please read Chapter 22
-("Expect as Just Another Tcl Extension") of Exploring Expect. Its
-sole focus is how to make Expect work with other extensions. - Don]
-======================================================================
-
-#28. Is it possible to use Expect and <lots of random extensions> together?
-
-From: libes (Don Libes)
-To: Frank Winkler <winkler@eas.iis.fhg.de>
-Subject: Q Expect + TkSteal
-
-Frank Winkler writes:
->Hi don,
->
->a short question considering installation of Expectk.
->
->Is it possible to build an Expectk-binary, which uses
->the features of BLT, TkSteal and Expect ?
-
-I've never done it, but I know it must be possible because the tgdb
-package in the Tcl archive uses all of those extensions with Expect.
-
-Expect is a "well-behaved extension" in the sense that it requires no
-changes to the Tcl core. So Expect should work with any other Tcl
-extensions. You just need to add the usual Exp_Init call to main() or
-the other _Init calls to Expect's main.
-
->If yes, which of them should be build first, second ... ?
-
-Order doesn't matter.
-
-I've done this kind of thing by hand. It's pretty simple. But people
-tell me the make-a-wish package in the Tcl archive automates the
-creation of multi-extension Tcl applications.
-
-[Also see the answer to the previous FAQ answer.]
-
-Don
-
-======================================================================
-
-#29. Why does configure complain about "cross-compiling"?
-
-From: libes (Don Libes)
-To: morton@hendrix.jci.tju.edu (Dan Morton)
-Subject: Re: Sorry to bother you, but...
-
-Dan Morton writes:
->Don,
->
->I've posted an inquiry to comp.lang.tcl about my configure problems with
->expect, but I've not yet gotten a reply. Perhaps you can nudge me in the
->right direction?
->
->I'm running HP-UX 9.0 on a 735, and I've snagged the latest versions of Tcl
->and expect from NIST (7.4 and 5.18 respectively). My gcc is v2.6. Tcl
->configured and built out of the box, but I can't get expect to configure
->properly. No matter what I do, it thinks it wants to cross-compile. I
->think it's failing that little snippet of eval code. It gets further if I
->specify --host=HP, but still complains about cross compiling. Here's the
->result without options:
->
->{hendrix:~/expect-5.18:8} ./configure
->checking for gcc... gcc
->checking whether we are using GNU C... yes
->checking whether gcc accepts -g... no
->checking how to run the C preprocessor... gcc -E
->checking whether cross-compiling... yes
->checking whether cross-compiling... (cached) configure: error: You need to
->specify --target to cross compile,
-> or the native compiler is broken
-
-I guess the error message has to be clearer. The message:
-
- "or the native compiler is broken"
-
-means that configure tried to compile a simple program and it failed.
-Here's the program it tries to compile:
-
- main() {
- return(0);
- }
-
-The configure output that you showed me says that it found gcc.
-Perhaps it was misinstalled or is just a placeholder and doesn't
-actually do anything? Try compiling a tiny C program yourself from
-the command line.
-
-Don
-
-======================================================================
-
-#30. make/configure seems to be looping endlessly
-
-To: Xiaorong Qu <aqu@cisco.com>
-Subject: Make message for Expect
---text follows this line--
-Xiaorong Qu writes:
->Don,
->
->The following is the output of make, you can find
->that the process repeated three times.
-
-I bet what's going on is that your system clock is set to some
-ridiculous time such as last year. "Make" is sensitive to your clock.
-Please fix your clock. Then check that all the files are "older"
-than the current time. (If not, "touch" them all.)
-
-Don
-
-======================================================================
-
-#31. Compile fails with: Don't know how to make pty_.c
-
-From: libes (Don Libes)
-To: wren@io.nosc.mil
-Subject: Compile fails with: Don't know how to make pty_.c
-
-> I'm trying to compile Expect on hpux 9.01,
-> downloaded from ftp.cme.nist.gov expect.tar
-
-> after running config
-> the make fails with "Don't know how to make pty_.c. (compile fails)
-> I see three versions pty_sgttyb.c, pty_termios.c and pty_unicos.c in
-> the load, but the configure picked none of them.
-> I tried forcing to pty_termios.c but that failed with other compile errors.
-
-I've seen this happen because gcc was partially installed. configure
-finds the gcc stub and uses gcc for all the tests. But because the
-compiler doesn't work, every test fails so configure doesn't select
-any of the choices.
-
-So either finish installing gcc or delete the stub.
-
-(And if it's not that, then something similar is wrong with whatever
-compiler you've got. Look closely at the output from configure, it
-will tell you what compiler it is trying to use.)
-
-By the way, Expect compiles fine on my HP (A.09.05 E 9000/735).
-
-Don
-
-======================================================================
-
-#32. Does Expect run on MSDOS, Win95, WinNT, MacOS, etc...
-
-From: libes (Don Libes)
-To: Gerry_Jones@qmgateib.mitre.org
-Subject: Does Expect run on ...
-Date: Wed, 11 Oct 95 19:57:42 EDT
-
->I am in a group looking into developing script language-based applications for
->Mac and PC-Windows environments. Our intent is to write scripts to work with
->interactive applications (e.g. telnet). After asking around, I started
->looking into Tcl/Tk, which now have 'official' (?) (alpha) Mac and PC-Windows
->ports. One of the people in our group has been working (in UNIX) with Tcl and
->Tk for quite some time, and said if there isn't an Expect port or similar tool
->for Mac and PC-Windows, then we shouldn't use Tcl/Tk; i.e. they would be too
->limited and/or require too much work to do what we need. I've been cruising
->the Web for information, reading the Newsgroups, read the FAQs, etc., and have
->the following questions:
->
->1) Is there a current or planned port of Expect to Mac or PC-Windows
->environments?
-
-No, Expect isn't currently portable to Windows or Mac. Let me know
-if you're seriously interested in a lot of work. I'm not saying it's
-not possible. It's definitely possible and the porting work at Sun
-has made it easier than before. But it's still not a weekend hack.
-Far from it.
-
-I actually requested some time to work on it this year and
-management said ("sure Don, go ahead") but I see now that they
-approved approximately 65 weeks worth of projects for me for the
-second half of the fiscal year. (Yes, I'm serious, they really did.)
-So I wouldn't hold my breath on this. I'm really hoping someone
-skilled with UNIX and NT volunteers some time. Funding contributions
-would also help.
-
-If you are a student and would like a fun but demanding job for the
-summer, let me know. I'd be willing to let someone come up to speed
-even if you don't already have all the skills. And we offer
-continuing internships if you'd like to come back for a semester or
-two. Pay is competitive. Note: you must be a US citizen and you must
-have good grades just to get through our personnel department.
-
-Don
-
-======================================================================
-
-**** Other... ****
-
-
-#33. Is it possible to prevent Expect from printing out its interactions?
-
-From: libes (Don Libes)
-To: Sunanda Iyengar <sunanda@simvax.labmed.umn.edu>
-Subject: Disabling display from Expect
-
-Sunanda Iyengar writes:
->Is it possible to have Expect interact with a process and not print-out
->the results of interaction? In my application, I need it to go into a
->silent mode, communicate with a process without reporting to the user, and
->then come back to normal mode and put the process into interactive mode.
-
-Use the following command:
-
- log_user 0
-
-To restore output:
-
- log_user 1
-
-See the Expect man page for more details or page 175 of Exploring
-Expect for details and examples.
-
-Don
-
-======================================================================
-
-#34. Why does it send back the same string twice?
-
-From: Don Libes
-To: yusufg@himalaya.cc.gatech.edu (Yusuf Goolamabbas)
-Subject: Duplicate pattern matches in Expectk
---text follows this line--
- Hi, I am trying to do a very simple thing in expectk
-
- spawn cat
- expect_background -re ".+" {
- send $expect_out(0,string)
- }
- exp_send "Hello World\n"
-
- Now the display in the text widget looks like this
- Hello World\r
- Hello World\r
-
- whereas I was expecting only one line
- Hello World\r
-
- Thanks in advance, Yusuf
- --
- Yusuf Goolamabbas yusufg@cc.gatech.edu
- Graphics, Visualization, & Usability Center (O) 404.894.8791
- College of Computing Georgia Tech
- http://www.cc.gatech.edu/grads/g/Yusuf.Goolamabbas/home.html
-
-This is correct behavior. The first "Hello World" is echoed by the
-terminal driver. The second is echoed by cat. This behavior has
-nothing to do with Expectk (or Expect for that matter). You can see
-this same thing if you type to cat interactively.
-
-% cat
-Hello World
-Hello World
-
-In the example above, I typed "cat" at the shell prompt and pressed
-return. Then I entered "Hello World" and pressed return. Looking at
-the output I *see* "Hello World" twice even though I only entered it
-once.
-
-You can account for this behavior in your patterns. Alternatively,
-just turn off the echo. In your particular case though, it's doing
-the right thing, showing you the result of an interactive cat just as
-if you had typed it yourself.
-
-In practice, this kind of problem doesn't arise - because programs
-like cat aren't spawned (except in very special situations). I assume
-that cat was just something you chose to experiment with.
-
-Don
-
-======================================================================
-
-#35. Why can't I send the line "user@hostname\r"?
-
-From: libes (Don Libes)
-To: bt@nadine.hpl.hp.com
-Subject: Re: [Q] Expect, ftp and '@'
-
-> I am attempting to use Expect to perform anonymous ftp gets without
->my having to type all the stuff --- I mean, waaaiiiting for the
->prompt, entering a-n-o-n-y-m-o-u-s with my fat fingers, and the rest.
->
-> But I have a probleme: as I set the password to be my e-mail address:
-> set password "bt@hplb.hpl.hp.com"
-
-> the ftp servers seem not to receive neither my login name nor the
->at-sign. Some of them do not care, some others say "ok, but don't do
->that again", and the last ones throw me off.
-
-The short answer is to upgrade to Expect 5.20 or later. (Warning:
-5.20 is still in beta.) If you don't feel like doing this,
-here's the explanation for older versions of Expect:
-
-spawn initializes the terminal by using your current parameters and
-then forces them to be "sane". Unfortunately, on your system, "sane"
-says to interpret the "@" as the line-kill character.
-
-The most sensible thing to do is change "sane" in your Makefile to
-something that makes sense. (Since you work at HP, you might also
-suggest that they modernize stty!)
-
-Here's an example of a replacement line for the Makefile:
-
- STTY = -DDFLT_STTY=\""sane kill ^U"\"
-
-Other alternatives are: quote the @, or use the -nottyinit flag, or
-set the stty_init variable.
-
-Don
-
-======================================================================
-
-#36. How do I hide the output of the send command?
-
-From: tim@mks.com (Timothy D. Prime)
-Subject: Re: hide the text of expect's send command?
-Date: 29 Mar 1996 15:41:02 GMT
-
-In article <khughesDoy1yH.5zo@netcom.com>, Kirby Hughes <khughes@netcom.com> wrote:
-> I don't want to see (on the screen) the text sent by a "send" command. Is
-> there a way to hide it? "log_user 0" works for text coming back to me, but
-> doesn't (seem to) work for sending...
->
-> #!/usr/local/bin/expect --
-> log_user 0
-> spawn telnet proxy
-> expect Command
-> send "c [lrange $argv 0 1]\n"
-> log_user 1
-> interact
-
-This answer courtesy of Timothy Prime, Mortice Kern Systems (tim@mks.com):
-
-The output you are seeing wasn't printed by the send command.
-(I.e., the log_user command is working just fine.) The output you see
-is from the interact command. The interact command found program
-output and thus wrote it to the terminal so that you could see it.
-That's what the interact command is supposed to do!
-
-Although the expanation might take a little thought, the solution is
-easy. Simply put an expect command in before the command "log_user 1".
-Match against the last characters that you wish to suppress.
-======================================================================
-
-#37. Why does "talk" fail with "Who are you? You have no entry utmp" or
- "You don't exist. Go away".
-
-From: libes (Don Libes)
-To: Will Smith (AC) <william@ritchie.acomp.usf.edu>
-Subject: Expect
-
-Will Smith (AC) writes:
->Hi there. I was wondering if you had any ideas to why i am getting
->this problem running an Expect script which tries to spawn a talk
->process to myself on another machine. Would it have anything to do
->with the fact that the executables are NOT installed in /usr/local/bin
->or because it wasnt installed by ROOT or what. This is what my Expect
->script looks like.
->
->#! /home/ritchie/ops/william/test/expect -f
->
->spawn talk william@curiac.acomp
->set timeout 200
->expect {*established*}
->set send_human {.1 .3 1 .05 2}
->send -h "This is only a test.. I swear \ Please don't bust me with expect \n >expect "{*\r*}"
->expect "{*\r*}"
->exec sleep 5
->send -h "Ok, well see ya tomorrow you idiot \n"
->exec sleep 3
->
->The error i get is that it returns this when i run the script.
->
-> Who are you? You have no entry in /etc/utmp! Aborting...
-
-On most systems, Expect does not automatically make a utmp entry. (A
-utmp entry normally indicates login information which seems kind of
-pointless for Expect scripts.) This allows Expect to run non-setuid.
-
-Normally, this lack of utmp entries doesn't mean much. However, a few
-programs actually refuse to run without a utmp entry. Fortunately,
-there are workarounds:
-
-Program-dependent solutions:
-
-"talk" is the only program I'm aware of that falls into this category.
-One solution is to get ytalk. ytalk doesn't have this problem plus it
-fixes many other bugs in talk, such as being able to communicate with
-both old and new talk.
-
-Program-independent solutions:
-
-Use a program specifically intended to create utmp entries. Such
-programs are easy to write or get if you don't have them already. For
-instance, sessreg is one which comes with the xdm distribution. And
-Solaris uses utmp_update. I like this approach because it isolates
-the setuid code in a small single system utility rather than in every
-program on the system that needs this ability.
-
-Don
-
-======================================================================
-
-#38. Why does . match a newline?
-
-From: libes (Don Libes)
-To: xipr@alv.teli.se (Ivan Prochazka)
-Subject: Why does . match a newline?
-Ivan Prochazka writes:
->
->Hello Don.
->
->In my opinion(and emacs) the regexp-symbol "." stands for all
->characters except newline(\n).
->This is not the case in Expect 5.2.
-
-Yes, there are some packages that follow this convention, but I don't
-think it is appropriate for Expect. Unlike emacs, most Expect
-patterns don't look for full lines - more often they look for prompts
-which *don't* end with newlines.
-
-I find that I actually write the [^\n] pattern very rarely. And
-if I write it frequently in a script, then the expect itself probably
-ought to be in a subroutine.
-
-In fact, the more common line-terminating sequence in Expect is \r\n,
-so that might make a more likely argument. In any case, Expect
-defines . the way POSIX does. So I feel pretty good about the
-definition of . being what it is.
-
-Don
-
-======================================================================
-
-#39. Why doesn't Expect kill telnet (or other programs) sometimes?
-
-From: libes (Don Libes)
-To: Karl.Sierka@Labyrinth.COM
-Subject: Re: need help running telnet Expect script from cron on sunos 4.1.3
-
-karl.sierka@labyrinth.com writes:
-> The only problem I am still having with the script I wrote is that
-> the telnet does not seem to die on it's own, unless I turn on debugging.
-
-Actually, Expect doesn't explicitly kill processes at all. Generally,
-processes kill themselves after reading EOF on input. So it just seems
-like Expect kills all of its children.
-
-> I was forced to save the pid of the spawned telnet, and kill it with an
-> 'exec kill $pid' in a proc that is hopefully called before the script
-> exits. This seems to work fine, but it makes me nervous since omnet
-> charges for connect time, and leaving a hung telnet lying around could
-> get expensive. I warned the rest of the staff so that they will also be
-> on the lookout for any possible hung telnets to omnet.
-
-The problem is that telnet is not recognizing EOF. (This is quite
-understandable since real users can't actually generate one from the
-telnet user interface.) The solution is to either 1) explicitly drive
-telnet to kill itself (i.e., a graceful logout) followed by "expect
-eof" or 2) "exec kill" as you are doing.
-
-This is described further in Exploring Expect beginning on page 103.
-
-Don
-
-======================================================================
-
-#40. How come I get "ioctl(set): Inappropriate ..., bye recursed" ...
-
-From: libes (Don Libes)
-To: james@Solbourne.COM (James B. Davis)
-Subject: How come I get "ioctl(set): Inappropriate ..., bye recursed" ...
-Date: Tue, 10 Dec 91 10:47:21 MST
-
->Every time I ^C out of a Expect script run I get:
->
->ioctl(set): Inappropriate ioctl for device
->bye recursed
->
->james@solbourne.com
-
-This answer courtesy of Michael Grant (mgrant@xdr.ncsl.nist.gov):
-
-You (or whoever installed gcc) forgot to run the fixincludes shell
-script while installing gcc. Recompiled gcc with itself, then run the
-fixincludes script - and the messages will go away.
-
-Michael Grant
-======================================================================
-
-#41. How come there's no interact function in the Expect library?
-
-From: libes (Don Libes)
-To: Djamal SIMOHAND <djamal@lyohp5.in2p3.fr>
-Subject: Re: exp_expectl
-Date: Wed, 3 Jan 96 12:17:01 EST
-
-Djamal SIMOHAND writes:
->I have already used the Expect program to write a script to connect by
->telnet on my machine. Now I made a graphic interface in C and I need
->the expect in C in order to have a coherent executable.
->
->I've already written most of the C already, but the connection is
->closed just after my program is finished. Then I have no opportunity
->to work on my machine. It seems I need of the equivalent of
->"interact" in C. Is there such a function in the C library?
->
->Thanks for your help,
-> Djamal
-
-No, there is no interact-like function in the C library. The reason
-is three-fold:
-
-1) It is simple enough to write your own. It's just a loop after
-all:
-
- while 1 {
- select/poll()
- read()
- write()
- }
-
-2) There's no way I could possibly provide all the options you might
-need. In Expect, it's not a problem because the environment is very
-controlled, but in C, it's impossible to control what you might want
-to do. For example, you mention that you're embedding your code in a
-graphics application. Graphics packages typically have their own
-event manager, so you wouldn't want a monolithic interact function.
-
-3) The library is intended for embedding in other applications, where
-it rarely makes sense to give the user direct control of a spawned
-process. That kind of thing makes so much more sense to handle with
-an Expect script than a C program. The C library was not intended as
-a replacement for Expect. Expect is really the tool of choice for
-interaction problems, not C.
-
-In summary, there's very little payoff for the library to supply an
-interact function. A simple one would only satisfy people who should
-be using Expect anyway - and it's impossible to create one that would
-do everything that everyone wants. It's easier just to let people
-roll their own.
-
-Don
-
-======================================================================
-
-
-Names of companies and products, and links to commercial pages are
-provided in order to adequately specify procedures and equipment used.
-In no case does such identification imply recommendation or
-endorsement by the National Institute of Standards and Technology, nor
-does it imply that the products are necessarily the best available for
-the purpose.
-
-Last edited: Thu Jun 6 07:35:19 EDT 1996 by Don Libes
+++ /dev/null
-This is the HISTORY file for Expect. Modifications made by Cygnus
-support are in ChangeLog. - Don
-
-Date Version Description
-------- ------- ------------------------------------------------------
-6/15/98 5.26.1 Dean Sauder <dsauder@dcn.att.com> noted C-preprocessor lines in
- configure must start in column 0.
-
-5/18/98 5.26.0 Kevin Schleicher <kms@lucent.com> noted xkibitz leaves xterms
- if first xterm is HUP'd. Kevin also noticed a resource leak
- in dislocate. Both problems fixed.
-
- Robbie Gilbert <rwg@fns.com> noted expect_devtty was logging
- devtty (twice) to stdout. Fixed.
-
- Added support inttypes.h, required on Solaris 5.6 for termios.h
-
- Kristina <kristina@greatbasin.net> noted that tip failed when
- spawned from a cgi script (BSDI BSD/OS 3.1 i386) because tip
- didn't see a definition for SHELL and HOME. They need to be
- set. (Doesn't have to be anything useful; the empty string is
- fine!) Solution: documented this in Expect man page.
-
- Zachariah Baum <zack@studioarchetype.com> noted that config.sub
- didn't grok Intel 686. Found a newer version that did in
- autoconf-2.11.
-
- POTENTIAL INCOMPATIBILITY: Changed interact so that it observes
- parity while matching. It used to ignore parity. This impacts
- people who use interact to connect through to a real serial
- device that generates parity. If matches don't work, use the
- exp_parity command. (This fix should have been made years ago,
- when the exp_parity command was added. It is now absolutely
- necessary now that people are doing matching with 8 bits.)
-
- After the second occurrence of a system admin who broke grantpt
- by removing setuid from the relevant system util, I added an
- explicit test and explanation.
-
- Disabled history in xkibitz. There seems to be some new
- incestuous relationship between history and unknown now so that
- redefining unknown leaves Tcl calling history but without
- knowing what it is because it's never been defined (as it would
- be by the traditional unknown).
-
- Fixed quoting bug in passwd.cgi example.
-
-9/28/97 5.25.0 Switched back to hand-generating pkgIndex.tcl file after too
- many complaints about problems running pkg_mkIndex.
-
-8/12/97 5.24.1 Chris Schanzle <chris@goof2.ncsl.nist.gov> pointed out that
- install fails on a virgin file system because install_shared_
- lib depends on a directory that hasn't yet been created.
-
- Larry Virden gave corrections to URLs in README.
-
-8/21/97 5.24.0 Bo Johansson <bo.johansson@mbox2.swipnet.se> noted TclWordEnd
- had changed and provided fix. This caused crash in expect.
-
-8/18/97 5.23.0 This version supports Tcl 8.0 and continues support for 7.6.
- Refs to Tcl_Files dropped. inter_return and close became
- obj cmds. Rewrote notifier (again) to accomodate new notifier
- model. Lots of other miscellaneous tweaks. Also see debugger
- HISTORY file.
-
- Finally removed long-deprecated commands "continue -expect",
- "send_spawn", and "getpid" and their exp_ versions.
-
- Harold Brauer <harold.brauer@canada.cdev.com> reported problems
- with an old SCO system (i386-unknown-sco3.2v5.0) that turned
- out to be due to a typo in the configure script.
-
- Jimmy Aitken supplied mods to config.guess for brand new and
- very old Pyramid systems.
-
- Buz Owen noted memory leak in use of expect_background (with
- no args).
-
- Jonathon Kamens noted provided patch for pty_termios.c for
- modern Sequent (which ptmx).
-
- Jonathon Kamens noted that TCL defined RANLIB for shared lib
- (if --enabled-shared) which isn't appropriate when Expect tries
- to build both shared and unshared libs.
-
- Jonathon Kamens noted that shared lib config didn't work on
- SunOS. I had used Tcl's SHLIB_SUFFIX instead of its
- SHARED_LIB_SUFFIX.
-
- Qingyi Liao <liao@casabyte.com> encountered core dump when
- exp_bg -i $exp_spawn_any was retracted. Bug in ecmd_remove_fd.
-
- Fixed a bunch of bugs in example/gethostbyaddr.
-
- Josef Sachs noted that stty cannot be caught when no /dev/tty.
- It calls exit instead of returning an error.
-
- Gordon Chaffee <chaffee@plateau.CS.Berkeley.EDU> patched
- Exp_WaitCmd - it was zeroing pid element instead of wait.
-
- Bob Manson <manson@cygnus.com> provided fix for HP on which it
- was possible for timer to be mistakenly deleted in
- exp_get_next_event while processing a pty open event.
-
- Jeff Slonaker <JSlonaker@osc.uscg.mil> noted that exp_poll.c
- had wrong signature and poll had arguments out of order! That
- would suggest that no one has ever used exp_poll.c before...
-
- 5.22.1 Larry Virden noted that TCL_BUILD_LIB_SPEC can't be used if
- build directory has been removed. Added check to configure.
-
- Worked more on package command. Buz Owen pointed out that my
- code wouldn't support redefinition of TCL_LIBRARY. Bumped up
- minor version to avoid package loading mishaps.
-
- Nigel Standing <nigel@idiom.com> noted lack of C-u binding in
- tkpasswd - must be due to change in tk4.2.
-
- Forced env(SHELL) to be defined inside kibitz for when using
- with CGI.
-
- Charles Packer <packer@fermi.gsfc.nasa.gov> noted that CRAY-YMP
- needed sys/types.h in exp_console.c
-
- Extra / when developing defn of TCL_LIBRARY. Shouldn't
- actually cause any problems though.
-
-2/3/97 5.22.0 Fixed package support - again. Sigh.
-
- David Pasirstein <dpasirst@sun.cs.wcupa.edu> noted that RedHat
- Linux 2nd passwd prompt requires slightly different pattern -
- modified mkpasswd and tkpasswd.
-
- Toshiaki Nomura <nom@yk.fujitsu.co.jp> provided patch to
- config.guess for Fujitsu DS/90.
-
- Roger Brooks <R.S.Brooks@liverpool.ac.uk> noted C lib passed
- argv[0] instead of file to first arg of execvp.
-
- Cary D. Renzema <caryr@mxim.com> noted that a simple puts -nnl
- might never appear - Expect closes all of its fds before Tcl
- gets a chance to flush. Stdout is the obvious problem since
- Expect thinks it can cavalierly close that too. Hmm.
-
- At request of Tom Tromey, solved possible missing tclRegexp.h
- problem by having Expect install it. Cleaned up TCLHDIR and
- TCL_LIBRARY hackery in Makefile.
-
-12/27/96 5.21.7 Nelson Beebe noted unset is not portable in /bin/sh. Removed
- and converted everything to understand CONFIG_SHELL.
-
- Modified cryptdir to strip out shell metachars from filenames.
-
-12/10/96 5.21.6 Michael Schumacher noted that some systems cannot build
- unshared libs from shared objects. Chose to go with BLT's
- approach of building shared objs in separate shared directory.
-
- Buz Owen <ado@bbn.com> noted that "package require Expect"
- didn't work because it looked for Expect lib in the wrong
- place (well, the "documented" place). The problem is that Tcl
- insists libraries should be in the same directory as the
- pkgIndex.tcl file while the natural thing to do would be to
- split them up and put the .tcl file in the arch-indepent
- app-specific scripts dir and the lib in the arch-dependent
- common dir. Sigh. If this is ever fixed/changed, the
- instructions in the Makefile should be fixed.
-
- <Van.Trinh@siemenscom.com> noted that expect library name
- exceed filename max on some systems - like his old SCO.
-
-12/4/96 5.21.5 Michael Schumacher noted new configure wasn't passing on Tcl's
- shared lib cflags.
-
-10/26/96 5.21.4 Achyutram Bhamidipaty <ram@epic.com> ran into bugs in Expect's
- file event handler which prevented expectk from entering
- implied event loop. Also found one memory problem - thanks
- to CenterLine.
-
- Tom Tromey fixed handling of --enable-shared when overriding
- Tcl's value et al. Tom also added missing "else true" to
- Makefile: "In a Makefile, you have to always supply an "else"
- clause for an "if", to work around a bug in certain versions of
- sh. In some versions of sh, an "if" whose test fails will
- return the status of the test if there is no "else" clause --
- causing spurious make failures." See ChangeLog.
-
-10/18/96 5.21.3 Example directory was missing several examples.
-
-10/17/96 5.21.2 Debugger section of configure file corrupted.
-
-10/10/96 5.21.1 Oops, distribution unpacked into wrong version.
-
- Tom Tromey provided patch for stty to understand OSF 4.0.
-
-9/28/96 5.21.0 Official Expect release for Tcl 7.5.
-
- Junio Hamano <junio@twinsun.com> provided fixes for aclocal
- for with_tcl/tkconfig.
-
- Roger Billau <rfbilla@amtnet.sandia.gov> noted that C library
- didn't work on Solaris 2.5. Turns out Solaris requires fflush
- be called between input and output operations on FILE pointers.
-
- Lots of Cygnus mods - see ChangeLog.
-
- Sid Cowles <scowles@incyte.com> and Hans Riethmann
- <hans@F1.telekurs.ch> noted relative path specs of tcl-includes
- (and others) caused debugger config to fail since it is at a
- different directory level.
-
- Al Snow <asnow@fuwutai.att.com> noted -C failed due to typo.
-
-8/17/96 5.20b18 Andrew Rakowski <andrew.rakowski@nr.usu.edu> noted no defn of
- LIB_RUNTIME_DIR, a creation of Tcl7.5p1.
-
- Tom Tromey added -v to Expect and -version to Expectk.
-
- Ben Boule <bboule@xylogics.com> noted that Interactive (IUNIX)
- requires 9 char max length after -l. Looks like squeezing out
- the "." is sufficient. He also noted that IUNIX needs -Xp in
- LIBS to find strftime. This test should really be done by Tcl.
-
-8/12/96 5.20b17 Glen Biagioni <glen@prosoft.com> noted interact -re "A(xx)"
- failed to match. Problem turned out to be that Tcl 7.5 changed
- a constant which in the regexp code, which Expect didn't see
- because it provides its own defn for interact. Alas, the one
- thing Expect reuses from Tcl was where the change was. This
- should really be fixed so Expect doesn't rely on Expect in this
- way, but there's no point in putting in a lot of work on regexp
- when we're anticipating a new one soon anyway.
-
- Bjorn S. Nilsson <nilsson@nbivms.nbi.dk> noted fixcat hangs.
- Turned out that new Tcl (7.5p1) now waits for all children to
- disappear. But Expect still had a handle to a child. I added
- an exit handler to close the connections before Tcl's exit
- handler.
-
- Tom Tromey provided patch to support augmenting CFLAGS on
- Makefile invocation.
-
- Gary Merinstein <gmerin@panix.com> noted that configure failed
- on his linux unless it had --enabled-shared. Not quite sure
- about how this can be, but the flag wasn't being passed to the
- debugger's configure, so I've fixed that and hopefully this
- will cure the original prob.
-
- Added initial announcement of full version at beginning of
- configure. This should ease my pain in responding to people
- sending me config output without including version numbers.
-
- Tom Tromey noted expect_cf.h was machine dependent. Fixed
- expect_comm.h so that it no longer required expect_cf.h (which
- should be renamed to indicate it is no longer public).
-
- Bart Robinson <lomew@cs.utah.edu> provides mods to support
- openpty() in FreeBSD/NetBSD. Without openpty, Expect doesn't
- see the full pty namespace (ptyX[0-v]).
-
-7/15/96 5.20b16 Nathan Estey <nfe@the-hermes.net> noted that Makefile failed
- on SunOS when shared libs were enabled due to incomplete dot
- stripping in lib prefix.
-
-7/6/96 5.20b15 Malcolm Tredinnick <malcolmt@geko.net.au> noted that shared lib
- has to be installed before building expect. Also noted that
- ldconfig should be run on Linux 2.0 systems and maybe others.
-
-6/25/96 5.20b14 Tim Mooney provided fixes to obey --includedir and similar
- configure conventions.
-
-6/25/96 5.20b13 A bug when installing Expect using new _installed targets.
-
-6/24/96 5.20b12 Numerous complaints from Solaris users about shared libraries.
- Unfortunately, no one is giving me configure-ready fixes so
- (and Tk's configure seems to have bugs as well) so fixing
- these is like throwing darts.
-
- Stan Brown <stanb@netcom.com> noted noidle example broke when
- fed "-".
-
- Gordon Irlam <gordoni@cygnus.com> noted typo in install-sh.
-
- David Sheinberg <sheinb@bcmvision.neusc.bcm.tmc.edu> noted no
- args test for spawn -open/leaveopen.
-
- Misc patches from Tim Mooney to pacify much of gcc -wall.
-
- Kayvan Sylvan insists Linux stty reads from stdin so added
- hardcoding to configure.in for that. In xkibitz, Linux stty
- -raw didn't disable all post-processing. How odd that it is
- not a problem in interact. In the meantime, added extra stty
- to xkibitz to do what was missed.
-
-5/30/96 5.20b11 Kayvan Sylvan <kayvan@sylvan.com> noted quoting bug in
- autoexpect.
-
-5/22/96 5.20.b10 Patches from Larry Virden in Makefile.in and exp_int.h
-
-5/20/96 5.20.b9 Too many substitutions in configure caused sed failures on
- DEC (limit 99) and HP (100). Commented out definitions
- that weren't absolutely critical. Hopefully, this gets us
- under the limit but can't be sure since there's no easy way
- of knowing.
-
- Numerous mods from Mark Diekhans to support clist-style ptys
- on SCO OpenServer. (He says SVR4 ptys are broken on that
- platform.)
-
- Simon J. Gerraty <sjg@zen.void.oz.au> says that write() returns
- 0 inside of exact_write on SunOS. This is outside the SunOS
- spec so of course we have no idea what's going on. So I added
- code to try and recover from (or at least warn of) this.
-
- Tom Tromey unified decls of errno to #includes.
-
-5/13/96 5.20b8 Tim Mooney <mooney@dogbert.cc.ndsu.NoDak.edu> pointed out
- backwards stty test - this would have corrupted every platform!
- He also pointed out that alpha-dec-osf3.2 (3.2c) complained
- too many args to sed. Someone earlier said similarly about
- HPUX 10, but I assumed it was the quotes in the weird stty
- flag I was passing, so that "fix" wasn't. GNU sed has no
- problem, but obviously this is not sufficient for many people.
-
-5/10/96 5.20b7 Renamed/numbered versions so that it's easier for others to
- track.
-
- Upgraded to autoconf 2.10.
-
- Matthias Kurz <mk@baerlap.north.de> noted Makefile problems
- with final Tcl7.5.
-
- Blair Zajac <blair@gps.caltech.edu> noted configure mishandled
- stty defaults on HP and shared lib must be installed executable
- on HP.
-
- autoconf insists on adding -O to CFLAGS when using gcc. Ack!
-
-3/23/96 5.20b1 Beta release 1 of Expect for Tcl 7.5.
-
- Michael Hunter <mphunter@qnx.com> provided misc mods for QNX.
-
- Various people reported problems with IRIX. Removing from the
- stty list fixed the problem. Similar problem with Solaris.
-
- Added explicit close to autoexpect. Added a mechanism for
- enabling conservative mode after script is generated.
-
- Hal Schechner <hal-j@netusa.net> pointed out passwd.cgi must
- meet passwd's requirement that it not be run by an unrelated
- user. Easy enough - just do an su first.
-
-3/26/96 5.20a5 Alpha release 5 of Expect for Tcl 7.5b3.
-
- Added example passwd.{html,cgi} to change a password.
-
- Many fixes from Stephen Williams <steve@icarus.com>
- and Jonathon Kamens for Makefile and configure.
-
-3/22/96 5.20a4 Alpha release 4 of Expect for Tcl 7.5b3.
-
- Added version number to lib directories (POTENTIAL
- INCOMPATIBILITY).
-
- Revised gethostbyaddr example - evidentally hadn't worked for
- some time!
-
- Jan Nijtmans <nijtmans@nici.kun.nl> provided pkgIndex.tcl.in.
- Renamed Exp_Init to Expect_Init to support package cmd.
- Provided #define so that Exp_Init will continue to work.
-
- Revised exit handling so that it works if Expect is dynamically
- loaded.
-
- aclocal.m4 Patches from Tom Tromey.
-
-3/15/96 5.20a3 Alpha release 3 of Expect for Tcl 7.5b3.
-
- Edward Haletky <elh@astroarch.com> noted that Machten required
- inclusion of types.h in exp_tty_in.h.
-
- Added various patches from Rob Savoye. One incompatibility
- is that the static lib now ends with the version number.
-
- Added support for TCL_SHLIB_{LD_LIBS,VERSION} in Tcl b3.
-
- Jonathan Karges <J.Karges@dkfz-heidelberg.de> found that clib
- was timing out immediately on -1.
-
-3/6/96 5.20a2 Alpha release 2 of Expect for Tcl 7.5b2.
-
- Leland Joseph <leland@tec.tetd.bellcore.com> noted
- expect-tests.exp exceeds the 14 character filename length.
-
- Added config.{sub,guess} to support AC_CANONICAL_....
-
- Rewrote much of aclocal, configure.in, and Makefile.in
- to handle Tcl/Tk config.sh files and shared/dl support.
-
- Simplified varargs/stdarg mess for Expect's C library.
-
- Threw away closetcl junk. No longer required because
- Tcl finally started doing close-on-exec.
-
- Incorporated various fixes from Tom Tromey at Cygnus.
- See ChangeLog for details.
-
- Added require/provide support.
-
- Rejiggered event handling to support new Tcl_File interface.
-
- Removed libexpectk. Because event loop was moved into Tcl, it
- is no longer necessary for it to be different than libexpect.
-
- Removed all support for earlier versions of Tcl and Tk.
-
- Numerous misc patches from Paul Eggert <eggert@twinsun.com>
- most to support Tcl 7.5.
-
- Arnold Robbins supplied yet another patch to fix earlier
- problem noted by Hume Smith.
-
- David Engel <david@ods.com> reported problem with Linux dumping
- core. CenterLine, of course, immediately found the problem -
- uninit'd lowercase buffer.
-
- Peter Haggerty <haggerty@borg.lib.vt.edu> noted that his Next
- died in cron. It seems that Next doesn't support O_NOCTTY
- (even though the man pages says it does) and so during pty
- testing, control terminal would get allocated and then kill
- the process (by generating a HUP) when deallocated. Avoid
- by ignoring HUP when doing pty testing on such machines.
-
-1/3/96 5.19.0 Fixed bug that made expect report wrong string when using
- a terminating anchor in a positive-length glob match,
- reported by Graham L. Randall <grandall@nit.airtouch.com>.
-
- Added rlogin-display to included examples. rlogin-display
- automatically propagates your $DISPLAY when you rlogin.
-
- Hume Smith <hclsmith@localhost.isisnet.com> noted problem
- with day of the week calc at year end/start. Arnold Robbins
- supplied fixes.
-
- Jonathan Kamens provided fix to make sync byte reads
- recover from EINTR.
-
- Henry Spencer noted errant line of spaces in Makefile.
-
-10/21/95 5.18.1 Began adding support for tcl7.5a1/tk4.1a1. (not finished!!)
- - Make aclocal understand new Tcl/Tk directory layout
- for finding tclInt.h and private libraries.
- - Added support for Tcl_AsyncReady.
-
- Paul Townsend <aab@aab.cc.purdue.edu> noted that distclean did
- not remove some config cruft. Also recommended unsetting
- M*FLAGS that cause make called from configure to fail.
-
- Various fixes from Cygnus. See Changelog.
-
- Deleted "-" before rm in loop in deinstall in Makefile as per
- Doug Claar <dclaar@hprtnyc.ptp.hp.com>. Doug also found prob
- involving recent STTY fix. Symptom was that pty wasn't
- correctly inited in cgi scripts on HPs - and Cray pty support
- blew up entirely.
-
- Added exp_ prefix to tests so that they can be run with other
- extensions.
-
- Seth Ornstein <pp001465@pop3.interramp.com> noted bug in the
- way rftp detected symlinks.
-
- Upgraded to autoconf 2.4. This fixes a bug in AC_PROC_CPP
- which blew up when CPP was defined in the environment. Noted
- by John Pfuntner.
-
- Jonathan Kamens noted that library didn't check return pipe()
- return value.
-
- Added vrfy example.
-
- Przemek Klosowski <przemek@rrdjazz.nist.gov> Irix 6.0 fails
- to use ptys that have been used by someone else. SGI admitted
- this is a bug and the solution is to upgrade to 6.1.
-
- Yoad Grinberg noted "expect -timeout" mistakenly ate next arg
- as pattern.
-
-8/24/95 5.18.0 Wayne Christopher noted that the way exp_eval_with_one_arg
- modifies the original argv makes the ICEM Tcl compiler unhappy
- so I rewrote it to avoid that.
-
- Ian Zimmerman <itz@rahul.net> found that a braced arg list of
- a single pattern beginning with a \n caused expect to reeval
- for multiple args twice. I added a -nobrace flag that expect
- and/interact can use internally to prevent this.
-
- Florian La Roche <florian@jurix.jura.uni-sb.de> noted a few
- glitches in the way -ltcl was searched for in aclocal.
-
- Joachim Posegga <posegga@ira.uka.de> noted lack of Tcl internal
- includes should be an error during configure.
-
-8/10/95 5.17.8 Martin Wunderli <wunderli@baloo.limmat.net.ch> found missing
- quote in config.
-
- Danny Faught noted problems in Makefile when passing STTY defn
- with quotes. Created another a STTY-less CPPFLAGS for cases
- where additional reexpansion occurs.
-
- Danny Faught noted bug in error handling for checking
- permission problem with /tmp.
-
-8/1/95 5.17.7 Todd Rimmer <trimmer@mantis.ssw.com> noted that HP 10 with
- optional streams package has both PTYM and PTMX which conflict
- in pty_termios.
-
- Rainer Wilcke provides fixes: scripts not listed as dependency.
- distclean target used Makefile after deleting, and many fixes
- to man pages.
-
- Saad Mufti <mufti@hobbit.pls.com> noted bug in how C library
- handled polling (when handling multiple fds).
-
- Jeff Bowyer noted more autoexpect bugs.
-
-7/22/95 5.17.6 More features added to autoexpect (now version 1.3).
-
- Sanjay <sanjay@clef.lcs.mit.edu> noted bug in TCLH config macro
- which caused it to use 7.3 instead of 7.4.
-
- Rodney Barnett <rlb@us.teltech.com> noted expectd.proto had a
- few refs to interact_out where it should've had expect_out.
-
- Terry Rhodes <tbr@88open.org> noted that Expect returned a 0
- exit status upon syntax error unlike tclsh and wish.
-
- Fred Obermann <fredo@conan.ids.net> noted that Unixware 2.01
- native development tools don't permit configure to find memcpy
- because memcpy is handled specially by the compiler and it
- complains when it finds configure's default test with no args.
- Changed to a hand-crafted test with args.
-
-7/12/95 5.17.5 Jeff Bowyer <jbowyer@muni.cz> noted minor bugs in autoexpect.
-
- Rob Saul <robs@sco.com> noted that configure failed on SCO OSR5
- because trap requested by Cygnus (to allow config in bg) used
- higher traps than SCO sh knows about.
-
- Changed "can't happen" to "xmkmf is broken" when configure
- fails to compile simple C-Tk program.
-
- John H. Chauvin <jchauvin@netcom.com> noted exp_tty_current and
- cooked raised multiple def errors on SGI 5.3 with native cc.
-
-7/9/95 5.17.4 Wolfhardt Lotz <s11@blue.lrw.uni-bremen.de> noted Solaris
- doesn't do case-insensitive man page lookups so I lowerized
- the beginning of the .SH lines.
-
- Henry Spencer noted unbackslashed quotes in the autoexpect
- boilerplate.
-
-7/3/95 5.17.3 Modified VARARGS decls to support new Tcl 7.4 definitions.
-
- Fine-tuned aclocal so that it would prefer later versions.
-
- Added autoexpect example and man page.
-
-6/30/95 5.17.2 select-based dsleep() was returning an internal expect-style
- return code instead of a Tcl-style.
-
-6/30/95 5.17.1 Kannan Varadhan <kannan@isi.edu> noted aclocal didn't
- look in right directories to find Tk.
-
-6/30/95 5.17.0 Modified regexp interfaces to support Tcl 7.4b4.
-
- Mods from Tony Isles <ittony@traf.com> for Sequent Dynix/ptx
- V2.1.5 (which is really old).
-
- Michael Schumacher <hightec@rz.uni-sb.de> noted that Solaris
- 2.4 header files require __EXTENSIONS__ for all sorts of
- traditional but non-standard definitions.
-
- Modified aclocal to support new Tcl/Tk library names.
-
- George Forman <forman@cs.washington.edu> requested support in
- C lib for fds that already exist. I added exp_spawnfd.
-
- Fixed bug preventing signal rearming on Linux (using SV-style
- signal handling).
-
- Wayne Christopher <wayne@pmac.icemcfd.com> noted missing interp
- in call to exp_error.
-
- Added null support to interact's exact matching.
-
- Bruce Jerrick noted INSTALL was being used rather than
- INSTALL_PROGRAM/DATA.
-
- Dennis Ferguson <dennis@mci.net> noted that on Solaris 2.4
- close(pty) occasionally returns EINVAL.
-
- Added tests so that if we can't get a pty, we can give the user
- much more help with what to do about it.
-
- Steven Byrnes noted that Solaris has replaced TIOCCONS with
- SRIOCISREDIR interface.
-
- Technically speaking, interact shouldn't do buffer-shuffling
- but I've added as a fail-safe mechanism to catch people who
- use preposterous patterns.
-
- Alan Heckert <heckert@tiber.nist.gov> noted missing decl in
- Convex pty support.
-
- Fixed all expectk examples for Tk4.
-
- Bryan S. So <so@cs.wisc.edu> noted that interact -o eof failed
- if an unbuffered pattern was partially in progress.
-
- Added -timeout flag to expect command to override timeout var.
-
- John Pfuntner <pfuntner@VNET.IBM.COM> noted that OpenMVS did
- not notice @ inside of Makefile SETUID macro as suppression
- but instead treated it as part of the program name.
-
- Jim Porter <James.W.Porter@att.com> noted that exp_free_i freed
- the variable name even if not allocated.
-
- Yet more mods to aclocal and various .in files from Rob Savoye.
-
-4/21/95 5.16.3 Matija Grabnar <Matija.Grabnar@ijs.si> noted that sleep maxed
- out after about 36 minutes. Turned out to be a poor assumption
- in some interfacing code.
-
-4/19/95 5.16.2 rbd <uport@netcom.com> noted tcl_RcFileName multiply defined
- when compiling with Tk4.
-
-4/16/95 5.16.1 Robert Nicholson <robert@steffi.dircon.co.uk> noted NextStep's
- sys/wait.h is not POSIX-like so WNOHANG fails to get a defn.
-
- Alexandre Rafalovitch <arafalov@socs.uts.edu.au> discovered
- example on dislocate man page didn't work. I fixed it.
-
-4/8/95 5.16.0 gcc 2.3.3 complains about internal errors so I figure: time to
- upgrade. Switched to Cygnus 2.6-95q1. Works now but now
- complains about wait status. I trashed all the gory wait
- status configure code and adopted autoconf's suggestion about
- refusing to use sys/wait.h if not POSIX.1 compatible. Nice!
-
- Jeffrey C Honig <jch@nr-tech.cit.cornell.edu> requested a -gmt
- flag for timestamp command.
-
- Chuck Ocheret <chuck@gigadactyl.com> noted that expect -pty
- fails. Problem is that Tcl's exec blindly closes all the fds
- between 3 and its own highest fd. See comments in code.
-
- Loris Caren <loris@caren.demon.co.uk> noted eof in fg bombs on
- Linux. Turns out to be analogous to eof in bg problem fixed
- in 5.14.0.
-
- Upgraded to autoconf 2.3. Continued making changed to config
- script to take advantage of autoconf 2 capabilities.
-
-4/1/95 5.15.4 Steve Simmons noted .x remnant from earlier dir install proc.
-
-3/31/95 5.15.3 Forgot to export TCLHDIR defn when configuring debugger.
-
-3/29/95 5.15.2 Steve Simmons <scs@aisinc.com> noted Makefile multiple defined
- distclean and it might be nice to provide aclocal.m4 even
- though it isn't normally used.
-
- cevans@resdev1.ppco.com added prompts to passmass for AIX.
-
-3/27/95 5.15.1 Fixed tkterm script - inadvertently left tic debugging on.
- Also add support for Ctrl-space and Ctrl-@ as requested by
- Zbigniew Wieckowski <wieckows@cs.umn.edu>.
-
- Larry Virden asked that configure also check for .so libs.
-
-3/23/95 5.15.0 Everitt Beers <ebeers@scf.usc.edu> noted that Linux doesn't
- support kill -STOP 0. Changed 0 to [pid].
-
- zhengping (z.) you <you@bnr.ca> found bug where a bg expect did
- not rearm a spawn id after a first bg expect (and another one)
- to clear it.
-
- Elliott Wolin <wolin@physics.wm.edu> noted that tkterm
- complained if tic wasn't found. I'll have it override the
- user misconfig in that case. Also noted that interact failed
- on AIX. Evidentally, my new config tests for ISC found that
- AIX looked just like it. Added additional test for tcsetattr
- to distinguish them.
-
- Rob Savoye asked for Dbg config.in to be distributed. Rob
- supplied numerous other mods: install-sh replaced install.sh,
- mkinstalldirs, testsuite mods, new aclocal.m4, support for
- recursive make.
-
- Fixed bugs in configuration of debugger.
-
- Disabled configure's file-caching.
-
- Kannan Varadhan <kannan@isi.edu> noted incorrect diag reporting
- TCLHDIR in configure.
-
- Marty Olevitch <marty@howdy.wustl.edu> noted that DEC Alpha
- did not sleep correctly because configure didn't find sleep
- and found poll (which is broken). Problem turned out to be a
- bug in autoconf's AC_CHECK_FUNC. Got patch from Jim Meyering
- <meyering@comco.com>
-
- Fixed config probs for Edward Huie <huie@net.com> on Mac SE/30,
- System 7.1, Tenon Intersystems' MachTen 2.1.1-G (BSD 4.3 on
- Mach kernel) and MachTen X11R4 3.1.
-
- Moved libraries forward in configure to allow for AC_CHECK_FUNC
- to succeed when funcs are in other libraries.
-
- Made configure test for Linux and unset CFLAGS=-g if so.
-
-2/25/95 5.14.3 Larry Virden noted configure was missing brackets in raw shell
- cmds evidentally due to m4 interpretation.
-
-2/24/95 5.14.2 Larry Virden noted configure was not correctly rewriting from
- --(exec-)prefix. Due to new autoconf. Also noted glob was
- finding tclX directory.
-
- Hal Peterson noted that because configure now actually attempts
- a link before using a library, the code to check for -ltk would
- have to worry about all the other utility libraries first.
-
-2/23/95 5.14.1 Hal Peterson noted that configure.in checked incorrectly for
- tcllib.
-
-2/22/95 5.14.0 Jamal <root@lonestar.tlug.org> noted Linux has tic in a
- different place than on my system - affected tkterm script.
-
- Xiaokun Zhu <xiaokun@stats.gla.ac.uk> noted problem on DEC
- Alpha OSF/1.3 evidentally due to backwards decl of index macro.
-
- Greg McFarlane <gregm@nms.otc.com.au> noted that large args in
- send cmd cannot be passed blindly to exp_error.
-
- david d `zoo' zuhn <zoo@armadillo.com> requested modifying
- configure so that it did not require Tcl/Tk to be built - only
- configured. This means that it may not find installed
- libraries. Hopefully, this won't cause anyone problems but its
- not my preference.
-
- Fixed error which caused spurious eof when changing patterns
- in expect_bg.
-
- Moved to autoconf-2.1 and m4-1.4. Rewrote a LOT of the config
- file. Finally got my hands on an ISC box and fixed configure
- for that.
-
- Tony Booker <tb@sequent.com> provides mods for Sequent ptx 2
- and 4.
-
- Jeffrey Friedl <jfriedl@nff.ncl.omron.co.jp> provided fixes for
- timezone handling in config and exp_strf.c.
-
- David Schmitt <dschmitt@netcom.com> noted that library did
- not detect eof on HP. I didn't think this was necessary for
- read() but it evidentally is. I added the support for raw fds
- although it is not obvious to me how to do it for FILEs.
-
- James Carter <jimc@math.ucla.edu> noted expect_after couldn't
- worked in the exp_bg because I had accidentally written BEFORE
- instead of AFTER when checking the cases. He also found that
- the eof body could be trashed in an exp_bg.
-
- Ousterhout apologized for the Tcl7.4 change I noted in 5.13.1
- and said he will undo it.
-
- Eric Frias <efrias@vt.edu> found library bombed after timeouts.
- exp_match_end was not updated - which makes sense since there
- was no match - however the following expect call assumed that
- exp_match_end was meaningful in order to do its buffer
- shuffling.
-
- Jonathan Kamens supplied new configure test for REARM_SIG after
- noting old could fail if limit prevented creation of core file.
- He also noted REARM_SIG had accidentally been commented out
- of cf file.
-
- Vincent D. Skahan <vds7789@aw101.iasl.ca.boeing.com> noted that
- Apollo's stty reads stdout and doesn't complain if its bogus.
-
- Yoad Grinberg <grinberg@vnet.ibm.com> noted that SIGCHLD does
- not work for forked processes, only spawned processes. Fixed
- this and added counting to make sure none get lost.
-
- Hal Peterson contributed mods for Unicos. He noted that
- configure should be more careful adding libs to the link line.
- On the Cray, non-existent libs generate warnings which are not
- detected by configure but which annoy make.
-
- Bela Gazdy <bela@euch3e.chem.emory.edu> noted /etc/resolv.conf
- misspelled in kibitz.
-
- Rainer Wilcke noted that "send -null/break" mishandled return
- code, and these and send/expect_tty were not in man page.
-
- Dvorak example was missing -- in send -.
-
-1/12/95 5.13.2 Peter Wassenaar <peterw@stack.urc.tue.nl> noted that kibitz
- didn't work on AIX. My fixcat script assumed that AIX's cat
- was like HP's cat - buffered by default.
-
-1/7/95 5.13.1 Marc Bouron <mbouron@lhr-sys.bru-ro.DHL.COM> noted I forgot to
- add virterm to distribution.
-
- Marc W. Mengel <mengel@dcdmwm.fnal.gov> noted that configure
- must be run in the foreground due to the stty tests. Added
- this to documentation.
-
- Modified interpreter to account for the change in Tcl7.4 which
- forces Tcl_RecordAndEval to call Tcl_GlobalEval instead of
- Tcl_Eval.
-
- Changed ptys to be initialized based on current tty setting
- rather than original tty setting.
-
- Stephen Melvin <melvin@zytek.fr> noted that set -e is the real
- problem with ash (see 5.13). I bet "[" is returning a value
- and triggering it. It appears that the script can live without
- the set, so out it goes.
-
- Braun Brelin <bbrelin@netcom.com> noted pipe allocs in spawn
- could fail with meaningless error message.
-
-12/15/94 5.13.0 Synchronize with appearance of "Exploring Expect". This
- distribution corresponds to the book both in description of
- Expect and in containing all the substantive examples.
-
- Graham Mark <gam@lanl.gov> noted that his Cray (Unicos 7.0.6.1)
- didn't recognize TCSETCTTY. Since this was in some Cray-
- specific code, I guess Unicos must have changed some .h files.
- I made it include either termios or termio. It, at least,
- works on our Cray (Unicos 8.0.2.4).
-
- Robert Withrow <witr@rwwa.com> noted that FreeBSD 1.1.5.1
- supplied union wait but waitpid doesn't use it! So I modified
- configure to be smarter. He also noted that its /bin/sh is
- really ash which blows up on install.sh. It appears that it
- doesn't handle uninitialized parameters correctly. I'm not
- going to fix this because having a broken /bin/sh is so awful
- probably other things are breaking too. He did note that it
- worked if he switched to bash or the native install, but that
- blows the whole point of install.sh - that we have found too
- much variation in native installs. Rather than try and figure
- out everyone's variation, we'd like to simplify our life and
- use this common, simple-to-understand sh script.
-
- Added more example scripts: Adrian Mariano's virterm (like
- expect_term but without relying on Tk), gethostbyaddr, and
- expectd.proto for telnet daemon.
-
- Matt DiMeo <mdimeo@brooktree.com> noted that expect_background
- failed to detect eof on HP. I had forgotten to pass the mask.
-
- Josef Sachs noted that expect_background put Tk's event handler
- in an infinite loop if it was listening to a pipeline that was
- killed. I had aborted the cleanup procedure if Tcl's close
- reported an error. That was a mistake.
-
- Rick Lyons <rick@razorback.brisnet.org.au> noted a bug. C lib
- expect would turn a normal read into a poll if remtime reached
- zero on the nose.
-
- Added ResetResult to Exp_Init to clean up diags in Expectk.
- Made GENFUNCs return -1 on error as per ParseArgv's convention.
-
-11/13/94 5.12.0 Alon Albert noted that in clib, exp_match_end should be init'd
- to exp_buffer before trying to match the pattern - if the
- expect doesn't produce a match, exp_match_end is incorrect and
- will be wrong for subsequent expects.
-
- Steven Diamond noted that fg expect did not react to a change
- in an indirect spawn id list if it was just waiting for I/O
- (rather than looping in exp_continue).
-
- Wait fix in previous version broke system() whose return value
- is horribly overloaded.
-
-11/10/94 5.11.0 Stephen Fitzpatrick <sfitzp@cs.qub.ac.uk> noted that NeXT wait
- macros do not accept int wait status. Switched to using Tcl's
- detection of wait status type.
-
- Made log_file -leaveopen leave file id open until close like
- spawn -leaveopen did.
-
- Bruce Jerrick <bruce@cse.ogi.edu> noted public include dir
- wasn't getting created.
-
- Karl Vogel noted 1) Pyramid has index instead of strchr, strf.c
- needs sys/time.h instead of time.h in strf.c, needs to call
- timezone(), and stty reads stdout but usual stty test fails.
-
- Made expect_out(spawn_id) always be written to assist people
- who want to log different procs to different files. This is
- no longer an efficiency problem because interact can do so
- much more then it used to. Made full_buffer condition write
- forgotten chars even when full_buffer isn't explicitly
- specified.
-
- Bert Robben <Bert.Robben@CS.kuleuven.ac.be> noted that the
- debugger needs to know about the presence of stdlib.h. I was
- hoping to avoid this because it's a pain getting configure to
- call another configure.
-
- Rainer Wilcke provide several improvements for xkibitz and man
- page.
-
-10/6/94 5.10.0 Moved example files around. Added password generation to
- tkpasswd. Created standalone script to generate and set
- passwords - good for all those adduser shell scripts.
-
- Rick Cady <rickc@NSD.3Com.COM> found a bug when switching log
- files.
-
- Rainer Wilcke <wilcke@esrf.fr> noted that xkibitz died when
- closing a connection. stdin was mistakenly being closed. He
- also noted that killing xterms under HPUX 9 requires kill -9.
-
- Enzo Michelangeli <enzo@airhk.air.org> noted that SCO 3.2.1
- defined window size structure in ptem.h.
-
- Josef Sachs <sachs@panix.com> found a bug when calling fg
- expects repeatedly between bg expects. On the first fg expect,
- it cached the fact that the filehandler was armed. The next
- background expect disarmed it but failed to update the cache.
-
- John P. Rouillard" <rouilj@dstar.iddis.com> provided configure
- support for --with-{tcl,tk}{lib,include}.
-
- Mike Figg <figg@pencom.com> noted that man page used old style
- of continue command.
-
-8/23/94 5.9.1 Adrian Mariano noted it would be useful to have exp_continue
- not reset the timer. Added flag to support this.
-
- Morris Gasser <gasser@ksr.com> noted that lowering match_max
- didn't work (lib was broken too).
-
- Keith Hanlan provided a fix for exp_exact.
-
- Added more examples: mkpasswd, tkterm, term_expect.
-
- Put close_tcl_files in sep file for easier non-Tcl use of clib.
-
-8/21/94 5.9.0 Fixed window handling code - on AIX, termios does not define
- TIOCGWINSZ. Instead, you have to include ioctl.h. Of course,
- you have to avoid the trap of including both on OTHER systems
- such as SunOS 4.1 where the include files conflict!
-
- Dan MacDonald found that close in async routine caused sync
- expect to blow up.
-
- Missed deletion of last line of out macro in exp_inter.c
-
- Simon Warfield <simonw@bwh.harvard.edu> noted bug in xkibitz
- help message.
-
- Fixed exp_background to use global scope instead of current.
-
- Steve Diamond <sdd@aplcomm.jhuapl.edu> noted that -i "4 5"
- only used spawn id 5.
-
- Rob Nagler found yet another bug in log_file when called
- incorrectly.
-
- Expectk wasn't creating a window by default.
-
-7/25/94 5.8.1 Made exp_interp external. Users should be able to set this
- explicitly.
-
- David Barnett <davidb@cats.ucsc.edu> found that Linux was not
- getting a controlling terminal. The original test for doing
- that was based on Stevens and tested in a very nonspecific way
- for the presence of a Sun via CIBAUD. Replaced this with a
- more specific test.
-
- It seems Tcl 7.3 broke my -nostack hack. The top-level interp
- translates unknown return codes to TCL_ERROR. Sigh. I wish
- Ousterhout would stop all of those translations. If the user
- wants them, they can do so themselves, but now they're forced.
-
- Martin Buchhoz <buchhlz@vnet.ibm.com> suggested adding
- XKIBITZ_XTERM_ARGS environment variable to xkibitz. He also
- noted that stty rows/columns support doesn't seem to work on
- AIX. I haven't yet looked into this.
-
- Copied 2nd sync mechanism from Expect to C library.
- Added exp_child_exec_prelude hook.
-
- Jonathan Kamens noted that "spawn cat;close;wait" returned
- -1 on AIX and 0 on Sun. This is "correct", however to
- address this, I added -ignore to spawn and otherwise made
- signals default. Also added extra information to return value
- of wait if caused by signal.
-
- Dan MacDonald <hfvstud@bcarh80a.bnr.ca> noted that exp_continue
- didn't cause timeout to get reread.
-
- Ting Tan <utan@cisco.com> noted that when using -b, expect
- hangs if open brace and doesn't stop in case of error.
-
- Oops, broke "log_file" with no args.
-
- Removed -timestamp from documentation. Use "timestamp" command
- instead.
-
- Keith Hanlan noted C library didn't test already arrived data
- before attempting to read more. He also suggested I avoid
- forcing the user to do save/restores of per-fd globals.
-
-6/24/94 5.8.0 Hubert Halkin <hhalkin@ucsd.edu> pointed out that interleaved
- expect_bgs and spawns dump core. I had used the exp_f ptrs
- as handles to TkCreateFileHandler but realloc shuffled them
- around.
-
- Rick Lyons <pclink@qus102.qld.tne.oz.au> provided misc. mods
- for Pyramid.
-
- Keith Hanlan <keithh@bnr.ca> noted that HP-UX C compiler causes
- odd behavior in Expect when it is compiled with -O. -g works
- fine.
-
- Peter Gasche <zrspg01@compserv.zdv.uni-tuebingen.de> pointed
- out that Convex 10.2 fails to build. New version of Convex OS
- added getpty(). Naturally, it differs from old one. Testing
- is tricky because there is no header file for it. Even worse,
- the algorithm in the Convex man page is incorrect - it allows
- you to allocate ptys already in use! Unfortunately, the man
- page is too vague to allow the reader to see that immediately.
-
- In contrast to BSD stty, Convex, Mach, and NeXT stty don't
- complain if redirected to null. I'll just have to hardwire the
- test in configure.
-
- Added -nowait flag to wait command.
-
- Upon suggestions from David Vezie <dv@xnet.ssl.berkeley.edu>:
- Added -noappend, -open, and -leaveopen to log_file command.
- Added -leaveopen flag to spawn and exp_open.
- Modified spawn to close -open immediately.
- Modified exp_open to close spawn_id immediately.
-
- Between Jeff Wright <wright@spock.cen.encompass.com>, Brad
- Skrbec, Arup Mukherjee <arup+@cmu.edu>, and the anonymous
- Mach support group at CMU, finally got hard answers about Mach.
- It is no longer supported and there is no intention to provide
- full POSIX support. Now, at least, I can fix the configure
- script to understand this.
-
- Added "unbuffer" example.
-
- Dana Chee <dana@dino.bellcore.com> provided configure hooks
- for finding -lnsl and -lsocket.
-
- Henry Spencer <henry@zoo.toronto.edu> noted timestamp doc did
- not jive with C defn. Fixed doc and added timezone support.
-
- Steve Pynes <fb@steve@ucsd.edu> noted that exp_win.c needs
- _IBCS2 (Intel Binary Compat Standard #2!?!) before it will
- recognize winsize. He also noted #out was redefined in inter
- code if using simple_event.
-
- Fixed defn of "stty cooked" to retain echo setting.
-
- Bennett Todd noted dislocate's pidfile_read was missing close.
- He also noted useless bind in tkpasswd.
-
- Marty Leisner noted that ^C causes xkibitz to exit ungracefully
- when in interpreter.
-
- Added yet another sync mechanism (see 5.6) to spawn so that
- child cannot eof before parent has prepped the pty (only a
- probably on HPs, of course). I had actually written most of
- the code, but left it disabled because I hoped that the
- problem simply wouldn't happen in practice. Alas, Jonathon
- Kamens found a case where it does.
-
- Jimmy Aitken <jimmy@pyra.co.uk> noted problem on Pyramid. My
- original code only looked for /dev/tty##. On pyramid, ptys
- look like /dev/pts/4. term wants the last two characters, but
- on the Pyramid, the first of the last two characters can be a
- / in which case xterm wants a 0. I.e., suffix of /dev/pts/4
- is "04". xterm fails completely with 3-digit ptys! I sent
- a suggestion and patch to X Consortium for this and the pid
- problem - xterm has no way of telling it to which pid to send
- the SIGWINCH.
-
- Poul-Henning Kamp <phk@TFS.COM> noted that -lm would make
- autoconf forget about other libs.
-
- Ram Bhamidipaty noted I forgot to document sleep.
-
- Removed disasterous performance with * at beginning of glob.
-
- Mods from Rob Savoye. See ChangeLog.
-
- Earnest Hua <eh@c-cube.com> noted expectk.man need wasn't
- installed.
-
- Bogus arguments to expectk were not reported correctly.
-
- Modified clib to catch when user changes match_max between
- expects on two different fds and then switches back.
-
- Rewrote timestamp to get rid of 200 char limit.
-
- Ram Bhamidipaty <ram@xor.epi.wisc.edu> noted NetBSD .9 stty
- complained "stdout appears redirected, but stdin is the
- control descriptor". It compares dev(stdout) to dev(stderr)
- and assumes if they are different then user thinks stty
- ioctls stdout. This is one case when that assumption is wrong.
- Fixed fd 2 so it points new 2 and is reset to old 2 if an
- error occurs. This forced me to remove any diagnostic output
- from child (in getptyslave) since this now went back to the
- proc as child output rather than original stderr, sigh.
-
- Stephan Winokur <swinokur@pinky.trevose.sgi.com> noted that
- IRIX 4.2 had problems with gcc. While diagnosing, I found
- PTY_TYPE was used before set. Make doesn't mind (how odd)
- but I changed it anyway.
-
- Made send understand "-null". Deprecated "-0".
-
- Made Expect read .expect.rc from DOTDIR if present.
-
-3/30/94 5.7.0 Removed alpha status.
-
- Added $(EVENT).o to library.
-
- Finally deleted old shar file. Revised README.
-
-3/22/94 5.6.3 Phil Moore <phil@signals.geol.scarolina.edu> noted termios.h
- should not come from sys even if it exists. (SGI doesn't have
- sys/termios.h.)
-
-3/21/94 5.6.2 Paul Kinzelman <pkinz@cougar.tandem.com> noted that I forgot
- to remove -update from documentation.
-
- Fixed interact's -i so it understands indirect spawn ids.
-
-3/21/94 5.6.1 expect_background randomly failed. I forgot to save Tk's
- event mask so occasionally events were incorrectly classified
- as eof.
-
- Added -buffer to expectk and made "nobuffer" the default so
- scripts are read in much faster.
-
-3/15/94 5.6.0 Added cat_buffers marker to avoid "catu" option to scripts.
-
- Got temporary use of an evaluation copy of TestCenter.
- Promptly found several memory leaks. Oops.
-
- Added a synchronization mechanism to spawn so that user cannot
- send to pty before it is init'd. This also deals with the HP
- trap more simply. Removed extra open added in 5.5.1. While
- working on this, it occurred to me stty needs to temporarily
- disable trap. Added exp_slave_control so that C programmers
- can get to it portably.
-
- Added "expect -ex" to documentation.
-
- Fixed winsize bug on Solaris.
-
- Added functions to allow user flexibility closing fds in child.
-
-3/8/93 5.5.1 Integrated bug fixes from Arnold Robbins <arnold@skeeve.atl.
- ga.us> for his own strftime code.
-
- Rob Savoye passed back a patch from OSF to cast ptsname.
-
- Added a test for cat. R.K.Lloyd noted HP failed pid test.
- Turned out to be another bug related to pty-trapping. The test
- of course, was doing something that a user would never do.
- Hope this doesn't break other HPs. Pty trapping is becoming
- less and less clear to me. Ioctls generated by slave look like
- modem ioctls. Added an artificial open because different
- versions of HP's stty execute differing numbers of ioctls.
- In test script, changed each cat to cat -u.
-
-2/17/93 5.5.0 Began a test suite based on Ousterhout's model: make test
-
- Added passmass man page.
- Added decl of exp_tty_original to pty_sgtty.c.
- Added error_spawn_id
-
- Alon Albert <al@mercury.co.il> provided a bug fix for new
- buffer handling code in C library.
-
- Fix fd leak related to spawn -open.
-
-2/7/94 5.4.0 Some installation improvements from Rob Savoye and Owen Rees.
-
- Bug in handling empty string match - crept in recently.
-
- Finally fixed longstanding oddness: stty -raw reset echo.
-
- Made spawn close all file descriptors. Added exp_open command
- to get old effect.
-
-1/26/94 5.3.5 Made rftp use /bin/ls to avoid -F from people's aliases.
-
- Initialized auto_path.
-
- Fixed exp_version so it fails if the major #s are not equal
- (which is what the man page said).
-
-1/18/94 5.3.4 Jim Meyering <meyering@idefix.comco.com> gave config fixes
- of X handling on Irix-4.0.5 and suggested that tknewsbiff
- observe DOTDIR.
-
-1/18/94 5.3.3 Kevin Short <short@gdc.com> noted some remaining use of malloc
- and free instead of ck versions.
-
- Initialize tcl_interactive to 0 while processing -c flag to
- avoid unreliable handling of unknown proc.
-
-1/17/94 5.3.2 Jeffry Abramson <jra@hrcms.att.com> noted that "spawn -pty"
- hung on an HP. Problem was trapping was enabled so as soon
- as I tried to open the slave, Expect blocked waiting for ack!
-
-1/14/94 5.3.1 Forgot to delete a bad call to strcat in exp_internal.
-
-1/13/94 5.3.0 Added -info flag to log_file, log_user, exp_internal, and
- strace, so you could get original args back out.
-
- Wrote tknewsbiff script (and was extremely pleased).
-
- Fixed rftp. I must have broke it when I changed to using Tcl's
- new switch cmd. Also sped it up by replacing split/join
- nonsense with a single regexp.
-
- Danny Faught <faught@convex.com> noted that glob patterns
- returned shortest matches. While fixing this, found that glob
- patterns ending in $ were broken, too.
-
- Massaged libraries and include files. The include file for
- using Expect with Tcl or Tk is now expectcl.h. libexpect.a
- now suffices for using Expect's funcs with C or Tcl.
-
- Add all the features from Expect into C library including
- null and full buffer matching. Added exp_buffer (_end) and
- some other variables to support fd multiplexing better.
- Made unmatched chars from previous expects remain for future
- matches.
-
- Chen <johnny@e0sun3.ccl.itri.org.tw> found bug in exp_pid when
- -i had no arg.
-
- Rewrote expect_bg, after, and before so they all handle args
- the same. Interact and all the expect variables now handle
- indirects. exp_bg now handles -brace flag.
-
- Geoff Bullen <geoff@itx.nsg.com.au> noted that interact put
- terminal into raw mode even if stdin was redirected.
-
- Rob Savoye provided more configure mods to better find Tcl/Tk.
-
- Fixed bug in wait that didn't close down "busied" fds.
-
- Kazuro Furukawa <furukawa@apricot.kek.jp> provided a better
- default for SHORT_BINDIR in the Makefile and noted that DEC
- doesn't understand "test -x".
-
-12/3/93 5.2.0 Recent fix was buggy and blew up when eof case still had data
- in buffer.
-
-11/23/93 5.1.4 At request of Rod Beckwith <rodb@slugo.corp.sgi.com> fix some
- minor things to which SGI cc was sensitive.
-
- Fixed bug in dvorak script where eof could occur in nested
- interact, upsetting original interact.
-
- Forgot to change -flush to -nobuffer in man page.
-
- Added some more places to search for X11 for Jeff Moore
- <jbm@internet.sbi.com> note.
-
- Added yet more fixes and notes for NeXT for Brad Skrbec
- <skrbec@motcid.rtsg.mot.com> who found that NeXT has POSIX
- include files but NOT the functions that go with them. Sigh.
- Needless to say, configure is thrown off by this.
-
-11/14/93 5.1.3 John Pierce <jpierce@chem.UCSD.EDU> noted several declarations
- that AIX's cc couldn't handle include a struct with same elt
- name at two different levels. Also _IO is declared twice
- in AIX include files but only checked once.
-
- Fixed bad args in exp_spawnl call in chesslib examples. Can't
- imagine how it ever worked before.
-
- Richard Weidner <richard@cicero.jpl.nasa.gov> found a bug in
- configure (test always treats a bare string as true!) that
- caused NeXT to be declared as POSIX.
-
- Fixed two bugs in Tcl_StringMatch2. One caused glob ranges to
- succeed when they shouldn't. Another was how malformed ranges
- are handled, and came right from Tcl. Reported to John.
- Switched Expect library to use T_SM2 from Expect itself.
-
- Blair Zajac <blair@olympia.gps.caltech.edu> noted expectk used
- CLFLAGS instead of CFLAGS.
-
- Forgot to fix mishandling of parens inside of alternation in
- interact.
-
-11/9/93 5.1.2 Added "null" keyword and remove_nulls command to allow matching
- ASCII 0 in expect/interact.
-
- Rob Nagler <nagler@olsen.ch> noted that expect_background
- failed if pattern didn't consume all data. event handler
- knows nothing about data already arrived but not processed.
-
- Made Expectk understand --
-
-11/8/93 5.1.1 Fixed yet another bug in setting expectk's argv0.
-
-11/6/93 5.1.0 Provided support to work with Tcl 7.[0-1] and Tk 3.[3-4].
-
- Pasi Kaara <ppk@atk.tpo.fi> found an off-by-one in the buffer
- shuffling when buffers fill up during an expect.
-
- Changed \\\$ to \\$ in patterns that search for literal $.
-
- Added "spawn -pty" support for xterm -S.
-
- Fixed yet another argv problem in Expectk. When run using
- expectk explicitly, script name was left in argv.
-
- Fixed system command's return value to match exec new style.
-
-11/1/93 5.0.4 Mark Davies <mark@comp.vuw.ac.nz> noted that BSD4.4 sysconf
- returns -1 (a bug). Rewrote to avoid requiring this info.
- Switched from from explicit refs of sys_errlist to Tcl's
- strerror.
-
- As per Adrian Mariano <adrian@cam.cornell.edu>, added exp_sleep
- command primarily to allow sleeping by sub-second intervals.
- Also avoids exec overhead. Not yet documented.
-
- Kartik Subbarao <subbarao@concorde.fc.hp.com> noted that on
- HPUX 9, SC_OPEN_MAX should be ifdef'd on itself rather than
- HAVE_SYSCONF.
-
- Karl Vogel <vogelke@c-17igp.wpafb.af.mil> noted Pyramid
- didn't like varargs included twice in exp_command.c.
-
- Deleted expect_version variable (was never documented) and
- deprecated expect_library to be exp_library for consistency.
-
-10/16/93 5.0.3 Lou-Salkind@deshaw.com found interpreter() could stomp past end
- of input array. Same problem in debugger.
-
- Bud Bach noted init.tcl wasn't being sourced, and Makefile
- broke if all scripts were commented out.
-
- Added interesting highlights and bindings to tkpasswd.
-
- Made Makefile look for -ltk if libtk.a doesn't exist.
-
- Rick Sladkey pointed out that -re patterns to look for $ should
- "\\\$".
-
- R.K.Lloyd noted config doesn't see prototypes with K&R cpp.
-
-10/8/93 5.0.2 Bud Bach noted tcl_interactive was not set.
-
-10/8/93 5.0.1 R.K.Lloyd noted various problems, some related to being on an
- HP when a lot of #ifdefs kicked in.
-
-10/7/93 5.0.0 Added expect_background. In the Tk environment, this registers
- actions to be called upon receipt of a pattern from a process.
-
- Renamed "debug" as exp_internal" and made debugger available
- as "debug" and "exp_debug".
-
- Milan Gupta <mbg0@bunny.gte.com> noted that system() (at least
- on his HP) hangs when SIGCLD is ignored.
-
- <jason@vicor.com> noted that Tcl's exec command doesn't bother
- to close fds, so force them with close on exec.
-
- Renamed "continue -expect" as "exp_continue". "continue
- -expect" will continue to work, just won't be documented. It's
- just too dangerous when you start mixing extensions.
- Renamed "return -tcl" as "inter_return". Had to do something
- to avoid random return values from matching "-tcl". This
- design was just wrong. Surprising that it never bit anyone.
- Renamed "expect_version" as "exp_version" just to continue
- this regularity.
-
- Protected initial fd_new's with isatty so disconnect doesn't
- lose redirected fds.
-
- Allowed DFLT_STTY to be omitted entirely. Apollo doesn't need
- it.
-
- Modified fork to fail on failure instead of returning -1. This
- made spawn failure match disconnect failure.
-
- Dan Hyde <drh@citi.umich.edu> noted missing arg in exp_error.
-
- Jerry Whelan <guru@stasi.bradley.edu> noted -buffer was botched
- in man page. Hal Peterson noted that bug in man page caused
- groff to choke.
-
- wait now returns {pid, spawn_id, 0|-1, status (or error msg).
- errorCode is now set if appropriate. wait -i -1 waits for any.
-
- Propagated winsize to pty.
-
- Documented "-open".
-
- Quentin Stafford-Fraser <Fraser@europarc.xerox.com> noted that
- interact -u was broken.
-
- Fixed interact's default actions "return"/"interpreter" to be
- writable. Removed ability to set default eof/timeout. Removed
- dash from same.
-
- Rewrote trap to use Tcl's async support.
- Added -code switch and made interpreter understand "-nostack"
- coming from error to use ^C to easily return to interpreter.
- Introduced following incompatibilities:
- - ONEXIT interface disappeared. Use "exit -onexit". (Thinking
- of this as a signal bought nothing but complexity.)
- Added "exit -noexit" to run all expect-related exit
- handlers without exiting or destroying interp or ".".
- Useful for when other apps have exit handlers.
- - trap command takes missing action as a query. Use "" or
- SIG_DFL to delete or reset a trap.
- - SIGCLD gone. Now always called CHLD even if underlying
- system only knows about CLD.
- All sig handlers and exit handlers run at global level.
-
- Removed setjmp/longjmp crap. Not needed since systems which
- wait in read don't restart system calls.
-
- Added support in expect for "-gl" and allowed longer forms to
- match Tcl's switch command. Similarly for "-ex" in interact.
- Rewrote arg parsing for send.
-
- Added "stty" command to support stty of ttys other than
- /dev/tty. Better for /dev/tty, too. This should fix
- security complaint from BSD's Net2 stty.
-
- <R.K.Lloyd@csc.liv.ac.uk> gave fixes for configure and noted
- exp_main_tk was missing exp_conf.h.
-
- Added "exp_timestamp" command. Fixed bug in interpreter cmd.
- It wouldn't return anything with TCL_OK.
-
- Renamed -flush to -nobuffer.
-
- Make interact default to executing actions in raw mode.
- Accept -reset to execute in cooked mode. Ignore -f.
- Fixed examples. Fixed bug in "-o -timeout".
-
- Deprecated getpid (due to Tcl's pid), added exp_pid.
-
- Put "rm -f" inside catch. SunOS 4.1.3 and some version of AIX
- complain despite the -f!
-
- Added "send -break" for Dave Mielke.
-
- Fixed argv handling of expectk to match expect for Steve Clark.
-
- Switching to Tcl 7.0
-
-8/21/93 4.7.7 Cygnus added support for OSF/1 style ptys.
-
- Brian Bebeau <brian@cblph.att.com> found bug in PTC support,
- HAVE__GETPTY, timestamp doc, and provides some mods for config
- AT&T StarServer.
-
- Detection of direct spawn ids failed on -1.
-
-8/18/93 4.7.6 Removed zone and gmtoff from timestamp. Not ANSI.
- Removed getpid confusion.
- Once again, added "cat -u" into kibitz (this time for AIX 3.2).
-
-8/18/93 4.7.5 De Clarke <de@lick.UCSC.EDU> hit error in exp_global.h because
- tcl.h had not been included.
-
-8/16/93 4.7.4 Richard Kasperowski <richk@icad.COM> found that Ultrix 4.1-2
- failed to allocate controlling terminal. Ultrix's setsid is
- evidentally buggy. Switched back to setpgrp - which fixed it.
-
- Fixed type defn of exp_tty_original.
-
- Dave Mielke found two bugs in interact: re-failure prevented
- other patterns from matching a particular point in the stream,
- and two or more -inputs didn't actually work. Also found bug
- in HP trap handling - despite what docs say, other things
- besides open/close have to be handled. Specifically, slave was
- generating an ARGGET. Backed off on trying to wait immediately
- for two OPENs to just waiting for one OPEN. Perhaps zero?
- Also found deficiency in return -tcl - failed to return arg.
-
- At Dave's request, made cmdfile by read in a single gulp rather
- than line by line. Added -b (buffer) flag for old behavior.
- Old behavior performs badly on very long procedures but is use-
- ful for reading commands from pipes. Made "system stty" return
- status of raw/echo.
-
- Made log_user return previous value irrespective of args.
-
- Fixed mishandling of parens inside of alternation noted by
- Bud Bach <bachww@rtsg.mot.com>.
-
- Added -timestamp, -iread, and -iwrite to interact and
- expect.
-
- Added -onexec flag to close to solve problem posed by
- Bellave Jayaram <bjayaram@slee01.srl.ford.com>.
-
- Added -0 to send. Removed capability of send to send multiple
- strings.
-
- Chip Rosenthal noted bug in releasing trap 0's action. Also
- modified exit handler to allow recursive invocation. Instead
- of complaining, it skips handlers that have already been
- invoked and forces the process to exit.
-
- Added new names for most command prefaced by "exp_".
- Deprecated send_spawn.
-
- Switched to Ousterhout's ckalloc and attitudes towards failure.
-
- Started adding Tcl 7.0 support. getpid renamed to pid. Added
- exp_pid to support things that Tcl 7 does with its pid.
-
-6/12/93 4.7.3 fnf@fishpond.cygnus.com noted minor type problems. Rob Savoye
- noted trap SIGINT overrode debugger handler. Default should
- be reverse.
-
-6/8/93 4.7.2 Added debugger to public release.
-
-6/7/93 4.7.1 Ed Oskiewicz <eo@ansa.co.uk> noted prototype botch - exp_cook.
- Owen Rees <rtor@ansa.co.uk> noted missing decl - tclRegexpError
-
-6/6/93 4.7.0 Gert Bultman <bultman@dgw.rws.nl> exposed a bug in interact's
- -update.
-
-5/27/93 4.6.0 Rick Sladkey <jrs@world.std.com> fixed a bug in send_log -
- checking a master needlessly and indexing off the end of an
- array.
-
- Rob Savoye made change for detecting libpt.a, modified
- autoconf for better handling of X, exec_prefix, and ranlib.
-
- Kris Woeppel <krisw@cs.athabascau.ca> said SVR3 doesn't have
- wait.h.
-
- Made libexpect.a understand regexp. Reorganized code. It
- now requires Tcl to be installed first, although it uses only
- a few utility routines. Hopefully this isn't a problem for
- anyone.
-
- Zack Xu <zack@cs.wisc.edu> noted exp_main.h needed C++ support.
-
- Pascal Meheut <pascal@cnam.cnam.fr> gave fix for skipping over
- null bytes while interact is pattern matching.
-
- Added "--" to expect, interact, and send.
-
- Added support for associating multiple -i's with a single
- pattern, and -i's with no pattern for use with spawn_id_any.
-
- Made interact work with systems that lack select/poll.
-
- Added code and #defines for debugger. Debugger itself is not
- yet available.
-
-4/19/93 4.5.2 Achim Flammenkamp <achim@HRZ.Uni-Bielefeld.DE> noted that I
- documented full_buffer as buffer_full.
-
- Ted Stockwell <ted@sirius.aggregate.com> noted that wait arg
- was missing an & in configure test.
-
- Scott Hess noted that systems can have wait4 without waitpid.
-
- Jonathan Kamens <jik@gza.com> noted/fixed some things that
- weren't autoconf'd correctly: pid_t, RETSIGTYPE, malloc.
-
- Gary Shea noted that a recent change to expectk made it not
- default to interactive.
-
-4/12/93 4.5.1 At request of Rusty Wilson <zrlw05@hou.amoco.com>, added
- "-console" to spawn.
-
- Pang Wai Man Raymond <wmpang@cuse1.se.cuhk.hk> reported that
- passmass didn't grok DEC's passwd prompts for root.
-
-4/7/93 4.5.0 Fixed bug in interact regexp preventing match of multichar
- literals.
-
-4/6/93 4.4.3 Bennett Todd <bet@sbi.com> noted missing example scripts
- timed-read and time-run.
-
-3/29/93 4.4.2 Bill Houle <Bill.House@SanDiego.NCR.COM reported fixes
- for SVR4 pty support to compile.
-
- Made string matcher understand *$. Documented tty_spawn_id.
- Made command line -i override -f.
-
- For Tuan Doan <tdoan@bnr.ca> on HP, make kibitz use domainname
- as fallback and used whoami instead of env(USER).
-
- Fixed bug in the generic pty code that could report out of ptys
- because an earlier slave slowly deleted the lock file.
-
-3/25/93 4.4.1 Stephen House <sdhouse@bnr.ca> reported exp_tk.c wouldn't
- compile on HP. Fixed.
-
-3/24/93 4.4.0 Added back SVR4-style pty allocation which got omitted in the
- autoconfig process. Fixed bug in interact's -update handling.
- Fixed bug in weather script that cut off long reports.
-
-3/15/93 4.3.0 Cleaned up /tmp files used during pty locking.
-
- Added command "parity" to enable parity stripping. Fixed
- match_max to do -i correctly.
-
-3/15/93 4.2.4 Fixed to work on new SGI which returns slave-close via excep
- (select) or POLLERR (poll) rather than thru read(). Why do you
- people do things like this?
-
-3/12/93 4.2.3 Fixed to work on AIX (using /dev/ptc) and UTS (using getpty).
-
-3/11/93 4.2.1-2 Fixed numerous bugs relating to HP ptys. It's amazing that for
- their bewildering complexity, they couldn't support generation
- of EOF to the master (or at least enable trapping of just
- close), rather than forcing the code to know about opens, too.
-
-3/8/93 4.2.0 Integrated Rob Savoye's autoconfig code.
-
- Interact mishandled new -eof flag. Added -update.
-
- Gary Shea <shea@cs.ukans.edu> noted that tkwait hung if
- expect had been called. Rewrote most of tk_event.c and fixed
- some other problems related to efficiency & multiple timeouts.
-
- E Beck <beck@qtp.ufl.edu> suggested mods to more easily support
- Extended Tcl.
-
- Bill Mitchell <mitchell@mdd.comm.mot.com> reported problems on
- 4.3+BSD. Added support for TIOCSCTTY.
-
- Dana Burd <dana@wrs.com> noted that "exit" caused by ^C during
- expect didn't work - just returning to expect. Fixed, and then
- removed "feature" of ^C to abort a timeout. This feature
- proved a lot less useful than I thought it would.
-
-2/21/93 4.1.0 Bill Tierney <wtierney@leland.stanford.edu> noted that double
- close dumped core. Rewrote fd_to_f and close/adjust functions.
-
- Interactive interpreter() didn't properly wait in
- get_next_event, so Tk stopped responding to events.
- Wrote version of interpreter that shares expect's input buffers
- but can't think of a use. Left as an ifdef SHARE_CMD_BUFFER.
-
-1/26/93 4.0.1 Added eof check to xpstat. Removed incorrect and unnec.
- #includes from exp_main_exp.c
-
- Chip Rosenthal <chip@chinacat.unicom.com> found my refs to
- tclRegexpError need externs on systems that don't use Tcl's
- string.h. string.h should probably be changed not to refer to
- tclInt.h.
-
- Added FAQ about Expect's copyright status.
-
- Mark Christopher <christo@bnr.ca> pointed out some really
- stupid errors in the HP support for select.
-
-12/16/92 4.0.0 Rewrote interact. Made re-entrant thru event-handler for Tk.
- (Same for Expect.) Abstracted out common code so that
- remainder is specific to select vs poll vs tk (although
- "simple" was impossible to handle). Added timeouts, regexps
- (at request of numerous people), ability to set up arbitrary
- graphs of process flows, and some miscellaneous but useful
- functionality. New flags are: -input, -output, -re, -echo,
- -flush, -eof.
-
- Added "-noecho" to spawn command.
-
- Added getpid command. Something with this functionality should
- be added to the Tcl core. When it is, this function will go
- away.
-
- Removed assumption of global "interp" handle. Rewrote init
- and other routines for use as libraries. Added appropriate
- glue to Makefile.
-
- At request of Rob Savoye <rob@cygnus.com> added "send_log" and
- disabled buffering on all output. The only affect unbuffered
- output will cause users is if they pass large strings in
- multiple args to send.
-
- Ray Davis <rdavis@masschaos.de.convex.com> reported Convex
- could not do job control from spawned procs. I added a symbol
- DO_SETSID to force this.
-
- Martin Leisner modified rftp to understand iftp. I added it
- to the publicly donated scripts directory.
-
-11/17/92 3.24.1 Martin Leisner suggested Makefile use $(MAKE) and support Tcl
- as a Sun shared library.
-
- Seth Perlman <seth@welchgate.welch.jhu.edu> suggested interact
- support timeout. I've added this as "-timeout" in inter_select
- but left undocumented while we experiment with interface.
-
- Joe VanAndel <vanandel@ncar.ucar.edu> pointed out that su2
- script still used old syntax. Fixed.
-
- Konrad Haedener <haedener@iacrs1.unibe.ch> fixed a bug in
- POSIX tty handling on AIX. Surprisingly, we discovered AIX
- worked just fine when pty_bsd is used and without -DPOSIX!
-
- Doug (George Jetson) <pynq@midway.uchicago.edu> pointed out
- that a spawn_id for /dev/tty would be really handy. I added
- tty_spawn_id for this purpose.
-
-11/4/92 3.24.0 After problem reported by James Ward <jew@sunquest.com> added
- to man page describing delays required by hardware such as for
- UART switching.
-
- Recoded all \C sequences as \### in examples and man page in
- anticipation of them going away in next version of Tcl.
-
- Switched to printing errorInfo during errors instead of the
- command and only the top-level error message. Since this
- includes entire stack, this should be very helpful.
-
- J. Cazander <cazander:pasichva via serigate@phcoms.seri.
- philips.nl> reported that purify found a write beyond the end
- of an input buffer. Lucked, it was just before a double-word
- boundary, so it probably isn't a problem. I fixed it anyway.
-
-10/9/92 3.23.1 Tor Lillqvist <tml@tik.vtt.fi> supplied support for HP 8.0.7 in
- POSIX-mode, and a bugfix for POSIX tty mode switching
-
-10/8/92 3.23.0 Larry Rogers <lrr@Princeton.EDU> reported that "weather" blew
- up in spawn. I'll add a catch-all to the script to report
- similar problems (out of ptys, processes, etc.)
-
- Ting Leung <tleung@bnr.ca> notes that log() in human_write can
- receive a 0 (domain error). Fixed unit_random to avoid that.
-
- Tony Primavera <aprima@xox.ssc.af.mil> notes that the sample
- archie script needs to understand mcgill's limit of 10 users.
- Tor Lillqvist <tml@tik.vtt.fi> noted that a lesser-used pattern
- ("unknown...") is incorrect.
-
- Grant Taylor <gat@pecan.cray.com> found a problem when forking
- (using Expect's fork) multiple processes, each of which spawned
- something. In the BSD pty support, I had used the pid to build
- a temporary file for testing the pty before actual use. When
- multiple processes tried to use the same tempfile, it blew up.
-
-8/12/92 3.22.13 Corey Satten pointed out that -u on cat caused kibitz to slow
- down on Ultrix. I see the same behavior on SunOS. I added an
- option to fix it for systems that need it. Corey also noted
- arg miscounting in kibitz, and pointed out that world-readable
- fifos could be a security problem. He gave a fix for this and
- also a fix to force ptys to be put into raw mode.
-
- Terrence Brannon <tb06@pl122e.eecs.lehigh.edu> reported rftp
- referenced the undefined variable 'transfer'. Turned out to be
- a bug in the code to handle symbolic links.
-
-7/20/92 3.22.12 Added O_NOCTTY (if defined) in pty_bsd.c to avoid gaining
- control terminal while testing pty when running as daemon.
-
- At request of Michael D. Riley <riley@mbeya.research.att.com>
- added explanation to man page - how expect_after/before deal
- with spawn_id.
-
- Charles Hannum discovered the problem with AIX (see earlier)
- was a missing "extern" in the errno declaration. Also, the
- compiler was sensitive to a lack of access to the defn of
- struct expect_special.
-
- Dave Coombs gave me yet another fix for the weather server to
- accomodate its ever continual change.
-
-7/2/92 3.22.11 Yet more work. Discovered that SunOS and Ultrix really like
- setpgrp(0,0) much better than setpgrp(0,getpid()) but the
- manual doesn't describe well why this seems to work better.
- (The old call worked inconsistently.)
-
-6/30/92 3.22.10 Did more work on modifications to dissolve connection between
- stdio and devtty. Eventually, I'd like to add a separate
- spawn_id for devtty (expect_devtty?).
-
-6/5/92 3.22.9 Hansel Wan <hhw0@gte.com> noted that $errorInfo was clobbered
- by prompt1. To prevent this, I added a default definition
- for prompt1 (and prompt2 while I was at it).
-
- Unnati Amin <uxa@po.cwru.edu> noted that the example scripts
- checked for $ in prompts which didn't work. This bug was
- created when $ was turned into a "match end-of-input" char
- in the transition from v2 to v3. Solution: backslash the $.
-
- A few parts of code assumed spawn_id was always stdin, which
- caused "send" to send to stdout, which meant succeeding
- expect's hung, waiting forever. Fixed is_user macro.
- This was a problem with scripts that redirected stdin or
- somehow reused fd 0. Surprising that no one ever did that
- before - also surprising that it didn't bother cron jobs.
-
-6/2/92 3.22.8 Man pages fixes from Matt Crawford crawdad@fncent.fnal.gov.
-
-5/12/92 3.22.7 Missing ; in Makefile, screwed up chmod.
-
- Fixed bug that caused interact to think the modes had changed
- when they hadn't.
-
-5/11/92 3.22.6 Added regression paper to ftp archive - published in the 1992
- USENIX San Antonio Proceedings.
-
- Swapped setpgrp and fork in disconnect command for sysV88.
- According to Dave Schmitt <daves@techmpc.csg.gss.mot.com>,
- original code (right out of Stevens) starts the child with
- closed stdio fds.
-
- Fixed bug in interact that changed /dev/tty modes even if
- interact was used to connect two completely different ttys.
- Had never been a problem before, but today I wrote some code
- that actually calls interact from cron! Also, copied the
- experimental fix from 3.22.5 to inter_poll.
-
- Jeremy Nussbaum <jeremy@world.std.com> says cat needs "-u" in
- kibitz for his HP 8.0 system to work. I wonder why this has
- never been a problem on earlier HP and other systems?
-
- Forced Makefile to mark scripts executable.
-
-4/12/92 3.22.5 Fixed bugs reported by Matt Ranney <mjr@uther.Calvin.EDU>
- including a syntax error (!) in expect.c on ecases_inuse.
- I didn't even compile this before pushing out? He also noted
- some # were not in column 1.
-
- I put in an experimental fix to interact (only in select
- version currently) to fix when pattern matching from master
- and user needs to continue typing in order to complete match.
-
-4/3/92 3.22.4 Charles Hannum (mycroft@gnu.ai.mit.edu) pointed out that I
- screwed up a comment in the brand new pty_aix3.c. He also gave
- me a fix for an arg-less expect, which did a malloc(0). And
- he said that AIX ptys return EOF in yet a new way - read()
- returns -1 with errno == 0. Yuck.
-
-3/29/92 3.22.3 Jay Schmidgall gave me yet another pty_aix3.c. He also gave
- ifdefs for POSIX terminal support.
-
-3/18/92 3.22.2 Jay Schmidgall <shmdgljd+@rchland.ibm.com> modified pty_sgi3.c
- to make a pty interface for recent versions of AIX.
-
- Steve Summit <scs@adam.mit.edu> noted that "trap 0" could
- actually call signal(0...)
-
- Martin Leisner <Martin_A._Leisner.Henr801C@xerox.com> noted
- that rftp was broken. It seems I never handled symlinks. They
- are interesting. You can't tell from the listing whether they
- are files or directories, so you just have to blindly go ahead
- and assume it's one or the other and see what happens!
-
-3/11/92 3.22.1 In talking to Dave Schmitt ,daves@techmpc.csg.gss.mot.com>,
- realized the documentation for wait had never been updated
- from the way it used to work in v2 (returning any pid).
-
-3/11/92 3.22.0 Another question from Ron, prompted me to find another bug.
- interact -o wrongly manipulated the user buffer at one point.
-
-3/10/92 3.21.0 Ron Young <ron@nevada.edu> found that spawn failed on a
- DECstation 3100 running Ultrix 4.2. I had forgotten to test
- that cmdfile was valid before comparing against stdin in fix
- related to fflush in 3.20.0.
-
- While I was on a DECstation, I noticed that it does not accept
- setpgrp(...,0). Changed 2nd arg to getpid().
-
-3/6/92 3.20.2 Stefan Farestam <farestam@orion.cerfacs.fr> provided a new
- version of pty_sgi.c which uses _getpty. I renamed the old
- one pty_sgi3.c
-
-3/3/92 3.20.1 Brian Woodson requested I update the dates and version numbers.
-
-3/1/92 3.20.0 Prompted by a question from Ken Mandelberg, added -raw to
- noidle and kibitz script.
-
- Fixed fflush(cmdfile) again, having been authoritatively told
- by net wisdom that there is no way to portably fflush a shared
- read-stream. (I take back my claim about a bug in HP's fclose!)
-
- John Sellens gave me some more fixes for non-DEC MIPS OS.
-
-2/22/92 3.19.1 John Sellens <jmsellen@watmath.waterloo.edu> gave me a bug
- fix for NOWAITPID.
-
-2/21/92 3.19.0 Found a bug in HPUX fclose!! It moves the I/O pointer in the
- shared file table entry! This explains the symptoms I reported
- earlier. Fortunately, it's easy to code around (by me - it is
- no longer necessary to fudge the scripts).
-
- Added some stuff to the man page to explain why expect behaves
- the way it does in an emacs shell window and how to live with
- it.
-
-2/21/92 3.18.0 Worked on the HP port some more. The HP causes a real problem
- by insisting SIGCLD be delivered in order for wait to return
- a status. This royally complicated the code, partly because
- of the special casing all over the place in the trap command,
- the asynchronous delivery of SIGCLD and also because Tcl itself
- is not prepared to have system calls be interrupted. Cleverly,
- the HP also defines both CLD and CHLD which threw my macros
- off at first. Thanks, but I don't this kind of help!
-
- Anyway, the end result is that on the HP, SIGCLD is ignored.
- The manual claims wait status will not be delivered but it
- seems to be anyway. Good grief! (Even if it were ignored,
- it would not be such a calamity, since wait is used mainly
- to discard zombies on other systems.)
-
- A remaining problem is that there appears to be some odd
- interaction, perhaps with fork, such that the script is rolled
- back at eof if a spawned process happens to exit at the same
- time. The solution for now is to exit all scripts via exit
- rather than letting exit be called implicitly. There must be
- some real bug, but I'm unable to find anything after lots of
- testing, line and Saber. At the moment, I'm highly suspicious
- of the HP itself rather than expect.
-
- Bob Proulx and Jeff Okamoto supplied me with patches for
- inter_select.c. HP transmits some pty interactions via the
- exception field in select.
-
- Michael Grant gave me a mod to grok ~ in the logfile and
- debug commands.
-
-2/17/92 3.17.1 Brian Keves <keves@meaddata.com> pointed out that the man page
- still referred to "expect_match" instead of "expect_out".
-
-2/12/92 3.17.0 Eric Arnold <Eric.Arnold@corp.sun.com> ran into a problem
- when running in the background. interact did ioctl(0...)s to
- change the terminal mode, ignoring the -u flag.
-
- Fixed a bug in kibitz which blew up when asking for a password
- due to a spelling error. The drawbacks of interpreters...
-
-2/4/92 3.16.3 Dongchul Lim <lim@doctor.chem.yale.edu> noted that scripts can
- hang in the background. I had assumed isatty(0) was enough to
- contrast bg/fg but it returns 1 if the script was started with
- a & from the terminal. I added code to watch if any ioctl(0)s
- were done. If so, than it is safe to do more, in particular
- in the exit handler to reset the terminal modes.
-
-1/28/92 3.16.2 Fixed a bug on SV systems causing errors when trying to do
- further reads after a SIGCLD had already arrived on a spawn_id.
-
- Peter Funk <pf@artcom0.north.de> gave mods for SCO XENIX 386.
-
-1/24/92 3.16.1 Oops. Forgot to add pty_svr4.c to shar.
-
-1/13/92 3.16.0 Karl Lehenbauer <karl@sugar.NeoSoft.Com> a tiny change for
- getting a clean compile on SCO 3.2.2.
-
- My getimeofday-avoidance code wasn't right, sigh. Kibitz
- noticed. Fixed two other bugs in kibitz - password request
- was for wrong user and it timed out but shouldn't have.
-
- Note: seems to work fine with new version of Tcl: 6.2
-
-1/13/92 3.15.1 Added a bit of code to avoid gettimeofday system calls when
- timeout == -1. Fixed minor bugs in kibitz relating to cleaning
- up and returning error messages.
-
- Redid support for stdlib.h including making it default to fix
- problem in Ultrix 4.2 reported by Oliver Kretzschmar <viskretz
- @ikesg1.energietechnik.uni-stuttgart.de>.
-
- Ian Johnstone <ianj@sequent.com> said his system (DYNIX 3.2)
- needed an additional include <ctype.h> in inter_select.
-
- Dave Coombs <cme.nist.gov> added logic to test/weather to
- accomodate a new feature in the weather server.
-
- Hal Peterson fixed some SV code that I just added for handling
- SIGCLD properly. He made the Cray-extra-child timeout in half
- the normal timeout to allow distinguishing between eof and real
- timeout. Finished rest of Jeff Okamoto's fixes for HPUX.
-
- Wally Strzelec <packman@tamuts.tamu.edu> provided mods for
- Amdahl which has its own pty-handling functions. Ifdef'd into
- pty_usg.
-
-12/30/91 3.15.0 Fixed a bug that struck when eof occurred when reading from
- multiple processes simultaneously and no user-supplied eof
- handler.
-
-12/26/91 3.14.1 Ted Gibson <tgibson@logdis11.hq.aflc.af.mil> gave me some mods
- for a 3B2 having to do with termio vs termios, etc.
-
-12/24/91 3.14.0 Deprecated expect 2. Expect 3 is now the official version.
-
- Parag Patel <parag@netcom.netcom.com> gave me some #includes
- necessary for A/UX 2.
-
- Brian Woodson noticed "send a b" generates incorrect debug
- output.
-
- Working with Jeff Okamoto to run expect on HP/UX 8.0, we fixed
- SIGCLD catching (he says HPUX doesn't ignore them by default?),
- obviating longjmp from stomping locals, fixed a bug in cmdWait
- that would prevent the wait status from being collected in
- rare situations.
-
-12/17/91 3.13.1 James Davis suggested fixing Makefile to handle case where no
- example scripts should be installed. I added similar logic
- for script man pages.
-
- Pete Siemsen fixed a bunch of things in the Makefile including
- where to get expect when invoking fixline1. He suggested defs
- for supporting install and multiple MAN targets.
-
-12/12/91 3.13.0 Matthew Freedman <mattf@cac.washington.edu> noted mismatch
- between lib man page (said "stty_init") and lib code (said
- "exp_stty"). He also found a screwup in the library such that
- the pty slave wasn't being set up correctly.
-
- Added note to kibitz man page on how to kibitz with 3 or more.
-
-12/12/91 3.12.0 "expect *" worked incorrectly if it was first expect after
- spawn, due to buffer not being initialized.
-
- Added a good example for "expect -continue" to man page.
- Added an FAQ about a gcc problem that seems to be common.
-
-12/11/91 3.11.2 James Davis noted I forgot to put kibitz.man in distribution.
- I changed kibitz to read domain from resolv.conf instead of
- calling domainname(1) for systems upon which NIS domainname
- differs from Internet.
-
- Pete Siemsen <siemsen@barnard.usc.edu> noted slight error in
- libexpect man page.
-
-12/10/91 3.11.1 A couple tiny mods to the Makefile courtesy of James B. Davis
- and Michael Grant (guest worker from Sun, temporarily at
- <mgrant@xdr.ncsl.nist.gov>. Both of them also noted a problem
- caused by incorrect installation of gcc that caused expect to
- say "ioctl(set): Invalid something or other" upon exit.
-
- Fixed complaint about exit() while compiling without STDC.
-
-12/9/91 3.11.0 beta!
-
- Hal Peterson provided fixes for UNICOS 6.1 and 7.0 on both
- CRAY-2 and CRAY Y-MP. He also fixed a problem in interact
- where malloc(0) could've occurred.
-
- Added support for allowing user to set interpreter prompt.
-
- Added forgotten -d flag to match_max in rftp script.
- Made kibitz understand user@host.
-
- Expect's internal buffer-full-handling incorrectly copied
- the latter buffer half beginning from the end of the buffer.
-
-12/5/91 3.10.1 Massaged Makefile to allow for more flexibility in
- installation, especially with regards to scripts. #! is now
- reset.
-
- Added "kibitz", a really cute script to let two people control
- one program. Example users are for one person to help another
- remotely, logging a conversation (run emacs or whatever inside
- kibitz and your conversation can be logged, scrolled backwards,
- etc., or of course, playing games together.
-
-12/4/91 3.10.0 Tightened up arg checking for "wait" - it core dumped when it
- should've said "syntax error".
-
- Rick Cady <rickc@nsd.3com.com> noted minor inconsistency in man
- page describing strace.
-
- I fixed a bug that prevented "system stty -echo raw" from
- working. The raw data was clobbering the -echo data.
-
-12/3/91 3.9.0 Brian Woodson noted that "close -i ..." evoked a syntax error.
- I had parsed the arguments incorrectly.
-
- After the nth request, I finally set up pub/expect/scripts as
- a directory for scripts.
-
-12/2/91 3.8.0 Phil Sheperd <pshepher@loki.uni.edu.au> fixed a major bug in
- exp_spawnv() preventing one side of the pty from being set up
- correctly. Thus nothing worked! He also reported that his
- system didn't have strdup, so I added an explicit defn of it.
-
- James B. Davis fixed a couple nroff-bugs on the man page, and
- said someone already gave him a dump script (see below).
-
- Richard (R.C.) Vieregge <richv@bnr.ca> found a $ was missing
- from test/ftp.exp.
-
-11/22/91 3.7.2 James B. Davis <james@solbourne.com> straightened out a couple
- things in the Makefile and asked if anyone had written a script
- for dump.
-
- Jeff Okamoto <okamoto@hpcc25.corp.hp.com> had a couple changes
- for HPUX 7 and 8 compat, involving termio stuff.
-
- Prompted by Andy Norman, added note to man page describing how
- to disable all argv processing while using #!.
-
- Converted passmass and rftp over to new version.
-
-11/15/91 3.7.1 Brian Woodson asked me about the Tcl_WaitPids "got unknown
- process" panic. This is a Tcl bug that John has promised
- to fix. I'll document how to avoid it in the man page.
-
- Incidentally, I'm going under the knife tomorrow for three
- torn cartilage in my wrist. The doctors say it may be a couple
- days to couple months. Until I get back, hang in there.
-
-11/13/91 3.7.0 Yet another bug discovered (and fixed). "expect eof" was
- failing to remember the buffer, and expect_out(buffer) was
- empty upon return.
-
- Brian Woodson noted I forgot to document the -i flag of close.
-
-11/12/91 3.6.0 Sean Cunningham <sean@moorenet.com> reported that he couldn't
- open /dev/tty from 'at'. 'spawn' was incorrectly not executing
- code to claim it was a controlling tty. BSD only.
-
-11/11/91 3.5.1 Brian Woodson notes that version 2 and 3 treat the following
- differently.
-
- proc p {} {spawn s}; expect
-
- In v3, spawn_id is locallized by the proc, and thrown away when
- p returns. Unfortunately, in v2 due to some sloppy coding on
- my part, spawn always affected the global value of spawn_id.
- This differed from the handling of other variables, and in v3,
- this unusual behavior had to go, because the multiprocess
- handling and the large number of variables implicitly set
- (especially by the expect command) demanded that I be more
- systematic about how this was done.
-
- Since I never depended on this behavior, I never documented it
- as being something you should rely upon. Alas. To fix it, add
- the line
-
- global spawn_id
-
- to the beginning of any proc that calls spawn and needs the
- value of spawn_id implicitly defined outside of the proc.
-
-11/6/91 3.5.0 Drew Whitehouse <Drew.Whitehouse@anu.edu.au> hit a bad pointer.
- I forgot an initialization in expect.c which caused problems
- when an EOF occurred which had no eof pattern.
-
-11/2/91 3.4.0 Added FAQ from various questions people have sent me and my
- replies. Made CONVERTING file on converting from 2 to 3.
-
- Nelson H. F. Beebe <beebe@math.utah.edu> found a missing
- declaration for exp_tty_original in bye() of main.c. How come
- the Sun C compiler doesn't complain about this!?!!?
-
- Nelson also reported that SunOS 4.0.3 had a problem including
- varargs. It turned out that old varargs had check for
- reinclusion, and tclInt.h also includes it. So I added an
- #ifdef va_dcl and put my inclusion after tclInt.h.
-
-10/31/91 3.3.0 Converted most of the examples. Three more to go.
- Worked on man page some more.
-
- Modified expect so that if timeout > 0, and nothing in the
- buffer matched, it will force a read, no matter how long the
- preceeding code took. This may be hard to understand, but is
- the intuitive behavior that I always desired.
-
-10/30/91 3.2.0 Fixed bug in eof handling. Converted some more of the
- examples, and added to Makefile.
-
-10/29/91 3.1.0 Fixed slight bugs in tty mode switching, pty initialization
- (via stty).
-
- Fixed expect library. Fixed compatibility code for non-BSD
- systems. As usual, I could only test it so far, not having
- all these systems at my disposal. I don't expect major
- problems though, since the basic functions I depend on haven't
- changed.
-
- Completely rewrote handling of continue, return, etc in
- expect, interact, interpreter. It's actually systematic now.
-
- Checked with John O. about some code to bounce wild return
- codes, which he said was a mistake and would remove, so now I
- can pass my own return codes different from Tcl's.
-
-To get | to return -> TCL_RETURN TCL_OK (no return)
- V
- expect return default continue -expect
- interact return -tcl return default
- interpreter return -tcl return default
-
- What this table says is, to get "interpreter" (for example) to
- return TCL_RETURN to its caller, you must say "return -tcl",
- because "return" makes it return TCL_OK.
-
- The "argumented" versions are considered to be the uncommon
- form. In particular, I'd be surprised if anyone ever uses
- the -tcl argument, but it's there for completeness and
- consistency now.
-
- Put together a FAQ. Needs more work, but hopefully worthwhile
- as is.
-
- Computing Systems with Expect article appeared a couple days
- ago. How ironic that it describes the old version of Expect.
- Nonetheless, it looks ok.
-
-10/25/91 3.0.0 alpha!
- First release of Tcl-6.0-ready code.
- It might fly for a couple seconds.
-
- Here is a quick list of changes. Besides Tcl incompatibilities, Expect
- incompatibilities are flagged below as:
-
- ** major - scripts definitely won't run if they depend on this
- * minor - scripts probably will run but there is some subtle
- change that should be examined).
-
- ** Select renamed 'ready' and undocumented. Seems pointless now.
-
- Added support to expect command for waiting on patterns from
- different processes. The old version implemented this via
- 'select' but but it is much simpler via expect. Added -i to
- a number of commands to signify a spawn_id which overrides
- the variable.
-
- Added any_spawn_id to match any spawn_id.
- An explicit null pattern, forces a spawn_id to be considered
- when all it can possibly match are any_spawn_id patterns.
-
- * output is no longer flushed to expect_match upon timeout.
- May be multiple buffers now, so it doesn't make sense to
- flush just one.) -n was added to disable transfers from input
- buffer to expect_match var. I suspect it will only be used
- for experimentation.
-
- Added expect -re for regular expressions. Added expect_out
- array to retain indices and strings of partial matches for
- ** for both glob and re. expect_match has been renamed
- expect_out(buffer).
-
- A la Tcl, added -nocase for both types of patterns. (Oddly,
- Tcl's case only does it for regexps.)
-
- By popular demand, unanchored glob patterns. Old patterns
- will continue to work, since earlier interpretation was much
- stricter. Unfortunately, unanchored matches make certain user
- errors easier. For instance, people will send answers before
- seeing all of the question. Typically, output can 'look'
- ugly, as answers land in the middle of other things.
-
- To anchor patterns, use ^ in beginning and/or $ at end.
-
- Added expect_out(spawn_id) to report which spawn_id was read.
-
- Made expect and variants understand all args as one arg.
-
- Added 'default' pattern.
-
- Added continue_expect command.
-
- Added expect_before, expect_after commands which take same
- args as expect, but continue to stay in effect for all expects.
-
- ** Added match_max command, deleted it as a variable. The old
- way was too coarse for use over multiple spawn_ids. With no
- arg, returns current max. Takes -i flag and -d for default.
-
- Added globbing to spawn command.
-
- Added optional -i spawn_id to wait.
-
- Added optional -i to send (and all its variants).
-
- Renamed trace to 'strace' since it conflicts with Tcl's new
- trace command. Since 'trace' traces variables, I figured
- 'strace' wasn't too bad (for "statement trace"). I felt
- obliged to make it short and not as obliged to make it as
- meaningful since it will probably invariably be typed by hand.
-
- Made timeout == -1 mean infinity.
-
- Made interact do pattern matching in both directions via
- use of -o flag.
-
- Added -F flag for convenience. If -f or -F used, interact
- can no longer be overrun. In particular, if more characters
- arrive then match a pattern, remaining characters will be
- buffered rather than thrown away (old behavior).
-
- Patterns may now be substrings of one another.
-
- Made interact optionally take all args as one.
-
- Default action is now 'interpreter' (see below).
- interpreter now forces cooked mode, and echos results
- so you don't have to constantly say "send_user [...]\n"
-
- * Interact reads characters that have been buffered but not
- matched by expect. And vice versa. Does anyone care?
- (My rogue script did.)
-
- From discussion with John Conti, I decided to make
- 'interpreter' a separate command to start up interactive
- command processor. Changed default action in interact to this.
- Added eval depth and event id to prompt to interpreter.
-
- Added expect_library which contains path for commonly
- sourced expect scripts. Automatically source expect.rc
- out of expect_library unless -N given. Automatically source
- ~/.expect.rc unless -n given.
-
- Added expect_version command to print and/or verify script
- is compatible with running expect. Tcl version is also tested.
- Felt it was worth making this a command because it's such a
- pain to tear apart version strings.
-
- Tcl's close and exit are both subsumed by expect's commands
- of the same name.
-
- Rewrote mode switching code so that "system stty" is handled
- specially. This allows interact and interpret to get the modes
- they want, without burning the user. It is now much easier
- to leave expect in raw mode all the time, but the choice is
- up to the user.
-
- Added vgrindefs, courtesy of Brian Fitzgerald.
-
-9/23/91 Tcl 6.0 released. This new Tcl has some incompatibilities
- with the old Tcl, so as long as everyone is changing their
- scripts already, I'm taking the opportunity to make some
- incompatible changes to Expect that I've wanted to do for a
- long time.
-
-9/11/91 2.67 Ed Klein <eklein@syrinx.umd.edu> added support for SVR4 in the
- form of pty_svr4.c and mods to command.c.
-
- Added explanation to man page of how to create unreadable but
- executable scripts. (No, chmod 111 doesn't work.)
-
- Mark Diekhans <markd@grizzly.COM> pointed out to me that there
- is a potential problem with the trap command:
-
- "There is no control over when the signal will cause Tcl_Eval
- to be executed. There is a chance that code in the Tcl library
- will be executing when the signal comes in and the interpreter
- data structure will be in an inconsistent state. This could
- cause all sorts of nasty things to happen. In our Extended Tcl
- (4.0) we added signal handling. but the way we implemented it
- was to have the signal handler set a global flag. We modified
- Tcl_Eval to check the flag after it finishs executing each
- command. If the signal came in, Tcl_Eval then returns an error
- such as: "SIGINT signal received". Signals may then be caught
- with the catch command and processed."
-
-9/10/91 2.66 Don Jackson <Don.Jackson@Eng.Sun.COM> found a syntax error in
- the usage error message of the example ftp-rfc script.
-
- Marty Olevitch <marty%cosray@wuphys.wustl.edu> provided mods to
- support MORE/bsd. Namely, added #include types.h to expect.c
- and extern int errno to a number of files.
-
- Scott Hess <scott@nic.gac.edu> noted a potential problem in
- interact. Since interact only checks patterns at beginning
- of reads, user can conceivably type fast enough so that
- patterns are typed in the middle of a read. In reality this
- doesn't happen, but Scott was driving one expect with another
- expect and in this way provoked the behavior.
-
- The solution is to read chars one at a time, either by
- read(,,1) or buffering in a stdio-like way, but I'm not going
- to do that because the code should really be rewritten entirely
- and it just isn't worth it, since it is so easy to get around
- at the user level.
-
- Steve Legowik found that spawn-disconnect sequences fail. The
- pty testing I added in version 2.55 causes expect to regain the
- slave as a controlling tty, which generated SIGHUPs. If anyone
- knows a clean way to avoid regain controlling ttys, let me
- know. For now, I just set SIGHUP to SIG_IGN in the disconnect
- command.
-
-8/14/91 2.65 Old passmass script changed root password. I renamed it to
- passmass.old, and made a new one which works for any account.
- It also supports yppasswd, telnet/rlogin, different names for
- accounts on different machines. Handles VMS machines, too.
-
- Added Computing Systems paper to expect distribution and moved
- all expect-related things to separate expect directory in our
- ftp directory.
-
-8/5/91 2.64 Achille Petrilli <achille@miss.cern.ch> found that on an SGI,
- the expect command ocassionally returned "no more processes".
- He traced the problem back to O_NDELAY in the open, which was
- taken as-is from the man page, by someone else who's code I
- didn't look at too closely at the time. The result works now.
- Oddly I thought I fixed this error myself when the SGI support
- was first installed, but I cannot find it. I evidentally
- screwed up.
-
-7/31/91 2.63 Steve Legowik <legowik@cme.nist.gov> wanted to implement
- callback by having a modem dial out and NOT go away, but
- interact in the reverse direction. I added "interact -u" to
- support the idea of changing the user from the default stdio
- to a second spawned process. The result is that we can now
- write a modem callback program that doesn't depend on the cute
- trick of having getty recognize DTR which only worked when the
- modem was directly connected to the computer. In Steve's case,
- there were several network switches in the way.
-
- Added "overlay" function which is similar to plain "exec" in
- shell. (Too bad Tcl took the name already.)
-
- Added robohunt scripts to the test directory. I wrote these
- back in January, '91 and forgot about them til now. But I
- suppose they are illustrative (at the very least of how to
- generate truly random numbers). Ha.
-
-7/20/91 2.62 Carl Witty <cwitty@jessica.stanford.edu> pointed out my fdset
- implementation (for systems that don't have it) wasted some
- space. I had commented it correctly, however, making the
- incorrect code obvious (except to me).
-
- Robert Howland <howland@rahjr.ame.nd.edu> pointed out that
- expect complained about not running from a real terminal under
- cron. Oops! So I added a test to skip saving/restoring
- terminal modes when fd 0 is not a tty, since this is obviously
- pointless.
-
-7/19/91 2.61 Oops. Forgot to include getline and getline.exp examples even
- though they have been documented!
-
-7/17/91 2.60 UMich changed interface to weather system necessitating change
- to weather script.
-
-7/9/91 2.59 Didn't correctly comment things right in Makefile. Fixed.
-
- Changed 'close' in gethostbyaddr example to 'catch close'.
-
-6/22/91 2.58 Made new file (pty_sgi.c) for supporting Silicon Graphics ptys.
- Silicon Graphics select fails to see eof immediately but poll
- works ok. Unfortunately, there was an error in inter_poll
- (bad_io was uninitialized). Silicon Graphics works now.
-
- Andy Norman <ange@hplb.hpl.hp.com> notes that linking expect
- with the BSD compatibility library under HP-UX, libc.a must
- be loaded before libBSD.a. Modified Makefile to reflect this.
- He notes that there is a problem with expect not reading an EOF
- from the current process. This should go away with HP-UX 8.0
- when select has been enhanced to flag exceptions in the readfds
- argument. Probably inter_poll would work.
-
- Edward Haines <haines@bbn.com> notes that close returns EPERM
- ("Not owner") on his Sun 4.0.3. This is rather startling!
- (That's what I get for checking the return value of close!)
- He said it is possible that they have modified things (viz.
- DDN X.25 is loaded), but it still sounds incredible. For now,
- I told him to either "catch" all closes or to remove the check
- in the source code.
-
- Added example scripts: ftp-rfc retrieves an RFC from uunet
- via ftp. archie mails back a listing from the archie server.
-
- Add the rest of Hal Peterson's changes for Cray support, 1)
- fixing a problem where spawned processes flushed unread I/O
- upon process exit, and 2) creating processes with the correct
- uid. See his comments in command.c for more info.
-
-6/6/91 2.57 (On Cray) made signal handler declarations right. Added
- missing #endif. Added includes to pty_unicos.c. Fixed bug
- in two bugs in CmdSend, one involving send_stderr, the other
- send_user. All of these are from Hal Peterson.
-
- Added gethostbyaddr as example script. Given an internet
- address, it returns the domain name. By querying neighboring
- hosts if the name server fails, a much higher probability of
- returning the name is obtained.
-
-5/30/91 2.56 Mispelled "match_max" as "max_match" in rftp script. This
- caused files after the 2000 byte mark (per directory) to be
- skipped.
-
-5/21/91 2.55 Revisited BSD pty code to reject ptys that have either slave or
- master side already open. This fixes problems rare problems
- such as expect not being able to see EOFs from the child proc.
- (because another process still has the pty slave side open).
- USG and Cray pty code could probably use this code, too.
-
- Fixed bug in expect library (lib_exp.c) which caused output to
- be copied to stderr instead of logfile when logfile_all was
- set. Per Sreedhar Muppala <muppalla@nssdca.gsfc.nasa.gov>.
-
-5/16/91 2.54 Fixed weather script to accomodate occasional Weather Watch
- that would cause an unexpected initial question to pop up.
-
-5/15/91 2.53 Added comment to BUG section of man page describing pty
- misbehavior with non-interactive programs (search for "553061"
- below), as per Hal Peterson <hrp@cray.com>.
-
- Removed note from README about asking Ousterhout for SV TCL
- at his request.
-
-5/11/91 2.52 Fixed a syntax error that Bruce Larson <ires@kaspar.ires.com>
- found in inter_poll.c
-
-4/23/91 Computing Systems accepted paper on Expect for issue 4.2.
-
-4/18/91 2.51 Added some example scripts:
- weather - retrieves weather forecasts from National Weather
- Service via University of Michigan server.
- rftp - ftp a directory hierarchy (i.e., recursively).
-
-4/18/91 2.50 Changed timeout to apply to total time in expect rather than
- per read(). Original behavior hung forever when my modem test
- script started listening to a modem than spit out 1 spurious
- character every 10 seconds (very consistently).
-
- Hal Peterson <hrp@pecan.cray.com> noted that exp_spawnv's args
- didn't match documentation. Fixed in favor of documentation.
- Several other funcs don't match header file (but typechecking
- is avoided during compilation), because it was too hard for me
- to make the header file ANSI compliant and support varargs
- (which is undeniably more portable than stdargs at this point).
- Fixed prototype declarations (again) in expect.h for C++ and
- Standard C. Verified with GNU, G++ and Sun C (proto-less).
-
- Added exp_disconnect to library. Moved alarm calls closer
- to read() to tighten windows.
-
-4/11/91 2.49 Changed passmass script to use timeout of 1000000 instead of
- 10000000000 after discovering that Ultrix sleep(3) doesn't
- sleep at all for large values!
-
- Added support for systems without dup2 (SVR2) per
- <elston@edwards-tems.af.mil>.
-
- Added test/Makefile to shar as per Chris Pribe
- <cpribe@park.bu.edu>.
-
-4/4/91 2.48 Fixed possible problem with poll in inter_poll.c for systems
- that check for a valid address even though no members are used.
-
-3/27/91 2.47 Added support for Cray Unicos 6.0, which of course is different
- from Unicos 5.1 (which was different from everything else)!
- This and other minor bugs fixed courtesy of Pete Termaat.
-
-3/19/91 2.46 Removed a "feature" which caused patterns with no whitespace
- not to be run through SplitList. While not documented not to
- do so, this was mystifying even to me when I saw it. For
- William Waite. The result actually simplified the internal
- handling of multiple patterns, removing some excessively
- complex logic that I thought would be helpful for speed, but
- that in retrospect, was not that important.
-
-3/16/91 2.45 Added my own definition of FD_SET, fd_set, etc, test for
- SIGABRT, and support different types of signal arg func
- definitions to support SunOS 3.5 as requested by William Waite
- <waite@scotty.colorado.edu>.
-
-3/14/91 2.44 Removed redundant def'n of pty_stty in pty_usg.c, redef of
- sprintf and added signal.h to command.c to make compiles
- cleaner on SV3 and HPUX machines. All compliments of Mike
- Gourlay.
-
-3/10/91 2.43 Added -s (for slow) and -h (for human) flags to send. This
- had been requested by several people including Frank Terhaar-
- Yonkers (who actually wrote and tested a "send_slow" command),
- and Steve Simmons who suggested the "human" option (over a year
- ago), and Brian Woodson (brianw@swqa-sun.ESD.3com.com), who
- requested both! Thanks to NIST statistician, Keith Eberhardt,
- who taught me about the Weibull Distribution.
-
- According to Jim Thomas <jthomas@nmsu.edu>, 3b2 requires
- defines for R_OK and W_OK. Added to pty_usg.c.
-
- Added support for "-" as file name on command line to mean
- stdin as requested by Steve Clark <clark@cme.nist.gov>.
-
- Wrote passmass (change root password on a set of machines) as
- requested by Ken Manheimer <klm@cme.nist.gov>. Added to test
- directory.
-
-2/21/91 2.42 Removed reinstallation of signal 0 in signal handler.
-
- Added hook for setting initial pty parameters when started in
- the background. Should've done this a long time ago, but I
- was never really happy with my solution and had hoped I would
- think of a nicer method. I only hope this is clean enough.
-
-2/10/91 2.41 Added buffer_full keyword to solve Brian Fitzgerald's problem.
- It disables "forgetfullness" so that when expect's internal
- buffer hits match_max, whatever it has returns at that point.
- Didn't add this to the library version, because I want to think
- for awhile about the cleanest way to do it.
-
-2/4/91 2.40 Per Brian Fitzgerald (fitz@mml0.meche.rpi.edu), fixed error in
- interact example on man page which incorrectly implied that
- "kill" was built-in.
-
- Added fork/disconnect functions. This solved the problem of
- Jerry Friesen (jafries@snll-arpagw.llnl.gov) who wanted to run
- an expect script that asks for a password and then goes to
- sleep for awhile before waking up to run in the background (to
- run a program using Kerberos).
-
-1/30/91 2.39 Per Jim Johnson (jaj@mlb.semi.harris.com), added declaration
- and documentation for exp_pid in libexpect.
-
-1/10/91 2.38 More mods from Frank Terhaar-Yonkers. Also, some requests
- from Pete TerMaat (pete@willow.cray.com) for features:
-
- 1) a single-step facility. Yeah, that would be nice. No
- ideas on how to do this easily.
-
- 2) Generate scripts automatically after watching a session.
- This is hard. Read more about this in the FAQ.
-
-1/10/91 2.37 Added support for Cray Unicos 5.1, all courtesy of Frank
- Terhaar-Yonkers (fty@sunvis.rtpnc.epa.gov). Most of it had to
- do with pty support.
-
-1/8/91 2.36 Modified expect.h to support C++ and ANSI prototypes. Added
- appropriate example in test directory based on chesslib.c.
-
-1/7/91 2.35 At the request of Jan Norden (jano@imdpy1.im.se) added
- NO_MEMCPY and NO_STRING_H defines for Pyramid.
-
-1/3/91 2.34 Added a check to protect against a longjmp occurring between
- i_read and alarm(0). Didn't think this would be a problem but
- evidentally a function return modifies the stack, so it cannot
- be returned to again. Drat! This appeared in the robohunt
- script I wrote which plays hunt automatically and uses 1
- second timeouts.
-
-12/19/90 2.33 Add signal to sighandler, to reinstall signal for those systems
- that need it.
-
-12/12/90 2.32 Removed test for args to expect. I only recently realized that
- no args still allows a valid way to check for timeout and eof!
-
-12/6/90 2.30-1 Mike Gourlay (mike@penguin.gatech.edu) found and fixed quite a
- few SV-related problems that I had introduced since Clem's
- fixes. We eventually got it to run on his HPUX machine, a
- mixed breed of BSD/USG stuff. But spawning a shell worked but
- always produced a complaint about "no access to tty" which we
- were never able to get rid of, and he had a problem with
- exp_fexpect (but not exp_expect), although it still isn't clear
- if that was expect's fault. He said he would speak to some HP
- engineers about what he found.
-
-12/5/90 2.29 Fixed a malloc off-by-one bug in new C library. After
- contemplation, revised interfaces. Decided that rather than
- following the original 'expect' style, it should be more like
- what a C programmer is used to, so I made the file descriptors
- be parameters to exp_expect rather than globals, added an
- exp_popen which is a popen equivalent, and added exp_fexpect
- versions which are stream equivalents.
-
- Am not happy with exp_fexpect. It is much less efficient than
- exp_expect, because there is no way to (portably) get fread()
- to return the way read() does, with less then the number of
- characters you supplied a buffer for. Instead, I have to call
- fgetc for every char. Ugh.
-
- Add a couple new examples, including lpunlock, time.exp,
- chesslib.c (using file descriptors) and chesslib2.c (which uses
- stream pointers).
-
-12/3/90 2.28 Created C library version of expect.
-
-11/29/90 2.27 Fixed bug in interact - when no string actions were defined,
- the mapping table length wasn't set at all.
-
- Made interact call printify when debugging so that crlf and
- other nonprintables are visible. Fixed bug in printify which
- interpreted some characters wrong due to parity.
-
- Added some more examples to the distribution (lpunlock, dvorak,
- timed_read) and put in another tip in the TCL HINTS section of
- the man page.
-
-11/18/90 2.26 Fixed mismatched comment per Craig Warren (ccw@deakin.oz.au).
- Also improved man page entry for "interact".
-
-11/17/90 2.25 Added -f (fast) on interact options, and made default case a
- little more efficient. Added explicit support for SIG_IGN and
- SIG_DFL in trap command. Added ability to specify signals
- symbolically for portability.
-
-11/15/90 2.24 Craig Warren (ccw@deakin.oz.au) wanted to exit expect while in
- interact with a single character. Dan Bernstein
- (brnstnd@kramden.acf.nyu.edu) wanted to suspend with a single
- character. So I generalized interact's escape character to
- string-action pairs.
-
-11/7/90 2.23 Tired of getting reports that various (Ultrix 3.1, BSD4.3) C
- compilers can't handle ternary conditionals returning ptr to
- func returning void. Made all (2) such statements into
- if-then-elses. Per Steve Simmons (scs@iti.org).
-
-10/8/90 2.22 Allow "log_file" even when no log is open. This makes user
- programming a little simpler - they don't have to remember
- whether they opened the log or not.
-
-9/27/90 2.21 Fixed bug, v2.19 introduced. debuglog(unknown string) requires
- a "%s" as formatting for protection against %'s in the unknown
- string.
-
-9/17/90 2.20 4 syntax errors in interact_poll.c, vik@sequent.com. Added
- quotes to all the sends (now that this is more efficient) in
- the examples and man pages. Also removed a misstatement in the
- man page about the behavior of double quotes.
-
-9/15/90 2.19 Removed buffering from send command. Originally, I buffered
- the args, so I could do it all in one write. But to send
- variables bigger than the buffer didn't work. I didn't think
- about this before. But Joe Gorman
- (Joe.Gorman@elab-runit.sintef.no) asked me if you could "send"
- a file in one command, and of course you can using [exec cat]
- as the argument to send, but the damn buffering prevented big
- files from being sent. Anyway, now it works.
-
-9/14/90 Fixed the declarations of nflog and nferrlog. Added a #define
- so lack of pid_t could be controlled from the Makefile. Per
- Andy Holyer (and@ux.rfhsm.lon.ac.uk)
-
-9/4/90 2.18 Added trap command to catch signals. This is nice as (among
- other things) it allows you to turn off the conversion of ^C to
- timeout which was requested by John Conti <jconti@cisco.com>.
-
-8/21/90 2.17 Fixed bug in printify. Forgot to reset ptr to beginning of
- print buffer. Made debugging info wrong. Possibly screwing up
- other things on overflow.
-
- Paper accepted into USENIX LISA!
-
-8/15/90 Cleaned up man page. Made tabs line things up correctly,
- finally.
-
- Found another problem with ptys (at least under SunOS 4.1 and
- earlier). When last pty-slave fd closed, any unread output is
- lost after a short window of time (around 10 seconds on a
- Sun 3/60). Sent example ptybug.c to Sun demonstrating this and
- EIO problem found earlier. (Service Order #553061)
-
-8/6/90 2.16 Added -f to debug command, -a to log_file command. This
- required significant changes, including revisiting all the
- logging routines, plus miscellaneous output done in special
- places. Noted that it cannot be done with getopt, since it
- could be called during main's getopt, and getopt is not
- reentrant! (Guess how I discovered this!!)
-
- I'm not particularly happy with the design, but maybe others
- won't be. In any case, I like the benefit of it and am now
- glad that -a was asked for. Per Harry Bochner and Ira Fuchs
- (fuchs@pucc.bitnet).
-
- Changed behavior of argv, so that 0 == [length $argv] when no
- script/args supplied.
-
-8/4/90 2.15 Added debug command, so -d-ness could be changed while expect
- is running.
-
-7/20/90 2.14 Fixed small bug in -d output from expect, which printed ^Z as
- ^:
-
-7/18/90 2.13 Added wait command. A waitpid/waitspawnid would be nice and
- cleaner, too, but since csh doesn't need it, it is probably not
- worth much.
-
- Consequently, removed SIGCHLD handling from command.c. It
- worked under SV but not BSD. By forcing users to explicitly
- code waits, resulting scripts are more portable.
-
- Rewrote rogue example. rogue sometimes misses EOF (generated
- by close on our side) and continues reading.
-
-7/16/90 2.12 Removed buffering from variadic log routines. This was
- faulting when the buffers overflowed.
-
- Cleaned up the -d output from expect, so it is much more
- readable. For example, control characters are now visible.
-
-7/14/90 2.11 Added declaration for errno, to support 4.3BSD. Per Alan
- Crosswell. Added -i flag and related behavior.
-
-7/12/90 2.10 Fixed bug where timeout = 0 waited forever rather than not
- waiting at all.
-
-7/11/90 Fixed man page example which didn't include the blank on the
- end of an ftp prompt.
-
-7/9/90 2.9 Fixed bug in send when spawn_id = $user_spawn_id.
-
-6/27/90 2.8 Integrated some mods from clem cole (clemc@ccc.com) to support
- System V.3 (386/ix Version 2.02). Unfortunately, he didn't do
- "select".
-
-6/25/90 2.7 Test that cmdfile and logfile are open before fclosing in child
- while spawning. Per Corey Satten <corey@cac.washington.edu>
-
-6/24/90 2.6 Pty master returns EIO instead of EOF when pty slave closes.
- Bug in pty driver? Until I figure this out, I have put in code
- to interpret EIO to EOF.
-
-6/21/90 Added new section to expect man page - Tcl hints.
-
-6/14/90 Spoke at USENIX. Went well. Added USENIX paper as separate
- ftp archive.
-
-6/4/90 2.5 Fixed bug in ^C catching during expect. Changed man page to
- accurately describe what ^C does. Fixed bug that caused "send"
- to screw up when handed 0 arguments. All per Harry Bochner.
-
-6/1/90 2.4 Made trailing empty action in expect optional, primarily to
- make straightline code easier to read.
-
-5/15/90 2.3 Changed expect to strip nulls from program output since there
- is no way for Tcl to handle them, per Harry Bochner.
-
-5/5/90 Added "send_error" command.
-
-4/26/90 Got USENIX paper back from Kolstad to proof. Am depressed at
- how awfully they formatted it.
-
-4/25/90 2.2 Eric Newton found that expect's special variables weren't being
- found inside of user subroutines. Had to do with new Tcl,
- which now differentiates between variables that are undefined
- vs. empty.
-
-4/24/90 Upgraded Tcl from 2.1 to 3.3.
-
-4/22/90 Added special behaviors of ^C in expect, and when profiling.
- Profiled rogue (at urging of Ousterhout).
-
-4/10/90 2.1 Added select command. Added support for user_spawn_id so that
- you could treat user just like another process (i.e. with send
- and expect). Decided to leave send_user/expect, since scripts
- are more readable with them.
-
-4/2/90 2.0 Changed syntax of expect to provide alternatives (a la Tcl
- case), per suggestion of John Ousterhout. Note that this
- breaks pre-2.0 scripts.
-
-3/31/90 Got great comments from Ousterhout. (This time he said that he
- really liked the idea. Maybe he realizes how much it will
- promote Tcl!)
-
-3/30/90 Got comments from dpk. Made me think more about Perl.
-
-3/28/90 Evi said I should turn the paper in unformatted and they will
- format it. (She's kidding, I hope.)
-
-3/27/90 1.8 Rewrote interface so that raw arguments can be passed in like a
- shell. I'd been thinking about this for some time, but Eric
- Newton finally prodded me into action.
-
-3/25/90 Got first corrections for paper - from Sue Mulroney!
-
-3/24/90 Observed that it is possible to use the #! syntax with expect.
- I asked John O. about this (his choice of # as a comment
- character), and he said it was pure coincidence. Deprecated
- request to end scripts in ".exp".
-
- Ted Hopp volunteered to be my Center WERB reader.
-
-3/23/90 Finished 1st draft of USENIX paper and sent copies to John
- Ousterhout and panel chair, dpk@morgan.com.
-
-3/20/90 1.7 Deprecated "stty", and added more general "system" command.
-
- Sent Evi some complaints about the business of not allowing
- camera-ready at USENIX.
-
-3/17/90 Sent copies of man page to Doug Gwyn and Larry Wall for
- comments. Note that gwyn downloaded it.
-
-3/16/90 Am really irritated by USENIX. My paper has been put in a
- session against another session, the BSD people. Furthermore,
- they called my paper an application, when it is no more so than
- any other shell or language. Better I should be in "lessons
- learned". Mashey said take a hike, i.e., it was too late to
- change the schedule. On top of that, our session has four
- people in it, so I'll have very little time to speak. Grrrr.
-
-3/13/90 1.6 Added "stty", because without it you can't do things like
- turning off echo to accept a password.
-
-3/8/90 1.5 Abstract was accepted into USENIX!!!! Time to start writing
- it! Sent man page to Ousterhout. He didn't seem too
- impressed.
-
- Added "send_user/expect_user" after listening to Ken complain
- about how shell could not do timed reads. Actually it can, but
- expect does it much more naturally. Deprecated echo. Now, I
- realize that expect can be viewed as a shell!
-
- Changed logfile/loguser to log_file/log_user to match all the
- variables with underscores in them.
-
- Barry Warsaw asked if there was any way one could execute any
- command from interact (apparently without any reason in mind).
- Nonetheless, it is a wonderful idea, and I changed the "abort
- character" in interact to an "escape mechanism". After
- escaping, you may execute any command. return duplicates the
- old action of the abort character. Now you can do interactive
- job control, recursive interacts, etc. You can bet I didn't
- get this right the first time!
-
- At Scott's request, fixed bug related to pty initializing.
- Scott was putting expect in the background which disassociated
- it from a tty, and I was blindly copying the tty parameters
- without checking to see if they were meaningful or not.
-
- Tightened up exit code. Fixed bug in spawn so it would print
- error messages when it failed. Spawn sends back the error
- message in the pty, if the fork succeeds but exec fails. Cute!
-
- Added "close" command. Makes scripts much shorter and cleaner.
-
- Return string matched by expect directly, rather than setting a
- special variable.
-
- Added "match_max" feature. Probably no one will ever use it.
-
- Added trace command.
-
-3/6/90 1.4 Rob Densock was the second user, and suggested (demanded?) the
- idea of the loguser command. I added it and changed "log" to
- "logfile" making the first incompatibility with existing
- scripts (sorry, Steve).
-
-3/1/90 1.3 Trying to make pty code more robust. Many questions unanswered
- by manuals. Did a lot of guessing. While debugging, looked
- through pty code in gnuemacs to see if I might increase
- portability somehow. I almost barfed when I saw all the funky
- ifdefs on weird ioctls. Found lots of comments like "this
- might work".
-
-2/28/90 Sent a short Tcl bug list to John Ousterhout. He thanked me!
-
-2/22-3/90 1.2 Hooked my first user, Steve Ray. Surprisingly, he only found
- one bug in the code (exit didn't handle args correctly), but it
- was obvious that I need to put more explanation in the man
- page. Many of the examples in the man page are based upon his
- probl.. questions. Thanks, Steve!
-
-2/20/90 Posted news about expect to "general" newsgroup locally.
-
-2/15-20/90 Talked to local POSIX reps and then to Steve Albert (AT&T)
- about portability of select, wait and other system calls. I'm
- not impressed by 1003.1.
-
-2/9/90 John Ousterhout answered some questions I had about Tcl syntax.
- I like this language!
-
-2/8/90 1.1 Sandy Ressler suggested the idea of being able to spawn
- multiple programs at the same time although he didn't say how.
-
- It took about a day to design and code the spawn_id hook.
- Extremely difficult to support this with uucp-style kludge.
- Switched to using select. So much for portability.
-
- I investigated how to do this portably, and spent some time
- talking to NIST & AT&T POSIX representatives. Unfortunately,
- portability (especially when it comes to select()) remains a
- dream. Provided multiple versions of "interact" depending upon
- what OS you are running.
-
-2/7/90 1.0 Completed first cut of "sex" (for "Smart EXec" or
- "Send/EXpect"). Supports send, expect, echo, log, spawn,
- interact.
-
- Spent a lot of time making "log" write to log in just the right
- order (across fork and while debug flag enabled). Ended up
- writing a bunch of variadic log routines.
-
- Fooled around with uucp-style multiple processes versus one
- process doing select() to read asynchronously. Using
- uucp-style for now, since it is more portable.
-
- Gave up on pipes, and switched to ptys. Pipes seem to be
- messed up by ftp, perhaps because it goes into raw mode? Ptys
- are more efficient and cleaner to program albeit less
- well-documented and portable from system to system.
-
- Ken Manheimer helped me explain what the program does. I kept
- saying it does "send/expect" processing, and he kept insisting
- that was meaningless to everyone. (In fact, it comes from
- uucp, and I guess uucp hackers are indeed a dying breed.) Ken
- gave me an elegant enough sentence that I expanded it into an
- abstract and sent it in to the USENIX conference the following
- day (two days after the deadline).
-
- I noted that the uucp documentation I referenced in the
- submission is dated October 31, 1978!
-
-1/30/90 0.0 Got a copy of Tcl and went to work. Tcl was exactly what I
- need. Plus, it is easy to use, AND it is documented.
-
-1/25/90 Attended Winter 1990 USENIX in DC, with the goal of banging
- heads with some other gurus in hopes of finding a good
- send/expect language for a generalized stelnet. Had looked at
- uucp and kermit but found nothing general enough.
-
- Listened to John Ousterhout's presentation on Tcl. By the
- middle of the talk, I had found religion. At the end when he
- said it was public-domain, I was ready to orgasm.
-
-*/*/88-89 Spent a lot of time telling Scott how useful his program could
- be if he made it more general. I thought it wouldn't be that
- difficult to make more generic. Scott was interested but not
- enough to do it.
-
-9/25/87 Helped Scott Paisley write a program called stelnet, that
- forked a telnet and did very simple send/expect processing.
- It used pipes, not ptys. It had no pattern matching, and only
- straight-line control without error handling. Nonetheless,
- this got me to thinking about making stelnet more generic.
+++ /dev/null
-This file is INSTALL. It contains installation instructions for Expect.
-
-If you do not have Tcl, get it (Expect's README explains how) and
-install it. The rest of these instructions assume that you have Tcl
-installed.
-
-If you are installing Expect on a single architecture, or are just
-trying it out to see whether it is worth installing, follow the
-"Simple Installation" below. If you are installing Expect on multiple
-architectures or the "Simple Installation" instructions are not
-sufficient, see "Sophisticated Installations" below.
-
---------------------
-Permissions
---------------------
-
-On a Cray, you must be root to compile Expect. See the FAQ for why
-this is.
-
-If you want shared libs on Linux, you must be root in order to run
-ldconfig. See the ldconfig man page for more info.
-
---------------------
-Simple Installation
---------------------
-
-By default, the Tcl source directory is assumed to be in the same
-directory as the Expect source directory. For example, in this
-listing, Expect and Tcl are both stored in /usr/local/src:
-
- /usr/local/src/tcl8.0 (actual version may be different)
- /usr/local/src/expect-5.24 (actual version may be different)
-
-If Tcl is stored elsewhere, the easiest way to deal with this is to
-create a symbolic link to its real directory. For example, from the
-Expect directory, type:
-
- ln -s /some/where/else/src/tcl8.0 ..
-
-The same applies for Tk, if you have it. (Tk is optional.)
-
-Run "./configure". This will generate a Makefile (from a prototype
-called "Makefile.in") appropriate to your system. (This step must be
-done in the foreground because configure performs various tests on
-your controlling tty. If you want to do this step in the background
-in the future, automate it using Expect!)
-
-Most people will not need to make any changes to the generated
-Makefile and can go on to the next step. If you want though, you can
-edit the Makefile and change any definitions as appropriate for your
-site. All the definitions you are likely to want to change are
-clearly identified and described at the beginning of the file.
-
-To build only the stand-alone Expect program, run "make expect". This
-is appropriate even if you still haven't decided whether to install
-Expect, are still curious about it, and want to do the minimum
-possible in order to experiment with it.
-
-To build everything, run "make". If "configure" found Tk and X on
-your system, this will build "expectk" (Expect with Tk).
-
-Once expect is built, you can cd to the example directory and try out
-some of the examples (see the README file in the example directory).
-
-"make install" will install Expect. If you built Expectk, that will
-be installed as well. So will the documentation and some of the most
-useful examples.
-
-If you want shared libs on Linux, you must now su to root and run
-ldconfig on the shared library. See the ldconfig man page for more
-info.
-
-A handful of people running "pure" 4.2BSD systems have noted that
-expect fails to link due to lack of getopt and vprintf. You can get
-these from uunet or any good archive site.
-
---------------------
-Sophisticated Installations
---------------------
-
-The following instructions provide some suggestions for handling
-complex installations.
-
---------------------
-Changing Defaults
---------------------
-
-The configure script allows you to customize the Expect configuration
-for your site; for details on how you can do this, type "./configure
--help" or refer to the autoconf documentation (not included here).
-Expect's configure supports the following flags in addition to the
-standard ones:
-
- --verbose Cause configure to describe
- what it is checking and what it decides.
-
- --enable-shared Compile Expect as a shared library if it
- can figure out how to do that on this
- platform. (You must have already
- compiled Tcl with this flag.)
-
- --disable-load This switch is ignored so that you can
- configure Expect with the same configure
- command as Tcl. If you want to disable
- dynamic loading, configure Tcl with this
- flag and then reconfigure Expect.
-
- --enable-gcc This switch is ignored so that you can
- configure Expect with the same configure
- command as Tcl. If you want to enable gcc,
- configure Tcl with it and then reconfigure
- Expect. Expect will inherit the definition
- that way. It is not safe to modify the
- Makefile to use gcc by hand. If you do
- this, then information related to dynamic
- linking will be incorrect.
-
- --with-tclconfig=... Specifies the directory containing Tcl's
- configure file (tclConfig.sh).
-
- --with-tclinclude=... Specifies the directory containing Tcl's
- private include files (such as tclInt.h)
-
- --with-tkconfig=... Specifies the directory containing Tk's
- configure file (tkConfig.sh).
-
- --with-tkinclude=... Specifies the directory containing Tk's
- private include files (such as tkInt.h)
-
-Some of the defaults in "configure" can be overridden by environment
-variables. This is a convenience intended for environments that are
-likely to affect any program that you configure and install.
-
-The following environment variables are supported. If you use these,
-consider adding them to your .login file so that other installation
-scripts can make use of them.
-
-CC C compiler
-CFLAGS Flags to C compiler
-CPPFLAGS Flags to C preprocessor
-LDFLAGS Flags to linker
-LIBS Libraries
-CONFIG_SHELL Shell for configure and Make
-
-Settings can also be given on the command line. For example, you
-could tell configure about flags from a Bourne-compatible shell as
-follows:
-
- CFLAGS=-O2 LIBS=-lposix ./configure
-
-Although configure will do some searching for Tcl (and all of this
-discussion holds true for Tk as well), configure likes to find the Tcl
-source directory in the parent directory of Expect and will use that
-Tcl if it exists. To make sure Tcl can be found this way (if it is
-located somewhere else), create a symbolic link in Expect's parent
-directory to where the Tcl directory is.
-
-By default, configure uses the latest Tcl it can find. You can
-override this by creating a symbolic link of "tcl" which points to the
-release you want.
-
-If you can't or don't want to create symbolic links, you can instead
-indicate where Tcl and Tk are by using the following environment variables:
-
-with_tclconfig Directory containing Tcl configure file (tclConfig.h)
-with_tclinclude Directory containing Tcl include files
-with_tkinclude Directory containing Tk include files
-with_tkconfig Directory containing Tk binary library (tkConfig.h)
-
---------------------
-Multiple-Architecture Installation
---------------------
-
-You might want to compile a software package in a different directory
-from the one that contains the source code. Doing this allows you to
-compile the package for several architectures simultaneously from the
-same copy of the source code and keep multiple sets of object files on
-disk.
-
-To compile the package in a different directory from the one
-containing the source code, you must use a version of make that
-supports the VPATH variable. GNU make and most other recent make
-programs can do this.
-
-cd to the directory where you want the object files and executables to
-go and run configure. configure automatically checks for the source
-code in the directory that configure is in and in .. If configure
-reports that it cannot find the source code, run configure with the
-option --srcdir=dir, where dir is the directory that contains the
-source code.
-
-You can save some disk space by installing architecture-independent
-files (e.g., scripts, include files) in a different place than
-architecture-dependent files (e.g., binaries, libraries). To do this,
-edit the Makefile after configure builds it, or have configure create
-the Makefile with the right definitions in the first place. To have
-configure do it, use the following options to configure:
-
- --prefix=indep
- --exec-prefix=dep
-
-where dep is the root of the tree in which to store
-architecture-dependent files and indep is the root in which to
-store -dependent files. For example, you might invoke configure this
-way:
-
- configure --prefix=/usr/local/bin --exec-prefix=/usr/local/bin/arch
-
---------------------
-Test Suite
---------------------
-
-Patterned after the Tcl test suite, I have begun building a test suite
-in the subdirectory "test". It is still incomplete however you may
-use by typing "make test" in this directory. You should then see a
-printout of the test files processed. If any errors occur, you'll see
-a much more substantial printout for each error. See the README file
-in the "tests" directory for more information on the test suite.
-
-Note that the test suite assumes the existence of certain programs to
-use as interactive programs. If you are missing these or they behave
-differently, errors may be reported. Similarly, the test suite
-assumes certain other things about your system, such as the sane stty
-parameters.
-
-You may also try some of the programs distribute in the example
-directory (see the README file in the example directory). They are a
-strong indication of whether Expect works or not. If you have any
-problems with them, let me know.
-
---------------------
-Uninstalling
---------------------
-
-"make uninstall" removes all the files that "make install" creates
-(excluding those in the current directory).
-
---------------------
-Cleaning Up
---------------------
-
-Several "clean" targets are available to reduce space consumption of
-the Expect source. The two most useful are as follows:
-
-"make clean" deletes all files from the current directory that were
-created by "make"
-
-"make distclean" is like "make clean", but it also deletes files
-created by "configure"
-
-Other targets can be found in the Makefile. They follow the GNU
-Makefile conventions.
-
+++ /dev/null
-#
-# Makefile for Expect
-#
-
-# Requires at least Tcl 7.5
-# Known to work with up to Tcl 7.5
-
-# While Tk is optional, if you do use Tk, it must be at least Tk 4.1
-# Known to work with up to Tk 4.1
-
-VERSION_FULL = \"@EXP_VERSION_FULL@\"
-# Tcl's tclConfig requires VERSION have a short-style version string.
-VERSION = @EXP_VERSION@
-
-srcdir = @srcdir@
-VPATH = @srcdir@
-SUBDIRS = @subdirs@
-
-EXEEXT = @EXEEXT@
-
-######################################################################
-# The following lines are things you may want to change
-######################################################################
-
-# Tcl include files. (If you haven't installed Tcl yet, read the README file).
-# This must point to the directory that contains ALL of Tcl's include
-# files, not just the public ones.
-TCLHDIR = @TCLHDIR@
-ITCLHDIR = @ITCLHDIR@
-TCLHDIRDASHI = @TCLHDIRDASHI@
-# Tcl's Tcl library (definitions of parray, etc)
-TCL_LIBRARY = @TCL_LIBRARY@
-
-# Tcl library uninstalled. Should be something like -ltcl or ../tcl/libtcl.a
-TCLLIB = @TCL_BUILD_LIB_SPEC@
-ITCLLIB = @ITCLLIB@
-# Tcl library installed. Should be something like -ltcl or ../tcl/libtcl.a
-TCLLIB_INSTALLED = @TCL_LIB_SPEC@
-
-# The following definitions are only nec. if you want to use Tk with Expect.
-# Tk include files
-TKHDIR = @TKHDIR@
-TKHDIRDASHI = @TKHDIRDASHI@
-
-# Tk library
-TKLIB = @TK_BUILD_LIB_SPEC@
-TKLIB_INSTALLED = @TK_LIB_SPEC@
-
-# X11 include files and other flags to compiler
-X11_CFLAGS = @TK_XINCLUDES@
-# X library
-X11_LD_FLAGS =
-# XXX Temporarily commented out until expectk is working again.
-#X11_PROGS = @X_PROGS@
-# X11_PROGS_INSTALLED should really be a separate symbol generated by configure but we're
-# hitting configure's limit on substitutions, so be crude and use one less symbol.
-# XXX Temporarily commented out until expectk is workign again.
-#X11_PROGS_INSTALLED = @X_PROGS@
-
-# Flags to pass to both cc and ld
-# You should be able to leave this just the way it is. However, here are some
-# note if you run into problems:
-#
-# Avoid -O (optimize) unless you are convinced your optimizer is flawless
-# (hint: not a chance). I have heard many reports of -O causing Expect to
-# misbehave.
-# I encourage you to use -g (debugging). While it is unlikely you will
-# encounter an internal error in Expect, should this happen, I may just need
-# the -g information and then you will need to recompile Expect. As an aside,
-# Expect is not a space or time pig, so this won't affect the performance of
-# your Expect scripts.
-# Note: On Linux systems which only have dynamic X libraries, the -g prevents
-# the linker from using them. So do not use -g on such systems.
-# From now on, CFLAGS is never used. Instead, use XCFLAGS. This is done so
-# that we can provide a public interface for CFLAGS thereby allowing users
-# to add to it on the Make command-line and still get the rest of the flags
-# computed by configure. Do this at your own risk - it obvious goes against
-# the idea of configure's interface, however this is established tradition
-# at some sites (e.g., Cygnus)!
-CFLAGS = @CFLAGS@
-XCFLAGS = $(CFLAGS) @EXP_CFLAGS@ @EXP_SHLIB_CFLAGS@
-#XCFLAGS = @CFLAGS@ @EXP_CFLAGS@ @EXP_SHLIB_CFLAGS@
-XCFLAGS = @CFLAGS@ @EXP_CFLAGS@
-
-# Flags to pass only to linker (after .o files but before libraries)
-LDFLAGS = @EXP_LDFLAGS@
-
-# Which C compiler to use. For simplicity, we inherit the same definition
-# used when Tcl was compiled. Changing this definition here can screw up
-# deductions that the configure script made on the assumption that you were
-# using a different compiler.
-CC = @CC@
-
-# By default, "make install" will install the appropriate files in
-# /usr/local/bin, /usr/local/lib, /usr/local/man, etc. By changing this
-# variable, you can specify an installation prefix other than /usr/local.
-# You may find it preferable to call configure with the --prefix option
-# to control this information. This is especially handy if you are
-# installing Expect several times (perhaps on a number of machines or
-# in different places). Then you don't have to hand-edit this file.
-# See the INSTALL file for more information. (Analogous information
-# applies to the next variable as well.)
-prefix = @prefix@
-
-# You can specify a separate installation prefix for architecture-specific
-# files such as binaries and libraries.
-exec_prefix = @exec_prefix@
-
-# The following Expect scripts are not necessary to have installed as
-# commands, but are very useful. Edit out what you don't want installed.
-# The INSTALL file describes these and others in more detail.
-# Some Make's screw up if you delete all of them because SCRIPTS is a
-# target. If this is a problem, just comment out the SCRIPTS target itself.
-SCRIPTS = timed-run timed-read ftp-rfc autopasswd lpunlock weather \
- passmass rftp kibitz rlogin-cwd xpstat tkpasswd dislocate xkibitz \
- tknewsbiff unbuffer mkpasswd cryptdir decryptdir autoexpect
-# A couple of the scripts have man pages of their own.
-# You can delete these too if you don't want'em.
-SCRIPTS_MANPAGES = kibitz dislocate xkibitz tknewsbiff unbuffer mkpasswd \
- passmass cryptdir decryptdir autoexpect
-
-# Short directory path where binary can be found to support #! hack.
-# This directory path can be the same as the directory in which the binary
-# actually sits except when the path is so long that the #! mechanism breaks
-# (usually at 32 characters).
-# The solution is to create a directory with a very short name, which consists
-# only of symbolic links back to the true binaries. Subtracting two for "#!"
-# and a couple more for arguments (typically " -f" or " --") gives you 27
-# characters. Pathnames over this length won't be able to use the #! magic.
-# For more info on this, see the execve(2) man page.
-SHORT_BINDIR = @bindir@
-
-# If you have ranlib but it should be avoided, change this from "ranlib"
-# to something innocuous like "echo". Known systems with this problem:
-# older SCO boxes.
-RANLIB = @TCL_RANLIB@
-UNSHARED_RANLIB = @UNSHARED_RANLIB@
-
-# Change EVENT_ABLE to "noevent" if your system is:
-# old SCO because poll doesn't exist and select is broken on ptys
-# 3b2 SVR3 because select doesn't exist and poll is broken on ptys
-# If you do use "noevent":
-# 1) you must also edit expect_cf.h and change
-# "#undef SIMPLE_EVENT" to "#define SIMPLE_EVENT",
-# 2) you cannot use any event facilities such as "after" or anything in Tk.
-# 3) you cannot expect or interact with two or more processes simultaneously
-#
-EVENT_ABLE = @EVENT_ABLE@
-
-# Change EVENT_TYPE to poll if your system is:
-# NCR SVR4 (1.03.01) where select is broken on ttys
-# StarServer (SVR3 and SVR4.0) where select is broken on ttys
-#
-# You will need to change EVENT_TYPE to select if your system is:
-# Pyramid OSx in the att universe where poll is broken (see LIBS below)
-#
-EVENT_TYPE = @EVENT_TYPE@
-
-# Define default parameters for ptys. This is used when 1) running in the
-# background, 2) user has not defined the variable STTY_INIT to initialize
-# ptys, and 3) the pty-driver's defaults suck.
-#
-# If your system doesn't understand "sane", try "cooked". Apollo systems
-# need nothing at all and should delete this line. Systems using 8-bit
-# character sets may need to disable parity.
-# Systems that define sane to use @ as line kill and # as erase should
-# use something like "sane kill \15 erase \b".
-STTY = -DDFLT_STTY="\"@DEFAULT_STTY_ARGS@\""
-
-######################################################################
-# End of things you may want to change
-#
-# Do not change anything after this
-######################################################################
-
-bindir = @bindir@
-bindir_arch_indep = $(prefix)/bin
-libdir = @libdir@/expect$(VERSION)
-tcl_libdir = @libdir@
-# CYGNUS LOCAL: use datadir, not $(prefix)/lib.
-libdir_arch_indep = @datadir@
-# END CYGNUS LOCAL
-
-mandir = @mandir@
-man1dir = $(mandir)/man1
-man3dir = $(mandir)/man3
-infodir = @infodir@
-includedir = @includedir@
-
-# Expect's utility script directories - arch-independent and arch-non-
-# independent. These correspond to the variables "exp_library" and
-# "exp_exec_library".
-SCRIPTDIR = $(libdir_arch_indep)
-EXECSCRIPTDIR = $(libdir)
-
-SHELL = @EXP_CONFIG_SHELL@
-
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_DATA = @INSTALL_DATA@
-
-AR = ar
-ARFLAGS = cr
-
-LOCAL_EXPECT=LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH ./expect$(EXEEXT)
-
-# These definitions are used by the "subdirs_do" target to pass
-# the compile flags down recursively.
-FLAGS_TO_PASS = \
- "CC=$(CC)" \
- "CFLAGS=$(XCFLAGS)" \
- "CFLAGS_INT=$(CFLAGS_INT)" \
- "HDEFS=$(HDEFS)" \
- "INSTALL=$(INSTALL)" \
- "INSTALL_DATA=$(INSTALL_DATA)" \
- "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
- "LDFLAGS=$(LDFLAGS)" \
- "RUNTEST=$(RUNTEST)" \
- "RUNTESTFLAGS=$(RUNTESTFLAGS)" \
- "SHLIB_CFLAGS=$(@EXP_SHLIB_CFLAGS@)" \
- "prefix=$(prefix)" \
- "exec_prefix=$(exec_prefix)"
-
-#
-# Following defines are for DejaGnu
-#
-
-# These let the DejaGnu test suite run when DejaGnu isn't
-# installed yet, so run it from the srcdir and objdir.
-EXPECT = ` \
- if [ -f $${rootme}/expect$(EXEEXT) ] ; then \
- echo $${rootme}/expect$(EXEEXT) ; \
- else echo expect ; fi`
-
-RUNTESTFLAGS =
-RUNTEST = ` \
- if [ -f ${srcdir}/../dejagnu/runtest$(EXEEXT) ] ; then \
- echo ${srcdir}/../dejagnu/runtest$(EXEEXT) ; \
- else echo runtest ; fi`
-
-PTY_TYPE = @PTY_TYPE@
-PTY = pty_$(PTY_TYPE)
-CFILES = exp_command.c expect.c $(PTY).c \
- exp_inter.c exp_regexp.c exp_tty.c \
- exp_log.c exp_main_sub.c exp_pty.c \
- exp_printify.c exp_trap.c exp_strf.c \
- exp_console.c exp_glob.c exp_win.c Dbg.c exp_clib.c \
- exp_closetcl.c exp_memmove.c exp_tty_comm.c \
- exp_$(EVENT_TYPE).c exp_$(EVENT_ABLE).c \
- tcl_regexp.c tclParse-compat.c
-OFILES = exp_command.o expect.o $(PTY).o exp_inter.o exp_regexp.o exp_tty.o \
- exp_log.o exp_main_sub.o exp_pty.o exp_printify.o exp_trap.o \
- exp_console.o exp_strf.o exp_glob.o exp_win.o Dbg.o exp_clib.o \
- exp_closetcl.o exp_memmove.o exp_tty_comm.o \
- exp_$(EVENT_TYPE).o exp_$(EVENT_ABLE).o \
- tcl_regexp.o tclParse-compat.o
-SHARED_OFILES = shared/exp_command.o shared/expect.o shared/$(PTY).o \
- shared/exp_inter.o shared/exp_regexp.o shared/exp_tty.o \
- shared/exp_log.o shared/exp_main_sub.o shared/exp_pty.o \
- shared/exp_printify.o shared/exp_trap.o \
- shared/exp_console.o shared/exp_strf.o shared/exp_glob.o \
- shared/exp_win.o shared/Dbg.o shared/exp_clib.o \
- shared/exp_closetcl.o shared/exp_memmove.o shared/exp_tty_comm.o \
- shared/exp_$(EVENT_TYPE).o shared/exp_$(EVENT_ABLE).o
-
-# Expect libraries (both .a and shared)
-EXP_LIB_FILES = @EXP_LIB_FILES@
-# default Expect library (shared if possible, otherwise static)
-EXP_LIB_FILE = @EXP_LIB_FILE@
-# Expect object library (.a)
-EXP_UNSHARED_LIB_FILE = @EXP_UNSHARED_LIB_FILE@
-# Expect object library (shared, if possible)
-EXP_SHARED_LIB_FILE = @EXP_SHARED_LIB_FILE@
-
-# expect must be setuid on crays in order to open ptys (and accordingly,
-# you must run this Makefile as root).
-# See the FAQ for more info on why this is necessary on Crays.
-SETUID = @SETUID@
-# SETUID = chmod u+s
-
-# allow us to handle null list gracefully, "end_of_list" should not exist
-SCRIPT_LIST = $(SCRIPTS) end_of_list
-SCRIPT_MANPAGE_LIST = $(SCRIPTS_MANPAGES) end_of_list
-
-# flags to pass only to the C compiler (not to ld)
-# because STTY can include whitespace and quotes, pass STTY separately
-CPPFLAGS = -I. -I$(srcdir) $(TCLHDIRDASHI) $(TKHDIRDASHI) $(X11_CFLAGS) \
- -DEXP_VERSION=\"$(VERSION)\" \
- -DSCRIPTDIR=\"$(SCRIPTDIR)\" \
- -DEXECSCRIPTDIR=\"$(EXECSCRIPTDIR)\" \
- -DTCL_DEBUGGER
-
-# Flags to pass to cc (i.e. add to the end of the CLDFLAGS line below).
-# Note that setting one will not set others automatically. Set all that
-# are relevant.
-#
-# NOTE THAT THESE FLAGS ARE NO LONGER SUPPORTED. THE FUNCTIONALLY IS REPLACED
-# BY THE AUTOMATIC CONFIGURATION CODE. ONLY MESS WITH THE FOLLOWING DEFS IF
-# YOU ARE POSITIVE THE AUTO CONFIG CODE IS FAILING.
-#
-# -DSYSV3 if you are running SVR3 or later.
-# -DSYSV4 if you are running SVR4. This option does not preclude -DSYSV3.
-# -DAUX2 if you are running Mac A/UX 2.
-# -DMIPS_BSD if you are on a Mips machine using the BSD universe.
-# -D_BSD_SIGNALS if you are on a Silicon Graphics AND want BSD semantics when
-# using the expect library. Otherwise, you are better off just sticking
-# with rearming signals.
-
-# Flags to pass to ld
-# You may need to add additional ones to the end of the LIBS line below:
-# -lc -lBSD If you are using the BSD compatibility library on an HP/UX,
-# force libc.a to be loaded first.
-# -lsocket For SCO UNIX 3.2.2 (this should now be done automatically)
-# -lX11 For Pyramid OSx, poll is broken, so use select from X lib
-# /usr/ucblib/libucb.a is needed for solaris 2.0 after -lm
-EXP_AND_TCL_LIBS = $(LDFLAGS) @EXP_AND_TCL_LIBS@
-EXP_AND_TK_LIBS = $(LDFLAGS) @EXP_AND_TK_LIBS@
-
-CFLAGS_INT = $(MH_CFLAGS) $(CPPFLAGS) $(XCFLAGS)
-
-LIB_INSTALL_DIR = $(tcl_libdir)
-LIB_RUNTIME_DIR = $(tcl_libdir)
-# I don't understand why Tcl splits these up, but it does. LIB_RUNTIME_DIR
-# can appear as part of the LD_SEARCH_FLAGS inherited by configure.
-
-.c.o:
- $(CC) -c $(CFLAGS_INT) $(STTY) $(HDEFS) $<
- if [ "@EXP_SHLIB_CFLAGS@" != "x" ] ; then \
- if [ ! -d shared ] ; then \
- mkdir shared ; \
- else true; fi ; \
- $(CC) -c $(CFLAGS_INT) @EXP_SHLIB_CFLAGS@ $(STTY) $(HDEFS) $< -o shared/$@ ; \
- fi
-
-
-all: expect$(EXEEXT) $(EXP_LIB_FILES) ${X11_PROGS}
- @$(MAKE) subdir_do DO=$@ $(FLAGS_TO_PASS)
-
-info:
-dvi:
-
-# CYGNUS LOCAL aoliva
-LOCAL_EXPECT=$(SHELL) ./expect-bld.sh
-all: expect-bld.sh
-# Run expect within the build tree
-expect-bld.sh: Makefile
- -rm -f $@ $@T
- echo "#! $(SHELL)" > $@T
- r=`pwd`; for var in LD_LIBRARY_PATH SHLIB_PATH ; do \
- echo "$$var=$$r:$$r/../tk/unix:$$r/../tcl/unix\$${$$var+:\$$$$var}; export $$var" >> $@T ; \
- done; echo "exec $$r/expect \$${1+\"\$$@\"}" >> $@T
- chmod +x $@T
- mv $@T $@
-# END CYGNUS LOCAL
-
-# build expect binary that does not depend on Expect's shared libs
-expect$(EXEEXT): exp_main_exp.o $(EXP_UNSHARED_LIB_FILE)
- $(CC) $(XCFLAGS) @TCL_LD_FLAGS@ -o expect$(EXEEXT) exp_main_exp.o @EXP_BUILD_LIB_SPEC@ $(TCLLIB) $(EXP_AND_TCL_LIBS)
- $(SETUID) expect$(EXEEXT)
-
-expecti$(EXEEXT): exp_main_exp.c $(EXP_UNSHARED_LIB_FILE)
- $(CC) $(CFLAGS_INT) $(STTY) $(HDEFS) $(ITCLHDIR) $(XCFLAGS) @TCL_LD_FLAGS@ -o expecti$(EXEEXT) -DUSE_ITCL $(srcdir)/exp_main_exp.c @EXP_BUILD_LIB_SPEC@ $(TCLLIB) $(ITCLLIB) $(EXP_AND_TCL_LIBS)
-
-# install Expect library
-# This is done before the install target because the libraries have to be
-# in place before the installed expect is built. Actually, only the shared
-# lib has to be handled this way, but do both here for consistency.
-# Can't seem to embed shell comments in backslashed lines, so comments here:
-# - To allow bare "load" commands, install shared libs in tcl_libdir rather
-# than Expect's lib-specific directory (libdir).
-# - install hand-generated pkgIndex.tcl file.
-# Local copy is pkgIndex rather than pkgIndex.tcl because pkgIndex.tcl.in
-# is too long for some filesystems, sigh.
-install_shared_lib: $(EXP_LIB_FILES)
- ${srcdir}/mkinstalldirs $(libdir)
- if [ -s $(EXP_UNSHARED_LIB_FILE) ] ; then \
- $(INSTALL_DATA) $(EXP_UNSHARED_LIB_FILE) $(libdir)/$(EXP_UNSHARED_LIB_FILE) ; \
- $(UNSHARED_RANLIB) $(libdir)/$(EXP_UNSHARED_LIB_FILE) ; \
- $(INSTALL_DATA) $(EXP_UNSHARED_LIB_FILE) $(tcl_libdir)/$(EXP_UNSHARED_LIB_FILE) ; \
- $(UNSHARED_RANLIB) $(tcl_libdir)/$(EXP_UNSHARED_LIB_FILE) ; \
- else true; fi
- if [ -s $(EXP_SHARED_LIB_FILE) ] ; then \
- $(INSTALL_PROGRAM) $(EXP_SHARED_LIB_FILE) $(tcl_libdir)/$(EXP_SHARED_LIB_FILE) ; \
- $(INSTALL_PROGRAM) pkgIndex $(libdir)/pkgIndex.tcl ; \
- else true; fi
-
-expect_installed$(EXEEXT): exp_main_exp.o $(EXP_LIB_FILE) install_shared_lib
- $(CC) $(XCFLAGS) @EXP_SHLIB_CFLAGS@ @TCL_LD_FLAGS@ -o expect_installed$(EXEEXT) exp_main_exp.o @EXP_LIB_SPEC@ $(TCLLIB_INSTALLED) $(EXP_AND_TCL_LIBS)
- $(SETUID) expect_installed$(EXEEXT)
-
-# Build Expect with TestCenter
-expect.tc$(EXEEXT): exp_main_exp.o $(OFILES)
- proof $(CC) $(XCFLAGS) @EXP_SHLIB_CFLAGS@ @TCL_LD_FLAGS@ -o expect.tc$(EXEEXT) $(OFILES) exp_main_exp.o $(TCLLIB) $(EXP_AND_TCL_LIBS)
- $(SETUID) expect.tc$(EXEEXT)
-
-# Build an executable with both Expect and Tk.
-# Yes, I know that the link line can have libraries repeated. This is a
-# consequence of Tcl's configure combining the Tcl and X dependent libs
-# together. I could fix it by testing all the libraries (again, in Expect's
-# configure) separately for Expectk, but as far as I know, it doesn't hurt
-# anything here, so I'm not worrying about it.
-expectk$(EXEEXT): exp_main_tk.o $(EXP_UNSHARED_LIB_FILE)
- $(CC) $(XCFLAGS) @TCL_LD_FLAGS@ -o expectk$(EXEEXT) exp_main_tk.o @EXP_UNSHARED_LIB_SPEC@ $(TKLIB) $(TCLLIB) $(X11_LD_FLAGS) $(EXP_AND_TK_LIBS)
- $(SETUID) expectk$(EXEEXT)
-
-expectk_installed$(EXEEXT): exp_main_tk.o $(EXP_LIB_FILE)
- $(CC) $(XCFLAGS) @EXP_SHLIB_CFLAGS@ @TCL_LD_FLAGS@ -o expectk_installed$(EXEEXT) exp_main_tk.o @EXP_LIB_SPEC@ $(TKLIB_INSTALLED) $(TCLLIB_INSTALLED) $(X11_LD_FLAGS) $(EXP_AND_TK_LIBS)
- $(SETUID) expectk_installed$(EXEEXT)
-
-# Build Expectk with TestCenter
-expectk.tc$(EXEEXT): exp_main_tk.o $(OFILES)
- proof $(CC) $(XCFLAGS) @TCL_LD_FLAGS@ -o expectk.tc$(EXEEXT) $(OFILES) exp_main_tk.o $(TKLIB) $(TCLLIB) $(X11_LD_FLAGS) $(EXP_AND_TK_LIBS)
- $(SETUID) expectk.tc$(EXEEXT)
-
-$(EXP_UNSHARED_LIB_FILE): $(OFILES)
- -rm -f $(EXP_UNSHARED_LIB_FILE)
- $(AR) $(ARFLAGS) $(EXP_UNSHARED_LIB_FILE) $(OFILES)
- -$(RANLIB) $(EXP_UNSHARED_LIB_FILE)
-
-# the dependency should really be SHARED_OFILES rather than OFILES
-# but there's no way to write a rule that says shared/XYZ.o should
-# depend on XYZ.c in a different directory (except by writing the
-# rule out for each file, sigh).
-$(EXP_SHARED_LIB_FILE): $(OFILES)
- -rm -f $(EXP_SHARED_LIB_FILE)
- @TCL_SHLIB_LD@ -o $(EXP_SHARED_LIB_FILE) $(SHARED_OFILES) @EXP_LD_SEARCH_FLAGS@ @EXP_SHLIB_LD_LIBS@
-
-.PHONY: install-info install info
-install-info:
-
-# CYGNUS LOCAL: minimal/angela
-install-minimal: expect$(EXEEXT) pkgIndex
- ${srcdir}/mkinstalldirs $(man1dir) $(bindir)
-# install Expect
- $(INSTALL_PROGRAM) expect$(EXEEXT) $(bindir)/expect$(EXEEXT)
-# install Expect man page
- $(INSTALL_DATA) $(srcdir)/expect.man $(man1dir)/expect.1
-# END CYGNUS LOCAL
-
-install: expect$(EXEEXT) expect_installed$(EXEEXT) ${X11_PROGS_INSTALLED} pkgIndex install_shared_lib
- ${srcdir}/mkinstalldirs $(man1dir) $(man3dir) $(bindir) $(libdir) $(includedir)
-# install Expect
- $(INSTALL_PROGRAM) expect_installed$(EXEEXT) $(bindir)/expect$(EXEEXT)
-# install Expectk (and man page) if present
- -if [ -s expectk_installed$(EXEEXT) ] ; then \
- $(INSTALL_PROGRAM) expectk_installed$(EXEEXT) $(bindir)/expectk$(EXEEXT) ; \
- $(INSTALL_DATA) $(srcdir)/expectk.man $(man1dir)/expectk.1 ; \
- else true; fi
-# install Expect man page
- $(INSTALL_DATA) $(srcdir)/expect.man $(man1dir)/expect.1
-# install man page for Expect and Expectk libraries
- $(INSTALL_DATA) $(srcdir)/libexpect.man $(man3dir)/libexpect.3
-# install Expect's public include files
-# $(INSTALL_DATA) expect_cf.h $(includedir)
- $(INSTALL_DATA) $(srcdir)/expect.h $(includedir)
- $(INSTALL_DATA) $(srcdir)/expect_tcl.h $(includedir)
- $(INSTALL_DATA) $(srcdir)/expect_comm.h $(includedir)
-# force installation of Tcl's private regexp definition - we simply have to
-# make it public in order for people to use Expect's C lib.
- $(INSTALL_DATA) $(TCLHDIR)/tclRegexp.h $(includedir)
-# install Debugger's public include file (just in case it's not there)
- $(INSTALL_DATA) $(srcdir)/Dbg.h $(includedir)
-
-install-scripts: $(SCRIPTS)
-# some people don't install Tcl, sigh
- TCL_LIBRARY=$(TCL_LIBRARY) ; \
- export TCL_LIBRARY ; \
- if $(LOCAL_EXPECT) $(srcdir)/fixcat ; then \
- $(INSTALL_DATA) $(srcdir)/fixcat $(EXECSCRIPTDIR)/cat-buffers ; \
- else true; fi
-# install standalone scripts and their man pages, if requested
- ${srcdir}/mkinstalldirs $(bindir_arch_indep) $(man1dir) $(SCRIPTDIR) $(EXECSCRIPTDIR)
- -for i in $(SCRIPT_LIST) ; do \
- if [ -f $$i ] ; then \
- $(INSTALL_PROGRAM) $$i $(bindir_arch_indep)/$$i ; \
- rm -f $$i ; \
- else true; fi ; \
- done
- -for i in $(SCRIPT_MANPAGE_LIST) ; do \
- if [ -f $(srcdir)/example/$$i.man ] ; then \
- $(INSTALL_DATA) $(srcdir)/example/$$i.man $(man1dir)/$$i.1 ; \
- else true; fi ; \
- done
- $(INSTALL_DATA) pkgIndex.tcl $(SCRIPTDIR)
-
-$(SCRIPT_LIST):
- TCL_LIBRARY=$(TCL_LIBRARY) ; \
- export TCL_LIBRARY ; \
- $(LOCAL_EXPECT) $(srcdir)/fixline1 $(SHORT_BINDIR) < $(srcdir)/example/$@ > $@
-
-# Delete all the installed files that the `install' target creates
-# (but not the noninstalled files such as `make all' creates)
-uninstall:
- -rm -f $(bindir)/expectk \
- $(man1dir)/expect.1 \
- $(man1dir)/expectk.1 \
- $(libdir)/$(EXP_SHARED_LIB_FILE) \
- $(tcl_libdir)/$(EXP_SHARED_LIB_FILE) \
- $(libdir)/$(EXP_UNSHARED_LIB_FILE) \
- $(tcl_libdir)/$(EXP_UNSHARED_LIB_FILE) \
- $(man3dir)/libexpect.3 \
- $(includedir)/expect_cf.h \
- $(includedir)/expect.h \
- $(includedir)/expect_tcl.h \
- $(includedir)/expect_comm.h \
- $(EXECSCRIPTDIR)/cat-buffers
-# debugger is not removed, since other things could depend on it
-# remove standalone scripts and man pages
- -for i in $(SCRIPT_LIST) ; do \
- rm -f $(bindir_arch_indep)/$$i ; \
- done
- -for i in $(SCRIPT_MANPAGE_LIST) ; do \
- rm -f $(man1dir)/$$i.1 ; \
- done
-
-###################################
-# Targets for Makefile and configure
-###################################
-
-Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) config.status
- @echo "Rebuilding the Makefile..."
- $(SHELL) ./config.status
-
-# CYGNUS LOCAL: Don't have dependancies, cause people get upset
-# when autoconf gets run automatically.
-#configure: $(srcdir)/configure.in $(srcdir)/Makefile.in \
-# $(srcdir)/expect_cf.h.in $(srcdir)/aclocal.m4
-# Let "make -f Makefile.in" produce a configure file
-configure:
- @echo "Rebuilding configure..."
- if [ x"${srcdir}" = x"@srcdir@" ] ; then \
- srcdir=. ; export srcdir ; \
- else true ; fi ; \
- (cd $${srcdir}; autoconf)
-
-config.status: $(srcdir)/configure
- @echo "Rebuilding config.status..."
- $(SHELL) ./config.status --recheck
-
-check:
- @if [ -f testsuite/Makefile ]; then \
- cd testsuite && $(MAKE) $(FLAGS_TO_PASS) check; \
- else true; fi
-
-# Original Dbgconfig.in comes from the NIST Tcl debugger distribution.
-# CYGNUS LOCAL: Don't have dependancies, cause people get upset
-# when autoconf gets run automatically.
-#Dbgconfigure: $(srcdir)/Dbgconfig.in $(srcdir)/Makefile.in \
-# $(srcdir)/Dbg_cf.h.in $(srcdir)/aclocal.m4
-Dbgconfigure:
- @echo "Rebuilding Dbgconfigure..."
- @if [ x"${srcdir}" = x"@srcdir@" ] ; then \
- srcdir=. ; export srcdir ; \
- else true ; fi ; \
- (cd $${srcdir}; rm -fr Dbgconfigure ; \
- autoconf Dbgconfig.in > Dbgconfigure ; \
- chmod a+x Dbgconfigure)
-
-################################################
-# Various "clean" targets follow GNU conventions
-################################################
-
-# delete all files from current directory that are created by "make"
-clean:
- -rm -rf *~ *.o shared core \
- expect$(EXEEXT) expect_installed$(EXEEXT) \
- expecti$(EXEEXT) expecti_installed$(EXEEXT) \
- expectk$(EXEEXT) expectk_installed$(EXEEXT) \
- dumb exho devtty \
- $(EXP_UNSHARED_LIB_FILE) $(EXP_SHARED_LIB_FILE) \
- $(SCRIPT_LIST)
- @$(MAKE) subdir_do DO=$@ $(FLAGS_TO_PASS)
-
-# like "clean", but also delete files created by "configure"
-distclean: clean
- @$(MAKE) subdir_do DO=$@ $(FLAGS_TO_PASS)
- -rm -f Makefile config.status config.cache config.log expect_cf.h
- -rm -f Dbg_cf.h
-
-# like "clean", but doesn't delete test utilities or massaged scripts
-# because most people don't have to worry about them
-mostlyclean:
- -rm -f *~ *.o shared core \
- expect$(EXEEXT) expect_installed$(EXEEXT) \
- expecti$(EXEEXT) expecti_installed$(EXEEXT) \
- expectk$(EXEEXT) expectk_installed$(EXEEXT) \
- $(EXP_UNSHARED_LIB_FILE) $(EXP_SHARED_LIB_FILE)
- @$(MAKE) subdir_do DO=$@ $(FLAGS_TO_PASS)
-
-# delete everything from current directory that can be reconstructed
-# except for configure
-realclean: distclean
-
-##################################
-# Targets for development at NIST
-##################################
-
-# the unsets allow calling this via Makefile.in
-
-nist:
- unset CC ; \
- configure --verbose --prefix=/depot/tcl --exec-prefix=/depot/tcl/arch
-
-epg:
- unset CC ; \
- echo configure --verbose --prefix=/home/libes --exec-prefix=/home/libes/arch
-
-mink:
- unset CC ; \
- configure --verbose --prefix=/usr/tmp --exec-prefix=/usr/tmp/arch
-
-cam:
- unset CC ; \
- configure --verbose --prefix=/tmp_mnt/home/fs1a/libes \
- --exec-prefix=/tmp_mnt/home/fs1a/libes/arch
-
-granta:
- unset CC ; \
- configure --verbose --prefix=/home/nist/libes/cray --exec-prefix=/home/nist/libes/cray/arch
-
-
-hudson:
- unset CC ; \
- configure --verbose --prefix=/granta/home/nist/libes/ibm --exec-prefix=/granta /home/nist/libes/ibm/arch
-
-# report globals that shouldn't be public but are
-bad_globals:
- nm $(EXP_UNSHARED_LIB_FILE) | egrep -v " [a-zU] | _exp| _Exp| _Dbg"
-
-LINTFLAGS = -h -q -x
-
-lint:
- lint $(LINTFLAGS) $(CPPFLAGS) $(STTY) $(CFILES) exp_main_exp.c $(TCLLINTLIB) | tee expect.lint
-
-# after copying source directory, reestablish all links
-symlink:
- rm -rf Dbg* e ek testsuite/aclocal.m4
- ln -s ../tcl-debug/configure.in Dbgconfig.in
- ln -s ../tcl-debug/Makefile.in DbgMkfl.in
- ln -s ../tcl-debug/Dbg_cf.h.in
- ln -s ../tcl-debug/Dbg.h
- ln -s ../tcl-debug/Dbg.c
- ln -s ../aclocal.m4 testsuite
-
-#########################################
-# Targets for building with CodeCenter
-#########################################
-
-GCCROOT = /depot/gnu/arch/lib/gcc-lib/sparc-sun-sunos4.1/2.3.3
-GCCLIB = $(GCCROOT)/libgcc.a
-GCCINC = -I$(GCCROOT)/include
-# following only on Sparcs
-SABERDEFINE = -D__sparc__
-
-# Following target builds expect under CodeCenter.
-# If using ObjectCenter, before loading, type: setopt primary_language C
-exp: $(CFILES) exp_main_exp.c
- #load $(CPPFLAGS) $(STTY) $(CFILES) exp_main_exp.c $(TCLLIB) $(GCCLIB) $(EXP_AND_TCL_LIBS)
-
-# Following target builds expectk under CodeCenter. Notes:
-# Because of explicit #includes of <X11/...> in tk.h, you need to create
-# a symlink from your X11 include directory to this directory
-tk: $(CFILES) exp_main_tk.c
- #load $(CPPFLAGS) $(STTY) $(CFILES) exp_main_tk.c $(TKLIB) $(TCLLIB) $(EXP_AND_TK_LIBS)
-
-# Follow definitions are for building expect and expectk under ObjectCenter
-oexp: $(CFILES) exp_main_exp.c
- #load $(CPPFLAGS) $(STTY) -C $(CFILES) exp_main_exp.c $(TCLLIB)
-
-otk: $(CFILES) exp_main_tk.c
- #load $(CPPFLAGS) $(STTY) -C $(CFILES) exp_main_tk.c $(TKLIB) $(TCLLIB) $(EXP_AND_TK_LIBS)
-######################################
-# Targets for pushing out releases
-######################################
-
-# until we are completely switched over, keep updating old ftp site too
-OLDFTPDIR = /proj/elib/online/pub/expect
-FTPDIR = /proj/itl/www/div826/subject/expect
-
-# make a private tar file for myself
-tar: expect-$(VERSION).tar
- mv expect-$(VERSION).tar expect.tar
-
-# make a release and install it on ftp server
-ftp: expect-$(VERSION).tar.Z expect-$(VERSION).tar.gz
- cp expect-$(VERSION).tar.Z $(FTPDIR)/expect.tar.Z
- cp expect-$(VERSION).tar.gz $(FTPDIR)/expect.tar.gz
- cp HISTORY $(FTPDIR)
- cp README $(FTPDIR)/README.distribution
- cp example/README $(FTPDIR)/example
- cp `pubfile example` $(FTPDIR)/example
- rm expect-$(SHORT_VERSION).tar*
- ls -l $(FTPDIR)/expect.tar*
-# update old ftp site too
- cp expect-$(VERSION).tar.Z $(OLDFTPDIR)/expect.tar.Z
- cp expect-$(VERSION).tar.gz $(OLDFTPDIR)/expect.tar.gz
- cp HISTORY $(OLDFTPDIR)
- cp README $(OLDFTPDIR)/README.distribution
- cp example/README $(OLDFTPDIR)/example
- cp `pubfile example` $(OLDFTPDIR)/example
-# delete temp files
- rm expect-$(VERSION).tar*
- ls -l $(OLDFTPDIR)/expect.tar*
-
-# make an alpha relase and install it on ftp server
-alpha: expect-$(VERSION).tar.Z expect-$(VERSION).tar.gz
- cp expect-$(VERSION).tar.Z $(FTPDIR)/alpha.tar.Z
- cp expect-$(VERSION).tar.gz $(FTPDIR)/alpha.tar.gz
- cp HISTORY $(FTPDIR)
- rm expect-$(VERSION).tar*
- ls -l $(FTPDIR)/alpha.tar*
-
-# make a beta relase and install it on ftp server
-beta: expect-$(VERSION).tar.Z expect-$(VERSION).tar.gz
- rm -rf $(FTPDIR)/alpha.tar*
- cp expect-$(VERSION).tar.Z $(FTPDIR)/beta.tar.Z
- cp expect-$(VERSION).tar.gz $(FTPDIR)/beta.tar.gz
- cp HISTORY $(FTPDIR)
- rm expect-$(VERSION).tar*
- ls -l $(FTPDIR)/beta.tar*
-
-expect-$(VERSION).tar: configure
- rm -f ../expect-$(VERSION)
- ln -s `pwd` ../expect-$(VERSION)
- rm -f ../pubfile
- ln pubfile ..
- cd ..;tar cvfh $@ `pubfile expect-$(VERSION)`
- mv ../$@ .
-
-expect-$(VERSION).tar.Z: expect-$(VERSION).tar
- compress -fc expect-$(VERSION).tar > $@
-
-expect-$(VERSION).tar.gz: expect-$(VERSION).tar
- gzip -fc expect-$(VERSION).tar > $@
-
-test: expect
- rm -f .tmp
- echo "set objdir" `pwd` > .tmp
- if [ "$(srcdir)" = "." ] ; then \
- echo "set srcdir" `pwd` >> .tmp ; \
- else echo "set srcdir" $(srcdir) >> .tmp ; fi
- echo "cd \$${srcdir}/tests" >> .tmp
- echo "source all" >> .tmp
- rootme=`pwd`; export rootme; \
- srcdir=${srcdir} ; export srcdir ; \
- if [ -f ./expect ] ; then \
- TCL_LIBRARY=$(TCL_LIBRARY) ; \
- export TCL_LIBRARY ; fi ; \
- $(LOCAL_EXPECT) -f .tmp
- rm -f .tmp
-
-###########################
-# Targets for producing FAQ and homepage
-###########################
-
-#WEBDIR = /proj/elib/online/pub/expect
-WEBDIR = /proj/itl/www/div826/subject/expect
-
-# create the FAQ in html form
-FAQ.html: FAQ.src FAQ.tcl
- FAQ.src html > FAQ.html
-
-# create the FAQ in text form
-FAQ: FAQ.src FAQ.tcl
- FAQ.src text > FAQ
-
-# generate Expect home page
-homepage.html: homepage.src homepage.tcl
- homepage.src > homepage.html
-
-# install various html docs on our web server
-install-html: FAQ.html homepage.html
- cp homepage.html $(WEBDIR)/index.html
- cp FAQ.html $(WEBDIR)
-# cp FAQ.src $(WEBDIR)
-# cp FAQ.tcl $(WEBDIR)
-
-# add recursive support to the build process.
-subdir_do: force
- @for i in $(SUBDIRS); do \
- echo "Making $(DO) in $${i}..." ; \
- if [ -d ./$$i ] ; then \
- if (rootme=`pwd`/ ; export rootme ; \
- rootsrc=`cd $(srcdir); pwd`/ ; export rootsrc ; \
- cd ./$$i; \
- $(MAKE) $(FLAGS_TO_PASS) $(DO)) ; then true ; \
- else exit 1 ; fi ; \
- else true ; fi ; \
- done
-force:
-
-## dependencies will be put after this line... ##
-Dbg.o: $(srcdir)/Dbg.c Dbg.h
-exp_$(EVENT_ABLE).o: $(srcdir)/exp_$(EVENT_ABLE).c expect_cf.h expect.h \
- exp_command.h exp_event.h
-exp_$(EVENT_TYPE).o: $(srcdir)/exp_$(EVENT_TYPE).c expect_cf.h expect.h \
- exp_command.h exp_event.h
-exp_command.o: $(srcdir)/exp_command.c expect_cf.h exp_tty.h \
- exp_rename.h expect.h exp_command.h \
- exp_log.h exp_printify.h exp_event.h exp_pty.h
-exp_inter.o: $(srcdir)/exp_inter.c expect_cf.h \
- exp_tty_in.h exp_tty.h exp_rename.h expect.h exp_command.h \
- exp_log.h exp_printify.h exp_regexp.h exp_tstamp.h
-exp_log.o: $(srcdir)/exp_log.c expect_cf.h expect.h \
- exp_rename.h exp_log.h exp_printify.h
-exp_main_exp.o: $(srcdir)/exp_main_exp.c expect_cf.h \
- expect.h exp_rename.h exp_command.h exp_log.h exp_printify.h
-exp_main_sub.o: $(srcdir)/exp_main_sub.c expect_cf.h \
- exp_rename.h \
- expect.h exp_command.h exp_tty_in.h exp_tty.h exp_log.h \
- exp_printify.h exp_event.h
-#exp_main_tk.o: $(srcdir)/exp_main_tk.c expect_cf.h Dbg.h
-
-exp_main_tk.o: $(srcdir)/exp_main_tk.c expect_cf.h Dbg.h
- $(CC) -c @TK_DEFS@ $(CFLAGS_INT) $(HDEFS) $<
-shared/exp_main_tk.o: $(srcdir)/exp_main_tk.c expect_cf.h Dbg.h
- $(CC) -c @TK_DEFS@ $(CFLAGS_INT) $(HDEFS) $<
-exp_noevent.o: $(srcdir)/exp_noevent.c expect_cf.h exp_prog.h exp_command.h \
- exp_event.h
-exp_poll.o: $(srcdir)/exp_poll.c expect_cf.h expect.h \
- exp_command.h exp_event.h
- $(CC) -c $(CFLAGS_INT) @TCL_DEFS@ $(HDEFS) $<
-shared/exp_poll.o: $(srcdir)/exp_poll.c expect_cf.h expect.h \
- exp_command.h exp_event.h
- $(CC) -c $(CFLAGS_INT) @EXP_SHLIB_CFLAGS@ @TCL_DEFS@ $(HDEFS) $< -o shared/$@
-exp_printify.o: $(srcdir)/exp_printify.c expect_cf.h
-exp_pty.o: $(srcdir)/exp_pty.c expect_cf.h exp_rename.h exp_pty.h
-exp_regexp.o: $(srcdir)/exp_regexp.c expect_cf.h \
- expect.h exp_regexp.h
-exp_select.o: $(srcdir)/exp_select.c expect_cf.h \
- expect.h exp_command.h exp_event.h
-exp_simple.o: $(srcdir)/exp_simple.c expect_cf.h \
- expect.h exp_command.h exp_event.h
-exp_strf.o: $(srcdir)/exp_strf.c
-exp_trap.o: $(srcdir)/exp_trap.c expect_cf.h expect.h \
- exp_command.h exp_log.h exp_printify.h
-exp_tty.o: $(srcdir)/exp_tty.c expect_cf.h \
- expect.h exp_rename.h exp_tty_in.h exp_tty.h exp_log.h \
- exp_printify.h exp_command.h
-exp_win.o: $(srcdir)/exp_win.c exp_win.h
-expect.o: $(srcdir)/expect.c expect_cf.h \
- exp_rename.h expect.h exp_command.h \
- exp_log.h exp_printify.h exp_event.h exp_tty.h exp_tstamp.h
-lib_exp.o: $(srcdir)/lib_exp.c expect_cf.h exp_rename.h expect.h \
- exp_printify.h
-pty_sgttyb.o: $(srcdir)/pty_sgttyb.c expect_cf.h exp_rename.h exp_tty_in.h \
- exp_tty.h exp_pty.h
-pty_termios.o: $(srcdir)/pty_termios.c expect_cf.h exp_win.h \
- exp_tty_in.h exp_tty.h exp_rename.h exp_pty.h
-pty_unicos.o: $(srcdir)/pty_unicos.c expect_cf.h exp_rename.h
-tcl_regexp.o: $(srcdir)/tcl_regexp.c
- $(CC) -c $(CFLAGS_INT) @TCL_DEFS@ $(HDEFS) $<
-shared/tcl_regexp.o: $(srcdir)/tcl_regexp.c
- $(CC) -c $(CFLAGS_INT) @EXP_SHLIB_CFLAGS@ @TCL_DEFS@ $(HDEFS) $< -o shared/$@
-
+++ /dev/null
-This file is the NEWS file from the Expect distribution.
-
-======================================================================
-======================================================================
-
-Date: 8/18/96
-
-Expect now works with Tcl 8.0.
-
-No changes were made to take advantage of 8.0 features such as
-namespaces. (If you want to put the Expect commands in a namespace,
-declare a namespace before loading them in.)
-
-Even thought Tcl allows embedded nulls in commands, Expect still does
-not. Tcl still doesn't support embedded in patterns and regexps.
-I'll wait til Tcl supports that before rewriting Expect's null
-support.
-
-
-======================================================================
-======================================================================
-
-Date: 9/28/96
-
-There is now an Expect FAQ and home page. Feedback is encouraged.
-You can get to the FAQ from the home page and vice versa, so you only
-need to remember one of the links, but here are both for completeness:
-
-home page: http://expect.nist.gov
-FAQ: http://expect.nist.gov/FAQ.html
-
-
-
-======================================================================
-======================================================================
-This section describes the changes to Expect 5, many due to changes
-from Tcl 7.4 to 7.5.
-
-Improvements
-==============================
-
-You can now use expect_background from Tcl along with all the
-Tcl-based event stuff such as "after". You can also do fun things
-such as have "after" actions run while expect is waiting for input.
-It's worth comparing the difference between commands such as expect
-(which waits in the event loop) and gets (which doesn't).
-
-Incompatibilities
-==============================
-
-libexpectk is gone. Because of the event loop was moved into Tcl,
-this is no longer necessary. Just use the regular Expect library.
-This only affects you if are hand-linking.
-
-The name of the static C library now has the extension on the end -
-just like Tcl. This only affects you if are hand-linking.
-
-
-==============================
-Some obvious questions and answers
-
-Nothing in the user interface has changed. All your old scripts
-should run. Tcl now has commands that replace Expect functionality in
-the area of version control and date handling. I encourage you to use
-Tcl's support rather than Expect's for any new scripts that you write.
-However, I won't be removing Expect's commands, so don't worry about
-having to convert old scripts.
-
-It is my understand that shared/dl libs work. (I say "it is my
-understanding", because my own environment doesn't handle it, sigh.
-My system admins tell me that they're working on it.) So I've had to
-guess on some things - in fact, I've talked to a number of people and
-I get the feeling that a lot of people are guessing on shared/dl libs.
-I have yet to talk to anyone that REALLY understands this stuff (by
-"understand", I mean "can write the configure/Makefile portably and
-correctly". So much for my griping. In theory, the shared/dl support
-is pretty much a freebie because Tcl itself provides all the support
-for this. (There is some reorganization that could be done to improve
-shared library memory use - I'll get to it eventually - it shouldn't
-affect most people.) Don't send me complaints about shared/dl libs
-unless you are *positive* it is something that I am responsible for.
-Even if Tcl works and Expect fails, it is likely to be a Tcl error (or
-more precisely, a configuration problem that is more appropriately
-fixed from the Tcl distribution).
-
-For Tcl-package purposes, Expect is called "Expect". (Duh...)
-
-Expect's multiple interpreter support is minimal. It should work for
-most things, serendipitously. I haven't spent any time making this
-perfect.
-
-No, this release isn't portable to Windows or Mac. Let me know if
-you're seriously interested in a lot of work. I'm not saying it's not
-possible. It's definitely possible and the porting working at Sun has
-made it easier than before. But it's still not a weekend hack.
-
-Industrial support for the NT port, would be very helpful. If you are
-interested, either as a student or an industrial sponsor, let me know.
-
-==============================
-Building the code
-==============================
-
-Expect builds as usual. (See the INSTALL file for details.)
-
-The only significant change is that Expect now has to find the
-tclConfig.sh file (and tkConfig.sh if you want). So if you like to
-store Tcl where Expect can't find it, you'll need to use even more
-configure flags than you used to.
-
-Shared/dl Expect libraries are built if you configured Tcl for
-shared/dl libraries.
-
-All support for earlier versions of Tcl and Tk have been removed from
-Expect. For example, if you're still using Tcl 7.4 (or earlier),
-don't bother to install this release.
-
-======================================================================
-======================================================================
-This section describes the changes from Expect 4 to Expect 5.
-
-The changes that people will find most interesting or annoying are as
-follows. Some of them may seem rather arbitrary but fix inconsistencies
-leading to much cleaner coding both internally and externally.
-
-
--- Expect version 5.20 and above is designed to work with Tcl 7.5 and
-Tk 4.1. Expect 5.20 and above will not work with earlier versions.
-
--- Glob-style patterns do longest-possible matches (from the earliest
-possible position) just like regexps. Previously, they matched the
-shortest-possible strings. However, the documentation didn't actually
-say this (it didn't say anything)
-
--- Exact patterns are now supported from expect. Use the "-ex" flag.
-Exact patterns work just like those in interact. No special handling
-is made of *, ^, etc.
-
--- The new command "expect_background" registers patterns that are to
-be tested against spawned process output whenever it appears (i.e.,
-asynchronously). This only works in the Tk environment. The
-arguments are the same as the expect command.
-
--- expect_before and expect_after now handle their arguments like
-expect_background. Previously, a command such as "expect_before"
-with no arguments deleted patterns for all spawn ids. Now, it only
-deletes patterns for the current spawn id. Similarly with the "-i"
-form.
-
--- expect_background/before/after support an -info flag to query what
-the current patterns are. The results are returned in such a way that
-they can be re-used by a new expect command.
-
-The -info flag must be the first flag in the command. With no other
-arguments, it returns the setting for the current spawn id. With a -i
-descriptor, information is returned for that spawn id. The argument
--noindirect may be used to suppress indirects which also match a
-direct spawn id. Only a single -i specification may be given with
--info. With the argument "-all", all spawn id specifications are
-reported.
-
--- There is now a sleep command. It understands decimal values such as
-
- sleep .5
-
-Interrupts and other asynchronous events are processed while Expect sleeps.
-
--- Traps now use Tcl's "Async" support. This has advantages and
-disadvantages. One advantage is that traps have no chance of screwing
-up the Tcl internals. One disadvantage is that trap handlers are
-delayed at certain specific times and places. For example, a handler
-cannot occur inside another handler. While one handler is running,
-all other handlers are blocked. This is probably the most noticable
-place where handlers are blocked. Others are generally small windows,
-so you shouldn't notice the delay in executing the handlers.
-
-Several traps are initially defined:
-
- trap exit {SIGINT SIGTERM}
-
-If you use the -D flag to start the debugger, the following trap is
-defined:
-
- trap {exp_debug 1} SIGINT
-
-You can, of course, override these. In particular, if you have your
-own "trap exit SIGINT", this will override the debugger trap. Because
-SIGINT is tied to exit (see above) by default anyway, you should
-remove your own "trap exit SIGINT" unless you specifically do not want
-to be able to get to the debugger by ^C.
-
-If you want to define your own trap on SIGINT but still trap to the
-debugger when it is running, use:
-
- if ![exp_debug] {trap mystuff SIGINT}
-
-Alternatively, you can trap to the debugger using some other signal.
-
-The ONEXIT trap is no longer available. Instead, say "exit -onexit ..."
-
-Traps are now deleted by using the empty ({}) handler. The current
-handler is returned if no action is supplied. With no arguments, trap
-returns the signal number of the trap command currently being executed.
-
--- The wait command now returns a four element list if a valid child
-was waited on.
-Element 1: pid
-Element 2: spawn id
-Element 3: 0 (or -1 if there was an OS error)
-Element 4: status (or errno if element 3 == -1)
-
--- expect and interact notes:
-
-The timeout and eof patterns were initially named "-timeout" and
-"-eof" but have been renamed "timeout" and "eof" to match those of
-expect. The ability to define default timeout/eof actions has been
-removed. (You can do this more easily by grouping spawn ids.)
-
-expect and interact now support a "null" keyword to match an ASCII 0.
-send supports -null and -break keywords.
-
-Since a large number of special keywords have been added to interact,
-a new keyword "-ex" for "exact" was added descriptive of its default
-treatment of patterns. This protects the next token from being
-misinterpreted as a keyword. The expect command provides "-gl" for
-"glob" for analogous reasons.
-
-Any string starting with "-" should be protected by the "-ex" or "-gl"
-flag, even those that are not keywords currently. (All strings
-starting with "-" are reserved for future options.)
-
-String start/end indices are no longer written to expect_out and
-interact_out unless the -indices flag is given.
-
-expect_out(spawn_id) is set to the spawn id associated with the spawn
-id that produced the last output in an expect command. For example,
-you can use this to delete files that have closed, by removing this
-element from an indirect spawn ids spec. The same effect is
-reproducable with interact (and interact_out(spawn_id)) but for
-efficiency reasons, it requires the -iwrite flag before each pattern.
-
-Expect's -i and interact's -i, -u, -input, and -output flags can now
-describe a list of spawn ids. So you can say things like:
-
- interact -input "$id1 $id2 $id3" .... -output "$id1 $id2" ...
-
-In this case, id1, 2, 3 would be sent to id1, and 2.
-
-The spawn id may be given as a global variable name (called an
-"indirect spawn id specification"), in which case, the variable
-contains the list of spawn ids. Whenever the variable is changed, the
-new list of spawn ids is automatically used. This is particularly
-useful with any long running expect command such as expect_before,
-expect_after, expect_background, and interact.
-
-The -update flag was removed. Use indirect spawn ids (see previous
-paragraph).
-
--- interact notes:
-
-Interact now support -input and -output flags that provide very
-flexible means of moving data from/to multiple spawn ids in complex
-ways (but very quickly). It is possible to write most expect loops
-using a simple interact statement. For instance, the three way
-interaction inside kibitz (between two users and a process) is written
-this way:
-
- interact {
- -output $shell
- -input $userin eof { . . . } -output $shell
- -input $shell -output "$user_spawn_id $userout"
- }
-
--- send command notes:
-
-It is possible to send a break by using the "-break" flag.
-
-Any string starting with "-" should be protected by preceding it with
-the "--" flag, even those that are not keywords currently. (All
-strings starting "-" are reserved for future options.)
-
--- The spawn command now takes an "-open" flag which in turns takes a
-Tcl file as an argument. This lets you treat raw devices, files, and
-pipelines as spawned processes without using a pty.
-
-This was actually in Expect 4, but I forgot to document it. Oops!
-
--- The old "debug" command (which describes what Expect is doing
-internally) was renamed "exp_internal". "debug" (and "exp_debug") now
-invoke the interactive debugger.
-
--- The new command "stty" now takes over the job of "system stty". It
-works much better, allowing POSIX-style redirection to affect other
-ttys. It otherwise takes arguments as "system stty" did.
-
--- The "-tcl" option to "return" has gone away. (This was dangerous
-to anyone that actually happened to return the value "-tcl".)
-Instead, use inter_return.
-
--- Added exp_timestamp command to produce very fast timestamps.
-
--- Added exp_pid command to return pid of given spawn id.
-
--- The close command now takes an argument of "-onexec" with a following
-0 or non-zero value. For example, the follow command stops the
-current spawn id from being closed when another process is exec'd or
-spawn'd.
-
- close -onexec 0
-
-While "-onexec 1" returns it to the default condition where it will be
-closed upon exec or spawn.
-
--- log_user now returns previous value. It is acceptable to call now,
-without arguments just to get the value.
-
--- The following forms are deprecated. They will be allowed
-indefinitely but not advertised or supported if they break.
-
- -eof, -timeout in interact (reason: didn't match expect.
- Instead, use eof or timeout.)
-
- -- in expect or interact (reason: no easier to read.
- Instead, use -gl in expect or -ex in interact.)
-
- continue -expect (reason: when mixing in extensions, you have
- to use exp_continue, so -expect becomes irrelevant.
- Instead, use exp_continue.)
-
- getpid (reason: Tcl now supplies same functionality as "pid".
- Instead, use pid.)
-
- expect_version and expect_library (reason: the name implies
- they have something to do with the expect command,
- which they doesn't.
- Instead, use exp_version and exp_library.)
-
- -timestamp for obtaining tm and ctime in expect and interact
- (reason: separate command now exists for this purpose.
- Instead, use exp_timestamp.)
-
- system stty (reason: bad interaction with redirection.
- Instead, use stty.)
-
--- New examples have been added:
-
-"dislocate" lets you disconnect and reconnect to processes.
-
-"tkpasswd" illustrates passwd embedded in a GUI.
-
-They may not be overwhelmingly useful, but run them once to see what
-they do. If you ever need to do anything similar, you can look back
-at them.
-
-"tknewsbiff" pops up a window or plays a audio clip when you have
-unread news.
-
--- Changes to the Expect libraries:
-
-The expect-tcl library (libexpectcl.a) has been integrated with the
-expect library (libexpect.a). So references to libexpectcl.a should
-be removed.
-
-The Expect C library now supports buffering, multiplexing, null
-matching, full buffer matching. Basically, all of the features in
-Expect are now in the library.
-
-Buffering and multiplexing has caused the biggest change to the
-library. Previously, exp_match contained the entire buffer that
-matched. Now exp_match just points to where in the buffer the match
-started. exp_buffer points to the beginning of the buffer.
-Previously, the previous buffer was thrown away at the beginning of
-each expect function call. Now, previously unmatched characters are
-eligible for matching.
-
-To match on different file descriptors, exp_match, exp_match_end,
-exp_buffer_end must be restored to their previous values. Initially,
-they should be zero.
-
-The meaning of timeout == 0 in the Expect library has been changed.
-See the man page for more info.
-
-======================================================================
-======================================================================
-This file describes the changes from Expect 3 to Expect 4.
-
-The improvements that people will find most interesting are:
-
-1) Expect version 4 is designed to work with Tcl 6.7 and Tk 3.2.
- (Earlier versions of Expect will not work with Tcl 6.7)
- Expect can now be layered in with any Tcl program.
- Note that in Tk, Expect's send command is called "exp_send".
- (It used to be called "send_spawn" but this bit the dust.)
-2) A debugger is provided.
-3) The interact command has been totally rewritten and supports regular
- expressions, timeout/eof patterns, and a number of other new things.
-4) The default behavior of ^C (SIGINT) is exit whether or not you are in
- a read.
-5) Expect uses "sane" terminal parameters by default, allowing scripts
- to work the same whether inside emacs shell mode or not. (See man
- page on "spawn" for more info.)
-6) All the hard parts of the installation process are automated. This
- was done primarily by Rob Savoye at Cygnus. Thank you, Rob!
-7) It is now possible to buy a support contract for Expect from Cygnus.
-
-The changes that people will find most annoying are:
-
-1) send now only sends a single string. (It used to send any number of
- strings with spaces jammed in between.)
-2) getpid was renamed pid.
-3) interact's -flush was renamed -nobuffer (much more descriptive).
-4) interact now runs all actions in raw mode unless the flag -reset
- is used. -f and -F are ignored. send automatically understands
- how to do the right thing. The most likely thing to watch out for
- are actions like "exec kill -STOP 0" which almost certainly need
- the -reset flag.
-5) argv0 is initialized to script name. argv no longer contains it.
- argc is initialized [llength $argv]. This follows new Tcl style.
-
-All differences are described in the man page. Some of the less
-significant differences are described in the HISTORY file. The
-debugger is described in a separate document (see the README).
-
-This version also introduces one incompatibility that may require
-changes to scripts. While this may initially annoy you, the final
-result will simplify the process of writing scripts. Namely:
-
-In version 3, the expect command accepted lists of glob-style patterns
-such as:
-
- expect "a\ b c" action
-
-where "a b" or "c" would cause action to be executed. The problem
-with this is that the pattern list is hard to write and hard to read.
-Patterns with control-characters, backslashes and dollar signs were
-very difficult to deal with.
-
-Regular-expression patterns provide a much simpler solution. Via the
-alternation feature (using a "|") the above pattern can be written as:
-
- expect -re "a b|c" action
-
-I was concerned about people having a significant investment in code
-that depended on the old syntax but responders to a comp.lang.tcl poll
-about such a change in pattern handling were 100% in favor of it. (I
-even proposed hooks for backward compatibility, but there was no
-interest in it.)
-
-Fortunately, most simple things will work as before including:
-
- expect foobar
- expect {foobar}
- expect "foobar"
- expect "foo\ bar"
-
-However, some things won't work as before. For example, the following
-will behave differently - now the braces will be considered as part of
-the pattern.
-
- expect "{foo bar}"
-
-Here are examples of patterns in my own code that I had to change:
-
- was changed to
- Version 3 pattern list Version 4 pattern
-
- {Whois:\ } "Whois: "
- {No\ match} "No match"
- {250*ftp>* 200*ftp>*} -re "2(5|0)0.*ftp>.*"
- {{Press Return to continue*}} "Press Return to continue*"
- {*\r\n*\\\\\r\n} "\r\n*\\\r\n"
-
-
-
-Future Change Alert
-
-John Ousterhout has pre-announced a future change in Tcl that may
-affect you. In particular, backslash sequences other than those
-explicitly listed in the Tcl documentation will be handled as if the
-backslash was not present.
-
-The likely place this arises is when quoting characters that are
-special to the pattern matcher but not to Tcl.
-
-For example in Tcl 6.7, the following command matches a period.
-
- expect -re "\."
-
-In Tcl 7.0, it will match any character, because Tcl will throw away
-the backslash. If you want to match a period, you will have to say:
-
- expect -re "\\."
-or
- expect -re {\.}
-
-The following command will find occurrences of this. (It may find
-other things, but it will at least find the problem cases.)
-
- egrep '(\\$)|(\\[^][bfnrtv\0-9{}$ ;"])' *.exp
-
-======================================================================
-======================================================================
-This section describes the changes from Expect 2 to Expect 3.
-
-If you used to use Expect version 2 (any version written before
-September '91) you will find that the current version of Expect (3)
-introduced minor but significant incompatibilities.
-
-The HISTORY file describes these briefly. They are described at
-length in the man page.
-
-I'm sorry if you feel annoyed at the incompatibilities, but Expect has
-been out for a year and a half, Tcl even longer. Both Tcl and Expect
-are using this as a last chance to make significant changes, so that
-we will not disturb even more users in the future.
-
-There is no automated conversion procedure (although see note below)
-for Expect or even raw Tcl. For now, I suggest that you not bother
-fixing things that already work - just keep the old Expect around.
-The binary isn't very big after all. If you do write a translation
-script, let me know. Thanks.
-
-Of course, I felt obligated to convert the examples distributed with
-expect. I did this by hand while writing the new version itself,
-partly as an aid but mostly to test lots of variations. In 90% of the
-scripts, all I had to do was change:
-
-(changes due to Tcl)
- 'index' to 'lindex'
- 'range' to 'lrange'
- 'length' to 'llength'
- 'print' to 'send_user' or 'puts' depending on how you use it
- 'function .... c' with '[join [function [split string ""]] ""]'
-(changes due to Expect)
- 'expect_match' to 'expect_out(buffer)'
- 'set match_max' to 'match_max' (perhaps with -d flag)
- '*' to '-re .+'
-
-If anyone wants to write a script to do this, note the pitfalls:
-
-1) functions and variables do not share the same namespace, so it is a
-inappropriate to just globally rename things.
-
-A number of optimizations can be made:
-
-1) If you are doing multiple split/joins, you should probably cache the
-split string.
-
-2) Virtually all uses of scan are unnecessary now, due to exec's automatic
-stripping of terminating newlines, and expect's support of regexps.
-
-3) String manipulation can be reduced or avoided entirely if you use
-expect -re.
-
-4) exec is no longer necessary to retrieve environment variables, since
-they can now be retrieved from $env.
-
-5) If you have been really anal about testing for timeout and eof, you
-can dramatically reduce the size of your scripts by using expect_before
-and expect_after. This is more efficient, as well, since those actions
-are only parsed once.
-
+++ /dev/null
-NOTE: ALPHA AND BETA RELEASES OF TCL/TK ARE NOT SUPPORTED!
-
---------------------
-Introduction
---------------------
-
-This is the README file for Expect, a program that performs programmed
-dialogue with other interactive programs. It is briefly described by
-its man page, expect(1). This directory contains the source and man
-page for Expect.
-
-This is Expect 5 for Tcl 7.5, 7.6, and 8.0. Tk 4.1, 4.2, 8.0 and the
-Tcl Debugger are also supported. Significant changes and other news
-can be found in the NEWS file.
-
-The Expect home page is: http://expect.nist.gov
-The Expect FAQ is: http://expect.nist.gov/FAQ.html
-
---------------------
-Getting Started - The Preferable Way
---------------------
-
-A book on Expect is available from O'Reilly with the title "Exploring
-Expect: A Tcl-Based Toolkit for Automating Interactive Applications",
-ISBN 1-56592-090-2.
-
-The book is filled with detailed examples and explanations, and is a
-comprehensive tutorial to Expect. The book also includes a tutorial
-on Tcl written specifically for Expect users (so you don't have to
-read the Expect papers, the debugger paper, Ousterhout's book, or the
-man pages). Exploring Expect is 602 pages.
-
---------------------
-Getting Started - The Hacker Way
---------------------
-
-While the book is the best way to learn about Expect, it is not
-absolutely necessary. There are man pages after all and there are
-numerous articles and papers on Expect. All of my own papers are in
-the public domain and can be received free. If you are a hacker on a
-tight budget, this may appeal to you. Nonetheless, I think you will
-find the book pays for itself very quickly. It is much more readable
-than the man pages, it includes well-written and explained examples,
-and it describes everything in the papers as a coherent whole. The
-concepts in the papers actually only make up a small fraction of the
-book.
-
-The 1990 USENIX paper (see "Readings" below) is probably the best one
-for understanding Expect conceptually. The 1991 Computing Systems and
-the LISA IV papers provide a nice mix of examples. The only downside
-is, the examples in these papers don't actually work anymore - some
-aspects (e.g., syntax) of both Expect and Tcl have changed. The
-papers still make interesting reading - just don't study the examples
-too closely! Fortunately, most of the examples from the papers also
-accompany this distribution - and all of these are up to date.
-
-For all the details, read the man page. It is long but you can get
-started just by skimming the sections on the following commands:
-
- spawn (starts a process)
- send (sends to a process)
- expect (waits for output from a process)
- interact (lets you interact with a process)
-
-To print out the Expect man page, invoke your local troff using the
--man macros, such as either of:
-
- ptroff -man expect.man
- ditroff -man expect.man
-
-If Expect is installed, you can read the man pages using the "usual"
-man commands, such as "man expect". If not installed, view the man
-page on your screen by saying something like:
-
- nroff -man expect.man | more
-
-Expect uses Tcl as the underlying language for expressing things such
-as procedures, loops, file I/O, and arithmetic expressions. For many
-simple scripts, it is not necessary to learn about Tcl. Just by
-studying the examples, you will learn enough Tcl to get by. But if
-you would like to learn more about Tcl or use it in your own
-applications, read the Tcl README file which provides pointers to the
-extensive Tcl documentation. Or read Exploring Expect. Chapter 2 of
-Exploring Expect is a Tcl tutorial specifically designed for Expect
-users.
-
-An interactive debugger is bundled with Expect. The debugger has its
-own documentation that comes separately. It is listed in the Readings
-below. Again, it is slightly out of date. An up-to-date description
-of the debugger appears in Chapter 18 of Exploring Expect. This
-chapter also contains additional advice and tips for debugging.
-
-You may get the feeling that the Expect documentation is somewhat
-scattered and disorganized. This was true prior to publication of
-Exploring Expect. The book contains everything you need to know, all
-up-to-date, and with examples of every concept. (The book contains no
-references to any of the Expect papers because none are necessary.)
-
-----------------------
-Examples
-----------------------
-
-This distribution contains many example scripts. (All of the
-substantive examples in the book are included.) They can be found in
-the example directory of this distribution. The README file in that
-directory briefly describes all of the example scripts. Many of the
-more sophisticated examples have man pages of their own.
-
-Other interesting scripts are available separately in the directory
-http://expect.nist.gov/scripts/ (ftpable as
-ftp://ftp.nist.gov/mel/div826/subject/expect/scripts). (See below for
-how to retrieve these.) You are welcome to send me scripts to add to
-this directory. A number of Expect scripts are also available in the
-Tcl archive, available at ftp://ftp.neosoft.com/pub/tcl.
-
---------------------
-Readings on Expect
---------------------
-
-The implementation, philosophy, and design are discussed in "expect:
-Curing Those Uncontrollable Fits of Interaction", Proceedings of the
-Summer 1990 USENIX Conference, Anaheim, CA, June 11-15, 1990.
-
-Examples and discussion, specifically aimed at system administrators,
-are in "Using expect to Automate System Administration Tasks",
-Proceedings of the 1990 USENIX Large Systems Administration Conference
-(LISA) IV, Colorado Springs, CO, October 17-19, 1990.
-
-A comprehensive paper of example scripts is "expect: Scripts for
-Controlling Interactive Programs", Computing Systems, Vol. 4, No. 2,
-University of California Press Journals, 1991.
-
-Regression and conformance testing is discussed in "Regression Testing
-and Conformance Testing Interactive Programs", Proceedings of the
-Summer 1992 USENIX Conference, San Antonio, TX, June 8-12, 1992.
-
-An explanation of some of the more interesting source code to an early
-version of Expect is in Chapter 36 ("Expect") of "Obfuscated C and
-Other Mysteries", John Wiley & Sons, ISBN 0-471-57805-3, January 1993.
-
-A paper on connecting multiple interactive programs together using
-Expect is "Kibitz - Connecting Multiple Interactive Programs
-Together", Software - Practice & Experience, Vol. 23, No. 5, May 1993.
-
-The debugger is discussed in "A Debugger for Tcl Applications",
-Proceedings of the 1993 Tcl/Tk Workshop, Berkeley, CA, June 10-11,
-1993.
-
-Using Expect with Tk is described in the paper "X Wrappers for
-Non-Graphic Interactive Programs", Proceedings of Xhibition '94, San
-Jose, CA, June 20-24, 1994.
-
-Simple techniques to allow secure handling of passwords in background
-processes are covered in "Handling Passwords with Security and
-Reliability in Background Processes", Proceedings of the 1994 USENIX
-LISA VIII Conference, San Diego, CA, September 19-23, 1994.
-
-More publications can be found in the Expect home page (see elsewhere).
-
---------------------
-How to Get the Latest Version of Expect or the Readings
---------------------
-
-Expect may be ftp'd as mel/div826/subject/expect/expect.tar.gz from
-expect.nist.gov. (Yes, the URL is much shorter:
-http://expect.nist.gov/expect.tar.Z) Request email delivery by mailing
-to "library@cme.nist.gov". The contents of the message should be (no
-subject line) "send pub/expect/expect.tar.Z".
-
-Once you have retrieved the system, read the INSTALL file. The papers
-mentioned above can be retrieved separately (from the same directories
-listed above) as:
-
- doc/seminal.ps.Z (USENIX '90 - Intro and Implementation)
- doc/sysadm.ps.Z (LISA '90 - System Administration)
- doc/scripts.ps.Z (Comp. Systems '91 - Overview of Scripts)
- doc/regress.ps.Z (USENIX '92 - Testing)
- doc/kibitz.ps.Z (SP&E '93 - Automating Multiple
- Interactive Programs Simultaneously)
- doc/tcl-debug.ps.Z (Tcl/Tk '93 - Tcl/Tk Debugger)
- doc/expectk.ps.Z (Xhibition '94 - Using Expect with Tk)
- doc/bgpasswd.ps.Z (LISA '94 - Passwds in Background Procs)
- doc/chargraph.ps.Z (SP&E '96 - Testing and Automation
- of Character Graphic Applications)
-
-The book "Exploring Expect" is described in more detail earlier in
-this file.
-
-The book "Obfuscated C and Other Mysteries" is not on-line but is
-available in bookstores or directly from the publisher (Wiley).
-
-Overhead transparencies I've used at conferences are also available in
-the same way as the papers themselves. The transparencies are sketchy
-and not meant for personal education - however if you are familiar
-with Expect and just want to give a short talk on it to your
-colleagues, you may find the transparencies useful. They vary in
-length from 15 to 20 minutes in length. These are:
-
- doc/seminal-talk.ps.Z (USENIX '90 - Intro and Implementation)
- doc/sysadm-talk.ps.Z (LISA '90 - System Administration)
- doc/regress-talk.ps.Z (USENIX '92 - Testing)
- doc/tcl-debug-talk.ps.Z (Tcl/Tk '93 - Tcl/Tk Debugger)
- doc/expectk-talk.ps.Z (Xhibition '94 - Expect + Tk = Expectk)
- doc/bgpasswd-talk.ps.Z (LISA '94 - Passwords in the Background)
-
-All of the documents are compressed PostScript files and should be
-uncompressed and sent to a PostScript printer. The documents are
-intended for printing at 8.5"x11" and may fail on some ISO A4
-printers. According to Hans Mayer <Hans.Mayer@gmd.de>, you can make
-them A4-able by searching for "FMVERSION" and changing the next line
-from:
-
- 1 1 0 0 612 792 0 1 13 FMDOCUMENT
-to:
- 1 1 0 0 594 841 0 1 13 FMDOCUMENT
-
-
---------------------
-Using Expect with and without Tcl and/or Tk.
---------------------
-
-The usual way of using Expect is as a standalone program with Tcl as
-the control language. Since you may already have Tcl, it is available
-separately. Tcl may be retrieved as tcl.tar.Z in the same way as
-described above for Expect. When new releases of Tcl appear, I will
-try to check them out for Expect as soon as possible. If you would
-like to get the newest Tcl release without waiting, ftp it from
-ftp.smli.com (directory pub/tcl).
-
-Expect may also be built using the Tk library, a Tcl interface to the
-X Window System. Tk is available in the same way as Tcl.
-
-It is possible to embed the Expect/Tcl core and optionally Tk in your
-own C programs. This is described in libexpect(3).
-
-Expect can also be used from a C or C++ program without Tcl. This is
-described in libexpect(3). While I consider this library to be easy
-to use, the standalone Expect program is much, much easier to use than
-working with the C compiler and its usual edit, compile, debug cycle.
-Unlike typical programming, most of the debugging isn't getting the C
-compiler to accept your programs - rather, it is getting the dialogue
-correct. Also, translating scripts from Expect to C is usually not
-necessary. For example, the speed of interactive dialogues is
-virtually never an issue. So please try 'expect' first. It is a more
-appropriate tool than the library for most people.
-
---------------------
-Systems Supported
---------------------
-
-I do not know of any UNIX systems on which Expect will not run.
-Systems which do not support select or poll can use Expect, but
-without the ability to run multiple processes simultaneously. I am
-willing to work with you to complete a port.
-
-Before sending me changes, please download or verify that you have the
-latest version of Expect (see above). Then send me a "diff -c" along
-with a suitable English explanation. If your diff involves something
-specific to a machine, give me diffs for configure.in as well or give
-me a hint about when the diffs should be done so I can write the
-configure support myself. Also please include the version of the OS
-and whether it is beta, current, recent, or totally out-of-date and
-unsupported.
-
---------------------
-Installing Expect
---------------------
-
-Expect comes with a configure script that provides for an automated
-installation. I believe you will find that Expect is very easy to
-install. (Tcl and Tk, too.)
-
-For more information, read the INSTALL file.
-
---------------------
-Support from Don Libes or NIST
---------------------
-
-Although I can't promise anything in the way of support, I'd be
-interested to hear about your experiences using it (good or bad). I'm
-also interested in hearing bug reports and suggestions for improvement
-even though I can't promise to implement them.
-
-If you send me a bug, fix, or question, include the version of Expect
-(as reported by expect -d), version of Tcl, and name and version of
-the OS that you are using. Before sending mail, it may be helpful to
-verify that your problem still exists in the latest version. You can
-check on the current release and whether it addresses your problems by
-retrieving the latest HISTORY file (see "History" above).
-
-
-Awards, love letters, and bug reports may be sent to:
-
-Don Libes
-National Institute of Standards and Technology
-Bldg 220, Rm A-127
-Gaithersburg, MD 20899
-(301) 975-3535
-libes@nist.gov
-
-I hereby place this software in the public domain. NIST and I would
-appreciate credit if this program or parts of it are used.
-
-Design and implementation of this program was funded primarily by
-myself. Funding contributors include the NIST Automated Manufacturing
-Research Facility (funded by the Navy Manufacturing Technology
-Program), the NIST Scientific and Technical Research Services, the
-ARPA Persistent Object Bases project and the Computer-aided
-Acquisition and the Logistic Support (CALS) program of the Office of
-the Secretary of Defense.
-
-Especially signicant contributions were made by John Ousterhout, Henry
-Spencer, and Rob Savoye. See the HISTORY file for others.
-
---------------------
-Support for Don Libes or NIST
---------------------
-
-NIST accepts external funding and other resources (hardware, software,
-and personnel). This can be a fine way to work more closely with NIST
-and encourage particular areas of research.
-
-Funding can be earmarked for specific purposes or for less-specific
-purposes. For example, if you simply like the work I do, you can
-contribute directly to my funding which will reduce the amount of time
-I have to spend writing proposals and submitting them to other people
-for funding on my own.
-
-I can also participate in the NIST Fellows program allowing me to
-spend several months to a year working directly with your company and
-potentially even at your location. I am also interested in returning
-to an academic program. I presently have an MS and am hunting for
-Ph.D. topics and advisors. Let me know if you have ideas or are
-interested in being my advisor.
-
---------------------
-Commercial Support, Classes
---------------------
-
-Several companies provide commercial support for Expect. If your
-company has a financial investment in Expect or you wish to be assured
-of continuing support for Expect, you can buy a support contract this
-way. These companies currently include:
-
-Cygnus Support
-1937 Landings Drive
-Mountain View, CA 94043
-+1 (415) 903-1400
-info@cygnus.com
-http://www.cygnus.com
-
-Computerized Processes Unlimited (CPU)
-4200 S. I-10 Service Rd., Suite 205
-Metairie, LA 70006
-+1 (504) 889-2784
-info@cpu.com
-http://www.cpu.com
-http://www.cpu.com/cpu/expect.htm (Expect class page)
-
-CPU provides Expect support and also Expect classes. Contact them for
-more information.
-
-Neither NIST nor I have any financial relationship with these
-companies.
-
-
+++ /dev/null
-dnl written by Rob Savoye <rob@cygnus.com> for Cygnus Support
-dnl major rewriting for Tcl 7.5 by Don Libes <libes@nist.gov>
-
-dnl CY_AC_PATH_TCLCONFIG and CY_AC_LOAD_TCLCONFIG should be invoked
-dnl (in that order) before any other TCL macros. Similarly for TK.
-
-dnl CYGNUS LOCAL: This gets the right posix flag for gcc
-AC_DEFUN(CY_AC_TCL_LYNX_POSIX,
-[AC_REQUIRE([AC_PROG_CC])AC_REQUIRE([AC_PROG_CPP])
-AC_MSG_CHECKING([if running LynxOS])
-AC_CACHE_VAL(ac_cv_os_lynx,
-[AC_EGREP_CPP(yes,
-[/*
- * The old Lynx "cc" only defines "Lynx", but the newer one uses "__Lynx__"
- */
-#if defined(__Lynx__) || defined(Lynx)
-yes
-#endif
-], ac_cv_os_lynx=yes, ac_cv_os_lynx=no)])
-#
-if test "$ac_cv_os_lynx" = "yes" ; then
- AC_MSG_RESULT(yes)
- AC_DEFINE(LYNX)
- AC_MSG_CHECKING([whether -mposix or -X is available])
- AC_CACHE_VAL(ac_cv_c_posix_flag,
- [AC_TRY_COMPILE(,[
- /*
- * This flag varies depending on how old the compiler is.
- * -X is for the old "cc" and "gcc" (based on 1.42).
- * -mposix is for the new gcc (at least 2.5.8).
- */
- #if defined(__GNUC__) && __GNUC__ >= 2
- choke me
- #endif
- ], ac_cv_c_posix_flag=" -mposix", ac_cv_c_posix_flag=" -X")])
- CC="$CC $ac_cv_c_posix_flag"
- AC_MSG_RESULT($ac_cv_c_posix_flag)
- else
- AC_MSG_RESULT(no)
-fi
-])
-
-#
-# Sometimes the native compiler is a bogus stub for gcc or /usr/ucb/cc. This
-# makes configure think it's cross compiling. If --target wasn't used, then
-# we can't configure, so something is wrong. We don't use the cache
-# here cause if somebody fixes their compiler install, we want this to work.
-AC_DEFUN(CY_AC_C_WORKS,
-[# If we cannot compile and link a trivial program, we can't expect anything to work
-AC_MSG_CHECKING(whether the compiler ($CC) actually works)
-AC_TRY_COMPILE(, [/* don't need anything here */],
- c_compiles=yes, c_compiles=no)
-
-AC_TRY_LINK(, [/* don't need anything here */],
- c_links=yes, c_links=no)
-
-if test x"${c_compiles}" = x"no" ; then
- AC_MSG_ERROR(the native compiler is broken and won't compile.)
-fi
-
-if test x"${c_links}" = x"no" ; then
- AC_MSG_ERROR(the native compiler is broken and won't link.)
-fi
-AC_MSG_RESULT(yes)
-])
-
-AC_DEFUN(CY_AC_PATH_TCLH, [
-#
-# Ok, lets find the tcl source trees so we can use the headers
-# Warning: transition of version 9 to 10 will break this algorithm
-# because 10 sorts before 9. We also look for just tcl. We have to
-# be careful that we don't match stuff like tclX by accident.
-# the alternative search directory is involked by --with-tclinclude
-#
-no_tcl=true
-AC_MSG_CHECKING(for Tcl private headers)
-AC_ARG_WITH(tclinclude, [ --with-tclinclude directory where tcl private headers are], with_tclinclude=${withval})
-AC_CACHE_VAL(ac_cv_c_tclh,[
-# first check to see if --with-tclinclude was specified
-if test x"${with_tclinclude}" != x ; then
- if test -f ${with_tclinclude}/tclInt.h ; then
- ac_cv_c_tclh=`(cd ${with_tclinclude}; pwd)`
- elif test -f ${with_tclinclude}/generic/tclInt.h ; then
- ac_cv_c_tclh=`(cd ${with_tclinclude}/generic; pwd)`
- else
- AC_MSG_ERROR([${with_tclinclude} directory doesn't contain private headers])
- fi
-fi
-
-# next check if it came with Tcl configuration file
-if test x"${ac_cv_c_tclconfig}" != x ; then
- if test -f $ac_cv_c_tclconfig/../generic/tclInt.h ; then
- ac_cv_c_tclh=`(cd $ac_cv_c_tclconfig/../generic; pwd)`
- fi
-fi
-
-# next check in private source directory
-#
-# since ls returns lowest version numbers first, reverse its output
-changequote(,)
-if test x"${ac_cv_c_tclh}" = x ; then
- for i in \
- ${srcdir}/../tcl \
- `ls -dr ${srcdir}/../tcl[7-9].[0-9] 2>/dev/null` \
- ${srcdir}/../../tcl \
- `ls -dr ${srcdir}/../../tcl[7-9].[0-9] 2>/dev/null` \
- ${srcdir}/../../../tcl \
- `ls -dr ${srcdir}/../../../tcl[7-9].[0-9] 2>/dev/null ` ; do
- if test -f $i/generic/tclInt.h ; then
- ac_cv_c_tclh=`(cd $i/generic; pwd)`
- break
- fi
- done
-fi
-changequote([,])
-# finally check in a few common install locations
-#
-# since ls returns lowest version numbers first, reverse its output
-changequote(,)
-if test x"${ac_cv_c_tclh}" = x ; then
- for i in \
- `ls -dr /usr/local/src/tcl[7-9].[0-9] 2>/dev/null` \
- `ls -dr /usr/local/lib/tcl[7-9].[0-9] 2>/dev/null` \
- /usr/local/src/tcl \
- /usr/local/lib/tcl \
- ${prefix}/include ; do
- if test -f $i/generic/tclInt.h ; then
- ac_cv_c_tclh=`(cd $i/generic; pwd)`
- break
- fi
- done
-fi
-changequote([,])
-# see if one is installed
-if test x"${ac_cv_c_tclh}" = x ; then
- AC_HEADER_CHECK(tclInt.h, ac_cv_c_tclh=installed, ac_cv_c_tclh="")
-fi
-])
-if test x"${ac_cv_c_tclh}" = x ; then
- TCLHDIR="# no Tcl private headers found"
- TCLHDIRDASHI="# no Tcl private headers found"
- AC_MSG_ERROR([Can't find Tcl private headers])
-fi
-if test x"${ac_cv_c_tclh}" != x ; then
- no_tcl=""
- if test x"${ac_cv_c_tclh}" = x"installed" ; then
- AC_MSG_RESULT([is installed])
- TCLHDIR=""
- TCLHDIRDASHI=""
- TCL_LIBRARY=""
- else
- AC_MSG_RESULT([found in ${ac_cv_c_tclh}])
- # this hack is cause the TCLHDIR won't print if there is a "-I" in it.
- TCLHDIR="${ac_cv_c_tclh}"
- TCLHDIRDASHI="-I${ac_cv_c_tclh}"
- TCL_LIBRARY=`echo $TCLHDIR | sed -e 's/generic//'`library
- fi
-fi
-
-AC_SUBST(TCLHDIR)
-AC_SUBST(TCLHDIRDASHI)
-AC_SUBST(TCL_LIBRARY)
-])
-
-
-AC_DEFUN(CY_AC_PATH_TCLCONFIG, [
-#
-# Ok, lets find the tcl configuration
-# First, look for one uninstalled.
-# the alternative search directory is invoked by --with-tclconfig
-#
-
-if test x"${no_tcl}" = x ; then
- # we reset no_tcl in case something fails here
- no_tcl=true
- AC_ARG_WITH(tclconfig, [ --with-tclconfig directory containing tcl configuration (tclConfig.sh)],
- with_tclconfig=${withval})
- AC_MSG_CHECKING([for Tcl configuration])
- AC_CACHE_VAL(ac_cv_c_tclconfig,[
-
- # First check to see if --with-tclconfig was specified.
- if test x"${with_tclconfig}" != x ; then
- if test -f "${with_tclconfig}/tclConfig.sh" ; then
- ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
- else
- AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
- fi
- fi
-
- # then check for a private Tcl installation
-changequote(,)
- if test x"${ac_cv_c_tclconfig}" = x ; then
- for i in \
- ../tcl \
- `ls -dr ../tcl[7-9].[0-9] 2>/dev/null` \
- ../../tcl \
- `ls -dr ../../tcl[7-9].[0-9] 2>/dev/null` \
- ../../../tcl \
- `ls -dr ../../../tcl[7-9].[0-9] 2>/dev/null` ; do
- if test -f "$i/unix/tclConfig.sh" ; then
- ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
- break
- fi
- if test -f "$i/win/tclConfig.sh" ; then
- ac_cv_c_tclconfig=`(cd $i/win; pwd)`
- break
- fi
- done
- fi
-changequote([,])
- # check in a few common install locations
- if test x"${ac_cv_c_tclconfig}" = x ; then
- for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
- if test -f "$i/tclConfig.sh" ; then
- ac_cv_c_tclconfig=`(cd $i; pwd)`
- break
- fi
- done
- fi
- # check in a few other private locations
-changequote(,)
- if test x"${ac_cv_c_tclconfig}" = x ; then
- for i in \
- ${srcdir}/../tcl \
- `ls -dr ${srcdir}/../tcl[7-9].[0-9] 2>/dev/null` ; do
- if test -f "$i/unix/tclConfig.sh" ; then
- ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
- break
- fi
- done
- fi
-changequote([,])
- ])
- if test x"${ac_cv_c_tclconfig}" = x ; then
- TCLCONFIG="# no Tcl configs found"
- AC_MSG_WARN(Can't find Tcl configuration definitions)
- else
- no_tcl=
- TCLCONFIG=${ac_cv_c_tclconfig}/tclConfig.sh
- AC_MSG_RESULT(found $TCLCONFIG)
- fi
-fi
-])
-
-# Defined as a separate macro so we don't have to cache the values
-# from PATH_TCLCONFIG (because this can also be cached).
-AC_DEFUN(CY_AC_LOAD_TCLCONFIG, [
- . $TCLCONFIG
-
-dnl AC_SUBST(TCL_VERSION)
-dnl AC_SUBST(TCL_MAJOR_VERSION)
-dnl AC_SUBST(TCL_MINOR_VERSION)
-dnl AC_SUBST(TCL_CC)
- AC_SUBST(TCL_DEFS)
-
-dnl not used, don't export to save symbols
-dnl AC_SUBST(TCL_LIB_FILE)
-
-dnl don't export, not used outside of configure
-dnl AC_SUBST(TCL_LIBS)
-dnl not used, don't export to save symbols
-dnl AC_SUBST(TCL_PREFIX)
-
-dnl not used, don't export to save symbols
-dnl AC_SUBST(TCL_EXEC_PREFIX)
-
-dnl not used, don't export to save symbols
-dnl AC_SUBST(TCL_SHLIB_CFLAGS)
- AC_SUBST(TCL_SHLIB_LD)
-dnl don't export, not used outside of configure
-dnl AC_SUBST(TCL_SHLIB_LD_LIBS)
-dnl AC_SUBST(TCL_SHLIB_SUFFIX)
-
-# Tcl defines TCL_SHLIB_SUFFIX but TCL_SHARED_LIB_SUFFIX then looks for it
-# as just SHLIB_SUFFIX. How bizarre.
- SHLIB_SUFFIX=$TCL_SHLIB_SUFFIX
- AC_SUBST(SHLIB_SUFFIX)
-
-dnl not used, don't export to save symbols
-dnl AC_SUBST(TCL_DL_LIBS)
- AC_SUBST(TCL_LD_FLAGS)
-dnl don't export, not used outside of configure
-dnl AC_SUBST(TCL_LD_SEARCH_FLAGS)
-dnl AC_SUBST(TCL_COMPAT_OBJS)
-AC_SUBST(TCL_RANLIB)
-
-dnl CYGNUS LOCAL:
-dnl Anyone that tries to build expect without Tcl, deserves what happens
-dnl to them.
-dnl
-dnl # if Tcl's build directory has been removed, TCL_LIB_SPEC should
-dnl # be used instead of TCL_BUILD_LIB_SPEC
-dnl SAVELIBS=$LIBS
-dnl LIBS="$TCL_BUILD_LIB_SPEC $TCL_LIBS"
-dnl AC_CHECK_FUNC(Tcl_CreateCommand,[
-dnl AC_MSG_CHECKING([if Tcl library build specification is valid])
-dnl AC_MSG_RESULT(yes)
-dnl ],[
-dnl TCL_BUILD_LIB_SPEC=$TCL_LIB_SPEC
-dnl # Can't pull the following CHECKING call out since it will be
-dnl # broken up by the CHECK_FUNC just above.
-dnl AC_MSG_CHECKING([if Tcl library build specification is valid])
-dnl AC_MSG_RESULT(no)
-dnl])
-dnl LIBS=$SAVELIBS
-
- AC_SUBST(TCL_BUILD_LIB_SPEC)
- AC_SUBST(TCL_LIB_SPEC)
-dnl AC_SUBST(TCL_LIB_VERSIONS_OK)
-
-dnl not used, don't export to save symbols
- AC_SUBST(TCL_SHARED_LIB_SUFFIX)
-
-dnl not used, don't export to save symbols
-dnl AC_SUBST(TCL_UNSHARED_LIB_SUFFIX)
-])
-
-# Warning: Tk definitions are very similar to Tcl definitions but
-# are not precisely the same. There are a couple of differences,
-# so don't do changes to Tcl thinking you can cut and paste it do
-# the Tk differences and later simply substitute "Tk" for "Tcl".
-# Known differences:
-# - Acceptable Tcl major version #s is 7-9 while Tk is 4-9
-# - Searching for Tcl includes looking for tclInt.h, Tk looks for tk.h
-# - Computing major/minor versions is different because Tk depends on
-# headers to Tcl, Tk, and X.
-# - Symbols in tkConfig.sh are different than tclConfig.sh
-# - Acceptable for Tk to be missing but not Tcl.
-
-AC_DEFUN(CY_AC_PATH_TKH, [
-#
-# Ok, lets find the tk source trees so we can use the headers
-# If the directory (presumably symlink) named "tk" exists, use that one
-# in preference to any others. Same logic is used when choosing library
-# and again with Tcl. The search order is the best place to look first, then in
-# decreasing significance. The loop breaks if the trigger file is found.
-# Note the gross little conversion here of srcdir by cd'ing to the found
-# directory. This converts the path from a relative to an absolute, so
-# recursive cache variables for the path will work right. We check all
-# the possible paths in one loop rather than many seperate loops to speed
-# things up.
-# the alternative search directory is involked by --with-tkinclude
-#
-#no_tk=true
-AC_MSG_CHECKING(for Tk private headers)
-AC_ARG_WITH(tkinclude, [ --with-tkinclude directory where tk private headers are], with_tkinclude=${withval})
-AC_CACHE_VAL(ac_cv_c_tkh,[
-# first check to see if --with-tkinclude was specified
-if test x"${with_tkinclude}" != x ; then
- if test -f ${with_tkinclude}/tk.h ; then
- ac_cv_c_tkh=`(cd ${with_tkinclude}; pwd)`
- elif test -f ${with_tkinclude}/generic/tk.h ; then
- ac_cv_c_tkh=`(cd ${with_tkinclude}/generic; pwd)`
- else
- AC_MSG_ERROR([${with_tkinclude} directory doesn't contain private headers])
- fi
-fi
-
-# next check if it came with Tk configuration file
-if test x"${ac_cv_c_tkconfig}" != x ; then
- if test -f $ac_cv_c_tkconfig/../generic/tk.h ; then
- ac_cv_c_tkh=`(cd $ac_cv_c_tkconfig/../generic; pwd)`
- fi
-fi
-
-# next check in private source directory
-#
-# since ls returns lowest version numbers first, reverse its output
-changequote(,)
-if test x"${ac_cv_c_tkh}" = x ; then
- for i in \
- ${srcdir}/../tk \
- `ls -dr ${srcdir}/../tk[4-9].[0-9] 2>/dev/null` \
- ${srcdir}/../../tk \
- `ls -dr ${srcdir}/../../tk[4-9].[0-9] 2>/dev/null` \
- ${srcdir}/../../../tk \
- `ls -dr ${srcdir}/../../../tk[4-9].[0-9] 2>/dev/null ` ; do
- if test -f $i/generic/tk.h ; then
- ac_cv_c_tkh=`(cd $i/generic; pwd)`
- break
- fi
- done
-fi
-changequote([,])
-# finally check in a few common install locations
-#
-# since ls returns lowest version numbers first, reverse its output
-changequote(,)
-if test x"${ac_cv_c_tkh}" = x ; then
- for i in \
- `ls -dr /usr/local/src/tk[4-9].[0-9] 2>/dev/null` \
- `ls -dr /usr/local/lib/tk[4-9].[0-9] 2>/dev/null` \
- /usr/local/src/tk \
- /usr/local/lib/tk \
- ${prefix}/include ; do
- if test -f $i/generic/tk.h ; then
- ac_cv_c_tkh=`(cd $i/generic; pwd)`
- break
- fi
- done
-fi
-changequote([,])
-# see if one is installed
-if test x"${ac_cv_c_tkh}" = x ; then
- AC_HEADER_CHECK(tk.h, ac_cv_c_tkh=installed, ac_cv_c_tkh="")
-fi
-])
-if test x"${ac_cv_c_tkh}" != x ; then
-# no_tk=""
- if test x"${ac_cv_c_tkh}" = x"installed" ; then
- AC_MSG_RESULT([is installed])
- TKHDIRDASHI=""
- else
- AC_MSG_RESULT([found in ${ac_cv_c_tkh}])
- # this hack is cause the TKHDIRDASHI won't print if there is a "-I" in it.
- TKHDIRDASHI="-I${ac_cv_c_tkh}"
- fi
-else
- TKHDIRDASHI="# no Tk directory found"
- AC_MSG_WARN([Can't find Tk private headers])
- no_tk=true
-fi
-
-AC_SUBST(TKHDIRDASHI)
-])
-
-
-AC_DEFUN(CY_AC_PATH_TKCONFIG, [
-#
-# Ok, lets find the tk configuration
-# First, look for one uninstalled.
-# the alternative search directory is invoked by --with-tkconfig
-#
-
-if test x"${no_tk}" = x ; then
- # we reset no_tk in case something fails here
- no_tk=true
- AC_ARG_WITH(tkconfig, [ --with-tkconfig directory containing tk configuration (tkConfig.sh)],
- with_tkconfig=${withval})
- AC_MSG_CHECKING([for Tk configuration])
- AC_CACHE_VAL(ac_cv_c_tkconfig,[
-
- # First check to see if --with-tkconfig was specified.
- if test x"${with_tkconfig}" != x ; then
- if test -f "${with_tkconfig}/tkConfig.sh" ; then
- ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
- else
- AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
- fi
- fi
-
- # then check for a private Tk library
-changequote(,)
- if test x"${ac_cv_c_tkconfig}" = x ; then
- for i in \
- ../tk \
- `ls -dr ../tk[4-9].[0-9] 2>/dev/null` \
- ../../tk \
- `ls -dr ../../tk[4-9].[0-9] 2>/dev/null` \
- ../../../tk \
- `ls -dr ../../../tk[4-9].[0-9] 2>/dev/null` ; do
- if test -f "$i/unix/tkConfig.sh" ; then
- ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
- break
- fi
- if test -f "$i/win/tkConfig.sh" ; then
- ac_cv_c_tkconfig=`(cd $i/win; pwd)`
- break
- fi
- done
- fi
-changequote([,])
- # check in a few common install locations
- if test x"${ac_cv_c_tkconfig}" = x ; then
- for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
- if test -f "$i/tkConfig.sh" ; then
- ac_cv_c_tkconfig=`(cd $i; pwd)`
- break
- fi
- done
- fi
- # check in a few other private locations
-changequote(,)
- if test x"${ac_cv_c_tkconfig}" = x ; then
- for i in \
- ${srcdir}/../tk \
- `ls -dr ${srcdir}/../tk[4-9].[0-9] 2>/dev/null` ; do
- if test -f "$i/unix/tkConfig.sh" ; then
- ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
- break
- fi
- done
- fi
-changequote([,])
- ])
- if test x"${ac_cv_c_tkconfig}" = x ; then
- TKCONFIG="# no Tk configs found"
- AC_MSG_WARN(Can't find Tk configuration definitions)
- else
- no_tk=
- TKCONFIG=${ac_cv_c_tkconfig}/tkConfig.sh
- AC_MSG_RESULT(found $TKCONFIG)
- fi
-fi
-
-])
-
-# Defined as a separate macro so we don't have to cache the values
-# from PATH_TKCONFIG (because this can also be cached).
-AC_DEFUN(CY_AC_LOAD_TKCONFIG, [
- if test -f "$TKCONFIG" ; then
- . $TKCONFIG
- fi
-
- AC_SUBST(TK_VERSION)
-dnl not actually used, don't export to save symbols
-dnl AC_SUBST(TK_MAJOR_VERSION)
-dnl AC_SUBST(TK_MINOR_VERSION)
- AC_SUBST(TK_DEFS)
-
-dnl not used, don't export to save symbols
- dnl AC_SUBST(TK_LIB_FILE)
-
-dnl not used outside of configure
-dnl AC_SUBST(TK_LIBS)
-dnl not used, don't export to save symbols
-dnl AC_SUBST(TK_PREFIX)
-
-dnl not used, don't export to save symbols
-dnl AC_SUBST(TK_EXEC_PREFIX)
-
- AC_SUBST(TK_XINCLUDES)
- AC_SUBST(TK_XLIBSW)
- AC_SUBST(TK_BUILD_LIB_SPEC)
- AC_SUBST(TK_LIB_SPEC)
-])
-
-# check for Itcl headers.
-
-AC_DEFUN(CY_AC_PATH_ITCLH, [
-AC_MSG_CHECKING(for Itcl private headers. srcdir=${srcdir})
-if test x"${ac_cv_c_itclh}" = x ; then
- for i in ${srcdir}/../itcl ${srcdir}/../../itcl ${srcdir}/../../../itcl ; do
- if test -f $i/itcl/generic/itcl.h ; then
- ac_cv_c_itclh=`(cd $i/itcl/generic; pwd)`
- break
- fi
- done
-fi
-if test x"${ac_cv_c_itclh}" = x ; then
- ITCLHDIR="# no Itcl private headers found"
- ITCLLIB="# no Itcl private headers found"
- AC_MSG_WARN([Can't find Itcl private headers])
- no_itcl=true
-else
- ITCLHDIR="-I${ac_cv_c_itclh}"
-# should always be here
- ITCLLIB="../itcl/src/libitcl.a"
-fi
-
-AC_SUBST(ITCLHDIR)
-AC_SUBST(ITCLLIB)
-])
-
-# Check to see if we're running under Cygwin32, without using
-# AC_CANONICAL_*. If so, set output variable CYGWIN to "yes".
-# Otherwise set it to "no".
-
-dnl AM_CYGWIN()
-dnl You might think we can do this by checking for a cygwin32-specific
-dnl cpp define.
-AC_DEFUN(CY_AC_CYGWIN,
-[AC_CACHE_CHECK(for Cygwin32 environment, ac_cv_cygwin32,
-[AC_TRY_COMPILE(,[int main () { return __CYGWIN__; }],
-ac_cv_cygwin32=yes, ac_cv_cygwin32=no)
-rm -f conftest*])
-CYGWIN=
-test "$ac_cv_cygwin32" = yes && CYGWIN=yes])
-
-# Check to see if we're running under Win32, without using
-# AC_CANONICAL_*. If so, set output variable EXEEXT to ".exe".
-# Otherwise set it to "".
-
-dnl AM_EXEEXT()
-dnl This knows we add .exe if we're building in the Cygwin32
-dnl environment. But if we're not, then it compiles a test program
-dnl to see if there is a suffix for executables.
-AC_DEFUN(CY_AC_EXEEXT,
-dnl AC_REQUIRE([AC_PROG_CC])AC_REQUIRE([AM_CYGWIN])
-AC_MSG_CHECKING([for executable suffix])
-[AC_CACHE_VAL(ac_cv_exeext,
-[if test "$CYGWIN" = yes; then
-ac_cv_exeext=.exe
-else
-cat > ac_c_test.c << 'EOF'
-int main() {
-/* Nothing needed here */
-}
-EOF
-${CC-cc} -o ac_c_test $CFLAGS $CPPFLAGS $LDFLAGS ac_c_test.c $LIBS 1>&5
-ac_cv_exeext=`ls ac_c_test.* | grep -v ac_c_test.c | sed -e s/ac_c_test//`
-rm -f ac_c_test*])
-test x"${ac_cv_exeext}" = x && ac_cv_exeext=no
-fi
-EXEEXT=""
-test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext}
-AC_MSG_RESULT(${ac_cv_exeext})
-AC_SUBST(EXEEXT)])
-
-# Check for inttypes.h. On some older systems there is a
-# conflict with the definitions of int8_t, int16_t, int32_t
-# that are in sys/types.h. So we have to compile the test
-# program with both, to make sure we want inttypes to be
-# included.
-AC_DEFUN(CY_AC_INTTYPES_H,
-[AC_MSG_CHECKING(for inttypes.h)
-AC_CACHE_VAL(ac_cv_inttypes_h,
- [AC_TRY_COMPILE([
- #include <sys/types.h>
- #include <inttypes.h>],
- [
- int16_t x = 0;
- ], ac_cv_inttypes_h="yes", ac_cv_inttypes_h="no")])
-AC_MSG_RESULT($ac_cv_inttypes_h)
-if test x"${ac_cv_inttypes_h}" = x"yes"; then
- AC_DEFINE(HAVE_INTTYPES_H)
-fi
-])
-
+++ /dev/null
-#! /bin/sh
-
-# Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.13
-# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
-#
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-
-# Defaults:
-ac_help=
-ac_default_prefix=/usr/local
-# Any additions from configure.in:
-ac_help="$ac_help
- --with-tclconfig directory containing tcl configuration (tclConfig.sh)"
-ac_help="$ac_help
- --with-tkconfig directory containing tk configuration (tkConfig.sh)"
-ac_help="$ac_help
- --with-tclinclude directory where tcl private headers are"
-ac_help="$ac_help
- --enable-shared build libexpect as a shared library"
-ac_help="$ac_help
- --with-x whether or not to use X (default yes)"
-ac_help="$ac_help
- --with-tkinclude directory where tk private headers are"
-ac_help="$ac_help
- --disable-load disallow dynamic loading"
-ac_help="$ac_help
- --enable-gcc allow use of gcc if available"
-
-# Initialize some variables set by options.
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-build=NONE
-cache_file=./config.cache
-exec_prefix=NONE
-host=NONE
-no_create=
-nonopt=NONE
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-target=NONE
-verbose=
-x_includes=NONE
-x_libraries=NONE
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datadir='${prefix}/share'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-libdir='${exec_prefix}/lib'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-infodir='${prefix}/info'
-mandir='${prefix}/man'
-
-# Initialize some other variables.
-subdirs=
-MFLAGS= MAKEFLAGS=
-SHELL=${CONFIG_SHELL-/bin/sh}
-# Maximum number of lines to put in a shell here document.
-ac_max_here_lines=12
-
-ac_prev=
-for ac_option
-do
-
- # If the previous option needs an argument, assign it.
- if test -n "$ac_prev"; then
- eval "$ac_prev=\$ac_option"
- ac_prev=
- continue
- fi
-
- case "$ac_option" in
- -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
- *) ac_optarg= ;;
- esac
-
- # Accept the important Cygnus configure options, so we can diagnose typos.
-
- case "$ac_option" in
-
- -bindir | --bindir | --bindi | --bind | --bin | --bi)
- ac_prev=bindir ;;
- -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
- bindir="$ac_optarg" ;;
-
- -build | --build | --buil | --bui | --bu)
- ac_prev=build ;;
- -build=* | --build=* | --buil=* | --bui=* | --bu=*)
- build="$ac_optarg" ;;
-
- -cache-file | --cache-file | --cache-fil | --cache-fi \
- | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
- ac_prev=cache_file ;;
- -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
- | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
- cache_file="$ac_optarg" ;;
-
- -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
- ac_prev=datadir ;;
- -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
- | --da=*)
- datadir="$ac_optarg" ;;
-
- -disable-* | --disable-*)
- ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
- fi
- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
- eval "enable_${ac_feature}=no" ;;
-
- -enable-* | --enable-*)
- ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
- fi
- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes ;;
- esac
- eval "enable_${ac_feature}='$ac_optarg'" ;;
-
- -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
- | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
- | --exec | --exe | --ex)
- ac_prev=exec_prefix ;;
- -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
- | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
- | --exec=* | --exe=* | --ex=*)
- exec_prefix="$ac_optarg" ;;
-
- -gas | --gas | --ga | --g)
- # Obsolete; use --with-gas.
- with_gas=yes ;;
-
- -help | --help | --hel | --he)
- # Omit some internal or obsolete options to make the list less imposing.
- # This message is too long to be a string in the A/UX 3.1 sh.
- cat << EOF
-Usage: configure [options] [host]
-Options: [defaults in brackets after descriptions]
-Configuration:
- --cache-file=FILE cache test results in FILE
- --help print this message
- --no-create do not create output files
- --quiet, --silent do not print \`checking...' messages
- --version print the version of autoconf that created configure
-Directory and file names:
- --prefix=PREFIX install architecture-independent files in PREFIX
- [$ac_default_prefix]
- --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
- [same as prefix]
- --bindir=DIR user executables in DIR [EPREFIX/bin]
- --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
- --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
- --datadir=DIR read-only architecture-independent data in DIR
- [PREFIX/share]
- --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
- --sharedstatedir=DIR modifiable architecture-independent data in DIR
- [PREFIX/com]
- --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
- --libdir=DIR object code libraries in DIR [EPREFIX/lib]
- --includedir=DIR C header files in DIR [PREFIX/include]
- --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
- --infodir=DIR info documentation in DIR [PREFIX/info]
- --mandir=DIR man documentation in DIR [PREFIX/man]
- --srcdir=DIR find the sources in DIR [configure dir or ..]
- --program-prefix=PREFIX prepend PREFIX to installed program names
- --program-suffix=SUFFIX append SUFFIX to installed program names
- --program-transform-name=PROGRAM
- run sed PROGRAM on installed program names
-EOF
- cat << EOF
-Host type:
- --build=BUILD configure for building on BUILD [BUILD=HOST]
- --host=HOST configure for HOST [guessed]
- --target=TARGET configure for TARGET [TARGET=HOST]
-Features and packages:
- --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
- --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
- --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
- --x-includes=DIR X include files are in DIR
- --x-libraries=DIR X library files are in DIR
-EOF
- if test -n "$ac_help"; then
- echo "--enable and --with options recognized:$ac_help"
- fi
- exit 0 ;;
-
- -host | --host | --hos | --ho)
- ac_prev=host ;;
- -host=* | --host=* | --hos=* | --ho=*)
- host="$ac_optarg" ;;
-
- -includedir | --includedir | --includedi | --included | --include \
- | --includ | --inclu | --incl | --inc)
- ac_prev=includedir ;;
- -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
- | --includ=* | --inclu=* | --incl=* | --inc=*)
- includedir="$ac_optarg" ;;
-
- -infodir | --infodir | --infodi | --infod | --info | --inf)
- ac_prev=infodir ;;
- -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
- infodir="$ac_optarg" ;;
-
- -libdir | --libdir | --libdi | --libd)
- ac_prev=libdir ;;
- -libdir=* | --libdir=* | --libdi=* | --libd=*)
- libdir="$ac_optarg" ;;
-
- -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
- | --libexe | --libex | --libe)
- ac_prev=libexecdir ;;
- -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
- | --libexe=* | --libex=* | --libe=*)
- libexecdir="$ac_optarg" ;;
-
- -localstatedir | --localstatedir | --localstatedi | --localstated \
- | --localstate | --localstat | --localsta | --localst \
- | --locals | --local | --loca | --loc | --lo)
- ac_prev=localstatedir ;;
- -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
- | --localstate=* | --localstat=* | --localsta=* | --localst=* \
- | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
- localstatedir="$ac_optarg" ;;
-
- -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
- ac_prev=mandir ;;
- -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
- mandir="$ac_optarg" ;;
-
- -nfp | --nfp | --nf)
- # Obsolete; use --without-fp.
- with_fp=no ;;
-
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c)
- no_create=yes ;;
-
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
- no_recursion=yes ;;
-
- -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
- | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
- | --oldin | --oldi | --old | --ol | --o)
- ac_prev=oldincludedir ;;
- -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
- | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
- | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
- oldincludedir="$ac_optarg" ;;
-
- -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
- ac_prev=prefix ;;
- -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
- prefix="$ac_optarg" ;;
-
- -program-prefix | --program-prefix | --program-prefi | --program-pref \
- | --program-pre | --program-pr | --program-p)
- ac_prev=program_prefix ;;
- -program-prefix=* | --program-prefix=* | --program-prefi=* \
- | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
- program_prefix="$ac_optarg" ;;
-
- -program-suffix | --program-suffix | --program-suffi | --program-suff \
- | --program-suf | --program-su | --program-s)
- ac_prev=program_suffix ;;
- -program-suffix=* | --program-suffix=* | --program-suffi=* \
- | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
- program_suffix="$ac_optarg" ;;
-
- -program-transform-name | --program-transform-name \
- | --program-transform-nam | --program-transform-na \
- | --program-transform-n | --program-transform- \
- | --program-transform | --program-transfor \
- | --program-transfo | --program-transf \
- | --program-trans | --program-tran \
- | --progr-tra | --program-tr | --program-t)
- ac_prev=program_transform_name ;;
- -program-transform-name=* | --program-transform-name=* \
- | --program-transform-nam=* | --program-transform-na=* \
- | --program-transform-n=* | --program-transform-=* \
- | --program-transform=* | --program-transfor=* \
- | --program-transfo=* | --program-transf=* \
- | --program-trans=* | --program-tran=* \
- | --progr-tra=* | --program-tr=* | --program-t=*)
- program_transform_name="$ac_optarg" ;;
-
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- silent=yes ;;
-
- -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
- ac_prev=sbindir ;;
- -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
- | --sbi=* | --sb=*)
- sbindir="$ac_optarg" ;;
-
- -sharedstatedir | --sharedstatedir | --sharedstatedi \
- | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
- | --sharedst | --shareds | --shared | --share | --shar \
- | --sha | --sh)
- ac_prev=sharedstatedir ;;
- -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
- | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
- | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
- | --sha=* | --sh=*)
- sharedstatedir="$ac_optarg" ;;
-
- -site | --site | --sit)
- ac_prev=site ;;
- -site=* | --site=* | --sit=*)
- site="$ac_optarg" ;;
-
- -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
- ac_prev=srcdir ;;
- -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
- srcdir="$ac_optarg" ;;
-
- -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
- | --syscon | --sysco | --sysc | --sys | --sy)
- ac_prev=sysconfdir ;;
- -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
- | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
- sysconfdir="$ac_optarg" ;;
-
- -target | --target | --targe | --targ | --tar | --ta | --t)
- ac_prev=target ;;
- -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
- target="$ac_optarg" ;;
-
- -v | -verbose | --verbose | --verbos | --verbo | --verb)
- verbose=yes ;;
-
- -version | --version | --versio | --versi | --vers)
- echo "configure generated by autoconf version 2.13"
- exit 0 ;;
-
- -with-* | --with-*)
- ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
- fi
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes ;;
- esac
- eval "with_${ac_package}='$ac_optarg'" ;;
-
- -without-* | --without-*)
- ac_package=`echo $ac_option|sed -e 's/-*without-//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
- fi
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- eval "with_${ac_package}=no" ;;
-
- --x)
- # Obsolete; use --with-x.
- with_x=yes ;;
-
- -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
- | --x-incl | --x-inc | --x-in | --x-i)
- ac_prev=x_includes ;;
- -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
- | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
- x_includes="$ac_optarg" ;;
-
- -x-libraries | --x-libraries | --x-librarie | --x-librari \
- | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
- ac_prev=x_libraries ;;
- -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
- | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
- x_libraries="$ac_optarg" ;;
-
- -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
- ;;
-
- *)
- if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
- echo "configure: warning: $ac_option: invalid host type" 1>&2
- fi
- if test "x$nonopt" != xNONE; then
- { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
- fi
- nonopt="$ac_option"
- ;;
-
- esac
-done
-
-if test -n "$ac_prev"; then
- { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
-fi
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-# File descriptor usage:
-# 0 standard input
-# 1 file creation
-# 2 errors and warnings
-# 3 some systems may open it to /dev/tty
-# 4 used on the Kubota Titan
-# 6 checking for... messages and results
-# 5 compiler messages saved in config.log
-if test "$silent" = yes; then
- exec 6>/dev/null
-else
- exec 6>&1
-fi
-exec 5>./config.log
-
-echo "\
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-" 1>&5
-
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Also quote any args containing shell metacharacters.
-ac_configure_args=
-for ac_arg
-do
- case "$ac_arg" in
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c) ;;
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
- ac_configure_args="$ac_configure_args '$ac_arg'" ;;
- *) ac_configure_args="$ac_configure_args $ac_arg" ;;
- esac
-done
-
-# NLS nuisances.
-# Only set these to C if already set. These must not be set unconditionally
-# because not all systems understand e.g. LANG=C (notably SCO).
-# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
-# Non-C LC_CTYPE values break the ctype check.
-if test "${LANG+set}" = set; then LANG=C; export LANG; fi
-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
-if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
-if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -rf conftest* confdefs.h
-# AIX cpp loses on an empty file, so make sure it contains at least a newline.
-echo > confdefs.h
-
-# A filename unique to this package, relative to the directory that
-# configure is in, which we can look for to find out if srcdir is correct.
-ac_unique_file=expect.h
-
-# Find the source files, if location was not specified.
-if test -z "$srcdir"; then
- ac_srcdir_defaulted=yes
- # Try the directory containing this script, then its parent.
- ac_prog=$0
- ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
- test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
- srcdir=$ac_confdir
- if test ! -r $srcdir/$ac_unique_file; then
- srcdir=..
- fi
-else
- ac_srcdir_defaulted=no
-fi
-if test ! -r $srcdir/$ac_unique_file; then
- if test "$ac_srcdir_defaulted" = yes; then
- { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
- else
- { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
- fi
-fi
-srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
-
-# Prefer explicitly selected file to automatically selected ones.
-if test -z "$CONFIG_SITE"; then
- if test "x$prefix" != xNONE; then
- CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
- else
- CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
- fi
-fi
-for ac_site_file in $CONFIG_SITE; do
- if test -r "$ac_site_file"; then
- echo "loading site script $ac_site_file"
- . "$ac_site_file"
- fi
-done
-
-
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-ac_exeext=
-ac_objext=o
-if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
- # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
- if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
- ac_n= ac_c='
-' ac_t=' '
- else
- ac_n=-n ac_c= ac_t=
- fi
-else
- ac_n= ac_c='\c' ac_t=
-fi
-
-
-
-ac_aux_dir=
-for ac_dir in $srcdir/.. $srcdir/$srcdir/..; do
- if test -f $ac_dir/install-sh; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/install-sh -c"
- break
- elif test -f $ac_dir/install.sh; then
- ac_aux_dir=$ac_dir
- ac_install_sh="$ac_aux_dir/install.sh -c"
- break
- fi
-done
-if test -z "$ac_aux_dir"; then
- { echo "configure: error: can not find install-sh or install.sh in $srcdir/.. $srcdir/$srcdir/.." 1>&2; exit 1; }
-fi
-ac_config_guess=$ac_aux_dir/config.guess
-ac_config_sub=$ac_aux_dir/config.sub
-ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
-
-
-# note when updating version numbers here, also update pkgIndex.in (see
-# comments in Makefile)
-EXP_MAJOR_VERSION=5
-EXP_MINOR_VERSION=26
-EXP_MICRO_VERSION=0
-EXP_VERSION=$EXP_MAJOR_VERSION.$EXP_MINOR_VERSION
-EXP_VERSION_NODOTS=$EXP_MAJOR_VERSION$EXP_MINOR_VERSION
-EXP_VERSION_FULL=$EXP_VERSION.$EXP_MICRO_VERSION
-
-# Tcl's handling of shared_lib_suffix requires this symbol exist
-VERSION=$EXP_MAJOR_VERSION.$EXP_MINOR_VERSION
-
-# Too many people send me configure output without identifying the version.
-# This forced identification should reduce my pain significantly.
-echo "configuring Expect $EXP_MAJOR_VERSION.$EXP_MINOR_VERSION.$EXP_MICRO_VERSION"
-
-
-# Do some error checking and defaulting for the host and target type.
-# The inputs are:
-# configure --host=HOST --target=TARGET --build=BUILD NONOPT
-#
-# The rules are:
-# 1. You are not allowed to specify --host, --target, and nonopt at the
-# same time.
-# 2. Host defaults to nonopt.
-# 3. If nonopt is not specified, then host defaults to the current host,
-# as determined by config.guess.
-# 4. Target and build default to nonopt.
-# 5. If nonopt is not specified, then target and build default to host.
-
-# The aliases save the names the user supplied, while $host etc.
-# will get canonicalized.
-case $host---$target---$nonopt in
-NONE---*---* | *---NONE---* | *---*---NONE) ;;
-*) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;;
-esac
-
-
-# Make sure we can run config.sub.
-if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
-else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
-fi
-
-echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:599: checking host system type" >&5
-
-host_alias=$host
-case "$host_alias" in
-NONE)
- case $nonopt in
- NONE)
- if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then :
- else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
- fi ;;
- *) host_alias=$nonopt ;;
- esac ;;
-esac
-
-host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias`
-host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-echo "$ac_t""$host" 1>&6
-
-echo $ac_n "checking target system type""... $ac_c" 1>&6
-echo "configure:620: checking target system type" >&5
-
-target_alias=$target
-case "$target_alias" in
-NONE)
- case $nonopt in
- NONE) target_alias=$host_alias ;;
- *) target_alias=$nonopt ;;
- esac ;;
-esac
-
-target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias`
-target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-echo "$ac_t""$target" 1>&6
-
-echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:638: checking build system type" >&5
-
-build_alias=$build
-case "$build_alias" in
-NONE)
- case $nonopt in
- NONE) build_alias=$host_alias ;;
- *) build_alias=$nonopt ;;
- esac ;;
-esac
-
-build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias`
-build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-echo "$ac_t""$build" 1>&6
-
-test "$host_alias" != "$target_alias" &&
- test "$program_prefix$program_suffix$program_transform_name" = \
- NONENONEs,x,x, &&
- program_prefix=${target_alias}-
-
-
-
-
-# /bin/sh on some systems is too deficient (in particular, Ultrix 4.3
-# sh lacks unset and we *need* that), but all these systems come with
-# alternatives, so take user's choice or whatever we're using here and
-# allow it to be seen by Make.
-echo $ac_n "checking shell to use within Make""... $ac_c" 1>&6
-echo "configure:668: checking shell to use within Make" >&5
-EXP_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
-echo "$ac_t""$CONFIG_SHELL" 1>&6
-
-# If `configure' is invoked (in)directly via `make', ensure that it
-# encounters no `make' conflicts.
-#
-unset MFLAGS MAKEFLAGS
-MFLAGS=""
-MAKEFLAGS=""
-
-
-#
-# Ok, lets find the tcl configuration
-# First, look for one uninstalled.
-# the alternative search directory is invoked by --with-tclconfig
-#
-
-if test x"${no_tcl}" = x ; then
- # we reset no_tcl in case something fails here
- no_tcl=true
- # Check whether --with-tclconfig or --without-tclconfig was given.
-if test "${with_tclconfig+set}" = set; then
- withval="$with_tclconfig"
- with_tclconfig=${withval}
-fi
-
- echo $ac_n "checking for Tcl configuration""... $ac_c" 1>&6
-echo "configure:696: checking for Tcl configuration" >&5
- if eval "test \"`echo '$''{'ac_cv_c_tclconfig'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
-
-
- # First check to see if --with-tclconfig was specified.
- if test x"${with_tclconfig}" != x ; then
- if test -f "${with_tclconfig}/tclConfig.sh" ; then
- ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
- else
- { echo "configure: error: ${with_tclconfig} directory doesn't contain tclConfig.sh" 1>&2; exit 1; }
- fi
- fi
-
- # then check for a private Tcl installation
-
- if test x"${ac_cv_c_tclconfig}" = x ; then
- for i in \
- ../tcl \
- `ls -dr ../tcl[7-9].[0-9] 2>/dev/null` \
- ../../tcl \
- `ls -dr ../../tcl[7-9].[0-9] 2>/dev/null` \
- ../../../tcl \
- `ls -dr ../../../tcl[7-9].[0-9] 2>/dev/null` ; do
- if test -f "$i/unix/tclConfig.sh" ; then
- ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
- break
- fi
- if test -f "$i/win/tclConfig.sh" ; then
- ac_cv_c_tclconfig=`(cd $i/win; pwd)`
- break
- fi
- done
- fi
-
- # check in a few common install locations
- if test x"${ac_cv_c_tclconfig}" = x ; then
- for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
- if test -f "$i/tclConfig.sh" ; then
- ac_cv_c_tclconfig=`(cd $i; pwd)`
- break
- fi
- done
- fi
- # check in a few other private locations
-
- if test x"${ac_cv_c_tclconfig}" = x ; then
- for i in \
- ${srcdir}/../tcl \
- `ls -dr ${srcdir}/../tcl[7-9].[0-9] 2>/dev/null` ; do
- if test -f "$i/unix/tclConfig.sh" ; then
- ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
- break
- fi
- done
- fi
-
-
-fi
-
- if test x"${ac_cv_c_tclconfig}" = x ; then
- TCLCONFIG="# no Tcl configs found"
- echo "configure: warning: Can't find Tcl configuration definitions" 1>&2
- else
- no_tcl=
- TCLCONFIG=${ac_cv_c_tclconfig}/tclConfig.sh
- echo "$ac_t""found $TCLCONFIG" 1>&6
- fi
-fi
-
-
- . $TCLCONFIG
-
-
-
-
-
-
-
-
-# Tcl defines TCL_SHLIB_SUFFIX but TCL_SHARED_LIB_SUFFIX then looks for it
-# as just SHLIB_SUFFIX. How bizarre.
- SHLIB_SUFFIX=$TCL_SHLIB_SUFFIX
-
-
-
-
-
-
-
-
-
-
-
-
-CC=$TCL_CC
-EXP_AND_TCL_LIBS=$TCL_LIBS
-
-#
-# Ok, lets find the tk configuration
-# First, look for one uninstalled.
-# the alternative search directory is invoked by --with-tkconfig
-#
-
-if test x"${no_tk}" = x ; then
- # we reset no_tk in case something fails here
- no_tk=true
- # Check whether --with-tkconfig or --without-tkconfig was given.
-if test "${with_tkconfig+set}" = set; then
- withval="$with_tkconfig"
- with_tkconfig=${withval}
-fi
-
- echo $ac_n "checking for Tk configuration""... $ac_c" 1>&6
-echo "configure:811: checking for Tk configuration" >&5
- if eval "test \"`echo '$''{'ac_cv_c_tkconfig'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
-
-
- # First check to see if --with-tkconfig was specified.
- if test x"${with_tkconfig}" != x ; then
- if test -f "${with_tkconfig}/tkConfig.sh" ; then
- ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
- else
- { echo "configure: error: ${with_tkconfig} directory doesn't contain tkConfig.sh" 1>&2; exit 1; }
- fi
- fi
-
- # then check for a private Tk library
-
- if test x"${ac_cv_c_tkconfig}" = x ; then
- for i in \
- ../tk \
- `ls -dr ../tk[4-9].[0-9] 2>/dev/null` \
- ../../tk \
- `ls -dr ../../tk[4-9].[0-9] 2>/dev/null` \
- ../../../tk \
- `ls -dr ../../../tk[4-9].[0-9] 2>/dev/null` ; do
- if test -f "$i/unix/tkConfig.sh" ; then
- ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
- break
- fi
- if test -f "$i/win/tkConfig.sh" ; then
- ac_cv_c_tkconfig=`(cd $i/win; pwd)`
- break
- fi
- done
- fi
-
- # check in a few common install locations
- if test x"${ac_cv_c_tkconfig}" = x ; then
- for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
- if test -f "$i/tkConfig.sh" ; then
- ac_cv_c_tkconfig=`(cd $i; pwd)`
- break
- fi
- done
- fi
- # check in a few other private locations
-
- if test x"${ac_cv_c_tkconfig}" = x ; then
- for i in \
- ${srcdir}/../tk \
- `ls -dr ${srcdir}/../tk[4-9].[0-9] 2>/dev/null` ; do
- if test -f "$i/unix/tkConfig.sh" ; then
- ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
- break
- fi
- done
- fi
-
-
-fi
-
- if test x"${ac_cv_c_tkconfig}" = x ; then
- TKCONFIG="# no Tk configs found"
- echo "configure: warning: Can't find Tk configuration definitions" 1>&2
- else
- no_tk=
- TKCONFIG=${ac_cv_c_tkconfig}/tkConfig.sh
- echo "$ac_t""found $TKCONFIG" 1>&6
- fi
-fi
-
-
-
- if test -f "$TKCONFIG" ; then
- . $TKCONFIG
- fi
-
-
-
-
-
-
-
-
-
-
-
-
-EXP_AND_TK_LIBS=$TK_LIBS
-
-# CYGNUS LOCAL dj/cygwin
-
-# Make sure we can run config.sub.
-if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
-else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
-fi
-
-echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:909: checking host system type" >&5
-
-host_alias=$host
-case "$host_alias" in
-NONE)
- case $nonopt in
- NONE)
- if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then :
- else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
- fi ;;
- *) host_alias=$nonopt ;;
- esac ;;
-esac
-
-host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias`
-host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
-echo "$ac_t""$host" 1>&6
-
-EXP_CFLAGS=""
-# If we built a cygwin-specific tcl, use it here.
-case "${host}" in
-*-*-cygwin*)
- if test -d $srcdir/../tcl/cygwin/.
- then
- TCL_BUILD_LIB_SPEC="../tcl/cygwin/libtcl_cygwin.a"
- # Use the same static lib for installed_expect
- TCL_LIB_SPEC="../tcl/cygwin/libtcl_cygwin.a"
- EXP_CYGWIN_ALTTCL='-DCYGWIN_ALTTCL'
- fi
- touch ac$$.c
- if ${CC} -c -mno-win32 ac$$.c >/dev/null 2>&1; then
- case "$EXP_CFLAGS" in
- *-mno-win32*) ;;
- *) EXP_CFLAGS="-mno-win32 $EXP_CFLAGS" ;;
- esac
- fi
- rm -f ac$$.o ac$$.c
- ;;
-esac
-
-# An explanation is in order for the strange things going on with the
-# various LIBS. There are three separate definitions for LIBS. The
-# reason is that some systems require shared libraries include
-# references to their dependent libraries, i.e., any additional
-# libraries that must be linked to. And some systems get upset if the
-# references are repeated on the link line. So therefore, we create
-# one for Expect and Tk (EXP_AND_TK_LIBS), one for Expect and Tcl
-# (EXP_AND_TCL_LIBS), and finally, one for building Expect's own
-# shared library. Tcl's tclConfig.sh insists that any shared libs
-# that it "helps" build must pass the libraries as LIBS (see comment
-# near end of this configure file). I would do but since we're close
-# to hitting config's max symbols, we take one short cut and pack the
-# LIBS into EXP_SHLIB_LD_LIBS (which is basically what Tcl wants to do
-# for us). The point, however, is that there's no separate LIBS or
-# EXP_LIBS symbol passed out of configure. One additional point for
-# confusion is that LIBS is what configure uses to do all library
-# tests, so we have to swap definitions of LIBS peridically. When we
-# are swapping out the one for Expect's shared library, we save it in
-# EXP_LIBS. Sigh.
-
-OLD_CFLAGS=$CFLAGS
-# Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:975: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_dummy="$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_CC="gcc"
- break
- fi
- done
- IFS="$ac_save_ifs"
-fi
-fi
-CC="$ac_cv_prog_CC"
-if test -n "$CC"; then
- echo "$ac_t""$CC" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-if test -z "$CC"; then
- # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1005: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_prog_rejected=no
- ac_dummy="$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
- ac_prog_rejected=yes
- continue
- fi
- ac_cv_prog_CC="cc"
- break
- fi
- done
- IFS="$ac_save_ifs"
-if test $ac_prog_rejected = yes; then
- # We found a bogon in the path, so make sure we never use it.
- set dummy $ac_cv_prog_CC
- shift
- if test $# -gt 0; then
- # We chose a different compiler from the bogus one.
- # However, it has the same basename, so the bogon will be chosen
- # first if we set CC to just the basename; use the full file name.
- shift
- set dummy "$ac_dir/$ac_word" "$@"
- shift
- ac_cv_prog_CC="$@"
- fi
-fi
-fi
-fi
-CC="$ac_cv_prog_CC"
-if test -n "$CC"; then
- echo "$ac_t""$CC" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
- if test -z "$CC"; then
- case "`uname -s`" in
- *win32* | *WIN32*)
- # Extract the first word of "cl", so it can be a program name with args.
-set dummy cl; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1056: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_dummy="$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_CC="cl"
- break
- fi
- done
- IFS="$ac_save_ifs"
-fi
-fi
-CC="$ac_cv_prog_CC"
-if test -n "$CC"; then
- echo "$ac_t""$CC" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
- ;;
- esac
- fi
- test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
-fi
-
-echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1088: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
-
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-cat > conftest.$ac_ext << EOF
-
-#line 1099 "configure"
-#include "confdefs.h"
-
-main(){return(0);}
-EOF
-if { (eval echo configure:1104: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- ac_cv_prog_cc_works=yes
- # If we can't run a trivial program, we are probably using a cross compiler.
- if (./conftest; exit) 2>/dev/null; then
- ac_cv_prog_cc_cross=no
- else
- ac_cv_prog_cc_cross=yes
- fi
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- ac_cv_prog_cc_works=no
-fi
-rm -fr conftest*
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
-if test $ac_cv_prog_cc_works = no; then
- { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
-fi
-echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:1130: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
-echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
-cross_compiling=$ac_cv_prog_cc_cross
-
-echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:1135: checking whether we are using GNU C" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.c <<EOF
-#ifdef __GNUC__
- yes;
-#endif
-EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1144: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
- ac_cv_prog_gcc=yes
-else
- ac_cv_prog_gcc=no
-fi
-fi
-
-echo "$ac_t""$ac_cv_prog_gcc" 1>&6
-
-if test $ac_cv_prog_gcc = yes; then
- GCC=yes
-else
- GCC=
-fi
-
-ac_test_CFLAGS="${CFLAGS+set}"
-ac_save_CFLAGS="$CFLAGS"
-CFLAGS=
-echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:1163: checking whether ${CC-cc} accepts -g" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- echo 'void f(){}' > conftest.c
-if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
- ac_cv_prog_cc_g=yes
-else
- ac_cv_prog_cc_g=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
-if test "$ac_test_CFLAGS" = set; then
- CFLAGS="$ac_save_CFLAGS"
-elif test $ac_cv_prog_cc_g = yes; then
- if test "$GCC" = yes; then
- CFLAGS="-g -O2"
- else
- CFLAGS="-g"
- fi
-else
- if test "$GCC" = yes; then
- CFLAGS="-O2"
- else
- CFLAGS=
- fi
-fi
-
-CFLAGS=$OLD_CFLAGS
-
-# If we cannot compile and link a trivial program, we can't expect anything to work
-echo $ac_n "checking whether the compiler ($CC) actually works""... $ac_c" 1>&6
-echo "configure:1198: checking whether the compiler ($CC) actually works" >&5
-cat > conftest.$ac_ext <<EOF
-#line 1200 "configure"
-#include "confdefs.h"
-
-int main() {
-/* don't need anything here */
-; return 0; }
-EOF
-if { (eval echo configure:1207: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- c_compiles=yes
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- c_compiles=no
-fi
-rm -f conftest*
-
-cat > conftest.$ac_ext <<EOF
-#line 1219 "configure"
-#include "confdefs.h"
-
-int main() {
-/* don't need anything here */
-; return 0; }
-EOF
-if { (eval echo configure:1226: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- c_links=yes
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- c_links=no
-fi
-rm -f conftest*
-
-if test x"${c_compiles}" = x"no" ; then
- { echo "configure: error: the native compiler is broken and won't compile." 1>&2; exit 1; }
-fi
-
-if test x"${c_links}" = x"no" ; then
- { echo "configure: error: the native compiler is broken and won't link." 1>&2; exit 1; }
-fi
-echo "$ac_t""yes" 1>&6
-
-
-# this'll use a BSD compatible install or our included install-sh
-# Find a good install program. We prefer a C program (faster),
-# so one script is as good as another. But avoid the broken or
-# incompatible versions:
-# SysV /etc/install, /usr/sbin/install
-# SunOS /usr/etc/install
-# IRIX /sbin/install
-# AIX /bin/install
-# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
-# AFS /usr/afsws/bin/install, which mishandles nonexistent args
-# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
-# ./install, which can be erroneously created by make from ./install.sh.
-echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:1260: checking for a BSD compatible install" >&5
-if test -z "$INSTALL"; then
-if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
- for ac_dir in $PATH; do
- # Account for people who put trailing slashes in PATH elements.
- case "$ac_dir/" in
- /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
- *)
- # OSF1 and SCO ODT 3.0 have their own names for install.
- # Don't use installbsd from OSF since it installs stuff as root
- # by default.
- for ac_prog in ginstall scoinst install; do
- if test -f $ac_dir/$ac_prog; then
- if test $ac_prog = install &&
- grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
- # AIX install. It has an incompatible calling convention.
- :
- else
- ac_cv_path_install="$ac_dir/$ac_prog -c"
- break 2
- fi
- fi
- done
- ;;
- esac
- done
- IFS="$ac_save_IFS"
-
-fi
- if test "${ac_cv_path_install+set}" = set; then
- INSTALL="$ac_cv_path_install"
- else
- # As a last resort, use the slow shell script. We don't cache a
- # path for INSTALL within a source directory, because that will
- # break other packages using the cache if that directory is
- # removed, or if the path is relative.
- INSTALL="$ac_install_sh"
- fi
-fi
-echo "$ac_t""$INSTALL" 1>&6
-
-# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
-# It thinks the first close brace ends the variable substitution.
-test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
-
-test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
-
-test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
-
-
-# Tcl sets TCL_RANLIB appropriately for shared library if --enable-shared
-# Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1317: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$RANLIB"; then
- ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_dummy="$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_RANLIB="ranlib"
- break
- fi
- done
- IFS="$ac_save_ifs"
- test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
-fi
-fi
-RANLIB="$ac_cv_prog_RANLIB"
-if test -n "$RANLIB"; then
- echo "$ac_t""$RANLIB" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-UNSHARED_RANLIB=$RANLIB
-
-# these are the other subdirectories we need to configure
-subdirs="testsuite"
-
-
-# This is for LynxOS, which needs a flag to force true POSIX when
-# building. The flag varies depending how old the compiler is.
-# -X is for the old "cc" and "gcc" (based on 1.42)
-# -mposix is for the new gcc (at least 2.5.8)
-# This modifies the value of $CC to have the POSIX flag added
-# so it'll configure correctly
-echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1357: checking how to run the C preprocessor" >&5
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
- CPP=
-fi
-if test -z "$CPP"; then
-if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- # This must be in double quotes, not single quotes, because CPP may get
- # substituted into the Makefile and "${CC-cc}" will confuse make.
- CPP="${CC-cc} -E"
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp.
- cat > conftest.$ac_ext <<EOF
-#line 1372 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1378: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- CPP="${CC-cc} -E -traditional-cpp"
- cat > conftest.$ac_ext <<EOF
-#line 1389 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1395: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- CPP="${CC-cc} -nologo -E"
- cat > conftest.$ac_ext <<EOF
-#line 1406 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1412: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- CPP=/lib/cpp
-fi
-rm -f conftest*
-fi
-rm -f conftest*
-fi
-rm -f conftest*
- ac_cv_prog_CPP="$CPP"
-fi
- CPP="$ac_cv_prog_CPP"
-else
- ac_cv_prog_CPP="$CPP"
-fi
-echo "$ac_t""$CPP" 1>&6
-
-
-echo $ac_n "checking if running LynxOS""... $ac_c" 1>&6
-echo "configure:1438: checking if running LynxOS" >&5
-if eval "test \"`echo '$''{'ac_cv_os_lynx'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1443 "configure"
-#include "confdefs.h"
-/*
- * The old Lynx "cc" only defines "Lynx", but the newer one uses "__Lynx__"
- */
-#if defined(__Lynx__) || defined(Lynx)
-yes
-#endif
-
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "yes" >/dev/null 2>&1; then
- rm -rf conftest*
- ac_cv_os_lynx=yes
-else
- rm -rf conftest*
- ac_cv_os_lynx=no
-fi
-rm -f conftest*
-
-fi
-
-#
-if test "$ac_cv_os_lynx" = "yes" ; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define LYNX 1
-EOF
-
- echo $ac_n "checking whether -mposix or -X is available""... $ac_c" 1>&6
-echo "configure:1473: checking whether -mposix or -X is available" >&5
- if eval "test \"`echo '$''{'ac_cv_c_posix_flag'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1478 "configure"
-#include "confdefs.h"
-
-int main() {
-
- /*
- * This flag varies depending on how old the compiler is.
- * -X is for the old "cc" and "gcc" (based on 1.42).
- * -mposix is for the new gcc (at least 2.5.8).
- */
- #if defined(__GNUC__) && __GNUC__ >= 2
- choke me
- #endif
-
-; return 0; }
-EOF
-if { (eval echo configure:1494: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- ac_cv_c_posix_flag=" -mposix"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- ac_cv_c_posix_flag=" -X"
-fi
-rm -f conftest*
-fi
-
- CC="$CC $ac_cv_c_posix_flag"
- echo "$ac_t""$ac_cv_c_posix_flag" 1>&6
- else
- echo "$ac_t""no" 1>&6
-fi
-
-
-echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1514: checking for ANSI C header files" >&5
-if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1519 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1527: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- ac_cv_header_stdc=yes
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-if test $ac_cv_header_stdc = yes; then
- # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-cat > conftest.$ac_ext <<EOF
-#line 1544 "configure"
-#include "confdefs.h"
-#include <string.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "memchr" >/dev/null 2>&1; then
- :
-else
- rm -rf conftest*
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-cat > conftest.$ac_ext <<EOF
-#line 1562 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "free" >/dev/null 2>&1; then
- :
-else
- rm -rf conftest*
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-if test "$cross_compiling" = yes; then
- :
-else
- cat > conftest.$ac_ext <<EOF
-#line 1583 "configure"
-#include "confdefs.h"
-#include <ctype.h>
-#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int main () { int i; for (i = 0; i < 256; i++)
-if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
-exit (0); }
-
-EOF
-if { (eval echo configure:1594: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
- :
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -fr conftest*
- ac_cv_header_stdc=no
-fi
-rm -fr conftest*
-fi
-
-fi
-fi
-
-echo "$ac_t""$ac_cv_header_stdc" 1>&6
-if test $ac_cv_header_stdc = yes; then
- cat >> confdefs.h <<\EOF
-#define STDC_HEADERS 1
-EOF
-
-fi
-
-echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:1618: checking for pid_t" >&5
-if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1623 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "(^|[^a-zA-Z_0-9])pid_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
- rm -rf conftest*
- ac_cv_type_pid_t=yes
-else
- rm -rf conftest*
- ac_cv_type_pid_t=no
-fi
-rm -f conftest*
-
-fi
-echo "$ac_t""$ac_cv_type_pid_t" 1>&6
-if test $ac_cv_type_pid_t = no; then
- cat >> confdefs.h <<\EOF
-#define pid_t int
-EOF
-
-fi
-
-echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:1651: checking return type of signal handlers" >&5
-if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1656 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#include <signal.h>
-#ifdef signal
-#undef signal
-#endif
-#ifdef __cplusplus
-extern "C" void (*signal (int, void (*)(int)))(int);
-#else
-void (*signal ()) ();
-#endif
-
-int main() {
-int i;
-; return 0; }
-EOF
-if { (eval echo configure:1673: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- ac_cv_type_signal=void
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- ac_cv_type_signal=int
-fi
-rm -f conftest*
-fi
-
-echo "$ac_t""$ac_cv_type_signal" 1>&6
-cat >> confdefs.h <<EOF
-#define RETSIGTYPE $ac_cv_type_signal
-EOF
-
-
-echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:1692: checking whether time.h and sys/time.h may both be included" >&5
-if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1697 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#include <sys/time.h>
-#include <time.h>
-int main() {
-struct tm *tp;
-; return 0; }
-EOF
-if { (eval echo configure:1706: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- ac_cv_header_time=yes
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- ac_cv_header_time=no
-fi
-rm -f conftest*
-fi
-
-echo "$ac_t""$ac_cv_header_time" 1>&6
-if test $ac_cv_header_time = yes; then
- cat >> confdefs.h <<\EOF
-#define TIME_WITH_SYS_TIME 1
-EOF
-
-fi
-
-echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:1727: checking for sys/wait.h that is POSIX.1 compatible" >&5
-if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1732 "configure"
-#include "confdefs.h"
-#include <sys/types.h>
-#include <sys/wait.h>
-#ifndef WEXITSTATUS
-#define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
-#endif
-#ifndef WIFEXITED
-#define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
-#endif
-int main() {
-int s;
-wait (&s);
-s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
-; return 0; }
-EOF
-if { (eval echo configure:1748: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- ac_cv_header_sys_wait_h=yes
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- ac_cv_header_sys_wait_h=no
-fi
-rm -f conftest*
-fi
-
-echo "$ac_t""$ac_cv_header_sys_wait_h" 1>&6
-if test $ac_cv_header_sys_wait_h = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_SYS_WAIT_H 1
-EOF
-
-fi
-
-
-# Use -g on all systems but Linux where it upsets the dynamic X libraries.
-EXP_CFLAGS="$EXP_CFLAGS $EXP_CYGWIN_ALTTCL"
-
-echo $ac_n "checking if running Mach""... $ac_c" 1>&6
-echo "configure:1773: checking if running Mach" >&5
-mach=0
-case "${host}" in
- # Both Next and pure Mach behave identically with respect
- # to a few things, so just lump them together as "mach"
- *-*-mach*) mach=1 ;;
- *-*-next*) mach=1 ; next=1 ;;
-esac
-
-if test $mach -eq 1 ; then
- echo "$ac_t""yes" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-echo $ac_n "checking if running MachTen""... $ac_c" 1>&6
-echo "configure:1789: checking if running MachTen" >&5
-# yet another Mach clone
-if test -r /MachTen -a "$cross_compiling" != "yes" ; then
- echo "$ac_t""yes" 1>&6
- mach=1
-else
- echo "$ac_t""no" 1>&6
-fi
-
-echo $ac_n "checking if on Pyramid""... $ac_c" 1>&6
-echo "configure:1799: checking if on Pyramid" >&5
-if test -r /bin/pyr -a "$cross_compiling" != "yes" ; then
- echo "$ac_t""yes" 1>&6
- pyr=1
-else
- echo "$ac_t""no" 1>&6
- pyr=0
-fi
-
-echo $ac_n "checking if on Apollo""... $ac_c" 1>&6
-echo "configure:1809: checking if on Apollo" >&5
-if test -r /usr/apollo/bin -a "$cross_compiling" != "yes" ; then
- echo "$ac_t""yes" 1>&6
- apollo=1
-else
- echo "$ac_t""no" 1>&6
- apollo=0
-fi
-
-echo $ac_n "checking if on Interactive""... $ac_c" 1>&6
-echo "configure:1819: checking if on Interactive" >&5
-if test "x`(uname -s) 2>/dev/null`" = xIUNIX; then
- echo "$ac_t""yes" 1>&6
- iunix=1
-else
- echo "$ac_t""no" 1>&6
- iunix=0
-fi
-
-echo $ac_n "checking if stty reads stdout""... $ac_c" 1>&6
-echo "configure:1829: checking if stty reads stdout" >&5
-
-# On some systems stty can't be run in the background (svr4) or get it
-# wrong because they fail to complain (next, mach), so don't attempt
-# the test on some systems.
-
-stty_reads_stdout=""
-case "${host}" in
- *-*-solaris*) stty_reads_stdout=0 ;;
- *-*-irix*) stty_reads_stdout=0 ;;
- *-*-sco3.2v[45]*) stty_reads_stdout=1 ;;
- i[3456]86-*-sysv4.2MP) stty_reads_stdout=0 ;;
- i[3456]86-*-linux*) stty_reads_stdout=0 ;;
- # Not sure about old convex but 5.2 definitely reads from stdout
- c[12]-*-*) stty_reads_stdout=1 ;;
- *-*-aix[34]*) stty_reads_stdout=0 ;;
- *-*-hpux9*) stty_reads_stdout=0 ;;
- *-*-hpux10*) stty_reads_stdout=0 ;;
- *-*-hpux11*) stty_reads_stdout=0 ;;
- *-*-osf[234]*) stty_reads_stdout=0 ;;
- *-*-ultrix4.4) stty_reads_stdout=0 ;;
- *-*-dgux*) stty_reads_stdout=0 ;;
- *-*-cygwin*) stty_reads_stdout=0 ;;
-esac
-
-if test $mach -eq 1 ; then
- stty_reads_stdout=1
-fi
-if test $apollo -eq 1 ; then
- stty_reads_stdout=1
-fi
-if test $pyr -eq 1 ; then
- stty_reads_stdout=1
-fi
-
-# if we still don't know, test
-if test x"${stty_reads_stdout}" = x"" ; then
- /bin/stty > /dev/null 2> /dev/null
- if test $? -ne 0 ; then
- stty_reads_stdout=1
- else
- stty_reads_stdout=0
- fi
-fi
-
-if test ${stty_reads_stdout} -eq 1 ; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define STTY_READS_STDOUT 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-# Solaris 2.4 and later requires __EXTENSIONS__ in order to see all sorts
-# of traditional but nonstandard stuff in header files.
-echo $ac_n "checking if running Solaris""... $ac_c" 1>&6
-echo "configure:1887: checking if running Solaris" >&5
-solaris=0
-case "${host}" in
- *-*-solaris*) solaris=1;;
-esac
-
-if test $solaris -eq 1 ; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define SOLARIS 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-
-# On a few systems, libm.a is the same as libc.a
-# Don't bother to test against Tcl and Tk libs, they always include -lm
-echo $ac_n "checking for sin""... $ac_c" 1>&6
-echo "configure:1907: checking for sin" >&5
-if eval "test \"`echo '$''{'ac_cv_func_sin'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1912 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char sin(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char sin();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_sin) || defined (__stub___sin)
-choke me
-#else
-sin();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:1935: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_sin=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_sin=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'sin`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- :
-else
- echo "$ac_t""no" 1>&6
-LIBS="${LIBS} -lm"
-fi
-
-
-# On Interactive UNIX, -Xp must be added to LIBS in order to find strftime.
-# This test should really be done by Tcl. So just check Tcl's definition.
-# If defective, add to all three LIBS. (It's not actually necessary for
-# EXP_LIBS since -Xp will just be ignored the way that EXP_LIBS is used in
-# the Makefile, but we include it for consistency.)
-if test $iunix -eq 1 ; then
- EXP_LIBS=$LIBS
- LIBS=$EXP_AND_TCL_LIBS
- echo $ac_n "checking for strftime""... $ac_c" 1>&6
-echo "configure:1965: checking for strftime" >&5
-if eval "test \"`echo '$''{'ac_cv_func_strftime'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1970 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char strftime(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char strftime();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_strftime) || defined (__stub___strftime)
-choke me
-#else
-strftime();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:1993: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_strftime=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_strftime=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'strftime`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- :
-else
- echo "$ac_t""no" 1>&6
-
- EXP_LIBS="${LIBS} -Xp"
- EXP_AND_TCL_LIBS="${LIBS} -Xp"
- EXP_AND_TK_LIBS="${LIBS} -Xp"
-
-fi
-
- LIBS=EXP_LIBS
-fi
-
-#
-# Ok, lets find the tcl source trees so we can use the headers
-#
-
-#
-# Ok, lets find the tcl source trees so we can use the headers
-# Warning: transition of version 9 to 10 will break this algorithm
-# because 10 sorts before 9. We also look for just tcl. We have to
-# be careful that we don't match stuff like tclX by accident.
-# the alternative search directory is involked by --with-tclinclude
-#
-no_tcl=true
-echo $ac_n "checking for Tcl private headers""... $ac_c" 1>&6
-echo "configure:2033: checking for Tcl private headers" >&5
-# Check whether --with-tclinclude or --without-tclinclude was given.
-if test "${with_tclinclude+set}" = set; then
- withval="$with_tclinclude"
- with_tclinclude=${withval}
-fi
-
-if eval "test \"`echo '$''{'ac_cv_c_tclh'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
-
-# first check to see if --with-tclinclude was specified
-if test x"${with_tclinclude}" != x ; then
- if test -f ${with_tclinclude}/tclInt.h ; then
- ac_cv_c_tclh=`(cd ${with_tclinclude}; pwd)`
- elif test -f ${with_tclinclude}/generic/tclInt.h ; then
- ac_cv_c_tclh=`(cd ${with_tclinclude}/generic; pwd)`
- else
- { echo "configure: error: ${with_tclinclude} directory doesn't contain private headers" 1>&2; exit 1; }
- fi
-fi
-
-# next check if it came with Tcl configuration file
-if test x"${ac_cv_c_tclconfig}" != x ; then
- if test -f $ac_cv_c_tclconfig/../generic/tclInt.h ; then
- ac_cv_c_tclh=`(cd $ac_cv_c_tclconfig/../generic; pwd)`
- fi
-fi
-
-# next check in private source directory
-#
-# since ls returns lowest version numbers first, reverse its output
-
-if test x"${ac_cv_c_tclh}" = x ; then
- for i in \
- ${srcdir}/../tcl \
- `ls -dr ${srcdir}/../tcl[7-9].[0-9] 2>/dev/null` \
- ${srcdir}/../../tcl \
- `ls -dr ${srcdir}/../../tcl[7-9].[0-9] 2>/dev/null` \
- ${srcdir}/../../../tcl \
- `ls -dr ${srcdir}/../../../tcl[7-9].[0-9] 2>/dev/null ` ; do
- if test -f $i/generic/tclInt.h ; then
- ac_cv_c_tclh=`(cd $i/generic; pwd)`
- break
- fi
- done
-fi
-
-# finally check in a few common install locations
-#
-# since ls returns lowest version numbers first, reverse its output
-
-if test x"${ac_cv_c_tclh}" = x ; then
- for i in \
- `ls -dr /usr/local/src/tcl[7-9].[0-9] 2>/dev/null` \
- `ls -dr /usr/local/lib/tcl[7-9].[0-9] 2>/dev/null` \
- /usr/local/src/tcl \
- /usr/local/lib/tcl \
- ${prefix}/include ; do
- if test -f $i/generic/tclInt.h ; then
- ac_cv_c_tclh=`(cd $i/generic; pwd)`
- break
- fi
- done
-fi
-
-# see if one is installed
-if test x"${ac_cv_c_tclh}" = x ; then
- ac_safe=`echo "tclInt.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for tclInt.h""... $ac_c" 1>&6
-echo "configure:2103: checking for tclInt.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2108 "configure"
-#include "confdefs.h"
-#include <tclInt.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2113: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_cv_c_tclh=installed
-else
- echo "$ac_t""no" 1>&6
-ac_cv_c_tclh=""
-fi
-
-fi
-
-fi
-
-if test x"${ac_cv_c_tclh}" = x ; then
- TCLHDIR="# no Tcl private headers found"
- TCLHDIRDASHI="# no Tcl private headers found"
- { echo "configure: error: Can't find Tcl private headers" 1>&2; exit 1; }
-fi
-if test x"${ac_cv_c_tclh}" != x ; then
- no_tcl=""
- if test x"${ac_cv_c_tclh}" = x"installed" ; then
- echo "$ac_t""is installed" 1>&6
- TCLHDIR=""
- TCLHDIRDASHI=""
- TCL_LIBRARY=""
- else
- echo "$ac_t""found in ${ac_cv_c_tclh}" 1>&6
- # this hack is cause the TCLHDIR won't print if there is a "-I" in it.
- TCLHDIR="${ac_cv_c_tclh}"
- TCLHDIRDASHI="-I${ac_cv_c_tclh}"
- TCL_LIBRARY=`echo $TCLHDIR | sed -e 's/generic//'`library
- fi
-fi
-
-
-
-
-
-if test x"$no_tcl" = x"true" ; then
- echo " ERROR: Can't find Tcl headers or library."
- echo " See README for information on how to obtain Tcl."
- echo " If Tcl is installed, see INSTALL on how to tell"
- echo " configure where Tcl is installed."
- exit 1
-fi
-
-echo $ac_n "checking for Itcl private headers. srcdir=${srcdir}""... $ac_c" 1>&6
-echo "configure:2173: checking for Itcl private headers. srcdir=${srcdir}" >&5
-if test x"${ac_cv_c_itclh}" = x ; then
- for i in ${srcdir}/../itcl ${srcdir}/../../itcl ${srcdir}/../../../itcl ; do
- if test -f $i/itcl/generic/itcl.h ; then
- ac_cv_c_itclh=`(cd $i/itcl/generic; pwd)`
- break
- fi
- done
-fi
-if test x"${ac_cv_c_itclh}" = x ; then
- ITCLHDIR="# no Itcl private headers found"
- ITCLLIB="# no Itcl private headers found"
- echo "configure: warning: Can't find Itcl private headers" 1>&2
- no_itcl=true
-else
- ITCLHDIR="-I${ac_cv_c_itclh}"
-# should always be here
- ITCLLIB="../itcl/src/libitcl.a"
-fi
-
-
-
-
-
-# have to whether we're generating shared libs before configuring debugger
-echo $ac_n "checking if generating shared or nonshared library""... $ac_c" 1>&6
-echo "configure:2199: checking if generating shared or nonshared library" >&5
-# Check whether --enable-shared or --disable-shared was given.
-if test "${enable_shared+set}" = set; then
- enableval="$enable_shared"
- enable_shared=$enableval
-else
- enable_shared=no
-fi
-
-if test "$enable_shared" = "yes" && test "x${TCL_SHLIB_SUFFIX}" != "x" ; then
- echo "$ac_t""both shared and unshared" 1>&6
-else
- echo "$ac_t""unshared" 1>&6
-fi
-
-# Now that we've found the Tcl sources, configure the debugger
-# this is a little tricky because it has its own configure script
-# which produces a Makefile and cf file. We only want the cf file,
-# so switch to a temporary directory and run the debugger's configure.
-# Then save the cf file and delete the rest.
-#
-# Incidentally, the debugger can't depend on Expect's cf file, because
-# the debugger is designed to be independent of Expect.
-#
-
-test -n "$verbose" && echo "configuring Tcl debugger"
-tmpdir=./Dbg$$
-mkdir ${tmpdir}
-
-if test "${enable_shared}" = "yes"; then
- dbg_config_flags='--enable-shared'
-else
- dbg_config_flags='--disable-shared'
-fi
-# (cd;pwd) in next several commands converts relative dirs to absolute.
-# This is required because the debugger src is at a different level in
-# the filesystem than Expect src (where we are presently), thereby
-# making the relative pathnames incorrect.
-if test "x$with_tclconfig" != "x" ; then
- dbg_config_flags="$dbg_config_flags --with-tclconfig=`(cd ${with_tclconfig}; pwd)`"
-fi
-if test "x$with_tcllibdir" != "x" ; then
- dbg_config_flags="$dbg_config_flags --with-tcllibdir=`(cd ${with_tcllibdir}; pwd)`"
-fi
-if test "x$with_tcllib" != "x" ; then
- dbg_config_flags="$dbg_config_flags --with-tcllib=`(cd ${with_tcllib}; pwd)`"
-fi
-if test "x$with_tclinclude" != "x" ; then
- dbg_config_flags="$dbg_config_flags --with-tclinclude=`(cd ${with_tclinclude}; pwd)`"
-fi
-case "$cache_file" in
- /*)
- dbg_config_flags="$dbg_config_flags --cache-file=$cache_file"
- ;;
- *)
- dbg_config_flags="$dbg_config_flags --cache-file=../$cache_file"
- ;;
-esac
-
-cp ${srcdir}/Dbgconfigure ${srcdir}/Dbg.h ${srcdir}/Dbg_cf.h.in ${srcdir}/install-sh ${tmpdir}
-cp $srcdir/DbgMkfl.in ${tmpdir}/Makefile.in
- (cd $tmpdir; ${CONFIG_SHELL-/bin/sh} Dbgconfigure --with-tclinclude=`echo ${TCLHDIR} | sed -e 's/-I//'` $dbg_config_flags)
-cp ${tmpdir}/Dbg_cf.h .
-rm -rf $tmpdir
-test -n "$verbose" && echo "configured Tcl debugger"
-
-# some people would complain if this explanation wasn't provided...
-
-echo "Begin tests for function/library dependencies. Tests may be repeated"
-echo "up to three times. First test is for building Expect's shared library."
-echo "Second set is for building with Tcl. Third is for building with Tk."
-
-######################################################################
-# required by Sequent ptx2
-unset ac_cv_func_gethostname
-echo $ac_n "checking for gethostname""... $ac_c" 1>&6
-echo "configure:2275: checking for gethostname" >&5
-if eval "test \"`echo '$''{'ac_cv_func_gethostname'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2280 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char gethostname(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char gethostname();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_gethostname) || defined (__stub___gethostname)
-choke me
-#else
-gethostname();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:2303: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_gethostname=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_gethostname=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'gethostname`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- gethostname=1
-else
- echo "$ac_t""no" 1>&6
-gethostname=0
-fi
-
-if test $gethostname -eq 0 ; then
- unset ac_cv_lib_inet_gethostname
- echo $ac_n "checking for gethostname in -linet""... $ac_c" 1>&6
-echo "configure:2326: checking for gethostname in -linet" >&5
-ac_lib_var=`echo inet'_'gethostname | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_save_LIBS="$LIBS"
-LIBS="-linet $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 2334 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char gethostname();
-
-int main() {
-gethostname()
-; return 0; }
-EOF
-if { (eval echo configure:2345: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- LIBS="$LIBS -linet"
-else
- echo "$ac_t""no" 1>&6
-fi
-
-fi
-# save results and retry for Tcl
-EXP_LIBS=$LIBS
-LIBS=$EXP_AND_TCL_LIBS
-unset ac_cv_func_gethostname
-echo $ac_n "checking for gethostname""... $ac_c" 1>&6
-echo "configure:2371: checking for gethostname" >&5
-if eval "test \"`echo '$''{'ac_cv_func_gethostname'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2376 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char gethostname(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char gethostname();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_gethostname) || defined (__stub___gethostname)
-choke me
-#else
-gethostname();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:2399: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_gethostname=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_gethostname=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'gethostname`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- gethostname=1
-else
- echo "$ac_t""no" 1>&6
-gethostname=0
-fi
-
-if test $gethostname -eq 0 ; then
- unset ac_cv_lib_inet_gethostname
- echo $ac_n "checking for gethostname in -linet""... $ac_c" 1>&6
-echo "configure:2422: checking for gethostname in -linet" >&5
-ac_lib_var=`echo inet'_'gethostname | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_save_LIBS="$LIBS"
-LIBS="-linet $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 2430 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char gethostname();
-
-int main() {
-gethostname()
-; return 0; }
-EOF
-if { (eval echo configure:2441: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- LIBS="$LIBS -linet"
-else
- echo "$ac_t""no" 1>&6
-fi
-
-fi
-# save Tcl results and retry for Tk
-EXP_AND_TCL_LIBS=$LIBS
-LIBS=$EXP_AND_TK_LIBS
-unset ac_cv_func_gethostname
-echo $ac_n "checking for gethostname""... $ac_c" 1>&6
-echo "configure:2467: checking for gethostname" >&5
-if eval "test \"`echo '$''{'ac_cv_func_gethostname'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2472 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char gethostname(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char gethostname();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_gethostname) || defined (__stub___gethostname)
-choke me
-#else
-gethostname();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:2495: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_gethostname=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_gethostname=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'gethostname`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- gethostname=1
-else
- echo "$ac_t""no" 1>&6
-gethostname=0
-fi
-
-if test $gethostname -eq 0 ; then
- unset ac_cv_lib_inet_gethostname
- echo $ac_n "checking for gethostname in -linet""... $ac_c" 1>&6
-echo "configure:2518: checking for gethostname in -linet" >&5
-ac_lib_var=`echo inet'_'gethostname | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_save_LIBS="$LIBS"
-LIBS="-linet $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 2526 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char gethostname();
-
-int main() {
-gethostname()
-; return 0; }
-EOF
-if { (eval echo configure:2537: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- LIBS="$LIBS -linet"
-else
- echo "$ac_t""no" 1>&6
-fi
-
-fi
-# save Tk results and reset for Expect
-EXP_AND_TK_LIBS=$LIBS
-LIBS=$EXP_LIBS
-
-######################################################################
-# required by Fischman's ISC 4.0
-unset ac_cv_func_socket
-echo $ac_n "checking for socket""... $ac_c" 1>&6
-echo "configure:2566: checking for socket" >&5
-if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2571 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char socket(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char socket();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_socket) || defined (__stub___socket)
-choke me
-#else
-socket();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:2594: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_socket=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_socket=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'socket`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- socket=1
-else
- echo "$ac_t""no" 1>&6
-socket=0
-fi
-
-if test $socket -eq 0 ; then
- unset ac_cv_lib_inet_socket
- echo $ac_n "checking for socket in -linet""... $ac_c" 1>&6
-echo "configure:2617: checking for socket in -linet" >&5
-ac_lib_var=`echo inet'_'socket | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_save_LIBS="$LIBS"
-LIBS="-linet $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 2625 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char socket();
-
-int main() {
-socket()
-; return 0; }
-EOF
-if { (eval echo configure:2636: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- LIBS="$LIBS -linet"
-else
- echo "$ac_t""no" 1>&6
-fi
-
-fi
-# save results and retry for Tcl
-EXP_LIBS=$LIBS
-LIBS=$EXP_AND_TCL_LIBS
-unset ac_cv_func_socket
-echo $ac_n "checking for socket""... $ac_c" 1>&6
-echo "configure:2662: checking for socket" >&5
-if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2667 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char socket(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char socket();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_socket) || defined (__stub___socket)
-choke me
-#else
-socket();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:2690: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_socket=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_socket=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'socket`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- socket=1
-else
- echo "$ac_t""no" 1>&6
-socket=0
-fi
-
-if test $socket -eq 0 ; then
- unset ac_cv_lib_inet_socket
- echo $ac_n "checking for socket in -linet""... $ac_c" 1>&6
-echo "configure:2713: checking for socket in -linet" >&5
-ac_lib_var=`echo inet'_'socket | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_save_LIBS="$LIBS"
-LIBS="-linet $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 2721 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char socket();
-
-int main() {
-socket()
-; return 0; }
-EOF
-if { (eval echo configure:2732: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- LIBS="$LIBS -linet"
-else
- echo "$ac_t""no" 1>&6
-fi
-
-fi
-# save Tcl results and retry for Tk
-EXP_AND_TCL_LIBS=$LIBS
-LIBS=$EXP_AND_TK_LIBS
-unset ac_cv_func_socket
-echo $ac_n "checking for socket""... $ac_c" 1>&6
-echo "configure:2758: checking for socket" >&5
-if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2763 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char socket(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char socket();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_socket) || defined (__stub___socket)
-choke me
-#else
-socket();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:2786: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_socket=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_socket=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'socket`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- socket=1
-else
- echo "$ac_t""no" 1>&6
-socket=0
-fi
-
-if test $socket -eq 0 ; then
- unset ac_cv_lib_inet_socket
- echo $ac_n "checking for socket in -linet""... $ac_c" 1>&6
-echo "configure:2809: checking for socket in -linet" >&5
-ac_lib_var=`echo inet'_'socket | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_save_LIBS="$LIBS"
-LIBS="-linet $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 2817 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char socket();
-
-int main() {
-socket()
-; return 0; }
-EOF
-if { (eval echo configure:2828: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- LIBS="$LIBS -linet"
-else
- echo "$ac_t""no" 1>&6
-fi
-
-fi
-# save Tk results and reset for Expect
-EXP_AND_TK_LIBS=$LIBS
-LIBS=$EXP_LIBS
-
-######################################################################
-unset ac_cv_func_select
-echo $ac_n "checking for select""... $ac_c" 1>&6
-echo "configure:2856: checking for select" >&5
-if eval "test \"`echo '$''{'ac_cv_func_select'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2861 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char select(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char select();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_select) || defined (__stub___select)
-choke me
-#else
-select();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:2884: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_select=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_select=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'select`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- select=1
-else
- echo "$ac_t""no" 1>&6
-select=0
-fi
-
-if test $select -eq 0 ; then
- unset ac_cv_lib_inet_select
- echo $ac_n "checking for select in -linet""... $ac_c" 1>&6
-echo "configure:2907: checking for select in -linet" >&5
-ac_lib_var=`echo inet'_'select | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_save_LIBS="$LIBS"
-LIBS="-linet $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 2915 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char select();
-
-int main() {
-select()
-; return 0; }
-EOF
-if { (eval echo configure:2926: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- LIBS="$LIBS -linet"
-else
- echo "$ac_t""no" 1>&6
-fi
-
-fi
-# save results and retry for Tcl
-EXP_LIBS=$LIBS
-LIBS=$EXP_AND_TCL_LIBS
-unset ac_cv_func_select
-echo $ac_n "checking for select""... $ac_c" 1>&6
-echo "configure:2952: checking for select" >&5
-if eval "test \"`echo '$''{'ac_cv_func_select'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2957 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char select(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char select();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_select) || defined (__stub___select)
-choke me
-#else
-select();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:2980: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_select=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_select=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'select`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- select=1
-else
- echo "$ac_t""no" 1>&6
-select=0
-fi
-
-if test $select -eq 0 ; then
- unset ac_cv_lib_inet_select
- echo $ac_n "checking for select in -linet""... $ac_c" 1>&6
-echo "configure:3003: checking for select in -linet" >&5
-ac_lib_var=`echo inet'_'select | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_save_LIBS="$LIBS"
-LIBS="-linet $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 3011 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char select();
-
-int main() {
-select()
-; return 0; }
-EOF
-if { (eval echo configure:3022: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- LIBS="$LIBS -linet"
-else
- echo "$ac_t""no" 1>&6
-fi
-
-fi
-# save Tcl results and retry for Tk
-EXP_AND_TCL_LIBS=$LIBS
-LIBS=$EXP_AND_TK_LIBS
-unset ac_cv_func_select
-echo $ac_n "checking for select""... $ac_c" 1>&6
-echo "configure:3048: checking for select" >&5
-if eval "test \"`echo '$''{'ac_cv_func_select'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3053 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char select(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char select();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_select) || defined (__stub___select)
-choke me
-#else
-select();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:3076: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_select=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_select=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'select`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- select=1
-else
- echo "$ac_t""no" 1>&6
-select=0
-fi
-
-if test $select -eq 0 ; then
- unset ac_cv_lib_inet_select
- echo $ac_n "checking for select in -linet""... $ac_c" 1>&6
-echo "configure:3099: checking for select in -linet" >&5
-ac_lib_var=`echo inet'_'select | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_save_LIBS="$LIBS"
-LIBS="-linet $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 3107 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char select();
-
-int main() {
-select()
-; return 0; }
-EOF
-if { (eval echo configure:3118: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- LIBS="$LIBS -linet"
-else
- echo "$ac_t""no" 1>&6
-fi
-
-fi
-# save Tk results and reset for Expect
-EXP_AND_TK_LIBS=$LIBS
-LIBS=$EXP_LIBS
-
-######################################################################
-unset ac_cv_func_getpseudotty
-echo $ac_n "checking for getpseudotty""... $ac_c" 1>&6
-echo "configure:3146: checking for getpseudotty" >&5
-if eval "test \"`echo '$''{'ac_cv_func_getpseudotty'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3151 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char getpseudotty(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char getpseudotty();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_getpseudotty) || defined (__stub___getpseudotty)
-choke me
-#else
-getpseudotty();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:3174: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_getpseudotty=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_getpseudotty=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'getpseudotty`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- getpseudotty=1
-else
- echo "$ac_t""no" 1>&6
-getpseudotty=0
-fi
-
-if test $getpseudotty -eq 0 ; then
- unset ac_cv_lib_seq_getpseudotty
- echo $ac_n "checking for getpseudotty in -lseq""... $ac_c" 1>&6
-echo "configure:3197: checking for getpseudotty in -lseq" >&5
-ac_lib_var=`echo seq'_'getpseudotty | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_save_LIBS="$LIBS"
-LIBS="-lseq $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 3205 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char getpseudotty();
-
-int main() {
-getpseudotty()
-; return 0; }
-EOF
-if { (eval echo configure:3216: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_lib=HAVE_LIB`echo seq | sed -e 's/[^a-zA-Z0-9_]/_/g' \
- -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_lib 1
-EOF
-
- LIBS="-lseq $LIBS"
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-fi
-# save results and retry for Tcl
-EXP_LIBS=$LIBS
-LIBS=$EXP_AND_TCL_LIBS
-unset ac_cv_func_getpseudotty
-echo $ac_n "checking for getpseudotty""... $ac_c" 1>&6
-echo "configure:3249: checking for getpseudotty" >&5
-if eval "test \"`echo '$''{'ac_cv_func_getpseudotty'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3254 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char getpseudotty(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char getpseudotty();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_getpseudotty) || defined (__stub___getpseudotty)
-choke me
-#else
-getpseudotty();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:3277: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_getpseudotty=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_getpseudotty=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'getpseudotty`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- getpseudotty=1
-else
- echo "$ac_t""no" 1>&6
-getpseudotty=0
-fi
-
-if test $getpseudotty -eq 0 ; then
- unset ac_cv_lib_seq_getpseudotty
- echo $ac_n "checking for getpseudotty in -lseq""... $ac_c" 1>&6
-echo "configure:3300: checking for getpseudotty in -lseq" >&5
-ac_lib_var=`echo seq'_'getpseudotty | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_save_LIBS="$LIBS"
-LIBS="-lseq $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 3308 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char getpseudotty();
-
-int main() {
-getpseudotty()
-; return 0; }
-EOF
-if { (eval echo configure:3319: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_lib=HAVE_LIB`echo seq | sed -e 's/[^a-zA-Z0-9_]/_/g' \
- -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_lib 1
-EOF
-
- LIBS="-lseq $LIBS"
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-fi
-# save Tcl results and retry for Tk
-EXP_AND_TCL_LIBS=$LIBS
-LIBS=$EXP_AND_TK_LIBS
-unset ac_cv_func_getpseudotty
-echo $ac_n "checking for getpseudotty""... $ac_c" 1>&6
-echo "configure:3352: checking for getpseudotty" >&5
-if eval "test \"`echo '$''{'ac_cv_func_getpseudotty'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3357 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char getpseudotty(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char getpseudotty();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_getpseudotty) || defined (__stub___getpseudotty)
-choke me
-#else
-getpseudotty();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:3380: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_getpseudotty=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_getpseudotty=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'getpseudotty`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- getpseudotty=1
-else
- echo "$ac_t""no" 1>&6
-getpseudotty=0
-fi
-
-if test $getpseudotty -eq 0 ; then
- unset ac_cv_lib_seq_getpseudotty
- echo $ac_n "checking for getpseudotty in -lseq""... $ac_c" 1>&6
-echo "configure:3403: checking for getpseudotty in -lseq" >&5
-ac_lib_var=`echo seq'_'getpseudotty | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_save_LIBS="$LIBS"
-LIBS="-lseq $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 3411 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char getpseudotty();
-
-int main() {
-getpseudotty()
-; return 0; }
-EOF
-if { (eval echo configure:3422: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_lib=HAVE_LIB`echo seq | sed -e 's/[^a-zA-Z0-9_]/_/g' \
- -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_lib 1
-EOF
-
- LIBS="-lseq $LIBS"
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-fi
-# save Tk results and reset for Expect
-EXP_AND_TK_LIBS=$LIBS
-LIBS=$EXP_LIBS
-
-######################################################################
-# Check for FreeBSD/NetBSD openpty()
-# CYGNUS LOCAL: Don't do this on Linux. Alpha Linux Red Hat 4.2 has
-# openpty, but it doesn't work correctly.
-case "${host}" in
-*-*-linux*) ;;
-*-*-cygwin*)
- EXP_AND_TCL_LIBS="$EXP_AND_TCL_LIBS -luser32" ;;
-*)
- unset ac_cv_func_openpty
- echo $ac_n "checking for openpty""... $ac_c" 1>&6
-echo "configure:3465: checking for openpty" >&5
-if eval "test \"`echo '$''{'ac_cv_func_openpty'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3470 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char openpty(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char openpty();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_openpty) || defined (__stub___openpty)
-choke me
-#else
-openpty();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:3493: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_openpty=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_openpty=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'openpty`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- openpty=1
-else
- echo "$ac_t""no" 1>&6
-openpty=0
-fi
-
- if test $openpty -eq 0 ; then
- unset ac_cv_lib_util_openpty
- echo $ac_n "checking for openpty in -lutil""... $ac_c" 1>&6
-echo "configure:3516: checking for openpty in -lutil" >&5
-ac_lib_var=`echo util'_'openpty | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_save_LIBS="$LIBS"
-LIBS="-lutil $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 3524 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char openpty();
-
-int main() {
-openpty()
-; return 0; }
-EOF
-if { (eval echo configure:3535: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
-
- # we only need to define OPENPTY once, but since we are overriding
- # the default behavior, we must also handle augment LIBS too.
- # This needn't be done in the 2nd and 3rd tests.
- cat >> confdefs.h <<\EOF
-#define HAVE_OPENPTY 1
-EOF
-
- LIBS="$LIBS -lutil"
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
- fi
- # save results and retry for Tcl
- EXP_LIBS=$LIBS
- LIBS=$EXP_AND_TCL_LIBS
- unset ac_cv_func_openpty
- echo $ac_n "checking for openpty""... $ac_c" 1>&6
-echo "configure:3570: checking for openpty" >&5
-if eval "test \"`echo '$''{'ac_cv_func_openpty'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3575 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char openpty(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char openpty();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_openpty) || defined (__stub___openpty)
-choke me
-#else
-openpty();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:3598: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_openpty=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_openpty=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'openpty`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- openpty=1
-else
- echo "$ac_t""no" 1>&6
-openpty=0
-fi
-
- if test $openpty -eq 0 ; then
- unset ac_cv_lib_util_openpty
- echo $ac_n "checking for openpty in -lutil""... $ac_c" 1>&6
-echo "configure:3621: checking for openpty in -lutil" >&5
-ac_lib_var=`echo util'_'openpty | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_save_LIBS="$LIBS"
-LIBS="-lutil $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 3629 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char openpty();
-
-int main() {
-openpty()
-; return 0; }
-EOF
-if { (eval echo configure:3640: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
-
- cat >> confdefs.h <<\EOF
-#define HAVE_OPENPTY 1
-EOF
-
- LIBS="$LIBS -lutil"
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
- fi
- # save Tcl results and retry for Tk
- EXP_AND_TCL_LIBS=$LIBS
- LIBS=$EXP_AND_TK_LIBS
- unset ac_cv_func_openpty
- echo $ac_n "checking for openpty""... $ac_c" 1>&6
-echo "configure:3672: checking for openpty" >&5
-if eval "test \"`echo '$''{'ac_cv_func_openpty'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3677 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char openpty(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char openpty();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_openpty) || defined (__stub___openpty)
-choke me
-#else
-openpty();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:3700: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_openpty=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_openpty=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'openpty`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- openpty=1
-else
- echo "$ac_t""no" 1>&6
-openpty=0
-fi
-
- if test $openpty -eq 0 ; then
- unset ac_cv_lib_util_openpty
- echo $ac_n "checking for openpty in -lutil""... $ac_c" 1>&6
-echo "configure:3723: checking for openpty in -lutil" >&5
-ac_lib_var=`echo util'_'openpty | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_save_LIBS="$LIBS"
-LIBS="-lutil $LIBS"
-cat > conftest.$ac_ext <<EOF
-#line 3731 "configure"
-#include "confdefs.h"
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char openpty();
-
-int main() {
-openpty()
-; return 0; }
-EOF
-if { (eval echo configure:3742: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_lib_$ac_lib_var=no"
-fi
-rm -f conftest*
-LIBS="$ac_save_LIBS"
-
-fi
-if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
- echo "$ac_t""yes" 1>&6
-
- cat >> confdefs.h <<\EOF
-#define HAVE_OPENPTY 1
-EOF
-
- LIBS="$LIBS -lutil"
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
- fi
- # save Tk results and reset for Expect
- EXP_AND_TK_LIBS=$LIBS
- LIBS=$EXP_LIBS
-;;
-esac
-
-######################################################################
-# End of library/func checking
-######################################################################
-
-######################################################################
-#
-# Look for various header files
-#
-ac_safe=`echo "sys/sysmacros.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for sys/sysmacros.h""... $ac_c" 1>&6
-echo "configure:3785: checking for sys/sysmacros.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3790 "configure"
-#include "confdefs.h"
-#include <sys/sysmacros.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3795: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_SYSMACROS_H 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-ac_safe=`echo "stdlib.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for stdlib.h""... $ac_c" 1>&6
-echo "configure:3821: checking for stdlib.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3826 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3831: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- :
-else
- echo "$ac_t""no" 1>&6
-cat >> confdefs.h <<\EOF
-#define NO_STDLIB_H 1
-EOF
-
-fi
-
-
-#
-# Look for inttypes.h. Sometimes there are data type conflicts
-# with sys/types.h, so we have to use our own special test.
-#
-echo $ac_n "checking for inttypes.h""... $ac_c" 1>&6
-echo "configure:3862: checking for inttypes.h" >&5
-if eval "test \"`echo '$''{'ac_cv_inttypes_h'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3867 "configure"
-#include "confdefs.h"
-
- #include <sys/types.h>
- #include <inttypes.h>
-int main() {
-
- int16_t x = 0;
-
-; return 0; }
-EOF
-if { (eval echo configure:3878: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- ac_cv_inttypes_h="yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- ac_cv_inttypes_h="no"
-fi
-rm -f conftest*
-fi
-
-echo "$ac_t""$ac_cv_inttypes_h" 1>&6
-if test x"${ac_cv_inttypes_h}" = x"yes"; then
- cat >> confdefs.h <<\EOF
-#define HAVE_INTTYPES_H 1
-EOF
-
-fi
-
-
-# Oddly, some systems have stdarg but don't support prototypes
-# Tcl avoids the whole issue by not using stdarg on UNIX at all!
-
-ac_safe=`echo "varargs.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for varargs.h""... $ac_c" 1>&6
-echo "configure:3904: checking for varargs.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3909 "configure"
-#include "confdefs.h"
-#include <varargs.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3914: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_VARARGS_H 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-ac_safe=`echo "unistd.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for unistd.h""... $ac_c" 1>&6
-echo "configure:3940: checking for unistd.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3945 "configure"
-#include "confdefs.h"
-#include <unistd.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3950: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_UNISTD_H 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-ac_safe=`echo "sys/stropts.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for sys/stropts.h""... $ac_c" 1>&6
-echo "configure:3976: checking for sys/stropts.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 3981 "configure"
-#include "confdefs.h"
-#include <sys/stropts.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3986: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_STROPTS_H 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-ac_safe=`echo "sys/sysconfig.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for sys/sysconfig.h""... $ac_c" 1>&6
-echo "configure:4012: checking for sys/sysconfig.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 4017 "configure"
-#include "confdefs.h"
-#include <sys/sysconfig.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4022: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_SYSCONF_H 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-ac_safe=`echo "sys/fcntl.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for sys/fcntl.h""... $ac_c" 1>&6
-echo "configure:4048: checking for sys/fcntl.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 4053 "configure"
-#include "confdefs.h"
-#include <sys/fcntl.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4058: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_SYS_FCNTL_H 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-ac_safe=`echo "sys/select.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for sys/select.h""... $ac_c" 1>&6
-echo "configure:4084: checking for sys/select.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 4089 "configure"
-#include "confdefs.h"
-#include <sys/select.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4094: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_SYS_SELECT_H 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-ac_safe=`echo "sys/time.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for sys/time.h""... $ac_c" 1>&6
-echo "configure:4120: checking for sys/time.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 4125 "configure"
-#include "confdefs.h"
-#include <sys/time.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4130: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_SYS_TIME_H 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-ac_safe=`echo "sys/ptem.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for sys/ptem.h""... $ac_c" 1>&6
-echo "configure:4156: checking for sys/ptem.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 4161 "configure"
-#include "confdefs.h"
-#include <sys/ptem.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4166: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_SYS_PTEM_H 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-ac_safe=`echo "sys/strredir.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for sys/strredir.h""... $ac_c" 1>&6
-echo "configure:4192: checking for sys/strredir.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 4197 "configure"
-#include "confdefs.h"
-#include <sys/strredir.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4202: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_STRREDIR_H 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-ac_safe=`echo "sys/strpty.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for sys/strpty.h""... $ac_c" 1>&6
-echo "configure:4228: checking for sys/strpty.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 4233 "configure"
-#include "confdefs.h"
-#include <sys/strpty.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4238: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_STRPTY_H 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-
-
-echo $ac_n "checking for sys/bsdtypes.h""... $ac_c" 1>&6
-echo "configure:4265: checking for sys/bsdtypes.h" >&5
-if test "ISC_${ISC}" = "ISC_1" ; then
- echo "$ac_t""yes" 1>&6
- # if on ISC 1, we need <sys/bsdtypes.h> to get FD_SET macros
- for ac_hdr in sys/bsdtypes.h
-do
-ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4273: checking for $ac_hdr" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 4278 "configure"
-#include "confdefs.h"
-#include <$ac_hdr>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4283: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_hdr 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-done
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-#
-# Look for functions that may be missing
-#
-echo $ac_n "checking for memmove""... $ac_c" 1>&6
-echo "configure:4317: checking for memmove" >&5
-if eval "test \"`echo '$''{'ac_cv_func_memmove'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 4322 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char memmove(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char memmove();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_memmove) || defined (__stub___memmove)
-choke me
-#else
-memmove();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:4345: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_memmove=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_memmove=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'memmove`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_MEMMOVE 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-echo $ac_n "checking for sysconf""... $ac_c" 1>&6
-echo "configure:4368: checking for sysconf" >&5
-if eval "test \"`echo '$''{'ac_cv_func_sysconf'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 4373 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char sysconf(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char sysconf();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_sysconf) || defined (__stub___sysconf)
-choke me
-#else
-sysconf();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:4396: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_sysconf=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_sysconf=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'sysconf`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_SYSCONF 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-echo $ac_n "checking for strftime""... $ac_c" 1>&6
-echo "configure:4419: checking for strftime" >&5
-if eval "test \"`echo '$''{'ac_cv_func_strftime'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 4424 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char strftime(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char strftime();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_strftime) || defined (__stub___strftime)
-choke me
-#else
-strftime();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:4447: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_strftime=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_strftime=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'strftime`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_STRFTIME 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-echo $ac_n "checking for strchr""... $ac_c" 1>&6
-echo "configure:4470: checking for strchr" >&5
-if eval "test \"`echo '$''{'ac_cv_func_strchr'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 4475 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char strchr(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char strchr();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_strchr) || defined (__stub___strchr)
-choke me
-#else
-strchr();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:4498: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_strchr=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_strchr=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'strchr`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_STRCHR 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-echo $ac_n "checking for timezone""... $ac_c" 1>&6
-echo "configure:4521: checking for timezone" >&5
-if eval "test \"`echo '$''{'ac_cv_func_timezone'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 4526 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char timezone(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char timezone();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_timezone) || defined (__stub___timezone)
-choke me
-#else
-timezone();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:4549: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_timezone=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_timezone=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'timezone`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_TIMEZONE 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-
-# dnl check for memcpy by hand
-# because Unixware 2.0 handles it specially and refuses to compile
-# autoconf's automatic test that is a call with no arguments
-echo $ac_n "checking for memcpy""... $ac_c" 1>&6
-echo "configure:4576: checking for memcpy" >&5
-cat > conftest.$ac_ext <<EOF
-#line 4578 "configure"
-#include "confdefs.h"
-
-int main() {
-
-char *s1, *s2;
-memcpy(s1,s2,0);
-
-; return 0; }
-EOF
-if { (eval echo configure:4588: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_MEMCPY 1
-EOF
-
-
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- echo "$ac_t""no" 1>&6
-
-fi
-rm -f conftest*
-
-# Some systems only define WNOHANG if _POSIX_SOURCE is defined
-# The following merely tests that sys/wait.h can be included
-# and if so that WNOHANG is not defined. The only place I've
-# seen this is ISC.
-echo $ac_n "checking if WNOHANG requires _POSIX_SOURCE""... $ac_c" 1>&6
-echo "configure:4610: checking if WNOHANG requires _POSIX_SOURCE" >&5
-if test "$cross_compiling" = yes; then
- case "${host}" in
- *-*-cygwin*) echo "$ac_t""no" 1>&6 ;;
- *) { echo "configure: error: Expect can't be cross compiled" 1>&2; exit 1; } ;;
- esac
-
-else
- cat > conftest.$ac_ext <<EOF
-#line 4619 "configure"
-#include "confdefs.h"
-
-#include <sys/wait.h>
-main() {
-#ifndef WNOHANG
- return 0;
-#else
- return 1;
-#endif
-}
-EOF
-if { (eval echo configure:4631: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define WNOHANG_REQUIRES_POSIX_SOURCE 1
-EOF
-
-
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -fr conftest*
- echo "$ac_t""no" 1>&6
-
-fi
-rm -fr conftest*
-fi
-
-
-echo $ac_n "checking if any value exists for WNOHANG""... $ac_c" 1>&6
-echo "configure:4651: checking if any value exists for WNOHANG" >&5
-rm -rf wnohang
-if test "$cross_compiling" = yes; then
- case "${host}" in
- *-*-cygwin*) echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define WNOHANG_BACKUP_VALUE 1
-EOF
- ;;
- *) { echo "configure: error: Expect can't be cross compiled" 1>&2; exit 1; } ;;
- esac
-
-else
- cat > conftest.$ac_ext <<EOF
-#line 4665 "configure"
-#include "confdefs.h"
-
-#include <stdio.h>
-#include <sys/wait.h>
-main() {
-#ifdef WNOHANG
- FILE *fp = fopen("wnohang","w");
- fprintf(fp,"%d",WNOHANG);
- fclose(fp);
- return 0;
-#else
- return 1;
-#endif
-}
-EOF
-if { (eval echo configure:4681: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<EOF
-#define WNOHANG_BACKUP_VALUE `cat wnohang`
-EOF
-
- rm -f wnohang
-
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -fr conftest*
- echo "$ac_t""no" 1>&6
- cat >> confdefs.h <<\EOF
-#define WNOHANG_BACKUP_VALUE 1
-EOF
-
-
-fi
-rm -fr conftest*
-fi
-
-
-#
-# check how signals work
-#
-
-# Check for the data type of the mask used in select().
-# This picks up HP braindamage which defines fd_set and then
-# proceeds to ignore it and use int.
-# Pattern matching on int could be loosened.
-# Can't use ac_header_egrep since that doesn't see prototypes with K&R cpp.
-echo $ac_n "checking mask type of select""... $ac_c" 1>&6
-echo "configure:4715: checking mask type of select" >&5
-if egrep "select\(size_t, int" /usr/include/sys/time.h >/dev/null 2>&1; then
- echo "$ac_t""int" 1>&6
- cat >> confdefs.h <<\EOF
-#define SELECT_MASK_TYPE int
-EOF
-
-else
- echo "$ac_t""none" 1>&6
-fi
-
-
-# FIXME: check if alarm exists
-echo $ac_n "checking if signals need to be re-armed""... $ac_c" 1>&6
-echo "configure:4729: checking if signals need to be re-armed" >&5
-if test "$cross_compiling" = yes; then
- case "${host}" in
- *-*-cygwin*) echo "$ac_t""no" 1>&6 ;;
- *) echo "configure: warning: Expect can't be cross compiled" 1>&2 ;;
- esac
-
-else
- cat > conftest.$ac_ext <<EOF
-#line 4738 "configure"
-#include "confdefs.h"
-
-#include <signal.h>
-#define RETSIGTYPE $retsigtype
-
-int signal_rearms = 0;
-
-RETSIGTYPE
-child_sigint_handler(n)
-int n;
-{
-}
-
-RETSIGTYPE
-parent_sigint_handler(n)
-int n;
-{
-signal_rearms++;
-}
-
-main()
-{
- signal(SIGINT,parent_sigint_handler);
-
- if (0 == fork()) {
- signal(SIGINT,child_sigint_handler);
- kill(getpid(),SIGINT);
- kill(getpid(),SIGINT);
- kill(getppid(),SIGINT);
- } else {
- int status;
-
- wait(&status);
- unlink("core");
- exit(signal_rearms);
- }
-}
-EOF
-if { (eval echo configure:4777: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define REARM_SIG 1
-EOF
-
-
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -fr conftest*
- echo "$ac_t""no" 1>&6
-
-fi
-rm -fr conftest*
-fi
-
-
-# HPUX7 has trouble with the big cat so split it
-# Owen Rees <rtor@ansa.co.uk> 29Mar93
-SEDDEFS="${SEDDEFS}CONFEOF
-cat >> conftest.sed <<CONFEOF
-"
-#
-
-# There are multiple versions of getpty, alas.
-# I don't remember who has the first one, but Convex just added one
-# so check for it. Unfortunately, there is no header so the only
-# reasonable way to make sure is to look it we are on a Convex.
-echo $ac_n "checking if on Convex""... $ac_c" 1>&6
-echo "configure:4808: checking if on Convex" >&5
-convex=0
-case "${host}" in
- c[12]-*-*) convex=1;;
-esac
-
-if test $convex -eq 1 ; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define CONVEX 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-EXP_LDFLAGS=
-
-echo $ac_n "checking if on NeXT""... $ac_c" 1>&6
-echo "configure:4827: checking if on NeXT" >&5
-if test -r /NextApps -a "$cross_compiling" != "yes" ; then
- echo "$ac_t""yes" 1>&6
- # "-m" flag suppresses complaints about multiple strtod
- EXP_LDFLAGS="$EXP_LDFLAGS -m"
-else
- echo "$ac_t""no" 1>&6
-fi
-
-
-echo $ac_n "checking if on HP""... $ac_c" 1>&6
-echo "configure:4838: checking if on HP" >&5
-if test "x`(uname) 2>/dev/null`" = xHP-UX; then
- echo "$ac_t""yes" 1>&6
- hp=1
-else
- echo "$ac_t""no" 1>&6
- hp=0
-fi
-
-echo $ac_n "checking sane default stty arguments""... $ac_c" 1>&6
-echo "configure:4848: checking sane default stty arguments" >&5
-DEFAULT_STTY_ARGS="sane"
-
-if test $mach -eq 1 ; then
- DEFAULT_STTY_ARGS="cooked"
-fi
-
-if test $hp -eq 1 ; then
- DEFAULT_STTY_ARGS="sane kill \15"
-fi
-
-echo "$ac_t""$DEFAULT_STTY_ARG" 1>&6
-
-# Look for various features to determine what kind of pty
-# we have. For some weird reason, ac_compile_check would not
-# work, but ac_test_program does.
-#
-echo $ac_n "checking for HP style pty allocation""... $ac_c" 1>&6
-echo "configure:4866: checking for HP style pty allocation" >&5
-# following test fails on DECstations and other things that don't grok -c
-# but that's ok, since they don't have PTYMs anyway
-if test -r /dev/ptym/ptyp0 2>/dev/null -a "$cross_compiling" != "yes" ; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_PTYM 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-echo $ac_n "checking for HP style pty trapping""... $ac_c" 1>&6
-echo "configure:4880: checking for HP style pty trapping" >&5
-cat > conftest.$ac_ext <<EOF
-#line 4882 "configure"
-#include "confdefs.h"
-#include <sys/ptyio.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "struct.*request_info" >/dev/null 2>&1; then
- rm -rf conftest*
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_PTYTRAP 1
-EOF
-
-
-else
- rm -rf conftest*
- echo "$ac_t""no" 1>&6
-
-fi
-rm -f conftest*
-
-
-echo $ac_n "checking for AIX new-style pty allocation""... $ac_c" 1>&6
-echo "configure:4904: checking for AIX new-style pty allocation" >&5
-if test -r /dev/ptc -a -r /dev/pts -a "$cross_compiling" != "yes" ; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_PTC_PTS 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-echo $ac_n "checking for SGI old-style pty allocation""... $ac_c" 1>&6
-echo "configure:4916: checking for SGI old-style pty allocation" >&5
-if test -r /dev/ptc -a ! -r /dev/pts -a "$cross_compiling" != "yes" ; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_PTC 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-# On SCO OpenServer, two types of ptys are available: SVR4 streams and c-list.
-# The library routines to open the SVR4 ptys are broken on certain systems and
-# the SCO command to increase the number of ptys only configure c-list ones
-# anyway. So we chose these, which have a special numbering scheme.
-#
-echo $ac_n "checking for SCO style pty allocation""... $ac_c" 1>&6
-echo "configure:4933: checking for SCO style pty allocation" >&5
-sco_ptys=""
-case "${host}" in
- *-sco3.2v[45]*) sco_clist_ptys=1 svr4_ptys_broken=1;;
-esac
-
-if test x"${sco_clist_ptys}" != x"" ; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_SCO_CLIST_PTYS 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-
-echo $ac_n "checking for SVR4 style pty allocation""... $ac_c" 1>&6
-echo "configure:4950: checking for SVR4 style pty allocation" >&5
-if test -r /dev/ptmx -a "x$svr4_ptys_broken" = x -a "$cross_compiling" != "yes" ; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_PTMX 1
-EOF
-
- # aargg. Some systems need libpt.a to use /dev/ptmx
- echo $ac_n "checking for ptsname""... $ac_c" 1>&6
-echo "configure:4959: checking for ptsname" >&5
-if eval "test \"`echo '$''{'ac_cv_func_ptsname'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 4964 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char ptsname(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char ptsname();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_ptsname) || defined (__stub___ptsname)
-choke me
-#else
-ptsname();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:4987: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_ptsname=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_ptsname=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'ptsname`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- :
-else
- echo "$ac_t""no" 1>&6
-LIBS="${LIBS} -lpt"
-fi
-
- # I've never seen Tcl or Tk include -lpt so don't bother with explicit test
- echo $ac_n "checking for ptsname""... $ac_c" 1>&6
-echo "configure:5009: checking for ptsname" >&5
-if eval "test \"`echo '$''{'ac_cv_func_ptsname'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 5014 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char ptsname(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char ptsname();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_ptsname) || defined (__stub___ptsname)
-choke me
-#else
-ptsname();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:5037: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_ptsname=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_ptsname=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'ptsname`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- :
-else
- echo "$ac_t""no" 1>&6
-EXP_AND_TCL_LIBS="${EXP_AND_TCL_LIBS} -lpt"
-fi
-
- echo $ac_n "checking for ptsname""... $ac_c" 1>&6
-echo "configure:5058: checking for ptsname" >&5
-if eval "test \"`echo '$''{'ac_cv_func_ptsname'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 5063 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char ptsname(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char ptsname();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_ptsname) || defined (__stub___ptsname)
-choke me
-#else
-ptsname();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:5086: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_ptsname=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_ptsname=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'ptsname`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- :
-else
- echo "$ac_t""no" 1>&6
-EXP_AND_TK_LIBS="${EXP_AND_TK_LIBS} -lpt"
-fi
-
- # CYGNUS LOCAL: IA-64
- # On some systems (e.g., IA-64 Linux), we need to define _XOPEN_SOURCE
- # in order to get a declaration for ptsname. It is safe to simply
- # define that whenever we are using ptsname.
- echo $ac_n "checking for NSIG definition with _XOPEN_SOURCE""... $ac_c" 1>&6
-echo "configure:5111: checking for NSIG definition with _XOPEN_SOURCE" >&5
- cat > conftest.$ac_ext <<EOF
-#line 5113 "configure"
-#include "confdefs.h"
-
-/* _XOPEN_SOURCE can remove NSIG on UnixWare or OSF/1. */
-#define _XOPEN_SOURCE
-#include <signal.h>
-#ifndef NSIG
-#define NSIG _NSIG
-#endif
-char junk[NSIG];
-int main() {
-
-; return 0; }
-EOF
-if { (eval echo configure:5127: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- cat >> confdefs.h <<\EOF
-#define _XOPEN_SOURCE 1
-EOF
-
- echo "$ac_t""yes" 1>&6
-
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- echo "$ac_t""no" 1>&6
-
-fi
-rm -f conftest*
- # END CYGNUS LOCAL
-else
- echo "$ac_t""no" 1>&6
-fi
-
-# In OSF/1 case, SVR4 are somewhat different.
-# Gregory Depp <depp@osf.org> 17Aug93
-echo $ac_n "checking for OSF/1 style pty allocation""... $ac_c" 1>&6
-echo "configure:5151: checking for OSF/1 style pty allocation" >&5
-if test -r /dev/ptmx_bsd -a "$cross_compiling" != "yes" ; then
- cat >> confdefs.h <<\EOF
-#define HAVE_PTMX_BSD 1
-EOF
-
- echo "$ac_t""yes" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-# Set the pty handling for Cygwin
-case "${host}" in
- *-*-cygwin*) cat >> confdefs.h <<\EOF
-#define HAVE_PTMX 1
-EOF
- ;;
- *) ;;
-esac
-
-tcgetattr=0
-tcsetattr=0
-echo $ac_n "checking for tcgetattr""... $ac_c" 1>&6
-echo "configure:5174: checking for tcgetattr" >&5
-if eval "test \"`echo '$''{'ac_cv_func_tcgetattr'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 5179 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char tcgetattr(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char tcgetattr();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_tcgetattr) || defined (__stub___tcgetattr)
-choke me
-#else
-tcgetattr();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:5202: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_tcgetattr=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_tcgetattr=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'tcgetattr`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- tcgetattr=1
-else
- echo "$ac_t""no" 1>&6
-fi
-
-echo $ac_n "checking for tcsetattr""... $ac_c" 1>&6
-echo "configure:5222: checking for tcsetattr" >&5
-if eval "test \"`echo '$''{'ac_cv_func_tcsetattr'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 5227 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char tcsetattr(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char tcsetattr();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_tcsetattr) || defined (__stub___tcsetattr)
-choke me
-#else
-tcsetattr();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:5250: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_tcsetattr=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_tcsetattr=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'tcsetattr`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- tcsetattr=1
-else
- echo "$ac_t""no" 1>&6
-fi
-
-if test $tcgetattr -eq 1 -a $tcsetattr -eq 1 ; then
- cat >> confdefs.h <<\EOF
-#define HAVE_TCSETATTR 1
-EOF
-
- cat >> confdefs.h <<\EOF
-#define POSIX 1
-EOF
-
-fi
-
-# first check for the pure bsd
-echo $ac_n "checking for struct sgttyb""... $ac_c" 1>&6
-echo "configure:5282: checking for struct sgttyb" >&5
-if test "$cross_compiling" = yes; then
- case "${host}" in
- *-*-cygwin*) echo "$ac_t""no" 1>&6 ;;
- *) { echo "configure: error: Expect can't be cross compiled" 1>&2; exit 1; } ;;
- esac
-
-else
- cat > conftest.$ac_ext <<EOF
-#line 5291 "configure"
-#include "confdefs.h"
-
-#include <sgtty.h>
-main()
-{
- struct sgttyb tmp;
- exit(0);
-}
-EOF
-if { (eval echo configure:5301: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define HAVE_SGTTYB 1
-EOF
-
- PTY_TYPE=sgttyb
-
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -fr conftest*
- echo "$ac_t""no" 1>&6
-
-fi
-rm -fr conftest*
-fi
-
-
-# mach systems have include files for unimplemented features
-# so avoid doing following test on those systems
-if test $mach -eq 0 ; then
-
- # next check for the older style ttys
- # note that if we detect termio.h (only), we still set PTY_TYPE=termios
- # since that just controls which of pty_XXXX.c file is use and
- # pty_termios.c is set up to handle pty_termio.
- echo $ac_n "checking for struct termio""... $ac_c" 1>&6
-echo "configure:5330: checking for struct termio" >&5
- if test "$cross_compiling" = yes; then
- case "${host}" in
- *-*-cygwin*) echo "$ac_t""no" 1>&6 ;;
- *) { echo "configure: error: Expect can't be cross compiled" 1>&2; exit 1; } ;;
- esac
-
-else
- cat > conftest.$ac_ext <<EOF
-#line 5339 "configure"
-#include "confdefs.h"
-#include <termio.h>
- main()
- {
- struct termio tmp;
- exit(0);
- }
-EOF
-if { (eval echo configure:5348: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
- cat >> confdefs.h <<\EOF
-#define HAVE_TERMIO 1
-EOF
-
- PTY_TYPE=termios
- echo "$ac_t""yes" 1>&6
-
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -fr conftest*
- echo "$ac_t""no" 1>&6
-
-fi
-rm -fr conftest*
-fi
-
-
- # now check for the new style ttys (not yet posix)
- echo $ac_n "checking for struct termios""... $ac_c" 1>&6
-echo "configure:5370: checking for struct termios" >&5
- if test "$cross_compiling" = yes; then
- case "${host}" in
- *-*-cygwin*) cat >> confdefs.h <<\EOF
-#define HAVE_TERMIOS 1
-EOF
-
- PTY_TYPE=termios
- echo "$ac_t""yes" 1>&6 ;;
- *) { echo "configure: error: Expect can't be cross compiled" 1>&2; exit 1; } ;;
- esac
-
-else
- cat > conftest.$ac_ext <<EOF
-#line 5384 "configure"
-#include "confdefs.h"
-
-# ifdef HAVE_INTTYPES_H
-# include <inttypes.h>
-# endif
-# include <termios.h>
- main()
- {
- struct termios tmp;
- exit(0);
- }
-EOF
-if { (eval echo configure:5397: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
- cat >> confdefs.h <<\EOF
-#define HAVE_TERMIOS 1
-EOF
-
- PTY_TYPE=termios
- echo "$ac_t""yes" 1>&6
-
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -fr conftest*
- echo "$ac_t""no" 1>&6
-
-fi
-rm -fr conftest*
-fi
-
-fi
-
-echo $ac_n "checking if TCGETS or TCGETA in termios.h""... $ac_c" 1>&6
-echo "configure:5419: checking if TCGETS or TCGETA in termios.h" >&5
-if test "$cross_compiling" = yes; then
- case "${host}" in
- *-*-cygwin*) cat >> confdefs.h <<\EOF
-#define HAVE_TCGETS_OR_TCGETA_IN_TERMIOS_H 1
-EOF
-
- echo "$ac_t""yes" 1>&6 ;;
- *) { echo "configure: error: Expect can't be cross compiled" 1>&2; exit 1; } ;;
- esac
-
-else
- cat > conftest.$ac_ext <<EOF
-#line 5432 "configure"
-#include "confdefs.h"
-
-/* including termios.h on Solaris 5.6 fails unless inttypes.h included */
-#ifdef HAVE_INTTYPES_H
-#include <inttypes.h>
-#endif
-#include <termios.h>
-main() {
-#if defined(TCGETS) || defined(TCGETA)
- return 0;
-#else
- return 1;
-#endif
-}
-EOF
-if { (eval echo configure:5448: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
- cat >> confdefs.h <<\EOF
-#define HAVE_TCGETS_OR_TCGETA_IN_TERMIOS_H 1
-EOF
-
- echo "$ac_t""yes" 1>&6
-
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -fr conftest*
- echo "$ac_t""no" 1>&6
-
-fi
-rm -fr conftest*
-fi
-
-
-echo $ac_n "checking if TIOCGWINSZ in termios.h""... $ac_c" 1>&6
-echo "configure:5468: checking if TIOCGWINSZ in termios.h" >&5
-if test "$cross_compiling" = yes; then
- case "${host}" in
- *-*-cygwin*) cat >> confdefs.h <<\EOF
-#define HAVE_TIOCGWINSZ_IN_TERMIOS_H 1
-EOF
-
- echo "$ac_t""yes" 1>&6 ;;
- *) { echo "configure: error: Expect can't be cross compiled" 1>&2; exit 1; } ;;
- esac
-
-else
- cat > conftest.$ac_ext <<EOF
-#line 5481 "configure"
-#include "confdefs.h"
-
-/* including termios.h on Solaris 5.6 fails unless inttypes.h included */
-#ifdef HAVE_INTTYPES_H
-#include <inttypes.h>
-#endif
-#include <termios.h>
-main() {
-#ifdef TIOCGWINSZ
- return 0;
-#else
- return 1;
-#endif
-}
-EOF
-if { (eval echo configure:5497: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
- cat >> confdefs.h <<\EOF
-#define HAVE_TIOCGWINSZ_IN_TERMIOS_H 1
-EOF
-
- echo "$ac_t""yes" 1>&6
-
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -fr conftest*
- echo "$ac_t""no" 1>&6
-
-fi
-rm -fr conftest*
-fi
-
-
-# finally check for Cray style ttys
-echo $ac_n "checking for Cray-style ptys""... $ac_c" 1>&6
-echo "configure:5518: checking for Cray-style ptys" >&5
-SETUID=":"
-if test "$cross_compiling" = yes; then
- case "${host}" in
- *-*-cygwin*) echo "$ac_t""no" 1>&6 ;;
- *) { echo "configure: error: Expect can't be cross compiled" 1>&2; exit 1; } ;;
- esac
-
-else
- cat > conftest.$ac_ext <<EOF
-#line 5528 "configure"
-#include "confdefs.h"
-
-main(){
-#ifdef CRAY
- return 0;
-#else
- return 1;
-#endif
-}
-
-EOF
-if { (eval echo configure:5540: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
- PTY_TYPE=unicos
- SETUID="chmod u+s"
- echo "$ac_t""yes" 1>&6
-
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -fr conftest*
- echo "$ac_t""no" 1>&6
-
-fi
-rm -fr conftest*
-fi
-
-
-#
-# Check for select and/or poll. If both exist, we prefer select.
-# if neither exists, define SIMPLE_EVENT.
-#
-select=0
-poll=0
-unset ac_cv_func_select
-echo $ac_n "checking for select""... $ac_c" 1>&6
-echo "configure:5565: checking for select" >&5
-if eval "test \"`echo '$''{'ac_cv_func_select'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 5570 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char select(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char select();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_select) || defined (__stub___select)
-choke me
-#else
-select();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:5593: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_select=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_select=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'select`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- select=1
-else
- echo "$ac_t""no" 1>&6
-fi
-
-echo $ac_n "checking for poll""... $ac_c" 1>&6
-echo "configure:5613: checking for poll" >&5
-if eval "test \"`echo '$''{'ac_cv_func_poll'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 5618 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char poll(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char poll();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_poll) || defined (__stub___poll)
-choke me
-#else
-poll();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:5641: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_poll=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_poll=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'poll`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- poll=1
-else
- echo "$ac_t""no" 1>&6
-fi
-
-echo $ac_n "checking event handling""... $ac_c" 1>&6
-echo "configure:5661: checking event handling" >&5
-if test $select -eq 1 ; then
- EVENT_TYPE=select
- EVENT_ABLE=event
- echo "$ac_t""via select" 1>&6
-elif test $poll -eq 1 ; then
- EVENT_TYPE=poll
- EVENT_ABLE=event
- echo "$ac_t""via poll" 1>&6
-else
- EVENT_TYPE=simple
- EVENT_ABLE=noevent
- echo "$ac_t""none" 1>&6
- cat >> confdefs.h <<\EOF
-#define SIMPLE_EVENT 1
-EOF
-
-fi
-
-for ac_func in _getpty
-do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5683: checking for $ac_func" >&5
-if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 5688 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char $ac_func();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:5711: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_func 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-done
-
-for ac_func in getpty
-do
-echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5738: checking for $ac_func" >&5
-if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 5743 "configure"
-#include "confdefs.h"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char $ac_func(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char $ac_func();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-$ac_func();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo configure:5766: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=yes"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_$ac_func=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
- cat >> confdefs.h <<EOF
-#define $ac_tr_func 1
-EOF
-
-else
- echo "$ac_t""no" 1>&6
-fi
-done
-
-
-#
-# check for timezones
-#
-echo $ac_n "checking for SV-style timezone""... $ac_c" 1>&6
-echo "configure:5795: checking for SV-style timezone" >&5
-if test "$cross_compiling" = yes; then
- case "${host}" in
- *-*-cygwin*) echo "$ac_t""no" 1>&6 ;;
- *) { echo "configure: error: Expect can't be cross compiled" 1>&2; exit 1; } ;;
- esac
-
-else
- cat > conftest.$ac_ext <<EOF
-#line 5804 "configure"
-#include "confdefs.h"
-
-extern char *tzname[2];
-extern int daylight;
-main()
-{
- int *x = &daylight;
- char **y = tzname;
-
- exit(0);
-}
-EOF
-if { (eval echo configure:5817: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
- cat >> confdefs.h <<\EOF
-#define HAVE_SV_TIMEZONE 1
-EOF
-
- echo "$ac_t""yes" 1>&6
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -fr conftest*
- echo "$ac_t""no" 1>&6
-
-fi
-rm -fr conftest*
-fi
-
-
-# only look for Tk stuff if we have X11 and user doesn't say not to
-# Check whether --with-x or --without-x was given.
-if test "${with_x+set}" = set; then
- withval="$with_x"
- :
-else
- with_x=yes
-fi
-
-if test "$with_x" = "no"; then
- no_tk=true
-else
-
-#
-# Ok, lets find the tk source trees so we can use the headers
-# If the directory (presumably symlink) named "tk" exists, use that one
-# in preference to any others. Same logic is used when choosing library
-# and again with Tcl. The search order is the best place to look first, then in
-# decreasing significance. The loop breaks if the trigger file is found.
-# Note the gross little conversion here of srcdir by cd'ing to the found
-# directory. This converts the path from a relative to an absolute, so
-# recursive cache variables for the path will work right. We check all
-# the possible paths in one loop rather than many seperate loops to speed
-# things up.
-# the alternative search directory is involked by --with-tkinclude
-#
-#no_tk=true
-echo $ac_n "checking for Tk private headers""... $ac_c" 1>&6
-echo "configure:5863: checking for Tk private headers" >&5
-# Check whether --with-tkinclude or --without-tkinclude was given.
-if test "${with_tkinclude+set}" = set; then
- withval="$with_tkinclude"
- with_tkinclude=${withval}
-fi
-
-if eval "test \"`echo '$''{'ac_cv_c_tkh'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
-
-# first check to see if --with-tkinclude was specified
-if test x"${with_tkinclude}" != x ; then
- if test -f ${with_tkinclude}/tk.h ; then
- ac_cv_c_tkh=`(cd ${with_tkinclude}; pwd)`
- elif test -f ${with_tkinclude}/generic/tk.h ; then
- ac_cv_c_tkh=`(cd ${with_tkinclude}/generic; pwd)`
- else
- { echo "configure: error: ${with_tkinclude} directory doesn't contain private headers" 1>&2; exit 1; }
- fi
-fi
-
-# next check if it came with Tk configuration file
-if test x"${ac_cv_c_tkconfig}" != x ; then
- if test -f $ac_cv_c_tkconfig/../generic/tk.h ; then
- ac_cv_c_tkh=`(cd $ac_cv_c_tkconfig/../generic; pwd)`
- fi
-fi
-
-# next check in private source directory
-#
-# since ls returns lowest version numbers first, reverse its output
-
-if test x"${ac_cv_c_tkh}" = x ; then
- for i in \
- ${srcdir}/../tk \
- `ls -dr ${srcdir}/../tk[4-9].[0-9] 2>/dev/null` \
- ${srcdir}/../../tk \
- `ls -dr ${srcdir}/../../tk[4-9].[0-9] 2>/dev/null` \
- ${srcdir}/../../../tk \
- `ls -dr ${srcdir}/../../../tk[4-9].[0-9] 2>/dev/null ` ; do
- if test -f $i/generic/tk.h ; then
- ac_cv_c_tkh=`(cd $i/generic; pwd)`
- break
- fi
- done
-fi
-
-# finally check in a few common install locations
-#
-# since ls returns lowest version numbers first, reverse its output
-
-if test x"${ac_cv_c_tkh}" = x ; then
- for i in \
- `ls -dr /usr/local/src/tk[4-9].[0-9] 2>/dev/null` \
- `ls -dr /usr/local/lib/tk[4-9].[0-9] 2>/dev/null` \
- /usr/local/src/tk \
- /usr/local/lib/tk \
- ${prefix}/include ; do
- if test -f $i/generic/tk.h ; then
- ac_cv_c_tkh=`(cd $i/generic; pwd)`
- break
- fi
- done
-fi
-
-# see if one is installed
-if test x"${ac_cv_c_tkh}" = x ; then
- ac_safe=`echo "tk.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for tk.h""... $ac_c" 1>&6
-echo "configure:5933: checking for tk.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 5938 "configure"
-#include "confdefs.h"
-#include <tk.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5943: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_cv_c_tkh=installed
-else
- echo "$ac_t""no" 1>&6
-ac_cv_c_tkh=""
-fi
-
-fi
-
-fi
-
-if test x"${ac_cv_c_tkh}" != x ; then
-# no_tk=""
- if test x"${ac_cv_c_tkh}" = x"installed" ; then
- echo "$ac_t""is installed" 1>&6
- TKHDIRDASHI=""
- else
- echo "$ac_t""found in ${ac_cv_c_tkh}" 1>&6
- # this hack is cause the TKHDIRDASHI won't print if there is a "-I" in it.
- TKHDIRDASHI="-I${ac_cv_c_tkh}"
- fi
-else
- TKHDIRDASHI="# no Tk directory found"
- echo "configure: warning: Can't find Tk private headers" 1>&2
- no_tk=true
-fi
-
-
-
-fi
-if test x"$no_tk" != x"true" ; then
-# libexpectk no longer exists
-# X_PROGS="expectk \$(LIBEXPECTK)"
- X_PROGS=expectk
-# should really generate following symbol, but I'm hitting configure's limit on substs.
- X_PROGS_INSTALLED=expectk_installed
-else
- X_PROGS="# no X support on this system"
- echo "configure: warning: No X based programs will be built" 1>&2
- echo " WARNING: Can't find Tk headers or library. You can still"
- echo " build expect, but not expectk. See Expect's README for"
- echo " information on how to obtain Tk. If Tk is installed, see"
- echo " Expect's INSTALL on how to tell configure where Tk is"
- echo " installed."
-fi
-
-# consume these flags so that user can invoke Expect's configure with
-# the same command as Tcl's configure
-# Check whether --enable-load or --disable-load was given.
-if test "${enable_load+set}" = set; then
- enableval="$enable_load"
- disable_dl=$enableval
-else
- disable_dl=no
-fi
-
-
-# Check whether --enable-gcc or --disable-gcc was given.
-if test "${enable_gcc+set}" = set; then
- enableval="$enable_gcc"
- enable_gcc=$enableval
-else
- enable_gcc=no
-fi
-
-
-
-# Following comment stolen from Tcl's configure.in:
-# Note: in the following variable, it's important to use the absolute
-# path name of the Tcl directory rather than "..": this is because
-# AIX remembers this path and will attempt to use it at run-time to look
-# up the Tcl library.
-
-if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then
- EXP_LIB_VERSION=$EXP_VERSION
-else
- EXP_LIB_VERSION=$EXP_VERSION_NODOTS
-fi
-if test $iunix -eq 1 ; then
- EXP_LIB_VERSION=$EXP_VERSION_NODOTS
-fi
-
-# also remove dots on systems that don't support filenames > 14
-# (are there systems which support shared libs and restrict filename lengths!?)
-echo $ac_n "checking for long file names""... $ac_c" 1>&6
-echo "configure:6043: checking for long file names" >&5
-if eval "test \"`echo '$''{'ac_cv_sys_long_file_names'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- ac_cv_sys_long_file_names=yes
-# Test for long file names in all the places we know might matter:
-# . the current directory, where building will happen
-# $prefix/lib where we will be installing things
-# $exec_prefix/lib likewise
-# eval it to expand exec_prefix.
-# $TMPDIR if set, where it might want to write temporary files
-# if $TMPDIR is not set:
-# /tmp where it might want to write temporary files
-# /var/tmp likewise
-# /usr/tmp likewise
-if test -n "$TMPDIR" && test -d "$TMPDIR" && test -w "$TMPDIR"; then
- ac_tmpdirs="$TMPDIR"
-else
- ac_tmpdirs='/tmp /var/tmp /usr/tmp'
-fi
-for ac_dir in . $ac_tmpdirs `eval echo $prefix/lib $exec_prefix/lib` ; do
- test -d $ac_dir || continue
- test -w $ac_dir || continue # It is less confusing to not echo anything here.
- (echo 1 > $ac_dir/conftest9012345) 2>/dev/null
- (echo 2 > $ac_dir/conftest9012346) 2>/dev/null
- val=`cat $ac_dir/conftest9012345 2>/dev/null`
- if test ! -f $ac_dir/conftest9012345 || test "$val" != 1; then
- ac_cv_sys_long_file_names=no
- rm -f $ac_dir/conftest9012345 $ac_dir/conftest9012346 2>/dev/null
- break
- fi
- rm -f $ac_dir/conftest9012345 $ac_dir/conftest9012346 2>/dev/null
-done
-fi
-
-echo "$ac_t""$ac_cv_sys_long_file_names" 1>&6
-if test $ac_cv_sys_long_file_names = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_LONG_FILE_NAMES 1
-EOF
-
-fi
-
-if test $ac_cv_sys_long_file_names = no; then
- EXP_LIB_VERSION=$EXP_VERSION_NODOTS
-fi
-
-EXP_BUILD_LIB_SPEC="-L`pwd` -lexpect${EXP_LIB_VERSION}"
-EXP_LIB_SPEC="-L\${libdir} -lexpect${EXP_LIB_VERSION}"
-EXP_UNSHARED_LIB_FILE=libexpect${EXP_LIB_VERSION}.a
-EXP_BUILD_LIB_SPEC=${EXP_UNSHARED_LIB_FILE}
-
-echo $ac_n "checking for type of library to build""... $ac_c" 1>&6
-echo "configure:6096: checking for type of library to build" >&5
-if test "$enable_shared" = "yes" && test "x${TCL_SHLIB_SUFFIX}" != "x" ; then
- EXP_SHLIB_CFLAGS=$TCL_SHLIB_CFLAGS
-# EXP_SHARED_LIB_FILE=libexpect$EXP_LIB_VERSION$TCL_SHLIB_SUFFIX
- eval "EXP_SHARED_LIB_FILE=libexpect${TCL_SHARED_LIB_SUFFIX}"
- EXP_LIB_FILE=$EXP_SHARED_LIB_FILE
- EXP_LIB_FILES="$EXP_SHARED_LIB_FILE $EXP_UNSHARED_LIB_FILE"
- echo "$ac_t""both shared and unshared" 1>&6
-else
- EXP_SHLIB_CFLAGS=
- EXP_SHARED_LIB_FILE="reconfigure_Tcl_for_shared_library"
- EXP_LIB_FILE=$EXP_UNSHARED_LIB_FILE
- EXP_LIB_FILES="$EXP_UNSHARED_LIB_FILE"
- echo "$ac_t""unshared" 1>&6
-fi
-
-# CYGNUS LOCAL
-# We always link expect statically (against $EXP_UNSHARED_LIB_FILE)
-# so we can run it out of the build directory without hurting
-# ourselves and others.
-
-# now broken out into EXP_AND_TCL_LIBS and EXP_AND_TK_LIBS. Had to do this
-# in order to avoid repeating lib specs to which some systems object.
-EXP_AND_TCL_LIBS="$EXP_AND_TCL_LIBS $TCL_CC_SEARCH_FLAGS"
-EXP_AND_TK_LIBS="$EXP_AND_TK_LIBS $TCL_CC_SEARCH_FLAGS"
-
-# Sigh - Tcl defines SHLIB_LD_LIBS to be either empty or ${LIBS} and
-# LIBS is intended to be expanded by Make. But since we're too close
-# to hitting config's max symbols, pack everything together here and
-# do test ourselves. Ugh.
-#
-if test "x$TCL_SHLIB_LD_LIBS" = "x" ; then
- EXP_SHLIB_LD_LIBS=""
-else
- # seems a little strange to build in Tcl's build-lib, but
- # that's what Tk does.
- EXP_SHLIB_LD_LIBS="$TCL_BUILD_LIB_SPEC $TCL_DL_LIBS $LIBS -lc"
-fi
-
-echo $ac_n "checking for Cygwin32 environment""... $ac_c" 1>&6
-echo "configure:6136: checking for Cygwin32 environment" >&5
-if eval "test \"`echo '$''{'ac_cv_cygwin32'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 6141 "configure"
-#include "confdefs.h"
-
-int main() {
-int main () { return __CYGWIN__; }
-; return 0; }
-EOF
-if { (eval echo configure:6148: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- ac_cv_cygwin32=yes
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- ac_cv_cygwin32=no
-fi
-rm -f conftest*
-rm -f conftest*
-fi
-
-echo "$ac_t""$ac_cv_cygwin32" 1>&6
-CYGWIN=
-test "$ac_cv_cygwin32" = yes && CYGWIN=yes
-echo $ac_n "checking for executable suffix""... $ac_c" 1>&6
-echo "configure:6165: checking for executable suffix" >&5
-if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test "$CYGWIN" = yes; then
-ac_cv_exeext=.exe
-else
-cat > ac_c_test.c << 'EOF'
-int main() {
-/* Nothing needed here */
-}
-EOF
-${CC-cc} -o ac_c_test $CFLAGS $CPPFLAGS $LDFLAGS ac_c_test.c $LIBS 1>&5
-ac_cv_exeext=`ls ac_c_test.* | grep -v ac_c_test.c | sed -e s/ac_c_test//`
-rm -f ac_c_test*
-fi
-
-test x"${ac_cv_exeext}" = x && ac_cv_exeext=no
-fi
-EXEEXT=""
-test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext}
-echo "$ac_t""${ac_cv_exeext}" 1>&6
-
-
-#--------------------------------------------------------------------
-# This section is based on analogous thing in Tk installation. - DEL
-# Various manipulations on the search path used at runtime to
-# find shared libraries:
-# 2. On systems such as AIX and Ultrix that use "-L" as the
-# search path option, colons cannot be used to separate
-# directories from each other. Change colons to " -L".
-# 3. Create two sets of search flags, one for use in cc lines
-# and the other for when the linker is invoked directly. In
-# the second case, '-Wl,' must be stripped off and commas must
-# be replaced by spaces.
-#--------------------------------------------------------------------
-
-LIB_RUNTIME_DIR='${LIB_RUNTIME_DIR}'
-
-# If Tcl and Expect are installed in different places, adjust the library
-# search path to reflect this.
-
-if test "$TCL_EXEC_PREFIX" != "$exec_prefix"; then
- LIB_RUNTIME_DIR="${LIB_RUNTIME_DIR}:${TCL_EXEC_PREFIX}"
-fi
-
-if test "${TCL_LD_SEARCH_FLAGS}" = '-L${LIB_RUNTIME_DIR}'; then
- LIB_RUNTIME_DIR=`echo ${LIB_RUNTIME_DIR} |sed -e 's/:/ -L/g'`
-fi
-
-# The statement below is very tricky! It actually *evaluates* the
-# string in TCL_LD_SEARCH_FLAGS, which causes a substitution of the
-# variable LIB_RUNTIME_DIR.
-
-eval "EXP_CC_SEARCH_FLAGS=\"$TCL_LD_SEARCH_FLAGS\""
-if test "$GCC" = yes; then
- true
-else
- EXP_LD_SEARCH_FLAGS=`echo ${EXP_CC_SEARCH_FLAGS} |sed -e "s|-Wl,||g" -e "s|,| |g"`
-fi
-
-#
-# Set up makefile substitutions
-#
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-trap '' 1 2 15
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-# Any assignment to VPATH causes Sun make to only execute
-# the first set of double-colon rules, so remove it if not needed.
-# If there is a colon in the path, we need to keep it.
-if test "x$srcdir" = x.; then
- ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
-fi
-
-trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
-
-DEFS=-DHAVE_CONFIG_H
-
-# Without the "./", some shells look in PATH for config.status.
-: ${CONFIG_STATUS=./config.status}
-
-echo creating $CONFIG_STATUS
-rm -f $CONFIG_STATUS
-cat > $CONFIG_STATUS <<EOF
-#! /bin/sh
-# Generated automatically by configure.
-# Run this file to recreate the current configuration.
-# This directory was configured as follows,
-# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-#
-# $0 $ac_configure_args
-#
-# Compiler output produced by configure, useful for debugging
-# configure, is in ./config.log if it exists.
-
-ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
-for ac_option
-do
- case "\$ac_option" in
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
- exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
- -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
- echo "$CONFIG_STATUS generated by autoconf version 2.13"
- exit 0 ;;
- -help | --help | --hel | --he | --h)
- echo "\$ac_cs_usage"; exit 0 ;;
- *) echo "\$ac_cs_usage"; exit 1 ;;
- esac
-done
-
-ac_given_srcdir=$srcdir
-ac_given_INSTALL="$INSTALL"
-
-trap 'rm -fr `echo "Makefile pkgIndex expect_cf.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-# Protect against being on the right side of a sed subst in config.status.
-sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
- s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
-$ac_vpsub
-$extrasub
-s%@SHELL@%$SHELL%g
-s%@CFLAGS@%$CFLAGS%g
-s%@CPPFLAGS@%$CPPFLAGS%g
-s%@CXXFLAGS@%$CXXFLAGS%g
-s%@FFLAGS@%$FFLAGS%g
-s%@DEFS@%$DEFS%g
-s%@LDFLAGS@%$LDFLAGS%g
-s%@LIBS@%$LIBS%g
-s%@exec_prefix@%$exec_prefix%g
-s%@prefix@%$prefix%g
-s%@program_transform_name@%$program_transform_name%g
-s%@bindir@%$bindir%g
-s%@sbindir@%$sbindir%g
-s%@libexecdir@%$libexecdir%g
-s%@datadir@%$datadir%g
-s%@sysconfdir@%$sysconfdir%g
-s%@sharedstatedir@%$sharedstatedir%g
-s%@localstatedir@%$localstatedir%g
-s%@libdir@%$libdir%g
-s%@includedir@%$includedir%g
-s%@oldincludedir@%$oldincludedir%g
-s%@infodir@%$infodir%g
-s%@mandir@%$mandir%g
-s%@host@%$host%g
-s%@host_alias@%$host_alias%g
-s%@host_cpu@%$host_cpu%g
-s%@host_vendor@%$host_vendor%g
-s%@host_os@%$host_os%g
-s%@target@%$target%g
-s%@target_alias@%$target_alias%g
-s%@target_cpu@%$target_cpu%g
-s%@target_vendor@%$target_vendor%g
-s%@target_os@%$target_os%g
-s%@build@%$build%g
-s%@build_alias@%$build_alias%g
-s%@build_cpu@%$build_cpu%g
-s%@build_vendor@%$build_vendor%g
-s%@build_os@%$build_os%g
-s%@TCL_DEFS@%$TCL_DEFS%g
-s%@TCL_SHLIB_LD@%$TCL_SHLIB_LD%g
-s%@SHLIB_SUFFIX@%$SHLIB_SUFFIX%g
-s%@TCL_LD_FLAGS@%$TCL_LD_FLAGS%g
-s%@TCL_RANLIB@%$TCL_RANLIB%g
-s%@TCL_BUILD_LIB_SPEC@%$TCL_BUILD_LIB_SPEC%g
-s%@TCL_LIB_SPEC@%$TCL_LIB_SPEC%g
-s%@TCL_SHARED_LIB_SUFFIX@%$TCL_SHARED_LIB_SUFFIX%g
-s%@TK_VERSION@%$TK_VERSION%g
-s%@TK_DEFS@%$TK_DEFS%g
-s%@TK_XINCLUDES@%$TK_XINCLUDES%g
-s%@TK_XLIBSW@%$TK_XLIBSW%g
-s%@TK_BUILD_LIB_SPEC@%$TK_BUILD_LIB_SPEC%g
-s%@TK_LIB_SPEC@%$TK_LIB_SPEC%g
-s%@CC@%$CC%g
-s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
-s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
-s%@INSTALL_DATA@%$INSTALL_DATA%g
-s%@RANLIB@%$RANLIB%g
-s%@subdirs@%$subdirs%g
-s%@CPP@%$CPP%g
-s%@TCLHDIR@%$TCLHDIR%g
-s%@TCLHDIRDASHI@%$TCLHDIRDASHI%g
-s%@TCL_LIBRARY@%$TCL_LIBRARY%g
-s%@ITCLHDIR@%$ITCLHDIR%g
-s%@ITCLLIB@%$ITCLLIB%g
-s%@TKHDIRDASHI@%$TKHDIRDASHI%g
-s%@EXEEXT@%$EXEEXT%g
-s%@EXP_MAJOR_VERSION@%$EXP_MAJOR_VERSION%g
-s%@EXP_MINOR_VERSION@%$EXP_MINOR_VERSION%g
-s%@EXP_MICRO_VERSION@%$EXP_MICRO_VERSION%g
-s%@EXP_VERSION_FULL@%$EXP_VERSION_FULL%g
-s%@EXP_VERSION@%$EXP_VERSION%g
-s%@EXP_CONFIG_SHELL@%$EXP_CONFIG_SHELL%g
-s%@EXP_SHARED_LIB_FILE@%$EXP_SHARED_LIB_FILE%g
-s%@EXP_UNSHARED_LIB_FILE@%$EXP_UNSHARED_LIB_FILE%g
-s%@EXP_SHLIB_CFLAGS@%$EXP_SHLIB_CFLAGS%g
-s%@EXP_LIB_FILE@%$EXP_LIB_FILE%g
-s%@EXP_LIB_FILES@%$EXP_LIB_FILES%g
-s%@EXP_BUILD_LIB_SPEC@%$EXP_BUILD_LIB_SPEC%g
-s%@EXP_LIB_SPEC@%$EXP_LIB_SPEC%g
-s%@EXP_CFLAGS@%$EXP_CFLAGS%g
-s%@EXP_LDFLAGS@%$EXP_LDFLAGS%g
-s%@EXP_LD_SEARCH_FLAGS@%$EXP_LD_SEARCH_FLAGS%g
-s%@EXP_AND_TCL_LIBS@%$EXP_AND_TCL_LIBS%g
-s%@EXP_AND_TK_LIBS@%$EXP_AND_TK_LIBS%g
-s%@EXP_SHLIB_LD_LIBS@%$EXP_SHLIB_LD_LIBS%g
-s%@X_PROGS@%$X_PROGS%g
-s%@PTY_TYPE@%$PTY_TYPE%g
-s%@EVENT_TYPE@%$EVENT_TYPE%g
-s%@EVENT_ABLE@%$EVENT_ABLE%g
-s%@SETUID@%$SETUID%g
-s%@UNSHARED_RANLIB@%$UNSHARED_RANLIB%g
-s%@DEFAULT_STTY_ARGS@%$DEFAULT_STTY_ARGS%g
-
-CEOF
-EOF
-
-cat >> $CONFIG_STATUS <<\EOF
-
-# Split the substitutions into bite-sized pieces for seds with
-# small command number limits, like on Digital OSF/1 and HP-UX.
-ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
-ac_file=1 # Number of current file.
-ac_beg=1 # First line for current file.
-ac_end=$ac_max_sed_cmds # Line after last line for current file.
-ac_more_lines=:
-ac_sed_cmds=""
-while $ac_more_lines; do
- if test $ac_beg -gt 1; then
- sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
- else
- sed "${ac_end}q" conftest.subs > conftest.s$ac_file
- fi
- if test ! -s conftest.s$ac_file; then
- ac_more_lines=false
- rm -f conftest.s$ac_file
- else
- if test -z "$ac_sed_cmds"; then
- ac_sed_cmds="sed -f conftest.s$ac_file"
- else
- ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
- fi
- ac_file=`expr $ac_file + 1`
- ac_beg=$ac_end
- ac_end=`expr $ac_end + $ac_max_sed_cmds`
- fi
-done
-if test -z "$ac_sed_cmds"; then
- ac_sed_cmds=cat
-fi
-EOF
-
-cat >> $CONFIG_STATUS <<EOF
-
-CONFIG_FILES=\${CONFIG_FILES-"Makefile pkgIndex"}
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
- # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
- case "$ac_file" in
- *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
- ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
- *) ac_file_in="${ac_file}.in" ;;
- esac
-
- # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
-
- # Remove last slash and all that follows it. Not all systems have dirname.
- ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
- if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
- # The file is in a subdirectory.
- test ! -d "$ac_dir" && mkdir "$ac_dir"
- ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
- # A "../" for each directory in $ac_dir_suffix.
- ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
- else
- ac_dir_suffix= ac_dots=
- fi
-
- case "$ac_given_srcdir" in
- .) srcdir=.
- if test -z "$ac_dots"; then top_srcdir=.
- else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
- /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
- *) # Relative path.
- srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
- top_srcdir="$ac_dots$ac_given_srcdir" ;;
- esac
-
- case "$ac_given_INSTALL" in
- [/$]*) INSTALL="$ac_given_INSTALL" ;;
- *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
- esac
-
- echo creating "$ac_file"
- rm -f "$ac_file"
- configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
- case "$ac_file" in
- *Makefile*) ac_comsub="1i\\
-# $configure_input" ;;
- *) ac_comsub= ;;
- esac
-
- ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
- sed -e "$ac_comsub
-s%@configure_input@%$configure_input%g
-s%@srcdir@%$srcdir%g
-s%@top_srcdir@%$top_srcdir%g
-s%@INSTALL@%$INSTALL%g
-" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
-fi; done
-rm -f conftest.s*
-
-# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
-# NAME is the cpp macro being defined and VALUE is the value it is being given.
-#
-# ac_d sets the value in "#define NAME VALUE" lines.
-ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
-ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
-ac_dC='\3'
-ac_dD='%g'
-# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
-ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_uB='\([ ]\)%\1#\2define\3'
-ac_uC=' '
-ac_uD='\4%g'
-# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
-ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_eB='$%\1#\2define\3'
-ac_eC=' '
-ac_eD='%g'
-
-if test "${CONFIG_HEADERS+set}" != set; then
-EOF
-cat >> $CONFIG_STATUS <<EOF
- CONFIG_HEADERS="expect_cf.h"
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-fi
-for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
- # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
- case "$ac_file" in
- *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
- ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
- *) ac_file_in="${ac_file}.in" ;;
- esac
-
- echo creating $ac_file
-
- rm -f conftest.frag conftest.in conftest.out
- ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
- cat $ac_file_inputs > conftest.in
-
-EOF
-
-# Transform confdefs.h into a sed script conftest.vals that substitutes
-# the proper values into config.h.in to produce config.h. And first:
-# Protect against being on the right side of a sed subst in config.status.
-# Protect against being in an unquoted here document in config.status.
-rm -f conftest.vals
-cat > conftest.hdr <<\EOF
-s/[\\&%]/\\&/g
-s%[\\$`]%\\&%g
-s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
-s%ac_d%ac_u%gp
-s%ac_u%ac_e%gp
-EOF
-sed -n -f conftest.hdr confdefs.h > conftest.vals
-rm -f conftest.hdr
-
-# This sed command replaces #undef with comments. This is necessary, for
-# example, in the case of _POSIX_SOURCE, which is predefined and required
-# on some systems where configure will not decide to define it.
-cat >> conftest.vals <<\EOF
-s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
-EOF
-
-# Break up conftest.vals because some shells have a limit on
-# the size of here documents, and old seds have small limits too.
-
-rm -f conftest.tail
-while :
-do
- ac_lines=`grep -c . conftest.vals`
- # grep -c gives empty output for an empty file on some AIX systems.
- if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
- # Write a limited-size here document to conftest.frag.
- echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
- sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
- echo 'CEOF
- sed -f conftest.frag conftest.in > conftest.out
- rm -f conftest.in
- mv conftest.out conftest.in
-' >> $CONFIG_STATUS
- sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
- rm -f conftest.vals
- mv conftest.tail conftest.vals
-done
-rm -f conftest.vals
-
-cat >> $CONFIG_STATUS <<\EOF
- rm -f conftest.frag conftest.h
- echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
- cat conftest.in >> conftest.h
- rm -f conftest.in
- if cmp -s $ac_file conftest.h 2>/dev/null; then
- echo "$ac_file is unchanged"
- rm -f conftest.h
- else
- # Remove last slash and all that follows it. Not all systems have dirname.
- ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
- if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
- # The file is in a subdirectory.
- test ! -d "$ac_dir" && mkdir "$ac_dir"
- fi
- rm -f $ac_file
- mv conftest.h $ac_file
- fi
-fi; done
-
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-
-exit 0
-EOF
-chmod +x $CONFIG_STATUS
-rm -fr confdefs* $ac_clean_files
-test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
-
-if test "$no_recursion" != yes; then
-
- # Remove --cache-file and --srcdir arguments so they do not pile up.
- ac_sub_configure_args=
- ac_prev=
- for ac_arg in $ac_configure_args; do
- if test -n "$ac_prev"; then
- ac_prev=
- continue
- fi
- case "$ac_arg" in
- -cache-file | --cache-file | --cache-fil | --cache-fi \
- | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
- ac_prev=cache_file ;;
- -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
- | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
- ;;
- -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
- ac_prev=srcdir ;;
- -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
- ;;
- *) ac_sub_configure_args="$ac_sub_configure_args $ac_arg" ;;
- esac
- done
-
- for ac_config_dir in testsuite; do
-
- # Do not complain, so a configure script can configure whichever
- # parts of a large source tree are present.
- if test ! -d $srcdir/$ac_config_dir; then
- continue
- fi
-
- echo configuring in $ac_config_dir
-
- case "$srcdir" in
- .) ;;
- *)
- if test -d ./$ac_config_dir || mkdir ./$ac_config_dir; then :;
- else
- { echo "configure: error: can not create `pwd`/$ac_config_dir" 1>&2; exit 1; }
- fi
- ;;
- esac
-
- ac_popdir=`pwd`
- cd $ac_config_dir
-
- # A "../" for each directory in /$ac_config_dir.
- ac_dots=`echo $ac_config_dir|sed -e 's%^\./%%' -e 's%[^/]$%&/%' -e 's%[^/]*/%../%g'`
-
- case "$srcdir" in
- .) # No --srcdir option. We are building in place.
- ac_sub_srcdir=$srcdir ;;
- /*) # Absolute path.
- ac_sub_srcdir=$srcdir/$ac_config_dir ;;
- *) # Relative path.
- ac_sub_srcdir=$ac_dots$srcdir/$ac_config_dir ;;
- esac
-
- # Check for guested configure; otherwise get Cygnus style configure.
- if test -f $ac_sub_srcdir/configure; then
- ac_sub_configure=$ac_sub_srcdir/configure
- elif test -f $ac_sub_srcdir/configure.in; then
- ac_sub_configure=$ac_configure
- else
- echo "configure: warning: no configuration information is in $ac_config_dir" 1>&2
- ac_sub_configure=
- fi
-
- # The recursion is here.
- if test -n "$ac_sub_configure"; then
-
- # Make the cache file name correct relative to the subdirectory.
- case "$cache_file" in
- /*) ac_sub_cache_file=$cache_file ;;
- *) # Relative path.
- ac_sub_cache_file="$ac_dots$cache_file" ;;
- esac
- case "$ac_given_INSTALL" in
- [/$]*) INSTALL="$ac_given_INSTALL" ;;
- *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
- esac
-
- echo "running ${CONFIG_SHELL-/bin/sh} $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir"
- # The eval makes quoting arguments work.
- if eval ${CONFIG_SHELL-/bin/sh} $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir
- then :
- else
- { echo "configure: error: $ac_sub_configure failed for $ac_config_dir" 1>&2; exit 1; }
- fi
- fi
-
- cd $ac_popdir
- done
-fi
-
+++ /dev/null
-# Process this file with autoconf to produce a configure script.
-
-# while Expect is in alpha/beta, disable caching so as not to confuse
-# people trying to fix configure bugs
-dnl CYGNUS LOCAL: allow caching
-define([AC_CACHE_LOAD], )
-define([AC_CACHE_SAVE], )
-dnl END CYGNUS LOCAL
-
-AC_INIT(expect.h)
-
-dnl CYGNUS LOCAL: find aux files in ..
-AC_CONFIG_AUX_DIR($srcdir/..)
-dnl END CYGNUS LOCAL
-dnl AC_CANONICAL_SYSTEM
-
-# note when updating version numbers here, also update pkgIndex.in (see
-# comments in Makefile)
-EXP_MAJOR_VERSION=5
-EXP_MINOR_VERSION=26
-EXP_MICRO_VERSION=0
-EXP_VERSION=$EXP_MAJOR_VERSION.$EXP_MINOR_VERSION
-EXP_VERSION_NODOTS=$EXP_MAJOR_VERSION$EXP_MINOR_VERSION
-EXP_VERSION_FULL=$EXP_VERSION.$EXP_MICRO_VERSION
-
-# Tcl's handling of shared_lib_suffix requires this symbol exist
-VERSION=$EXP_MAJOR_VERSION.$EXP_MINOR_VERSION
-
-# Too many people send me configure output without identifying the version.
-# This forced identification should reduce my pain significantly.
-echo "configuring Expect $EXP_MAJOR_VERSION.$EXP_MINOR_VERSION.$EXP_MICRO_VERSION"
-
-dnl AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/..)
-AC_CANONICAL_SYSTEM
-
-AC_CONFIG_HEADER(expect_cf.h)
-
-# /bin/sh on some systems is too deficient (in particular, Ultrix 4.3
-# sh lacks unset and we *need* that), but all these systems come with
-# alternatives, so take user's choice or whatever we're using here and
-# allow it to be seen by Make.
-AC_MSG_CHECKING([shell to use within Make])
-EXP_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
-AC_MSG_RESULT($CONFIG_SHELL)
-
-# If `configure' is invoked (in)directly via `make', ensure that it
-# encounters no `make' conflicts.
-#
-unset MFLAGS MAKEFLAGS
-MFLAGS=""
-MAKEFLAGS=""
-
-CY_AC_PATH_TCLCONFIG
-CY_AC_LOAD_TCLCONFIG
-CC=$TCL_CC
-EXP_AND_TCL_LIBS=$TCL_LIBS
-CY_AC_PATH_TKCONFIG
-CY_AC_LOAD_TKCONFIG
-EXP_AND_TK_LIBS=$TK_LIBS
-
-# CYGNUS LOCAL dj/cygwin
-AC_CANONICAL_HOST
-EXP_CFLAGS=""
-# If we built a cygwin-specific tcl, use it here.
-case "${host}" in
-*-*-cygwin*)
- if test -d $srcdir/../tcl/cygwin/.
- then
- TCL_BUILD_LIB_SPEC="../tcl/cygwin/libtcl_cygwin.a"
- # Use the same static lib for installed_expect
- TCL_LIB_SPEC="../tcl/cygwin/libtcl_cygwin.a"
- EXP_CYGWIN_ALTTCL='-DCYGWIN_ALTTCL'
- fi
- touch ac$$.c
- if ${CC} -c -mno-win32 ac$$.c >/dev/null 2>&1; then
- case "$EXP_CFLAGS" in
- *-mno-win32*) ;;
- *) EXP_CFLAGS="-mno-win32 $EXP_CFLAGS" ;;
- esac
- fi
- rm -f ac$$.o ac$$.c
- ;;
-esac
-
-# An explanation is in order for the strange things going on with the
-# various LIBS. There are three separate definitions for LIBS. The
-# reason is that some systems require shared libraries include
-# references to their dependent libraries, i.e., any additional
-# libraries that must be linked to. And some systems get upset if the
-# references are repeated on the link line. So therefore, we create
-# one for Expect and Tk (EXP_AND_TK_LIBS), one for Expect and Tcl
-# (EXP_AND_TCL_LIBS), and finally, one for building Expect's own
-# shared library. Tcl's tclConfig.sh insists that any shared libs
-# that it "helps" build must pass the libraries as LIBS (see comment
-# near end of this configure file). I would do but since we're close
-# to hitting config's max symbols, we take one short cut and pack the
-# LIBS into EXP_SHLIB_LD_LIBS (which is basically what Tcl wants to do
-# for us). The point, however, is that there's no separate LIBS or
-# EXP_LIBS symbol passed out of configure. One additional point for
-# confusion is that LIBS is what configure uses to do all library
-# tests, so we have to swap definitions of LIBS peridically. When we
-# are swapping out the one for Expect's shared library, we save it in
-# EXP_LIBS. Sigh.
-
-dnl AC_PROG_CC insists on sticking crap -g and -O in CFLAGS
-dnl but I want to control it. Can't just throw it out at the
-dnl end alas, because the user might have defined CFLAGS.
-dnl CYGNUS LOCAL: just use AC_PROG_CC; we don't care.
-dnl OLD_CFLAGS=$CFLAGS
-OLD_CFLAGS=$CFLAGS
-AC_PROG_CC
-CFLAGS=$OLD_CFLAGS
-dnl CFLAGS=$OLD_CFLAGS
-dnl END CYGNUS LOCAL
-
-CY_AC_C_WORKS
-
-# this'll use a BSD compatible install or our included install-sh
-AC_PROG_INSTALL
-
-# Tcl sets TCL_RANLIB appropriately for shared library if --enable-shared
-AC_PROG_RANLIB
-UNSHARED_RANLIB=$RANLIB
-
-# these are the other subdirectories we need to configure
-AC_CONFIG_SUBDIRS(testsuite)
-
-# This is for LynxOS, which needs a flag to force true POSIX when
-# building. The flag varies depending how old the compiler is.
-# -X is for the old "cc" and "gcc" (based on 1.42)
-# -mposix is for the new gcc (at least 2.5.8)
-# This modifies the value of $CC to have the POSIX flag added
-# so it'll configure correctly
-CY_AC_TCL_LYNX_POSIX
-
-AC_TYPE_PID_T
-AC_RETSIGTYPE
-dnl AC_TIME_WITH_SYS_TIME
-AC_HEADER_TIME
-AC_HEADER_SYS_WAIT
-
-dnl CYGNUS LOCAL: always respect CFLAGS.
-dnl case "${host}" in
-# Use -g on all systems but Linux where it upsets the dynamic X libraries.
-dnl i[[3456]]86-*-linux*) EXP_CFLAGS="" ;;
-dnl esac
-dnl END CYGNUS LOCAL
-EXP_CFLAGS="$EXP_CFLAGS $EXP_CYGWIN_ALTTCL"
-
-AC_MSG_CHECKING([if running Mach])
-mach=0
-case "${host}" in
- # Both Next and pure Mach behave identically with respect
- # to a few things, so just lump them together as "mach"
- *-*-mach*) mach=1 ;;
- *-*-next*) mach=1 ; next=1 ;;
-esac
-
-if test $mach -eq 1 ; then
- AC_MSG_RESULT(yes)
-else
- AC_MSG_RESULT(no)
-fi
-
-AC_MSG_CHECKING([if running MachTen])
-# yet another Mach clone
-if test -r /MachTen -a "$cross_compiling" != "yes" ; then
- AC_MSG_RESULT(yes)
- mach=1
-else
- AC_MSG_RESULT(no)
-fi
-
-AC_MSG_CHECKING([if on Pyramid])
-if test -r /bin/pyr -a "$cross_compiling" != "yes" ; then
- AC_MSG_RESULT(yes)
- pyr=1
-else
- AC_MSG_RESULT(no)
- pyr=0
-fi
-
-AC_MSG_CHECKING([if on Apollo])
-if test -r /usr/apollo/bin -a "$cross_compiling" != "yes" ; then
- AC_MSG_RESULT(yes)
- apollo=1
-else
- AC_MSG_RESULT(no)
- apollo=0
-fi
-
-AC_MSG_CHECKING([if on Interactive])
-if test "x`(uname -s) 2>/dev/null`" = xIUNIX; then
- AC_MSG_RESULT(yes)
- iunix=1
-else
- AC_MSG_RESULT(no)
- iunix=0
-fi
-
-AC_MSG_CHECKING([if stty reads stdout])
-
-# On some systems stty can't be run in the background (svr4) or get it
-# wrong because they fail to complain (next, mach), so don't attempt
-# the test on some systems.
-
-stty_reads_stdout=""
-case "${host}" in
- *-*-solaris*) stty_reads_stdout=0 ;;
- *-*-irix*) stty_reads_stdout=0 ;;
- *-*-sco3.2v[[45]]*) stty_reads_stdout=1 ;;
- i[[3456]]86-*-sysv4.2MP) stty_reads_stdout=0 ;;
- i[[3456]]86-*-linux*) stty_reads_stdout=0 ;;
- # Not sure about old convex but 5.2 definitely reads from stdout
- c[[12]]-*-*) stty_reads_stdout=1 ;;
- *-*-aix[[34]]*) stty_reads_stdout=0 ;;
- *-*-hpux9*) stty_reads_stdout=0 ;;
- *-*-hpux10*) stty_reads_stdout=0 ;;
- *-*-hpux11*) stty_reads_stdout=0 ;;
- *-*-osf[[234]]*) stty_reads_stdout=0 ;;
- *-*-ultrix4.4) stty_reads_stdout=0 ;;
- *-*-dgux*) stty_reads_stdout=0 ;;
- *-*-cygwin*) stty_reads_stdout=0 ;;
-esac
-
-if test $mach -eq 1 ; then
- stty_reads_stdout=1
-fi
-if test $apollo -eq 1 ; then
- stty_reads_stdout=1
-fi
-if test $pyr -eq 1 ; then
- stty_reads_stdout=1
-fi
-
-# if we still don't know, test
-if test x"${stty_reads_stdout}" = x"" ; then
- /bin/stty > /dev/null 2> /dev/null
- if test $? -ne 0 ; then
- stty_reads_stdout=1
- else
- stty_reads_stdout=0
- fi
-fi
-
-if test ${stty_reads_stdout} -eq 1 ; then
- AC_MSG_RESULT(yes)
- AC_DEFINE(STTY_READS_STDOUT)
-else
- AC_MSG_RESULT(no)
-fi
-
-# Solaris 2.4 and later requires __EXTENSIONS__ in order to see all sorts
-# of traditional but nonstandard stuff in header files.
-AC_MSG_CHECKING([if running Solaris])
-solaris=0
-case "${host}" in
- *-*-solaris*) solaris=1;;
-esac
-
-if test $solaris -eq 1 ; then
- AC_MSG_RESULT(yes)
- AC_DEFINE(SOLARIS)
-else
- AC_MSG_RESULT(no)
-fi
-
-
-# On a few systems, libm.a is the same as libc.a
-# Don't bother to test against Tcl and Tk libs, they always include -lm
-AC_CHECK_FUNC(sin, , LIBS="${LIBS} -lm" )
-
-# On Interactive UNIX, -Xp must be added to LIBS in order to find strftime.
-# This test should really be done by Tcl. So just check Tcl's definition.
-# If defective, add to all three LIBS. (It's not actually necessary for
-# EXP_LIBS since -Xp will just be ignored the way that EXP_LIBS is used in
-# the Makefile, but we include it for consistency.)
-if test $iunix -eq 1 ; then
- EXP_LIBS=$LIBS
- LIBS=$EXP_AND_TCL_LIBS
- AC_CHECK_FUNC(strftime, , [
- EXP_LIBS="${LIBS} -Xp"
- EXP_AND_TCL_LIBS="${LIBS} -Xp"
- EXP_AND_TK_LIBS="${LIBS} -Xp"
- ])
- LIBS=EXP_LIBS
-fi
-
-#
-# Ok, lets find the tcl source trees so we can use the headers
-#
-CY_AC_PATH_TCLH
-if test x"$no_tcl" = x"true" ; then
- echo " ERROR: Can't find Tcl headers or library."
- echo " See README for information on how to obtain Tcl."
- echo " If Tcl is installed, see INSTALL on how to tell"
- echo " configure where Tcl is installed."
- exit 1
-fi
-CY_AC_PATH_ITCLH
-
-# have to whether we're generating shared libs before configuring debugger
-AC_MSG_CHECKING([if generating shared or nonshared library])
-AC_ARG_ENABLE(shared,
- [ --enable-shared build libexpect as a shared library],
- [enable_shared=$enableval], [enable_shared=no])
-if test "$enable_shared" = "yes" && test "x${TCL_SHLIB_SUFFIX}" != "x" ; then
- AC_MSG_RESULT(both shared and unshared)
-else
- AC_MSG_RESULT(unshared)
-fi
-
-# Now that we've found the Tcl sources, configure the debugger
-# this is a little tricky because it has its own configure script
-# which produces a Makefile and cf file. We only want the cf file,
-# so switch to a temporary directory and run the debugger's configure.
-# Then save the cf file and delete the rest.
-#
-# Incidentally, the debugger can't depend on Expect's cf file, because
-# the debugger is designed to be independent of Expect.
-#
-
-test -n "$verbose" && echo "configuring Tcl debugger"
-tmpdir=./Dbg$$
-mkdir ${tmpdir}
-
-if test "${enable_shared}" = "yes"; then
- dbg_config_flags='--enable-shared'
-else
- dbg_config_flags='--disable-shared'
-fi
-# (cd;pwd) in next several commands converts relative dirs to absolute.
-# This is required because the debugger src is at a different level in
-# the filesystem than Expect src (where we are presently), thereby
-# making the relative pathnames incorrect.
-if test "x$with_tclconfig" != "x" ; then
- dbg_config_flags="$dbg_config_flags --with-tclconfig=`(cd ${with_tclconfig}; pwd)`"
-fi
-if test "x$with_tcllibdir" != "x" ; then
- dbg_config_flags="$dbg_config_flags --with-tcllibdir=`(cd ${with_tcllibdir}; pwd)`"
-fi
-if test "x$with_tcllib" != "x" ; then
- dbg_config_flags="$dbg_config_flags --with-tcllib=`(cd ${with_tcllib}; pwd)`"
-fi
-if test "x$with_tclinclude" != "x" ; then
- dbg_config_flags="$dbg_config_flags --with-tclinclude=`(cd ${with_tclinclude}; pwd)`"
-fi
-case "$cache_file" in
- /*)
- dbg_config_flags="$dbg_config_flags --cache-file=$cache_file"
- ;;
- *)
- dbg_config_flags="$dbg_config_flags --cache-file=../$cache_file"
- ;;
-esac
-
-cp ${srcdir}/Dbgconfigure ${srcdir}/Dbg.h ${srcdir}/Dbg_cf.h.in ${srcdir}/install-sh ${tmpdir}
-cp $srcdir/DbgMkfl.in ${tmpdir}/Makefile.in
- (cd $tmpdir; ${CONFIG_SHELL-/bin/sh} Dbgconfigure --with-tclinclude=`echo ${TCLHDIR} | sed -e 's/-I//'` $dbg_config_flags)
-cp ${tmpdir}/Dbg_cf.h .
-rm -rf $tmpdir
-test -n "$verbose" && echo "configured Tcl debugger"
-
-# some people would complain if this explanation wasn't provided...
-
-echo "Begin tests for function/library dependencies. Tests may be repeated"
-echo "up to three times. First test is for building Expect's shared library."
-echo "Second set is for building with Tcl. Third is for building with Tk."
-
-######################################################################
-# required by Sequent ptx2
-unset ac_cv_func_gethostname
-AC_CHECK_FUNC(gethostname, gethostname=1 , gethostname=0)
-if test $gethostname -eq 0 ; then
- unset ac_cv_lib_inet_gethostname
- AC_CHECK_LIB(inet, gethostname, LIBS="$LIBS -linet")
-fi
-# save results and retry for Tcl
-EXP_LIBS=$LIBS
-LIBS=$EXP_AND_TCL_LIBS
-unset ac_cv_func_gethostname
-AC_CHECK_FUNC(gethostname, gethostname=1 , gethostname=0)
-if test $gethostname -eq 0 ; then
- unset ac_cv_lib_inet_gethostname
- AC_CHECK_LIB(inet, gethostname, LIBS="$LIBS -linet")
-fi
-# save Tcl results and retry for Tk
-EXP_AND_TCL_LIBS=$LIBS
-LIBS=$EXP_AND_TK_LIBS
-unset ac_cv_func_gethostname
-AC_CHECK_FUNC(gethostname, gethostname=1 , gethostname=0)
-if test $gethostname -eq 0 ; then
- unset ac_cv_lib_inet_gethostname
- AC_CHECK_LIB(inet, gethostname, LIBS="$LIBS -linet")
-fi
-# save Tk results and reset for Expect
-EXP_AND_TK_LIBS=$LIBS
-LIBS=$EXP_LIBS
-
-######################################################################
-# required by Fischman's ISC 4.0
-unset ac_cv_func_socket
-AC_CHECK_FUNC(socket, socket=1 , socket=0)
-if test $socket -eq 0 ; then
- unset ac_cv_lib_inet_socket
- AC_CHECK_LIB(inet, socket, LIBS="$LIBS -linet")
-fi
-# save results and retry for Tcl
-EXP_LIBS=$LIBS
-LIBS=$EXP_AND_TCL_LIBS
-unset ac_cv_func_socket
-AC_CHECK_FUNC(socket, socket=1 , socket=0)
-if test $socket -eq 0 ; then
- unset ac_cv_lib_inet_socket
- AC_CHECK_LIB(inet, socket, LIBS="$LIBS -linet")
-fi
-# save Tcl results and retry for Tk
-EXP_AND_TCL_LIBS=$LIBS
-LIBS=$EXP_AND_TK_LIBS
-unset ac_cv_func_socket
-AC_CHECK_FUNC(socket, socket=1 , socket=0)
-if test $socket -eq 0 ; then
- unset ac_cv_lib_inet_socket
- AC_CHECK_LIB(inet, socket, LIBS="$LIBS -linet")
-fi
-# save Tk results and reset for Expect
-EXP_AND_TK_LIBS=$LIBS
-LIBS=$EXP_LIBS
-
-######################################################################
-unset ac_cv_func_select
-AC_CHECK_FUNC(select, select=1 , select=0)
-if test $select -eq 0 ; then
- unset ac_cv_lib_inet_select
- AC_CHECK_LIB(inet, select, LIBS="$LIBS -linet")
-fi
-# save results and retry for Tcl
-EXP_LIBS=$LIBS
-LIBS=$EXP_AND_TCL_LIBS
-unset ac_cv_func_select
-AC_CHECK_FUNC(select, select=1 , select=0)
-if test $select -eq 0 ; then
- unset ac_cv_lib_inet_select
- AC_CHECK_LIB(inet, select, LIBS="$LIBS -linet")
-fi
-# save Tcl results and retry for Tk
-EXP_AND_TCL_LIBS=$LIBS
-LIBS=$EXP_AND_TK_LIBS
-unset ac_cv_func_select
-AC_CHECK_FUNC(select, select=1 , select=0)
-if test $select -eq 0 ; then
- unset ac_cv_lib_inet_select
- AC_CHECK_LIB(inet, select, LIBS="$LIBS -linet")
-fi
-# save Tk results and reset for Expect
-EXP_AND_TK_LIBS=$LIBS
-LIBS=$EXP_LIBS
-
-######################################################################
-unset ac_cv_func_getpseudotty
-AC_CHECK_FUNC(getpseudotty, getpseudotty=1 , getpseudotty=0)
-if test $getpseudotty -eq 0 ; then
- unset ac_cv_lib_seq_getpseudotty
- AC_CHECK_LIB(seq, getpseudotty)
-fi
-# save results and retry for Tcl
-EXP_LIBS=$LIBS
-LIBS=$EXP_AND_TCL_LIBS
-unset ac_cv_func_getpseudotty
-AC_CHECK_FUNC(getpseudotty, getpseudotty=1 , getpseudotty=0)
-if test $getpseudotty -eq 0 ; then
- unset ac_cv_lib_seq_getpseudotty
- AC_CHECK_LIB(seq, getpseudotty)
-fi
-# save Tcl results and retry for Tk
-EXP_AND_TCL_LIBS=$LIBS
-LIBS=$EXP_AND_TK_LIBS
-unset ac_cv_func_getpseudotty
-AC_CHECK_FUNC(getpseudotty, getpseudotty=1 , getpseudotty=0)
-if test $getpseudotty -eq 0 ; then
- unset ac_cv_lib_seq_getpseudotty
- AC_CHECK_LIB(seq, getpseudotty)
-fi
-# save Tk results and reset for Expect
-EXP_AND_TK_LIBS=$LIBS
-LIBS=$EXP_LIBS
-
-######################################################################
-# Check for FreeBSD/NetBSD openpty()
-# CYGNUS LOCAL: Don't do this on Linux. Alpha Linux Red Hat 4.2 has
-# openpty, but it doesn't work correctly.
-case "${host}" in
-*-*-linux*) ;;
-*-*-cygwin*)
- EXP_AND_TCL_LIBS="$EXP_AND_TCL_LIBS -luser32" ;;
-*)
- unset ac_cv_func_openpty
- AC_CHECK_FUNC(openpty, openpty=1 , openpty=0)
- if test $openpty -eq 0 ; then
- unset ac_cv_lib_util_openpty
- AC_CHECK_LIB(util, openpty, [
- # we only need to define OPENPTY once, but since we are overriding
- # the default behavior, we must also handle augment LIBS too.
- # This needn't be done in the 2nd and 3rd tests.
- AC_DEFINE(HAVE_OPENPTY)
- LIBS="$LIBS -lutil"
- ])
- fi
- # save results and retry for Tcl
- EXP_LIBS=$LIBS
- LIBS=$EXP_AND_TCL_LIBS
- unset ac_cv_func_openpty
- AC_CHECK_FUNC(openpty, openpty=1 , openpty=0)
- if test $openpty -eq 0 ; then
- unset ac_cv_lib_util_openpty
- AC_CHECK_LIB(util, openpty, [
- AC_DEFINE(HAVE_OPENPTY)
- LIBS="$LIBS -lutil"
- ])
- fi
- # save Tcl results and retry for Tk
- EXP_AND_TCL_LIBS=$LIBS
- LIBS=$EXP_AND_TK_LIBS
- unset ac_cv_func_openpty
- AC_CHECK_FUNC(openpty, openpty=1 , openpty=0)
- if test $openpty -eq 0 ; then
- unset ac_cv_lib_util_openpty
- AC_CHECK_LIB(util, openpty, [
- AC_DEFINE(HAVE_OPENPTY)
- LIBS="$LIBS -lutil"
- ])
- fi
- # save Tk results and reset for Expect
- EXP_AND_TK_LIBS=$LIBS
- LIBS=$EXP_LIBS
-;;
-esac
-
-######################################################################
-# End of library/func checking
-######################################################################
-
-######################################################################
-#
-# Look for various header files
-#
-AC_CHECK_HEADER(sys/sysmacros.h, AC_DEFINE(HAVE_SYSMACROS_H))
-AC_CHECK_HEADER(stdlib.h, ,AC_DEFINE(NO_STDLIB_H))
-
-#
-# Look for inttypes.h. Sometimes there are data type conflicts
-# with sys/types.h, so we have to use our own special test.
-#
-dnl AC_CHECK_HEADER(inttypes.h, AC_DEFINE(HAVE_INTTYPES_H))
-CY_AC_INTTYPES_H
-
-# Oddly, some systems have stdarg but don't support prototypes
-# Tcl avoids the whole issue by not using stdarg on UNIX at all!
-dnl AC_CHECK_HEADER(stdarg.h, AC_DEFINE(HAVE_STDARG_H))
-
-AC_CHECK_HEADER(varargs.h, AC_DEFINE(HAVE_VARARGS_H))
-AC_CHECK_HEADER(unistd.h, AC_DEFINE(HAVE_UNISTD_H))
-AC_CHECK_HEADER(sys/stropts.h, AC_DEFINE(HAVE_STROPTS_H))
-AC_CHECK_HEADER(sys/sysconfig.h, AC_DEFINE(HAVE_SYSCONF_H))
-AC_CHECK_HEADER(sys/fcntl.h, AC_DEFINE(HAVE_SYS_FCNTL_H))
-AC_CHECK_HEADER(sys/select.h, AC_DEFINE(HAVE_SYS_SELECT_H))
-AC_CHECK_HEADER(sys/time.h, AC_DEFINE(HAVE_SYS_TIME_H))
-AC_CHECK_HEADER(sys/ptem.h, AC_DEFINE(HAVE_SYS_PTEM_H))
-AC_CHECK_HEADER(sys/strredir.h, AC_DEFINE(HAVE_STRREDIR_H))
-AC_CHECK_HEADER(sys/strpty.h, AC_DEFINE(HAVE_STRPTY_H))
-
-dnl #echo checking for ucbinclude/sys/ioctl.h (ucb-style ioctl.h under SV)
-dnl #if test -f /usr/ucbinclude/sys/ioctl.h ; then
-dnl # AC_DEFINE(HAVE_UCB_IOCTL_H)
-dnl #fi
-
-AC_MSG_CHECKING([for sys/bsdtypes.h])
-if test "ISC_${ISC}" = "ISC_1" ; then
- AC_MSG_RESULT(yes)
- # if on ISC 1, we need <sys/bsdtypes.h> to get FD_SET macros
- AC_HAVE_HEADERS(sys/bsdtypes.h)
-else
- AC_MSG_RESULT(no)
-fi
-
-#
-# Look for functions that may be missing
-#
-dnl AC_CHECK_FUNC(memcpy, AC_DEFINE(HAVE_MEMCPY))
-AC_CHECK_FUNC(memmove, AC_DEFINE(HAVE_MEMMOVE))
-AC_CHECK_FUNC(sysconf, AC_DEFINE(HAVE_SYSCONF))
-AC_CHECK_FUNC(strftime, AC_DEFINE(HAVE_STRFTIME))
-AC_CHECK_FUNC(strchr, AC_DEFINE(HAVE_STRCHR))
-AC_CHECK_FUNC(timezone, AC_DEFINE(HAVE_TIMEZONE))
-
-# dnl check for memcpy by hand
-# because Unixware 2.0 handles it specially and refuses to compile
-# autoconf's automatic test that is a call with no arguments
-AC_MSG_CHECKING([for memcpy])
-AC_TRY_LINK(,[
-char *s1, *s2;
-memcpy(s1,s2,0);
-],
- AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_MEMCPY)
- ,
- AC_MSG_RESULT(no)
-)
-
-# Some systems only define WNOHANG if _POSIX_SOURCE is defined
-# The following merely tests that sys/wait.h can be included
-# and if so that WNOHANG is not defined. The only place I've
-# seen this is ISC.
-AC_MSG_CHECKING([if WNOHANG requires _POSIX_SOURCE])
-AC_TRY_RUN([
-#include <sys/wait.h>
-main() {
-#ifndef WNOHANG
- return 0;
-#else
- return 1;
-#endif
-}],
- AC_MSG_RESULT(yes)
- AC_DEFINE(WNOHANG_REQUIRES_POSIX_SOURCE)
-,
- AC_MSG_RESULT(no)
-,
- [case "${host}" in
- *-*-cygwin*) AC_MSG_RESULT(no) ;;
- *) AC_MSG_ERROR([Expect can't be cross compiled]) ;;
- esac]
-)
-
-AC_MSG_CHECKING([if any value exists for WNOHANG])
-rm -rf wnohang
-AC_TRY_RUN([
-#include <stdio.h>
-#include <sys/wait.h>
-main() {
-#ifdef WNOHANG
- FILE *fp = fopen("wnohang","w");
- fprintf(fp,"%d",WNOHANG);
- fclose(fp);
- return 0;
-#else
- return 1;
-#endif
-}],
- AC_MSG_RESULT(yes)
- AC_DEFINE_UNQUOTED(WNOHANG_BACKUP_VALUE, `cat wnohang`)
- rm -f wnohang
-,
- AC_MSG_RESULT(no)
- AC_DEFINE(WNOHANG_BACKUP_VALUE, 1)
-,
- [case "${host}" in
- *-*-cygwin*) AC_MSG_RESULT(yes)
- AC_DEFINE(WNOHANG_BACKUP_VALUE, 1) ;;
- *) AC_MSG_ERROR([Expect can't be cross compiled]) ;;
- esac]
-)
-
-#
-# check how signals work
-#
-
-# Check for the data type of the mask used in select().
-# This picks up HP braindamage which defines fd_set and then
-# proceeds to ignore it and use int.
-# Pattern matching on int could be loosened.
-# Can't use ac_header_egrep since that doesn't see prototypes with K&R cpp.
-AC_MSG_CHECKING([mask type of select])
-if egrep "select\(size_t, int" /usr/include/sys/time.h >/dev/null 2>&1; then
- AC_MSG_RESULT(int)
- AC_DEFINE(SELECT_MASK_TYPE, int)
-else
- AC_MSG_RESULT(none)
-fi
-
-dnl # Check for the data type of the function used in signal(). This
-dnl # must be before the test for rearming.
-dnl # echo checking return type of signal handlers
-dnl AC_HEADER_EGREP([(void|sighandler_t).*signal], signal.h, retsigtype=void,AC_DEFINE(RETSIGTYPE, int) retsigtype=int)
-
-# FIXME: check if alarm exists
-AC_MSG_CHECKING([if signals need to be re-armed])
-AC_TRY_RUN([
-#include <signal.h>
-#define RETSIGTYPE $retsigtype
-
-int signal_rearms = 0;
-
-RETSIGTYPE
-child_sigint_handler(n)
-int n;
-{
-}
-
-RETSIGTYPE
-parent_sigint_handler(n)
-int n;
-{
-signal_rearms++;
-}
-
-main()
-{
- signal(SIGINT,parent_sigint_handler);
-
- if (0 == fork()) {
- signal(SIGINT,child_sigint_handler);
- kill(getpid(),SIGINT);
- kill(getpid(),SIGINT);
- kill(getppid(),SIGINT);
- } else {
- int status;
-
- wait(&status);
- unlink("core");
- exit(signal_rearms);
- }
-}],
- AC_MSG_RESULT(yes)
- AC_DEFINE(REARM_SIG)
-,
- AC_MSG_RESULT(no)
-,
- [case "${host}" in
- *-*-cygwin*) AC_MSG_RESULT(no) ;;
- *) AC_MSG_WARN([Expect can't be cross compiled]) ;;
- esac]
-)
-
-# HPUX7 has trouble with the big cat so split it
-# Owen Rees <rtor@ansa.co.uk> 29Mar93
-SEDDEFS="${SEDDEFS}CONFEOF
-cat >> conftest.sed <<CONFEOF
-"
-#
-
-# There are multiple versions of getpty, alas.
-# I don't remember who has the first one, but Convex just added one
-# so check for it. Unfortunately, there is no header so the only
-# reasonable way to make sure is to look it we are on a Convex.
-AC_MSG_CHECKING([if on Convex])
-convex=0
-case "${host}" in
- c[[12]]-*-*) convex=1;;
-esac
-
-if test $convex -eq 1 ; then
- AC_MSG_RESULT(yes)
- AC_DEFINE(CONVEX)
-else
- AC_MSG_RESULT(no)
-fi
-
-EXP_LDFLAGS=
-
-AC_MSG_CHECKING([if on NeXT])
-if test -r /NextApps -a "$cross_compiling" != "yes" ; then
- AC_MSG_RESULT(yes)
- # "-m" flag suppresses complaints about multiple strtod
- EXP_LDFLAGS="$EXP_LDFLAGS -m"
-else
- AC_MSG_RESULT(no)
-fi
-
-
-AC_MSG_CHECKING([if on HP])
-if test "x`(uname) 2>/dev/null`" = xHP-UX; then
- AC_MSG_RESULT(yes)
- hp=1
-else
- AC_MSG_RESULT(no)
- hp=0
-fi
-
-AC_MSG_CHECKING([sane default stty arguments])
-DEFAULT_STTY_ARGS="sane"
-
-if test $mach -eq 1 ; then
- DEFAULT_STTY_ARGS="cooked"
-fi
-
-if test $hp -eq 1 ; then
- DEFAULT_STTY_ARGS="sane kill \15"
-fi
-
-AC_MSG_RESULT($DEFAULT_STTY_ARG)
-
-# Look for various features to determine what kind of pty
-# we have. For some weird reason, ac_compile_check would not
-# work, but ac_test_program does.
-#
-AC_MSG_CHECKING([for HP style pty allocation])
-# following test fails on DECstations and other things that don't grok -c
-# but that's ok, since they don't have PTYMs anyway
-if test -r /dev/ptym/ptyp0 2>/dev/null -a "$cross_compiling" != "yes" ; then
- AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_PTYM)
-else
- AC_MSG_RESULT(no)
-fi
-
-AC_MSG_CHECKING([for HP style pty trapping])
-AC_HEADER_EGREP([struct.*request_info], sys/ptyio.h,
- AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_PTYTRAP)
-,
- AC_MSG_RESULT(no)
-)
-
-AC_MSG_CHECKING([for AIX new-style pty allocation])
-if test -r /dev/ptc -a -r /dev/pts -a "$cross_compiling" != "yes" ; then
- AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_PTC_PTS)
-else
- AC_MSG_RESULT(no)
-fi
-
-AC_MSG_CHECKING([for SGI old-style pty allocation])
-if test -r /dev/ptc -a ! -r /dev/pts -a "$cross_compiling" != "yes" ; then
- AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_PTC)
-else
- AC_MSG_RESULT(no)
-fi
-
-# On SCO OpenServer, two types of ptys are available: SVR4 streams and c-list.
-# The library routines to open the SVR4 ptys are broken on certain systems and
-# the SCO command to increase the number of ptys only configure c-list ones
-# anyway. So we chose these, which have a special numbering scheme.
-#
-AC_MSG_CHECKING([for SCO style pty allocation])
-sco_ptys=""
-case "${host}" in
- *-sco3.2v[[45]]*) sco_clist_ptys=1 svr4_ptys_broken=1;;
-esac
-
-if test x"${sco_clist_ptys}" != x"" ; then
- AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_SCO_CLIST_PTYS)
-else
- AC_MSG_RESULT(no)
-fi
-
-AC_MSG_CHECKING([for SVR4 style pty allocation])
-if test -r /dev/ptmx -a "x$svr4_ptys_broken" = x -a "$cross_compiling" != "yes" ; then
- AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_PTMX)
- # aargg. Some systems need libpt.a to use /dev/ptmx
- AC_CHECK_FUNC(ptsname, , LIBS="${LIBS} -lpt")
- # I've never seen Tcl or Tk include -lpt so don't bother with explicit test
- AC_CHECK_FUNC(ptsname, , EXP_AND_TCL_LIBS="${EXP_AND_TCL_LIBS} -lpt")
- AC_CHECK_FUNC(ptsname, , EXP_AND_TK_LIBS="${EXP_AND_TK_LIBS} -lpt")
- # CYGNUS LOCAL: IA-64
- # On some systems (e.g., IA-64 Linux), we need to define _XOPEN_SOURCE
- # in order to get a declaration for ptsname. It is safe to simply
- # define that whenever we are using ptsname.
- AC_MSG_CHECKING([for NSIG definition with _XOPEN_SOURCE])
- AC_TRY_COMPILE([
-/* _XOPEN_SOURCE can remove NSIG on UnixWare or OSF/1. */
-#define _XOPEN_SOURCE
-#include <signal.h>
-#ifndef NSIG
-#define NSIG _NSIG
-#endif
-char junk[NSIG];],
- [],
- AC_DEFINE(_XOPEN_SOURCE)
- AC_MSG_RESULT(yes)
- ,
- AC_MSG_RESULT(no)
- ,
- )
- # END CYGNUS LOCAL
-else
- AC_MSG_RESULT(no)
-fi
-
-# In OSF/1 case, SVR4 are somewhat different.
-# Gregory Depp <depp@osf.org> 17Aug93
-AC_MSG_CHECKING([for OSF/1 style pty allocation])
-if test -r /dev/ptmx_bsd -a "$cross_compiling" != "yes" ; then
- AC_DEFINE(HAVE_PTMX_BSD)
- AC_MSG_RESULT(yes)
-else
- AC_MSG_RESULT(no)
-fi
-
-# Set the pty handling for Cygwin
-case "${host}" in
- *-*-cygwin*) AC_DEFINE(HAVE_PTMX) ;;
- *) ;;
-esac
-
-tcgetattr=0
-tcsetattr=0
-AC_CHECK_FUNC(tcgetattr, tcgetattr=1)
-AC_CHECK_FUNC(tcsetattr, tcsetattr=1)
-if test $tcgetattr -eq 1 -a $tcsetattr -eq 1 ; then
- AC_DEFINE(HAVE_TCSETATTR)
- AC_DEFINE(POSIX)
-fi
-
-# first check for the pure bsd
-AC_MSG_CHECKING([for struct sgttyb])
-AC_TRY_RUN([
-#include <sgtty.h>
-main()
-{
- struct sgttyb tmp;
- exit(0);
-}],
- AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_SGTTYB)
- PTY_TYPE=sgttyb
-,
- AC_MSG_RESULT(no)
-,
- [case "${host}" in
- *-*-cygwin*) AC_MSG_RESULT(no) ;;
- *) AC_MSG_ERROR([Expect can't be cross compiled]) ;;
- esac]
-)
-
-# mach systems have include files for unimplemented features
-# so avoid doing following test on those systems
-if test $mach -eq 0 ; then
-
- # next check for the older style ttys
- # note that if we detect termio.h (only), we still set PTY_TYPE=termios
- # since that just controls which of pty_XXXX.c file is use and
- # pty_termios.c is set up to handle pty_termio.
- AC_MSG_CHECKING([for struct termio])
- AC_TRY_RUN([#include <termio.h>
- main()
- {
- struct termio tmp;
- exit(0);
- }],
- AC_DEFINE(HAVE_TERMIO)
- PTY_TYPE=termios
- AC_MSG_RESULT(yes)
-,
- AC_MSG_RESULT(no)
-,
- [case "${host}" in
- *-*-cygwin*) AC_MSG_RESULT(no) ;;
- *) AC_MSG_ERROR([Expect can't be cross compiled]) ;;
- esac]
-)
-
- # now check for the new style ttys (not yet posix)
- AC_MSG_CHECKING([for struct termios])
- AC_TRY_RUN([
-# ifdef HAVE_INTTYPES_H
-# include <inttypes.h>
-# endif
-# include <termios.h>
- main()
- {
- struct termios tmp;
- exit(0);
- }],
- AC_DEFINE(HAVE_TERMIOS)
- PTY_TYPE=termios
- AC_MSG_RESULT(yes)
- ,
- AC_MSG_RESULT(no)
- ,
- [case "${host}" in
- *-*-cygwin*) AC_DEFINE(HAVE_TERMIOS)
- PTY_TYPE=termios
- AC_MSG_RESULT(yes) ;;
- *) AC_MSG_ERROR([Expect can't be cross compiled]) ;;
- esac]
- )
-fi
-
-AC_MSG_CHECKING([if TCGETS or TCGETA in termios.h])
-AC_TRY_RUN([
-/* including termios.h on Solaris 5.6 fails unless inttypes.h included */
-#ifdef HAVE_INTTYPES_H
-#include <inttypes.h>
-#endif
-#include <termios.h>
-main() {
-#if defined(TCGETS) || defined(TCGETA)
- return 0;
-#else
- return 1;
-#endif
-}],
- AC_DEFINE(HAVE_TCGETS_OR_TCGETA_IN_TERMIOS_H)
- AC_MSG_RESULT(yes)
-,
- AC_MSG_RESULT(no)
-,
- [case "${host}" in
- *-*-cygwin*) AC_DEFINE(HAVE_TCGETS_OR_TCGETA_IN_TERMIOS_H)
- AC_MSG_RESULT(yes) ;;
- *) AC_MSG_ERROR([Expect can't be cross compiled]) ;;
- esac]
-)
-
-AC_MSG_CHECKING([if TIOCGWINSZ in termios.h])
-AC_TRY_RUN([
-/* including termios.h on Solaris 5.6 fails unless inttypes.h included */
-#ifdef HAVE_INTTYPES_H
-#include <inttypes.h>
-#endif
-#include <termios.h>
-main() {
-#ifdef TIOCGWINSZ
- return 0;
-#else
- return 1;
-#endif
-}],
- AC_DEFINE(HAVE_TIOCGWINSZ_IN_TERMIOS_H)
- AC_MSG_RESULT(yes)
-,
- AC_MSG_RESULT(no)
-,
- [case "${host}" in
- *-*-cygwin*) AC_DEFINE(HAVE_TIOCGWINSZ_IN_TERMIOS_H)
- AC_MSG_RESULT(yes) ;;
- *) AC_MSG_ERROR([Expect can't be cross compiled]) ;;
- esac]
-)
-
-# finally check for Cray style ttys
-AC_MSG_CHECKING([for Cray-style ptys])
-SETUID=":"
-AC_TRY_RUN([
-main(){
-#ifdef CRAY
- return 0;
-#else
- return 1;
-#endif
-}
-],
- PTY_TYPE=unicos
- SETUID="chmod u+s"
- AC_MSG_RESULT(yes)
-,
- AC_MSG_RESULT(no)
-,
- [case "${host}" in
- *-*-cygwin*) AC_MSG_RESULT(no) ;;
- *) AC_MSG_ERROR([Expect can't be cross compiled]) ;;
- esac]
-)
-
-#
-# Check for select and/or poll. If both exist, we prefer select.
-# if neither exists, define SIMPLE_EVENT.
-#
-select=0
-poll=0
-unset ac_cv_func_select
-AC_CHECK_FUNC(select, select=1)
-AC_CHECK_FUNC(poll, poll=1)
-AC_MSG_CHECKING([event handling])
-if test $select -eq 1 ; then
- EVENT_TYPE=select
- EVENT_ABLE=event
- AC_MSG_RESULT(via select)
-elif test $poll -eq 1 ; then
- EVENT_TYPE=poll
- EVENT_ABLE=event
- AC_MSG_RESULT(via poll)
-else
- EVENT_TYPE=simple
- EVENT_ABLE=noevent
- AC_MSG_RESULT(none)
- AC_DEFINE(SIMPLE_EVENT)
-fi
-
-AC_HAVE_FUNCS(_getpty)
-AC_HAVE_FUNCS(getpty)
-
-#
-# check for timezones
-#
-AC_MSG_CHECKING([for SV-style timezone])
-AC_TRY_RUN([
-extern char *tzname[2];
-extern int daylight;
-main()
-{
- int *x = &daylight;
- char **y = tzname;
-
- exit(0);
-}],
- AC_DEFINE(HAVE_SV_TIMEZONE)
- AC_MSG_RESULT(yes),
- AC_MSG_RESULT(no)
-,
- [case "${host}" in
- *-*-cygwin*) AC_MSG_RESULT(no) ;;
- *) AC_MSG_ERROR([Expect can't be cross compiled]) ;;
- esac]
-)
-
-# only look for Tk stuff if we have X11 and user doesn't say not to
-AC_ARG_WITH(x, [ --with-x whether or not to use X (default yes)], , with_x=yes)
-if test "$with_x" = "no"; then
- no_tk=true
-else
- CY_AC_PATH_TKH
-fi
-if test x"$no_tk" != x"true" ; then
-# libexpectk no longer exists
-# X_PROGS="expectk \$(LIBEXPECTK)"
- X_PROGS=expectk
-# should really generate following symbol, but I'm hitting configure's limit on substs.
- X_PROGS_INSTALLED=expectk_installed
-else
- X_PROGS="# no X support on this system"
- AC_MSG_WARN([No X based programs will be built])
- echo " WARNING: Can't find Tk headers or library. You can still"
- echo " build expect, but not expectk. See Expect's README for"
- echo " information on how to obtain Tk. If Tk is installed, see"
- echo " Expect's INSTALL on how to tell configure where Tk is"
- echo " installed."
-fi
-
-# consume these flags so that user can invoke Expect's configure with
-# the same command as Tcl's configure
-AC_ARG_ENABLE(load,
- [ --disable-load disallow dynamic loading],
- [disable_dl=$enableval], [disable_dl=no])
-
-AC_ARG_ENABLE(gcc,
- [ --enable-gcc allow use of gcc if available],
- [enable_gcc=$enableval], [enable_gcc=no])
-
-
-# Following comment stolen from Tcl's configure.in:
-# Note: in the following variable, it's important to use the absolute
-# path name of the Tcl directory rather than "..": this is because
-# AIX remembers this path and will attempt to use it at run-time to look
-# up the Tcl library.
-
-if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then
- EXP_LIB_VERSION=$EXP_VERSION
-else
- EXP_LIB_VERSION=$EXP_VERSION_NODOTS
-fi
-if test $iunix -eq 1 ; then
- EXP_LIB_VERSION=$EXP_VERSION_NODOTS
-fi
-
-# also remove dots on systems that don't support filenames > 14
-# (are there systems which support shared libs and restrict filename lengths!?)
-AC_SYS_LONG_FILE_NAMES
-if test $ac_cv_sys_long_file_names = no; then
- EXP_LIB_VERSION=$EXP_VERSION_NODOTS
-fi
-
-EXP_BUILD_LIB_SPEC="-L`pwd` -lexpect${EXP_LIB_VERSION}"
-EXP_LIB_SPEC="-L\${libdir} -lexpect${EXP_LIB_VERSION}"
-EXP_UNSHARED_LIB_FILE=libexpect${EXP_LIB_VERSION}.a
-EXP_BUILD_LIB_SPEC=${EXP_UNSHARED_LIB_FILE}
-
-AC_MSG_CHECKING([for type of library to build])
-if test "$enable_shared" = "yes" && test "x${TCL_SHLIB_SUFFIX}" != "x" ; then
- EXP_SHLIB_CFLAGS=$TCL_SHLIB_CFLAGS
-# EXP_SHARED_LIB_FILE=libexpect$EXP_LIB_VERSION$TCL_SHLIB_SUFFIX
- eval "EXP_SHARED_LIB_FILE=libexpect${TCL_SHARED_LIB_SUFFIX}"
- EXP_LIB_FILE=$EXP_SHARED_LIB_FILE
- EXP_LIB_FILES="$EXP_SHARED_LIB_FILE $EXP_UNSHARED_LIB_FILE"
- AC_MSG_RESULT(both shared and unshared)
-else
- EXP_SHLIB_CFLAGS=
- EXP_SHARED_LIB_FILE="reconfigure_Tcl_for_shared_library"
- EXP_LIB_FILE=$EXP_UNSHARED_LIB_FILE
- EXP_LIB_FILES="$EXP_UNSHARED_LIB_FILE"
- AC_MSG_RESULT(unshared)
-fi
-
-# CYGNUS LOCAL
-# We always link expect statically (against $EXP_UNSHARED_LIB_FILE)
-# so we can run it out of the build directory without hurting
-# ourselves and others.
-dnl EXP_LIB_FILE=$EXP_UNSHARED_LIB_FILE
-
-# now broken out into EXP_AND_TCL_LIBS and EXP_AND_TK_LIBS. Had to do this
-# in order to avoid repeating lib specs to which some systems object.
-EXP_AND_TCL_LIBS="$EXP_AND_TCL_LIBS $TCL_CC_SEARCH_FLAGS"
-EXP_AND_TK_LIBS="$EXP_AND_TK_LIBS $TCL_CC_SEARCH_FLAGS"
-
-# Sigh - Tcl defines SHLIB_LD_LIBS to be either empty or ${LIBS} and
-# LIBS is intended to be expanded by Make. But since we're too close
-# to hitting config's max symbols, pack everything together here and
-# do test ourselves. Ugh.
-#
-if test "x$TCL_SHLIB_LD_LIBS" = "x" ; then
- EXP_SHLIB_LD_LIBS=""
-else
- # seems a little strange to build in Tcl's build-lib, but
- # that's what Tk does.
- EXP_SHLIB_LD_LIBS="$TCL_BUILD_LIB_SPEC $TCL_DL_LIBS $LIBS -lc"
-fi
-
-dnl CYGNUS LOCAL
-dnl check for win32 dependencies
-CY_AC_CYGWIN
-CY_AC_EXEEXT
-
-#--------------------------------------------------------------------
-# This section is based on analogous thing in Tk installation. - DEL
-# Various manipulations on the search path used at runtime to
-# find shared libraries:
-# 2. On systems such as AIX and Ultrix that use "-L" as the
-# search path option, colons cannot be used to separate
-# directories from each other. Change colons to " -L".
-# 3. Create two sets of search flags, one for use in cc lines
-# and the other for when the linker is invoked directly. In
-# the second case, '-Wl,' must be stripped off and commas must
-# be replaced by spaces.
-#--------------------------------------------------------------------
-
-LIB_RUNTIME_DIR='${LIB_RUNTIME_DIR}'
-
-# If Tcl and Expect are installed in different places, adjust the library
-# search path to reflect this.
-
-if test "$TCL_EXEC_PREFIX" != "$exec_prefix"; then
- LIB_RUNTIME_DIR="${LIB_RUNTIME_DIR}:${TCL_EXEC_PREFIX}"
-fi
-
-if test "${TCL_LD_SEARCH_FLAGS}" = '-L${LIB_RUNTIME_DIR}'; then
- LIB_RUNTIME_DIR=`echo ${LIB_RUNTIME_DIR} |sed -e 's/:/ -L/g'`
-fi
-
-# The statement below is very tricky! It actually *evaluates* the
-# string in TCL_LD_SEARCH_FLAGS, which causes a substitution of the
-# variable LIB_RUNTIME_DIR.
-
-eval "EXP_CC_SEARCH_FLAGS=\"$TCL_LD_SEARCH_FLAGS\""
-if test "$GCC" = yes; then
- true
-else
- EXP_LD_SEARCH_FLAGS=`echo ${EXP_CC_SEARCH_FLAGS} |sed -e "s|-Wl,||g" -e "s|,| |g"`
-fi
-
-#
-# Set up makefile substitutions
-#
-AC_SUBST(EXP_MAJOR_VERSION)
-AC_SUBST(EXP_MINOR_VERSION)
-AC_SUBST(EXP_MICRO_VERSION)
-AC_SUBST(EXP_VERSION_FULL)
-AC_SUBST(EXP_VERSION)
-AC_SUBST(CC)
-AC_SUBST(EXP_CONFIG_SHELL)
-AC_SUBST(EXP_SHARED_LIB_FILE)
-AC_SUBST(EXP_UNSHARED_LIB_FILE)
-AC_SUBST(EXP_SHLIB_CFLAGS)
-AC_SUBST(EXP_LIB_FILE)
-AC_SUBST(EXP_LIB_FILES)
-AC_SUBST(EXP_BUILD_LIB_SPEC)
-AC_SUBST(EXP_LIB_SPEC)
-AC_SUBST(EXP_CFLAGS)
-AC_SUBST(EXP_LDFLAGS)
-AC_SUBST(EXP_LD_SEARCH_FLAGS)
-AC_SUBST(EXP_AND_TCL_LIBS)
-AC_SUBST(EXP_AND_TK_LIBS)
-AC_SUBST(EXP_SHLIB_LD_LIBS)
-AC_SUBST(X_PROGS)
-AC_SUBST(PTY_TYPE)
-AC_SUBST(EVENT_TYPE)
-AC_SUBST(EVENT_ABLE)
-AC_SUBST(SETUID)
-AC_SUBST(UNSHARED_RANLIB)
-AC_SUBST(DEFAULT_STTY_ARGS)
-AC_OUTPUT(Makefile pkgIndex)
+++ /dev/null
-TCLVERSION = 8.0
-EXPVERSION = 5.25
-TCLROOT = ../../tcl$(TCLVERSION)
-
-# Tcl include files. (If you haven't installed Tcl yet, read the README file).
-# This must point to the directory that contains ALL of Tcl's include
-# files, not just the public ones.
-TCLHDIR = $(TCLROOT)/generic
-
-# TCL library. Very little actually comes out of it, but it is handy.
-TCLLIB = $(TCLROOT)/unix/libtcl$(TCLVERSION).so
-# if installed, you can use:
-# TCLLIB = -ltcl
-
-CC = gcc
-CPLUSPLUS = g++
-CPLUSPLUSLIBDIR = -L/depot/gnu/arch/lib
-CPLUSPLUSLIB = -lg++
-
-CFLAGS = -g -I.. -I$(TCLHDIR)
-LIBEXPECT = -L.. -lexpect$(EXPVERSION)
-
-LIBS = $(LIBEXPECT) $(TCLLIB) -lm
-
-SCRIPTS = su2 noidle script.exp bonfield.exp
-
-all: chesslib chesslib2 chesslib++
-
-# this can be compiled with either cc or gcc
-chesslib: chesslib.o
- $(CC) -g -o chesslib chesslib.o $(LIBS)
-
-# this can be compiled with either cc or gcc
-chesslib2: chesslib2.o
- $(CC) -g -o chesslib2 chesslib2.o $(LIBS)
-
-# this is compiled with c++
-chesslib++: chesslib++.o
- $(CPLUSPLUS) -g -o chesslib++ chesslib++.o $(LIBS) \
- $(CPLUSPLUSLIBDIR) $(CPLUSPLUSLIB)
-
-chesslib++.o: chesslib++.c
- $(CPLUSPLUS) -c $(CFLAGS) chesslib++.c
-
-unbuffer-standalone: unbuffer.o
- $(CC) -g -o unbuffer-standalone unbuffer.o $(LIBS)
-
-printvars: printvars.o
- $(CC) -o printvars printvars.o $(LIBS)
-
-ftplib: ftplib.o
- $(CC) -g -o ftplib ftplib.o $(LIBS)
-
-match_max: match_max.o
- $(CC) -g -o match_max match_max.o $(LIBS)
-
-jaj1: jaj1.o
- $(CC) -g -o jaj1 jaj1.o $(LIBS)
-
-jaj2: jaj2.o
- $(CC) -g -o jaj2 jaj2.o $(LIBS)
-
-# wrap up password-generation examples
-passgen:
- shar passgen.README tkpasswd mkpasswd mkpasswd.man > /tmp/passgen
-
-cleanup:
- rm -f expect devtty exho dumb test.raw test.results test.tmp
-
-# copy some contributed scripts over to public-accessible directory
-SCRIPTDIR = ~ftp/pub/expect/scripts
-ftp:
- rcp README.scripts durer:$(SCRIPTDIR)/README
- rcp $(SCRIPTS) durer:$(SCRIPTDIR)
- rsh durer ls -l $(SCRIPTDIR)
+++ /dev/null
-This file is example/README. It contains brief descriptions of the
-examples in this directory. Also listed are scripts from the Expect
-archive at ftp.cme.nist.gov (See Expect's README for how to retrieve
-these from). You are welcome to send me additional scripts. A number
-of Expect scripts are also available in the Tcl archive, available via
-anonymous ftp at harbor.ecn.purdue.edu
-
-Note that on some systems, some of the scripts (notably kibitz and
-dislocate) require that Expect be installed. (Merely compiling the
-expect binary is not enough.)
-
---------------------
-Expect scripts (See next section for example Tk scripts)
---------------------
-Entries marked with "m" have their own man page.
-Entries marked with "a" live in the Expect archive (see above).
-
- archie - mails back response after talking to archie ftp-catalog.
- m autoexpect - generate an Expect script from watching a session
- autopasswd - runs passwd non-interactively for superuser.
- a bc - Uses bc to do arbitrary precision math.
- beer.exp - 99 Bottles of Beer On The Wall, Expect-style.
- beer.exp.out - sample output from beer.exp (but you really have to
- run it to see the timing aspect).
- a bonfield.exp - solve Jim Bonfield's puzzle that won the 1991 Obfuscated
- C Code contest.
- carpal - warn about typing for too long without a break.
- chess.exp - has two chess games play each other.
- m cryptdir - encrypt all files in a directory.
- m decryptdir - decrypt all files in a directory.
- m dislocate - allow disconnection/reconnection to background processes.
- dvorak - dvorak keyboard.
- a eftp - ftp client with miscellaneous frills (also see rftp below).
- expectd.proto - telnet daemon.
- ftp-inband - does file transfer over telnet, rlogin, etc.
- ftp-rfc - retrieve a DoD RFC from uunet via anonymous ftp.
- ftp-talk-radio - gets "Internet Talk Radio" files from a host.
- gethostbyaddr - translates internet address to name (with a higher
- success rate than nslookup). Easier to use, too.
- irsh - run interactive commands via rsh
- m kibitz - lets two people control a program at the same time.
- Lots of uses. I.e., You can help another person remotely.
- Can run an editor and log a transcript of a conversation.
- a libro-II - connect to Libro-II, the NIST library catalog.
- lpunlock - unhangs a printer which says it is "waiting for lock".
- a mirror_file - mirror a file from another ftp site, copying file only
- if changed.
- a mirror_dir - mirror a directory from another ftp site, copying only
- files which have changed.
- m mkpasswd - generates good passwords, optionally runs passwd with them.
- a mx - return any MX records for the given host.
- a noidle - run a shell which avoids being 'autologged out'.
- a pager.alpha - sends a message to a (Alpha brand) pager.
- a pager.mercury - sends a message to a (Mercury brand) pager.
- m passmass - sets passwd on many machines simultaneously.
- passwd.html - form to change a login passwd
- passwd.cgi - CGI script to respond to passwd.html form
- a ping-and-page - Ping list of hosts. If any down, page system admin.
- read1char - read a single character for the shell, Perl, etc.
- reprompt - like timed-read but reprompt after given amount of time.
- rlogin-cwd - rlogin giving you same current working directory.
- (Compare to telnet-cwd and xrlogin.)
- robohunt - plays the game of hunt (from Berkeley).
- It's more of a wild player than good, but amusing to watch.
- Fun to throw against people who don't know about it.
- rogue.exp - finds a good game of rogue.
- rftp - recursive ftp (assumes UNIX-style ftpd at other end).
- a s-key-rlogin - Automate rlogin (or telnet) using s/key
- a scripttoggle - Like UNIX script command, but allow enabling/disabling
- of recording.
- a slip.shar - scripts to keep your SLIP link alive.
- su.exp - start up an 'su' and run the argument.
- telnet-cwd - telnet giving you same current working directory.
- telnet-in-bg - put telnet (or any program) in bg, saving all remaining
- output to a logfile.
- a term-rlogin - run Term over rlogin. Good for traversing PPP/SLIP or
- firewall rlogin connections.
- a term-start - start up Term (a sophisticated UNIX-to-UNIX serial line
- handler).
- a timed-choice - offer user a timed choice of responses.
- timed-read - a timed read for the shell, Perl, etc. Compare with
- reprompt example.
- m timed-run - run a program for only a given amount of time.
- a try-phone-list - automate logging in to remote system, trying numbers
- from a list until finding one that works.
- m unbuffer - disables output buffering that normally occurs when
- programs are redirected.
- virterm - example of terminal emulation and expect operations on
- character graphics using arrays (compare to term_expect
- (below) which uses Tk widget).
- vrfy - verifies an email address using SMTP/VRFY to remote site.
- a waste-collection - Contact NIST service for hazardous waste pickup.
- weather - retrieves weather forecasts.
- m xkibitz - similar to kibitz but uses X Window System for handling
- communication. Also, allows users to be added dynamically.
- xrlogin - rlogin giving you same DISPLAY. (Compare to rlogin-cwd.)
-
-To run, for example, chess.exp, type:
-
- expect chess.exp
-
-If expect is installed and your system supports the #! magic you can
-invoke it as:
-
- chess.exp
-
-Each of these examples necessarily depends upon other binaries in the
-system. For example, chess.exp depends upon the "usual" UNIX chess
-program being present. If any of these programs are different,
-it may cause the associated script to misbehave.
-
-Please use the ".exp" extension on scripts that might otherwise have
-names that could be confused with the real program, such as "rogue.exp".
-Scripts that have unique names do not need the extension, such as "rftp".
-
---------------------
-Sample Expectk scripts
---------------------
-Entries marked with "m" have their own man page.
-
- term_expect - template for doing expect operations on character
- graphics.
- m tknewsbiff - pops up a window (or plays sounds, etc) when news
- arrives in selected newsgroups.
- tkpasswd - Tk GUI for changing passwords.
- tkterm - Tk terminal emulator in a Tk text widget.
- xpstat - provide an X window front end to the xpilot game.
-
---------------------
-Sample C and C++ programs that use the Expect library
---------------------
-
- chesslib.c - same thing as chess.exp, but in C.
- chesslib2.c - ditto, but uses popen and stream-style I/O.
- chesslib++.c - ditto, but for C++.
- m unbuffer.c - same as unbuffer example but standalone
-
-You may change the value of CC or CPLUSPLUS in the Makefile, to
-compile under gcc or other compilers. However, you may have to edit
-the lines defining where the libraries are.
-
+++ /dev/null
-#!../expect -f
-
-# archie
-
-# Log in to the archie ftp-catalog at McGill University, and mail back results
-# Brian P. Fitzgerald
-# Department of Mechanical Engineering
-# Rensselaer Polytechnic Institute
-
-set CINTR \003 ;# ^C
-set CSUSP \032 ;# ^Z
-
-set timeout -1
-spawn telnet quiche.cs.mcgill.ca
-
-expect_after eof exit ;# archie logs us out if too many people are logged in
-
-expect {
- login: {send archie\r}
- "unknown" {exit 1}
- "unreachable" {exit 1}
-}
-
-expect "archie>" {send "set pager\r"}
-expect "archie>" {send "set maxhits 20\r"}
-expect "archie>" {send "set term vt100\r"}
-expect "archie>" {send "set sortby time\r"}
-expect "archie>" {
- send "set mailto [exec whoami]@[exec hostname].[exec domainname]\r"
-}
-
-send_user "type ^C to exit, ^Z to suspend\n"
-interact {
- -reset $CSUSP {exec kill -STOP [pid]}
- $CINTR {exit 0}
-}
+++ /dev/null
-#!../expect --
-# Name: autoexpect - generate an Expect script from watching a session
-#
-# Description:
-#
-# Given a program name, autoexpect will run that program. Otherwise
-# autoexpect will start a shell. Interact as desired. When done, exit
-# the program or shell. Autoexpect will create a script that reproduces
-# your interactions. By default, the script is named script.exp.
-# See the man page for more info.
-#
-# Author: Don Libes, NIST
-# Date: June 30 1995
-# Version: 1.4b
-
-set filename "script.exp"
-set verbose 1
-set conservative 0
-set promptmode 0
-set option_keys ""
-
-proc check_for_following {type} {
- if ![llength [uplevel set argv]] {
- puts "autoexpect: [uplevel set flag] requires following $type"
- exit 1
- }
-}
-
-while {[llength $argv]>0} {
- set flag [lindex $argv 0]
- if 0==[regexp "^-" $flag] break
- set argv [lrange $argv 1 end]
- switch -- $flag \
- "-c" {
- set conservative 1
- } "-C" {
- check_for_following character
- lappend option_keys [lindex $argv 0] ctoggle
- set argv [lrange $argv 1 end]
- } "-p" {
- set promptmode 1
- } "-P" {
- check_for_following character
- lappend option_keys [lindex $argv 0] ptoggle
- set argv [lrange $argv 1 end]
- } "-Q" {
- check_for_following character
- lappend option_keys [lindex $argv 0] quote
- set argv [lrange $argv 1 end]
- } "-f" {
- check_for_following filename
- set filename [lindex $argv 0]
- set argv [lrange $argv 1 end]
- } "-quiet" {
- set verbose 0
- } default {
- break
- }
-}
-
-#############################################################
-# Variables Descriptions
-#############################################################
-# userbuf buffered characters from user
-# procbuf buffered characters from process
-# lastkey last key pressed by user
-# if undefined, last key came from process
-# echoing if the process is echoing
-#############################################################
-
-# Handle a character that came from user input (i.e., the keyboard)
-proc input {c} {
- global userbuf lastkey
-
- send -- $c
- append userbuf $lastkey
- set lastkey $c
-}
-
-# Handle a null character from the keyboard
-proc input_null {} {
- global lastkey userbuf procbuf echoing
-
- send -null
-
- if {$lastkey == ""} {
- if $echoing {
- sendcmd "$userbuf"
- }
- if {$procbuf != ""} {
- expcmd "$procbuf"
- }
- } else {
- sendcmd "$userbuf"
- if $echoing {
- expcmd "$procbuf"
- sendcmd "$lastkey"
- }
- }
- cmd "send -null"
- set userbuf ""
- set procbuf ""
- set lastkey ""
- set echoing 0
-}
-
-# Handle a character that came from the process
-proc output {s} {
- global lastkey procbuf userbuf echoing
-
- send_user -raw -- $s
-
- if {$lastkey == ""} {
- if !$echoing {
- append procbuf $s
- } else {
- sendcmd "$userbuf"
- expcmd "$procbuf"
- set echoing 0
- set userbuf ""
- set procbuf $s
- }
- return
- }
-
- regexp (.)(.*) $s dummy c tail
- if {$c == $lastkey} {
- if $echoing {
- append userbuf $lastkey
- set lastkey ""
- } else {
- if {$procbuf != ""} {
- expcmd "$procbuf"
- set procbuf ""
- }
- set echoing 1
- }
- append procbuf $s
-
- if [string length $tail] {
- sendcmd "$userbuf$lastkey"
- set userbuf ""
- set lastkey ""
- set echoing 0
- }
- } else {
- if !$echoing {
- expcmd "$procbuf"
- }
- sendcmd "$userbuf$lastkey"
- set procbuf $s
- set userbuf ""
- set lastkey ""
- set echoing 0
- }
-}
-
-# rewrite raw strings so that can appear as source code but still reproduce
-# themselves.
-proc expand {s} {
- regsub -all "\\\\" $s "\\\\\\\\" s
- regsub -all "\r" $s "\\r" s
- regsub -all "\"" $s "\\\"" s
- regsub -all "\\\[" $s "\\\[" s
- regsub -all "\\\]" $s "\\\]" s
- regsub -all "\\\$" $s "\\\$" s
-
- return $s
-}
-
-# generate an expect command
-proc expcmd {s} {
- global promptmode
-
- if $promptmode {
- regexp ".*\[\r\n]+(.*)" $s dummy s
- }
-
- cmd "expect -exact \"[expand $s]\""
-}
-
-# generate a send command
-proc sendcmd {s} {
- global send_style conservative
-
- if {$conservative} {
- cmd "sleep .1"
- }
-
- cmd "send$send_style -- \"[expand $s]\""
-}
-
-# generate any command
-proc cmd {s} {
- global fd
- puts $fd "$s"
-}
-
-proc verbose_send_user {s} {
- global verbose
-
- if $verbose {
- send_user -- $s
- }
-}
-
-proc ctoggle {} {
- global conservative send_style
-
- if $conservative {
- cmd "# conservative mode off - adding no delays"
- verbose_send_user "conservative mode off\n"
- set conservative 0
- set send_style ""
- } else {
- cmd "# prompt mode on - adding delays"
- verbose_send_user "conservative mode on\n"
- set conservative 1
- set send_style " -s"
- }
-}
-
-proc ptoggle {} {
- global promptmode
-
- if $promptmode {
- cmd "# prompt mode off - now looking for complete output"
- verbose_send_user "prompt mode off\n"
- set promptmode 0
- } else {
- cmd "# prompt mode on - now looking only for prompts"
- verbose_send_user "prompt mode on\n"
- set promptmode 1
- }
-}
-
-# quote the next character from the user
-proc quote {} {
- expect_user -re .
- send -- $expect_out(buffer)
-}
-
-
-if [catch {set fd [open $filename w]} msg] {
- puts $msg
- exit
-}
-exec chmod +x $filename
-verbose_send_user "autoexpect started, file is $filename\n"
-
-# calculate a reasonable #! line
-set expectpath /usr/local/bin ;# prepare default
-foreach dir [split $env(PATH) :] { ;# now look for real location
- if [file executable $dir/expect] {
- set expectpath $dir
- break
- }
-}
-
-cmd "#![set expectpath]/expect -f
-#
-# This Expect script was generated by autoexpect on [timestamp -format %c]
-# Expect and autoexpect were both written by Don Libes, NIST."
-cmd {#
-# Note that autoexpect does not guarantee a working script. It
-# necessarily has to guess about certain things. Two reasons a script
-# might fail are:
-#
-# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet,
-# etc.) and devices discard or ignore keystrokes that arrive "too
-# quickly" after prompts. If you find your new script hanging up at
-# one spot, try adding a short sleep just before the previous send.
-# Setting "force_conservative" to 1 (see below) makes Expect do this
-# automatically - pausing briefly before sending each character. This
-# pacifies every program I know of. The -c flag makes the script do
-# this in the first place. The -C flag allows you to define a
-# character to toggle this mode off and on.
-
-set force_conservative 0 ;# set to 1 to force conservative mode even if
- ;# script wasn't run conservatively originally
-if {$force_conservative} {
- set send_slow {1 .1}
- proc send {ignore arg} {
- sleep .1
- exp_send -s -- $arg
- }
-}
-
-#
-# 2) differing output - Some programs produce different output each time
-# they run. The "date" command is an obvious example. Another is
-# ftp, if it produces throughput statistics at the end of a file
-# transfer. If this causes a problem, delete these patterns or replace
-# them with wildcards. An alternative is to use the -p flag (for
-# "prompt") which makes Expect only look for the last line of output
-# (i.e., the prompt). The -P flag allows you to define a character to
-# toggle this mode off and on.
-#
-# Read the man page for more info.
-#
-# -Don
-
-}
-
-cmd "set timeout -1"
-if $conservative {
- set send_style " -s"
- cmd "set send_slow {1 .1}"
-} else {
- set send_style ""
-}
-
-if [llength $argv]>0 {
- eval spawn -noecho $argv
- cmd "spawn $argv"
-} else {
- spawn -noecho $env(SHELL)
- cmd "spawn \$env(SHELL)"
-}
-
-cmd "match_max 100000"
-
-set lastkey ""
-set procbuf ""
-set userbuf ""
-set echoing 0
-
-remove_nulls 0
-
-eval interact $option_keys {
- -re . {
- input $interact_out(0,string)
- } null {
- input_null
- } \
- -o \
- -re .+ {
- output $interact_out(0,string)
- } eof {
- cmd "expect eof"
- return
- } null {
- }
-}
-
-close $fd
-verbose_send_user "autoexpect done, file is $filename\n"
+++ /dev/null
-.TH AUTOEXPECT 1 "30 June 1995"
-.SH NAME
-autoexpect \- generate an Expect script from watching a session
-.SH SYNOPSIS
-.B autoexpect
-[
-.I args
-]
-[
-.I program args...
-]
-.br
-.SH INTRODUCTION
-
-autoexpect watches you interacting with another program and creates an
-Expect script that reproduces your interactions. For straightline
-scripts, autoexpect saves substantial time over writing scripts by
-hand. Even if you are an Expect expert, you will find it convenient
-to use autoexpect to automate the more mindless parts of interactions.
-It is much easier to cut/paste hunks of autoexpect scripts together
-than to write them from scratch. And if you are a beginner, you may
-be able to get away with learning nothing more about Expect than how
-to call autoexpect.
-
-The simplest way to use autoexpect is to call it from the command line
-with no arguments. For example:
-
- % autoexpect
-
-By default, autoexpect spawns a shell for you. Given a program name
-and arguments, autoexpect spawns that program. For example:
-
- % autoexpect ftp ftp.cme.nist.gov
-
-Once your spawned program is running, interact normally. When you
-have exited the shell (or program that you specified), autoexpect will
-create a new script for you. By default, autoexpect writes the new
-script to "script.exp". You can override this with the \-f flag
-followed by a new script name.
-
-The following example runs "ftp ftp.cme.nist.gov" and stores the
-resulting Expect script in the file "nist".
-.nf
-
- % autoexpect \-f nist ftp ftp.cme.nist.gov
-
-.fi
-It is important to understand that
-autoexpect does not guarantee a working script because it necessarily
-has to guess about certain things \- and occasionally it guesses wrong.
-However, it is usually very easy to identify and fix these problems.
-The typical problems are:
-.RS
-.TP 4
-\(bu
-Timing. A surprisingly large number of programs (rn, ksh, zsh,
-telnet, etc.) and devices (e.g., modems) ignore keystrokes that arrive
-"too quickly" after prompts. If you find your new script hanging up
-at one spot, try adding a short sleep just before the previous send.
-
-You can force this behavior throughout by overriding the variable
-"force_conservative" near the beginning of the generated script. This
-"conservative" mode makes autoexpect automatically pause briefly (one
-tenth of a second) before sending each character. This pacifies every
-program I know of.
-
-This conservative mode is useful if you just want to quickly reassure
-yourself that the problem is a timing one (or if you really don't care
-about how fast the script runs). This same mode can be forced before
-script generation by using the \-c flag.
-
-Fortunately, these timing spots are rare. For example, telnet ignores
-characters only after entering its escape sequence. Modems only
-ignore characters immediately after connecting to them for the first
-time. A few programs exhibit this behavior all the time but typically
-have a switch to disable it. For example, rn's \-T flag disables this
-behavior.
-
-The following example starts autoexpect in conservative
-mode.
-.nf
-
- autoexpect \-c
-
-.fi
-The \-C flag defines a key to toggle conservative mode.
-The following example starts autoexpect (in non-conservative
-mode) with ^L as the toggle. (Note that the ^L is
-entered literally - i.e., enter a real control-L).
-.nf
-
- autoexpect \-C ^L
-
-.fi
-The following example starts autoexpect in conservative
-mode with ^L as the toggle.
-.nf
-
- autoexpect \-c \-C ^L
-
-.fi
-.TP
-\(bu
-Echoing. Many program echo characters. For example, if you type
-"more" to a shell, what autoexpect actually sees is:
-.nf
-
- you typed 'm',
- computer typed 'm',
- you typed 'o',
- computer typed 'o',
- you typed 'r',
- computer typed 'r',
- ...
-.fi
-
-Without specific knowledge of the program, it is impossible to know if
-you are waiting to see each character echoed before typing the next.
-If autoexpect sees characters being echoed, it assumes that it can
-send them all as a group rather than interleaving them the way they
-originally appeared. This makes the script more pleasant to read.
-However, it could conceivably be incorrect if you really had to wait
-to see each character echoed.
-
-.TP
-\(bu
-Change. Autoexpect records every character from the interaction in
-the script. This is desirable because it gives you the ability to
-make judgements about what is important and what can be replaced with
-a pattern match.
-
-On the other hand, if you use commands whose output differs from run
-to run, the generated scripts are not going to be correct. For
-example, the "date" command always produces different output. So
-using the date command while running autoexpect is a sure way to
-produce a script that will require editing in order for it to work.
-
-The \-p flag puts autoexpect into "prompt mode". In this mode,
-autoexpect will only look for the the last line of program output \-
-which is usually the prompt. This handles the date problem (see
-above) and most others.
-
-The following example starts autoexpect in prompt mode.
-.nf
-
- autoexpect \-p
-
-.fi
-The \-P flag defines a key to toggle prompt mode. The following
-example starts autoexpect (in non-prompt mode) with ^P as the toggle.
-Note that the ^P is entered literally - i.e., enter a real control-P.
-.nf
-
- autoexpect \-P ^P
-
-.fi
-The following example starts autoexpect in prompt mode with ^P as the toggle.
-.nf
-
- autoexpect \-p \-P ^P
-
-.fi
-.SH OTHER FLAGS
-The
-.B \-quiet
-flag disables informational messages produced by autoexpect.
-
-The
-.B \-Q
-flag names a quote character which can be used to enter characters
-that autoexpect would otherwise consume because they are used as toggles.
-
-The following example shows a number of flags with quote used to
-provide a way of entering the toggles literally.
-.nf
-
- autoexpect \-P ^P \-C ^L \-Q ^Q
-
-.fi
-.SH STYLE
-
-I don't know if there is a "style" for Expect programs but autoexpect
-should definitely not be held up as any model of style. For example,
-autoexpect uses features of Expect that are intended specifically for
-computer-generated scripting. So don't try to faithfully write
-scripts that appear as if they were generated by autoexpect. This is
-not useful.
-
-On the other hand, autoexpect scripts do show some worthwhile things.
-For example, you can see how any string must be quoted in order to use
-it in a Tcl script simply by running the strings through autoexpect.
-
-.SH SEE ALSO
-.I
-"Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Programs"
-\fRby Don Libes,
-O'Reilly and Associates, January 1995.
-.SH AUTHOR
-Don Libes, National Institute of Standards and Technology
-
-.B expect
-and
-.B autoexpect
-are in the public domain.
-NIST and I would
-appreciate credit if these programs or parts of them are used.
-
+++ /dev/null
-#!../expect -f
-# wrapper to make passwd(1) be non-interactive
-# username is passed as 1st arg, passwd as 2nd
-
-set password [lindex $argv 1]
-spawn passwd [lindex $argv 0]
-expect "password:"
-send "$password\r"
-expect "password:"
-send "$password\r"
-expect eof
+++ /dev/null
-#!/depot/path/expect -f
-
-# 99 bottles of beer on the wall, Expect-style
-# Author: Don Libes <libes@nist.gov>
-
-# Unlike programs (http://www.ionet.net/~timtroyr/funhouse/beer.html)
-# which merely print out the 99 verses, this one SIMULATES a human
-# typing the beer song. Like a real human, typing mistakes and timing
-# becomes more erratic with each beer - the final verse is barely
-# recognizable and it is really like watching a typist hunt and peck
-# while drunk.
-
-# Finally, no humans actually sing all 99 verses - particularly when
-# drunk. In reality, they occasionally lose their place (or just get
-# bored) and skip verses, so this program does likewise.
-
-# Because the output is timed, just looking at the output isn't enough
-# - you really have to see the program running to appreciate it.
-# Nonetheless, for convenience, output from one run (it's different
-# every time of course) can be found in the file beer.exp.out
-# But it won't show the erratic timing; you have to run it for that.
-
-# For an even fancier version, see http://expect.nist.gov/scripts/superbeer.exp
-
-proc bottles {i} {
- return "$i bottle[expr $i!=1?"s":""] of beer"
-}
-
-proc line123 {i} {
- out $i "[bottles $i] on the wall,\n"
- out $i "[bottles $i],\n"
- out $i "take one down, pass it around,\n"
-}
-
-proc line4 {i} {
- out $i "[bottles $i] on the wall.\n\n"
-}
-
-proc out {i s} {
- foreach c [split $s ""] {
- # don't touch punctuation; just looks too strange if you do
- if [regexp "\[,. \n\]" $c] {
- append d $c
- continue
- }
-
- # keep first couple of verses straight
- if {$i > 97} {append d $c; continue}
-
- # +3 prevents it from degenerating too far
- # /2 makes it degenerate faster though
-
- set r [rand [expr $i/2+3]]
- if {$r} {append d $c; continue}
-
- # do something strange
- switch [rand 3] {
- 0 {
- # substitute another letter
-
- if [regexp \[aeiou\] $c] {
- # if vowel, substitute another
- append d [string index aeiou [rand 5]]
- } elseif [regexp \[0-9\] $c] {
- # if number, substitute another
- append d [string index 123456789 [rand 9]]
- } else {
- # if consonant, substitute another
- append d [string index bcdfghjklmnpqrstvwxyz [rand 21]]
- }
- } 1 {
- # duplicate a letter
- append d $c$c
- } 2 {
- # drop a letter
- }
- }
- }
-
- set arr1 [expr .4 - ($i/333.)]
- set arr2 [expr .6 - ($i/333.)]
- set shape [expr log(($i+2)/2.)+.1]
- set min 0
- set max [expr 6-$i/20.]
-
- set send_human "$arr1 $arr2 $shape $min $max"
-
- send -h $d
-}
-
-set _ran [pid]
-
-proc rand {m} {
- global _ran
-
- set period 259200
- set _ran [expr ($_ran*7141 + 54773) % $period]
- expr int($m*($_ran/double($period)))
-}
-
-for {set i 99} {$i>0} {} {
- line123 $i
- incr i -1
- line4 $i
-
- # get bored and skip ahead
- if {$i == 92} {
- set i [expr 52+[rand 5]]
- }
- if {$i == 51} {
- set i [expr 12+[rand 5]]
- }
- if {$i == 10} {
- set i [expr 6+[rand 3]]
- }
-}
+++ /dev/null
-99 bottles of beer on the wall,
-99 bottles of beer,
-take one down, pass it around,
-98 bottles of beer on the wall.
-
-98 bottles of beer on the wall,
-98 bottles of beer,
-take one down, pass it around,
-97 bottles of beer on the wall.
-
-97 bottles of beer on the wadl,
-97 bottles of beer,
-take one down, pass it around,
-96 bottles of beer on the wall.
-
-96 bottlees of beer on the wall,
-96 bowtles of beer,
-take one down, piss it around,
-95 bottles of beer on the salll.
-
-95 bottles of ber on the wall,
-95 qottles of beer,
-take one down, pass it around,
-94 bottles of beeer on the wall.
-
-94 ottles ef beer on the wall,
-94 bottles of beer,
-take one down, pass it around,
-93 bottles of beer n the wall.
-
-93 bottles of beer on the wall,
-93 bottles of beer,
-take one sown, pass it ajound,
-92 bottles of beer on the wall.
-
-56 bottles of beer on the wwall,
-56 bottles of beer,
-ake ne down, pass it around,
-55 bottles oof beer on the wall.
-
-55 bottles of beer on the wall,
-55 bottles if beer,
-take one down, pass it around,
-54 bottles of beer on the wall.
-
-54 bottles of beer on the wall,
-54 bottles of beer,
-take one dow, bass it around,
-53 bottes of beer on the wall.
-
-53 bottlef of beer on the wall,
-53 bottles of beer,
-tke one down, pas t around,
-52 bottles of beer on the wall.
-
-52 bottless o beer on the wall,
-52 botttles of beer,
-take one down, pass it round,
-51 bottles of beer on the all.
-
-114 bottles of ber on the wall,
-14 botles of ber,
-taakee one ddown, pass it around,
-13 bottles of beeer on the wakl.
-
-13 bottles of beer on tth wall,
-1 yottles of beer,
-take one down, xass it around,
-12 botles ooff beer on the walll.
-
-12 bottttqes of beer oon the wall,
-12 bttles oof beer,
-take one down, pass it around,
-11 boottles of beer on the wall.
-
-11 botttles of beer on the all,
-1 otttles of beer,
-tae one duwn, ppess it around,
-10 bottlos of beer on the wall.
-
-8 bottles of beer on thee wwall,
-8 bottles oof eer,
-taxe onne doown, pass iz aaroind,
-77 botttles f beer on nhe wall.
-
-7 bbottes of beer on the wlll,
-7 bomtles of beer,
-ake onee dwn, pass it around,
-6 bottles of beer on the ral.
-
-6 botttles of berr on the wal,
-6 bottles oof beer,
-take onee donn, pas it arouund,
-5 bottles of beer oq the wall.
-
- bottles f beer on the walll,
-5 botttlees of meer,
-take one down, passs it aroundd,
-4 boothles of beer n thhe wall.
-
-6 botyles of boer n the lll,
-4 bottles i beer,
-take one down, pass i aarounnd,
-3 bbotlos of bbeir iy te wall.
-
- bottles off ee on the wall,
-3 buttes of bbeer,
-take one dooxn, pass il rround,
-3 bottles oof ber on tthe wall.
-
-2 bottle uf er ooc the tall,
-2 bettles ok beear,
-taka onu doowy, pesss itt arond,
-1 botjllee off beer i thh walll.
-
-11 botqle off baer oc tbe wakl,
-1 botplo of beer,
-take onne da, pass itt arounm,
-0 yotglees oof beeeer on tte walll.
+++ /dev/null
-99 bottles of beer on the wall,
-99 bottles of beer,
-take one down, pass it around,
-98 bottles of beer on the wall.
-
-98 bottles of beer on the wall,
-98 bottles of beer,
-take one down, pass it around,
-97 bottles of beer on the wall.
-
-97 bottles of beer on the wadl,
-97 bottles of beer,
-take one down, pass it around,
-96 bottles of beer on the wall.
-
-96 bottlees of beer on the wall,
-96 bowtles of beer,
-take one down, piss it around,
-95 bottles of beer on the salll.
-
-95 bottles of ber on the wall,
-95 qottles of beer,
-take one down, pass it around,
-94 bottles of beeer on the wall.
-
-94 ottles ef beer on the wall,
-94 bottles of beer,
-take one down, pass it around,
-93 bottles of beer n the wall.
-
-93 bottles of beer on the wall,
-93 bottles of beer,
-take one sown, pass it ajound,
-92 bottles of beer on the wall.
-
-56 bottles of beer on the wwall,
-56 bottles of beer,
-ake ne down, pass it around,
-55 bottles oof beer on the wall.
-
-55 bottles of beer on the wall,
-55 bottles if beer,
-take one down, pass it around,
-54 bottles of beer on the wall.
-
-54 bottles of beer on the wall,
-54 bottles of beer,
-take one dow, bass it around,
-53 bottes of beer on the wall.
-
-53 bottlef of beer on the wall,
-53 bottles of beer,
-tke one down, pas t around,
-52 bottles of beer on the wall.
-
-52 bottless o beer on the wall,
-52 botttles of beer,
-take one down, pass it round,
-51 bottles of beer on the all.
-
-114 bottles of ber on the wall,
-14 botles of ber,
-taakee one ddown, pass it around,
-13 bottles of beeer on the wakl.
-
-13 bottles of beer on tth wall,
-1 yottles of beer,
-take one down, xass it around,
-12 botles ooff beer on the walll.
-
-12 bottttqes of beer oon the wall,
-12 bttles oof beer,
-take one down, pass it around,
-11 boottles of beer on the wall.
-
-11 botttles of beer on the all,
-1 otttles of beer,
-tae one duwn, ppess it around,
-10 bottlos of beer on the wall.
-
-8 bottles of beer on thee wwall,
-8 bottles oof eer,
-taxe onne doown, pass iz aaroind,
-77 botttles f beer on nhe wall.
-
-7 bbottes of beer on the wlll,
-7 bomtles of beer,
-ake onee dwn, pass it around,
-6 bottles of beer on the ral.
-
-6 botttles of berr on the wal,
-6 bottles oof beer,
-take onee donn, pas it arouund,
-5 bottles of beer oq the wall.
-
- bottles f beer on the walll,
-5 botttlees of meer,
-take one down, passs it aroundd,
-4 boothles of beer n thhe wall.
-
-6 botyles of boer n the lll,
-4 bottles i beer,
-take one down, pass i aarounnd,
-3 bbotlos of bbeir iy te wall.
-
- bottles off ee on the wall,
-3 buttes of bbeer,
-take one dooxn, pass il rround,
-3 bottles oof ber on tthe wall.
-
-2 bottle uf er ooc the tall,
-2 bettles ok beear,
-taka onu doowy, pesss itt arond,
-1 botjllee off beer i thh walll.
-
-11 botqle off baer oc tbe wakl,
-1 botplo of beer,
-take onne da, pass itt arounm,
-0 yotglees oof beeeer on tte walll.
+++ /dev/null
-# Script to enforce a 10 minute break every half hour from typing -
-# Written for someone (Uwe Hollerbach) with Carpal Tunnel Syndrome.
-
-# If you type for more than 20 minutes straight, the script rings
-# the bell after every character until you take a 10 minute break.
-
-# Author: Don Libes, NIST
-# Date: Feb 26, '95
-
-spawn $env(SHELL)
-set start [timestamp] ;# when we started our current typing period
-set stop [timestamp] ;# when we stopped typing
-
-set typing 1200 ;# twenty minutes, max typing time allowed
-set notyping 600 ;# ten minutes, min notyping time required
-
-interact -nobuffer -re . {
- set now [timestamp]
-
- if {$now-$stop > $notyping} {
- set start [timestamp]
- } elseif {$now-$start > $typing} {
- send_user "\007"
- }
- set stop [timestamp]
-}
+++ /dev/null
-#!../expect -f
-# expect script to connect two UNIX chess programs together.
-# written by Don Libes - May 9, 1990
-
-# Note, this depends on the "usual" UNIX chess output. Other chess programs
-# will almost certainly not work.
-
-# Moves and counter-moves are printed out in different formats, sigh...
-# But I guess that's what makes this Expect script challenging to write.
-# In particular, the 1st player outputs:
-#
-# p/k2-k4 (echo from 2nd player)
-# 1. ... p/k2-k4 (reprint it with a number in front - god knows why)
-# 2. n/kn1-kb3 (our new move)
-#
-# and the 2nd player outputs the following
-#
-# n/kn1-kb3 (echo from first player)
-# 2. n/kn1-kb3 (reprint it as above, but differently - god knows why)
-# 2. ... p/k4-k5 (our new countermove - written differently, of course)
-
-set timeout -1; # wait forever
-expect_before {
- -i $any_spawn_id eof {
- send_user "player resigned!\n"
- exit
- }
-}
-
-# start things rolling
-spawn chess
-set id1 $spawn_id
-expect "Chess\r\n"
-send "first\r"
-# read_first_move
-expect -re "1. (.*)\n"
-
-spawn chess
-set id2 $spawn_id
-expect "Chess\r\n"
-send $expect_out(1,string)
-
-for {} 1 {} {
- expect {
- -i $id2 -re "\\.\\. (.*)\n" {
- send -i $id1 $expect_out(1,string)
- }
- -i $id1 -re "\\.\\. .*\\. (.*)\n" {
- send -i $id2 $expect_out(1,string)
- }
- }
-}
+++ /dev/null
-/* testlib.c for c++ - test expectlib */
-
-#include <stdio.h>
-#include "expect.h"
-
-extern "C" {
- extern int write(...);
- extern int strlen(...);
-}
-
-void
-timedout()
-{
- fprintf(stderr,"timed out\n");
- exit(-1);
-}
-
-char move[100];
-
-void
-read_first_move(int fd)
-{
- if (EXP_TIMEOUT == exp_expectl(fd,exp_glob,"first\r\n1.*\r\n",0,exp_end)) {
- timedout();
- }
- sscanf(exp_match,"%*s 1. %s",move);
-}
-
-/* moves and counter-moves are printed out in different formats, sigh... */
-
-void
-read_counter_move(int fd)
-{
- switch (exp_expectl(fd,exp_glob,"*...*\r\n",0,exp_end)) {
- case EXP_TIMEOUT: timedout();
- case EXP_EOF: exit(-1);
- }
-
- sscanf(exp_match,"%*s %*s %*s %*s ... %s",move);
-}
-
-void
-read_move(int fd)
-{
- switch (exp_expectl(fd,exp_glob,"*...*\r\n*.*\r\n",0,exp_end)) {
- case EXP_TIMEOUT: timedout();
- case EXP_EOF: exit(-1);
- }
-
- sscanf(exp_match,"%*s %*s ... %*s %*s %s",move);
-}
-
-void
-send_move(int fd)
-{
- write(fd,move,strlen(move));
-}
-
-main(){
- int fd1, fd2;
-
- exp_loguser = 1;
- exp_timeout = 3600;
-
- fd1 = exp_spawnl("chess","chess",(char *)0);
-
- if (-1 == exp_expectl(fd1,exp_glob,"Chess\r\n",0,exp_end)) exit;
-
- if (-1 == write(fd1,"first\r",6)) exit;
-
- read_first_move(fd1);
-
- fd2 = exp_spawnl("chess","chess",(char *)0);
-
- if (-1 == exp_expectl(fd2,exp_glob,"Chess\r\n",0,exp_end)) exit;
-
- for (;;) {
- send_move(fd2);
- read_counter_move(fd2);
-
- send_move(fd1);
- read_move(fd1);
- }
-}
+++ /dev/null
-/* chesslib.c - test expectlib */
-
-#include <stdio.h>
-#include "expect.h"
-
-timedout()
-{
- fprintf(stderr,"timed out\n");
- exit(-1);
-}
-
-char move[100];
-
-read_first_move(fd)
-int fd;
-{
- if (EXP_TIMEOUT == exp_expectl(fd,
- exp_glob,"first\r\n1.*\r\n",0,
- exp_end)) {
- timedout();
- }
- sscanf(exp_match,"%*s 1. %s",move);
-}
-
-/* moves and counter-moves are printed out in different formats, sigh... */
-
-read_counter_move(fd)
-int fd;
-{
- switch (exp_expectl(fd,exp_glob,"*...*\r\n",0,exp_end)) {
- case EXP_TIMEOUT: timedout();
- case EXP_EOF: exit(-1);
- }
-
- sscanf(exp_match,"%*s %*s %*s %*s ... %s",move);
-}
-
-read_move(fd)
-int fd;
-{
- switch (exp_expectl(fd,exp_glob,"*...*\r\n*.*\r\n",0,exp_end)) {
- case EXP_TIMEOUT: timedout();
- case EXP_EOF: exit(-1);
- }
-
- sscanf(exp_match,"%*s %*s ... %*s %*s %s",move);
-}
-
-send_move(fd)
-int fd;
-{
- write(fd,move,strlen(move));
-}
-
-main(){
- int fd1, fd2;
-
- exp_loguser = 1;
- exp_timeout = 3600;
-
- fd1 = exp_spawnl("chess","chess",(char *)0);
-
- if (-1 == exp_expectl(fd1,exp_glob,"Chess\r\n",0,exp_end)) exit;
-
- if (-1 == write(fd1,"first\r",6)) exit;
-
- read_first_move(fd1);
-
- fd2 = exp_spawnl("chess","chess",(char *)0);
-
- if (-1 == exp_expectl(fd2,exp_glob,"Chess\r\n",0,exp_end)) exit;
-
- for (;;) {
- send_move(fd2);
- read_counter_move(fd2);
-
- send_move(fd1);
- read_move(fd1);
- }
-}
+++ /dev/null
-/* testlib.c - test expectlib */
-
-#include <stdio.h>
-#include "expect.h"
-
-timedout()
-{
- fprintf(stderr,"timed out\n");
- exit(-1);
-}
-
-char move[100];
-
-read_first_move(fp)
-FILE *fp;
-{
- if (EXP_TIMEOUT == exp_fexpectl(fp,
- exp_glob,"first\r\n1.*\r\n",0,
- exp_end)) {
- timedout();
- }
- sscanf(exp_match,"%*s 1. %s",move);
-}
-
-/* moves and counter-moves are printed out in different formats, sigh... */
-
-read_counter_move(fp)
-FILE *fp;
-{
- switch (exp_fexpectl(fp,exp_glob,"*...*\r\n",0, exp_end)) {
- case EXP_TIMEOUT: timedout();
- case EXP_EOF: exit(-1);
- }
-
- sscanf(exp_match,"%*s %*s %*s %*s ... %s",move);
-}
-
-read_move(fp)
-FILE *fp;
-{
- switch (exp_fexpectl(fp,exp_glob,"*...*\r\n*.*\r\n",0,exp_end)) {
- case EXP_TIMEOUT: timedout();
- case EXP_EOF: exit(-1);
- }
-
- sscanf(exp_match,"%*s %*s ... %*s %*s %s",move);
-}
-
-send_move(fp)
-FILE *fp;
-{
- fprintf(fp,move);
-}
-
-main(){
- FILE *fp1, *fp2;
- int ec;
-
-/* exp_is_debugging = 1;*/
- exp_loguser = 1;
- exp_timeout = 3600;
-
- if (0 == (fp1 = exp_popen("chess"))) {
- printf("exp_popen failed\n");
- exit(-1);
- }
-
- if (0 > exp_fexpectl(fp1,exp_glob,"Chess\r\n",0,exp_end)) exit(-1);
- fprintf(fp1,"first\r");
-
- read_first_move(fp1);
-
- fp2 = exp_popen("chess");
-
- exp_fexpectl(fp2,exp_glob,"Chess\r\n",0,exp_end);
-
- for (;;) {
- send_move(fp2);
- read_counter_move(fp2);
-
- send_move(fp1);
- read_move(fp1);
- }
-}
+++ /dev/null
-#!../expect --
-# Name: cryptdir
-# Author: Don Libes, NIST
-#
-# Synopsis:
-# cryptdir [dir]
-# decryptdir [dir]
-#
-# Encrypt or decrypts the current directory or named directory if given.
-
-if {[llength $argv] > 0} {
- cd $argv
-}
-
-# encrypt or decrypt?
-set decrypt [regexp "decrypt" $argv0]
-
-set timeout -1
-stty -echo
-send "Password:"
-expect -re "(.*)\n"
-send "\n"
-set passwd $expect_out(1,string)
-
-# wouldn't want to encrypt files with mistyped password!
-if !$decrypt {
- send "Again:"
- expect -re "(.*)\n"
- send "\n"
- if ![string match $passwd $expect_out(1,string)] {
- send_user "mistyped password?\n"
- stty echo
- exit
- }
-}
-stty echo
-
-log_user 0
-foreach f [glob *] {
- # strip shell metachars from filename to avoid problems
- if [regsub -all {[]['`~<>:-]} $f "" newf] {
- exec mv $f $newf
- set f $newf
- }
-
- set strcmp [string compare .crypt [file extension $f]]
- if $decrypt {
- # skip files that don't end with ".crypt"
- if 0!=$strcmp continue
- spawn sh -c "exec crypt < $f > [file root $f]"
- } else {
- # skip files that already end with ".crypt"
- if 0==$strcmp continue
- spawn sh -c "exec crypt < $f > $f.crypt"
- }
- expect "key:"
- send "$passwd\r"
- expect
- wait
- exec rm -f $f
- send_tty "."
-}
-send_tty "\n"
+++ /dev/null
-.TH CRYPTDIR 1 "1 January 1993"
-.SH NAME
-cryptdir \- encrypt/decrypt all files in a directory
-.SH SYNOPSIS
-.B cryptdir
-[
-.I dir
-]
-.br
-.B decryptdir
-[
-.I dir
-]
-.SH INTRODUCTION
-.B cryptdir
-encrypts all files in the current directory (or the given directory
-if one is provided as an argument). When called as decryptdir
-(i.e., same program, different name), all files are decrypted.
-
-.SH NOTES
-When encrypting, you are prompted twice for the password as a
-precautionary measure. It would be a disaster to encrypt files with a
-password that wasn't what you intended.
-
-In contrast, when decrypting, you are only prompted once. If it's the
-wrong password, no harm done.
-
-Encrypted files have the suffix .crypt appended. This prevents files
-from being encrypted twice. The suffix is removed upon decryption.
-Thus, you can easily add files to an encrypted directory and run
-cryptdir on it without worrying about the already encrypted files.
-.SH BUGS
-
-The man page is longer than the program.
-
-.SH SEE ALSO
-.I
-"Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Programs"
-\fRby Don Libes,
-O'Reilly and Associates, January 1995.
-.SH AUTHOR
-Don Libes, National Institute of Standards and Technology
+++ /dev/null
-#!../expect --
-# Name: cryptdir
-# Author: Don Libes, NIST
-#
-# Synopsis:
-# cryptdir [dir]
-# decryptdir [dir]
-#
-# Encrypt or decrypts the current directory or named directory if given.
-
-if {[llength $argv] > 0} {
- cd $argv
-}
-
-# encrypt or decrypt?
-set decrypt [regexp "decrypt" $argv0]
-
-set timeout -1
-stty -echo
-send "Password:"
-expect -re "(.*)\n"
-send "\n"
-set passwd $expect_out(1,string)
-
-# wouldn't want to encrypt files with mistyped password!
-if !$decrypt {
- send "Again:"
- expect -re "(.*)\n"
- send "\n"
- if ![string match $passwd $expect_out(1,string)] {
- send_user "mistyped password?"
- stty echo
- exit
- }
-}
-stty echo
-
-log_user 0
-foreach f [glob *] {
- # strip shell metachars from filename to avoid problems
- if [regsub -all {[]['`~<>:-]} $f "" newf] {
- exec mv $f $newf
- set f $newf
- }
-
- set strcmp [string compare .crypt [file extension $f]]
- if $decrypt {
- # skip files that don't end with ".crypt"
- if 0!=$strcmp continue
- spawn sh -c "exec crypt < $f > [file root $f]"
- } else {
- # skip files that already end with ".crypt"
- if 0==$strcmp continue
- spawn sh -c "exec crypt < $f > $f.crypt"
- }
- expect "key:"
- send "$passwd\r"
- expect
- wait
- exec rm -f $f
- send_tty "."
-}
-send_tty "\n"
+++ /dev/null
-.TH CRYPTDIR 1 "1 January 1993"
-.SH NAME
-cryptdir \- encrypt/decrypt all files in a directory
-.SH SYNOPSIS
-.B cryptdir
-[
-.I dir
-]
-.br
-.B decryptdir
-[
-.I dir
-]
-.SH INTRODUCTION
-.B cryptdir
-encrypts all files in the current directory (or the given directory
-if one is provided as an argument). When called as decryptdir
-(i.e., same program, different name), all files are decrypted.
-
-.SH NOTES
-When encrypting, you are prompted twice for the password as a
-precautionary measure. It would be a disaster to encrypt files a
-password that wasn't what you intended.
-
-In contrast, when decrypting, you are only prompted once. If it's the
-wrong password, no harm done.
-
-Encrypted files have the suffix .crypt appended. This prevents files
-from being encrypted twice. The suffix is removed upon decryption.
-Thus, you can easily add files to an encrypted directory and run
-cryptdir on it without worrying about the already encrypted files.
-.SH BUGS
-
-The man page is longer than the program.
-
-.SH SEE ALSO
-.I
-"Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Programs"
-\fRby Don Libes,
-O'Reilly and Associates, January 1995.
-.SH AUTHOR
-Don Libes, National Institute of Standards and Technology
+++ /dev/null
-#!../expect --
-# dislocate - allow disconnection and reconnection to a background program
-# Author: Don Libes, NIST
-
-exp_version -exit 5.1
-
-# The following code attempts to intuit whether cat buffers by default.
-# The -u flag is required on HPUX (8 and 9) and IBM AIX (3.2) systems.
-if [file exists $exp_exec_library/cat-buffers] {
- set catflags "-u"
-} else {
- set catflags ""
-}
-# If this fails, you can also force it by commenting in one of the following.
-# Or, you can use the -catu flag to the script.
-#set catflags ""
-#set catflags "-u"
-
-set escape \035 ;# control-right-bracket
-set escape_printable "^\]"
-
-set pidfile "~/.dislocate"
-set prefix "disc"
-set timeout -1
-set debug_flag 0
-
-while {$argc} {
- set flag [lindex $argv 0]
- switch -- $flag \
- "-catu" {
- set catflags "-u"
- set argv [lrange $argv 1 end]
- incr argc -1
- } "-escape" {
- set escape [lindex $argv 1]
- set escape_printable $escape
- set argv [lrange $argv 2 end]
- incr argc -2
- } "-debug" {
- log_file [lindex $argv 1]
- set debug_flag 1
- set argv [lrange $argv 2 end]
- incr argc -2
- } default {
- break
- }
-}
-
-# These are correct from parent's point of view.
-# In child, we will reset these so that they appear backwards
-# thus allowing following two routines to be used by both parent and child
-set infifosuffix ".i"
-set outfifosuffix ".o"
-
-proc infifoname {pid} {
- global prefix infifosuffix
-
- return "/tmp/$prefix$pid$infifosuffix"
-}
-
-proc outfifoname {pid} {
- global prefix outfifosuffix
-
- return "/tmp/$prefix$pid$outfifosuffix"
-}
-
-proc pid_remove {pid} {
- global date proc
-
- say "removing $pid $proc($pid)"
-
- unset date($pid)
- unset proc($pid)
-}
-
-# lines in data file looks like this:
-# pid#date-started#argv
-
-# allow element lookups on empty arrays
-set date(dummy) dummy; unset date(dummy)
-set proc(dummy) dummy; unset proc(dummy)
-
-# load pidfile into memory
-proc pidfile_read {} {
- global date proc pidfile
-
- if [catch {open $pidfile} fp] return
-
- #
- # read info out of file
- #
-
- say "reading pidfile"
- set line 0
- while {[gets $fp buf]!=-1} {
- # while pid and date can't have # in it, proc can
- if [regexp "(\[^#]*)#(\[^#]*)#(.*)" $buf junk pid xdate xproc] {
- set date($pid) $xdate
- set proc($pid) $xproc
- } else {
- puts "warning: inconsistency in $pidfile line $line"
- }
- incr line
- }
- close $fp
- say "read $line entries"
-
- #
- # see if pids and fifos are still around
- #
-
- foreach pid [array names date] {
- if {$pid && [catch {exec /bin/kill -0 $pid}]} {
- say "$pid no longer exists, removing"
- pid_remove $pid
- continue
- }
-
- # pid still there, see if fifos are
- if {![file exists [infifoname $pid]] || ![file exists [outfifoname $pid]]} {
- say "$pid fifos no longer exists, removing"
- pid_remove $pid
- continue
- }
- }
-}
-
-proc pidfile_write {} {
- global pidfile date proc
-
- say "writing pidfile"
-
- set fp [open $pidfile w]
- foreach pid [array names date] {
- puts $fp "$pid#$date($pid)#$proc($pid)"
- say "wrote $pid#$date($pid)#$proc($pid)"
- }
- close $fp
-}
-
-proc fifo_pair_remove {pid} {
- global date proc prefix
-
- pidfile_read
- pid_remove $pid
- pidfile_write
-
- catch {exec rm -f [infifoname $pid] [outfifoname $pid]}
-}
-
-proc fifo_pair_create {pid argdate argv} {
- global prefix date proc
-
- pidfile_read
- set date($pid) $argdate
- set proc($pid) $argv
- pidfile_write
-
- mkfifo [infifoname $pid]
- mkfifo [outfifoname $pid]
-}
-
-proc mkfifo {f} {
- if [file exists $f] {
- say "uh, fifo already exists?"
- return
- }
-
- if 0==[catch {exec mkfifo $f}] return ;# POSIX
- if 0==[catch {exec mknod $f p}] return
- # some systems put mknod in wierd places
- if 0==[catch {exec /usr/etc/mknod $f p}] return ;# Sun
- if 0==[catch {exec /etc/mknod $f p}] return ;# AIX, Cray
- puts "Couldn't figure out how to make a fifo - where is mknod?"
- exit
-}
-
-proc child {argdate argv} {
- global catflags infifosuffix outfifosuffix
-
- disconnect
-
- # these are backwards from the child's point of view so that
- # we can make everything else look "right"
- set infifosuffix ".o"
- set outfifosuffix ".i"
- set pid 0
-
- eval spawn $argv
- set proc_spawn_id $spawn_id
-
- while {1} {
- say "opening [infifoname $pid] for read"
- spawn -open [open "|cat $catflags < [infifoname $pid]" "r"]
- set in $spawn_id
-
- say "opening [outfifoname $pid] for write"
- spawn -open [open [outfifoname $pid] w]
- set out $spawn_id
-
- fifo_pair_remove $pid
-
- say "interacting"
- interact {
- -u $proc_spawn_id eof exit
- -output $out
- -input $in
- }
-
- # parent has closed connection
- say "parent closed connection"
- catch {close -i $in}
- catch {wait -i $in}
- catch {close -i $out}
- catch {wait -i $out}
-
- # switch to using real pid
- set pid [pid]
- # put entry back
- fifo_pair_create $pid $argdate $argv
- }
-}
-
-proc say {msg} {
- global debug_flag
-
- if !$debug_flag return
-
- if [catch {puts "parent: $msg"}] {
- send_log "child: $msg\n"
- }
-}
-
-proc escape {} {
- # export process handles so that user can get at them
- global in out
-
- puts "\nto disconnect, enter: exit (or ^D)"
- puts "to suspend, press appropriate job control sequence"
- puts "to return to process, enter: return"
- interpreter
- puts "returning ..."
-}
-
-# interactively query user to choose process, return pid
-proc choose {} {
- global index date
-
- while 1 {
- send_user "enter # or pid: "
- expect_user -re "(.*)\n" {set buf $expect_out(1,string)}
- if [info exists index($buf)] {
- set pid $index($buf)
- } elseif [info exists date($buf)] {
- set pid $buf
- } else {
- puts "no such # or pid"
- continue
- }
- return $pid
- }
-}
-
-if {$argc} {
- # initial creation occurs before fork because if we do it after
- # then either the child or the parent may have to spin retrying
- # the fifo open. Unfortunately, we cannot know the pid ahead of
- # time so use "0". This will be set to the real pid when the
- # parent does its initial disconnect. There is no collision
- # problem because the fifos are deleted immediately anyway.
-
- set datearg [exec date]
- fifo_pair_create 0 $datearg $argv
-
- set pid [fork]
- say "after fork, pid = $pid"
- if $pid==0 {
- child $datearg $argv
- }
- # parent thinks of child as pid==0 for reason given earlier
- set pid 0
-}
-
-say "examining pid"
-
-if ![info exists pid] {
- global fifos date proc
-
- say "pid does not exist"
-
- pidfile_read
-
- set count 0
- foreach pid [array names date] {
- incr count
- }
-
- if $count==0 {
- puts "no connectable processes"
- exit
- } elseif $count==1 {
- puts "one connectable process: $proc($pid)"
- puts "pid $pid, started $date($pid)"
- send_user "connect? \[y] "
- expect_user -re "(.*)\n" {set buf $expect_out(1,string)}
- if {$buf!="y" && $buf!=""} exit
- } else {
- puts "connectable processes:"
- set count 1
- puts " # pid date started process"
- foreach pid [array names date] {
- puts [format "%2d %6d %.19s %s" \
- $count $pid $date($pid) $proc($pid)]
- set index($count) $pid
- incr count
- }
- set pid [choose]
- }
-}
-
-say "opening [outfifoname $pid] for write"
-spawn -noecho -open [open [outfifoname $pid] w]
-set out $spawn_id
-
-say "opening [infifoname $pid] for read"
-spawn -noecho -open [open "|cat $catflags < [infifoname $pid]" "r"]
-set in $spawn_id
-
-puts "Escape sequence is $escape_printable"
-
-proc prompt1 {} {
- global argv0
-
- return "$argv0[history nextid]> "
-}
-
-interact {
- -reset $escape escape
- -output $out
- -input $in
-}
-
+++ /dev/null
-.TH DISLOCATE 1 "7 October 1993"
-.SH NAME
-Dislocate \- disconnect and reconnect processes
-.SH SYNOPSIS
-.B dislocate
-[
-.I program args...
-]
-.SH INTRODUCTION
-.B Dislocate
-allows processes to be disconnected and reconnected to the terminal.
-Possible uses:
-.RS
-.TP 4
-\(bu
-You can disconnect a process from a terminal at work
-and reconnect from home, to continue working.
-.TP 4
-\(bu
-After having your line be dropped due to noise, you can get back to your
-process without having to restart it from scratch.
-.TP 4
-\(bu
-If you have a problem that you would like to show someone, you can set
-up the scenario at your own terminal, disconnect, walk down the hall,
-and reconnect on another terminal.
-.TP 4
-\(bu
-If you are in the middle of a great game (or whatever) that does not allow
-you to save, and someone else kicks you off the terminal, you can disconnect,
-and reconnect later.
-.SH USAGE
-When run with no arguments,
-.B Dislocate
-tells you about your disconnected processes and lets you reconnect to one.
-Otherwise,
-.B Dislocate
-runs the named program along with any arguments.
-
-By default, ^] is an escape that lets you talk to
-.B Dislocate
-itself. At that point, you can disconnect (by pressing ^D) or
-suspend
-.B Dislocate
-(by pressing ^Z).
-
-Any Tcl or Expect command is also acceptable at this point.
-For example,
-to insert the contents of a the file /etc/motd as if you had typed it, say:
-.nf
-
- send -i $out [exec cat /etc/motd]
-
-.fi
-
-To send the numbers 1 to 100 in response to the prompt "next #", say:
-.nf
-
- for {set i 0} {$i<100} {incr i} {
- expect -i $in "next #"
- send -i $out "$i\r"
- }
-.fi
-
-Scripts can also be prepared and sourced in so that you don't have to
-type them on the spot.
-
-.B Dislocate
-is actually just a simple
-.B Expect
-script. Feel free to make it do what you want it to do or just
-use
-.B Expect
-directly, without going through
-.BR Dislocate .
-.B Dislocate
-understands a few special arguments. These should appear before any program
-name. Each should be separated by whitespace. If the arguments themselves
-takes arguments, these should also be separated by whitespace.
-.PP
-The
-.B \-escape
-flag sets the escape to whatever follows. The default escape is ^].
-.PP
-.SH CAVEATS
-This program was written by the author as an exercise to show that
-communicating with disconnected processes is easy. There are
-many features that could be added, but that is not the intent of this
-program.
-
-.SH SEE ALSO
-.BR Tcl (3),
-.BR libexpect (3)
-.br
-.I
-"Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Programs"
-\fRby Don Libes,
-O'Reilly and Associates, January 1995.
-.SH AUTHOR
-Don Libes, National Institute of Standards and Technology
+++ /dev/null
-#!../expect -f
-# simulate a dvorak keyboard
-# Actually just the lowercase letters are mapped to show the basic idea.
-# Really, uppercase and control should probably be mapped too.
-# But this isn't really what expect is all about. It just demonstrates
-# the mapping ability of 'interact'.
-
-proc rot {} {
- interact {
- q {send '} w {send ,} e {send .} r {send p}
- t {send y} y {send f} u {send g} i {send c}
- o {send r} p {send l} s {send o} d {send e}
- f {send u} g {send i} h {send d} j {send h}
- k {send t} l {send n} \; {send s} ' {send -- -}
- z {send \;} x {send q} c {send j} v {send k}
- b {send x} n {send b} , {send w} . {send v}
- / {send z} ~q {return} ~d {} ~e {}
- -o eof exit
- }
-}
-
-log_user 0
-spawn $env(SHELL)
-log_user 1
-send_user "~d for dvorak input\n"
-send_user "~q for qwerty input (default)\n"
-send_user "~e for expect interpreter\n"
-send_user "Enter ~ sequences using qwerty keys\n"
-interact ~d rot ~q {} ~e
+++ /dev/null
-#!/depot/tcl/src/expect/e --
-# Description: Simple fragment to begin a telnet daemon
-# For more information, see Chapter 17 of "Exploring Expect"
-# Author: Don Libes, NIST
-
-set IAC "\xff"
-set DONT "\xfe"
-set DO "\xfd"
-set WONT "\xfc"
-set WILL "\xfb"
-set SB "\xfa" ;# subnegotation begin
-set SE "\xf0" ;# subnegotation end
-set TTYPE "\x18"
-set SGA "\x03"
-set ECHO "\x01"
-set SEND "\x01"
-
-send "$IAC$WILL$ECHO"
-send "$IAC$WILL$SGA"
-send "$IAC$DO$TTYPE"
-
-remove_nulls 0
-
-expect_before {
- -re "^$IAC$DO$ECHO" {
- # treat as acknowledgement and ignore
- exp_continue
- }
- -re "^$IAC$DO$SGA" {
- # treat as acknowledgement and ignore
- exp_continue
- }
- -re "^$IAC$DO\(.)" {
- # refuse anything else
- send_user "$IAC$WONT$expect_out(1,string)"
- exp_continue
- }
- -re "^$IAC$WILL$TTYPE" {
- # respond to acknowledgement
- send_user "$IAC$SB$TTYPE$SEND$IAC$SE"
- exp_continue
- }
- -re "^$IAC$WILL$SGA" {
- send_user "$IAC$DO$SGA"
- exp_continue
- }
- -re "^$IAC$WILL\(.)" {
- # refuse anything else
- send_user "$IAC$DONT$expect_out(1,string)"
- exp_continue
- }
- -re "^$IAC$SB$TTYPE" {
- expect_user null
- expect_user -re "(.*)$IAC$SE"
- set env(TERM) [string tolower $expect_out(1,string)]
- # no continue!
- }
- -re "^$IAC$WONT$TTYPE" {
- # treat as acknowledgement and ignore
- set env(TERM) vt100
- # no continue!
- }
-}
-
-# do negotations up to terminal type
-# expect
-
-##############################
-# your code goes after this point here
-
-# spawn something ;# typically spawn something
-# expect ... ;# typically do some expects, sends, etc.
-# send ...
-# expect ...
-# send ...
-
-# expect_before ;# remove all protocol nonsense
-
-# let user interact
-# interact -re "\r" {send "\r"; expect_user \n {} null}
+++ /dev/null
-#!../expect -f
-# ftp-inband - copy files over a telnet/rlogin/etc link
-# Author: Don Libes, NIST
-# Date: Jan 11, 1993
-
-# Program follows usual conventions and is otherwise self-documenting.
-# Assumes standard UNIX conventions on both sides. It uses "compress"
-# which can be replaced with gzip or removed totally - it's just there
-# for efficiency.
-# Assumes error-free transmission (i.e., MNP modems), telnet links, etc.
-# Assumes remote shell does not reset tty modes after each command.
-
-# Note, there is very little error checking. This script was written
-# primarily as an exercise - just to demonstrate Expect.
-
-set prompt "(%|#|\\\$) $" ;# default prompt
-catch {set prompt $env(EXPECT_PROMPT)}
-
-set timeout -1
-set verbose_flag 0
-
-proc send_verbose {msg} {
- global verbose_flag
-
- if $verbose_flag {
- send_user $msg
- }
-}
-
-proc get {infile outfile} {
- global prompt verbose_flag
-
- if (!$verbose_flag) {
- log_user 0
- }
-
- send_verbose "disabling echo: "
- send "stty -echo\r"
- expect -re $prompt
-
- send_verbose "remote pid is "
- send "echo $$\r"
- expect -re "(.*)\r\n.*$prompt" {set rpid $expect_out(1,string)}
-
- set pid [pid]
- # pid is local pid, rpid is remote pid
-
- set infile_plain "/tmp/$rpid"
- set infile_compressed "$infile_plain.Z"
- set infile_encoded "$infile_compressed.uu"
-
- set outfile_plain "/tmp/$pid"
- set outfile_compressed "$outfile_plain.Z"
- set outfile_encoded "$outfile_compressed.uu"
-
- set out [open $outfile_encoded w]
-
- send_verbose "compressing\n"
- send "compress -fc $infile > $infile_compressed\r"
- expect -re $prompt
-
- # use label corresponding to temporary name on local system
- send_verbose "uuencoding\n"
- send "uuencode $infile_compressed $outfile_compressed > $infile_encoded\r"
- expect -re $prompt
-
- send_verbose "copying\n"
- send "cat $infile_encoded\r"
-
- log_user 0
-
- expect {
- -re "^end\r\n" {
- puts $out "end"
- close $out
- } -re "^(\[^\r]*)\r\n" {
- puts $out $expect_out(1,string)
- send_verbose "."
- exp_continue
- }
- }
-
- if ($verbose_flag) {
- send_user "\n" ;# after last "."
- log_user 1
- }
-
- expect -re $prompt ;# wait for prompt from cat
-
- send_verbose "deleting temporary files\n"
- send "rm -f $infile_compressed $infile_encoded\r"
- expect -re $prompt
-
- send_verbose "switching attention to local system\nuudecoding\n"
- exec uudecode $outfile_encoded
-
- send_verbose "uncompressing\n"
- exec uncompress -f $outfile_compressed
-
- send_verbose "renaming\n"
- if [catch "exec cp $outfile_plain $outfile" msg] {
- send_user "could not move file in place, reason: $msg\n"
- send_user "left as $outfile_plain\n"
- exec rm -f $outfile_encoded
- } else {
- exec rm -f $outfile_plain $outfile_encoded
- }
-
- # restore echo and serendipitously reprompt
- send "stty echo\r"
-
- log_user 1
-}
-
-proc put {infile outfile} {
- global prompt verbose_flag
-
- if (!$verbose_flag) {
- log_user 0
- }
-
- send_verbose "disabling echo: "
- send "stty -echo\r"
- expect -re $prompt
-
- send_verbose "remote pid is "
- send "echo $$\r"
- expect -re "(.*)\r\n.*$prompt" {set rpid $expect_out(1,string)}
-
- set pid [pid]
- # pid is local pid, rpid is remote pid
-
- set infile_plain "/tmp/$pid"
- set infile_compressed "$infile_plain.Z"
- set infile_encoded "$infile_compressed.uu"
-
- set outfile_plain "/tmp/$rpid"
- set outfile_compressed "$outfile_plain.Z"
- set outfile_encoded "$outfile_compressed.uu"
-
- set out [open $outfile_encoded w]
-
- send_verbose "compressing\n"
- exec compress -fc $infile > $infile_compressed
-
- # use label corresponding to temporary name on local system
- send_verbose "uuencoding\n"
- exec uuencode $infile_compressed $outfile_compressed > $infile_encoded
-
- send_verbose "copying\n"
- send "cat > $outfile_encoded\r"
-
- log_user 0
-
- set fp [open $infile_encoded r]
- while 1 {
- if {-1 == [gets $fp buf]} break
- send_verbose "."
- send "$buf\r"
- }
-
- if ($verbose_flag) {
- send_user "\n" ;# after last "."
- log_user 1
- }
-
- send "\004" ;# eof
- close $fp
-
- send_verbose "deleting temporary files\n"
- exec rm -f $infile_compressed $infile_encoded
-
- send_verbose "switching attention to remote system\n"
-
- expect -re $prompt ;# wait for prompt from cat
-
- send_verbose "uudecoding\n"
- send "uudecode $outfile_encoded\r"
- expect -re $prompt
-
- send_verbose "uncompressing\n"
- send "uncompress -f $outfile_compressed\r"
- expect -re $prompt
-
- send_verbose "renaming\n"
- send "cp $outfile_plain $outfile\r"
- expect -re $prompt
-
- send_verbose "deleting temporary files\n"
- send "rm -f $outfile_plain $outfile_encoded\r"
- expect -re $prompt
-
- # restore echo and serendipitously reprompt
- send "stty echo\r"
-
- log_user 1
-}
-
-proc get_main {} {
- stty -raw echo
- send_user "g\nget remote file \[localfile]: "
- expect_user {
- -re "(\[^ ]+) +(\[^ ]+)\n" {
- send_user "copying (remote) $expect_out(1,string) to (local) $expect_out(2,string)\n"
- get $expect_out(1,string) $expect_out(2,string)
- } -re "(\[^ ]+)\n" {
- send_user "copying $expect_out(1,string)\n"
- get $expect_out(1,string) $expect_out(1,string)
- } -re "\n" {
- send_user "eh?\n"
- }
- }
- stty raw -echo
-}
-
-proc put_main {} {
- stty -raw echo
- send_user "p\nput localfile \[remotefile]: "
- expect_user {
- -re "(\[^ ]+) +(\[^ ]+)\n" {
- send_user "copying (local) $expect_out(1,string) to (remote) $expect_out(2,string)\n"
- put $expect_out(1,string) $expect_out(2,string)
- } -re "(\[^ ]+)\n" {
- send_user "copying $expect_out(1,string)\n"
- put $expect_out(1,string) $expect_out(1,string)
- } -re "\n" {
- send_user "eh?\n"
- }
- }
- stty raw -echo
-}
-
-proc chdir {} {
- stty -raw echo
- send_user "c\n"
- send_user "current directory is [pwd], new directory: "
- expect_user -re "(.*)\n" {
- cd $expect_out(1,string)
- }
- stty raw -echo
-}
-
-proc verbose {} {
- global verbose_flag
-
- set verbose_flag [expr !$verbose_flag]
- send_user "verbose [verbose_status]\r\n"
-}
-
-proc verbose_status {} {
- global verbose_flag
-
- if $verbose_flag {
- return "on"
- } else {
- return "off"
- }
-}
-
-proc cmd {} {
- set CTRLZ \032
-
- send_user "command (g,p,? for more): "
- expect_user {
- g get_main
- p put_main
- c chdir
- v verbose
- ~ {send "~"}
- "\\?" {
- send_user "?\n"
- send_user "~~g get file from remote system\n"
- send_user "~~p put file to remote system\n"
- send_user "~~c change/show directory on local system\n"
- send_user "~~~ send ~~ to remote system\n"
- send_user "~~? this list\n"
- send_user "~~v verbose mode toggle (currently [verbose_status])\n"
- send_user "~~^Z suspend\n"
- }
- $CTRLZ {
- stty -raw echo
- exec kill -STOP [pid]
- stty raw -echo
- }
- -re . {send_user "unknown command\n"}
- }
- send_user "resuming session...\n"
-}
-
-spawn -noecho $env(SHELL)
-
-send_user "Once logged in, cd to directory to transfer to/from and press: ~~\n"
-send_user "One moment...\n"
-interact ~~ cmd
-
+++ /dev/null
-#!../expect --
-
-# ftp-rfc <rfc-number>
-# ftp-rfc -index
-
-# retrieves an rfc (or the index) from uunet
-
-exp_version -exit 5.0
-
-if $argc!=1 {
- send_user "usage: ftp-rfc \[#] \[-index]\n"
- exit
-}
-
-set file "rfc$argv.Z"
-
-set timeout 60
-spawn ftp ftp.uu.net
-expect "Name*:"
-send "anonymous\r"
-expect "Password:"
-send "expect@nist.gov\r"
-expect "ftp>"
-send "binary\r"
-expect "ftp>"
-send "cd inet/rfc\r"
-expect "550*ftp>" exit "250*ftp>"
-send "get $file\r"
-expect "550*ftp>" exit "200*226*ftp>"
-close
-wait
-send_user "\nuncompressing file - wait...\n"
-exec uncompress $file
-
+++ /dev/null
-#!../expect --
-#
-# gethostbyaddr a.b.c.d - translate an internet address to a FQDN,
-# guessing (a lot) if necessary.
-# Author: Don Libes, NIST
-# Version 4.0
-# Written: January 11, 1991
-# Last revised: March 21, 1996
-
-# By default, return a FQDN (fully qualified domain name) or descriptive
-# string (if FQDN is not easily determinable). This is tagged with a brief
-# explanation of how it was determined.
-#
-# If the host part of the FQDN cannot be determined, the original IP address
-# is used.
-#
-# Optional arguments act as toggles: Default
-# -t tag names with a description of how derived. true
-# -v verbose. false
-# -r reverse names to see if they resolve back to orig IP address. true
-# -n query nic for a descriptive string if it begins to look like true
-# the FQDN may be hard to derive.
-# -d turn on debugging to expose underlying dialogue false
-#
-# These options and others (see below) may be set in a ~/.gethostbyaddr file
-# To set options from that file, use the same syntax as below.
-set timeout 120 ;# timeout query after this many seconds
-set tag 1 ;# same as -t
-set reverse 1 ;# same as -r
-set verbose 0 ;# same as -v
-set nic 1 ;# same as -n
-set debug 0 ;# same as -d
-log_user 0
-
-proc usage {} {
- send_user "usage: gethostbyaddr \[options\] a.b.c.d\n"
- send_user "options meaning (all options act as toggles) default\n"
- send_user " -t tag with derivation description true\n"
- send_user " -v verbose false\n"
- send_user " -r reverse back to IP addr for verification true\n"
- send_user " -n query nic true\n"
- send_user " -d produce debugging output false\n"
- send_user "options must be separate.\n"
- exit
-}
-
-if [file readable ~/.gethostbyaddr] {source ~/.gethostbyaddr}
-
-while {[llength $argv]>0} {
- set flag [lindex $argv 0]
- switch -- $flag \
- "-v" {
- set verbose [expr !$verbose]
- set argv [lrange $argv 1 end]
- } "-r" {
- set reverse [expr !$reverse]
- set argv [lrange $argv 1 end]
- } "-n" {
- set nic [expr !$nic]
- set argv [lrange $argv 1 end]
- } "-t" {
- set tag [expr !$tag]
- set argv [lrange $argv 1 end]
- } "-d" {
- set debug [expr !$debug]
- set argv [lrange $argv 1 end]
- debug $debug
- } default {
- break
- }
-}
-
-set IPaddress $argv
-
-if [llength $argv]!=1 usage
-if 4!=[scan $IPaddress "%d.%d.%d.%d" a b c d] usage
-
-proc vprint {s} {
- global verbose
-
- if !$verbose return
- send_user $s\n
-}
-
-# dn==1 if domain name, 0 if text (from nic)
-proc printhost {name how dn} {
- global reverse tag IPaddress
-
- if {$dn && $reverse} {
- set verified [verify $name $IPaddress]
- } else {set verified 0}
-
- if {$verified || !$reverse || !$dn} {
- if $tag {
- send_user "$name ($how)\n"
- } else {
- send_user "$name\n"
- }
-
- if {$verified || !$reverse} {
- close
- wait
- exit
- }
- }
-}
-
-# return 1 if name resolves to IP address
-proc verify {name IPaddress} {
- vprint "verifying $name is $IPaddress"
- set rc 0
- spawn nslookup
- expect ">*"
- send $name\r
-
- expect {
- -re "\\*\\*\\* (\[^\r]*)\r" {
- vprint $expect_out(1,string)
- } timeout {
- vprint "timed out"
- } -re "Address:.*Address: (\[^\r]*)\r" {
- set addr2 $expect_out(1,string)
- if [string match $IPaddress $addr2] {
- vprint "verified"
- set rc 1
- } else {
- vprint "not verified - $name is $addr2"
- }
- }
- }
- close
- wait
- return $rc
-}
-
-set bad_telnet_responses "(telnet:|: unknown).*"
-
-proc telnet_error {s} {
- regexp ": (.*)\r" $s dontcare msg
- vprint $msg
-}
-
-proc guessHost {guess} {
- global guessHost
- if [info exists guessHost] return
- set guessHost $guess
-}
-
-proc guessDomain {guess} {
- global guessDomain
- if [info exists guessDomain] return
- set guessDomain $guess
-}
-
-proc guessFQDN {} {
- global guessHost guessDomain
- return $guessHost.$guessDomain
-}
-
-######################################################################
-# first do a simple reverse nslookup
-######################################################################
-
-vprint "using nslookup"
-spawn nslookup
-expect ">*"
-send "set query=ptr\r"
-expect ">*"
-send "$d.$c.$b.$a.in-addr.arpa\r"
-expect {
- timeout {
- vprint "timed out"
- } -re "\\*\\*\\* (\[^\r]*)\r" {
- vprint $expect_out(1,string)
- } -re "name = (\[^\r]*)\r" {
- set host $expect_out(1,string)
- printhost $host nslookup 1
-
- # split out hostname from FQDN as guess for later
- guessHost [lindex [split $host "."] 0]
- }
-}
-
-close
-wait
-
-######################################################################
-# next telnet to host and ask it what its name is
-######################################################################
-
-vprint "talking smtp to $IPaddress"
-spawn telnet $IPaddress smtp
-expect {
- -re $bad_telnet_responses {
- telnet_error $expect_out(buffer)
- } timeout {
- vprint "timed out"
- } -re "\n220 (\[^\\. ]*).?(\[^ ]*)" {
- set host $expect_out(1,string)
- set domain $expect_out(2,string)
- printhost $host.$domain smtp 1
-
- # if not valid FQDN, it's likely either host or domain
- if [string length $domain] {
- guessDomain $host.$domain
- } else {
- guessHost $host
- }
- }
-}
-catch close
-wait
-
-######################################################################
-# ask NIC for any info about this host
-######################################################################
-
-if {$nic || ($d == 0)} {
- vprint "talking to nic"
- spawn telnet internic.net
- expect {
- -re $bad_telnet_responses {
- telnet_error $expect_out(buffer)
- } timeout {
- vprint "timed out"
- } "InterNIC >" {
- send "whois\r"
- expect "Whois: "
- vprint "getting info on network $a.$b.$c"
- send "net $a.$b.$c\r"
- expect {
- "No match*" {
- vprint "no info"
- expect "Whois: "
- vprint "getting info on network $a.$b"
- send "net $a.$b\r"
- expect {
- "No match*" {
- vprint "no info"
- } -re "net\r\n(\[^\r]*)\r" {
- printhost $expect_out(1,string) nic 0
- } timeout {
- vprint "timed out"
- }
- }
- } -re "net\r\n(\[^\r]*)\r" {
- printhost $expect_out(1,string) nic 0
- } timeout {
- vprint "timed out"
- }
- }
- }
- }
- catch close
- wait
- if {$d == 0} exit
-}
-
-######################################################################
-# ask other hosts in the same class C what their name is
-# so that we can at least get the likely domain
-#
-# do this in two loops - first from current IP address down to 0
-# and then next from current IP address up to 255
-######################################################################
-
-# give up guessing host name
-guessHost "unknown"
-
-for {set i [expr $d-1]} {$i>0} {incr i -1} {
- vprint "talking smtp to $a.$b.$c.$i"
- spawn telnet $a.$b.$c.$i smtp
- expect {
- -re $bad_telnet_responses {
- telnet_error $expect_out(buffer)
- } timeout {
- vprint "timed out"
- } -re "\n220 (\[^\\. ]*).?(\[^ ]*)" {
- set host $expect_out(1,string)
- set domain $expect_out(2,string)
- printhost $guessHost.$domain "smtp - $a.$b.$c.$i is $host.$domain" 1
-
- # if not valid FQDN, it's likely either host or domain
- # don't bother recording host since it can't be for
- # original addr.
- if [string length $domain] {
- guessDomain $host.$domain
- }
- }
- }
- catch close
- wait
-}
-
-for {set i [expr $d+1]} {$i<255} {incr i} {
- vprint "talking smtp to $a.$b.$c.$i"
- spawn telnet $a.$b.$c.$i smtp
- expect {
- -re $bad_telnet_responses {
- telnet_error $expect_out(buffer)
- } timeout {
- vprint "timed out"
- } -re "\n220 (\[^ ]*.(\[^ ])) " {
- set host $expect_out(1,string)
- set domain $expect_out(2,string)
- printhost $guessHost.$domain "smtp - $a.$b.$c.$i is $host.$domain" 1
-
- # if not valid FQDN, it's likely either host or domain
- # don't bother recording host since it can't be for
- # original addr.
- if [string length $domain] {
- guessDomain $host.$domain
- }
- }
- }
- catch close
- wait
-}
-
-######################################################################
-# print our best guess as to the name
-######################################################################
-
-
-# How pathetic. Print something, anything!
-if {!$verbose && !$tag} {send_user [guessFQDN]}
+++ /dev/null
-#!/depot/path/expect --
-
-# Do rsh interactively. For example, consider the following command:
-# rsh <remote> ls -l "|" more
-# where it would be nice to get a listing page by page
-
-spawn -noecho rlogin [lindex $argv 0]
-set timeout -1
-expect "% " ;# customize appropriately
-send "[lrange $argv 1 end];exit\r"
-interact
+++ /dev/null
-#!../expect --
-# allow another user to share a shell (or other program) with you
-# See kibitz(1) man page for complete info.
-# Author: Don Libes, NIST
-# Date written: December 5, 1991
-# Date last editted: October 19, 1994
-# Version: 2.11
-exp_version -exit 5.0
-
-# if environment variable "EXPECT_PROMPT" exists, it is taken as a regular
-# expression which matches the end of your login prompt (but does not other-
-# wise occur while logging in).
-
-set prompt "(%|#|\\$) $" ;# default prompt
-set noproc 0
-set tty "" ;# default if no -tty flag
-set allow_escape 1 ;# allow escapes if true
-set escape_char \035 ;# control-right-bracket
-set escape_printable "^\]"
-set verbose 1 ;# if true, describe what kibitz is doing
-
-set kibitz "kibitz" ;# where kibitz lives if some unusual place.
- ;# this must end in "kibitz", but can have
- ;# things in front (like directory names).
-#set proxy "kibitz" ;# uncomment and set if you want kibitz to use
- ;# some other account on remote systems
-
-# The following code attempts to intuit whether cat buffers by default.
-# The -u flag is required on HPUX (8 and 9) and IBM AIX (3.2) systems.
-if [file exists $exp_exec_library/cat-buffers] {
- set catflags "-u"
-} else {
- set catflags ""
-}
-# If this fails, you can also force it by commenting in one of the following.
-# Or, you can use the -catu flag to the script.
-#set catflags ""
-#set catflags "-u"
-
-# Some flags must be passed onto the remote kibitz process. They are stored
-# in "kibitz_flags". Currently, they include -tty and -silent.
-set kibitz_flags ""
-
-while {[llength $argv]>0} {
- set flag [lindex $argv 0]
- switch -- $flag \
- "-noproc" {
- set noproc 1
- set argv [lrange $argv 1 end]
- } "-catu" {
- set catflags "-u"
- set argv [lrange $argv 1 end]
- } "-tty" {
- set tty [lindex $argv 1]
- set argv [lrange $argv 2 end]
- set kibitz_flags "$kibitz_flags -tty $tty"
- } "-noescape" {
- set allow_escape 0
- set argv [lrange $argv 1 end]
- } "-escape" {
- set escape_char [lindex $argv 1]
- set escape_printable $escape_char
- set argv [lrange $argv 2 end]
- } "-silent" {
- set verbose 0
- set argv [lrange $argv 1 end]
- set kibitz_flags "$kibitz_flags -silent"
- } "-proxy" {
- set proxy [lindex $argv 1]
- set argv [lrange $argv 2 end]
- } default {
- break
- }
-}
-
-if {([llength $argv]<1) && ($noproc==0)} {
- send_user "usage: kibitz \[args] user \[program ...]\n"
- send_user " or: kibitz \[args] user@host \[program ...]\n"
- exit
-}
-
-log_user 0
-set timeout -1
-
-set user [lindex $argv 0]
-if [string match -r $user] {
- send_user "KRUN" ;# this tells user_number 1 that we're running
- ;# and to prepare for possible error messages
- set user_number 3
- # need to check that it exists first!
- set user [lindex $argv 1]
-} else {
- set user_number [expr 1+(0==[string first - $user])]
-}
-
-# at this point, user_number and user are correctly determined
-# User who originated kibitz session has user_number == 1 on local machine.
-# User who is responding to kibitz has user_number == 2.
-# User who originated kibitz session has user_number == 3 on remote machine.
-
-# user 1 invokes kibitz as "kibitz user[@host]"
-# user 2 invokes kibitz as "kibitz -####" (some pid).
-# user 3 invokes kibitz as "kibitz -r user".
-
-# uncomment for debugging: leaves each user's session in a file: 1, 2 or 3
-#exec rm -f $user_number
-#exp_internal -f $user_number 0
-
-set user2_islocal 1 ;# assume local at first
-
-# later move inside following if $user_number == 1
-# return true if x is a prefix of xjunk, given that prefixes are only
-# valid at . delimiters
-# if !do_if0, skip the whole thing - this is here just to make caller simpler
-proc is_prefix {do_if0 x xjunk} {
- if 0!=$do_if0 {return 0}
- set split [split $xjunk .]
- for {set i [expr [llength $split]-1]} {$i>=0} {incr i -1} {
- if [string match $x [join [lrange $split 0 $i] .]] {return 1}
- }
- return 0
-}
-
-# get domainname. Unfortunately, on some systems, domainname(1)
-# returns NIS domainname which is not the internet domainname.
-proc domainname {} {
- # open pops stack upon failure
- set rc [catch {open /etc/resolv.conf r} file]
- if {$rc==0} {
- while {-1!=[gets $file buf]} {
- if 1==[scan $buf "domain %s" name] {
- close $file
- return $name
- }
- }
- close $file
- }
-
- # fall back to using domainname
- if {0==[catch {exec domainname} name]} {return $name}
-
- error "could not figure out domainname"
-}
-
-if $user_number==1 {
- if $noproc==0 {
- if [llength $argv]>1 {
- set pid [eval spawn [lrange $argv 1 end]]
- } else {
- # if running as CGI, shell may not be set!
- set shell /bin/sh
- catch {set shell $env(SHELL)}
- set pid [spawn $shell]
- }
- set shell $spawn_id
- }
-
- # is user2 remote?
- regexp (\[^@\]*)@*(.*) $user ignore tmp host
- set user $tmp
- if ![string match $host ""] {
- set h_rc [catch {exec hostname} hostname]
- set d_rc [catch domainname domainname]
-
- if {![is_prefix $h_rc $host $hostname]
- && ![is_prefix $d_rc $host $hostname.$domainname]} {
- set user2_islocal 0
- }
- }
-
- if !$user2_islocal {
- if $verbose {send_user "connecting to $host\n"}
-
- if ![info exists proxy] {
- proc whoami {} {
- global env
- if [info exists env(USER)] {return $env(USER)}
- if [info exists env(LOGNAME)] {return $env(LOGNAME)}
- if ![catch {exec whoami} user] {return $user}
- if ![catch {exec logname} user] {return $user}
- # error "can't figure out who you are!"
- }
- set proxy [whoami]
- }
- spawn rlogin $host -l $proxy -8
- set userin $spawn_id
- set userout $spawn_id
-
- catch {set prompt $env(EXPECT_PROMPT)}
-
- set timeout 120
- expect {
- assword: {
- stty -echo
- send_user "password (for $proxy) on $host: "
- set old_timeout $timeout; set timeout -1
- expect_user -re "(.*)\n"
- send_user "\n"
- set timeout $old_timeout
- send "$expect_out(1,string)\r"
- # bother resetting echo?
- exp_continue
- } incorrect* {
- send_user "invalid password or account\n"
- exit
- } "TERM = *) " {
- send "\r"
- exp_continue
- } timeout {
- send_user "connection to $host timed out\n"
- exit
- } eof {
- send_user "connection to host failed: $expect_out(buffer)"
- exit
- } -re $prompt
- }
- if $verbose {send_user "starting kibitz on $host\n"}
- # the kill protects user1 from receiving user3's
- # prompt if user2 exits via expect's exit.
- send "$kibitz $kibitz_flags -r $user;kill -9 $$\r"
-
- expect {
- -re "kibitz $kibitz_flags -r $user.*KRUN" {}
- -re "kibitz $kibitz_flags -r $user.*(kibitz\[^\r\]*)\r" {
- send_user "unable to start kibitz on $host: \"$expect_out(1,string)\"\n"
- send_user "try rlogin by hand followed by \"kibitz $user\"\n"
- exit
- }
- timeout {
- send_user "unable to start kibitz on $host: "
- set expect_out(buffer) "timed out"
- set timeout 0; expect -re .+
- send_user $expect_out(buffer)
- exit
- }
- }
- expect {
- -re ".*\n" {
- # pass back diagnostics
- # should really strip out extra cr
- send_user $expect_out(buffer)
- exp_continue
- }
- KABORT exit
- default exit
- KDATA
- }
- }
-}
-
-if $user_number==2 {
- set pid [string trimleft $user -]
-}
-
-set local_io [expr ($user_number==3)||$user2_islocal]
-if $local_io||($user_number==2) {
- if 0==[info exists pid] {set pid [pid]}
-
- set userinfile /tmp/exp0.$pid
- set useroutfile /tmp/exp1.$pid
-}
-
-proc prompt1 {} {
- return "kibitz[info level].[history nextid]> "
-}
-
-set esc_match {}
-if {$allow_escape} {
- set esc_match {
- $escape_char {
- send_user "\nto exit kibitz, enter: exit\n"
- send_user "to suspend kibitz, press appropriate job control sequence\n"
- send_user "to return to kibitzing, enter: return\n"
- interpreter
- send_user "returning to kibitz\n"
- }
- }
-}
-
-proc prompt1 {} {
- return "kibitz[info level].[history nextid]> "
-}
-
-set timeout -1
-
-# kibitzer executes following code
-if $user_number==2 {
- # for readability, swap variables
- set tmp $userinfile
- set userinfile $useroutfile
- set useroutfile $tmp
-
- if ![file readable $userinfile] {
- send_user "Eh? No one is asking you to kibitz.\n"
- exit -1
- }
- spawn -open [open "|cat $catflags < $userinfile" "r"]
- set userin $spawn_id
-
- spawn -open [open $useroutfile w]
- set userout $spawn_id
- # open will hang until other user's cat starts
-
- stty -echo raw
- if $allow_escape {send_user "Escape sequence is $escape_printable\r\n"}
-
- # While user is reading message, try to delete other fifo
- catch {exec rm -f $userinfile}
-
- eval interact $esc_match \
- -output $userout \
- -input $userin
-
- exit
-}
-
-# only user_numbers 1 and 3 execute remaining code
-
-proc abort {} {
- global user_number
-
- # KABORT tells user_number 1 that user_number 3 has run into problems
- # and is exiting, and diagnostics have been returned already
- if $user_number==3 {send_user KABORT}
- exit
-}
-
-if $local_io {
- proc mkfifo {f} {
- if 0==[catch {exec mkfifo $f}] return ;# POSIX
- if 0==[catch {exec mknod $f p}] return
- # some systems put mknod in wierd places
- if 0==[catch {exec /usr/etc/mknod $f p}] return ;# Sun
- if 0==[catch {exec /etc/mknod $f p}] return ;# AIX, Cray
- puts "Couldn't figure out how to make a fifo - where is mknod?"
- abort
- }
-
- proc rmfifos {} {
- global userinfile useroutfile
- catch {exec rm -f $userinfile $useroutfile}
- }
-
- trap {rmfifos; exit} {SIGINT SIGQUIT SIGTERM}
-
- # create 2 fifos to communicate with other user
- mkfifo $userinfile
- mkfifo $useroutfile
- # make sure other user can access despite umask
- exec chmod 666 $userinfile $useroutfile
-
- if $verbose {send_user "asking $user to type: kibitz -$pid\n"}
-
- # can't use exec since write insists on being run from a tty!
- set rc [catch {
- system echo "Can we talk? Run: \"kibitz -$pid\"" | \
- /bin/write $user $tty
- }
- ]
- if $rc {rmfifos;abort}
-
- spawn -open [open $useroutfile w]
- set userout $spawn_id
- # open will hang until other user's cat starts
-
- spawn -open [open "|cat $catflags < $userinfile" "r"]
- set userin $spawn_id
- catch {exec rm $userinfile}
-}
-
-stty -echo raw
-
-if $user_number==3 {
- send_user "KDATA" ;# this tells user_number 1 to send data
-
- interact {
- -output $userout
- -input $userin eof {
- wait -i $userin
- return -tcl
- } -output $user_spawn_id
- }
-} else {
- if $allow_escape {send_user "Escape sequence is $escape_printable\r\n"}
-
- if $noproc {
- interact {
- -output $userout
- -input $userin eof {wait -i $userin; return}
- -output $user_spawn_id
- }
- } else {
- eval interact $esc_match {
- -output $shell \
- -input $userin eof {
- wait -i $userin
- close -i $shell
- return
- } -output $shell \
- -input $shell -output "$user_spawn_id $userout"
- }
- wait -i $shell
- }
-}
-
-if $local_io rmfifos
+++ /dev/null
-.TH KIBITZ 1 "19 October 1994"
-.SH NAME
-kibitz \- allow two people to interact with one shell
-.SH SYNOPSIS
-.B kibitz
-[
-.I kibitz-args
-]
-.I user
-[
-.I program program-args...
-]
-.br
-.B kibitz
-[
-.I kibitz-args
-]
-.I user@host
-[
-.I program program-args...
-]
-.SH INTRODUCTION
-.B kibitz
-allows two (or more) people to interact with one shell (or any arbitrary
-program). Uses include:
-.RS
-.TP 4
-\(bu
-A novice user can ask an expert user for help. Using
-.BR kibitz ,
-the expert can see what the user is doing, and offer advice or
-show how to do it right.
-.TP
-\(bu
-By running
-.B kibitz
-and then starting a full-screen editor, people may carry out a
-conversation, retaining the ability to scroll backwards,
-save the entire conversation, or even edit it while in progress.
-.TP
-\(bu
-People can team up on games, document editing, or other cooperative
-tasks where each person has strengths and weaknesses that complement one
-another.
-.SH USAGE
-To start
-.BR kibitz ,
-user1
-runs kibitz with the argument of the
-user to kibitz. For example:
-
- kibitz user2
-
-.B kibitz
-starts a new shell (or another program, if given on the command
-line), while prompting user2 to run
-.BR kibitz .
-If user2 runs
-.B kibitz
-as directed, the keystrokes of both users become the input of
-the shell. Similarly, both users receive the output from the
-shell.
-
-To terminate
-.B kibitz
-it suffices to terminate the shell itself. For example, if either user
-types ^D (and the shell accepts this to be EOF), the shell terminates
-followed by
-.BR kibitz .
-
-Normally, all characters are passed uninterpreted. However, if the
-escape character (described when
-.B kibitz
-starts) is issued, the user
-may talk directly to the
-.B kibitz
-interpreter. Any
-.BR Expect (1)
-or
-.BR Tcl (3)
-commands may be given.
-Also, job control may be used while in the interpreter, to, for example,
-suspend or restart
-.BR kibitz .
-
-Various processes
-can provide various effects. For example, you can emulate a two-way write(1)
-session with the command:
-
- kibitz user2 sleep 1000000
-.SH ARGUMENTS
-.B kibitz
-takes arguments, these should also be separated by whitespace.
-
-The
-.B \-noproc
-flag runs
-.B kibitz
-with no process underneath. Characters are passed to the other
-.BR kibitz .
-This is particularly useful for connecting multiple
-interactive processes together.
-In this mode, characters are not echoed back to the typist.
-
-.B \-noescape
-disables the escape character.
-
-.BI \-escape " char"
-sets the escape character. The default escape character is ^].
-
-.B \-silent
-turns off informational messages describing what kibitz is doing to
-initiate a connection.
-
-.BI \-tty " ttyname"
-defines the tty to which the invitation should be sent.
-
-If you start
-.B kibitz
-to user2 on a remote computer,
-.B kibitz
-performs a
-.B rlogin
-to the remote computer with your current username. The flag
-.BI \-proxy " username"
-causes
-.B rlogin
-to use
-.I username
-for the remote login (e.g. if your account on the remote computer has a
-different username). If the
-.B -proxy
-flag is not given,
-.B kibitz
-tries to determine your current username by (in that order) inspecting the
-environment variables USER and LOGNAME, then by using the commands
-.B whoami
-and
-.BR logname .
-
-The arguments
-.B -noescape
-and
-.B -escape
-can also be given by user2 when prompted to run
-.BR kibitz .
-
-.SH MORE THAN TWO USERS
-The current implementation of kibitz explicitly understands only two users,
-however, it is nonetheless possible to have a three (or more) -way kibitz,
-by kibitzing another
-.BR kibitz .
-For example, the following command runs
-.B kibitz
-with the current user, user2, and user3:
-
- % kibitz user2 kibitz user3
-
-Additional users may be added by simply appending more "kibitz user"
-commands.
-
-The
-.B xkibitz
-script is similar to
-.B kibitz
-but supports the ability to add additional users (and drop them)
-dynamically.
-.SH CAVEATS
-.B kibitz
-assumes the 2nd user has the same terminal type and size as the 1st user.
-If this assumption is incorrect, graphical programs may display oddly.
-
-.B kibitz
-handles character graphics, but cannot handle bitmapped graphics. Thus,
-.nf
-
- % xterm -e kibitz will work
- % kibitz xterm will not work
-
-.fi
-However, you can get the effect of the latter command by using
-.B xkibitz
-(see SEE ALSO below).
-.B kibitz
-uses the same permissions as used by rlogin, rsh, etc. Thus, you
-can only
-.B kibitz
-to users at hosts for which you can rlogin.
-Similarly,
-.B kibitz
-will prompt for a password on the remote host if
-rlogin would.
-
-If you
-.B kibitz
-to users at remote hosts,
-.B kibitz
-needs to distinguish your prompt from other things that may precede it
-during login.
-(Ideally, the end of it is preferred but any part should suffice.)
-If you have an unusual prompt,
-set the environment variable EXPECT_PROMPT to an egrep(1)-style
-regular expression.
-Brackets should be preceded with one backslash in ranges,
-and three backslashes for literal brackets.
-The default prompt r.e. is "($|%|#)\ ".
-
-.B kibitz
-requires the
-.B kibitz
-program on both hosts.
-.B kibitz
-requires
-.BR expect (1).
-
-By comparison, the
-.B xkibitz
-script uses the X authorization mechanism for inter-host communication
-so it does not need to login, recognize your prompt, or require kibitz
-on the remote host. It does however need permission to access
-the other X servers.
-.SH BUGS
-An early version of Sun's tmpfs had a bug in it that causes
-.B kibitz
-to blow up. If
-.B kibitz
-reports "error flushing ...: Is a directory"
-ask Sun for patch #100174.
-
-If your Expect is not compiled with multiple-process support (i.e., you do not
-have a working select or poll), you will not be able to run kibitz.
-.SH ENVIRONMENT
-The environment variable SHELL is used to determine the shell to start, if no
-other program is given on the command line.
-
-If the environment variable EXPECT_PROMPT exists, it is taken as a regular
-expression which matches the end of your login prompt (but does not otherwise
-occur while logging in). See also CAVEATS above.
-
-If the environment variables USER or LOGNAME are defined, they are used to
-determine the current user name for a
-.B kibitz
-to a remote computer. See description of the
-.B -proxy
-option in ARGUMENTS above.
-.SH SEE ALSO
-.BR Tcl (3),
-.BR libexpect (3),
-.BR xkibitz (1)
-.br
-.I
-"Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Programs"
-\fRby Don Libes,
-O'Reilly and Associates, January 1995.
-.br
-.I
-"Kibitz \- Connecting Multiple Interactive Programs Together", \fRby Don Libes,
-Software \- Practice & Experience, John Wiley & Sons, West Sussex, England,
-Vol. 23, No. 5, May, 1993.
-.SH AUTHOR
-Don Libes, National Institute of Standards and Technology
-
-.B kibitz
-is in the public domain.
-NIST and I would
-appreciate credit if this program or parts of it are used.
+++ /dev/null
-#!../expect -f
-
-# This script unhangs a printer which claims it is "waiting for lock".
-# Written by Don Libes. Based on English instructions from Scott Paisley.
-
-# lpunlock figures out if the printer is on a server, and if so which,
-# by looking in the local printcap file. (You can override this by
-# supplying a server name as an additional argument.) It then rlogins
-# to the server, recreates the device and resets the queue via lpc.
-
-# assumes user has root privs on remote host via /.rhosts
-
-# assumes printer is name of device on remote system
-
-proc usage {} {
- send_user "usage: lpunlock <printer> \[<server>\]\n"
- send_user "example: lpunlock lw-isg durer\n"
- exit
-}
-
-if $argc==0 usage
-set printer [lindex $argv 0]
-
-set client [exec hostname]
-
-if {$argc == 1} {
- # if no arg2, look in local printcap for info
- spawn ed /etc/printcap
- expect "\n" ;# discard character count
- send "/$printer/\r"
- for {} 1 {} {
- expect -re ".*:rm=(\[^:]*):.*\r\n" {
- set server $expect_out(1,string)
- break
- } "\r\n*\\\r\n" { ;# look at next line of entry
- send "\r"
- } "\r\n*\n" { ;# no more lines of entry - give up
- set server $client
- break
- }
- }
-} else {
- if {$argc == 2} {
- set server [lindex $argv 1]
- } else usage
-}
-
-set whoami [exec whoami]
-if {[string match $server $client] && [string match $whoami "root"]} {
- spawn csh
- expect "# "
-} else {
- # login to the print server as root.
- # Set timeout high because login is slow.
- set timeout 60
- spawn rlogin $server -l root
- expect timeout exit \
- eof exit \
- "Password*" {
- send_user "\ncouldn't login to $server as root\n"
- exit
- } "1#*"
- set timeout 10
-}
-
-# run lpc and 'stop printer'
-send lpc\r ; expect "lpc>*"
-send stop $printer\r ; expect "unknown*" exit \
- "disabled*lpc>*"
-
-# exit lpc and cd /dev
-send quit\r ; expect "#*"
-send cd /dev\r ; expect "#*"
-
-# figure out major/minor device numbers
-send ls -l /dev/$printer\r ; expect timeout {
- send_user "\nbad device - couldn't get major/minor numbers\n"; exit
- } "crw*#*"
-scan $expect_out(buffer) "ls -l %*s %*s 1 root %d, %d" major minor
-
-# delete the lock and the printer device itself
-send rm /var/spool/$printer/lock /dev/$printer\r ; expect #*
-
-# recreate the printer device
-send mknod $printer c $major $minor\r ; expect #*
-
-# run lpc and 'start printer'
-send lpc\r ; expect lpc>*
-send start $printer\r ; expect started*lpc>*
-send quit\r ; expect #*
-
-# logout
-send exit\r ; expect eof
-
-send_user Printer unlocked and restarted.\n
+++ /dev/null
-#!/depot/path/expect --
-# mkpasswd - make a password, if username given, set it.
-# Author: Don Libes, NIST
-
-# defaults
-set length 9
-set minnum 2
-set minlower 2
-set minupper 2
-set verbose 0
-set distribute 0
-
-if [file executable /bin/yppasswd] {
- set defaultprog /bin/yppasswd
-} elseif [file executable /bin/passwd] {
- set defaultprog /bin/passwd
-} else {
- set defaultprog passwd
-}
-set prog $defaultprog
-
-while {[llength $argv]>0} {
- set flag [lindex $argv 0]
- switch -- $flag \
- "-l" {
- set length [lindex $argv 1]
- set argv [lrange $argv 2 end]
- } "-d" {
- set minnum [lindex $argv 1]
- set argv [lrange $argv 2 end]
- } "-c" {
- set minlower [lindex $argv 1]
- set argv [lrange $argv 2 end]
- } "-C" {
- set minupper [lindex $argv 1]
- set argv [lrange $argv 2 end]
- } "-v" {
- set verbose 1
- set argv [lrange $argv 1 end]
- } "-p" {
- set prog [lindex $argv 1]
- set argv [lrange $argv 2 end]
- } "-2" {
- set distribute 1
- set argv [lrange $argv 1 end]
- } default {
- set user [lindex $argv 0]
- set argv [lrange $argv 1 end]
- break
- }
-}
-
-if {[llength $argv]} {
- puts "usage: mkpasswd \[args] \[user]"
- puts " where arguments are:"
- puts " -l # (length of password, default = $length)"
- puts " -d # (min # of digits, default = $minnum)"
- puts " -c # (min # of lowercase chars, default = $minlower)"
- puts " -C # (min # of uppercase chars, default = $minupper)"
- puts " -v (verbose, show passwd interaction)"
- puts " -p prog (program to set password, default = $defaultprog)"
- exit 1
-}
-
-if {$minnum + $minlower + $minupper > $length} {
- puts "impossible to generate $length-character password\
- with $minnum numbers, $minlower lowercase letters,\
- and $minupper uppercase letters"
- exit 1
-}
-
-# if there is any underspecification, use additional lowercase letters
-set minlower [expr $length - ($minnum + $minupper)]
-
-set lpass "" ;# password chars typed by left hand
-set rpass "" ;# password chars typed by right hand
-
-# insert char into password at a random position
-proc insert {pvar char} {
- upvar $pvar p
-
- set p [linsert $p [rand [expr 1+[llength $p]]] $char]
-}
-
-set _ran [pid]
-
-proc rand {m} {
- global _ran
-
- set period 259200
- set _ran [expr ($_ran*7141 + 54773) % $period]
- expr int($m*($_ran/double($period)))
-}
-
-# choose left or right starting hand
-set initially_left [set isleft [rand 2]]
-
-# given a size, distribute between left and right hands
-# taking into account where we left off
-proc psplit {max lvar rvar} {
- upvar $lvar left $rvar right
- global isleft
-
- if {$isleft} {
- set right [expr $max/2]
- set left [expr $max-$right]
- set isleft [expr !($max%2)]
- } else {
- set left [expr $max/2]
- set right [expr $max-$left]
- set isleft [expr $max%2]
- }
-}
-
-if {$distribute} {
- set lkeys {q w e r t a s d f g z x c v b}
- set rkeys {y u i o p h j k l n m}
- set lnums {1 2 3 4 5 6}
- set rnums {7 8 9 0}
-} else {
- set lkeys {a b c d e f g h i j k l m n o p q r s t u v w x y z}
- set rkeys {a b c d e f g h i j k l m n o p q r s t u v w x y z}
- set lnums {0 1 2 3 4 5 6 7 8 9}
- set rnums {0 1 2 3 4 5 6 7 8 9}
-}
-
-set lkeys_length [llength $lkeys]
-set rkeys_length [llength $rkeys]
-set lnums_length [llength $lnums]
-set rnums_length [llength $rnums]
-
-psplit $minnum left right
-for {set i 0} {$i<$left} {incr i} {
- insert lpass [lindex $lnums [rand $lnums_length]]
-}
-for {set i 0} {$i<$right} {incr i} {
- insert rpass [lindex $rnums [rand $rnums_length]]
-}
-
-psplit $minlower left right
-for {set i 0} {$i<$left} {incr i} {
- insert lpass [lindex $lkeys [rand $lkeys_length]]
-}
-for {set i 0} {$i<$right} {incr i} {
- insert rpass [lindex $rkeys [rand $rkeys_length]]
-}
-
-psplit $minupper left right
-for {set i 0} {$i<$left} {incr i} {
- insert lpass [string toupper [lindex $lkeys [rand $lkeys_length]]]
-}
-for {set i 0} {$i<$right} {incr i} {
- insert rpass [string toupper [lindex $rkeys [rand $rkeys_length]]]
-}
-
-# merge results together
-if {$initially_left} {
- regexp "(\[^ ]*) *(.*)" "$lpass" x password lpass
- while {[llength $lpass]} {
- regexp "(\[^ ]*) *(.*)" "$password$rpass" x password rpass
- regexp "(\[^ ]*) *(.*)" "$password$lpass" x password lpass
- }
- if {[llength $rpass]} {
- append password $rpass
- }
-} else {
- regexp "(\[^ ]*) *(.*)" "$rpass" x password rpass
- while {[llength $rpass]} {
- regexp "(\[^ ]*) *(.*)" "$password$lpass" x password lpass
- regexp "(\[^ ]*) *(.*)" "$password$rpass" x password rpass
- }
- if {[llength $lpass]} {
- append password $lpass
- }
-}
-
-if {[info exists user]} {
- if {!$verbose} {
- log_user 0
- }
-
- spawn $prog $user
- expect {
- "assword*:" {
- # some systems say "Password (again):"
- send "$password\r"
- exp_continue
- }
- }
-
- # if user isn't watching, check status
- if {!$verbose} {
- if {[lindex [wait] 3]} {
- puts -nonewline "$expect_out(buffer)"
- exit 1
- }
- }
-}
-
-if {$verbose} {
- puts -nonewline "password for $user is "
-}
-puts "$password"
+++ /dev/null
-.TH MKPASSWD 1 "22 August 1994"
-.SH NAME
-mkpasswd \- generate new password, optionally apply it to a user
-.SH SYNOPSIS
-.B mkpasswd
-.I
-[
-.I args
-]
-[
-.I user
-]
-.SH INTRODUCTION
-.B mkpasswd
-generates passwords and can apply them automatically to users.
-mkpasswd is based on the code from Chapter 23 of the O'Reilly book
-"Exploring Expect".
-.SH USAGE
-With no arguments,
-.B mkpasswd
-returns a new password.
-
- mkpasswd
-
-With a user name,
-.B mkpasswd
-assigns a new password to the user.
-
- mkpasswd don
-
-The passwords are randomly generated according to the flags below.
-
-.SH FLAGS
-The
-.B \-l
-flag defines the length of the password. The default is 9.
-The following example creates a 20 character password.
-
- mkpasswd -l 20
-
-The
-.B \-d
-flag defines the minimum number of digits that must be in the password.
-The default is 2. The following example creates a password with at least
-3 digits.
-
- mkpasswd -d 3
-
-The
-.B \-c
-flag defines the minimum number of lowercase alphabetic characters that must be in the password.
-The default is 2.
-
-The
-.B \-C
-flag defines the minimum number of uppercase alphabetic characters that must be in the password.
-The default is 2.
-
-The
-.B \-p
-flag names a program to set the password.
-By default, /etc/yppasswd is used if present, otherwise /bin/passwd is used.
-
-The
-.B \-2
-flag causes characters to be chosen so that they alternate between
-right and left hands (qwerty-style), making it harder for anyone
-watching passwords being entered. This can also make it easier for
-a password-guessing program.
-
-The
-.B \-v
-flag causes the password-setting interaction to be visible.
-By default, it is suppressed.
-
-.SH EXAMPLE
-The following example creates a 15-character password
-that contains at least 3 digits and 5 uppercase characters.
-
- mkpasswd -l 15 -d 3 -C 5
-
-.SH SEE ALSO
-.I
-"Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Programs"
-\fRby Don Libes,
-O'Reilly and Associates, January 1995.
-.SH AUTHOR
-Don Libes, National Institute of Standards and Technology
-
-.B mkpasswd
-is in the public domain.
-NIST and I would
-appreciate credit if this program or parts of it are used.
-
-
+++ /dev/null
-#!../expect --
-# passmass: change password on many machines
-# Synopsis: passmass host1 host2 host3 ....
-# Don Libes - March 11, 1991
-
-# Description: Change passwords on the named machines.
-#
-# You are prompted for old/new passwords. (If you are changing root
-# passwords and have equivalencing, the old password is not used and may be
-# omitted.)
-#
-# Additional arguments may be used for fine tuning. They affect all hosts
-# which follow until another argument overrides.
-#
-# -user User whose password will be changed. By default, the current
-# user is used.
-# -rlogin Use rlogin to access host. (default)
-# -telnet Use telnet to access host.
-# -program Next argument is taken as program to run to set password.
-# Default is "passwd". Other common choices are "yppasswd" and
-# "set passwd" (e.g., VMS hosts).
-# -prompt Next argument is taken as a prompt suffix pattern. This allows
-# the script to know when the shell is prompting. The default is
-# "# " for root and "% " for non-root accounts.
-# -timeout Next argument is number of seconds to wait for responses.
-# Default is 30 but some systems can be much slower logging in.
-
-# The best way to run this is to put the command in a one-line shell script
-# or alias. (Presumably, the set of hosts and parameters will rarely change.)
-# Then run it whenever you want to change your passwords on all the hosts.
-
-exp_version -exit 5.0
-
-if $argc==0 {
- send_user "usage: $argv0 host1 host2 host3 . . .\n"
- exit
-}
-
-expect_before -i $user_spawn_id \003 exit
-
-proc badhost {host emsg} {
- global badhosts
-
- send_user "\r\n\007password not changed on $host - $emsg\n\n"
- if 0==[llength $badhosts] {
- set badhosts $host
- } else {
- set badhosts [concat $badhosts $host]
- }
-}
-
-# set defaults
-set login "rlogin"
-set program "passwd"
-set user [exec whoami]
-
-set timeout 1000000
-stty -echo
-send_user "old password: "
-expect_user -re "(.*)\n"
-send_user "\n"
-set oldpassword $expect_out(1,string)
-send_user "new password: "
-expect_user -re "(.*)\n"
-send_user "\n"
-set newpassword $expect_out(1,string)
-send_user "retype new password: "
-expect_user -re "(.*)\n"
-set newpassword2 $expect_out(1,string)
-send_user "\n"
-stty echo
-trap exit SIGINT
-
-if ![string match $newpassword $newpassword2] {
- send_user "mismatch - password unchanged\n"
- exit
-}
-
-
-#send_user "want to see new password you just typed? (y|n) "
-#expect_user "*\n"
-#
-#if [string match "y" [lindex $expect_match 0 c]] {
-# send_user "password is <$newpassword>\nproceed? (y|n) "
-# expect_user "*\n"
-# if ![string match "y" [lindex $expect_match 0 c]] exit
-#}
-
-set timeout 30
-set badhosts {}
-for {set i 0} {$i<$argc} {incr i} {
-
- set arg [lindex $argv $i]
- switch -- $arg \
- "-user" {
- incr i
- set user [lindex $argv $i]
- continue
- } "-prompt" {
- incr i
- set prompt [lindex $argv $i]
- continue
- } "-rlogin" {
- set login "rlogin"
- continue
- } "-telnet" {
- set login "telnet"
- continue
- } "-program" {
- incr i
- set program [lindex $argv $i]
- continue
- } "-timeout" {
- incr i
- set timeout [lindex $argv $i]
- continue
- }
-
- set host $arg
- if [string match $login "rlogin"] {
- set pid [spawn rlogin $host -l $user]
- } else {
- set pid [spawn telnet $host]
- expect -re "(login|Username):.*" {
- send "$user\r"
- }
- }
-
- if ![info exists prompt] {
- if [string match $user "root"] {
- set prompt "# "
- } else {
- set prompt "(%|\\\$) "
- }
- }
-
- set logged_in 0
- for {} 1 {} {
- expect "Password*" {
- send "$oldpassword\r"
- } eof {
- badhost $host "spawn failed"
- break
- } timeout {
- badhost $host "could not log in (or unrecognized prompt)"
- exec kill $pid
- expect eof
- break
- } -re "incorrect|invalid" {
- badhost $host "bad password or login"
- exec kill $pid
- expect eof
- break
- } -re $prompt {
- set logged_in 1
- break
- }
- }
-
- if (!$logged_in) {
- wait
- continue
- }
-
- send "$program\r"
- expect "Old password*" {
- send "$oldpassword\r"
- expect "Sorry*" {
- badhost $host "old password is bad?"
- continue
- } "password:"
- } -re "(n|N)ew password:"
- send "$newpassword\r"
- expect -re "not changed|unchanged" {
- badhost $host "new password is bad?"
- continue
- } -re "(password|Verification|Verify|again):.*"
- send "$newpassword\r"
- expect -re "(not changed|incorrect|choose new).*" {
- badhost $host "password is bad?"
- continue
- } -re "$prompt"
- send_user "\n"
-
- close
- wait
-}
-
-if [llength $badhosts] {send_user "\nfailed to set password on $badhosts\n"}
+++ /dev/null
-.TH PASSMASS 1 "7 October 1993"
-.SH NAME
-passmass \- change password on multiple machines
-.SH SYNOPSIS
-.B passmass
-[
-.I host1 host2 host3 ...
-]
-.SH INTRODUCTION
-.B Passmass
-changes a password on multiple machines. If you have accounts on
-several machines that do not share password databases, Passmass can
-help you keep them all in sync. This, in turn, will make it easier to
-change them more frequently.
-
-When Passmass runs, it asks you for the old and new passwords.
-(If you are changing root passwords and have equivalencing, the old
-password is not used and may be omitted.)
-
-Passmass understands the "usual" conventions. Additional arguments
-may be used for tuning. They affect all hosts which follow until
-another argument overrides it. For example, if you are known as
-"libes" on host1 and host2, but "don" on host3, you would say:
-
- passmass host1 host2 -user don host3
-
-Arguments are:
-.RS
-.TP 4
--user
-User whose password will be changed. By default, the current user is used.
-
-.TP 4
--rlogin
-Use rlogin to access host. (default)
-
-.TP 4
--telnet
-Use telnet to access host.
-
-.TP 4
--program
-Next argument is taken as program to run to set password.
-Default is "passwd". Other common choices are "yppasswd" and
-"set passwd" (e.g., VMS hosts).
-
-.TP 4
--prompt
-Next argument is taken as a prompt suffix pattern. This allows
-the script to know when the shell is prompting. The default is
-"# " for root and "% " for non-root accounts.
-
-.TP 4
--timeout
-Next argument is number of seconds to wait for responses.
-Default is 30 but some systems can be much slower logging in.
-
-.SH HOW TO USE
-The best way to run Passmass is to put the command in a one-line shell
-script or alias. Whenever you get a new account on a new machine, add
-the appropriate arguments to the command. Then run it whenever you
-want to change your passwords on all the hosts.
-
-.SH CAVEATS
-
-It should be obvious that using the same password on multiple hosts
-carries risks. In particular, if the password can be stolen, then all
-of your accounts are at risk. Thus, you should not use Passmass in
-situations where your password is visible, such as across a network
-where hackers are known to eavesdrop.
-
-On the other hand, if you have enough accounts with different
-passwords, you may end up writing them down somewhere - and
-.I that
-can be a security problem. Funny story: my college roommate had an
-11"x13" piece of paper on which he had listed accounts and passwords
-all across the Internet. This was several years worth of careful work
-and he carried it with him everywhere he went.
-Well one day, he forgot to remove it from his jeans, and we found a
-perfectly blank sheet of paper when we took out the wash the following
-day!
-.SH SEE ALSO
-.I
-"Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Programs"
-\fRby Don Libes,
-O'Reilly and Associates, January 1995.
-.SH AUTHOR
-Don Libes, National Institute of Standards and Technology
+++ /dev/null
-#!/depot/path/expect --
-
-# This is a CGI script to process requests created by the accompanying
-# passwd.html form. This script is pretty basic, although it is
-# reasonably robust. (Purposely intent users can make the script bomb
-# by mocking up their own HTML form, however they can't expose or steal
-# passwords or otherwise open any security holes.) This script doesn't
-# need any special permissions. The usual (ownership nobody) is fine.
-#
-# With a little more code, the script can do much more exotic things -
-# for example, you could have the script:
-#
-# - telnet to another host first (useful if you run CGI scripts on a
-# firewall), or
-#
-# - change passwords on multiple password server hosts, or
-#
-# - verify that passwords aren't in the dictionary, or
-#
-# - verify that passwords are at least 8 chars long and have at least 2
-# digits, 2 uppercase, 2 lowercase, or whatever restrictions you like,
-# or
-#
-# - allow short passwords by responding appropriately to passwd
-#
-# and so on. Have fun!
-#
-# Don Libes, NIST
-
-puts "Content-type: text/html\n" ;# note extra newline
-
-puts "
-<head>
-<title>Passwd Change Acknowledgment</title>
-</head>
-
-<h2>Passwd Change Acknowledgment</h2>
-"
-
-proc cgi2ascii {buf} {
- regsub -all {\+} $buf { } buf
- regsub -all {([\\["$])} $buf {\\\1} buf
- regsub -all -nocase "%0d%0a" $buf "\n" buf
- regsub -all -nocase {%([a-f0-9][a-f0-9])} $buf {[format %c 0x\1]} buf
- eval return \"$buf\"
-}
-
-foreach pair [split [read stdin $env(CONTENT_LENGTH)] &] {
- regexp (.*)=(.*) $pair dummy varname val
- set val [cgi2ascii $val]
- set var($varname) $val
-}
-
-log_user 0
-
-proc errormsg {s} {puts "<h3>Error: $s</h3>"}
-proc successmsg {s} {puts "<h3>$s</h3>"}
-
-# Need to su first to get around passwd's requirement that passwd cannot
-# be run by a totally unrelated user. Seems rather pointless since it's
-# so easy to satisfy, eh?
-
-# Change following line appropriately for your site.
-# (We use yppasswd, but you might use something else.)
-spawn /bin/su $var(name) -c "/bin/yppasswd $var(name)"
-# This fails on SunOS 4.1.3 (passwd says "you don't have a login name")
-# run on (or telnet first to) host running SunOS 4.1.4 or later.
-
-expect {
- "Unknown login:" {
- errormsg "unknown user: $var(name)"
- exit
- } default {
- errormsg "$expect_out(buffer)"
- exit
- } "Password:"
-}
-send "$var(old)\r"
-expect {
- "unknown user" {
- errormsg "unknown user: $var(name)"
- exit
- } "Sorry" {
- errormsg "Old password incorrect"
- exit
- } default {
- errormsg "$expect_out(buffer)"
- exit
- } "Old password:"
-}
-send "$var(old)\r"
-expect "New password:"
-send "$var(new1)\r"
-expect "New password:"
-send "$var(new2)\r"
-expect -re (.*)\r\n {
- set error $expect_out(1,string)
-}
-
-if [info exists error] {
- errormsg "$error"
-} else {
- successmsg "Password changed successfully."
-}
-
+++ /dev/null
-<HTML>
-<head>
-<title>Change your login password</title>
-</head>
-<body>
-
-This HTML creates a form for letting users change login passwords with
-a browser. To actually use this form, install the corresponding
-accompanying cgi script and then modify the action value to identify
-where you put the cgi script. (Also read the comments at the
-beginning of the CGI script.) - Don Libes
-<hr>
-
-<form method=post
-action="http://www-i.cme.nist.gov/cgi-bin/expect/passwd.cgi">
-<h2>Change your login password</h2>
-<br>Username: <input name="name">
-<br>Old password: <input type=password name="old">
-<br>New password: <input type=password name="new1">
-<br>New password: <input type=password name="new2">
-<br>New password must be entered twice to avoid typos.
-<br><input type=submit value="Change password">
-</form>
-</body>
-</html>
+++ /dev/null
-#!../expect --
-
-# read a single character
-# Author: Don Libes, NIST
-
-stty raw
-expect ?
-send_user $expect_out(buffer)
+++ /dev/null
-#!/depot/path/expect --
-
-# Name: reprompt
-# Description: reprompt every so often until user enters something
-# Usage: reprompt timeout prompt
-# Author: Don Libes, NIST
-
-foreach {timeout prompt} $argv {}
-
-send_error $prompt
-expect {
- timeout {
- send_error "\nwake up!!\a"
- send_error \n$prompt
- exp_continue
- }
- -re .+ {
- send_user $expect_out(buffer)
- }
-}
+++ /dev/null
-#!../expect -f
-# rftp - ftp a directory hierarchy (i.e. recursive ftp)
-# Version 2.10
-# Don Libes, NIST
-exp_version -exit 5.0
-
-# rftp is much like ftp except that the command ~g copies everything in
-# the remote current working directory to the local current working
-# directory. Similarly ~p copies in the reverse direction. ~l just
-# lists the remote directories.
-
-# rftp takes an argument of the host to ftp to. Username and password
-# are prompted for. Other ftp options can be set interactively at that
-# time. If your local ftp understands .netrc, that is also used.
-
-# ~/.rftprc is sourced after the user has logged in to the remote site
-# and other ftp commands may be sent at that time. .rftprc may also be
-# used to override the following rftp defaults. The lines should use
-# the same syntax as these:
-
-set file_timeout 3600 ;# timeout (seconds) for retrieving files
-set timeout 1000000 ;# timeout (seconds) for other ftp dialogue
-set default_type binary ;# default type, i.e., ascii, binary, tenex
-set binary {} ;# files matching are transferred as binary
-set ascii {} ;# as above, but as ascii
-set tenex {} ;# as above, but as tenex
-
-# The values of binary, ascii and tenex should be a list of (Tcl) regular
-# expressions. For example, the following definitions would force files
-# ending in *.Z and *.tar to be transferred as binaries and everything else
-# as text.
-
-# set default_type ascii
-# set binary {*.Z *.tar}
-
-# If you are on a UNIX machine, you can probably safely ignore all of this
-# and transfer everything as "binary".
-
-# The current implementation requires that the source host be able to
-# provide directory listings in UNIX format. Hence, you cannot copy
-# from a VMS host (although you can copy to it). In fact, there is no
-# standard for the output that ftp produces, and thus, ftps that differ
-# significantly from the ubiquitous UNIX implementation may not work
-# with rftp (at least, not without changing the scanning and parsing).
-
-####################end of documentation###############################
-
-match_max -d 100000 ;# max size of a directory listing
-
-# return name of file from one line of directory listing
-proc getname {line} {
- # if it's a symbolic link, return local name
- set i [lsearch $line "->"]
- if {-1==$i} {
- # not a sym link, return last token of line as name
- return [lindex $line [expr [llength $line]-1]]
- } else {
- # sym link, return "a" of "a -> b"
- return [lindex $line [expr $i-1]]
- }
-}
-
-proc putfile {name} {
- global current_type default_type
- global binary ascii tenex
- global file_timeout
-
- switch -- $name $binary {set new_type binary} \
- $ascii {set new_type ascii} \
- $tenex {set new_type tenex} \
- default {set new_type $default_type}
-
- if {$current_type != $new_type} {
- settype $new_type
- }
-
- set timeout $file_timeout
- send "put $name\r"
- expect timeout {
- send_user "ftp timed out in response to \"put $name\"\n"
- exit
- } "ftp>*"
-}
-
-proc getfile {name} {
- global current_type default_type
- global binary ascii tenex
- global file_timeout
-
- switch -- $name $binary {set new_type binary} \
- $ascii {set new_type ascii} \
- $tenex {set new_type tenex} \
- default {set new_type $default_type}
-
- if {$current_type != $new_type} {
- settype $new_type
- }
-
- set timeout $file_timeout
- send "get $name\r"
- expect timeout {
- send_user "ftp timed out in response to \"get $name\"\n"
- exit
- } "ftp>*"
-}
-
-# returns 1 if successful, 0 otherwise
-proc putdirectory {name} {
- send "mkdir $name\r"
- expect "550*denied*ftp>*" {
- send_user "failed to make remote directory $name\n"
- return 0
- } timeout {
- send_user "timed out on make remote directory $name\n"
- return 0
- } -re "(257|550.*exists).*ftp>.*"
- # 550 is returned if directory already exists
-
- send "cd $name\r"
- expect "550*ftp>*" {
- send_user "failed to cd to remote directory $name\n"
- return 0
- } timeout {
- send_user "timed out on cd to remote directory $name\n"
- return 0
- } -re "2(5|0)0.*ftp>.*"
- # some ftp's return 200, some return 250
-
- send "lcd $name\r"
- # hard to know what to look for, since my ftp doesn't return status
- # codes. It is evidentally very locale-dependent.
- # So, assume success.
- expect "ftp>*"
- putcurdirectory
- send "lcd ..\r"
- expect "ftp>*"
- send "cd ..\r"
- expect timeout {
- send_user "failed to cd to remote directory ..\n"
- return 0
- } -re "2(5|0)0.*ftp>.*"
-
- return 1
-}
-
-# returns 1 if successful, 0 otherwise
-proc getdirectory {name transfer} {
- send "cd $name\r"
- # this can fail normally if it's a symbolic link, and we are just
- # experimenting
- expect "550*ftp>*" {
- send_user "failed to cd to remote directory $name\n"
- return 0
- } timeout {
- send_user "timed out on cd to remote directory $name\n"
- return 0
- } -re "2(5|0)0.*ftp>.*"
- # some ftp's return 200, some return 250
-
- if $transfer {
- send "!mkdir $name\r"
- expect "denied*" return timeout return "ftp>"
- send "lcd $name\r"
- # hard to know what to look for, since my ftp doesn't return
- # status codes. It is evidentally very locale-dependent.
- # So, assume success.
- expect "ftp>*"
- }
- getcurdirectory $transfer
- if $transfer {
- send "lcd ..\r"
- expect "ftp>*"
- }
- send "cd ..\r"
- expect timeout {
- send_user "failed to cd to remote directory ..\n"
- return 0
- } -re "2(5|0)0.*ftp>.*"
-
- return 1
-}
-
-proc putentry {name type} {
- switch -- $type \
- d {
- # directory
- if {$name=="." || $name==".."} return
- putdirectory $name
- } - {
- # file
- putfile $name
- } l {
- # symlink, could be either file or directory
- # first assume it's a directory
- if [putdirectory $name] return
- putfile $name
- } default {
- send_user "can't figure out what $name is, skipping\n"
- }
-}
-
-proc getentry {name type transfer} {
- switch -- $type \
- d {
- # directory
- getdirectory $name $transfer
- } - {
- # file
- if !$transfer return
- getfile $name
- } l {
- # symlink, could be either file or directory
- # first assume it's a directory
- if [getdirectory $name $transfer] return
- if !$transfer return
- getfile $name
- } default {
- send_user "can't figure out what $name is, skipping\n"
- }
-}
-
-proc putcurdirectory {} {
- send "!/bin/ls -alg\r"
- expect timeout {
- send_user "failed to get directory listing\n"
- return
- } "ftp>*"
-
- set buf $expect_out(buffer)
-
- for {} 1 {} {
- # if end of listing, succeeded!
- if 0==[regexp "(\[^\n]*)\n(.*)" $buf dummy line buf] return
-
- set token [lindex $line 0]
- switch -- $token \
- !/bin/ls {
- # original command
- } total {
- # directory header
- } . {
- # unreadable
- } default {
- # either file or directory
- set name [getname $line]
- set type [string index $line 0]
- putentry $name $type
- }
- }
-}
-
-
-# look at result of "dir". If transfer==1, get all files and directories
-proc getcurdirectory {transfer} {
- send "dir\r"
- expect timeout {
- send_user "failed to get directory listing\n"
- return
- } "ftp>*"
-
- set buf $expect_out(buffer)
-
- for {} 1 {} {
- regexp "(\[^\n]*)\n(.*)" $buf dummy line buf
-
- set token [lindex $line 0]
- switch -- $token \
- dir {
- # original command
- } 200 {
- # command successful
- } 150 {
- # opening data connection
- } total {
- # directory header
- } 226 {
- # transfer complete, succeeded!
- return
- } ftp>* {
- # next prompt, failed!
- return
- } . {
- # unreadable
- } default {
- # either file or directory
- set name [getname $line]
- set type [string index $line 0]
- getentry $name $type $transfer
- }
- }
-}
-
-proc settype {t} {
- global current_type
-
- send "type $t\r"
- set current_type $t
- expect "200*ftp>*"
-}
-
-proc final_msg {} {
- # write over the previous prompt with our message
- send_user "\rQuit ftp or cd to another directory and press ~g, ~p, or ~l\n"
- # and then reprompt
- send_user "ftp> "
-}
-
-if [file readable ~/.rftprc] {source ~/.rftprc}
-set first_time 1
-
-if $argc>1 {
- send_user "usage: rftp [host]
- exit
-}
-
-send_user "Once logged in, cd to the directory to be transferred and press:\n"
-send_user "~p to put the current directory from the local to the remote host\n"
-send_user "~g to get the current directory from the remote host to the local host\n"
-send_user "~l to list the current directory from the remote host\n"
-
-if $argc==0 {spawn ftp} else {spawn ftp $argv}
-interact -echo ~g {
- if $first_time {
- set first_time 0
- settype $default_type
- }
- getcurdirectory 1
- final_msg
-} -echo ~p {
- if $first_time {
- set first_time 0
- settype $default_type
- }
- putcurdirectory
- final_msg
-} -echo ~l {
- getcurdirectory 0
- final_msg
-}
+++ /dev/null
-#!../expect --
-# rlogin-cwd - rlogin but with same directory
-#
-# You can extend this idea to save any arbitrary information across rlogin
-# Don Libes - Oct 17, 1991.
-
-set prompt "(%|#|\\$) $" ;# default prompt
-catch {set prompt $env(EXPECT_PROMPT)}
-
-eval spawn rlogin $argv
-set timeout 60
-expect eof exit timeout {send_user "timed out\n"; exit} -re $prompt
-send "cd [pwd]\r"
-interact
+++ /dev/null
-#!/depot/path/expect --
-# rlogin.exp - rlogin but with current DISPLAY
-#
-# You can extend this idea to save any arbitrary information across rlogin
-# Don Libes - Oct 17, 1991.
-
-set prompt "(%|#|\\$) $" ;# default prompt
-catch {set prompt $env(EXPECT_PROMPT)}
-
-eval spawn rlogin $argv
-set timeout 60
-expect eof exit timeout {send_user "timed out\n"; exit} -re $prompt
-if [string match "unix:0.0" $env(DISPLAY)] {
- send "setenv DISPLAY [exec hostname].[exec domainname]:0.0\r"
-} else {
- send "setenv DISPLAY $env(DISPLAY)\r"
-}
-interact
+++ /dev/null
-#!../expect -f
-# Synopsis
-# robohunt player-name [-nodisplay]
-
-# Plays hunt automatically. Optional "-nodisplay" argument disables output.
-
-# by Don Libes
-
-expect_version -exit 5.0
-
-set timeout 1
-
-proc random {} {
- global ia ic im jran
-
- set jran [expr ($jran*$ia + $ic) % $im]
- return $jran
-}
-
-set ia 7141
-set ic 54773
-set im 259200
-set jran [pid]
-
-# given a direction and number, moves that many spaces in that direction
-proc mv {dir num} {
- # first try firing a bullet (what the hell...open some walls to move!)
- send "f"
- for {set i 0} {$i<$num} {incr i} {
- send $dir
- }
-}
-
-# move a random distance/direction
-
-# 31 is arbitrarily used as a max distance to move in any one direction
-# this is a compromise between long horizontal and vertical moves
-# but since excess movement is good for stabbing, this is reasonable
-proc move {} {
- set num [random]
- set mask [expr $num&3]
- set num [expr $num&31]
- if $mask==0 {send "H"; mv "h" $num; return}
- if $mask==1 {send "L"; mv "l" $num; return}
- if $mask==2 {send "K"; mv "k" $num; return}
- send "J"; mv "j" $num; return
-}
-
-if 2==$argc { set output 0 } {set output 1}
-if 1>$argc { send_user "usage: robohunt name \[-nodisplay\]\n"; exit}
-spawn hunt -b -c -n [lindex $argv 0]
-expect "team"
-send "\r"
-
-set several_moves 5
-
-expect "Monitor:"
-sleep 1
-expect ;# flush output
-log_user 0
-# output is turned off so that we can first strip out ^Gs before they
-# are sent to the tty. It seems to drive xterms crazy - because our
-# rather stupid algorithm off not checking after every move can cause
-# the game to send a lot of them.
-
-for {} 1 {} {
- # make several moves at a time, before checking to see if we are dead
- # this is a compromise between just ignoring our status after each move
- # and looking at our status after each move
- for {set j $several_moves} {$j} {incr j -1} {
- move
- }
-
- expect {
- -re ^\007+ {exp_continue}
- -re "\\? " {send y}
- -re .+
- }
- if $output {send_user -raw $expect_out(buffer)}
-}
+++ /dev/null
-#!../expect -f
-# Look for a GREAT game of rogue.
-# Idea is that any game with a Strength of 18 is unusually good.
-# Written by Don Libes - March, 1990
-
-set timeout -1
-while {1} {
- spawn rogue
- expect "Str: 18" break \
- "Str: 16"
- send "Q"
- expect "quit?"
- send "y"
- close
- wait
-}
-interact
+++ /dev/null
-#!../expect --
-# telnet-cwd - telnet but with same directory
-#
-# You can extend this idea to save any arbitrary information across telnet
-# Don Libes - Oct 17, 1991.
-
-set prompt "(%|#|\\$) $" ;# default prompt
-catch {set prompt $env(EXPECT_PROMPT)}
-
-eval spawn telnet $argv
-interact -o -nobuffer -re $prompt return
-send "cd [pwd]\r"
-interact
+++ /dev/null
-# Start telnet and when you press ^Z, put telnet in background and save any
-# remaining output in "telnet.log". You can actually apply this technique
-# to any interactive program - I just chose telnet here.
-
-# Author: Don Libes, NIST, 1/5/95
-
-spawn -ignore HUP telnet $argv ;# start telnet
-interact \032 return ;# interact until ^Z
-
-if [fork] exit ;# disconnect from terminal
-disconnect
-
-set log [open logfile w] ;# open logfile
-expect -re .+ { ;# and record everything to it
- puts -nonewline $log $expect_out(buffer)
- exp_continue
-}
-
+++ /dev/null
-#!/usr/local/bin/expectk --
-
-# Name: tkterm - terminal emulator using Expect and Tk text widget, v1.0
-# Author: Don Libes, July '94
-
-# This is primarily for regression testing character-graphic applications.
-# You can certainly use it as a terminal emulator - however many features
-# in a real terminal emulator are not supported (although I'll probably
-# add some of them later).
-
-###############################
-# Quick overview of this emulator
-###############################
-# Very good attributes:
-# Understands both termcap and terminfo
-# Understands meta-key (zsh, emacs, etc work)
-# Is fast
-# Understands X selections
-# Looks best with fixed-width font but doesn't require it
-# Good-enough-for-starters attributes:
-# Understands one kind of standout mode (reverse video)
-# Should-be-fixed-soon attributes:
-# Does not support scrollbar or resize
-# Probably-wont-be-fixed-soon attributes:
-# Assumes only one terminal exists
-
-###############################################
-# To try out this package, just run it. Using it in
-# your scripts is simple. Here are directions:
-###############################################
-# 0) make sure Expect is linked into your Tk-based program (or vice versa)
-# 1) modify the variables/procedures below these comments appropriately
-# 2) source this file
-# 3) pack the text widget ($term) if you have so configured it (see
-# "term_alone" below). As distributed, it packs into . automatically.
-
-#############################################
-# Variables that must be initialized before using this:
-#############################################
-set rows 24 ;# number of rows in term
-set cols 80 ;# number of columns in term
-set term .t ;# name of text widget used by term
-set term_alone 1 ;# if 1, directly pack term into .
- ;# else you must pack
-set termcap 1 ;# if your applications use termcap
-set terminfo 1 ;# if your applications use terminfo
- ;# (you can use both, but note that
- ;# starting terminfo is slow)
-set term_shell $env(SHELL) ;# program to run in term
-
-#############################################
-# Readable variables of interest
-#############################################
-# cur_row ;# current row where insert marker is
-# cur_col ;# current col where insert marker is
-# term_spawn_id ;# spawn id of term
-
-#############################################
-# Procs you may want to initialize before using this:
-#############################################
-
-# term_exit is called if the spawned process exits
-proc term_exit {} {
- exit
-}
-
-# term_chars_changed is called after every change to the displayed chars
-# You can use if you want matches to occur in the background (a la bind)
-# If you want to test synchronously, then just do so - you don't need to
-# redefine this procedure.
-proc term_chars_changed {} {
-}
-
-# term_cursor_changed is called after the cursor is moved
-proc term_cursor_changed {} {
-}
-
-# Example tests you can make
-#
-# Test if cursor is at some specific location
-# if {$cur_row == 1 && $cur_col == 0} ...
-#
-# Test if "foo" exists anywhere in line 4
-# if {[string match *foo* [$term get 4.0 4.end]]}
-#
-# Test if "foo" exists at line 4 col 7
-# if {[string match foo* [$term get 4.7 4.end]]}
-#
-# Test if a specific character at row 4 col 5 is in standout
-# if {-1 != [lsearch [$term tag names 4.5] standout]} ...
-#
-# Return contents of screen
-# $term get 1.0 end
-#
-# Return indices of first string on lines 4 to 6 that is in standout mode
-# $term tag nextrange standout 4.0 6.end
-#
-# Replace all occurrences of "foo" with "bar" on screen
-# for {set i 1} {$i<=$rows} {incr i} {
-# regsub -all "foo" [$term get $i.0 $i.end] "bar" x
-# $term delete $i.0 $i.end
-# $term insert $i.0 $x
-# }
-
-#############################################
-# End of things of interest
-#############################################
-
-
-unset env(DISPLAY)
-set env(LINES) $rows
-set env(COLUMNS) $cols
-
-set env(TERM) "tt"
-if $termcap {
- set env(TERMCAP) {tt:
- :cm=\E[%d;%dH:
- :up=\E[A:
- :nd=\E[C:
- :cl=\E[H\E[J:
- :do=^J:
- :so=\E[7m:
- :se=\E[m:
- :k1=\EOP:
- :k2=\EOQ:
- :k3=\EOR:
- :k4=\EOS:
- :k5=\EOT:
- :k6=\EOU:
- :k7=\EOV:
- :k8=\EOW:
- :k9=\EOX:
- }
-}
-
-if $terminfo {
- set env(TERMINFO) /tmp
- set ttsrc "/tmp/tt.src"
- set file [open $ttsrc w]
-
- puts $file {tt|textterm|Don Libes' tk text widget terminal emulator,
- cup=\E[%p1%d;%p2%dH,
- cuu1=\E[A,
- cuf1=\E[C,
- clear=\E[H\E[J,
- ind=\n,
- cr=\r,
- smso=\E[7m,
- rmso=\E[m,
- kf1=\EOP,
- kf2=\EOQ,
- kf3=\EOR,
- kf4=\EOS,
- kf5=\EOT,
- kf6=\EOU,
- kf7=\EOV,
- kf8=\EOW,
- kf9=\EOX,
- }
- close $file
-
- set oldpath $env(PATH)
- set env(PATH) "/usr/5bin:/usr/lib/terminfo"
- if 1==[catch {exec tic $ttsrc} msg] {
- puts "WARNING: tic failed - if you don't have terminfo support on"
- puts "your system, change \"set terminfo 1\" to \"set terminfo 0\"."
- puts "Here is the original error from running tic:"
- puts $msg
- }
- set env(PATH) $oldpath
-
- exec rm $ttsrc
-}
-
-set term_standout 0 ;# if in standout mode or not
-
-log_user 0
-
-# start a shell and text widget for its output
-set stty_init "-tabs"
-eval spawn $term_shell
-stty rows $rows columns $cols < $spawn_out(slave,name)
-set term_spawn_id $spawn_id
-
-# this shouldn't be needed if Ousterhout fixes text bug
-text $term -relief sunken -bd 1 -width $cols -height $rows -wrap none
-
-if {$term_alone} {
- pack $term
-}
-
-$term tag configure standout -background black -foreground white
-
-proc term_clear {} {
- global term
-
- $term delete 1.0 end
- term_init
-}
-
-proc term_init {} {
- global rows cols cur_row cur_col term
-
- # initialize it with blanks to make insertions later more easily
- set blankline [format %*s $cols ""]\n
- for {set i 1} {$i <= $rows} {incr i} {
- $term insert $i.0 $blankline
- }
-
- set cur_row 1
- set cur_col 0
-
- $term mark set insert $cur_row.$cur_col
-}
-
-proc term_down {} {
- global cur_row rows cols term
-
- if {$cur_row < $rows} {
- incr cur_row
- } else {
- # already at last line of term, so scroll screen up
- $term delete 1.0 "1.end + 1 chars"
-
- # recreate line at end
- $term insert end [format %*s $cols ""]\n
- }
-}
-
-proc term_insert {s} {
- global cols cur_col cur_row
- global term term_standout
-
- set chars_rem_to_write [string length $s]
- set space_rem_on_line [expr $cols - $cur_col]
-
- if {$term_standout} {
- set tag_action "add"
- } else {
- set tag_action "remove"
- }
-
- ##################
- # write first line
- ##################
-
- if {$chars_rem_to_write > $space_rem_on_line} {
- set chars_to_write $space_rem_on_line
- set newline 1
- } else {
- set chars_to_write $chars_rem_to_write
- set newline 0
- }
-
- $term delete $cur_row.$cur_col $cur_row.[expr $cur_col + $chars_to_write]
- $term insert $cur_row.$cur_col [
- string range $s 0 [expr $space_rem_on_line-1]
- ]
-
- $term tag $tag_action standout $cur_row.$cur_col $cur_row.[expr $cur_col + $chars_to_write]
-
- # discard first line already written
- incr chars_rem_to_write -$chars_to_write
- set s [string range $s $chars_to_write end]
-
- # update cur_col
- incr cur_col $chars_to_write
- # update cur_row
- if $newline {
- term_down
- }
-
- ##################
- # write full lines
- ##################
- while {$chars_rem_to_write >= $cols} {
- $term delete $cur_row.0 $cur_row.end
- $term insert $cur_row.0 [string range $s 0 [expr $cols-1]]
- $term tag $tag_action standout $cur_row.0 $cur_row.end
-
- # discard line from buffer
- set s [string range $s $cols end]
- incr chars_rem_to_write -$cols
-
- set cur_col 0
- term_down
- }
-
- #################
- # write last line
- #################
-
- if {$chars_rem_to_write} {
- $term delete $cur_row.0 $cur_row.$chars_rem_to_write
- $term insert $cur_row.0 $s
- $term tag $tag_action standout $cur_row.0 $cur_row.$chars_rem_to_write
-
- set cur_col $chars_rem_to_write
- }
-
- term_chars_changed
-}
-
-proc term_update_cursor {} {
- global cur_row cur_col term
-
- $term mark set insert $cur_row.$cur_col
-
- term_cursor_changed
-}
-
-term_init
-
-expect_background {
- -i $term_spawn_id
- -re "^\[^\x01-\x1f]+" {
- # Text
- term_insert $expect_out(0,string)
- term_update_cursor
- } "^\r" {
- # (cr,) Go to beginning of line
- set cur_col 0
- term_update_cursor
- } "^\n" {
- # (ind,do) Move cursor down one line
- term_down
- term_update_cursor
- } "^\b" {
- # Backspace nondestructively
- incr cur_col -1
- term_update_cursor
- } "^\a" {
- bell
- } "^\t" {
- # Tab, shouldn't happen
- send_error "got a tab!?"
- } eof {
- term_exit
- } "^\x1b\\\[A" {
- # (cuu1,up) Move cursor up one line
- incr cur_row -1
- term_update_cursor
- } "^\x1b\\\[C" {
- # (cuf1,nd) Non-destructive space
- incr cur_col
- term_update_cursor
- } -re "^\x1b\\\[(\[0-9]*);(\[0-9]*)H" {
- # (cup,cm) Move to row y col x
- set cur_row [expr $expect_out(1,string)+1]
- set cur_col $expect_out(2,string)
- term_update_cursor
- } "^\x1b\\\[H\x1b\\\[J" {
- # (clear,cl) Clear screen
- term_clear
- term_update_cursor
- } "^\x1b\\\[7m" {
- # (smso,so) Begin standout mode
- set term_standout 1
- } "^\x1b\\\[m" {
- # (rmso,se) End standout mode
- set term_standout 0
- }
-}
-
-bind $term <Any-Enter> {
- focus %W
-}
-bind $term <Meta-KeyPress> {
- if {"%A" != ""} {
- exp_send -i $term_spawn_id "\033%A"
- }
-}
-bind $term <KeyPress> {
- exp_send -i $term_spawn_id -- %A
- break
-}
-
-bind $term <Control-space> {exp_send -null}
-bind $term <Control-at> {exp_send -null}
-
-bind $term <F1> {exp_send -i $term_spawn_id "\033OP"}
-bind $term <F2> {exp_send -i $term_spawn_id "\033OQ"}
-bind $term <F3> {exp_send -i $term_spawn_id "\033OR"}
-bind $term <F4> {exp_send -i $term_spawn_id "\033OS"}
-bind $term <F5> {exp_send -i $term_spawn_id "\033OT"}
-bind $term <F6> {exp_send -i $term_spawn_id "\033OU"}
-bind $term <F7> {exp_send -i $term_spawn_id "\033OV"}
-bind $term <F8> {exp_send -i $term_spawn_id "\033OW"}
-bind $term <F9> {exp_send -i $term_spawn_id "\033OX"}
-
-set term_counter 0
-proc term_expect {args} {
- upvar timeout localTimeout
- upvar #0 timeout globalTimeout
- set timeout 10
- catch {set timeout $globalTimeout}
- catch {set timeout $localTimeout}
-
- global term_counter
- incr term_counter
- global [set strobe _data_[set term_counter]]
- global [set tstrobe _timer_[set term_counter]]
-
- proc term_chars_changed {} "uplevel #0 set $strobe 1"
-
- set $strobe 1
- set $tstrobe 0
-
- if {$timeout >= 0} {
- set mstimeout [expr 1000*$timeout]
- after $mstimeout "set $strobe 1; set $tstrobe 1"
- set timeout_act {}
- }
-
- set argc [llength $args]
- if {$argc%2 == 1} {
- lappend args {}
- incr argc
- }
-
- for {set i 0} {$i<$argc} {incr i 2} {
- set act_index [expr $i+1]
- if {[string compare timeout [lindex $args $i]] == 0} {
- set timeout_act [lindex $args $act_index]
- set args [lreplace $args $i $act_index]
- incr argc -2
- break
- }
- }
-
- while {![info exists act]} {
- if {![set $strobe]} {
- tkwait var $strobe
- }
- set $strobe 0
-
- if {[set $tstrobe]} {
- set act $timeout_act
- } else {
- for {set i 0} {$i<$argc} {incr i 2} {
- if {[uplevel [lindex $args $i]]} {
- set act [lindex $args [incr i]]
- break
- }
- }
- }
- }
-
- proc term_chars_changed {} {}
-
- if {$timeout >= 0} {
- after $mstimeout unset $strobe $tstrobe
- } else {
- unset $strobe $tstrobe
- }
-
- set code [catch {uplevel $act} string]
- if {$code > 4} {return -code $code $string}
- if {$code == 4} {return -code continue}
- if {$code == 3} {return -code break}
- if {$code == 2} {return -code return}
- if {$code == 1} {return -code error -errorinfo $errorInfo \
- -errorcode $errorCode $string}
- return $string
-}
-
-##################################################
-# user-supplied code goes below here
-##################################################
-
-set timeout 200
-
-# for example, wait for a shell prompt
-term_expect {regexp "%" [$term get 1.0 3.end]}
-
-# invoke game of rogue
-exp_send "myrogue\r"
-
-# wait for strength of 18
-term_expect \
- {regexp "Str: 18" [$term get 24.0 24.end]} {
- # do something
- } {timeout} {
- puts "ulp...timed out!"
- } {regexp "Str: 16" [$term get 24.0 24.end]}
-
-# and so on...
-
+++ /dev/null
-#!../expect -f
-# read a complete line from stdin
-# aborting after the number of seconds (given as an argument)
-# - Don Libes
-set timeout $argv
-expect -re \n {send_user $expect_out(buffer)}
+++ /dev/null
-#!../expect -f
-# run a program for a given amount of time
-# i.e. time 20 long_running_program
-
-set timeout [lindex $argv 0]
-eval spawn [lrange $argv 1 end]
-expect
+++ /dev/null
-#!../expectk -f
-
-# Name: tknewsbiff
-# Author: Don Libes
-# Version: 1.2b
-# Written: January 1, 1994
-
-# Description: When unread news appears in your favorite groups, pop up
-# a little window describing which newsgroups and how many articles.
-# Go away when articles are no longer unread.
-# Optionally, run a UNIX program (to play a sound, read news, etc.)
-
-# Default config file in ~/.tknewsbiff[-host]
-
-# These two procedures are needed because Tk provides no command to undo
-# the "wm unmap" command. You must remember whether it was iconic or not.
-# PUBLIC
-proc unmapwindow {} {
- global _window_open
-
- switch [wm state .] \
- iconic {
- set _window_open 0
- } normal {
- set _window_open 1
- }
- wm withdraw .
-}
-unmapwindow
-# window state starts out as "iconic" before it is mapped, Tk bug?
-# make sure that when we map it, it will be open (i.e., "normal")
-set _window_open 1
-
-# PUBLIC
-proc mapwindow {} {
- global _window_open
-
- if $_window_open {
- wm deiconify .
- } else {
- wm iconify .
- }
-}
-
-proc _abort {msg} {
- global argv0
-
- puts "$argv0: $msg"
- exit 1
-}
-
-if [info exists env(DOTDIR)] {
- set home $env(DOTDIR)
-} else {
- set home [glob ~]
-}
-
-set delay 60
-set width 27
-set height 10
-set _default_config_file $home/.tknewsbiff
-set _config_file $_default_config_file
-set _default_server news
-set server $_default_server
-set server_timeout 60
-
-log_user 0
-
-listbox .list -yscroll ".scrollbar set" -font "*-m-*" -setgrid 1
-scrollbar .scrollbar -command ".list yview" -relief raised
-.list config -highlightthickness 0 -border 0
-.scrollbar config -highlightthickness 0
-pack .scrollbar -side left -fill y
-pack .list -side left -fill both -expand 1
-
-while {[llength $argv]>0} {
- set arg [lindex $argv 0]
-
- if [file readable $arg] {
- if 0==[string compare active [file tail $arg]] {
- set active_file $arg
- set argv [lrange $argv 1 end]
- } else {
- # must be a config file
- set _config_file $arg
- set argv [lrange $argv 1 end]
- }
- } elseif {[file readable $_config_file-$arg]} {
- # maybe it's a hostname suffix for a newsrc file?
- set _config_file $_default_config_file-$arg
- set argv [lrange $argv 1 end]
- } else {
- # maybe it's just a hostname for regular newsrc file?
- set server $arg
- set argv [lrange $argv 1 end]
- }
-}
-
-proc _read_config_file {} {
- global _config_file argv0 watch_list ignore_list
-
- # remove previous user-provided proc in case user simply
- # deleted it from config file
- proc user {} {}
-
- set watch_list {}
- set ignore_list {}
-
- if [file exists $_config_file] {
- # uplevel allows user to set global variables
- if [catch {uplevel source $_config_file} msg] {
- _abort "error reading $_config_file\n$msg"
- }
- }
-
- if [llength $watch_list]==0 {
- watch *
- }
-}
-
-# PUBLIC
-proc watch {args} {
- global watch_list
-
- lappend watch_list $args
-}
-
-# PUBLIC
-proc ignore {ng} {
- global ignore_list
-
- lappend ignore_list $ng
-}
-
-# get time and server
-_read_config_file
-
-# if user didn't set newsrc, try ~/.newsrc-server convention.
-# if that fails, fall back to just plain ~/.newsrc
-if ![info exists newsrc] {
- set newsrc $home/.newsrc-$server
- if ![file readable $newsrc] {
- set newsrc $home/.newsrc
- if ![file readable $newsrc] {
- _abort "cannot tell what newgroups you read
-found neither $home/.newsrc-$server nor $home/.newsrc"
- }
- }
-}
-
-# PRIVATE
-proc _read_newsrc {} {
- global db newsrc
-
- if [catch {set file [open $newsrc]} msg] {
- _abort $msg
- }
- while {-1 != [gets $file buf]} {
- if [regexp "!" $buf] continue
- if [regexp "(\[^:]*):.*\[-, ](\[0-9]+)" $buf dummy ng seen] {
- set db($ng,seen) $seen
- }
- # only way 2nd regexp can fail is on lines
- # that have a : but no number
- }
- close $file
-}
-
-proc _unknown_host {} {
- global server _default_server
-
- if 0==[string compare $_default_server $server] {
- puts "tknewsbiff: default server <$server> is not known"
- } else {
- puts "tknewsbiff: server <$server> is not known"
- }
-
- puts "Give tknewsbiff an argument - either the name of your news server
-or active file. I.e.,
-
- tknewsbiff news.nist.gov
- tknewsbiff /usr/news/lib/active
-
-If you have a correctly defined configuration file (.tknewsbiff),
-an argument is not required. See the man page for more info."
- exit 1
-}
-
-# read active file
-# PRIVATE
-proc _read_active {} {
- global db server active_list active_file
- upvar #0 server_timeout timeout
-
- set active_list {}
-
- if [info exists active_file] {
- spawn -open [open $active_file]
- } else {
- spawn telnet $server nntp
- expect {
- "20*\n" {
- # should get 200 or 201
- } "NNTP server*\n" {
- puts "tknewsbiff: unexpected response from server:"
- puts "$expect_out(buffer)"
- return 1
- } "unknown host" {
- _unknown_host
- } timeout {
- close
- wait
- return 1
- } eof {
- # loadav too high probably
- wait
- return 1
- }
- }
- exp_send "list\r"
- expect "list\r\n" ;# ignore echo of "list" command
- expect -re "215\[^\n]*\n" ;# skip "Newsgroups in form" line
- }
-
- expect {
- -re "(\[^ ]*) 0*(\[^ ]+) \[^\n]*\n" {
- set ng $expect_out(1,string)
- set hi $expect_out(2,string)
- lappend active_list $ng
- set db($ng,hi) $hi
- exp_continue
- }
- ".\r\n" close
- ".\r\r\n" close
- timeout close
- eof
- }
-
- wait
- return 0
-}
-
-# test in various ways for good newsgroups
-# return 1 if good, 0 if not good
-# PRIVATE
-proc _isgood {ng threshold} {
- global db seen_list ignore_list
-
- # skip if we don't subscribe to it
- if ![info exists db($ng,seen)] {return 0}
-
- # skip if the threshold isn't exceeded
- if {$db($ng,hi) - $db($ng,seen) < $threshold} {return 0}
-
- # skip if it matches an ignore command
- foreach igpat $ignore_list {
- if [string match $igpat $ng] {return 0}
- }
-
- # skip if we've seen it before
- if [lsearch -exact $seen_list $ng]!=-1 {return 0}
-
- # passed all tests, so remember that we've seen it
- lappend seen_list $ng
- return 1
-}
-
-# return 1 if not seen on previous turn
-# PRIVATE
-proc _isnew {ng} {
- global previous_seen_list
-
- if [lsearch -exact $previous_seen_list $ng]==-1 {
- return 1
- } else {
- return 0
- }
-}
-
-# schedule display of newsgroup in global variable "newsgroup"
-# PUBLIC
-proc display {} {
- global display_list newsgroup
-
- lappend display_list $newsgroup
-}
-
-# PRIVATE
-proc _update_ngs {} {
- global watch_list active_list newsgroup
-
- foreach watch $watch_list {
- set threshold 1
- set display display
- set new {}
-
- set ngpat [lindex $watch 0]
- set watch [lrange $watch 1 end]
-
- while {[llength $watch] > 0} {
- switch -- [lindex $watch 0] \
- -threshold {
- set threshold [lindex $watch 1]
- set watch [lrange $watch 2 end]
- } -display {
- set display [lindex $watch 1]
- set watch [lrange $watch 2 end]
- } -new {
- set new [lindex $watch 1]
- set watch [lrange $watch 2 end]
- } default {
- _abort "watch: expecting -threshold -display or -new but found: [lindex $watch 0]"
- }
- }
-
- foreach ng $active_list {
- if [string match $ngpat $ng] {
- if [_isgood $ng $threshold] {
- if [llength $display] {
- set newsgroup $ng
- uplevel $display
- }
- if [_isnew $ng] {
- if [llength $new] {
- set newsgroup $ng
- uplevel $new
- }
- }
- }
- }
- }
- }
-}
-
-# initialize display
-
-set min_reasonable_width 8
-
-wm minsize . $min_reasonable_width 1
-wm maxsize . 999 999
-if {0 == [info exists active_file] &&
- 0 != [string compare $server $_default_server]} {
- wm title . "news@$server"
- wm iconname . "news@$server"
-}
-
-# PRIVATE
-proc _update_window {} {
- global server display_list height width min_reasonable_width
-
- if {0 == [llength $display_list]} {
- unmapwindow
- return
- }
-
- # make height correspond to length of display_list or
- # user's requested max height, whichever is smaller
-
- if {[llength $display_list] < $height} {
- set current_height [llength $display_list]
- } else {
- set current_height $height
- }
-
- # force reasonable min width
- if {$width < $min_reasonable_width} {
- set width $min_reasonable_width
- }
-
- wm geometry . ${width}x$current_height
- wm maxsize . 999 [llength $display_list]
-
- _display_ngs $width
-
- if [string compare [wm state .] withdrawn]==0 {
- mapwindow
- }
-}
-
-# actually write all newsgroups to the window
-# PRIVATE
-proc _display_ngs {width} {
- global db display_list
-
- set str_width [expr $width-7]
-
- .list delete 0 end
- foreach ng $display_list {
- .list insert end [format \
- "%-$str_width.${str_width}s %5d" $ng \
- [expr $db($ng,hi) - $db($ng,seen)]]
- }
-}
-
-# PUBLIC
-proc help {} {
- catch {destroy .help}
- toplevel .help
- message .help.text -aspect 400 -text \
-{tknewsbiff - written by Don Libes, NIST, 1/1/94
-
-tknewsbiff displays newsgroups with unread articles based on your .newsrc\
-and your .tknewsbiff files.\
-If no articles are unread, no window is displayed.
-
-Click mouse button 1 for this help,\
-button 2 to force display to query news server immediately,\
-and button 3 to remove window from screen until the next update.
-
-Example .tknewsbiff file:}
- message .help.sample -font "*-r-normal-*-m-*" \
- -relief raised -aspect 10000 -text \
-{set width 30 ;# max width, defaults to 27
-set height 17 ;# max height, defaults to 10
-set delay 120 ;# in seconds, defaults to 60
-set server news.nist.gov ;# defaults to "news"
-set server_timeout 60 ;# in seconds, defaults to 60
-set newsrc ~/.newsrc ;# defaults to ~/.newsrc
- ;# after trying ~/.newsrc-$server
-# Groups to watch.
-watch comp.lang.tcl
-watch dc.dining -new "play yumyum"
-watch nist.security -new "exec red-alert"
-watch nist.*
-watch dc.general -threshold 5
-watch *.sources.* -threshold 20
-watch alt.howard-stern -threshold 100 -new "play robin"
-
-# Groups to ignore (but which match patterns above).
-# Note: newsgroups that you don't read are ignored automatically.
-ignore *.d
-ignore nist.security
-ignore nist.sport
-
-# Change background color of newsgroup list
-.list config -bg honeydew1
-
-# Play a sound file
-proc play {sound} {
- exec play /usr/local/lib/sounds/$sound.au
-}}
- message .help.end -aspect 10000 -text \
-"Other customizations are possible. See man page for more information."
-
- button .help.ok -text "ok" -command {destroy .help}
- pack .help.text
- pack .help.sample
- pack .help.end -anchor w
- pack .help.ok -fill x -padx 2 -pady 2
-}
-
-spawn cat -u; set _cat_spawn_id $spawn_id
-set _update_flag 0
-
-# PUBLIC
-proc update-now {} {
- global _update_flag _cat_spawn_id
-
- if $_update_flag return ;# already set, do nothing
- set _update_flag 1
-
- exp_send -i $_cat_spawn_id "\r"
-}
-
-bind .list <1> help
-bind .list <2> update-now
-bind .list <3> unmapwindow
-bind .list <Configure> {
- scan [wm geometry .] "%%dx%%d" w h
- _display_ngs $w
-}
-
-# PRIVATE
-proc _sleep {timeout} {
- global _cat_spawn_id _update_flag
-
- set _update_flag 0
-
- # restore to idle cursor
- .list config -cursor ""; update
-
- # sleep for a little while, subject to click from "update" button
- expect -i $_cat_spawn_id -re "...." ;# two crlfs
-
- # change to busy cursor
- .list config -cursor watch; update
-}
-
-set previous_seen_list {}
-set seen_list {}
-
-# PRIVATE
-proc _init_ngs {} {
- global display_list db
- global seen_list previous_seen_list
-
- set previous_seen_list $seen_list
-
- set display_list {}
- set seen_list {}
-
- catch {unset db}
-}
-
-for {} 1 {_sleep $delay} {
- _init_ngs
-
- _read_newsrc
- if [_read_active] continue
- _read_config_file
-
- _update_ngs
- user
- _update_window
-}
+++ /dev/null
-.TH TKNEWSBIFF 1 "1 January 1994"
-.SH NAME
-tknewsbiff \- pop up a window when news appears
-.SH SYNOPSIS
-.B tknewsbiff
-[
-.I server or config-file
-]
-.br
-.SH INTRODUCTION
-.B tknewsbiff
-pops up a window when there is unread news in your favorite newsgroups
-and removes the window after you've read the news. tknewsbiff can
-optionally play a sound, start your newsreader, etc.
-
-.SH SELECTING NEWSGROUPS
-
-By default, the configuration file ~/.tknewsbiff describes how
-tknewsbiff behaves. The syntax observes the usual Tcl rules
-- however, even if you don't know Tcl, all but the most esoteric
-configurations will be obvious.
-
-Each newsgroup (or set of newsgroups) to be watched is described by
-using the "watch" command. For example:
-
-.nf
-
-watch dc.dining
-watch nist.*
-watch comp.unix.wizard -threshold 3
-watch *.sources.* -threshold 20
-
-.fi
-
-For each newsgroup pattern, any newsgroup that matches it and which
-you are subscribed to (according to your newsrc file) is eligible for
-reporting. By default, tknewsbiff reports on the newsgroup if there
-is at least one unread article. The "-threshold" flag changes the
-threshold to the following number. For example, "-threshold 3" means
-there must be at least three articles unread before tknewsbiff will
-report the newsgroup.
-
-If no watch commands are given (or no configuration file exists), all
-groups which are subscribed to are watched.
-
-To suppress newsgroups that would otherwise be reported, use the
-"ignore" command. For example, the following matches all comp.* and
-nist.* newgroups except for nist.posix or .d (discussion) groups:
-
-.nf
-
-watch comp.*
-watch nist.*
-ignore nist.posix.*
-ignore *.d
-
-.fi
-
-The flag "-new" describes a command to be executed when the newsgroup
-is first reported as having unread news. For example, the following
-lines invoke the UNIX command "play" to play a sound.
-
-.nf
-
-watch dc.dining -new "exec play /usr/local/sounds/yumyum.au"
-watch rec.auto* -new "exec play /usr/local/sounds/vroom.au"
-
-.fi
-
-You can cut down on the verbosity of actions by defining procedures.
-For example, if you have many -new flags that all play sound files,
-you could define a sound procedure. This would allow the -new
-specification to be much shorter.
-
-.nf
-
-proc play {sound} {
- exec play /usr/local/sounds/$sound.au
-}
-
-watch dc.dining -new "play yumyum"
-watch rec.auto* -new "play vroom"
-
-.fi
-
-As an aside, you can put an "&" at the end of an "exec" command to get
-commands to execute asynchronously. However, it's probably not a good
-idea to do this when playing sound files anyway.
-
-"newsgroup" is a read-only variable which contains the name of the
-newsgroup that is being reported. This is useful when the action is
-triggered by a pattern. For example, the following line could run the
-newsgroup name through a speech synthesizer:
-
-.nf
-
-watch * -new {
- exec play herald.au
- exec speak "New news has arrived in $newsgroup."
-}
-
-.fi
-
-The flag "\-display" describes a command to be executed every time the
-newsgroup is reported as having unread news. The special command
-"display" is the default command. It schedules $newsgroup to be
-written to tknewsbiff's display when it is rewritten. For example, by
-explicitly providing a -display flag that omits the display command,
-you can disable the display of newsgroups that are already reported
-via -new.
-
-.nf
-
-watch dc.dining -new {exec play yumyum.au} -display {}
-
-.fi
-
-If you want to execute an action repeatedly and
-.I still
-display the newsgroup in the default manner,
-explicitly invoke the display command via the -display flag. For example:
-
-.nf
-
-watch *security* -display {
- exec play red-alert.au
- display
-}
-
-.fi
-
-Actions associated with the -new and -display flags are executed only
-once for each matching newsgroup. The command executed is the one
-associated with the first pattern in the configuration file that
-matches and observes the given threshold.
-
-Any command that is simply listed in the configuration file is
-executed each time before the update loop in tknewsbiff. The reserved
-(but user-defined) procedure "user" is run immediately after the
-newsgroups are scheduled to be written to the display and before they
-are actually written.
-
-For example, suppose unread articles appear in several rec.auto groups
-and you play the same sound for each one. To prevent playing the
-sound several times in a row, make the -new command simply set a flag.
-In the user procedure, play the sound if the flag is set (and then
-reset the flag).
-
-The user procedure could also be used to start a newsreader. This
-would avoid the possibility of starting multiple newsreaders just
-because multiple newsgroups contained unread articles. (A check
-should, of course, be made to make sure that a newsreader is not
-already running.)
-
-.SH MORE VARIABLES
-
-The following example lines show variables that can affect the
-behavior of tknewsbiff
-
-.nf
-
-set delay 120
-set server news.nist.gov
-set server_timeout 60
-set newsrc ~/.newsrc
-set width 40
-set height 20
-set active_file /usr/news/lib/active
-
-.fi
-
-tknewsbiff alternates between checking for unread news and
-sleeping (kind of like many undergraduates). The "delay" variable
-describes how many seconds to sleep.
-
-The "server" variable names an NNTP news-server.
-The default is "news". The "server" variable is
-only used if the "active_file" variable is not set.
-
-The "server_timeout" variable describes how how many seconds to wait
-for a response from the server before giving up. -1 means wait
-forever or until the server itself times out. The default is 60
-seconds.
-
-The "newsrc" variable describes the name of your .newsrc file. By
-default, tknewsbiff looks in your home directory for a newsrc file. A
-server-specific newsrc is used if found. For example, if you have set
-server to "cubit.nist.gov", then tknewsbiff looks for
-~/.newsrc-cubit.nist.gov. (This is the Emacs gnus convention - which
-is very convenient when you read news from multiple servers.) If
-there is no server-specific newsrc, tknewsbiff uses ~/.newsrc.
-
-The "width" variable describes the width that tknewsbiff will use to
-display information. If any newsgroup names are long enough, they
-will be truncated so that the article counts can still be shown. You
-can manually resize the window to see what was truncated. However, if
-your configuration file sets the width variable, the window will be
-restored to that size the next time that tknewsbiff checks for unread
-news and updates its display.
-
-The "height" variable describes the maximum height that tknewsbiff
-will use to display information. If fewer newsgroups are reported,
-tknewsbiff will shrink the window appropriately. You can manually
-resize the window but if your configuration file sets the height
-variable, the window will be restored to that size the next time that
-tknewsbiff checks for unread news and updates its display.
-
-The "active_file" variable describes the name of the news active file.
-If set, the active file is read directly in preference to using NNTP
-(even if the "server" variable is set). This is particularly useful
-for testing out new configuration files since you can edit a fake
-active file and then click button 2 to immediately see how tknewsbiff
-responds (see BUTTONS below).
-
-If the environment variable DOTDIR is set, then its value is used as a
-directory in which to find all dotfiles instead of from the home
-directory. In particular, this affects the tknewsbiff configuration
-file and the .newsrc file (assuming the newsrc variable is not set
-explicitly).
-
-.SH WATCHING DIFFERENT NEWS SERVERS
-
-To watch multiple servers, run tknewsbiff multiple times. (Since you
-need different .newsrc files and the servers have different newsgroups
-and article numbers anyway, there is no point in trying to do this in
-a single process.)
-
-You can point tknewsbiff at a different server with an appropriate
-argument. The argument is tried both as a configuration file name and
-as a suffix to the string "~/.tknewsbiff-". So if you want to watch
-the server "kidney", store the tknewsbiff configuration information in
-~/.tknewsbiff-kidney". The following two commands will both use that
-configuration file.
-
-.nf
-
- tknewsbiff kidney
- tknewsbiff ~/.tknewsbiff-kidney
-
-.fi
-
-In both cases, the actual server to contact is set by the value of the
-server variable in the configuration file.
-
-If no configuration file is found, the argument is used as the server
-to contact. This allows tknewsbiff to be run with no preparation
-whatsoever.
-
-If the argument is the special keyword "active" (or ends in
-"/active"), it is used as the name of an active file. This is in turn
-used to initialize the variable "active_file" so that tknewsbiff reads
-from the active file directly rather than using NNTP.
-
-Creating your own active file is a convenient way of testing your
-configuration file. For example, after running the following command,
-you can repeatedly edit your active file and trigger the update-now
-command (either by pressing button 2 or setting the delay variable
-very low) to see how tknewsbiff responds.
-
-The active file must follow the format of a real active file. The
-format is one newsgroup per line. After the newsgroup name is the
-number of the highest article, the lowest article. Lastly is the
-letter y or m. m means the newsgroup is moderated. y means posting
-is allowed.
-
-.SH WINDOW
-
-When unread news is found, a window is popped up. The window lists
-the names of the newsgroups and the number of unread articles in each
-(unless suppressed by the -display flag). When there is no longer any
-unread news, the window disappears (although the process continues to
-run).
-
-.SH BUTTONS
-
-Button or key bindings may be assigned by bind commands. Feel free to
-change them. The default bind commands are:
-
-.nf
-
-bind .list <1> help
-bind .list <2> update-now
-bind .list <3> unmapwindow
-
-.fi
-
-By default button 1 (left) is bound to "help". The help command
-causes tknewsbiff to pop up a help window.
-
-By default, button 2 (middle) is bound to "update-now". The update-now
-command causes tknewsbiff to immediately check for unread news. If
-your news server is slow or maintains a very large number of
-newsgroups, or you have a large number of patterns in your
-configuration file, tknewsbiff can take considerable time before
-actually updating the window.
-
-By default, button 3 (right) is bound to "unmapwindow". The
-unmapwindow command causes tknewsbiff to remove the window from the
-display until the next time it finds unread news. (The mapwindow
-command causes tknewsbiff to restore the window.)
-
-As an example, here is a binding to pop up an xterm and run rn when
-you hold down the shift key and press button 1 in the listing window.
-
-.nf
-
-bind .list <Shift-1> {
- exec xterm -e rn &
-}
-
-.fi
-
-Here is a similar binding. However it tells rn to look only at the
-newsgroup that is under the mouse when you pressed it. (The
-"display_list" variable is described later in this man page.)
-
-.nf
-
-bind .list <Shift-1> {
- exec xterm -e rn [lindex $display_list [.list nearest %y]] &
-}
-
-.fi
-
-.SH OTHER COMMANDS AND VARIABLES
-
-Built-in commands already mentioned are: watch, ignore, display, help,
-update-now, unmapwindow, and mapwindow.
-
-Any Tcl and Tk command can also be given. In particular, the list of
-newsgroups is stored in the list widget ".list", and the scroll bar is
-stored in the scrollbar widget ".scroll". So for example, if you want
-to change the foreground and background colors of the newsgroup list,
-you can say:
-
-.nf
-
- .list config -bg honeydew1 -fg orchid2
-
-.fi
-
-These can also be controlled by the X resource database as well.
-However, the configuration file allows arbitrarily complex commands to
-be evaluated rather than simple assignments.
-
-Certain Tcl/Tk commands can disrupt proper function of tknewsbiff.
-These will probably be obvious to anyone who knows enough to give
-these commands in the first place. As a simple example, the program
-assumes the font in the list box is of fixed width. The newsgroups
-will likely not align if you use a variable-width font.
-
-The following variables are accessible and can be used for esoteric
-uses. All other variables are private. Private variables and
-commands begin with "_" so you don't need to worry about accidental
-collisions.
-
-The array "db" is a database which maintains information about read
-and unread news. db($newsgroup,hi) is the highest article that
-exists. db($newsgroup,seen) is the highest article that you have
-read.
-
-A number of lists maintain interesting information. "active_list" is a
-list of known newsgroups. "seen_list" is a list of newsgroups that
-have been seen so far as the -new and -display flags are being
-processed. "previous_seen_list" is "seen_list" from the previous
-cycle. "ignore_list" is the list of newsgroup patterns to ignore.
-"watch_list" is the list of newsgroup patterns to watch.
-"display_list" is the list of newsgroup will be displayed at the next
-opportunity.
-
-.SH UPDATING YOUR FILES
-
-tknewsbiff automatically rereads your configuration file each time it
-wakes up to check for unread news. To force tknewsbiff to reread the
-file immediately (such as if you are testing a new configuration or
-have just modified your newsrc file), press button 2 in the display
-(see BUTTONS above).
-
-.SH CAVEATS
-
-tknewsbiff defines the number of unread articles as the highest
-existing article minus the highest article that you've read. So if
-you've read the last article in the newsgroup but no others,
-tknewsbiff thinks there are no unread articles. (It's impossible to
-do any better by reading the active file and it would be very time
-consuming to do this more accurately via NNTP since servers provide no
-efficient way of reporting their own holes in the newsgroups.)
-Fortunately, this definition is considered a feature by most people.
-It allows you to read articles and then mark them "unread" but not
-have tknewsbiff continue telling you that they are unread.
-
-.SH UNWARRANTED CONCERNS
-
-Your news administrator may wonder if many people using tknewsbiff
-severely impact an NNTP server. In fact, the impact is negligible
-even when the delay is very low. To gather all the information it
-needs, tknewsbiff uses a single NNTP query - it just asks for the
-active file. The NNTP server does no computation, formatting, etc, it
-just sends the file. All the interesting processing happens locally
-in the tknewsbiff program itself.
-
-.SH BUGS
-
-The man page is longer than the program.
-
-.SH SEE ALSO
-.I
-"Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Programs"
-\fRby Don Libes,
-O'Reilly and Associates, January 1995.
-.SH AUTHOR
-Don Libes, National Institute of Standards and Technology
+++ /dev/null
-#!/depot/path/expectk -f
-# tkpasswd - Change passwords using Expectk
-# Author: Don Libes, NIST, October 1, 1993
-# Version: 1.8 - Added support for Tk 4.1
-
-# There is no man page. However, there is some on-line help when you run
-# the program. Technical details and insights are described in the
-# O'Reilly book "Exploring Expect".
-
-proc prog_exists {prog} {
- global env
-
- foreach dir [split $env(PATH) :] {
- if [file executable $dir/$prog] {
- return 1
- }
- }
- return 0
-}
-
-frame .type -relief raised -bd 1
-
-radiobutton .passwd -text passwd -variable passwd_cmd \
- -value {passwd {cat /etc/passwd}} \
- -anchor w -command get_users -relief flat
-pack .passwd -in .type -fill x
-
-if [prog_exists yppasswd] {
- radiobutton .yppasswd -text yppasswd -variable passwd_cmd \
- -value {yppasswd {ypcat passwd}} \
- -anchor w -command get_users -relief flat
- pack .yppasswd -in .type -fill x
-}
-
-if [prog_exists nispasswd] {
- radiobutton .nispasswd -text nispasswd -variable passwd_cmd \
- -value {nispasswd {niscat passwd}} \
- -anchor w -command get_users -relief flat
- pack .nispasswd -in .type -fill x
-}
-pack .type -fill x
-
-frame .sort -relief raised -bd 1
-radiobutton .unsorted -text unsorted -variable sort_cmd -value " " \
- -anchor w -relief flat -command get_users
-radiobutton .name -text name -variable sort_cmd -value "| sort" \
- -anchor w -relief flat -command get_users
-radiobutton .uid -text uid -variable sort_cmd -value "| sort -t: -n +2" \
- -anchor w -relief flat -command get_users
-pack .unsorted .name .uid -in .sort -fill x
-pack .sort -fill x
-
-frame .users -relief raised -bd 1
-# has to be wide enough for 8+1+5=14
-text .names -yscrollcommand ".scroll set" -width 14 -height 1 \
- -font "*-bold-o-normal-*-120-*-m-*" -setgrid 1
-.names tag configure nopassword -relief raised
-.names tag configure selection -relief raised
-
-set iscolor 0
-if {[winfo depth .] > 1} {
- set iscolor 1
-}
-
-if {$iscolor} {
- .names tag configure nopassword -background red
- .names tag configure selection -background green
-} else {
- .names tag configure nopassword -background black -foreground white
- .names tag configure selection -background white -foreground black
-}
-scrollbar .scroll -command ".names yview" -relief raised
-pack .scroll -in .users -side left -fill y
-pack .names -in .users -side left -fill y
-pack .users -expand 1 -fill y
-
-wm minsize . 14 1
-wm maxsize . 14 999
-wm geometry . 14x10
-
-frame .password_frame -relief raised -bd 1
-entry .password -textvar password -relief sunken -width 1
-focus .password
-bind .password <Return> password_set
-label .prompt -text "Password:" -bd 0
-button .password_set -text "set" -command password_set
-button .generate_button -text "generate" -command password_generate
-pack .prompt .password -in .password_frame -fill x -padx 2 -pady 2
-pack .password_set .generate_button -in .password_frame -side left -expand 1 -fill x -padx 2 -pady 2
-pack .password_frame -fill x
-
-set dict_loaded 0
-checkbutton .dict -text "test dictionary" -variable dict_check \
- -command {if !$dict_loaded load_dict} \
- -anchor w
-pack .dict -fill x -padx 2 -pady 2
-
-
-button .quit -text quit -command exit
-button .help_button -text help -command help
-pack .quit .help_button -side left -expand 1 -fill x -padx 2 -pady 2
-
-proc help {} {
- if [catch {toplevel .help}] return
- message .help.text -text \
-"tkpasswd - written by Don Libes, NIST, 10/1/93.
-
-Click on passwd (local users) or yppasswd (NIS users).\
-Select user using mouse (or keys - see below).\
-Enter password or press ^G to generate a random password.\
-(Press ^A to adjust the generation parameters.)\
-Press return to set the password.\
-If the dictionary is enabled and the password is in it,\
-the password is rejected.
-
-You must be root to set local passwords besides your own.\
-If you are not root, you must also enter an old password\
-when requested.
-
-You do not have to move mouse into password field(s) to enter password.\
-^U clears password field.\
-^N and ^P select next/previous user.\
-M-n and M-p select next/previous user with no password.\
-(Users with no passwords are highlighted.)"
-
- button .help.ok -text "ok" -command {destroy .help}
- pack .help.text
- pack .help.ok -fill x -padx 2 -pady 2
-}
-
-# get list of local users
-proc get_users {} {
- global sort_cmd passwd_cmd
- global nopasswords ;# line numbers of entries with no passwords
- global last_line ;# last line of text box
- global selection_line
-
- .names delete 1.0 end
-
- set file [open "|[lindex $passwd_cmd 1] $sort_cmd"]
- set last_line 1
- set nopasswords {}
- while {[gets $file buf] != -1} {
- set buf [split $buf :]
- if [llength $buf]>2 {
- # normal password entry
- .names insert end "[format "%-8.8s %5d" [lindex $buf 0] [lindex $buf 2]]\n"
- if 0==[string compare [lindex $buf 1] ""] {
- .names tag add nopassword \
- {end - 2 line linestart} \
- {end - 2 line lineend}
- lappend nopasswords $last_line
- }
- } else {
- # +name style entry
- .names insert end "$buf\n"
- }
- incr last_line
- }
- incr last_line -1
- close $file
- set selection_line 0
-}
-
-proc feedback {msg} {
- global password
-
- set password $msg
- .password select from 0
- .password select to end
- update
-}
-
-proc load_dict {} {
- global dict dict_loaded
-
- feedback "loading dictionary..."
-
- if 0==[catch {open /usr/dict/words} file] {
- rename set s
- foreach w [split [read $file] "\n"] {s dict($w) ""}
- close $file
- rename s set
- set dict_loaded 1
- feedback "dictionary loaded"
- } else {
- feedback "dictionary missing"
- .dict deselect
- }
-}
-
-# put whatever security checks you like in here
-proc weak_password {password} {
- global dict dict_check
-
- if $dict_check {
- feedback "checking password"
-
- if [info exists dict($password)] {
- feedback "sorry - in dictionary"
- return 1
- }
- }
- return 0
-}
-
-proc password_set {} {
- global password passwd_cmd selection_line
-
- set new_password $password
-
- if {$selection_line==0} {
- feedback "select a user first"
- return
- }
- set user [lindex [.names get selection.first selection.last] 0]
-
- if [weak_password $password] return
-
- feedback "setting password . . ."
-
- set cmd [lindex $passwd_cmd 0]
- spawn -noecho $cmd $user
- log_user 0
- set last_msg "error in $cmd"
- while 1 {
- expect {
- -nocase "old password:" {
- exp_send "[get_old_password]\r"
- } "assword*:" {
- exp_send "$new_password\r"
- } -re "(.*)\r\n" {
- set last_msg $expect_out(1,string)
- } eof break
- }
- }
- set status [wait]
- if [lindex $status 3]==0 {
- feedback "set successfully"
- } else {
- feedback $last_msg
- }
-}
-
-# defaults for generating passwords
-set length 9
-set minnum 2
-set minlower 5
-set minupper 2
-set distribute 0
-
-proc parameter_filename {} {
- set file .tkpasswd.rc
- if [info exists env(DOTDIR)] {
- set file "$env(DOTDIR)/$file"
- }
- return ~/$file
-}
-
-catch {source [parameter_filename]}
-
-# save parameters in a file
-proc save_parameters {} {
- global minnum minlower minupper length
-
- if [catch {open [parameter_filename] w} f] {
- # should never happen, so don't bother with window code
- puts "tkpasswd: could not write [parameter_filename]"
- return
- }
- puts $f "# This is the .tkpasswd.rc file. Do not edit it by hand as"
- puts $f "# it is automatically maintained by tkpasswd. Any manual"
- puts $f "# modifications will be lost."
- puts $f ""
- puts $f "set length $length"
- puts $f "set minnum $minnum"
- puts $f "set minupper $minupper"
- puts $f "set minlower $minlower"
- close $f
-}
-
-# insert char into password at a random position
-proc insert {pvar char} {
- upvar $pvar p
-
- set p [linsert $p [rand [expr 1+[llength $p]]] $char]
-}
-
-# given a size, distribute between left and right hands
-# taking into account where we left off
-proc psplit {max lvar rvar} {
- upvar $lvar left $rvar right
- global isleft
-
- if {$isleft} {
- set right [expr $max/2]
- set left [expr $max-$right]
- set isleft [expr !($max%2)]
- } else {
- set left [expr $max/2]
- set right [expr $max-$left]
- set isleft [expr $max%2]
- }
-}
-
-proc password_generate {} {
- global password length minnum minlower minupper
- global lpass rpass initially_left isleft
- global distribute
-
- if {$distribute} {
- set lkeys {q w e r t a s d f g z x c v b}
- set rkeys {y u i o p h j k l n m}
- set lnums {1 2 3 4 5 6}
- set rnums {7 8 9 0}
- } else {
- set lkeys {a b c d e f g h i j k l m n o p q r s t u v w x y z}
- set rkeys {a b c d e f g h i j k l m n o p q r s t u v w x y z}
- set lnums {0 1 2 3 4 5 6 7 8 9}
- set rnums {0 1 2 3 4 5 6 7 8 9}
- }
- set lkeys_length [llength $lkeys]
- set rkeys_length [llength $rkeys]
- set lnums_length [llength $lnums]
- set rnums_length [llength $rnums]
-
- # if there is any underspecification, use additional lowercase letters
- set minlower [expr $length - ($minnum + $minupper)]
-
-
- set lpass "" ;# password chars typed by left hand
- set rpass "" ;# password chars typed by right hand
- set password "" ;# merged password
-
- # choose left or right starting hand
- set initially_left [set isleft [rand 2]]
-
- psplit $minnum left right
- for {set i 0} {$i<$left} {incr i} {
- insert lpass [lindex $lnums [rand $lnums_length]]
- }
- for {set i 0} {$i<$right} {incr i} {
- insert rpass [lindex $rnums [rand $rnums_length]]
- }
-
- psplit $minlower left right
- for {set i 0} {$i<$left} {incr i} {
- insert lpass [lindex $lkeys [rand $lkeys_length]]
- }
- for {set i 0} {$i<$right} {incr i} {
- insert rpass [lindex $rkeys [rand $rkeys_length]]
- }
-
- psplit $minupper left right
- for {set i 0} {$i<$left} {incr i} {
- insert lpass [string toupper [lindex $lkeys [rand $lkeys_length]]]
- }
- for {set i 0} {$i<$right} {incr i} {
- insert rpass [string toupper [lindex $rkeys [rand $rkeys_length]]]
- }
-
- # merge results together
- if {$initially_left} {
- regexp "(\[^ ]*) *(.*)" "$lpass" x password lpass
- while {[llength $lpass]} {
- regexp "(\[^ ]*) *(.*)" "$password$rpass" x password rpass
- regexp "(\[^ ]*) *(.*)" "$password$lpass" x password lpass
- }
- if {[llength $rpass]} {
- append password $rpass
- }
- } else {
- regexp "(\[^ ]*) *(.*)" "$rpass" x password rpass
- while {[llength $rpass]} {
- regexp "(\[^ ]*) *(.*)" "$password$lpass" x password lpass
- regexp "(\[^ ]*) *(.*)" "$password$rpass" x password rpass
- }
- if {[llength $lpass]} {
- append password $lpass
- }
- }
-}
-
-set _ran [pid]
-proc rand {m} {
- global _ran
-
- set period 259200
- set _ran [expr ($_ran*7141 + 54773) % $period]
- expr int($m*($_ran/double($period)))
-}
-
-proc gen_bad_args {msg} {
- if ![llength [info commands .parameters.errmsg]] {
- message .parameters.errmsg -aspect 300
- pack .parameters.errmsg
- }
- .parameters.errmsg configure -text "$msg\
-Please adjust the password generation arguments."
-}
-
-
-# tell tab what window to move between
-set parm_tabList {}
-
-# The procedure below is invoked in response to tabs in the entry
-# windows. It moves the focus to the next window in the tab list.
-# Arguments:
-#
-# list - Ordered list of windows to receive focus
-
-proc Tab {list} {
- set i [lsearch $list [focus]]
- if {$i < 0} {
- set i 0
- } else {
- incr i
- if {$i >= [llength $list]} {
- set i 0
- }
- }
- focus [lindex $list $i]
-}
-
-# adjust args used in password generation
-proc adjust_parameters {} {
- global parm_tabList
- set parm_tabList {}
-
- toplevel [set w .parameters]
-
-# wm title $w ""
-# wm iconname $w ""
-
- message $w.text -aspect 300 -text \
-"These parameters control generation of random passwords.
-
-It is not necessary to move the mouse into this window to operate it.\
-Press <tab> to move to the next entry.\
-Press <return> or click the <ok> button when you are done."
-
- foreach desc {
- {length {total length}}
- {minnum {minimum number of digits}}
- {minupper {minimum number of uppercase letters}}
- {minlower {minimum number of lowercase letters}}} {
- set name [lindex $desc 0]
- set text [lindex $desc 1]
- frame $w.$name -bd 1
- entry $w.$name.entry -relief sunken -width 2 -textvar $name
- bind $w.$name.entry <Tab> "Tab \$parm_tabList"
- bind $w.$name.entry <Return> "destroy_parm_window"
- label $w.$name.text -text $text
- pack $w.$name.entry -side left
- pack $w.$name.text -side left
- lappend parm_tabList $w.$name.entry
- }
- frame $w.2 -bd 1
- checkbutton $w.2.cb -text "alternate characters across hands" \
- -relief flat -variable distribute
- pack $w.2.cb -side left
-
- button $w.ok -text "ok" -command "destroy_parm_window"
- pack $w.text -expand 1 -fill x
- pack $w.length $w.minnum $w.minupper $w.minlower $w.2 -expand 1 -fill x
- pack $w.ok -side left -fill x -expand 1 -padx 2 -pady 2
-
-#strace 10
- set oldfocus [focus]
-# $w.length.entry icursor end
- tkwait visibility $w.length.entry
- focus $w.length.entry
-# grab $w
- tkwait window $w
-# grab release $w
- focus $oldfocus
-
-#strace 0
-
- save_parameters
-}
-
-proc isnumber {n} {
- regexp "^\[0-9\]+$" $n
-}
-
-# destroy parm window IF all values are legal
-proc destroy_parm_window {} {
- global minnum minlower minupper length
-
- set mustbe "must be a number greater than or equal to zero."
-
- # check all variables
- if {![isnumber $length]} {
- gen_bad_args "The total length $mustbe"
- return
- }
- if {![isnumber $minlower]} {
- gen_bad_args "The minimum number of lowercase characters $mustbe"
- return
- }
- if {![isnumber $minupper]} {
- gen_bad_args "The minimum number of uppercase characters $mustbe"
- return
- }
- if {![isnumber $minnum]} {
- gen_bad_args "The minimum number of digits $mustbe"
- return
- }
-
- # check constraints
- if {$minnum + $minlower + $minupper > $length} {
- gen_bad_args \
-"It is impossible to generate a $length-character password with\
-$minnum number[pluralize $minnum],\
-$minlower lowercase letter[pluralize $minlower], and\
-$minupper uppercase letter[pluralize $minupper]."
- return
- }
-
- destroy .parameters
-}
-
-# return appropriate ending for a count of "n" nouns
-proc pluralize {n} {
- expr $n!=1?"s":""
-}
-
-
-proc get_old_password {} {
- global old
-
- toplevel .old
- label .old.label -text "Old password:"
- catch {unset old}
- entry .old.entry -textvar old -relief sunken -width 1
-
- pack .old.label
- pack .old.entry -fill x -padx 2 -pady 2
-
- bind .old.entry <Return> {destroy .old}
- set oldfocus [focus]
- focus .old.entry
- tkwait visibility .old
- grab .old
- tkwait window .old
- focus $oldfocus
- return $old
-}
-
-.unsorted select
-.passwd invoke
-
-proc make_selection {} {
- global selection_line last_line
-
- .names tag remove selection 0.0 end
-
- # don't let selection go off top of screen
- if {$selection_line < 1} {
- set selection_line $last_line
- } elseif {$selection_line > $last_line} {
- set selection_line 1
- }
- .names yview -pickplace [expr $selection_line-1]
- .names tag add selection $selection_line.0 [expr 1+$selection_line].0
-}
-
-proc select_next_nopassword {direction} {
- global selection_line last_line
- global nopasswords
-
- if 0==[llength $nopasswords] {
- feedback "no null passwords"
- return
- }
-
- if $direction==1 {
- # is there a better way to get last element of list?
- if $selection_line>=[lindex $nopasswords [expr [llength $nopasswords]-1]] {
- set selection_line 0
- }
- foreach i $nopasswords {
- if $selection_line<$i break
- }
- } else {
- if $selection_line<=[lindex $nopasswords 0] {
- set selection_line $last_line
- }
- set j [expr [llength $nopasswords]-1]
- for {} {$j>=0} {incr j -1} {
- set i [lindex $nopasswords $j]
- if $selection_line>$i break
- }
- }
- set selection_line $i
- make_selection
-}
-
-proc select {w coords} {
- global selection_line
-
- $w mark set insert "@$coords linestart"
- $w mark set anchor insert
- set first [$w index "anchor linestart"]
- set last [$w index "insert lineend + 1c"]
- scan $first %d selection_line
-
- $w tag remove selection 0.0 end
- $w tag add selection $first $last
-}
-
-bind Text <1> {select %W %x,%y}
-bind Text <Double-1> {select %W %x,%y}
-bind Text <Triple-1> {select %W %x,%y}
-bind Text <2> {select %W %x,%y}
-bind Text <3> {select %W %x,%y}
-bind Text <B1-Motion> {}
-bind Text <Shift-1> {}
-bind Text <Shift-B1-Motion> {}
-bind Text <B2-Motion> {}
-
-bind .password <Control-n> {incr selection_line 1; make_selection}
-bind .password <Control-p> {incr selection_line -1;make_selection}
-bind .password <Meta-n> {select_next_nopassword 1}
-bind .password <Meta-p> {select_next_nopassword -1}
-bind .password <Control-g> {password_generate}
-bind .password <Control-a> {adjust_parameters}
-bind .password <Control-u> {set password ""}
-bind Entry <Control-c> {exit}
+++ /dev/null
-#!../expectk -f
-
-# Name: tkterm - terminal emulator using Expect and Tk text widget, v1.0
-# Author: Don Libes, July '94
-
-# This is primarily for regression testing character-graphic applications.
-# You can certainly use it as a terminal emulator - however many features
-# in a real terminal emulator are not supported (although I'll probably
-# add some of them later).
-
-# A paper on the implementation: Libes, D., Automation and Testing of
-# Interactive Character Graphic Programs", Software - Practice &
-# Experience, John Wiley & Sons, West Sussex, England, Vol. 27(2),
-# p. 123-137, February 1997.
-
-###############################
-# Quick overview of this emulator
-###############################
-# Very good attributes:
-# Understands both termcap and terminfo
-# Understands meta-key (zsh, emacs, etc work)
-# Is fast
-# Understands X selections
-# Looks best with fixed-width font but doesn't require it
-# Good-enough-for-starters attributes:
-# Understands one kind of standout mode (reverse video)
-# Should-be-fixed-soon attributes:
-# Does not support scrollbar or resize
-# Probably-wont-be-fixed-soon attributes:
-# Assumes only one terminal exists
-
-###############################################
-# To try out this package, just run it. Using it in
-# your scripts is simple. Here are directions:
-###############################################
-# 0) make sure Expect is linked into your Tk-based program (or vice versa)
-# 1) modify the variables/procedures below these comments appropriately
-# 2) source this file
-# 3) pack the text widget ($term) if you have so configured it (see
-# "term_alone" below). As distributed, it packs into . automatically.
-
-#############################################
-# Variables that must be initialized before using this:
-#############################################
-set rows 24 ;# number of rows in term
-set cols 80 ;# number of columns in term
-set term .t ;# name of text widget used by term
-set term_alone 1 ;# if 1, directly pack term into .
- ;# else you must pack
-set termcap 1 ;# if your applications use termcap
-set terminfo 1 ;# if your applications use terminfo
- ;# (you can use both, but note that
- ;# starting terminfo is slow)
-set term_shell $env(SHELL) ;# program to run in term
-
-#############################################
-# Readable variables of interest
-#############################################
-# cur_row ;# current row where insert marker is
-# cur_col ;# current col where insert marker is
-# term_spawn_id ;# spawn id of term
-
-#############################################
-# Procs you may want to initialize before using this:
-#############################################
-
-# term_exit is called if the spawned process exits
-proc term_exit {} {
- exit
-}
-
-# term_chars_changed is called after every change to the displayed chars
-# You can use if you want matches to occur in the background (a la bind)
-# If you want to test synchronously, then just do so - you don't need to
-# redefine this procedure.
-proc term_chars_changed {} {
-}
-
-# term_cursor_changed is called after the cursor is moved
-proc term_cursor_changed {} {
-}
-
-# Example tests you can make
-#
-# Test if cursor is at some specific location
-# if {$cur_row == 1 && $cur_col == 0} ...
-#
-# Test if "foo" exists anywhere in line 4
-# if {[string match *foo* [$term get 4.0 4.end]]}
-#
-# Test if "foo" exists at line 4 col 7
-# if {[string match foo* [$term get 4.7 4.end]]}
-#
-# Test if a specific character at row 4 col 5 is in standout
-# if {-1 != [lsearch [$term tag names 4.5] standout]} ...
-#
-# Return contents of screen
-# $term get 1.0 end
-#
-# Return indices of first string on lines 4 to 6 that is in standout mode
-# $term tag nextrange standout 4.0 6.end
-#
-# Replace all occurrences of "foo" with "bar" on screen
-# for {set i 1} {$i<=$rows} {incr i} {
-# regsub -all "foo" [$term get $i.0 $i.end] "bar" x
-# $term delete $i.0 $i.end
-# $term insert $i.0 $x
-# }
-
-#############################################
-# End of things of interest
-#############################################
-
-
-unset env(DISPLAY)
-set env(LINES) $rows
-set env(COLUMNS) $cols
-
-set env(TERM) "tt"
-if $termcap {
- set env(TERMCAP) {tt:
- :cm=\E[%d;%dH:
- :up=\E[A:
- :nd=\E[C:
- :cl=\E[H\E[J:
- :do=^J:
- :so=\E[7m:
- :se=\E[m:
- :k1=\EOP:
- :k2=\EOQ:
- :k3=\EOR:
- :k4=\EOS:
- :k5=\EOT:
- :k6=\EOU:
- :k7=\EOV:
- :k8=\EOW:
- :k9=\EOX:
- }
-}
-
-if $terminfo {
- set env(TERMINFO) /tmp
- set ttsrc "/tmp/tt.src"
- set file [open $ttsrc w]
-
- puts $file {tt|textterm|Don Libes' tk text widget terminal emulator,
- cup=\E[%p1%d;%p2%dH,
- cuu1=\E[A,
- cuf1=\E[C,
- clear=\E[H\E[J,
- ind=\n,
- cr=\r,
- smso=\E[7m,
- rmso=\E[m,
- kf1=\EOP,
- kf2=\EOQ,
- kf3=\EOR,
- kf4=\EOS,
- kf5=\EOT,
- kf6=\EOU,
- kf7=\EOV,
- kf8=\EOW,
- kf9=\EOX,
- }
- close $file
-
- set oldpath $env(PATH)
- set env(PATH) "/usr/5bin:/usr/lib/terminfo"
- if 1==[catch {exec tic $ttsrc} msg] {
- puts "WARNING: tic failed - if you don't have terminfo support on"
- puts "your system, change \"set terminfo 1\" to \"set terminfo 0\"."
- puts "Here is the original error from running tic:"
- puts $msg
- }
- set env(PATH) $oldpath
-
- exec rm $ttsrc
-}
-
-set term_standout 0 ;# if in standout mode or not
-
-log_user 0
-
-# start a shell and text widget for its output
-set stty_init "-tabs"
-eval spawn $term_shell
-stty rows $rows columns $cols < $spawn_out(slave,name)
-set term_spawn_id $spawn_id
-
-# this shouldn't be needed if Ousterhout fixes text bug
-text $term -relief sunken -bd 1 -width $cols -height $rows -wrap none
-
-if {$term_alone} {
- pack $term
-}
-
-$term tag configure standout -background black -foreground white
-
-proc term_clear {} {
- global term
-
- $term delete 1.0 end
- term_init
-}
-
-proc term_init {} {
- global rows cols cur_row cur_col term
-
- # initialize it with blanks to make insertions later more easily
- set blankline [format %*s $cols ""]\n
- for {set i 1} {$i <= $rows} {incr i} {
- $term insert $i.0 $blankline
- }
-
- set cur_row 1
- set cur_col 0
-
- $term mark set insert $cur_row.$cur_col
-}
-
-proc term_down {} {
- global cur_row rows cols term
-
- if {$cur_row < $rows} {
- incr cur_row
- } else {
- # already at last line of term, so scroll screen up
- $term delete 1.0 "1.end + 1 chars"
-
- # recreate line at end
- $term insert end [format %*s $cols ""]\n
- }
-}
-
-proc term_insert {s} {
- global cols cur_col cur_row
- global term term_standout
-
- set chars_rem_to_write [string length $s]
- set space_rem_on_line [expr $cols - $cur_col]
-
- if {$term_standout} {
- set tag_action "add"
- } else {
- set tag_action "remove"
- }
-
- ##################
- # write first line
- ##################
-
- if {$chars_rem_to_write > $space_rem_on_line} {
- set chars_to_write $space_rem_on_line
- set newline 1
- } else {
- set chars_to_write $chars_rem_to_write
- set newline 0
- }
-
- $term delete $cur_row.$cur_col $cur_row.[expr $cur_col + $chars_to_write]
- $term insert $cur_row.$cur_col [
- string range $s 0 [expr $space_rem_on_line-1]
- ]
-
- $term tag $tag_action standout $cur_row.$cur_col $cur_row.[expr $cur_col + $chars_to_write]
-
- # discard first line already written
- incr chars_rem_to_write -$chars_to_write
- set s [string range $s $chars_to_write end]
-
- # update cur_col
- incr cur_col $chars_to_write
- # update cur_row
- if $newline {
- term_down
- }
-
- ##################
- # write full lines
- ##################
- while {$chars_rem_to_write >= $cols} {
- $term delete $cur_row.0 $cur_row.end
- $term insert $cur_row.0 [string range $s 0 [expr $cols-1]]
- $term tag $tag_action standout $cur_row.0 $cur_row.end
-
- # discard line from buffer
- set s [string range $s $cols end]
- incr chars_rem_to_write -$cols
-
- set cur_col 0
- term_down
- }
-
- #################
- # write last line
- #################
-
- if {$chars_rem_to_write} {
- $term delete $cur_row.0 $cur_row.$chars_rem_to_write
- $term insert $cur_row.0 $s
- $term tag $tag_action standout $cur_row.0 $cur_row.$chars_rem_to_write
- set cur_col $chars_rem_to_write
- }
-
- term_chars_changed
-}
-
-proc term_update_cursor {} {
- global cur_row cur_col term
-
- $term mark set insert $cur_row.$cur_col
-
- term_cursor_changed
-}
-
-term_init
-
-set flush 0
-proc screen_flush {} {
- global flush
- incr flush
- if {$flush == 24} {
- update idletasks
- set flush 0
- }
-# update idletasks
-# after 1000 a
-}
-
-
-
-expect_background {
- -i $term_spawn_id
- -re "^\[^\x01-\x1f]+" {
- # Text
- term_insert $expect_out(0,string)
- term_update_cursor
- } "^\r" {
- # (cr,) Go to beginning of line
- screen_flush
- set cur_col 0
- term_update_cursor
- } "^\n" {
- # (ind,do) Move cursor down one line
- term_down
- term_update_cursor
- } "^\b" {
- # Backspace nondestructively
- incr cur_col -1
- term_update_cursor
- } "^\a" {
- bell
- } "^\t" {
- # Tab, shouldn't happen
- send_error "got a tab!?"
- } eof {
- term_exit
- } "^\x1b\\\[A" {
- # (cuu1,up) Move cursor up one line
- incr cur_row -1
- term_update_cursor
- } "^\x1b\\\[C" {
- # (cuf1,nd) Non-destructive space
- incr cur_col
- term_update_cursor
- } -re "^\x1b\\\[(\[0-9]*);(\[0-9]*)H" {
- # (cup,cm) Move to row y col x
- set cur_row [expr $expect_out(1,string)+1]
- set cur_col $expect_out(2,string)
- term_update_cursor
- } "^\x1b\\\[H\x1b\\\[J" {
- # (clear,cl) Clear screen
- term_clear
- term_update_cursor
- } "^\x1b\\\[7m" {
- # (smso,so) Begin standout mode
- set term_standout 1
- } "^\x1b\\\[m" {
- # (rmso,se) End standout mode
- set term_standout 0
- }
-}
-
-bind $term <Any-Enter> {
- focus %W
-}
-bind $term <Meta-KeyPress> {
- if {"%A" != ""} {
- exp_send -i $term_spawn_id "\033%A"
- }
-}
-
-bind $term <KeyPress> {
- exp_send -i $term_spawn_id -- %A
- break
-}
-
-bind $term <Control-space> {exp_send -null}
-bind $term <Control-at> {exp_send -null}
-
-bind $term <F1> {exp_send -i $term_spawn_id "\033OP"}
-bind $term <F2> {exp_send -i $term_spawn_id "\033OQ"}
-bind $term <F3> {exp_send -i $term_spawn_id "\033OR"}
-bind $term <F4> {exp_send -i $term_spawn_id "\033OS"}
-bind $term <F5> {exp_send -i $term_spawn_id "\033OT"}
-bind $term <F6> {exp_send -i $term_spawn_id "\033OU"}
-bind $term <F7> {exp_send -i $term_spawn_id "\033OV"}
-bind $term <F8> {exp_send -i $term_spawn_id "\033OW"}
-bind $term <F9> {exp_send -i $term_spawn_id "\033OX"}
+++ /dev/null
-#!../expect --
-# Description: unbuffer stdout of a program
-# Author: Don Libes, NIST
-
-eval spawn -noecho $argv
-set timeout -1
-expect
+++ /dev/null
-.TH UNBUFFER 1 "1 June 1994"
-.SH NAME
-unbuffer \- unbuffer output
-.SH SYNOPSIS
-.B unbuffer
-.I program
-[
-.I args
-]
-.SH INTRODUCTION
-.B unbuffer
-disables the output buffering that occurs when program output
-is redirected.
-For example, suppose you are watching the output from a fifo by running it
-through od and then more.
-.nf
-
- od -c /tmp/fifo | more
-
-.fi
-You will not see anything until a full page
-of output has been produced.
-
-You can disable this automatic buffering as follows:
-
-.nf
-
- unbuffer od -c /tmp/fifo | more
-
-.fi
-.SH BUGS
-
-The man page is longer than the program.
-
-.SH SEE ALSO
-.I
-"Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Programs"
-\fRby Don Libes,
-O'Reilly and Associates, January 1995.
-.SH AUTHOR
-Don Libes, National Institute of Standards and Technology
+++ /dev/null
-#!../expect --
-
-# Name: virterm - terminal emulator using Expect, v1.0, December, 1994
-# Author: Adrian Mariano <adrian@cam.cornell.edu>
-#
-# Derived from Done Libes' tkterm
-
-# This is a program for interacting with applications that use terminal
-# control sequences. It is a subset of Don Libes' tkterm emulator
-# with a compatible interface so that programs can be written to work
-# under both.
-#
-# Internally, it uses arrays instead of the Tk widget. Nonetheless, this
-# code is not as fast as it should be. I need an Expect profiler to go
-# any further.
-#
-# standout mode is not supported like it is in tkterm.
-# the only terminal widget operation that is supported for the user
-# is the "get" operation.
-###############################################
-# Variables that must be initialized before using this:
-#############################################
-set rows 24 ;# number of rows in term
-set cols 80 ;# number of columns in term
-set term myterm ;# name of text widget used by term
-set termcap 1 ;# if your applications use termcap
-set terminfo 0 ;# if your applications use terminfo
- ;# (you can use both, but note that
- ;# starting terminfo is slow)
-set term_shell $env(SHELL) ;# program to run in term
-
-#############################################
-# Readable variables of interest
-#############################################
-# cur_row ;# current row where insert marker is
-# cur_col ;# current col where insert marker is
-# term_spawn_id ;# spawn id of term
-
-#############################################
-# Procs you may want to initialize before using this:
-#############################################
-
-# term_exit is called if the associated proc exits
-proc term_exit {} {
- exit
-}
-
-# term_chars_changed is called after every change to the displayed chars
-# You can use if you want matches to occur in the background (a la bind)
-# If you want to test synchronously, then just do so - you don't need to
-# redefine this procedure.
-proc term_chars_changed {} {
-}
-
-# term_cursor_changed is called after the cursor is moved
-proc term_cursor_changed {} {
-}
-
-# Example tests you can make
-#
-# Test if cursor is at some specific location
-# if {$cur_row == 1 && $cur_col == 0} ...
-#
-# Test if "foo" exists anywhere in line 4
-# if {[string match *foo* [$term get 4.0 4.end]]}
-#
-# Test if "foo" exists at line 4 col 7
-# if {[string match foo* [$term get 4.7 4.end]]}
-#
-# Return contents of screen
-# $term get 1.0 end
-
-#############################################
-# End of things of interest
-#############################################
-
-set blankline ""
-set env(LINES) $rows
-set env(COLUMNS) $cols
-
-set env(TERM) "tt"
-if $termcap {
- set env(TERMCAP) {tt:
- :cm=\E[%d;%dH:
- :up=\E[A:
- :cl=\E[H\E[J:
- :do=^J:
- :so=\E[7m:
- :se=\E[m:
- :nd=\E[C:
- }
-}
-
-if $terminfo {
- set env(TERMINFO) /tmp
- set ttsrc "/tmp/tt.src"
- set file [open $ttsrc w]
-
- puts $file {tt|textterm|Don Libes' tk text widget terminal emulator,
- cup=\E[%p1%d;%p2%dH,
- cuu1=\E[A,
- cuf1=\E[C,
- clear=\E[H\E[J,
- ind=\n,
- cr=\r,
- smso=\E[7m,
- rmso=\E[m,
- }
- close $file
-
- set oldpath $env(PATH)
- set env(PATH) "/usr/5bin:/usr/lib/terminfo"
- if 1==[catch {exec tic $ttsrc} msg] {
- puts "WARNING: puts "tic failed - if you don't have terminfo support on"
- puts "your system, change \"set terminfo 1\" to \"set terminfo 0\"."
- puts "Here is the original error from running tic:"
- puts $msg
- }
- set env(PATH) $oldpath
-
- exec rm $ttsrc
-}
-
-log_user 0
-
-# start a shell and text widget for its output
-set stty_init "-tabs"
-eval spawn $term_shell
-stty rows $rows columns $cols < $spawn_out(slave,name)
-set term_spawn_id $spawn_id
-
-proc term_replace {reprow repcol text} {
- global termdata
- set middle $termdata($reprow)
- set termdata($reprow) \
- [string range $middle 0 [expr $repcol-1]]$text[string \
- range $middle [expr $repcol+[string length $text]] end]
-}
-
-
-proc parseloc {input row col} {
- upvar $row r $col c
- global rows
- switch -glob -- $input \
- end { set r $rows; set c end } \
- *.* { regexp (.*)\\.(.*) $input dummy r c
- if {$r == "end"} { set r $rows }
- }
-}
-
-proc myterm {command first second args} {
- global termdata
- if {[string compare get $command]} {
- send_error "Unknown terminal command: $command\r"
- } else {
- parseloc $first startrow startcol
- parseloc $second endrow endcol
- if {$endcol != "end"} {incr endcol -1}
- if {$startrow == $endrow} {
- set data [string range $termdata($startrow) $startcol $endcol]
- } else {
- set data [string range $termdata($startrow) $startcol end]
- for {set i [expr $startrow + 1]} {$i < $endrow} {incr i} {
- append data $termdata($i)
- }
- append data [string range $termdata($endrow) 0 $endcol]
- }
- return $data
- }
-}
-
-
-proc scrollup {} {
- global termdata blankline
- for {set i 1} {$i < $rows} {incr i} {
- set termdata($i) $termdata([expr $i+1])
- }
- set termdata($rows) $blankline
-}
-
-
-proc term_init {} {
- global rows cols cur_row cur_col term termdata blankline
-
- # initialize it with blanks to make insertions later more easily
- set blankline [format %*s $cols ""]\n
- for {set i 1} {$i <= $rows} {incr i} {
- set termdata($i) "$blankline"
- }
-
- set cur_row 1
- set cur_col 0
-}
-
-
-proc term_down {} {
- global cur_row rows cols term
-
- if {$cur_row < $rows} {
- incr cur_row
- } else {
- scrollup
- }
-}
-
-
-proc term_insert {s} {
- global cols cur_col cur_row term
-
- set chars_rem_to_write [string length $s]
- set space_rem_on_line [expr $cols - $cur_col]
-
- ##################
- # write first line
- ##################
-
- if {$chars_rem_to_write <= $space_rem_on_line} {
- term_replace $cur_row $cur_col \
- [string range $s 0 [expr $space_rem_on_line-1]]
- incr cur_col $chars_rem_to_write
- term_chars_changed
- return
- }
-
- set chars_to_write $space_rem_on_line
- set newline 1
-
- term_replace $cur_row $cur_col\
- [string range $s 0 [expr $space_rem_on_line-1]]
-
- # discard first line already written
- incr chars_rem_to_write -$chars_to_write
- set s [string range $s $chars_to_write end]
-
- # update cur_col
- incr cur_col $chars_to_write
- # update cur_row
- if $newline {
- term_down
- }
-
- ##################
- # write full lines
- ##################
- while {$chars_rem_to_write >= $cols} {
- term_replace $cur_row 0 [string range $s 0 [expr $cols-1]]
-
- # discard line from buffer
- set s [string range $s $cols end]
- incr chars_rem_to_write -$cols
-
- set cur_col 0
- term_down
- }
-
- #################
- # write last line
- #################
-
- if {$chars_rem_to_write} {
- term_replace $cur_row 0 $s
- set cur_col $chars_rem_to_write
- }
-
- term_chars_changed
-}
-
-term_init
-
-expect_before {
- -i $term_spawn_id
- -re "^\[^\x01-\x1f]+" {
- # Text
- term_insert $expect_out(0,string)
- term_cursor_changed
- } "^\r" {
- # (cr,) Go to to beginning of line
- set cur_col 0
- term_cursor_changed
- } "^\n" {
- # (ind,do) Move cursor down one line
- term_down
- term_cursor_changed
- } "^\b" {
- # Backspace nondestructively
- incr cur_col -1
- term_cursor_changed
- } "^\a" {
- # Bell, pass back to user
- send_user "\a"
- } "^\t" {
- # Tab, shouldn't happen
- send_error "got a tab!?"
- } eof {
- term_exit
- } "^\x1b\\\[A" {
- # (cuu1,up) Move cursor up one line
- incr cur_row -1
- term_cursor_changed
- } "^\x1b\\\[C" {
- # (cuf1,nd) Nondestructive space
- incr cur_col
- term_cursor_changed
- } -re "^\x1b\\\[(\[0-9]*);(\[0-9]*)H" {
- # (cup,cm) Move to row y col x
- set cur_row [expr $expect_out(1,string)+1]
- set cur_col $expect_out(2,string)
- term_cursor_changed
- } "^\x1b\\\[H\x1b\\\[J" {
- # (clear,cl) Clear screen
- term_init
- term_cursor_changed
- } "^\x1b\\\[7m" { # unsupported
- # (smso,so) Begin standout mode
- # set term_standout 1
- } "^\x1b\\\[m" { # unsupported
- # (rmso,se) End standout mode
- # set term_standout 0
- }
-}
-
-
-proc term_expect {args} {
- global cur_row cur_col # used by expect_background actions
-
- set desired_timeout [
- uplevel {
- if [info exists timeout] {
- set timeout
- } else {
- uplevel #0 {
- if {[info exists timeout]} {
- set timeout
- } else {
- expr 10
- }
- }
- }
- }
- ]
-
- set timeout $desired_timeout
-
- set timeout_act {}
-
- set argc [llength $args]
- if {$argc%2 == 1} {
- lappend args {}
- incr argc
- }
-
- for {set i 0} {$i<$argc} {incr i 2} {
- set act_index [expr $i+1]
- if {[string compare timeout [lindex $args $i]] == 0} {
- set timeout_act [lindex $args $act_index]
- set args [lreplace $args $i $act_index]
- incr argc -2
- break
- }
- }
-
- set got_timeout 0
-
- set start_time [timestamp]
-
- while {![info exists act]} {
- expect timeout {set got_timeout 1}
- set timeout [expr $desired_timeout - [timestamp] + $start_time]
- if {! $got_timeout} \
- {
- for {set i 0} {$i<$argc} {incr i 2} {
- if {[uplevel [lindex $args $i]]} {
- set act [lindex $args [incr i]]
- break
- }
- }
- } else { set act $timeout_act }
-
- if {![info exists act]} {
-
- }
- }
-
- set code [catch {uplevel $act} string]
- if {$code > 4} {return -code $code $string}
- if {$code == 4} {return -code continue}
- if {$code == 3} {return -code break}
- if {$code == 2} {return -code return}
- if {$code == 1} {return -code error -errorinfo $errorInfo \
- -errorcode $errorCode $string}
- return $string
-}
-
-
-# ======= end of terminal emulator ========
-
-# The following is a program to interact with the Cornell Library catalog
-
-
-proc waitfornext {} {
- global cur_row cur_col term
- term_expect {expr {$cur_col==15 && $cur_row == 24 &&
- " NEXT COMMAND: " == [$term get 24.0 24.16]}} {}
-}
-
-proc sendcommand {command} {
- global cur_col
- exp_send $command
- term_expect {expr {$cur_col == 79}} {}
-}
-
-proc removespaces {intext} {
- regsub -all " *\n" $intext \n intext
- regsub "\n+$" $intext \n intext
- return $intext
-}
-
-proc output {text} {
- exp_send_user $text
-}
-
-
-
-proc connect {} {
- global term
- term_expect {regexp {.*[>%]} [$term get 1.0 3.end]}
- exp_send "tn3270 notis.library.cornell.edu\r"
- term_expect {regexp "desk" [$term get 19.0 19.end]} {
- exp_send "\r"
- }
- waitfornext
- exp_send_error "connected.\n\n"
-}
-
-
-proc dosearch {search} {
- global term
- exp_send_error "Searching for '$search'..."
- if [string match ?=* "$search"] {set typ ""} else {set typ "k="}
- sendcommand "$typ$search\r"
- waitfornext
- set countstr [$term get 2.17 2.35]
- if {![regsub { Entries Found *} $countstr "" number]} {
- set number 1
- exp_send_error "one entry found.\n\n"
- return 1
- }
- if {$number == 0} {
- exp_send_error "no matches.\n\n"
- return 0
- }
- exp_send_error "$number entries found.\n"
- if {$number > 250} {
- exp_send_error "(only the first 250 can be displayed)\n"
- }
- exp_send_error "\n"
- return $number
-}
-
-
-proc getshort {count} {
- global term
- output [removespaces [$term get 5.0 19.0]]
- while {[regexp "CONTINUED on next page" [$term get 19.0 19.end]]} {
- sendcommand "for\r"
- waitfornext
- output [removespaces [$term get 5.0 19.0]]
- }
-}
-
-proc getonecitation {} {
- global term
- output [removespaces [$term get 4.0 19.0]]
- while {[regexp "FORward page" [$term get 20.0 20.end]]} {
- sendcommand "for\r"
- waitfornext
- output [removespaces [$term get 5.0 19.0]]
- }
-}
-
-
-proc getcitlist {} {
- global term
- getonecitation
- set citcount 1
- while {[regexp "NEXt record" [$term get 20.0 21.end]]} {
- sendcommand "nex\r"
- waitfornext
- getonecitation
- incr citcount
- if {$citcount % 10 == 0} {exp_send_error "$citcount.."}
- }
-}
-
-proc getlong {count} {
- if {$count != 1} {
- sendcommand "1\r"
- waitfornext
- }
- sendcommand "lon\r"
- waitfornext
- getcitlist
-}
-
-proc getmed {count} {
- if {$count != 1} {
- sendcommand "1\r"
- waitfornext
- }
- sendcommand "bri\r"
- waitfornext
- getcitlist
-}
-
-#################################################################
-#
-set help {
-libsearch version 1.0 by Adrian Mariano (adrian@cam.cornell.edu)
-
-Invocation: libsearch [options] search text
-
- -i : interactive
- -s : short listing
- -l : long listing
- -o file : output file (default stdout)
- -h : print out list of options and version number
- -H : print terse keyword search help
-
-The search will be a keyword search.
-Example: libsearch -i sound and arabic
-
-}
-
-#################################################################
-
-proc searchhelp {} {
- send_error {
-? truncation wildcard default operator is AND
-
-AND - both words appear in record
-OR - one of the words appears
-NOT - first word appears, second words does not
-ADJ - words are adjacent
-SAME- words appear in the same field (any order)
-
-.su. - subject b.fmt. - books eng.lng. - English
-.ti. - title m.fmt. - music spa.lng. - Spanish
-.au. - author s.fmt. - serials fre.lng. - French
-
-.dt. or .dt1. -- limits to a specific publication year. E.g., 1990.dt.
-
-}
-}
-
-proc promptuser {prompt} {
- exp_send_error "$prompt"
- expect_user -re "(.*)\n"
- return "$expect_out(1,string)"
-}
-
-
-set searchtype 1
-set outfile ""
-set search ""
-set interactive 0
-
-while {[llength $argv]>0} {
- set flag [lindex $argv 0]
- switch -glob -- $flag \
- "-i" { set interactive 1; set argv [lrange $argv 1 end]} \
- "-s" { set searchtype 0; set argv [lrange $argv 1 end] } \
- "-l" { set searchtype 2; set argv [lrange $argv 1 end] } \
- "-o" { set outfile [lindex $argv 1]; set argv [lrange $argv 2 end] } \
- "-H" { searchhelp; exit } \
- "-h" { send_error "$help"; exit } \
- "-*" { send_error "\nUnknown option: $flag\n$help";exit }\
- default { set search [join $argv]; set argv {};}
-}
-if { "$search" == "" } {
- send_error "No search specified\n$help"
- exit
-}
-
-exp_send_error "Connecting to the library..."
-
-set timeout 200
-
-trap { log_user 1;exp_send "\003";
- expect_before
- expect tn3270 {exp_send "quit\r"}
- expect "Connection closed." {exp_send "exit\r"}
- expect eof ; send_error "\n";
- exit} SIGINT
-
-
-connect
-
-set result [dosearch $search]
-
-if {$interactive} {
- set quit 0
- while {!$quit} {
- if {!$result} {
- switch "[promptuser {(h)elp (n)ewsearch (q)uit? }]" {
- n { }
- h { searchhelp }
- q { set quit 1}
- }
- } else {
- switch "[promptuser {(s)hort (m)ed (l)ong (h)elp (n)ewsearch (q)uit? }]" {
- s { getshort $result; ;}
- l { getlong $result; ;}
- m { getmed $result; ; }
- n { research; }
- h { searchhelp }
- q { set quit 1; }
- }
- }
- }
-} else {
- if {$result} {
- switch $searchtype {
- 0 { getshort $result}
- 1 { getmed $result }
- 2 { getlong $result }
- }
- }
-}
-
-
-
-
-
-
+++ /dev/null
-#!/depot/path/expect -f
-
-
-# separate address into user and host
-regexp (.*)@(.*) $argv ignore user host
-
-log_user 0
-set timeout -1
-
-# host might be an mx record, convert to a real host via nslookup
-spawn nslookup
-expect "> "
-send "set query=mx\r"
-expect "> "
-send "$host\r"
-expect {
- "No mail exchanger" {}
- -re "mail exchanger = (\[^\r]*)" {
- set host $expect_out(1,string)
- }
-}
-
-spawn telnet $host smtp
-expect "220*\r\n"
-send "vrfy $user\r"
-expect "250" {send_user "GOOD\n"} \
- "550" {send_user "BAD\n"}
+++ /dev/null
-#!../expect -f
-
-# weather - Expect script to get the weather (courtesy University of Michigan)
-# Don Libes
-# Version 1.9
-
-# local weather is retrieved if no argument
-# argument is the National Weather Service designation for an area
-# I.e., WBC = Washington DC (oh yeah, that's obvious)
-
-exp_version -exit 5.0
-
-if $argc>0 {set code $argv} else {set code "WBC"}
-
-proc timedout {} {
- send_user "Weather server timed out. Try again later when weather server is not so busy.\n"
- exit 1
-}
-
-# delete special weather statement question
-proc delete_special {s} {
- set x [string first " ******" $s]
- return [join [lrange [split $s ""] 0 $x] ""]
-}
-
-set timeout 60
-log_user 0
-
-set env(TERM) vt100 ;# actual value doesn't matter, just has to be set
-
-spawn telnet downwind.sprl.umich.edu 3000
-match_max 100000
-for {} 1 {} {
- expect timeout {
- send_user "failed to contact weather server\n"
- exit
- } "Press Return to continue*" {
- # this prompt used sometimes, eg, upon opening connection
- send "\r"
- } "Press Return for menu*" {
- # this prompt used sometimes, eg, upon opening connection
- send "\r"
- } "M to display main menu*" {
- # sometimes ask this if there is a weather watch in effect
- send "M\r"
- } "Change scrolling to screen*Selection:" {
- break
- } eof {
- send_user "failed to telnet to weather server\n"
- exit
- }
-}
-send "C\r"
-expect timeout timedout "Selection:"
-send "4\r"
-expect timeout timedout "Selection:"
-send "1\r"
-expect timeout timedout "Selection:"
-send "1\r"
-expect timeout timedout "city code:"
-send "$code\r"
-expect $code ;# discard this
-
-for {} 1 {} {
- expect timeout {
- timedout
- } "Press Return to continue*:*" {
- send_user "\n[delete_special $expect_out(buffer)]\n"
- send "\r"
- } "Press Return to display statement, M for menu:*" {
- send_user "\n[delete_special $expect_out(buffer)]\n"
- send "\r"
- } -re "(.*)CITY FORECAST MENU.*Selection:" {
- send_user "\n$expect_out(1,string)\n"
- break
- }
-}
-
-send "X\r"
-expect
-
+++ /dev/null
-#!../expect --
-
-# share an xterm with other users
-# See xkibitz(1) man page for complete info.
-# Compare with kibitz.
-# Author: Don Libes, NIST
-# Version: 1.2
-
-proc help {} {
- puts "Commands Meaning"
- puts "-------- -------"
- puts "return return to program"
- puts "= list"
- puts "+ <display> add"
- puts "- <tag> drop"
- puts "where <display> is an X display name such as nist.gov or nist.gov:0.0"
- puts "and <tag> is a tag from the = command."
- puts "+ and - require whitespace before argument."
- puts {return command must be spelled out ("r", "e", "t", ...).}
-}
-
-proc prompt1 {} {
- return "xkibitz> "
-}
-
-proc h {} help
-proc ? {} help
-
-# disable history processing - there seems to be some incestuous relationship
-# between history and unknown in Tcl 8.0
-proc history {args} {}
-proc unknown {args} {
- puts "$args: invalid command"
- help
-}
-
-set tag2pid(0) [pid]
-set pid2tty([pid]) "/dev/tty"
-if [info exists env(DISPLAY)] {
- set pid2display([pid]) $env(DISPLAY)
-} else {
- set pid2display([pid]) ""
-}
-
-# small int allowing user to more easily identify display
-# maxtag always points at highest in use
-set maxtag 0
-
-proc + {display} {
- global ids pid2display pid2tag tag2pid maxtag pid2sid
- global pid2tty env
-
- if ![string match *:* $display] {
- append display :0.0
- }
-
- if {![info exists env(XKIBITZ_XTERM_ARGS)]} {
- set env(XKIBITZ_XTERM_ARGS) ""
- }
-
- set dummy1 [open /dev/null]
- set dummy2 [open /dev/null]
- spawn -pty -noecho
- close $dummy1
- close $dummy2
-
- stty raw -echo < $spawn_out(slave,name)
- # Linux needs additional stty, sounds like a bug in its stty to me.
- # raw should imply this stuff, no?
- stty -icrnl -icanon < $spawn_out(slave,name)
-
- regexp ".*(.)(.)" $spawn_out(slave,name) dummy c1 c2
- if {[string compare $c1 "/"] == 0} {
- # On Pyramid and AIX, ttynames such as /dev/pts/1
- # requre suffix to be padded with a 0
- set c1 0
- }
-
- set pid [eval exec xterm \
- -display $display \
- -geometry [stty columns]x[stty rows] \
- -S$c1$c2$spawn_out(slave,fd) \
- $env(XKIBITZ_XTERM_ARGS) &]
- close -slave
-
- # xterm first sends back window id, discard
- log_user 0
- expect {
- eof {wait;return}
- \n
- }
- log_user 1
-
- lappend ids $spawn_id
- set pid2display($pid) $display
- incr maxtag
- set tag2pid($maxtag) $pid
- set pid2tag($pid) $maxtag
- set pid2sid($pid) $spawn_id
- set pid2tty($pid) $spawn_out(slave,name)
- return
-}
-
-proc = {} {
- global pid2display tag2pid pid2tty
-
- puts "Tag Size Display"
- foreach tag [lsort -integer [array names tag2pid]] {
- set pid $tag2pid($tag)
- set tty $pid2tty($pid)
-
- puts [format "%3d [stty columns < $tty]x[stty rows < $tty] $pid2display($pid)" $tag]
- }
-}
-
-proc - {tag} {
- global tag2pid pid2tag pid2display maxtag ids pid2sid
- global pid2tty
-
- if ![info exists tag2pid($tag)] {
- puts "no such tag"
- return
- }
- if {$tag == 0} {
- puts "cannot drop self"
- return
- }
-
- set pid $tag2pid($tag)
-
- # close and remove spawn_id from list
- set spawn_id $pid2sid($pid)
- set index [lsearch $ids $spawn_id]
- set ids [lreplace $ids $index $index]
-
- exec kill -9 $pid
- close
- wait
-
- unset tag2pid($tag)
- unset pid2tag($pid)
- unset pid2display($pid)
- unset pid2sid($pid)
- unset pid2tty($pid)
-
- # lower maxtag if possible
- while {![info exists tag2pid($maxtag)]} {
- incr maxtag -1
- }
-}
-
-exit -onexit {
- unset pid2display([pid]) ;# avoid killing self
-
- foreach pid [array names pid2display] {
- catch {exec kill -9 $pid}
- }
-}
-
-trap exit HUP
-
-trap {
- set r [stty rows]
- set c [stty columns]
- stty rows $r columns $c < $app_tty
- foreach pid [array names pid2tty] {
- if {$pid == [pid]} continue
- stty rows $r columns $c < $pid2tty($pid)
- }
-} WINCH
-
-set escape \035 ;# control-right-bracket
-set escape_printable "^\]"
-
-while [llength $argv]>0 {
- set flag [lindex $argv 0]
- switch -- $flag \
- "-escape" {
- set escape [lindex $argv 1]
- set escape_printable $escape
- set argv [lrange $argv 2 end]
- } "-display" {
- + [lindex $argv 1]
- set argv [lrange $argv 2 end]
- } default {
- break
- }
-}
-
-if [llength $argv]>0 {
- eval spawn -noecho $argv
-} else {
- spawn -noecho $env(SHELL)
-}
-set prog $spawn_id
-set app_tty $spawn_out(slave,name)
-
-puts "Escape sequence is $escape_printable"
-
-interact {
- -input $user_spawn_id -reset $escape {
- puts "\nfor help enter: ? or h or help"
- interpreter
- } -output $prog
- -input ids -output $prog
- -input $prog -output $user_spawn_id -output ids
-}
-
+++ /dev/null
-.TH XKIBITZ 1 "06 October 1994"
-.SH NAME
-xkibitz \- allow multiple people to interact in an xterm
-.SH SYNOPSIS
-.B xkibitz
-[
-.I xkibitz-args
-] [
-.I program program-args...
-]
-.br
-.SH INTRODUCTION
-.B xkibitz
-allows users in separate xterms to share one shell (or any program
-that runs in an xterm). Uses include:
-.RS
-.TP 4
-\(bu
-A novice user can ask an expert user for help. Using
-.BR xkibitz ,
-the expert can see what the user is doing, and offer advice or
-show how to do it right.
-.TP
-\(bu
-By running
-.B xkibitz
-and then starting a full-screen editor, people may carry out a
-conversation, retaining the ability to scroll backwards,
-save the entire conversation, or even edit it while in progress.
-.TP
-\(bu
-People can team up on games, document editing, or other cooperative
-tasks where each person has strengths and weaknesses that complement one
-another.
-.TP
-\(bu
-If you want to have a large number of people do an on-line code
-walk-through, you can sit two in front of each workstation, and then
-connect them all together while you everyone looks at code together
-in the editor.
-.SH USAGE
-To start
-.BR xkibitz ,
-one user (the master) runs xkibitz with no arguments.
-
-.B xkibitz
-starts a new shell (or another program, if given on the command
-line). The user can interact normally with the shell, or
-upon entering an escape (described when xkibitz starts) can add
-users to the interaction.
-
-To add users, enter "+ display" where display is the X display name.
-If there is no ":X.Y" in the display name, ":0.0" is assumed.
-The master user must have permission to access each display.
-Each display is assigned
-a tag \- a small integer which can be used to reference the display.
-
-To show the current tags and displays, enter "=".
-
-To drop a display, enter "- tag" where tag is the display's tag
-according to the "=" command.
-
-To return to the shared shell, enter "return". Then the keystrokes of
-all users become the input of the shell. Similarly, all users receive
-the output from the shell.
-
-To terminate
-.B xkibitz
-it suffices to terminate the shell itself. For example, if any user
-types ^D (and the shell accepts this to be EOF), the shell terminates
-followed by
-.BR xkibitz .
-
-Normally, all characters are passed uninterpreted. However, in the
-escape dialogue the user talks directly to the
-.B xkibitz
-interpreter. Any
-.BR Expect (1)
-or
-.BR Tcl (3)
-commands may also be given.
-Also, job control may be used while in the interpreter, to, for example,
-suspend or restart
-.BR xkibitz .
-
-Various processes
-can produce various effects. For example, you can emulate a multi-way write(1)
-session with the command:
-
- xkibitz sleep 1000000
-.PP
-.SH ARGUMENTS
-.B xkibitz
-understands a few special arguments
-which should appear before the
-.I program
-name (if given).
-Each argument should be separated by whitespace.
-If the arguments themselves takes arguments,
-these should also be separated by whitespace.
-
-.B \-escape
-sets the escape character. The default escape character is ^].
-
-.B \-display
-adds a display much like the "+" command. Multiple \-display flags
-can be given. For example, to start up xkibitz with three additional
-displays:
-
- xkibitz -display mercury -display fox -display dragon:1.0
-
-.SH CAVEATS
-Due to limitations in both X and UNIX, resize propagation is weak.
-
-When the master user resizes the xterm, all the other xterms are logically
-resized.
-Unfortunately, xkibitz cannot force the physical xterm size to correspond
-with the logical xterm sizes.
-
-The other users are free to resize their xterm but their sizes are not
-propagated. The master can check the logical sizes with the "=" command.
-
-Deducing the window size is a non-portable operation. The code is known
-to work for recent versions of SunOS, AIX, Unicos, and HPUX. Send back
-mods if you add support for anything else.
-.SH ENVIRONMENT
-The environment variable SHELL is used to determine and start a shell, if no
-other program is given on the command line.
-
-If the environment variable DISPLAY is defined, its value is used for the
-display name of the
-.B xkibitz
-master (the display with tag number 0). Otherwise this name remains empty.
-
-Additional arguments may be passed to new xterms through
-the environment variable XKIBITZ_XTERM_ARGS.
-For example, to create xterms
-with a scrollbar and a green pointer cursor:
-.nf
-
- XKIBITZ_XTERM_ARGS="-sb -ms green"
- export XKIBITZ_XTERM_ARGS
-
-.fi
-(this is for the Bourne shell - use whatever syntax is appropriate for your
-favorite shell). Any option can be given that is valid for the
-.B xterm
-command, with the exception of
-.BR -display ,
-.B -geometry
-and
-.BI -S
-as those are set by
-.BR xkibitz .
-.SH SEE ALSO
-.BR Tcl (3),
-.BR libexpect (3)
-.BR kibitz (1)
-.br
-.I
-"Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Programs"
-\fRby Don Libes,
-O'Reilly and Associates, January 1995.
-.br
-.I
-"kibitz \- Connecting Multiple Interactive Programs Together", \fRby Don Libes,
-Software \- Practice & Experience, John Wiley & Sons, West Sussex, England,
-Vol. 23, No. 5, May, 1993.
-.SH AUTHOR
-Don Libes, National Institute of Standards and Technology
+++ /dev/null
-#!../expectk --
-
-# This script acts as a front-end for xpilot. Run it in the background,
-# and it will pop up a window for each server it finds running. After
-# you run it, press the "?" button for more info.
-
-# Store the filename of your xpilot client in the following variable.
-set xpilot /usr/local/bin/xpilot
-
-# Author: Don Libes, NIST, 12/29/92
-
-# I never have figured out how to get the alias out of xrdb. For now, just
-# read it ourselves out of .Xdefaults - ugh.
-
-log_user 0
-
-set timeout 60
-
-proc probe {} {
- global max db hosts world
-
- set timeout -1
-
- expect_before eof {wait;return 0}
-
- expect -re "Server on (.*). Enter command> " {
- exp_send "S\r"
- set host $expect_out(1,string)
- # replace dots in hostnames by underscores
- regsub -all . $host _ host
- # force lowercase to avoid Tk widget name problems
- set host [string tolower $host]
- lappend hosts $host
- }
- expect -re "WORLD\[^:]*: (\[^\r]*)\r" {
- set worldtmp $expect_out(1,string)
- }
- expect -re "AUTHOR\[^:]*: (\[^\r]*)\r" {
- set author $expect_out(1,string)
- }
- set world($host) "$worldtmp by $author"
-
- # skip over junk to get players
- expect {
- -re -+ {}
- -re "Enter command> " {
- set max($host) 0
- display $host
- return 1
- }
- }
- set i 0
- expect {
- -re "\\.\\.\\. . (................) (...) *(\[^ ]*) *(\[^\r]*)\r" {
- # strip trailing blanks
- set alias [string trimright $expect_out(1,string)]
- set db($host,$i,alias) $alias
-
- # strip leading zeros
- scan $expect_out(2,string) %d db($host,$i,life)
-
- set db($host,$i,score) $expect_out(3,string)
-
- set db($host,name,$alias) $expect_out(4,string)
-
- incr i
- exp_continue
- }
- -re "Enter command>"
-
- }
- set max($host) $i
- display $host
-
- return 1
-}
-
-proc resize {w a b} {
- # 27 is a guess at a fixed-width sufficiently comfortable for
- # the variable-width font. I don't know how to do better.
- $w configure -width 27
-}
-
-proc play {host} {
- global xpilot alias
-
- exec xhost $host
- catch {exec $xpilot -name $alias($host) -join $host} status
-}
-
-proc show-help {x y msg} {
- catch {destroy .help}
- toplevel .help
- wm geometry .help +$x+$y
-
- message .help.text -text $msg
-
- button .help.ok -text "ok" -command {destroy .help}
- pack .help.text
- pack .help.ok -fill x
-}
-
-# pop up window with alias
-proc show-alias {host seln x y} {
- global db
-
- catch {destroy .alias}
- toplevel .alias
- wm geometry .alias +$x+$y
- wm transient .alias .
-
- regexp "(.*\[^ ]) +\[-0-9]+ +\[0-9]+$" $seln discard alias
-
- button .alias.b -text "$db($host,name,$alias)" -command {
- destroy .alias
- }
- .alias.b config -padx 1 -pady 1 -highlightthickness 0
- pack .alias.b
-}
-
-proc help {x y} {
- show-help $x $y "xpstat - written by Don Libes, NIST, December 29, 1992
-
-This script acts as a front-end for xpilot. Run it in the background, and it will pop up a window for each server it finds running. Press the \"?\" button for this info.
-
-This program polls each xpilot server once a minute. To make it poll immediately, press \"update\". Press \"play as\" to enter the current game with the alias to the right. Edit to taste. (Your alias is initialized from the value of xpilot.name in ~/.Xdefaults.)
-
-Double-click the left button on an alias to see the real user name. To remove the user name window, click on it with the left button.
-
-Pan the world/author text, player list, or your own alias by holding the middle mouse button down and moving the mouse."
-}
-
-# if user presses "update" try to update screen immediately
-proc prod {x y} {
- global cat_spawn_id updateflag
-
- if $updateflag {
- show-help $x $y "I heard you, gimme a break. I'm waiting for the xpilot server to respond..."
- }
- set updateflag 1
-
- exp_send -i $cat_spawn_id "\r"
-}
-
-proc display {host} {
- global world db alias max env
-
- set w .$host
- #if 0==[llength [info com $w]]
- if ![winfo exists $w] {
-
- # window does not exist, create it
-
- toplevel $w -class xpstat
- wm minsize $w 1 1
- wm title $w "xpilot@$host"
- wm iconname $w "$host xpilot stats"
- entry $w.world -state disabled -textvar world($host)
-
- listbox $w.players -yscroll "resize $w.players" -font 7x13bold
- $w.players config -highlightthickness 0 -border 0
- $w.world config -highlightthickness 0
-
- bind $w.players <Double-Button-1> {
- scan %W ".%%\[^.]" host
- show-alias $host [selection get] %X %Y
- }
-
- message $w.msg -text "no players" -aspect 1000 -justify center
-
- button $w.help -text ? -command {
- help 10 20
- }
-
- button $w.update -text "update"
- bind $w.update <1> {
- after 1 prod %X %Y
- }
-
- button $w.play -text "play as"
- bind $w.play <1> {
- scan %W ".%%\[^.]" host
- after 1 play $host
- }
-
- entry $w.alias -textvar alias($host) -width 10
- set alias($host) $env(USER)
-
- bind $w.alias <Return> {
- scan %W ".%%\[^.]" host
- play $host
- }
-
- $w.play config -padx 1 -pady 1 -highlightthickness 0
- $w.update config -padx 1 -pady 1 -highlightthickness 0
- $w.help config -padx 1 -pady 1 -highlightthickness 0
- $w.alias config -highlightthickness 0
-
- pack $w.world -expand 1 -fill x
- pack $w.msg
- pack $w.help $w.update $w.play -side left
- pack $w.alias -side left -expand 1 -fill x
- set max($host,was) 0
- }
-
- if $max($host)==0 {
- # put up "no players" message?
- if $max($host,was)>0 {
- pack $w.msg -after $w.world -fill x -side top
- pack forget $w.world
- }
- } else {
- # remove "no players" message?
- if $max($host,was)==0 {
- pack $w.players -after $w.world -side top
- pack forget $w.msg
- }
- }
-
- $w.players delete 0 end
-
- for {set i 0} {$i<$max($host)} {incr i} {
- $w.players insert end [format "%-17s %4d %d" \
- $db($host,$i,alias) \
- $db($host,$i,score) \
- $db($host,$i,life) \
- ]
- }
-
- set max($host,was) $max($host)
-}
-
-wm withdraw .
-set oldhosts {}
-
-set updateflag 0 ;# 1 if user pressed "update" button
-
-# look for desired alias in the .Xdefaults file
-set status [catch {exec egrep "xpilot.name:" [glob ~/.Xdefaults]} output]
-if $status==0 {
- regexp "xpilot.name:\[ \t]*(\[^\r]*)" $output dummy env(USER)
-}
-
-spawn cat -u; set cat_spawn_id $spawn_id
-
-while 1 {
- global xpilot hosts
-
- set hosts {}
-
- eval spawn $xpilot $argv
- while {[probe]} {exp_send "N\r"}
- catch {expect_before} ;# disable expect_before from inside probe
-
- # clean up hosts that no longer are running xpilots
-
- foreach host $oldhosts {
- # if host not in hosts
- if -1==[lsearch $hosts $host] {
- destroy .$host
- }
- }
- set oldhosts $hosts
-
- set updateflag 0
-
- # sleep for a little while, subject to click from "update" button
- expect -i $cat_spawn_id -re "...." ;# two crlfs
-}
+++ /dev/null
-#!/depot/path/expect --
-# xrlogin - rlogin but with current DISPLAY
-#
-# You can extend this idea to save any arbitrary information across rlogin
-# Don Libes - Oct 17, 1991.
-
-if {[llength $argv] != 1} {
- puts "usage: xrlogin remotehost"
- exit
-}
-
-set prompt "(%|#|\\$) $" ;# default prompt
-catch {set prompt $env(EXPECT_PROMPT)}
-
-set timeout -1
-eval spawn rlogin $argv
-expect eof exit -re $prompt
-if [string match "unix:0.0" $env(DISPLAY)] {
- set env(DISPLAY) "[exec hostname].[exec domainname]:0.0\r"
-}
-send "setenv DISPLAY $env(DISPLAY)\r"
-interact
+++ /dev/null
-/* exp_clib.c - top-level functions in the expect C library, libexpect.a
-
-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.
-*/
-
-#include "expect_cf.h"
-#include <stdio.h>
-#include <setjmp.h>
-#ifdef HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#include <sys/types.h>
-#include <sys/ioctl.h>
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#ifdef TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-# include <sys/time.h>
-# else
-# include <time.h>
-# endif
-#endif
-
-#ifdef CRAY
-# ifndef TCSETCTTY
-# if defined(HAVE_TERMIOS)
-# include <termios.h>
-# else
-# include <termio.h>
-# endif
-# endif
-#endif
-
-#ifdef HAVE_SYS_FCNTL_H
-# include <sys/fcntl.h>
-#else
-# include <fcntl.h>
-#endif
-
-#ifdef HAVE_STRREDIR_H
-#include <sys/strredir.h>
-# ifdef SRIOCSREDIR
-# undef TIOCCONS
-# endif
-#endif
-
-#include <signal.h>
-/*#include <memory.h> - deprecated - ANSI C moves them into string.h */
-#include "string.h"
-
-#include <errno.h>
-#include "exp_rename.h"
-#define EXP_AVOID_INCLUDING_TCL_H
-#include "expect.h"
-#include "exp_int.h"
-
-#include "exp_printify.h"
-
-#ifdef NO_STDLIB_H
-#include "../compat/stdlib.h"
-#else
-#include <stdlib.h> /* for malloc */
-#endif
-
-#define EXP_MATCH_MAX 2000
-/* public */
-char *exp_buffer = 0;
-char *exp_buffer_end = 0;
-char *exp_match = 0;
-char *exp_match_end = 0;
-int exp_match_max = EXP_MATCH_MAX; /* bytes */
-int exp_full_buffer = FALSE; /* don't return on full buffer */
-int exp_remove_nulls = TRUE;
-int exp_timeout = 10; /* seconds */
-int exp_pty_timeout = 5; /* seconds - see CRAY below */
-int exp_autoallocpty = TRUE; /* if TRUE, we do allocation */
-int exp_pty[2]; /* master is [0], slave is [1] */
-int exp_pid;
-char *exp_stty_init = 0; /* initial stty args */
-int exp_ttycopy = TRUE; /* copy tty parms from /dev/tty */
-int exp_ttyinit = TRUE; /* set tty parms to sane state */
-int exp_console = FALSE; /* redirect console */
-void (*exp_child_exec_prelude)() = 0;
-
-jmp_buf exp_readenv; /* for interruptable read() */
-int exp_reading = FALSE; /* whether we can longjmp or not */
-
-void debuglog();
-int getptymaster();
-int getptyslave();
-int Exp_StringMatch();
-
-#define sysreturn(x) return(errno = x, -1)
-
-void exp_init_pty();
-
-/*
- The following functions are linked from the Tcl library. They
- don't cause anything else in the library to be dragged in, so it
- shouldn't cause any problems (e.g., bloat).
-
- The functions are relatively small but painful enough that I don't care
- to recode them. You may, if you absolutely want to get rid of any
- vestiges of Tcl.
-*/
-extern char *TclGetRegError();
-extern void TclRegError();
-char *Tcl_ErrnoMsg();
-
-
-
-static unsigned int bufsiz = 2*EXP_MATCH_MAX;
-
-static struct f {
- int valid;
-
- char *buffer; /* buffer of matchable chars */
- char *buffer_end; /* one beyond end of matchable chars */
- /*char *match; /* start of matched string */
- char *match_end; /* one beyond end of matched string */
- int msize; /* size of allocate space */
- /* actual size is one larger for null */
-} *fs = 0;
-
-static int fd_alloc_max = -1; /* max fd allocated */
-
-/* translate fd or fp to fd */
-static struct f *
-fdfp2f(fd,fp)
-int fd;
-FILE *fp;
-{
- if (fd == -1) return(fs + fileno(fp));
- else return(fs + fd);
-}
-
-static struct f *
-fd_new(fd)
-int fd;
-{
- int i, low;
- struct f *fp;
- struct f *newfs; /* temporary, so we don't lose old fs */
-
- if (fd > fd_alloc_max) {
- if (!fs) { /* no fd's yet allocated */
- newfs = (struct f *)malloc(sizeof(struct f)*(fd+1));
- low = 0;
- } else { /* enlarge fd table */
- newfs = (struct f *)realloc((char *)fs,sizeof(struct f)*(fd+1));
- low = fd_alloc_max+1;
- }
- fs = newfs;
- fd_alloc_max = fd;
- for (i = low; i <= fd_alloc_max; i++) { /* init new entries */
- fs[i].valid = FALSE;
- }
- }
-
- fp = fs+fd;
-
- if (!fp->valid) {
- /* initialize */
- fp->buffer = malloc((unsigned)(bufsiz+1));
- if (!fp->buffer) return 0;
- fp->msize = bufsiz;
- fp->valid = TRUE;
- }
- fp->buffer_end = fp->buffer;
- fp->match_end = fp->buffer;
- return fp;
-
-}
-
-/* returns fd of master side of pty */
-int
-exp_spawnv(file,argv)
-char *file;
-char *argv[]; /* some compiler complains about **argv? */
-{
- int cc;
- int errorfd; /* place to stash fileno(stderr) in child */
- /* while we're setting up new stderr */
- int ttyfd;
- int sync_fds[2];
- int sync2_fds[2];
- char sync_byte;
-#ifdef PTYTRAP_DIES
- int slave_write_ioctls = 1;
- /* by default, slave will be write-ioctled this many times */
-#endif
-
- static int first_time = TRUE;
-
- if (first_time) {
- first_time = FALSE;
- exp_init_pty();
- exp_init_tty();
- }
-
- if (!file || !argv) sysreturn(EINVAL);
- if (!argv[0] || strcmp(file,argv[0])) {
- debuglog("expect: warning: file (%s) != argv[0] (%s)\n",
- file,
- argv[0]?argv[0]:"");
- }
-
-#ifdef PTYTRAP_DIES
-/* any extraneous ioctl's that occur in slave must be accounted for
-when trapping, see below in child half of fork */
-#if defined(TIOCSCTTY) && !defined(CIBAUD) && !defined(sun) && !defined(hp9000s300)
- slave_write_ioctls++;
-#endif
-#endif /*PTYTRAP_DIES*/
-
- if (exp_autoallocpty) {
- if (0 > (exp_pty[0] = getptymaster())) sysreturn(ENODEV);
- }
- fcntl(exp_pty[0],F_SETFD,1); /* close on exec */
-#ifdef PTYTRAP_DIES
- exp_slave_control(exp_pty[0],1);*/
-#endif
-
- if (!fd_new(exp_pty[0])) {
- errno = ENOMEM;
- return -1;
- }
-
- if (-1 == (pipe(sync_fds))) {
- return -1;
- }
- if (-1 == (pipe(sync2_fds))) {
- return -1;
- }
-
- if ((exp_pid = fork()) == -1) return(-1);
- if (exp_pid) {
- /* parent */
- close(sync_fds[1]);
- close(sync2_fds[0]);
- if (!exp_autoallocpty) close(exp_pty[1]);
-
-#ifdef PTYTRAP_DIES
-#ifdef HAVE_PTYTRAP
- if (exp_autoallocpty) {
- /* trap initial ioctls in a feeble attempt to not */
- /* block the initially. If the process itself */
- /* ioctls /dev/tty, such blocks will be trapped */
- /* later during normal event processing */
-
- while (slave_write_ioctls) {
- int cc;
-
- cc = exp_wait_for_slave_open(exp_pty[0]);
-#if defined(TIOCSCTTY) && !defined(CIBAUD) && !defined(sun) && !defined(hp9000s300)
- if (cc == TIOCSCTTY) slave_write_ioctls = 0;
-#endif
- if (cc & IOC_IN) slave_write_ioctls--;
- else if (cc == -1) {
- printf("failed to trap slave pty");
- return -1;
- }
- }
- }
-#endif
-#endif /*PTYTRAP_DIES*/
-
- /*
- * wait for slave to initialize pty before allowing
- * user to send to it
- */
-
- debuglog("parent: waiting for sync byte\r\n");
- cc = read(sync_fds[0],&sync_byte,1);
- if (cc == -1) {
- fprintf(stderr,"parent sync byte read: %s\r\n",Tcl_ErrnoMsg(errno));
- exit(-1);
- }
-
- /* turn on detection of eof */
- exp_slave_control(exp_pty[0],1);
-
- /*
- * tell slave to go on now now that we have initialized pty
- */
-
- debuglog("parent: telling child to go ahead\r\n");
- cc = write(sync2_fds[1]," ",1);
- if (cc == -1) {
- errorlog("parent sync byte write: %s\r\n",Tcl_ErrnoMsg(errno));
- exit(-1);
- }
-
- debuglog("parent: now unsynchronized from child\r\n");
-
- close(sync_fds[0]);
- close(sync2_fds[1]);
-
- return(exp_pty[0]);
- }
-
- /* child process - do not return from here! all errors must exit() */
-
- close(sync_fds[0]);
- close(sync2_fds[1]);
-
-#ifdef CRAY
- (void) close(exp_pty[0]);
-#endif
-
-/* ultrix (at least 4.1-2) fails to obtain controlling tty if setsid */
-/* is called. setpgrp works though. */
-#if defined(POSIX) && !defined(ultrix)
-#define DO_SETSID
-#endif
-#ifdef __convex__
-#define DO_SETSID
-#endif
-
-#ifdef DO_SETSID
- setsid();
-#else
-#ifdef SYSV3
-#ifndef CRAY
- setpgrp();
-#endif /* CRAY */
-#else /* !SYSV3 */
-#ifdef MIPS_BSD
- /* required on BSD side of MIPS OS <jmsellen@watdragon.waterloo.edu> */
-# include <sysv/sys.s>
- syscall(SYS_setpgrp);
-#endif
- setpgrp(0,0);
-/* setpgrp(0,getpid());*/ /* make a new pgrp leader */
-
-#ifdef TIOCNOTTY
- ttyfd = open("/dev/tty", O_RDWR);
- if (ttyfd >= 0) {
- (void) ioctl(ttyfd, TIOCNOTTY, (char *)0);
- (void) close(ttyfd);
- }
-#endif /* TIOCNOTTY */
-
-#endif /* SYSV3 */
-#endif /* DO_SETSID */
-
- /* save error fd while we're setting up new one */
- errorfd = fcntl(2,F_DUPFD,3);
- /* and here is the macro to restore it */
-#define restore_error_fd {close(2);fcntl(errorfd,F_DUPFD,2);}
-
- if (exp_autoallocpty) {
-
- close(0);
- close(1);
- close(2);
-
- /* since we closed fd 0, open of pty slave must return fd 0 */
-
- if (0 > (exp_pty[1] = getptyslave(exp_ttycopy,exp_ttyinit,
- exp_stty_init))) {
- restore_error_fd
- fprintf(stderr,"open(slave pty): %s\n",Tcl_ErrnoMsg(errno));
- exit(-1);
- }
- /* sanity check */
- if (exp_pty[1] != 0) {
- restore_error_fd
- fprintf(stderr,"getptyslave: slave = %d but expected 0\n",
- exp_pty[1]);
- exit(-1);
- }
- } else {
- if (exp_pty[1] != 0) {
- close(0); fcntl(exp_pty[1],F_DUPFD,0);
- }
- close(1); fcntl(0,F_DUPFD,1);
- close(2); fcntl(0,F_DUPFD,1);
- close(exp_pty[1]);
- }
-
-
-
-/* The test for hpux may have to be more specific. In particular, the */
-/* code should be skipped on the hp9000s300 and hp9000s720 (but there */
-/* is no documented define for the 720!) */
-
-#if defined(TIOCSCTTY) && !defined(sun) && !defined(hpux)
- /* 4.3+BSD way to acquire controlling terminal */
- /* according to Stevens - Adv. Prog..., p 642 */
-#ifdef __QNX__ /* posix in general */
- if (tcsetct(0, getpid()) == -1) {
-#else
- if (ioctl(0,TIOCSCTTY,(char *)0) < 0) {
-#endif
- restore_error_fd
- fprintf(stderr,"failed to get controlling terminal using TIOCSCTTY");
- exit(-1);
- }
-#endif
-
-#ifdef CRAY
- (void) setsid();
- (void) ioctl(0,TCSETCTTY,0);
- (void) close(0);
- if (open("/dev/tty", O_RDWR) < 0) {
- restore_error_fd
- fprintf(stderr,"open(/dev/tty): %s\r\n",Tcl_ErrnoMsg(errno));
- exit(-1);
- }
- (void) close(1);
- (void) close(2);
- (void) dup(0);
- (void) dup(0);
- setptyutmp(); /* create a utmp entry */
-
- /* _CRAY2 code from Hal Peterson <hrp@cray.com>, Cray Research, Inc. */
-#ifdef _CRAY2
- /*
- * Interpose a process between expect and the spawned child to
- * keep the slave side of the pty open to allow time for expect
- * to read the last output. This is a workaround for an apparent
- * bug in the Unicos pty driver on Cray-2's under Unicos 6.0 (at
- * least).
- */
- if ((pid = fork()) == -1) {
- restore_error_fd
- fprintf(stderr,"second fork: %s\r\n",Tcl_ErrnoMsg(errno));
- exit(-1);
- }
-
- if (pid) {
- /* Intermediate process. */
- int status;
- int timeout;
- char *t;
-
- /* How long should we wait? */
- timeout = exp_pty_timeout;
-
- /* Let the spawned process run to completion. */
- while (wait(&status) < 0 && errno == EINTR)
- /* empty body */;
-
- /* Wait for the pty to clear. */
- sleep(timeout);
-
- /* Duplicate the spawned process's status. */
- if (WIFSIGNALED(status))
- kill(getpid(), WTERMSIG(status));
-
- /* The kill may not have worked, but this will. */
- exit(WEXITSTATUS(status));
- }
-#endif /* _CRAY2 */
-#endif /* CRAY */
-
- if (exp_console) {
-#ifdef SRIOCSREDIR
- int fd;
-
- if ((fd = open("/dev/console", O_RDONLY)) == -1) {
- restore_error_fd
- fprintf(stderr, "spawn %s: cannot open console, check permissions of /dev/console\n",argv[0]);
- exit(-1);
- }
- if (ioctl(fd, SRIOCSREDIR, 0) == -1) {
- restore_error_fd
- fprintf(stderr, "spawn %s: cannot redirect console, check permissions of /dev/console\n",argv[0]);
- }
- close(fd);
-#endif
-
-#ifdef TIOCCONS
- int on = 1;
- if (ioctl(0,TIOCCONS,(char *)&on) == -1) {
- restore_error_fd
- fprintf(stderr, "spawn %s: cannot open console, check permissions of /dev/console\n",argv[0]);
- exit(-1);
- }
-#endif /* TIOCCONS */
- }
-
- /* tell parent that we are done setting up pty */
- /* The actual char sent back is irrelevant. */
-
- /* debuglog("child: telling parent that pty is initialized\r\n");*/
- cc = write(sync_fds[1]," ",1);
- if (cc == -1) {
- restore_error_fd
- fprintf(stderr,"child: sync byte write: %s\r\n",Tcl_ErrnoMsg(errno));
- exit(-1);
- }
- close(sync_fds[1]);
-
- /* wait for master to let us go on */
- /* debuglog("child: waiting for go ahead from parent\r\n"); */
-
-/* close(master); /* force master-side close so we can read */
- cc = read(sync2_fds[0],&sync_byte,1);
- if (cc == -1) {
- restore_error_fd
- errorlog("child: sync byte read: %s\r\n",Tcl_ErrnoMsg(errno));
- exit(-1);
- }
- close(sync2_fds[0]);
-
- /* debuglog("child: now unsynchronized from parent\r\n"); */
-
- /* (possibly multiple) masters are closed automatically due to */
- /* earlier fcntl(,,CLOSE_ON_EXEC); */
-
- /* just in case, allow user to explicitly close other files */
- if (exp_close_in_child) (*exp_close_in_child)();
-
- /* allow user to do anything else to child */
- if (exp_child_exec_prelude) (*exp_child_exec_prelude)();
-
- (void) execvp(file,argv);
- /* Unfortunately, by now we've closed fd's to stderr, logfile and
- debugfile.
- The only reasonable thing to do is to send back the error as
- part of the program output. This will be picked up in an
- expect or interact command.
- */
- fprintf(stderr,"execvp(%s): %s\n",file,Tcl_ErrnoMsg(errno));
- exit(-1);
- /*NOTREACHED*/
-}
-
-/* returns fd of master side of pty */
-/*VARARGS*/
-int
-exp_spawnl TCL_VARARGS_DEF(char *,arg1)
-/*exp_spawnl(va_alist)*/
-/*va_dcl*/
-{
- va_list args; /* problematic line here */
- int i;
- char *arg, **argv;
-
- arg = TCL_VARARGS_START(char *,arg1,args);
- /*va_start(args);*/
- for (i=1;;i++) {
- arg = va_arg(args,char *);
- if (!arg) break;
- }
- va_end(args);
- if (i == 0) sysreturn(EINVAL);
- if (!(argv = (char **)malloc((i+1)*sizeof(char *)))) sysreturn(ENOMEM);
- argv[0] = TCL_VARARGS_START(char *,arg1,args);
- /*va_start(args);*/
- for (i=1;;i++) {
- argv[i] = va_arg(args,char *);
- if (!argv[i]) break;
- }
- i = exp_spawnv(argv[0],argv+1);
- free((char *)argv);
- return(i);
-}
-
-/* allow user-provided fd to be passed to expect funcs */
-int
-exp_spawnfd(fd)
-int fd;
-{
- if (!fd_new(fd)) {
- errno = ENOMEM;
- return -1;
- }
- return fd;
-}
-
-/* remove nulls from s. Initially, the number of chars in s is c, */
-/* not strlen(s). This count does not include the trailing null. */
-/* returns number of nulls removed. */
-static int
-rm_nulls(s,c)
-char *s;
-int c;
-{
- char *s2 = s; /* points to place in original string to put */
- /* next non-null character */
- int count = 0;
- int i;
-
- for (i=0;i<c;i++,s++) {
- if (0 == *s) {
- count++;
- continue;
- }
- if (count) *s2 = *s;
- s2++;
- }
- return(count);
-}
-
-static int i_read_errno;/* place to save errno, if i_read() == -1, so it
- doesn't get overwritten before we get to read it */
-
-/*ARGSUSED*/
-static void
-sigalarm_handler(n)
-int n; /* signal number, unused by us */
-{
-#ifdef REARM_SIG
- signal(SIGALRM,sigalarm_handler);
-#endif
-
- longjmp(exp_readenv,1);
-}
-
-/* interruptable read */
-static int
-i_read(fd,fp,buffer,length,timeout)
-int fd;
-FILE *fp;
-char *buffer;
-int length;
-int timeout;
-{
- int cc = -2;
-
- /* since setjmp insists on returning 1 upon longjmp(,0), */
- /* longjmp(,2 (EXP_RESTART)) instead. */
-
- /* no need to set alarm if -1 (infinite) or 0 (poll with */
- /* guaranteed data) */
-
- if (timeout > 0) alarm(timeout);
-
- /* restart read if setjmp returns 0 (first time) or 2 (EXP_RESTART). */
- /* abort if setjmp returns 1 (EXP_ABORT). */
- if (EXP_ABORT != setjmp(exp_readenv)) {
- exp_reading = TRUE;
- if (fd == -1) {
- int c;
- c = getc(fp);
- if (c == EOF) {
-/*fprintf(stderr,"<<EOF>>",c);fflush(stderr);*/
- if (feof(fp)) cc = 0;
- else cc = -1;
- } else {
-/*fprintf(stderr,"<<%c>>",c);fflush(stderr);*/
- buffer[0] = c;
- cc = 1;
- }
- } else {
-#ifndef HAVE_PTYTRAP
- cc = read(fd,buffer,length);
-#else
-# include <sys/ptyio.h>
-
- fd_set rdrs;
- fd_set excep;
-
- restart:
- FD_ZERO(&rdrs);
- FD_ZERO(&excep);
- FD_SET(fd,&rdrs);
- FD_SET(fd,&excep);
- if (-1 == (cc = select(fd+1,
- (SELECT_MASK_TYPE *)&rdrs,
- (SELECT_MASK_TYPE *)0,
- (SELECT_MASK_TYPE *)&excep,
- (struct timeval *)0))) {
- /* window refreshes trigger EINTR, ignore */
- if (errno == EINTR) goto restart;
- }
- if (FD_ISSET(fd,&rdrs)) {
- cc = read(fd,buffer,length);
- } else if (FD_ISSET(fd,&excep)) {
- struct request_info ioctl_info;
- ioctl(fd,TIOCREQCHECK,&ioctl_info);
- if (ioctl_info.request == TIOCCLOSE) {
- cc = 0; /* indicate eof */
- } else {
- ioctl(fd, TIOCREQSET, &ioctl_info);
- /* presumably, we trapped an open here */
- goto restart;
- }
- }
-#endif /* HAVE_PTYTRAP */
- }
-#if 0
- /* can't get fread to return early! */
- else {
- if (!(cc = fread(buffer,1,length,fp))) {
- if (ferror(fp)) cc = -1;
- }
- }
-#endif
- i_read_errno = errno; /* errno can be overwritten by the */
- /* time we return */
- }
- exp_reading = FALSE;
-
- if (timeout > 0) alarm(0);
- return(cc);
-}
-
-/* I tried really hard to make the following two functions share the code */
-/* that makes the ecase array, but I kept running into a brick wall when */
-/* passing var args into the funcs and then again into a make_cases func */
-/* I would very much appreciate it if someone showed me how to do it right */
-
-/* takes triplets of args, with a final "exp_last" arg */
-/* triplets are type, pattern, and then int to return */
-/* returns negative value if error (or EOF/timeout) occurs */
-/* some negative values can also have an associated errno */
-
-/* the key internal variables that this function depends on are:
- exp_buffer
- exp_buffer_end
- exp_match_end
-*/
-static int
-expectv(fd,fp,ecases)
-int fd;
-FILE *fp;
-struct exp_case *ecases;
-{
- int cc = 0; /* number of chars returned in a single read */
- int buf_length; /* numbers of chars in exp_buffer */
- int old_length; /* old buf_length */
- int first_time = TRUE; /* force old buffer to be tested before */
- /* additional reads */
- int polled = 0; /* true if poll has caused read() to occur */
-
- struct exp_case *ec; /* points to current ecase */
-
- time_t current_time; /* current time (when we last looked)*/
- time_t end_time; /* future time at which to give up */
- int remtime; /* remaining time in timeout */
-
- struct f *f;
- int return_val;
- int sys_error = 0;
-#define return_normally(x) {return_val = x; goto cleanup;}
-#define return_errno(x) {sys_error = x; goto cleanup;}
-
- f = fdfp2f(fd,fp);
- if (!f) return_errno(ENOMEM);
-
- exp_buffer = f->buffer;
- exp_buffer_end = f->buffer_end;
- exp_match_end = f->match_end;
-
- buf_length = exp_buffer_end - exp_match_end;
- if (buf_length) {
- /*
- * take end of previous match to end of buffer
- * and copy to beginning of buffer
- */
- memmove(exp_buffer,exp_match_end,buf_length);
- }
- exp_buffer_end = exp_buffer + buf_length;
- *exp_buffer_end = '\0';
-
- if (!ecases) return_errno(EINVAL);
-
- /* compile if necessary */
- for (ec=ecases;ec->type != exp_end;ec++) {
- if ((ec->type == exp_regexp) && !ec->re) {
- TclRegError((char *)0);
- if (!(ec->re = (void*)TclRegComp(ec->pattern))) {
- fprintf(stderr,"regular expression %s is bad: %s",ec->pattern,TclGetRegError());
- return_errno(EINVAL);
- }
- }
- }
-
- /* get the latest buffer size. Double the user input for two */
- /* reasons. 1) Need twice the space in case the match */
- /* straddles two bufferfuls, 2) easier to hack the division by */
- /* two when shifting the buffers later on */
-
- bufsiz = 2*exp_match_max;
- if (f->msize != bufsiz) {
- /* if truncated, forget about some data */
- if (buf_length > bufsiz) {
- /* copy end of buffer down */
-
- /* copy one less than what buffer can hold to avoid */
- /* triggering buffer-full handling code below */
- /* which will immediately dump the first half */
- /* of the buffer */
- memmove(exp_buffer,exp_buffer+(buf_length - bufsiz)+1,
- bufsiz-1);
- buf_length = bufsiz-1;
- }
- exp_buffer = realloc(exp_buffer,bufsiz+1);
- if (!exp_buffer) return_errno(ENOMEM);
- exp_buffer[buf_length] = '\0';
- exp_buffer_end = exp_buffer + buf_length;
- f->msize = bufsiz;
- }
-
- /* some systems (i.e., Solaris) require fp be flushed when switching */
- /* directions - do this again afterwards */
- if (fd == -1) fflush(fp);
-
- if (exp_timeout != -1) signal(SIGALRM,sigalarm_handler);
-
- /* remtime and current_time updated at bottom of loop */
- remtime = exp_timeout;
-
- time(¤t_time);
- end_time = current_time + remtime;
-
- for (;;) {
- /* when buffer fills, copy second half over first and */
- /* continue, so we can do matches over multiple buffers */
- if (buf_length == bufsiz) {
- int first_half, second_half;
-
- if (exp_full_buffer) {
- debuglog("expect: full buffer\r\n");
- exp_match = exp_buffer;
- exp_match_end = exp_buffer + buf_length;
- exp_buffer_end = exp_match_end;
- return_normally(EXP_FULLBUFFER);
- }
- first_half = bufsiz/2;
- second_half = bufsiz - first_half;
-
- memcpy(exp_buffer,exp_buffer+first_half,second_half);
- buf_length = second_half;
- exp_buffer_end = exp_buffer + second_half;
- }
-
- /*
- * always check first if pattern is already in buffer
- */
- if (first_time) {
- first_time = FALSE;
- goto after_read;
- }
-
- /*
- * check for timeout
- */
- if ((exp_timeout >= 0) && ((remtime < 0) || polled)) {
- debuglog("expect: timeout\r\n");
- exp_match_end = exp_buffer;
- return_normally(EXP_TIMEOUT);
- }
-
- /*
- * if timeout == 0, indicate a poll has
- * occurred so that next time through loop causes timeout
- */
- if (exp_timeout == 0) {
- polled = 1;
- }
-
- cc = i_read(fd,fp,
- exp_buffer_end,
- bufsiz - buf_length,
- remtime);
-
- if (cc == 0) {
- debuglog("expect: eof\r\n");
- return_normally(EXP_EOF); /* normal EOF */
- } else if (cc == -1) { /* abnormal EOF */
- /* ptys produce EIO upon EOF - sigh */
- if (i_read_errno == EIO) {
- /* convert to EOF indication */
- debuglog("expect: eof\r\n");
- return_normally(EXP_EOF);
- }
- debuglog("expect: error (errno = %d)\r\n",i_read_errno);
- return_errno(i_read_errno);
- } else if (cc == -2) {
- debuglog("expect: timeout\r\n");
- exp_match_end = exp_buffer;
- return_normally(EXP_TIMEOUT);
- }
-
- old_length = buf_length;
- buf_length += cc;
- exp_buffer_end += buf_length;
-
- if (logfile_all || (loguser && logfile)) {
- fwrite(exp_buffer + old_length,1,cc,logfile);
- }
- if (loguser) fwrite(exp_buffer + old_length,1,cc,stdout);
- if (debugfile) fwrite(exp_buffer + old_length,1,cc,debugfile);
-
- /* if we wrote to any logs, flush them */
- if (debugfile) fflush(debugfile);
- if (loguser) {
- fflush(stdout);
- if (logfile) fflush(logfile);
- }
-
- /* remove nulls from input, so we can use C-style strings */
- /* doing it here lets them be sent to the screen, just */
- /* in case they are involved in formatting operations */
- if (exp_remove_nulls) {
- buf_length -= rm_nulls(exp_buffer + old_length, cc);
- }
- /* cc should be decremented as well, but since it will not */
- /* be used before being set again, there is no need */
- exp_buffer_end = exp_buffer + buf_length;
- *exp_buffer_end = '\0';
- exp_match_end = exp_buffer;
-
- after_read:
- debuglog("expect: does {%s} match ",exp_printify(exp_buffer));
- /* pattern supplied */
- for (ec=ecases;ec->type != exp_end;ec++) {
- int matched = -1;
-
- debuglog("{%s}? ",exp_printify(ec->pattern));
- if (ec->type == exp_glob) {
- int offset;
- matched = Exp_StringMatch(exp_buffer,ec->pattern,&offset);
- if (matched >= 0) {
- exp_match = exp_buffer + offset;
- exp_match_end = exp_match + matched;
- }
- } else if (ec->type == exp_exact) {
- char *p = strstr(exp_buffer,ec->pattern);
- if (p) {
- matched = 1;
- exp_match = p;
- exp_match_end = p + strlen(ec->pattern);
- }
- } else if (ec->type == exp_null) {
- char *p;
-
- for (p=exp_buffer;p<exp_buffer_end;p++) {
- if (*p == 0) {
- matched = 1;
- exp_match = p;
- exp_match_end = p+1;
- }
- }
- } else {
- TclRegError((char *)0);
- if (TclRegExec(ec->re,exp_buffer,exp_buffer)) {
- matched = 1;
- exp_match = ec->re->startp[0];
- exp_match_end = ec->re->endp[0];
- } else if (TclGetRegError()) {
- fprintf(stderr,"r.e. match (pattern %s) failed: %s",ec->pattern,TclGetRegError());
- }
- }
-
- if (matched != -1) {
- debuglog("yes\nexp_buffer is {%s}\n",
- exp_printify(exp_buffer));
- return_normally(ec->value);
- } else debuglog("no\n");
- }
-
- /*
- * Update current time and remaining time.
- * Don't bother if we are waiting forever or polling.
- */
- if (exp_timeout > 0) {
- time(¤t_time);
- remtime = end_time - current_time;
- }
- }
- cleanup:
- f->buffer = exp_buffer;
- f->buffer_end = exp_buffer_end;
- f->match_end = exp_match_end;
-
- /* some systems (i.e., Solaris) require fp be flushed when switching */
- /* directions - do this before as well */
- if (fd == -1) fflush(fp);
-
- if (sys_error) {
- errno = sys_error;
- return -1;
- }
- return return_val;
-}
-
-int
-exp_fexpectv(fp,ecases)
-FILE *fp;
-struct exp_case *ecases;
-{
- return(expectv(-1,fp,ecases));
-}
-
-int
-exp_expectv(fd,ecases)
-int fd;
-struct exp_case *ecases;
-{
- return(expectv(fd,(FILE *)0,ecases));
-}
-
-/*VARARGS*/
-int
-exp_expectl TCL_VARARGS_DEF(int,arg1)
-/*exp_expectl(va_alist)*/
-/*va_dcl*/
-{
- va_list args;
- int fd;
- struct exp_case *ec, *ecases;
- int i;
- enum exp_type type;
-
- fd = TCL_VARARGS_START(int,arg1,args);
- /* va_start(args);*/
- /* fd = va_arg(args,int);*/
- /* first just count the arg sets */
- for (i=0;;i++) {
- type = va_arg(args,enum exp_type);
- if (type == exp_end) break;
-
- /* Ultrix 4.2 compiler refuses enumerations comparison!? */
- if ((int)type < 0 || (int)type >= (int)exp_bogus) {
- fprintf(stderr,"bad type (set %d) in exp_expectl\n",i);
- sysreturn(EINVAL);
- }
-
- va_arg(args,char *); /* COMPUTED BUT NOT USED */
- if (type == exp_compiled) {
- va_arg(args,Expect_regexp *); /* COMPUTED BUT NOT USED */
- }
- va_arg(args,int); /* COMPUTED BUT NOT USED*/
- }
- va_end(args);
-
- if (!(ecases = (struct exp_case *)
- malloc((1+i)*sizeof(struct exp_case))))
- sysreturn(ENOMEM);
-
- /* now set up the actual cases */
- fd = TCL_VARARGS_START(int,arg1,args);
- /*va_start(args);*/
- /*va_arg(args,int);*/ /*COMPUTED BUT NOT USED*/
- for (ec=ecases;;ec++) {
- ec->type = va_arg(args,enum exp_type);
- if (ec->type == exp_end) break;
- ec->pattern = va_arg(args,char *);
- if (ec->type == exp_compiled) {
- ec->re = va_arg(args,Expect_regexp *);
- } else {
- ec->re = 0;
- }
- ec->value = va_arg(args,int);
- }
- va_end(args);
- i = expectv(fd,(FILE *)0,ecases);
-
- for (ec=ecases;ec->type != exp_end;ec++) {
- /* free only if regexp and we compiled it for user */
- if (ec->type == exp_regexp) {
- free((char *)ec->re);
- }
- }
- free((char *)ecases);
- return(i);
-}
-
-int
-exp_fexpectl TCL_VARARGS_DEF(FILE *,arg1)
-/*exp_fexpectl(va_alist)*/
-/*va_dcl*/
-{
- va_list args;
- FILE *fp;
- struct exp_case *ec, *ecases;
- int i;
- enum exp_type type;
-
- fp = TCL_VARARGS_START(FILE *,arg1,args);
- /*va_start(args);*/
- /*fp = va_arg(args,FILE *);*/
- /* first just count the arg-pairs */
- for (i=0;;i++) {
- type = va_arg(args,enum exp_type);
- if (type == exp_end) break;
-
- /* Ultrix 4.2 compiler refuses enumerations comparison!? */
- if ((int)type < 0 || (int)type >= (int)exp_bogus) {
- fprintf(stderr,"bad type (set %d) in exp_expectl\n",i);
- sysreturn(EINVAL);
- }
-
- va_arg(args,char *); /* COMPUTED BUT NOT USED */
- if (type == exp_compiled) {
- va_arg(args,Expect_regexp *); /* COMPUTED BUT NOT USED */
- }
- va_arg(args,int); /* COMPUTED BUT NOT USED*/
- }
- va_end(args);
-
- if (!(ecases = (struct exp_case *)
- malloc((1+i)*sizeof(struct exp_case))))
- sysreturn(ENOMEM);
-
-#if 0
- va_start(args);
- va_arg(args,FILE *); /*COMPUTED, BUT NOT USED*/
-#endif
- (void) TCL_VARARGS_START(FILE *,arg1,args);
-
- for (ec=ecases;;ec++) {
- ec->type = va_arg(args,enum exp_type);
- if (ec->type == exp_end) break;
- ec->pattern = va_arg(args,char *);
- if (ec->type == exp_compiled) {
- ec->re = va_arg(args,Expect_regexp *);
- } else {
- ec->re = 0;
- }
- ec->value = va_arg(args,int);
- }
- va_end(args);
- i = expectv(-1,fp,ecases);
-
- for (ec=ecases;ec->type != exp_end;ec++) {
- /* free only if regexp and we compiled it for user */
- if (ec->type == exp_regexp) {
- free((char *)ec->re);
- }
- }
- free((char *)ecases);
- return(i);
-}
-
-/* like popen(3) but works in both directions */
-FILE *
-exp_popen(program)
-char *program;
-{
- FILE *fp;
- int ec;
-
- if (0 > (ec = exp_spawnl("sh","sh","-c",program,(char *)0))) return(0);
- if (!(fp = fdopen(ec,"r+"))) return(0);
- setbuf(fp,(char *)0);
- return(fp);
-}
-
-int
-exp_disconnect()
-{
- int ttyfd;
-
-#ifndef EALREADY
-#define EALREADY 37
-#endif
-
- /* presumably, no stderr, so don't bother with error message */
- if (exp_disconnected) sysreturn(EALREADY);
- exp_disconnected = TRUE;
-
- freopen("/dev/null","r",stdin);
- freopen("/dev/null","w",stdout);
- freopen("/dev/null","w",stderr);
-
-#ifdef POSIX
- setsid();
-#else
-#ifdef SYSV3
- /* put process in our own pgrp, and lose controlling terminal */
- setpgrp();
- signal(SIGHUP,SIG_IGN);
- if (fork()) exit(0); /* first child exits (as per Stevens, */
- /* UNIX Network Programming, p. 79-80) */
- /* second child process continues as daemon */
-#else /* !SYSV3 */
-#ifdef MIPS_BSD
- /* required on BSD side of MIPS OS <jmsellen@watdragon.waterloo.edu> */
-# include <sysv/sys.s>
- syscall(SYS_setpgrp);
-#endif
- setpgrp(0,getpid()); /* put process in our own pgrp */
-/* Pyramid lacks this defn */
-#ifdef TIOCNOTTY
- ttyfd = open("/dev/tty", O_RDWR);
- if (ttyfd >= 0) {
- /* zap controlling terminal if we had one */
- (void) ioctl(ttyfd, TIOCNOTTY, (char *)0);
- (void) close(ttyfd);
- }
-#endif /* TIOCNOTTY */
-#endif /* SYSV3 */
-#endif /* POSIX */
- return(0);
-}
+++ /dev/null
-/* exp_closetcl.c - close tcl files */
-
-/* isolated in it's own file since it has hooks into Tcl and exp_clib user */
-/* might like to avoid dragging it in */
-
-#include "expect_cf.h"
-#include "tclInt.h"
-
-void (*exp_close_in_child)() = 0;
-
-void
-exp_close_tcl_files() {
- int i;
-
- /* So much for close-on-exec. Tcl doesn't mark its files that way */
- /* everything has to be closed explicitly. */
-
-#if 0
-/* Not necessary with Tcl 7.5? */
- for (i=3; i<tclNumFiles;i++) close(i);
-#endif
-}
+++ /dev/null
-/* exp_command.c - the bulk of the Expect commands
-
-Written by: Don Libes, NIST, 2/6/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.
-
-*/
-
-#include "expect_cf.h"
-
-#include <stdio.h>
-#include <sys/types.h>
-/*#include <sys/time.h> seems to not be present on SVR3 systems */
-/* and it's not used anyway as far as I can tell */
-
-/* AIX insists that stropts.h be included before ioctl.h, because both */
-/* define _IO but only ioctl.h checks first. Oddly, they seem to be */
-/* defined differently! */
-#ifdef HAVE_STROPTS_H
-# include <sys/stropts.h>
-#endif
-#include <sys/ioctl.h>
-
-#ifdef HAVE_SYS_FCNTL_H
-# include <sys/fcntl.h>
-#else
-# include <fcntl.h>
-#endif
-#include <sys/file.h>
-#include "exp_tty.h"
-
-#ifdef HAVE_SYS_WAIT_H
- /* ISC doesn't def WNOHANG unless _POSIX_SOURCE is def'ed */
-# ifdef WNOHANG_REQUIRES_POSIX_SOURCE
-# define _POSIX_SOURCE
-# endif
-# include <sys/wait.h>
-# ifdef WNOHANG_REQUIRES_POSIX_SOURCE
-# undef _POSIX_SOURCE
-# endif
-#endif
-
-#include <errno.h>
-#include <signal.h>
-
-#if defined(SIGCLD) && !defined(SIGCHLD)
-#define SIGCHLD SIGCLD
-#endif
-
-/* Use _NSIG if NSIG not present */
-#ifndef NSIG
-#ifdef _NSIG
-#define NSIG _NSIG
-#endif
-#endif
-
-#ifdef HAVE_PTYTRAP
-#include <sys/ptyio.h>
-#endif
-
-#ifdef CRAY
-# ifndef TCSETCTTY
-# if defined(HAVE_TERMIOS)
-# include <termios.h>
-# else
-# include <termio.h>
-# endif
-# endif
-#endif
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#include <math.h> /* for log/pow computation in send -h */
-#include <ctype.h> /* all this for ispunct! */
-
-#include "tclInt.h" /* need OpenFile */
-/*#include <varargs.h> tclInt.h drags in varargs.h. Since Pyramid */
-/* objects to including varargs.h twice, just */
-/* omit this one. */
-
-#include "tcl.h"
-#include "string.h"
-#include "expect_tcl.h"
-#include "exp_rename.h"
-#include "exp_prog.h"
-#include "exp_command.h"
-#include "exp_log.h"
-#include "exp_event.h"
-#include "exp_pty.h"
-#ifdef TCL_DEBUGGER
-#include "Dbg.h"
-#endif
-
-#define SPAWN_ID_VARNAME "spawn_id"
-
-int getptymaster();
-int getptyslave();
-
-int exp_forked = FALSE; /* whether we are child process */
-
-/* the following are just reserved addresses, to be used as ClientData */
-/* args to be used to tell commands how they were called. */
-/* The actual values won't be used, only the addresses, but I give them */
-/* values out of my irrational fear the compiler might collapse them all. */
-static int sendCD_error = 2; /* called as send_error */
-static int sendCD_user = 3; /* called as send_user */
-static int sendCD_proc = 4; /* called as send or send_spawn */
-static int sendCD_tty = 6; /* called as send_tty */
-
-struct exp_f *exp_fs = 0; /* process array (indexed by spawn_id's) */
-int exp_fd_max = -1; /* highest fd */
-
-/*
- * expect_key is just a source for generating a unique stamp. As each
- * expect/interact command begins, it generates a new key and marks all
- * the spawn ids of interest with it. Then, if someone comes along and
- * marks them with yet a newer key, the old command will recognize this
- * reexamine the state of the spawned process.
- */
-int expect_key = 0;
-
-/*
- * exp_configure_count is incremented whenever a spawned process is closed
- * or an indirect list is modified. This forces any (stack of) expect or
- * interact commands to reexamine the state of the world and adjust
- * accordingly.
- */
-int exp_configure_count = 0;
-
-/* this message is required because fopen sometimes fails to set errno */
-/* Apparently, it "does the user a favor" and doesn't even call open */
-/* if the file name is bizarre enough. This means we can't handle fopen */
-/* with the obvious trivial logic. */
-static char *open_failed = "could not open - odd file name?";
-
-#ifdef HAVE_PTYTRAP
-/* slaveNames provides a mapping from the pty slave names to our */
-/* spawn id entry. This is needed only on HPs for stty, sigh. */
-static Tcl_HashTable slaveNames;
-#endif /* HAVE_PTYTRAP */
-
-#ifdef FULLTRAPS
-static void
-init_traps(traps)
-RETSIGTYPE (*traps[])();
-{
- int i;
-
- for (i=1;i<NSIG;i++) {
- traps[i] = SIG_ERR;
- }
-}
-#endif
-
-/* Do not terminate format strings with \n!!! */
-/*VARARGS*/
-void
-exp_error TCL_VARARGS_DEF(Tcl_Interp *,arg1)
-/*exp_error(va_alist)*/
-/*va_dcl*/
-{
- Tcl_Interp *interp;
- char *fmt;
- va_list args;
-
- interp = TCL_VARARGS_START(Tcl_Interp *,arg1,args);
- /*va_start(args);*/
- /*interp = va_arg(args,Tcl_Interp *);*/
- fmt = va_arg(args,char *);
- vsprintf(interp->result,fmt,args);
- va_end(args);
-}
-
-/* returns handle if fd is usable, 0 if not */
-struct exp_f *
-exp_fd2f(interp,fd,opened,adjust,msg)
-Tcl_Interp *interp;
-int fd;
-int opened; /* check not closed */
-int adjust; /* adjust buffer sizes */
-char *msg;
-{
- if (fd >= 0 && fd <= exp_fd_max && (exp_fs[fd].valid)) {
- struct exp_f *f = exp_fs + fd;
-
- /* following is a little tricky, do not be tempted do the */
- /* 'usual' boolean simplification */
- if ((!opened) || !f->user_closed) {
- if (adjust) exp_adjust(f);
- return f;
- }
- }
-
- exp_error(interp,"%s: invalid spawn id (%d)",msg,fd);
- return(0);
-}
-
-#if 0
-/* following routine is not current used, but might be later */
-/* returns fd or -1 if no such entry */
-static int
-pid_to_fd(pid)
-int pid;
-{
- int fd;
-
- for (fd=0;fd<=exp_fd_max;fd++) {
- if (exp_fs[fd].pid == pid) return(fd);
- }
- return 0;
-}
-#endif
-
-/* Tcl needs commands in writable space */
-static char close_cmd[] = "close";
-
-/* zero out the wait status field */
-static void
-exp_wait_zero(status)
-WAIT_STATUS_TYPE *status;
-{
- int i;
-
- for (i=0;i<sizeof(WAIT_STATUS_TYPE);i++) {
- ((char *)status)[i] = 0;
- }
-}
-
-/* prevent an fd from being allocated */
-void
-exp_busy(fd)
-int fd;
-{
- int x = open("/dev/null",0);
- if (x != fd) {
- fcntl(x,F_DUPFD,fd);
- close(x);
- }
- exp_close_on_exec(fd);
-}
-
-/* called just before an exp_f entry is about to be invalidated */
-void
-exp_f_prep_for_invalidation(interp,f)
-Tcl_Interp *interp;
-struct exp_f *f;
-{
- int fd = f - exp_fs;
-
- exp_ecmd_remove_fd_direct_and_indirect(interp,fd);
-
- exp_configure_count++;
-
- if (f->buffer) {
- ckfree(f->buffer);
- f->buffer = 0;
- f->msize = 0;
- f->size = 0;
- f->printed = 0;
- f->echoed = 0;
- if (f->fg_armed) {
- exp_event_disarm(f-exp_fs);
- f->fg_armed = FALSE;
- }
- ckfree(f->lower);
- }
- f->fg_armed = FALSE;
-}
-
-/*ARGSUSED*/
-void
-exp_trap_on(master)
-int master;
-{
-#ifdef HAVE_PTYTRAP
- if (master == -1) return;
- exp_slave_control(master,1);
-#endif /* HAVE_PTYTRAP */
-}
-
-int
-exp_trap_off(name)
-char *name;
-{
-#ifdef HAVE_PTYTRAP
- int master;
- struct exp_f *f;
- int enable = 0;
-
- Tcl_HashEntry *entry = Tcl_FindHashEntry(&slaveNames,name);
- if (!entry) {
- debuglog("exp_trap_off: no entry found for %s\n",name);
- return -1;
- }
-
- f = (struct exp_f *)Tcl_GetHashValue(entry);
- master = f - exp_fs;
-
- exp_slave_control(master,0);
-
- return master;
-#else
- return name[0]; /* pacify lint, use arg and return something */
-#endif
-}
-
-/*ARGSUSED*/
-void
-sys_close(fd,f)
-int fd;
-struct exp_f *f;
-{
- /* Ignore close errors. Some systems are really odd and */
- /* return errors for no evident reason. Anyway, receiving */
- /* an error upon pty-close doesn't mean anything anyway as */
- /* far as I know. */
- close(fd);
- f->sys_closed = TRUE;
-
-#ifdef HAVE_PTYTRAP
- if (f->slave_name) {
- Tcl_HashEntry *entry;
-
- entry = Tcl_FindHashEntry(&slaveNames,f->slave_name);
- Tcl_DeleteHashEntry(entry);
-
- ckfree(f->slave_name);
- f->slave_name = 0;
- }
-#endif
-}
-
-/* given a Tcl file identifier, close it */
-static void
-close_tcl_file(interp,file_id)
-Tcl_Interp *interp;
-char *file_id;
-{
- Tcl_VarEval(interp,"close ",file_id,(char *)0);
-
-#if 0 /* old Tcl 7.6 code */
- char *argv[3];
- Tcl_CmdInfo info;
-
- argv[0] = close_cmd;
- argv[1] = file_id;
- argv[2] = 0;
-
- Tcl_ResetResult(interp);
- Tcl_GetCommandInfo(interp,"close",&info);
- if (0 == Tcl_GetCommandInfo(interp,"close",&info)) {
- info.clientData = 0;
- }
- (void) Tcl_CloseCmd(info.clientData,interp,2,argv);
-#endif
-}
-
-
-/* close all connections
-The kernel would actually do this by default, however Tcl is going to
-come along later and try to reap its exec'd processes. If we have
-inherited any via spawn -open, Tcl can hang if we don't close the
-connections first.
-*/
-
-void
-exp_close_all(interp)
-Tcl_Interp *interp;
-{
- int fd;
-
- for (fd=0;fd<=exp_fd_max;fd++) {
- if (exp_fs[fd].valid) {
- exp_close(interp,fd);
- }
- }
-}
-
-int
-exp_close(interp,fd)
-Tcl_Interp *interp;
-int fd;
-{
- struct exp_f *f = exp_fd2f(interp,fd,1,0,"close");
- if (!f) return(TCL_ERROR);
-
- f->user_closed = TRUE;
-
- if (f->slave_fd != EXP_NOFD) close(f->slave_fd);
-#if 0
- if (f->tcl_handle) {
- ckfree(f->tcl_handle);
- if ((f - exp_fs) != f->tcl_output) close(f->tcl_output);
- }
-#endif
- sys_close(fd,f);
-
- if (f->tcl_handle) {
- if ((f - exp_fs) != f->tcl_output) close(f->tcl_output);
-
- if (!f->leaveopen) {
- /*
- * Ignore errors from close; they report things like
- * broken pipeline, etc, which don't affect our
- * subsequent handling.
- */
-
- close_tcl_file(interp,f->tcl_handle);
-
- ckfree(f->tcl_handle);
- f->tcl_handle = 0;
- }
- }
-
- exp_f_prep_for_invalidation(interp,f);
-
- if (f->user_waited) {
- f->valid = FALSE;
- } else {
- exp_busy(fd);
- f->sys_closed = FALSE;
- }
-
- return(TCL_OK);
-}
-
-static struct exp_f *
-fd_new(fd,pid)
-int fd;
-int pid;
-{
- int i, low;
- struct exp_f *newfs; /* temporary, so we don't lose old exp_fs */
-
- /* resize table if nec */
- if (fd > exp_fd_max) {
- if (!exp_fs) { /* no fd's yet allocated */
- newfs = (struct exp_f *)ckalloc(sizeof(struct exp_f)*(fd+1));
- low = 0;
- } else { /* enlarge fd table */
- newfs = (struct exp_f *)ckrealloc((char *)exp_fs,sizeof(struct exp_f)*(fd+1));
- low = exp_fd_max+1;
- }
- exp_fs = newfs;
- exp_fd_max = fd;
- for (i = low; i <= exp_fd_max; i++) { /* init new fd entries */
- exp_fs[i].valid = FALSE;
- exp_fs[i].fd_ptr = (int *)ckalloc(sizeof(int));
- *exp_fs[i].fd_ptr = i;
-
-/* exp_fs[i].ptr = (struct exp_f **)ckalloc(sizeof(struct exp_fs *));*/
-
- }
-
-#if 0
- for (i = 0; i <= exp_fd_max; i++) { /* update all indirect ptrs */
- *exp_fs[i].ptr = exp_fs + i;
- }
-#endif
- }
-
- /* this could happen if user does "spawn -open stdin" I suppose */
- if (exp_fs[fd].valid) return exp_fs+fd;
-
- /* close down old table entry if nec */
- exp_fs[fd].pid = pid;
- exp_fs[fd].size = 0;
- exp_fs[fd].msize = 0;
- exp_fs[fd].buffer = 0;
- exp_fs[fd].printed = 0;
- exp_fs[fd].echoed = 0;
- exp_fs[fd].rm_nulls = exp_default_rm_nulls;
- exp_fs[fd].parity = exp_default_parity;
- exp_fs[fd].key = expect_key++;
- exp_fs[fd].force_read = FALSE;
- exp_fs[fd].fg_armed = FALSE;
-#if TCL_MAJOR_VERSION < 8
- /* Master must be inited each time because Tcl could have alloc'd */
- /* this fd and shut it down (deallocating the FileHandle) behind */
- /* our backs */
- exp_fs[fd].Master = Tcl_GetFile((ClientData)fd,TCL_UNIX_FD);
- exp_fs[fd].MasterOutput = 0;
- exp_fs[fd].Slave = 0;
-#endif /* TCL_MAJOR_VERSION < 8 */
- exp_fs[fd].tcl_handle = 0;
- exp_fs[fd].slave_fd = EXP_NOFD;
-#ifdef HAVE_PTYTRAP
- exp_fs[fd].slave_name = 0;
-#endif /* HAVE_PTYTRAP */
- exp_fs[fd].umsize = exp_default_match_max;
- exp_fs[fd].valid = TRUE;
- exp_fs[fd].user_closed = FALSE;
- exp_fs[fd].sys_closed = FALSE;
- exp_fs[fd].user_waited = FALSE;
- exp_fs[fd].sys_waited = FALSE;
- exp_fs[fd].bg_interp = 0;
- exp_fs[fd].bg_status = unarmed;
- exp_fs[fd].bg_ecount = 0;
-
- return exp_fs+fd;
-}
-
-#if 0
-void
-exp_global_init(eg,duration,location)
-struct expect_global *eg;
-int duration;
-int location;
-{
- eg->ecases = 0;
- eg->ecount = 0;
- eg->i_list = 0;
- eg->duration = duration;
- eg->location = location;
-}
-#endif
-
-void
-exp_init_spawn_id_vars(interp)
-Tcl_Interp *interp;
-{
- Tcl_SetVar(interp,"user_spawn_id",EXP_SPAWN_ID_USER_LIT,0);
- Tcl_SetVar(interp,"error_spawn_id",EXP_SPAWN_ID_ERROR_LIT,0);
-
- /* note that the user_spawn_id is NOT /dev/tty which could */
- /* (at least in theory anyway) be later re-opened on a different */
- /* fd, while stdin might have been redirected away from /dev/tty */
-
- if (exp_dev_tty != -1) {
- char dev_tty_str[10];
- sprintf(dev_tty_str,"%d",exp_dev_tty);
- Tcl_SetVar(interp,"tty_spawn_id",dev_tty_str,0);
- }
-}
-
-void
-exp_init_spawn_ids()
-{
- /* note whether 0,1,2 are connected to a terminal so that if we */
- /* disconnect, we can shut these down. We would really like to */
- /* test if 0,1,2 are our controlling tty, but I don't know any */
- /* way to do that portably. Anyway, the likelihood of anyone */
- /* disconnecting after redirecting to a non-controlling tty is */
- /* virtually zero. */
-
- fd_new(0,isatty(0)?exp_getpid:EXP_NOPID);
- fd_new(1,isatty(1)?exp_getpid:EXP_NOPID);
- fd_new(2,isatty(2)?exp_getpid:EXP_NOPID);
-
- if (exp_dev_tty != -1) {
- fd_new(exp_dev_tty,exp_getpid);
- }
-
- /* really should be in interpreter() but silly to do on every call */
- exp_adjust(&exp_fs[0]);
-}
-
-void
-exp_close_on_exec(fd)
-int fd;
-{
- (void) fcntl(fd,F_SETFD,1);
-}
-
-#define STTY_INIT "stty_init"
-
-#if 0
-static void
-show_pgrp(fd,string)
-int fd;
-char *string;
-{
- int pgrp;
-
- fprintf(stderr,"getting pgrp for %s\n",string);
- if (-1 == ioctl(fd,TIOCGETPGRP,&pgrp)) perror("TIOCGETPGRP");
- else fprintf(stderr,"%s pgrp = %d\n",string,pgrp);
- if (-1 == ioctl(fd,TIOCGPGRP,&pgrp)) perror("TIOCGPGRP");
- else fprintf(stderr,"%s pgrp = %d\n",string,pgrp);
- if (-1 == tcgetpgrp(fd,pgrp)) perror("tcgetpgrp");
- else fprintf(stderr,"%s pgrp = %d\n",string,pgrp);
-}
-
-static void
-set_pgrp(fd)
-int fd;
-{
- int pgrp = getpgrp(0);
- if (-1 == ioctl(fd,TIOCSETPGRP,&pgrp)) perror("TIOCSETPGRP");
- if (-1 == ioctl(fd,TIOCSPGRP,&pgrp)) perror("TIOCSPGRP");
- if (-1 == tcsetpgrp(fd,pgrp)) perror("tcsetpgrp");
-}
-#endif
-
-/*ARGSUSED*/
-static void
-set_slave_name(f,name)
-struct exp_f *f;
-char *name;
-{
-#ifdef HAVE_PTYTRAP
- int newptr;
- Tcl_HashEntry *entry;
-
- /* save slave name */
- f->slave_name = ckalloc(strlen(exp_pty_slave_name)+1);
- strcpy(f->slave_name,exp_pty_slave_name);
-
- entry = Tcl_CreateHashEntry(&slaveNames,exp_pty_slave_name,&newptr);
- Tcl_SetHashValue(entry,(ClientData)f);
-#endif /* HAVE_PTYTRAP */
-}
-
-/* arguments are passed verbatim to execvp() */
-/*ARGSUSED*/
-static int
-Exp_SpawnCmd(clientData,interp,argc,argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- int slave;
- int pid;
- char **a;
- /* tell Saber to ignore non-use of ttyfd */
- /*SUPPRESS 591*/
- int errorfd; /* place to stash fileno(stderr) in child */
- /* while we're setting up new stderr */
- int ttyfd;
- int master;
- int write_master; /* write fd of Tcl-opened files */
- int ttyinit = TRUE;
- int ttycopy = TRUE;
- int echo = TRUE;
- int console = FALSE;
- int pty_only = FALSE;
-
-#ifdef FULLTRAPS
- /* Allow user to reset signals in child */
- /* The following array contains indicates */
- /* whether sig should be DFL or IGN */
- /* ERR is used to indicate no initialization */
- RETSIGTYPE (*traps[NSIG])();
-#endif
- int ignore[NSIG]; /* if true, signal in child is ignored */
- /* if false, signal gets default behavior */
- int i; /* trusty overused temporary */
-
- char *argv0 = argv[0];
- char *openarg = 0;
- int leaveopen = FALSE;
- FILE *readfilePtr;
- FILE *writefilePtr;
- int rc, wc;
- char *stty_init;
- int slave_write_ioctls = 1;
- /* by default, slave will be write-ioctled this many times */
- int slave_opens = 3;
- /* by default, slave will be opened this many times */
- /* first comes from initial allocation */
- /* second comes from stty */
- /* third is our own signal that stty is done */
-
- int sync_fds[2];
- int sync2_fds[2];
- int status_pipe[2];
- int child_errno;
- char sync_byte;
-
- char buf[4]; /* enough space for a string literal */
- /* representing a file descriptor */
- Tcl_DString dstring;
- Tcl_DStringInit(&dstring);
-
-#ifdef FULLTRAPS
- init_traps(&traps);
-#endif
- /* don't ignore any signals in child by default */
- for (i=1;i<NSIG;i++) {
- ignore[i] = FALSE;
- }
-
- argc--; argv++;
-
- for (;argc>0;argc--,argv++) {
- if (streq(*argv,"-nottyinit")) {
- ttyinit = FALSE;
- slave_write_ioctls--;
- slave_opens--;
- } else if (streq(*argv,"-nottycopy")) {
- ttycopy = FALSE;
- } else if (streq(*argv,"-noecho")) {
- echo = FALSE;
- } else if (streq(*argv,"-console")) {
- console = TRUE;
- } else if (streq(*argv,"-pty")) {
- pty_only = TRUE;
- } else if (streq(*argv,"-open")) {
- if (argc < 2) {
- exp_error(interp,"usage: -open file-identifier");
- return TCL_ERROR;
- }
- openarg = argv[1];
- argc--; argv++;
- } else if (streq(*argv,"-leaveopen")) {
- if (argc < 2) {
- exp_error(interp,"usage: -open file-identifier");
- return TCL_ERROR;
- }
- openarg = argv[1];
- leaveopen = TRUE;
- argc--; argv++;
- } else if (streq(*argv,"-ignore")) {
- int sig;
-
- if (argc < 2) {
- exp_error(interp,"usage: -ignore signal");
- return TCL_ERROR;
- }
- sig = exp_string_to_signal(interp,argv[1]);
- if (sig == -1) {
- exp_error(interp,"usage: -ignore %s: unknown signal name",argv[1]);
- return TCL_ERROR;
- }
- ignore[sig] = TRUE;
- argc--; argv++;
-#ifdef FULLTRAPS
- } else if (streq(*argv,"-trap")) {
- /* argv[1] is action */
- /* argv[2] is list of signals */
-
- RETSIGTYPE (*sig_handler)();
- int n; /* number of signals in list */
- char **list; /* list of signals */
-
- if (argc < 3) {
- exp_error(interp,"usage: -trap siglist SIG_DFL or SIG_IGN");
- return TCL_ERROR;
- }
-
- if (0 == strcmp(argv[2],"SIG_DFL")) {
- sig_handler = SIG_DFL;
- } else if (0 == strcmp(argv[2],"SIG_IGN")) {
- sig_handler = SIG_IGN;
- } else {
- exp_error(interp,"usage: -trap siglist SIG_DFL or SIG_IGN");
- return TCL_ERROR;
- }
-
- if (TCL_OK != Tcl_SplitList(interp,argv[1],&n,&list)) {
- errorlog("%s\r\n",interp->result);
- exp_error(interp,"usage: -trap {siglist} ...");
- return TCL_ERROR;
- }
- for (i=0;i<n;i++) {
- int sig = exp_string_to_signal(interp,list[i]);
- if (sig == -1) {
- ckfree((char *)&list);
- return TCL_ERROR;
- }
- traps[sig] = sig_handler;
- }
- ckfree((char *)&list);
-
- argc--; argv++;
- argc--; argv++;
-#endif /*FULLTRAPS*/
- } else break;
- }
-
- if (openarg && (argc != 0)) {
- exp_error(interp,"usage: -[leave]open [fileXX]");
- return TCL_ERROR;
- }
-
- if (!pty_only && !openarg && (argc == 0)) {
- exp_error(interp,"usage: spawn [spawn-args] program [program-args]");
- return(TCL_ERROR);
- }
-
- stty_init = exp_get_var(interp,STTY_INIT);
- if (stty_init) {
- slave_write_ioctls++;
- slave_opens++;
- }
-
-/* any extraneous ioctl's that occur in slave must be accounted for
-when trapping, see below in child half of fork */
-#if defined(TIOCSCTTY) && !defined(CIBAUD) && !defined(sun) && !defined(hp9000s300)
- slave_write_ioctls++;
- slave_opens++;
-#endif
-
- exp_pty_slave_name = 0;
-
- Tcl_ReapDetachedProcs();
-
- if (!openarg) {
- if (echo) {
- exp_log(0,"%s ",argv0);
- for (a = argv;*a;a++) {
- exp_log(0,"%s ",*a);
- }
- exp_nflog("\r\n",0);
- }
-
- if (0 > (master = getptymaster())) {
- /*
- * failed to allocate pty, try and figure out why
- * so we can suggest to user what to do about it.
- */
-
- int count;
- int testfd;
-
- if (exp_pty_error) {
- exp_error(interp,"%s",exp_pty_error);
- return TCL_ERROR;
- }
-
- count = 0;
- for (i=3;i<=exp_fd_max;i++) {
- count += exp_fs[i].valid;
- }
- if (count > 10) {
- exp_error(interp,"The system only has a finite number of ptys and you have many of them in use. The usual reason for this is that you forgot (or didn't know) to call \"wait\" after closing each of them.");
- return TCL_ERROR;
- }
-
- testfd = open("/",0);
- close(testfd);
-
- if (testfd != -1) {
- exp_error(interp,"The system has no more ptys. Ask your system administrator to create more.");
- } else {
- exp_error(interp,"- You have too many files are open. Close some files or increase your per-process descriptor limit.");
- }
- return(TCL_ERROR);
- }
-#ifdef PTYTRAP_DIES
- if (!pty_only) exp_slave_control(master,1);
-#endif /* PTYTRAP_DIES */
-
-#define SPAWN_OUT "spawn_out"
- Tcl_SetVar2(interp,SPAWN_OUT,"slave,name",exp_pty_slave_name,0);
- } else {
- Tcl_Channel chan;
- int mode;
-#if TCL_MAJOR_VERSION < 8
- Tcl_File tclReadFile, tclWriteFile;
-#endif /* TCL_MAJOR_VERSION < 8 */
- /* CYGNUS LOCAL 64bit/law */
- /* These must be both wide enough and aligned enough for
- the TCL code to store a pointer into them! */
- void *rfd, *wfd;
- /* END CYGNUS LOCAL */
-
- if (echo) exp_log(0,"%s [open ...]\r\n",argv0);
-
-#if TCL7_4
- rc = Tcl_GetOpenFile(interp,openarg,0,1,&readfilePtr);
- wc = Tcl_GetOpenFile(interp,openarg,1,1,&writefilePtr);
-
- /* fail only if both descriptors are bad */
- if (rc == TCL_ERROR && wc == TCL_ERROR) {
- return TCL_ERROR;
- }
-
- master = fileno((rc == TCL_OK)?readfilePtr:writefilePtr);
-
- /* make a new copy of file descriptor */
- if (-1 == (write_master = master = dup(master))) {
- exp_error(interp,"fdopen: %s",Tcl_PosixError(interp));
- return TCL_ERROR;
- }
-
- /* if writefilePtr is different, dup that too */
- if ((rc == TCL_OK) && (wc == TCL_OK) && (fileno(writefilePtr) != fileno(readfilePtr))) {
- if (-1 == (write_master = dup(fileno(writefilePtr)))) {
- exp_error(interp,"fdopen: %s",Tcl_PosixError(interp));
- return TCL_ERROR;
- }
- exp_close_on_exec(write_master);
- }
-
-#endif
- if (!(chan = Tcl_GetChannel(interp,openarg,&mode))) {
- return TCL_ERROR;
- }
- if (!mode) {
- exp_error(interp,"channel is neither readable nor writable");
- return TCL_ERROR;
- }
- if (mode & TCL_READABLE) {
-#if TCL_MAJOR_VERSION < 8
- tclReadFile = Tcl_GetChannelFile(chan, TCL_READABLE);
- rfd = (int)Tcl_GetFileInfo(tclReadFile, (int *)0);
-#else
- if (TCL_ERROR == Tcl_GetChannelHandle(chan, TCL_READABLE, (ClientData) &rfd)) {
- return TCL_ERROR;
- }
-#endif /* TCL_MAJOR_VERSION < 8 */
- }
- if (mode & TCL_WRITABLE) {
-#if TCL_MAJOR_VERSION < 8
- tclWriteFile = Tcl_GetChannelFile(chan, TCL_WRITABLE);
- wfd = (int)Tcl_GetFileInfo(tclWriteFile, (int *)0);
-#else
- if (TCL_ERROR == Tcl_GetChannelHandle(chan, TCL_WRITABLE, (ClientData) &wfd)) {
- return TCL_ERROR;
- }
-#endif /* TCL_MAJOR_VERSION < 8 */
- }
-
- master = (int)((mode & TCL_READABLE)?rfd:wfd);
-
- /* make a new copy of file descriptor */
- if (-1 == (write_master = master = dup(master))) {
- exp_error(interp,"fdopen: %s",Tcl_PosixError(interp));
- return TCL_ERROR;
- }
-
- /* if writefilePtr is different, dup that too */
- if ((mode & TCL_READABLE) && (mode & TCL_WRITABLE) && (wfd != rfd)) {
- if (-1 == (write_master = dup((int)wfd))) {
- exp_error(interp,"fdopen: %s",Tcl_PosixError(interp));
- return TCL_ERROR;
- }
- exp_close_on_exec(write_master);
- }
-
- /*
- * It would be convenient now to tell Tcl to close its
- * file descriptor. Alas, if involved in a pipeline, Tcl
- * will be unable to complete a wait on the process.
- * So simply remember that we meant to close it. We will
- * do so later in our own close routine.
- */
- }
-
- /* much easier to set this, than remember all masters */
- exp_close_on_exec(master);
-
- if (openarg || pty_only) {
- struct exp_f *f;
-
- f = fd_new(master,EXP_NOPID);
-
- if (openarg) {
- /* save file# handle */
- f->tcl_handle = ckalloc(strlen(openarg)+1);
- strcpy(f->tcl_handle,openarg);
-
- f->tcl_output = write_master;
-#if 0
- /* save fd handle for output */
- if (wc == TCL_OK) {
-/* f->tcl_output = fileno(writefilePtr);*/
- f->tcl_output = write_master;
- } else {
- /* if we actually try to write to it at some */
- /* time in the future, then this will cause */
- /* an error */
- f->tcl_output = master;
- }
-#endif
-
- f->leaveopen = leaveopen;
- }
-
- if (exp_pty_slave_name) set_slave_name(f,exp_pty_slave_name);
-
- /* make it appear as if process has been waited for */
- f->sys_waited = TRUE;
- exp_wait_zero(&f->wait);
-
- /* tell user id of new process */
- sprintf(buf,"%d",master);
- Tcl_SetVar(interp,SPAWN_ID_VARNAME,buf,0);
-
- if (!openarg) {
- char value[20];
- int dummyfd1, dummyfd2;
-
- /*
- * open the slave side in the same process to support
- * the -pty flag.
- */
-
- /* Start by working around a bug in Tcl's exec.
- It closes all the file descriptors from 3 to it's
- own fd_max which inappropriately closes our slave
- fd. To avoid this, open several dummy fds. Then
- exec's fds will fall below ours.
- Note that if you do something like pre-allocating
- a bunch before using them or generating a pipeline,
- then this code won't help.
- Instead you'll need to add the right number of
- explicit Tcl open's of /dev/null.
- The right solution is fix Tcl's exec so it is not
- so cavalier.
- */
-
- dummyfd1 = open("/dev/null",0);
- dummyfd2 = open("/dev/null",0);
-
- if (0 > (f->slave_fd = getptyslave(ttycopy,ttyinit,
- stty_init))) {
- exp_error(interp,"open(slave pty): %s\r\n",Tcl_PosixError(interp));
- return TCL_ERROR;
- }
-
- close(dummyfd1);
- close(dummyfd2);
-
- exp_slave_control(master,1);
-
- sprintf(value,"%d",f->slave_fd);
- Tcl_SetVar2(interp,SPAWN_OUT,"slave,fd",value,0);
- }
- sprintf(interp->result,"%d",EXP_NOPID);
- debuglog("spawn: returns {%s}\r\n",interp->result);
-
- return TCL_OK;
- }
-
- if (NULL == (argv[0] = Tcl_TildeSubst(interp,argv[0],&dstring))) {
- goto parent_error;
- }
-
- if (-1 == pipe(sync_fds)) {
- exp_error(interp,"too many programs spawned? could not create pipe: %s",Tcl_PosixError(interp));
- goto parent_error;
- }
-
- if (-1 == pipe(sync2_fds)) {
- close(sync_fds[0]);
- close(sync_fds[1]);
- exp_error(interp,"too many programs spawned? could not create pipe: %s",Tcl_PosixError(interp));
- goto parent_error;
- }
-
- if (-1 == pipe(status_pipe)) {
- close(sync_fds[0]);
- close(sync_fds[1]);
- close(sync2_fds[0]);
- close(sync2_fds[1]);
- }
-
- if ((pid = fork()) == -1) {
- exp_error(interp,"fork: %s",Tcl_PosixError(interp));
- goto parent_error;
- }
-
- if (pid) { /* parent */
- struct exp_f *f;
-
- close(sync_fds[1]);
- close(sync2_fds[0]);
- close(status_pipe[1]);
-
- f = fd_new(master,pid);
-
- if (exp_pty_slave_name) set_slave_name(f,exp_pty_slave_name);
-
-#ifdef CRAY
- setptypid(pid);
-#endif
-
-
-#if PTYTRAP_DIES
-#ifdef HAVE_PTYTRAP
-
- while (slave_opens) {
- int cc;
- cc = exp_wait_for_slave_open(master);
-#if defined(TIOCSCTTY) && !defined(CIBAUD) && !defined(sun) && !defined(hp9000s300)
- if (cc == TIOCSCTTY) slave_opens = 0;
-#endif
- if (cc == TIOCOPEN) slave_opens--;
- if (cc == -1) {
- exp_error(interp,"failed to trap slave pty");
- goto parent_error;
- }
- }
-
-#if 0
- /* trap initial ioctls in a feeble attempt to not block */
- /* the initially. If the process itself ioctls */
- /* /dev/tty, such blocks will be trapped later */
- /* during normal event processing */
-
- /* initial slave ioctl */
- while (slave_write_ioctls) {
- int cc;
-
- cc = exp_wait_for_slave_open(master);
-#if defined(TIOCSCTTY) && !defined(CIBAUD) && !defined(sun) && !defined(hp9000s300)
- if (cc == TIOCSCTTY) slave_write_ioctls = 0;
-#endif
- if (cc & IOC_IN) slave_write_ioctls--;
- else if (cc == -1) {
- exp_error(interp,"failed to trap slave pty");
- goto parent_error;
- }
- }
-#endif /*0*/
-
-#endif /* HAVE_PTYTRAP */
-#endif /* PTYTRAP_DIES */
-
- /*
- * wait for slave to initialize pty before allowing
- * user to send to it
- */
-
- debuglog("parent: waiting for sync byte\r\n");
- while (((rc = read(sync_fds[0],&sync_byte,1)) < 0) && (errno == EINTR)) {
- /* empty */;
- }
- if (rc == -1) {
- errorlog("parent: sync byte read: %s\r\n",Tcl_ErrnoMsg(errno));
- exit(-1);
- }
-
- /* turn on detection of eof */
- exp_slave_control(master,1);
-
- /*
- * tell slave to go on now now that we have initialized pty
- */
-
- debuglog("parent: telling child to go ahead\r\n");
- wc = write(sync2_fds[1]," ",1);
- if (wc == -1) {
- errorlog("parent: sync byte write: %s\r\n",Tcl_ErrnoMsg(errno));
- exit(-1);
- }
-
- debuglog("parent: now unsynchronized from child\r\n");
- close(sync_fds[0]);
- close(sync2_fds[1]);
-
- /* see if child's exec worked */
- retry:
- switch (read(status_pipe[0],&child_errno,sizeof child_errno)) {
- case -1:
- if (errno == EINTR) goto retry;
- /* well it's not really the child's errno */
- /* but it can be treated that way */
- child_errno = errno;
- break;
- case 0:
- /* child's exec succeeded */
- child_errno = 0;
- break;
- default:
- /* child's exec failed; err contains exec's errno */
- waitpid(pid, NULL, 0);
- /* in order to get Tcl to set errorcode, we must */
- /* hand set errno */
- errno = child_errno;
- exp_error(interp, "couldn't execute \"%s\": %s",
- argv[0],Tcl_PosixError(interp));
- goto parent_error;
- }
- close(status_pipe[0]);
-
-
- /* tell user id of new process */
- sprintf(buf,"%d",master);
- Tcl_SetVar(interp,SPAWN_ID_VARNAME,buf,0);
-
- sprintf(interp->result,"%d",pid);
- debuglog("spawn: returns {%s}\r\n",interp->result);
-
- Tcl_DStringFree(&dstring);
- return(TCL_OK);
-parent_error:
- Tcl_DStringFree(&dstring);
- return TCL_ERROR;
- }
-
- /* child process - do not return from here! all errors must exit() */
-
- close(sync_fds[0]);
- close(sync2_fds[1]);
- close(status_pipe[0]);
- exp_close_on_exec(status_pipe[1]);
-
- if (exp_dev_tty != -1) {
- close(exp_dev_tty);
- exp_dev_tty = -1;
- }
-
-#ifdef CRAY
- (void) close(master);
-#endif
-
-/* ultrix (at least 4.1-2) fails to obtain controlling tty if setsid */
-/* is called. setpgrp works though. */
-#if defined(POSIX) && !defined(ultrix)
-#define DO_SETSID
-#endif
-#ifdef __convex__
-#define DO_SETSID
-#endif
-
-#ifdef DO_SETSID
- setsid();
-#else
-#ifdef SYSV3
-#ifndef CRAY
- setpgrp();
-#endif /* CRAY */
-#else /* !SYSV3 */
-#ifdef MIPS_BSD
- /* required on BSD side of MIPS OS <jmsellen@watdragon.waterloo.edu> */
-# include <sysv/sys.s>
- syscall(SYS_setpgrp);
-#endif
- setpgrp(0,0);
-/* setpgrp(0,getpid());*/ /* make a new pgrp leader */
-
-/* Pyramid lacks this defn */
-#ifdef TIOCNOTTY
- ttyfd = open("/dev/tty", O_RDWR);
- if (ttyfd >= 0) {
- (void) ioctl(ttyfd, TIOCNOTTY, (char *)0);
- (void) close(ttyfd);
- }
-#endif /* TIOCNOTTY */
-
-#endif /* SYSV3 */
-#endif /* DO_SETSID */
-
- /* save stderr elsewhere to avoid BSD4.4 bogosity that warns */
- /* if stty finds dev(stderr) != dev(stdout) */
-
- /* save error fd while we're setting up new one */
- errorfd = fcntl(2,F_DUPFD,3);
- /* and here is the macro to restore it */
-#define restore_error_fd {close(2);fcntl(errorfd,F_DUPFD,2);}
-
- close(0);
- close(1);
- close(2);
-
- /* since we closed fd 0, open of pty slave must return fd 0 */
-
- /* since getptyslave may have to run stty, (some of which work on fd */
- /* 0 and some of which work on 1) do the dup's inside getptyslave. */
-
- if (0 > (slave = getptyslave(ttycopy,ttyinit,stty_init))) {
- restore_error_fd
- errorlog("open(slave pty): %s\r\n",Tcl_ErrnoMsg(errno));
- exit(-1);
- }
- /* sanity check */
- if (slave != 0) {
- restore_error_fd
- errorlog("getptyslave: slave = %d but expected 0\n",slave);
- exit(-1);
- }
-
-/* The test for hpux may have to be more specific. In particular, the */
-/* code should be skipped on the hp9000s300 and hp9000s720 (but there */
-/* is no documented define for the 720!) */
-
-/*#if defined(TIOCSCTTY) && !defined(CIBAUD) && !defined(sun) && !defined(hpux)*/
-#if defined(TIOCSCTTY) && !defined(sun) && !defined(hpux)
- /* 4.3+BSD way to acquire controlling terminal */
- /* according to Stevens - Adv. Prog..., p 642 */
- /* Oops, it appears that the CIBAUD is on Linux also */
- /* so let's try without... */
-#ifdef __QNX__
- if (tcsetct(0, getpid()) == -1) {
-#else
- if (ioctl(0,TIOCSCTTY,(char *)0) < 0) {
-#endif
- restore_error_fd
- errorlog("failed to get controlling terminal using TIOCSCTTY");
- exit(-1);
- }
-#endif
-
-#ifdef CRAY
- (void) setsid();
- (void) ioctl(0,TCSETCTTY,0);
- (void) close(0);
- if (open("/dev/tty", O_RDWR) < 0) {
- restore_error_fd
- errorlog("open(/dev/tty): %s\r\n",Tcl_ErrnoMsg(errno));
- exit(-1);
- }
- (void) close(1);
- (void) close(2);
- (void) dup(0);
- (void) dup(0);
- setptyutmp(); /* create a utmp entry */
-
- /* _CRAY2 code from Hal Peterson <hrp@cray.com>, Cray Research, Inc. */
-#ifdef _CRAY2
- /*
- * Interpose a process between expect and the spawned child to
- * keep the slave side of the pty open to allow time for expect
- * to read the last output. This is a workaround for an apparent
- * bug in the Unicos pty driver on Cray-2's under Unicos 6.0 (at
- * least).
- */
- if ((pid = fork()) == -1) {
- restore_error_fd
- errorlog("second fork: %s\r\n",Tcl_ErrnoMsg(errno));
- exit(-1);
- }
-
- if (pid) {
- /* Intermediate process. */
- int status;
- int timeout;
- char *t;
-
- /* How long should we wait? */
- if (t = exp_get_var(interp,"pty_timeout"))
- timeout = atoi(t);
- else if (t = exp_get_var(interp,"timeout"))
- timeout = atoi(t)/2;
- else
- timeout = 5;
-
- /* Let the spawned process run to completion. */
- while (wait(&status) < 0 && errno == EINTR)
- /* empty body */;
-
- /* Wait for the pty to clear. */
- sleep(timeout);
-
- /* Duplicate the spawned process's status. */
- if (WIFSIGNALED(status))
- kill(getpid(), WTERMSIG(status));
-
- /* The kill may not have worked, but this will. */
- exit(WEXITSTATUS(status));
- }
-#endif /* _CRAY2 */
-#endif /* CRAY */
-
- if (console) exp_console_set();
-
-#ifdef FULLTRAPS
- for (i=1;i<NSIG;i++) {
- if (traps[i] != SIG_ERR) {
- signal(i,traps[i]);
- }
- }
-#endif /* FULLTRAPS */
-
- for (i=1;i<NSIG;i++) {
- signal(i,ignore[i]?SIG_IGN:SIG_DFL);
- }
-
-#if 0
- /* avoid fflush of cmdfile since this screws up the parents seek ptr */
- /* There is no portable way to fclose a shared read-stream!!!! */
- if (exp_cmdfile && (exp_cmdfile != stdin))
- (void) close(fileno(exp_cmdfile));
- if (logfile) (void) fclose(logfile);
- if (debugfile) (void) fclose(debugfile);
-#endif
- /* (possibly multiple) masters are closed automatically due to */
- /* earlier fcntl(,,CLOSE_ON_EXEC); */
-
- /* tell parent that we are done setting up pty */
- /* The actual char sent back is irrelevant. */
-
- /* debuglog("child: telling parent that pty is initialized\r\n");*/
- wc = write(sync_fds[1]," ",1);
- if (wc == -1) {
- restore_error_fd
- errorlog("child: sync byte write: %s\r\n",Tcl_ErrnoMsg(errno));
- exit(-1);
- }
- close(sync_fds[1]);
-
- /* wait for master to let us go on */
- /* debuglog("child: waiting for go ahead from parent\r\n"); */
-
-/* close(master); /* force master-side close so we can read */
-
- while (((rc = read(sync2_fds[0],&sync_byte,1)) < 0) && (errno == EINTR)) {
- /* empty */;
- }
-
- if (rc == -1) {
- restore_error_fd
- errorlog("child: sync byte read: %s\r\n",Tcl_ErrnoMsg(errno));
- exit(-1);
- }
- close(sync2_fds[0]);
-
- /* debuglog("child: now unsynchronized from parent\r\n"); */
-
- /* So much for close-on-exec. Tcl doesn't mark its files that way */
- /* everything has to be closed explicitly. */
- if (exp_close_in_child) (*exp_close_in_child)();
-
- (void) execvp(argv[0],argv);
-#if 0
- /* Unfortunately, by now we've closed fd's to stderr, logfile and
- debugfile.
- The only reasonable thing to do is to send back the error as
- part of the program output. This will be picked up in an
- expect or interact command.
- */
- errorlog("%s: %s\r\n",argv[0],Tcl_ErrnoMsg(errno));
-#endif
- /* if exec failed, communicate the reason back to the parent */
- write(status_pipe[1], &errno, sizeof errno);
- exit(-1);
- /*NOTREACHED*/
-}
-
-/*ARGSUSED*/
-static int
-Exp_ExpPidCmd(clientData,interp,argc,argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- struct exp_f *f;
- int m = -1;
-
- argc--; argv++;
-
- for (;argc>0;argc--,argv++) {
- if (streq(*argv,"-i")) {
- argc--; argv++;
- if (!*argv) goto usage;
- m = atoi(*argv);
- } else goto usage;
- }
-
- if (m == -1) {
- if (exp_update_master(interp,&m,0,0) == 0) return TCL_ERROR;
- }
-
- if (0 == (f = exp_fd2f(interp,m,1,0,"exp_pid"))) return TCL_ERROR;
-
- sprintf(interp->result,"%d",f->pid);
- return TCL_OK;
- usage:
- exp_error(interp,"usage: -i spawn_id");
- return TCL_ERROR;
-}
-
-/*ARGSUSED*/
-static int
-Exp_GetpidDeprecatedCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- debuglog("getpid is deprecated, use pid\r\n");
- sprintf(interp->result,"%d",getpid());
- return(TCL_OK);
-}
-
-/* returns current master (via out-parameter) */
-/* returns f or 0, but note that since exp_fd2f calls tcl_error, this */
-/* may be immediately followed by a "return(TCL_ERROR)"!!! */
-struct exp_f *
-exp_update_master(interp,m,opened,adjust)
-Tcl_Interp *interp;
-int *m;
-int opened;
-int adjust;
-{
- char *s = exp_get_var(interp,SPAWN_ID_VARNAME);
- *m = (s?atoi(s):EXP_SPAWN_ID_USER);
- return(exp_fd2f(interp,*m,opened,adjust,(s?s:EXP_SPAWN_ID_USER_LIT)));
-}
-
-/*ARGSUSED*/
-static int
-Exp_SleepCmd(clientData,interp,argc,argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- argc--; argv++;
-
- if (argc != 1) {
- exp_error(interp,"must have one arg: seconds");
- return TCL_ERROR;
- }
-
- return(exp_dsleep(interp,(double)atof(*argv)));
-}
-
-/* write exactly this many bytes, i.e. retry partial writes */
-/* returns 0 for success, -1 for failure */
-static int
-exact_write(fd,buffer,rembytes)
-int fd;
-char *buffer;
-int rembytes;
-{
- int cc;
-
- while (rembytes) {
- if (-1 == (cc = write(fd,buffer,rembytes))) return(-1);
- if (0 == cc) {
- /* This shouldn't happen but I'm told that it does */
- /* nonetheless (at least on SunOS 4.1.3). Since */
- /* this is not a documented return value, the most */
- /* reasonable thing is to complain here and retry */
- /* in the hopes that is some transient condition. */
- sleep(1);
- exp_debuglog("write() failed to write anything but returned - sleeping and retrying...\n");
- }
-
- buffer += cc;
- rembytes -= cc;
- }
- return(0);
-}
-
-struct slow_arg {
- int size;
- double time;
-};
-
-/* returns 0 for success, -1 for failure */
-static int
-get_slow_args(interp,x)
-Tcl_Interp *interp;
-struct slow_arg *x;
-{
- int sc; /* return from scanf */
- char *s = exp_get_var(interp,"send_slow");
- if (!s) {
- exp_error(interp,"send -s: send_slow has no value");
- return(-1);
- }
- if (2 != (sc = sscanf(s,"%d %lf",&x->size,&x->time))) {
- exp_error(interp,"send -s: found %d value(s) in send_slow but need 2",sc);
- return(-1);
- }
- if (x->size <= 0) {
- exp_error(interp,"send -s: size (%d) in send_slow must be positive", x->size);
- return(-1);
- }
- if (x->time <= 0) {
- exp_error(interp,"send -s: time (%f) in send_slow must be larger",x->time);
- return(-1);
- }
- return(0);
-}
-
-/* returns 0 for success, -1 for failure, pos. for Tcl return value */
-static int
-slow_write(interp,fd,buffer,rembytes,arg)
-Tcl_Interp *interp;
-int fd;
-char *buffer;
-int rembytes;
-struct slow_arg *arg;
-{
- int rc;
-
- while (rembytes > 0) {
- int len;
-
- len = (arg->size<rembytes?arg->size:rembytes);
- if (0 > exact_write(fd,buffer,len)) return(-1);
- rembytes -= arg->size;
- buffer += arg->size;
-
- /* skip sleep after last write */
- if (rembytes > 0) {
- rc = exp_dsleep(interp,arg->time);
- if (rc>0) return rc;
- }
- }
- return(0);
-}
-
-struct human_arg {
- float alpha; /* average interarrival time in seconds */
- float alpha_eow; /* as above but for eow transitions */
- float c; /* shape */
- float min, max;
-};
-
-/* returns -1 if error, 0 if success */
-static int
-get_human_args(interp,x)
-Tcl_Interp *interp;
-struct human_arg *x;
-{
- int sc; /* return from scanf */
- char *s = exp_get_var(interp,"send_human");
-
- if (!s) {
- exp_error(interp,"send -h: send_human has no value");
- return(-1);
- }
- if (5 != (sc = sscanf(s,"%f %f %f %f %f",
- &x->alpha,&x->alpha_eow,&x->c,&x->min,&x->max))) {
- if (sc == EOF) sc = 0; /* make up for overloaded return */
- exp_error(interp,"send -h: found %d value(s) in send_human but need 5",sc);
- return(-1);
- }
- if (x->alpha < 0 || x->alpha_eow < 0) {
- exp_error(interp,"send -h: average interarrival times (%f %f) must be non-negative in send_human", x->alpha,x->alpha_eow);
- return(-1);
- }
- if (x->c <= 0) {
- exp_error(interp,"send -h: variability (%f) in send_human must be positive",x->c);
- return(-1);
- }
- x->c = 1/x->c;
-
- if (x->min < 0) {
- exp_error(interp,"send -h: minimum (%f) in send_human must be non-negative",x->min);
- return(-1);
- }
- if (x->max < 0) {
- exp_error(interp,"send -h: maximum (%f) in send_human must be non-negative",x->max);
- return(-1);
- }
- if (x->max < x->min) {
- exp_error(interp,"send -h: maximum (%f) must be >= minimum (%f) in send_human",x->max,x->min);
- return(-1);
- }
- return(0);
-}
-
-/* Compute random numbers from 0 to 1, for expect's send -h */
-/* This implementation sacrifices beauty for portability */
-static float
-unit_random()
-{
- /* current implementation is pathetic but works */
- /* 99991 is largest prime in my CRC - can't hurt, eh? */
- return((float)(1+(rand()%99991))/99991.0);
-}
-
-void
-exp_init_unit_random()
-{
- srand(getpid());
-}
-
-/* This function is my implementation of the Weibull distribution. */
-/* I've added a max time and an "alpha_eow" that captures the slight */
-/* but noticable change in human typists when hitting end-of-word */
-/* transitions. */
-/* returns 0 for success, -1 for failure, pos. for Tcl return value */
-static int
-human_write(interp,fd,buffer,arg)
-Tcl_Interp *interp;
-int fd;
-char *buffer;
-struct human_arg *arg;
-{
- char *sp;
- float t;
- float alpha;
- int wc;
- int in_word = TRUE;
-
- debuglog("human_write: avg_arr=%f/%f 1/shape=%f min=%f max=%f\r\n",
- arg->alpha,arg->alpha_eow,arg->c,arg->min,arg->max);
-
- for (sp = buffer;*sp;sp++) {
- /* use the end-of-word alpha at eow transitions */
- if (in_word && (ispunct(*sp) || isspace(*sp)))
- alpha = arg->alpha_eow;
- else alpha = arg->alpha;
- in_word = !(ispunct(*sp) || isspace(*sp));
-
- t = alpha * pow(-log((double)unit_random()),arg->c);
-
- /* enforce min and max times */
- if (t<arg->min) t = arg->min;
- else if (t>arg->max) t = arg->max;
-
-/*fprintf(stderr,"\nwriting <%c> but first sleep %f seconds\n",*sp,t);*/
- /* skip sleep before writing first character */
- if (sp != buffer) {
- wc = exp_dsleep(interp,(double)t);
- if (wc > 0) return wc;
- }
-
- wc = write(fd,sp,1);
- if (0 > wc) return(wc);
- }
- return(0);
-}
-
-struct exp_i *exp_i_pool = 0;
-struct exp_fd_list *exp_fd_list_pool = 0;
-
-#define EXP_I_INIT_COUNT 10
-#define EXP_FD_INIT_COUNT 10
-
-struct exp_i *
-exp_new_i()
-{
- int n;
- struct exp_i *i;
-
- if (!exp_i_pool) {
- /* none avail, generate some new ones */
- exp_i_pool = i = (struct exp_i *)ckalloc(
- EXP_I_INIT_COUNT * sizeof(struct exp_i));
- for (n=0;n<EXP_I_INIT_COUNT-1;n++,i++) {
- i->next = i+1;
- }
- i->next = 0;
- }
-
- /* now that we've made some, unlink one and give to user */
-
- i = exp_i_pool;
- exp_i_pool = exp_i_pool->next;
- i->value = 0;
- i->variable = 0;
- i->fd_list = 0;
- i->ecount = 0;
- i->next = 0;
- return i;
-}
-
-struct exp_fd_list *
-exp_new_fd(val)
-int val;
-{
- int n;
- struct exp_fd_list *fd;
-
- if (!exp_fd_list_pool) {
- /* none avail, generate some new ones */
- exp_fd_list_pool = fd = (struct exp_fd_list *)ckalloc(
- EXP_FD_INIT_COUNT * sizeof(struct exp_fd_list));
- for (n=0;n<EXP_FD_INIT_COUNT-1;n++,fd++) {
- fd->next = fd+1;
- }
- fd->next = 0;
- }
-
- /* now that we've made some, unlink one and give to user */
-
- fd = exp_fd_list_pool;
- exp_fd_list_pool = exp_fd_list_pool->next;
- fd->fd = val;
- /* fd->next is assumed to be changed by caller */
- return fd;
-}
-
-void
-exp_free_fd(fd_first)
-struct exp_fd_list *fd_first;
-{
- struct exp_fd_list *fd, *penultimate;
-
- if (!fd_first) return;
-
- /* link entire chain back in at once by first finding last pointer */
- /* making that point back to pool, and then resetting pool to this */
-
- /* run to end */
- for (fd = fd_first;fd;fd=fd->next) {
- penultimate = fd;
- }
- penultimate->next = exp_fd_list_pool;
- exp_fd_list_pool = fd_first;
-}
-
-/* free a single fd */
-void
-exp_free_fd_single(fd)
-struct exp_fd_list *fd;
-{
- fd->next = exp_fd_list_pool;
- exp_fd_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 */
-{
- if (i->next) exp_free_i(interp,i->next,updateproc);
-
- exp_free_fd(i->fd_list);
-
- if (i->direct == EXP_INDIRECT) {
- Tcl_UntraceVar(interp,i->variable,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES,
- updateproc,(ClientData)i);
- }
-
- /* here's the long form
- if duration & direct free(var) free(val)
- PERM DIR 1
- PERM INDIR 1 1
- TMP DIR
- TMP INDIR 1
- Also if i->variable was a bogus variable name, i->value might not be
- set, so test i->value to protect this
- TMP in this case does NOT mean from the "expect" command. Rather
- it means "an implicit spawn id from any expect or expect_XXX
- command". In other words, there was no variable name provided.
- */
- if (i->value
- && (((i->direct == EXP_DIRECT) && (i->duration == EXP_PERMANENT))
- || ((i->direct == EXP_INDIRECT) && (i->duration == EXP_TEMPORARY)))) {
- ckfree(i->value);
- } else if (i->duration == EXP_PERMANENT) {
- if (i->value) ckfree(i->value);
- if (i->variable) ckfree(i->variable);
- }
-
- i->next = exp_i_pool;
- exp_i_pool = i;
-}
-
-/* generate a descriptor for a "-i" flag */
-/* cannot fail */
-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 */
- /* should only need do this in expect_before/after */
-Tcl_VarTraceProc *updateproc; /* proc to invoke if indirect is written */
-{
- struct exp_i *i;
- char **stringp;
-
- i = exp_new_i();
-
- i->direct = (isdigit(arg[0]) || (arg[0] == '-'))?EXP_DIRECT:EXP_INDIRECT;
- if (i->direct == EXP_DIRECT) {
- stringp = &i->value;
- } else {
- stringp = &i->variable;
- }
-
- i->duration = duration;
- if (duration == EXP_PERMANENT) {
- *stringp = ckalloc(strlen(arg)+1);
- strcpy(*stringp,arg);
- } else {
- *stringp = arg;
- }
-
- i->fd_list = 0;
- exp_i_update(interp,i);
-
- /* if indirect, ask Tcl to tell us when variable is modified */
-
- if (i->direct == EXP_INDIRECT) {
- Tcl_TraceVar(interp, i->variable,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES,
- updateproc, (ClientData) i);
- }
-
- return i;
-}
-
-void
-exp_i_add_fd(i,fd)
-struct exp_i *i;
-int fd;
-{
- struct exp_fd_list *new_fd;
-
- new_fd = exp_new_fd(fd);
- new_fd->next = i->fd_list;
- i->fd_list = new_fd;
-}
-
-/* this routine assumes i->fd is meaningful */
-void
-exp_i_parse_fds(i)
-struct exp_i *i;
-{
- char *p = i->value;
-
- /* reparse it */
- while (1) {
- int m;
- int negative = 0;
- int valid_spawn_id = 0;
-
- m = 0;
- while (isspace(*p)) p++;
- for (;;p++) {
- if (*p == '-') negative = 1;
- else if (isdigit(*p)) {
- m = m*10 + (*p-'0');
- valid_spawn_id = 1;
- } else if (*p == '\0' || isspace(*p)) break;
- }
-
- /* we either have a spawn_id or whitespace at end of string */
-
- /* skip whitespace end-of-string */
- if (!valid_spawn_id) break;
-
- if (negative) m = -m;
-
- exp_i_add_fd(i,m);
- }
-}
-
-/* updates a single exp_i struct */
-void
-exp_i_update(interp,i)
-Tcl_Interp *interp;
-struct exp_i *i;
-{
- char *p; /* string representation of list of spawn ids */
-
- if (i->direct == EXP_INDIRECT) {
- p = Tcl_GetVar(interp,i->variable,TCL_GLOBAL_ONLY);
- if (!p) {
- p = "";
- exp_debuglog("warning: indirect variable %s undefined",i->variable);
- }
-
- if (i->value) {
- if (streq(p,i->value)) return;
-
- /* replace new value with old */
- ckfree(i->value);
- }
- i->value = ckalloc(strlen(p)+1);
- strcpy(i->value,p);
-
- exp_free_fd(i->fd_list);
- i->fd_list = 0;
- } else {
- /* no free, because this should only be called on */
- /* "direct" i's once */
- i->fd_list = 0;
- }
- exp_i_parse_fds(i);
-}
-
-struct exp_i *
-exp_new_i_simple(fd,duration)
-int fd;
-int duration; /* if we have to copy the args */
- /* should only need do this in expect_before/after */
-{
- struct exp_i *i;
-
- i = exp_new_i();
-
- i->direct = EXP_DIRECT;
- i->duration = duration;
-
- exp_i_add_fd(i,fd);
-
- return i;
-}
-
-/*ARGSUSED*/
-static int
-Exp_SendLogCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- char *string;
- int len;
-
- argv++;
- argc--;
-
- if (argc) {
- if (streq(*argv,"--")) {
- argc--; argv++;
- }
- }
-
- if (argc != 1) {
- exp_error(interp,"usage: send [args] string");
- return TCL_ERROR;
- }
-
- string = *argv;
-
- len = strlen(string);
-
- if (debugfile) fwrite(string,1,len,debugfile);
- if (logfile) fwrite(string,1,len,logfile);
-
- return(TCL_OK);
-}
-
-
-/* I've rewritten this to be unbuffered. I did this so you could shove */
-/* large files through "send". If you are concerned about efficiency */
-/* you should quote all your send args to make them one single argument. */
-/*ARGSUSED*/
-static int
-Exp_SendCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- int m = -1; /* spawn id (master) */
- int rc; /* final result of this procedure */
- struct human_arg human_args;
- struct slow_arg slow_args;
-#define SEND_STYLE_STRING_MASK 0x07 /* mask to detect a real string arg */
-#define SEND_STYLE_PLAIN 0x01
-#define SEND_STYLE_HUMAN 0x02
-#define SEND_STYLE_SLOW 0x04
-#define SEND_STYLE_ZERO 0x10
-#define SEND_STYLE_BREAK 0x20
- int send_style = SEND_STYLE_PLAIN;
- int want_cooked = TRUE;
- char *string; /* string to send */
- int len; /* length of string to send */
- int zeros; /* count of how many ascii zeros to send */
-
- char *i_masters = 0;
- struct exp_fd_list *fd;
- struct exp_i *i;
- char *arg;
-
- argv++;
- argc--;
- while (argc) {
- arg = *argv;
- if (arg[0] != '-') break;
- arg++;
- if (exp_flageq1('-',arg)) { /* "--" */
- argc--; argv++;
- break;
- } else if (exp_flageq1('i',arg)) { /* "-i" */
- argc--; argv++;
- if (argc==0) {
- exp_error(interp,"usage: -i spawn_id");
- return(TCL_ERROR);
- }
- i_masters = *argv;
- argc--; argv++;
- continue;
- } else if (exp_flageq1('h',arg)) { /* "-h" */
- argc--; argv++;
- if (-1 == get_human_args(interp,&human_args))
- return(TCL_ERROR);
- send_style = SEND_STYLE_HUMAN;
- continue;
- } else if (exp_flageq1('s',arg)) { /* "-s" */
- argc--; argv++;
- if (-1 == get_slow_args(interp,&slow_args))
- return(TCL_ERROR);
- send_style = SEND_STYLE_SLOW;
- continue;
- } else if (exp_flageq("null",arg,1) || exp_flageq1('0',arg)) {
- argc--; argv++; /* "-null" */
- if (!*argv) zeros = 1;
- else {
- zeros = atoi(*argv);
- argc--; argv++;
- if (zeros < 1) return TCL_OK;
- }
- send_style = SEND_STYLE_ZERO;
- string = "<zero(s)>";
- continue;
- } else if (exp_flageq("raw",arg,1)) { /* "-raw" */
- argc--; argv++;
- want_cooked = FALSE;
- continue;
- } else if (exp_flageq("break",arg,1)) { /* "-break" */
- argc--; argv++;
- send_style = SEND_STYLE_BREAK;
- string = "<break>";
- continue;
- } else {
- exp_error(interp,"usage: unrecognized flag <-%.80s>",arg);
- return TCL_ERROR;
- }
- }
-
- if (send_style & SEND_STYLE_STRING_MASK) {
- if (argc != 1) {
- exp_error(interp,"usage: send [args] string");
- return TCL_ERROR;
- }
- string = *argv;
- }
- len = strlen(string);
-
- if (clientData == &sendCD_user) m = 1;
- else if (clientData == &sendCD_error) m = 2;
- else if (clientData == &sendCD_tty) m = exp_dev_tty;
- else if (!i_masters) {
- /* we really do want to check if it is open */
- /* but since stdin could be closed, we have to first */
- /* get the fd and then convert it from 0 to 1 if necessary */
- if (0 == exp_update_master(interp,&m,0,0))
- return(TCL_ERROR);
- }
-
- /* if master != -1, then it holds desired master */
- /* else i_masters does */
-
- if (m != -1) {
- i = exp_new_i_simple(m,EXP_TEMPORARY);
- } else {
- i = exp_new_i_complex(interp,i_masters,FALSE,(Tcl_VarTraceProc *)0);
- }
-
-#define send_to_stderr (clientData == &sendCD_error)
-#define send_to_proc (clientData == &sendCD_proc)
-#define send_to_user ((clientData == &sendCD_user) || \
- (clientData == &sendCD_tty))
-
- if (send_to_proc) {
- want_cooked = FALSE;
- debuglog("send: sending \"%s\" to {",dprintify(string));
- /* if closing brace doesn't appear, that's because an error */
- /* was encountered before we could send it */
- } else {
- if (debugfile)
- fwrite(string,1,len,debugfile);
- if ((send_to_user && logfile_all) || logfile)
- fwrite(string,1,len,logfile);
- }
-
- for (fd=i->fd_list;fd;fd=fd->next) {
- m = fd->fd;
-
- if (send_to_proc) {
- debuglog(" %d ",m);
- }
-
- /* true if called as Send with user_spawn_id */
- if (exp_is_stdinfd(m)) m = 1;
-
- /* check validity of each - i.e., are they open */
- if (0 == exp_fd2f(interp,m,1,0,"send")) {
- rc = TCL_ERROR;
- goto finish;
- }
- /* Check if Tcl is using a different fd for output */
- if (exp_fs[m].tcl_handle) {
- m = exp_fs[m].tcl_output;
- }
-
- if (want_cooked) string = exp_cook(string,&len);
-
- switch (send_style) {
- case SEND_STYLE_PLAIN:
- rc = exact_write(m,string,len);
- break;
- case SEND_STYLE_SLOW:
- rc = slow_write(interp,m,string,len,&slow_args);
- break;
- case SEND_STYLE_HUMAN:
- rc = human_write(interp,m,string,&human_args);
- break;
- case SEND_STYLE_ZERO:
- for (;zeros>0;zeros--) rc = write(m,"",1);
- /* catching error on last write is sufficient */
- rc = ((rc==1) ? 0 : -1); /* normal is 1 not 0 */
- break;
- case SEND_STYLE_BREAK:
- exp_tty_break(interp,m);
- rc = 0;
- break;
- }
-
- if (rc != 0) {
- if (rc == -1) {
- exp_error(interp,"write(spawn_id=%d): %s",m,Tcl_PosixError(interp));
- rc = TCL_ERROR;
- }
- goto finish;
- }
- }
- if (send_to_proc) debuglog("}\r\n");
-
- rc = TCL_OK;
- finish:
- exp_free_i(interp,i,(Tcl_VarTraceProc *)0);
- return rc;
-}
-
-/*ARGSUSED*/
-static int
-Exp_LogFileCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- static Tcl_DString dstring;
- static int first_time = TRUE;
- static int current_append; /* true if currently appending */
- static char *openarg = 0; /* Tcl file identifier from -open */
- static int leaveopen = FALSE; /* true if -leaveopen was used */
-
- int old_logfile_all = logfile_all;
- FILE *old_logfile = logfile;
- char *old_openarg = openarg;
- int old_leaveopen = leaveopen;
-
- int aflag = FALSE;
- int append = TRUE;
- char *filename = 0;
- char *type;
- FILE *writefilePtr;
- int usage_error_occurred = FALSE;
-
- openarg = 0;
- leaveopen = FALSE;
-
- if (first_time) {
- Tcl_DStringInit(&dstring);
- first_time = FALSE;
- }
-
-
-#define usage_error if (0) ; else {\
- usage_error_occurred = TRUE;\
- goto error;\
- }
-
- /* when this function returns, we guarantee that if logfile_all */
- /* is TRUE, then logfile is non-zero */
-
- argv++;
- argc--;
- for (;argc>0;argc--,argv++) {
- if (streq(*argv,"-open")) {
- if (!argv[1]) usage_error;
- openarg = ckalloc(strlen(argv[1])+1);
- strcpy(openarg,argv[1]);
- argc--; argv++;
- } else if (streq(*argv,"-leaveopen")) {
- if (!argv[1]) usage_error;
- openarg = ckalloc(strlen(argv[1])+1);
- strcpy(openarg,argv[1]);
- leaveopen = TRUE;
- argc--; argv++;
- } else if (streq(*argv,"-a")) {
- aflag = TRUE;
- } else if (streq(*argv,"-info")) {
- if (logfile) {
- if (logfile_all) strcat(interp->result,"-a ");
- if (!current_append) strcat(interp->result,"-noappend ");
- strcat(interp->result,Tcl_DStringValue(&dstring));
- }
- return TCL_OK;
- } else if (streq(*argv,"-noappend")) {
- append = FALSE;
- } else break;
- }
-
- if (argc == 1) {
- filename = argv[0];
- } else if (argc > 1) {
- /* too many arguments */
- usage_error
- }
-
- if (openarg && filename) {
- usage_error
- }
- if (aflag && !(openarg || filename)) {
- usage_error
- }
-
- logfile = 0;
- logfile_all = aflag;
-
- current_append = append;
-
- type = (append?"a":"w");
-
- if (filename) {
- filename = Tcl_TildeSubst(interp,filename,&dstring);
- if (filename == NULL) {
- goto error;
- } else {
- /* Tcl_TildeSubst doesn't store into dstring */
- /* if no ~, so force string into dstring */
- /* this is only needed so that next time around */
- /* we can get dstring for -info if necessary */
- if (Tcl_DStringValue(&dstring)[0] == '\0') {
- Tcl_DStringAppend(&dstring,filename,-1);
- }
- }
-
- errno = 0;
- if (NULL == (logfile = fopen(filename,type))) {
- char *msg;
-
- if (errno == 0) {
- msg = open_failed;
- } else {
- msg = Tcl_PosixError(interp);
- }
- exp_error(interp,"%s: %s",filename,msg);
- Tcl_DStringFree(&dstring);
- goto error;
- }
- } else if (openarg) {
- int cc;
- int fd;
- Tcl_Channel chan;
- int mode;
-#if TCL_MAJOR_VERSION < 8
- Tcl_File tclWriteFile;
-#endif /* TCL_MAJOR_VERSION < 8 */
-
- Tcl_DStringTrunc(&dstring,0);
-#if TCL7_4
- cc = Tcl_GetOpenFile(interp,openarg,1,1,&writefilePtr);
- if (cc == TCL_ERROR) goto error;
-
- if (-1 == (fd = dup(fileno(writefilePtr)))) {
- exp_error(interp,"dup: %s",Tcl_PosixError(interp));
- goto error;
- }
-#endif
- if (!(chan = Tcl_GetChannel(interp,openarg,&mode))) {
- return TCL_ERROR;
- }
- if (!(mode & TCL_WRITABLE)) {
- exp_error(interp,"channel is not writable");
- }
-#if TCL_MAJOR_VERSION < 8
- tclWriteFile = Tcl_GetChannelFile(chan, TCL_WRITABLE);
- fd = dup((int)Tcl_GetFileInfo(tclWriteFile, (int *)0));
-#else
- if (TCL_ERROR == Tcl_GetChannelHandle(chan, TCL_WRITABLE, (ClientData) &fd)) {
- goto error;
- }
- fd = dup(fd);
-#endif /* TCL_MAJOR_VERSION < 8 */
- if (!(logfile = fdopen(fd,type))) {
- exp_error(interp,"fdopen: %s",Tcl_PosixError(interp));
- close(fd);
- goto error;
- }
-
- if (leaveopen) {
- Tcl_DStringAppend(&dstring,"-leaveopen ",-1);
- } else {
- Tcl_DStringAppend(&dstring,"-open ",-1);
- }
-
- Tcl_DStringAppend(&dstring,openarg,-1);
-
- /*
- * It would be convenient now to tell Tcl to close its
- * file descriptor. Alas, if involved in a pipeline, Tcl
- * will be unable to complete a wait on the process.
- * So simply remember that we meant to close it. We will
- * do so later in our own close routine.
- */
- }
- if (logfile) {
- setbuf(logfile,(char *)0);
- exp_close_on_exec(fileno(logfile));
- }
-
- if (old_logfile) {
- fclose(old_logfile);
- }
-
- if (old_openarg) {
- if (!old_leaveopen) {
- close_tcl_file(interp,old_openarg);
- }
- ckfree((char *)old_openarg);
- }
-
- return TCL_OK;
-
- error:
- if (old_logfile) {
- logfile = old_logfile;
- logfile_all = old_logfile_all;
- }
-
- if (openarg) ckfree(openarg);
- openarg = old_openarg;
- leaveopen = old_leaveopen;
-
- if (usage_error_occurred) {
- exp_error(interp,"usage: log_file [-info] [-noappend] [[-a] file] [-[leave]open [open ...]]");
- }
-
- return TCL_ERROR;
-}
-
-/*ARGSUSED*/
-static int
-Exp_LogUserCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- int old_loguser = loguser;
-
- if (argc == 0 || (argc == 2 && streq(argv[1],"-info"))) {
- /* do nothing */
- } else if (argc == 2) {
- if (0 == atoi(argv[1])) loguser = FALSE;
- else loguser = TRUE;
- } else {
- exp_error(interp,"usage: [-info|1|0]");
- }
-
- sprintf(interp->result,"%d",old_loguser);
-
- return(TCL_OK);
-}
-
-#ifdef TCL_DEBUGGER
-/*ARGSUSED*/
-static int
-Exp_DebugCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- int now = FALSE; /* soon if FALSE, now if TRUE */
- int exp_tcl_debugger_was_available = exp_tcl_debugger_available;
-
- if (argc > 3) goto usage;
-
- if (argc == 1) {
- sprintf(interp->result,"%d",exp_tcl_debugger_available);
- return TCL_OK;
- }
-
- argv++;
-
- while (*argv) {
- if (streq(*argv,"-now")) {
- now = TRUE;
- argv++;
- }
- else break;
- }
-
- if (!*argv) {
- if (now) {
- Dbg_On(interp,1);
- exp_tcl_debugger_available = 1;
- } else {
- goto usage;
- }
- } else if (streq(*argv,"0")) {
- Dbg_Off(interp);
- exp_tcl_debugger_available = 0;
- } else {
- Dbg_On(interp,now);
- exp_tcl_debugger_available = 1;
- }
- sprintf(interp->result,"%d",exp_tcl_debugger_was_available);
- return(TCL_OK);
- usage:
- exp_error(interp,"usage: [[-now] 1|0]");
- return TCL_ERROR;
-}
-#endif
-
-/*ARGSUSED*/
-static int
-Exp_ExpInternalCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- static Tcl_DString dstring;
- static int first_time = TRUE;
- int fopened = FALSE;
-
- if (first_time) {
- Tcl_DStringInit(&dstring);
- first_time = FALSE;
- }
-
- if (argc > 1 && streq(argv[1],"-info")) {
- if (debugfile) {
- sprintf(interp->result,"-f %s ",
- Tcl_DStringValue(&dstring));
- }
- strcat(interp->result,((exp_is_debugging==0)?"0":"1"));
- return TCL_OK;
- }
-
- argv++;
- argc--;
- while (argc) {
- if (!streq(*argv,"-f")) break;
- argc--;argv++;
- if (argc < 1) goto usage;
- if (debugfile) fclose(debugfile);
- argv[0] = Tcl_TildeSubst(interp, argv[0],&dstring);
- if (argv[0] == NULL) goto error;
- else {
- /* Tcl_TildeSubst doesn't store into dstring */
- /* if no ~, so force string into dstring */
- /* this is only needed so that next time around */
- /* we can get dstring for -info if necessary */
- if (Tcl_DStringValue(&dstring)[0] == '\0') {
- Tcl_DStringAppend(&dstring,argv[0],-1);
- }
- }
-
- errno = 0;
- if (NULL == (debugfile = fopen(*argv,"a"))) {
- char *msg;
-
- if (errno == 0) {
- msg = open_failed;
- } else {
- msg = Tcl_PosixError(interp);
- }
-
- exp_error(interp,"%s: %s",*argv,msg);
- goto error;
- }
- setbuf(debugfile,(char *)0);
- exp_close_on_exec(fileno(debugfile));
- fopened = TRUE;
- argc--;argv++;
- }
-
- if (argc != 1) goto usage;
-
- /* if no -f given, close file */
- if (fopened == FALSE && debugfile) {
- fclose(debugfile);
- debugfile = 0;
- Tcl_DStringFree(&dstring);
- }
-
- exp_is_debugging = atoi(*argv);
- return(TCL_OK);
- usage:
- exp_error(interp,"usage: [-f file] expr");
- error:
- Tcl_DStringFree(&dstring);
- return TCL_ERROR;
-}
-
-char *exp_onexit_action = 0;
-
-/*ARGSUSED*/
-static int
-Exp_ExitCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- int value = 0;
-
- argv++;
-
- if (*argv) {
- if (exp_flageq(*argv,"-onexit",3)) {
- argv++;
- if (*argv) {
- int len = strlen(*argv);
- if (exp_onexit_action)
- ckfree(exp_onexit_action);
- exp_onexit_action = ckalloc(len + 1);
- strcpy(exp_onexit_action,*argv);
- } else if (exp_onexit_action) {
- Tcl_AppendResult(interp,exp_onexit_action,(char *)0);
- }
- return TCL_OK;
- } else if (exp_flageq(*argv,"-noexit",3)) {
- argv++;
- exp_exit_handlers((ClientData)interp);
- return TCL_OK;
- }
- }
-
- if (*argv) {
- if (Tcl_GetInt(interp, *argv, &value) != TCL_OK) {
- return TCL_ERROR;
- }
- }
-
- exp_exit(interp,value);
- /*NOTREACHED*/
-}
-
-/* so cmd table later is more intuitive */
-#define Exp_CloseObjCmd Exp_CloseCmd
-
-/*ARGSUSED*/
-static int
-Exp_CloseCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-#if TCL_MAJOR_VERSION < 8
-char **argv;
-#else
-Tcl_Obj *CONST argv[]; /* Argument objects. */
-#endif
-{
- int onexec_flag = FALSE; /* true if -onexec seen */
- int close_onexec;
- int slave_flag = FALSE;
- int m = -1;
-
- int argc_orig = argc;
-#if TCL_MAJOR_VERSION < 8
- char **argv_orig = argv;
-#else
- Tcl_Obj *CONST *argv_orig = argv;
-#endif
-
- argc--; argv++;
-
-#if TCL_MAJOR_VERSION < 8
-# define STARARGV *argv
-#else
-# if TCL_MINOR_VERSION < 3
-# define STARARGV Tcl_GetStringFromObj(*argv,(int *)0)
-# else
-# define STARARGV Tcl_GetString(*argv)
-# endif
-#endif
-
- for (;argc>0;argc--,argv++) {
- if (streq("-i",STARARGV)) {
- argc--; argv++;
- if (argc == 0) {
- exp_error(interp,"usage: -i spawn_id");
- return(TCL_ERROR);
- }
- m = atoi(STARARGV);
- } else if (streq(STARARGV,"-slave")) {
- slave_flag = TRUE;
- } else if (streq(STARARGV,"-onexec")) {
- argc--; argv++;
- if (argc == 0) {
- exp_error(interp,"usage: -onexec 0|1");
- return(TCL_ERROR);
- }
- onexec_flag = TRUE;
- close_onexec = atoi(STARARGV);
- } else break;
- }
-
- if (argc) {
- /* doesn't look like our format, it must be a Tcl-style file */
- /* handle. Lucky that formats are easily distinguishable. */
- /* Historical note: we used "close" long before there was a */
- /* Tcl builtin by the same name. */
-
- Tcl_CmdInfo info;
- Tcl_ResetResult(interp);
- if (0 == Tcl_GetCommandInfo(interp,"close",&info)) {
- info.clientData = 0;
- }
-#if TCL_MAJOR_VERSION < 8
- return(Tcl_CloseCmd(info.clientData,interp,argc_orig,argv_orig));
-#else
- return(Tcl_CloseObjCmd(info.clientData,interp,argc_orig,argv_orig));
-#endif
- }
-
- if (m == -1) {
- if (exp_update_master(interp,&m,1,0) == 0) return(TCL_ERROR);
- }
-
- if (slave_flag) {
- struct exp_f *f = exp_fd2f(interp,m,1,0,"-slave");
- if (!f) return TCL_ERROR;
-
- if (f->slave_fd) {
- close(f->slave_fd);
- f->slave_fd = EXP_NOFD;
-
- exp_slave_control(m,1);
-
- return TCL_OK;
- } else {
- exp_error(interp,"no such slave");
- return TCL_ERROR;
- }
- }
-
- if (onexec_flag) {
- /* heck, don't even bother to check if fd is open or a real */
- /* spawn id, nothing else depends on it */
- fcntl(m,F_SETFD,close_onexec);
- return TCL_OK;
- }
-
- return(exp_close(interp,m));
-}
-
-/*ARGSUSED*/
-static void
-tcl_tracer(clientData,interp,level,command,cmdProc,cmdClientData,argc,argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int level;
-char *command;
-int (*cmdProc)();
-ClientData cmdClientData;
-int argc;
-char *argv[];
-{
- int i;
-
- /* come out on stderr, by using errorlog */
- errorlog("%2d",level);
- for (i = 0;i<level;i++) exp_nferrorlog(" ",0/*ignored - satisfy lint*/);
- errorlog("%s\r\n",command);
-}
-
-/*ARGSUSED*/
-static int
-Exp_StraceCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- static int trace_level = 0;
- static Tcl_Trace trace_handle;
-
- if (argc > 1 && streq(argv[1],"-info")) {
- sprintf(interp->result,"%d",trace_level);
- return TCL_OK;
- }
-
- if (argc != 2) {
- exp_error(interp,"usage: trace level");
- return(TCL_ERROR);
- }
- /* tracing already in effect, undo it */
- if (trace_level > 0) Tcl_DeleteTrace(interp,trace_handle);
-
- /* get and save new trace level */
- trace_level = atoi(argv[1]);
- if (trace_level > 0)
- trace_handle = Tcl_CreateTrace(interp,
- trace_level,tcl_tracer,(ClientData)0);
- return(TCL_OK);
-}
-
-/* following defn's are stolen from tclUnix.h */
-
-/*
- * The type of the status returned by wait varies from UNIX system
- * to UNIX system. The macro below defines it:
- */
-
-#if 0
-#ifndef NO_UNION_WAIT
-# define WAIT_STATUS_TYPE union wait
-#else
-# define WAIT_STATUS_TYPE int
-#endif
-#endif /* 0 */
-
-/*
- * following definitions stolen from tclUnix.h
- * (should have been made public!)
-
- * Supply definitions for macros to query wait status, if not already
- * defined in header files above.
- */
-
-#if 0
-#ifndef WIFEXITED
-# define WIFEXITED(stat) (((*((int *) &(stat))) & 0xff) == 0)
-#endif
-
-#ifndef WEXITSTATUS
-# define WEXITSTATUS(stat) (((*((int *) &(stat))) >> 8) & 0xff)
-#endif
-
-#ifndef WIFSIGNALED
-# define WIFSIGNALED(stat) (((*((int *) &(stat)))) && ((*((int *) &(stat))) == ((*((int *) &(stat))) & 0x00ff)))
-#endif
-
-#ifndef WTERMSIG
-# define WTERMSIG(stat) ((*((int *) &(stat))) & 0x7f)
-#endif
-
-#ifndef WIFSTOPPED
-# define WIFSTOPPED(stat) (((*((int *) &(stat))) & 0xff) == 0177)
-#endif
-
-#ifndef WSTOPSIG
-# define WSTOPSIG(stat) (((*((int *) &(stat))) >> 8) & 0xff)
-#endif
-#endif /* 0 */
-
-/* end of stolen definitions */
-
-/* Describe the processes created with Expect's fork.
-This allows us to wait on them later.
-
-This is maintained as a linked list. As additional procs are forked,
-new links are added. As procs disappear, links are marked so that we
-can reuse them later.
-*/
-
-struct forked_proc {
- int pid;
- WAIT_STATUS_TYPE wait_status;
- enum {not_in_use, wait_done, wait_not_done} link_status;
- struct forked_proc *next;
-} *forked_proc_base = 0;
-
-void
-fork_clear_all()
-{
- struct forked_proc *f;
-
- for (f=forked_proc_base;f;f=f->next) {
- f->link_status = not_in_use;
- }
-}
-
-void
-fork_init(f,pid)
-struct forked_proc *f;
-int pid;
-{
- f->pid = pid;
- f->link_status = wait_not_done;
-}
-
-/* make an entry for a new proc */
-void
-fork_add(pid)
-int pid;
-{
- struct forked_proc *f;
-
- for (f=forked_proc_base;f;f=f->next) {
- if (f->link_status == not_in_use) break;
- }
-
- /* add new entry to the front of the list */
- if (!f) {
- f = (struct forked_proc *)ckalloc(sizeof(struct forked_proc));
- f->next = forked_proc_base;
- forked_proc_base = f;
- }
- fork_init(f,pid);
-}
-
-/* Provide a last-chance guess for this if not defined already */
-#ifndef WNOHANG
-#define WNOHANG WNOHANG_BACKUP_VALUE
-#endif
-
-/* wait returns are a hodgepodge of things
- If wait fails, something seriously has gone wrong, for example:
- bogus arguments (i.e., incorrect, bogus spawn id)
- no children to wait on
- async event failed
- If wait succeeeds, something happened on a particular pid
- 3rd arg is 0 if successfully reaped (if signal, additional fields supplied)
- 3rd arg is -1 if unsuccessfully reaped (additional fields supplied)
-*/
-/*ARGSUSED*/
-static int
-Exp_WaitCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- int master_supplied = FALSE;
- int m; /* master waited for */
- struct exp_f *f; /* ditto */
- struct forked_proc *fp = 0; /* handle to a pure forked proc */
-
- struct exp_f ftmp; /* temporary memory for either f or fp */
-
- int nowait = FALSE;
- int result = 0; /* 0 means child was successfully waited on */
- /* -1 means an error occurred */
- /* -2 means no eligible children to wait on */
-#define NO_CHILD -2
-
- argv++;
- argc--;
- for (;argc>0;argc--,argv++) {
- if (streq(*argv,"-i")) {
- argc--; argv++;
- if (argc==0) {
- exp_error(interp,"usage: -i spawn_id");
- return(TCL_ERROR);
- }
- master_supplied = TRUE;
- m = atoi(*argv);
- } else if (streq(*argv,"-nowait")) {
- nowait = TRUE;
- }
- }
-
- if (!master_supplied) {
- if (0 == exp_update_master(interp,&m,0,0))
- return TCL_ERROR;
- }
-
- if (m != EXP_SPAWN_ID_ANY) {
- if (0 == exp_fd2f(interp,m,0,0,"wait")) {
- return TCL_ERROR;
- }
-
- f = exp_fs + m;
-
- /* check if waited on already */
- /* things opened by "open" or set with -nowait */
- /* are marked sys_waited already */
- if (!f->sys_waited) {
- if (nowait) {
- /* should probably generate an error */
- /* if SIGCHLD is trapped. */
-
- /* pass to Tcl, so it can do wait */
- /* in background */
-#if TCL_MAJOR_VERSION < 8
- Tcl_DetachPids(1,&f->pid);
-#else
- Tcl_DetachPids(1,(Tcl_Pid *)&f->pid);
-#endif
- exp_wait_zero(&f->wait);
- } else {
- while (1) {
- if (Tcl_AsyncReady()) {
- int rc = Tcl_AsyncInvoke(interp,TCL_OK);
- if (rc != TCL_OK) return(rc);
- }
-
- result = waitpid(f->pid,&f->wait,0);
- if (result == f->pid) break;
- if (result == -1) {
- if (errno == EINTR) continue;
- else break;
- }
- }
- }
- }
-
- /*
- * Now have Tcl reap anything we just detached.
- * This also allows procs user has created with "exec &"
- * and and associated with an "exec &" process to be reaped.
- */
-
- Tcl_ReapDetachedProcs();
- exp_rearm_sigchld(interp); /* new */
- } else {
- /* wait for any of our own spawned processes */
- /* we call waitpid rather than wait to avoid running into */
- /* someone else's processes. Yes, according to Ousterhout */
- /* this is the best way to do it. */
-
- for (m=0;m<=exp_fd_max;m++) {
- f = exp_fs + m;
- if (!f->valid) continue;
- if (f->pid == exp_getpid) continue; /* skip ourself */
- if (f->user_waited) continue; /* one wait only! */
- if (f->sys_waited) break;
- restart:
- result = waitpid(f->pid,&f->wait,WNOHANG);
- if (result == f->pid) break;
- if (result == 0) continue; /* busy, try next */
- if (result == -1) {
- if (errno == EINTR) goto restart;
- else break;
- }
- }
-
- /* if it's not a spawned process, maybe its a forked process */
- for (fp=forked_proc_base;fp;fp=fp->next) {
- if (fp->link_status == not_in_use) continue;
- restart2:
- result = waitpid(fp->pid,&fp->wait_status,WNOHANG);
- if (result == fp->pid) {
- m = -1; /* DOCUMENT THIS! */
- break;
- }
- if (result == 0) continue; /* busy, try next */
- if (result == -1) {
- if (errno == EINTR) goto restart2;
- else break;
- }
- }
-
- if (m > exp_fd_max) {
- result = NO_CHILD; /* no children */
- Tcl_ReapDetachedProcs();
- }
- exp_rearm_sigchld(interp);
- }
-
- /* sigh, wedge forked_proc into an exp_f structure so we don't
- * have to rewrite remaining code (too much)
- */
- if (fp) {
- f = &ftmp;
- f->pid = fp->pid;
- f->wait = fp->wait_status;
- }
-
- /* non-portable assumption that pid_t can be printed with %d */
-
- if (result == -1) {
- sprintf(interp->result,"%d %d -1 %d POSIX %s %s",
- f->pid,m,errno,Tcl_ErrnoId(),Tcl_ErrnoMsg(errno));
- result = TCL_OK;
- } else if (result == NO_CHILD) {
- interp->result = "no children";
- return TCL_ERROR;
- } else {
- sprintf(interp->result,"%d %d 0 %d",
- f->pid,m,WEXITSTATUS(f->wait));
- if (WIFSIGNALED(f->wait)) {
- Tcl_AppendElement(interp,"CHILDKILLED");
- Tcl_AppendElement(interp,Tcl_SignalId((int)(WTERMSIG(f->wait))));
- Tcl_AppendElement(interp,Tcl_SignalMsg((int) (WTERMSIG(f->wait))));
- } else if (WIFSTOPPED(f->wait)) {
- Tcl_AppendElement(interp,"CHILDSUSP");
- Tcl_AppendElement(interp,Tcl_SignalId((int) (WSTOPSIG(f->wait))));
- Tcl_AppendElement(interp,Tcl_SignalMsg((int) (WSTOPSIG(f->wait))));
- }
- }
-
- if (fp) {
- fp->link_status = not_in_use;
- return ((result == -1)?TCL_ERROR:TCL_OK);
- }
-
- f->sys_waited = TRUE;
- f->user_waited = TRUE;
-
- /* if user has already called close, make sure fd really is closed */
- /* and forget about this entry entirely */
- if (f->user_closed) {
- if (!f->sys_closed) {
- sys_close(m,f);
- }
- f->valid = FALSE;
- }
- return ((result == -1)?TCL_ERROR:TCL_OK);
-}
-
-/*ARGSUSED*/
-static int
-Exp_ForkCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- int rc;
- if (argc > 1) {
- exp_error(interp,"usage: fork");
- return(TCL_ERROR);
- }
-
- rc = fork();
- if (rc == -1) {
- exp_error(interp,"fork: %s",Tcl_PosixError(interp));
- return TCL_ERROR;
- } else if (rc == 0) {
- /* child */
- exp_forked = TRUE;
- exp_getpid = getpid();
- fork_clear_all();
- } else {
- /* parent */
- fork_add(rc);
- }
-
- /* both child and parent follow remainder of code */
- sprintf(interp->result,"%d",rc);
- debuglog("fork: returns {%s}\r\n",interp->result);
- return(TCL_OK);
-}
-
-/*ARGSUSED*/
-static int
-Exp_DisconnectCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- /* tell Saber to ignore non-use of ttyfd */
- /*SUPPRESS 591*/
- int ttyfd;
-
- if (argc > 1) {
- exp_error(interp,"usage: disconnect");
- return(TCL_ERROR);
- }
-
- if (exp_disconnected) {
- exp_error(interp,"already disconnected");
- return(TCL_ERROR);
- }
- if (!exp_forked) {
- exp_error(interp,"can only disconnect child process");
- return(TCL_ERROR);
- }
- exp_disconnected = TRUE;
-
- /* ignore hangup signals generated by testing ptys in getptymaster */
- /* and other places */
- signal(SIGHUP,SIG_IGN);
-
- /* reopen prevents confusion between send/expect_user */
- /* accidentally mapping to a real spawned process after a disconnect */
- if (exp_fs[0].pid != EXP_NOPID) {
- exp_close(interp,0);
- open("/dev/null",0);
- fd_new(0, EXP_NOPID);
- }
- if (exp_fs[1].pid != EXP_NOPID) {
- exp_close(interp,1);
- open("/dev/null",1);
- fd_new(1, EXP_NOPID);
- }
- if (exp_fs[2].pid != EXP_NOPID) {
- /* reopen stderr saves error checking in error/log routines. */
- exp_close(interp,2);
- open("/dev/null",1);
- fd_new(2, EXP_NOPID);
- }
-
- Tcl_UnsetVar(interp,"tty_spawn_id",TCL_GLOBAL_ONLY);
-
-#ifdef DO_SETSID
- setsid();
-#else
-#ifdef SYSV3
- /* put process in our own pgrp, and lose controlling terminal */
-#ifdef sysV88
- /* With setpgrp first, child ends up with closed stdio */
- /* according to Dave Schmitt <daves@techmpc.csg.gss.mot.com> */
- if (fork()) exit(0);
- setpgrp();
-#else
- setpgrp();
- /*signal(SIGHUP,SIG_IGN); moved out to above */
- if (fork()) exit(0); /* first child exits (as per Stevens, */
- /* UNIX Network Programming, p. 79-80) */
- /* second child process continues as daemon */
-#endif
-#else /* !SYSV3 */
-#ifdef MIPS_BSD
- /* required on BSD side of MIPS OS <jmsellen@watdragon.waterloo.edu> */
-# include <sysv/sys.s>
- syscall(SYS_setpgrp);
-#endif
- setpgrp(0,0);
-/* setpgrp(0,getpid());*/ /* put process in our own pgrp */
-
-/* Pyramid lacks this defn */
-#ifdef TIOCNOTTY
- ttyfd = open("/dev/tty", O_RDWR);
- if (ttyfd >= 0) {
- /* zap controlling terminal if we had one */
- (void) ioctl(ttyfd, TIOCNOTTY, (char *)0);
- (void) close(ttyfd);
- }
-#endif /* TIOCNOTTY */
-
-#endif /* SYSV3 */
-#endif /* DO_SETSID */
- return(TCL_OK);
-}
-
-/*ARGSUSED*/
-static int
-Exp_OverlayCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- int newfd, oldfd;
- int dash_name = 0;
- char *command;
-
- argc--; argv++;
- while (argc) {
- if (*argv[0] != '-') break; /* not a flag */
- if (streq(*argv,"-")) { /* - by itself */
- argc--; argv++;
- dash_name = 1;
- continue;
- }
- newfd = atoi(argv[0]+1);
- argc--; argv++;
- if (argc == 0) {
- exp_error(interp,"overlay -# requires additional argument");
- return(TCL_ERROR);
- }
- oldfd = atoi(argv[0]);
- argc--; argv++;
- debuglog("overlay: mapping fd %d to %d\r\n",oldfd,newfd);
- if (oldfd != newfd) (void) dup2(oldfd,newfd);
- else debuglog("warning: overlay: old fd == new fd (%d)\r\n",oldfd);
- }
- if (argc == 0) {
- exp_error(interp,"need program name");
- return(TCL_ERROR);
- }
- command = argv[0];
- if (dash_name) {
- argv[0] = ckalloc(1+strlen(command));
- sprintf(argv[0],"-%s",command);
- }
-
- signal(SIGINT, SIG_DFL);
- signal(SIGQUIT, SIG_DFL);
- (void) execvp(command,argv);
- exp_error(interp,"execvp(%s): %s\r\n",argv[0],Tcl_PosixError(interp));
- return(TCL_ERROR);
-}
-
-#if 0
-/*ARGSUSED*/
-int
-cmdReady(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- char num[4]; /* can hold up to "999 " */
- char buf[1024]; /* can easily hold 256 spawn_ids! */
- int i, j;
- int *masters, *masters2;
- int timeout = get_timeout();
-
- if (argc < 2) {
- exp_error(interp,"usage: ready spawn_id1 [spawn_id2 ...]");
- return(TCL_ERROR);
- }
-
- masters = (int *)ckalloc((argc-1)*sizeof(int));
- masters2 = (int *)ckalloc((argc-1)*sizeof(int));
-
- for (i=1;i<argc;i++) {
- j = atoi(argv[i]);
- if (!exp_fd2f(interp,j,1,"ready")) {
- ckfree(masters);
- return(TCL_ERROR);
- }
- masters[i-1] = j;
- }
- j = i-1;
- if (TCL_ERROR == ready(masters,i-1,masters2,&j,&timeout))
- return(TCL_ERROR);
-
- /* pack result back into out-array */
- buf[0] = '\0';
- for (i=0;i<j;i++) {
- sprintf(num,"%d ",masters2[i]); /* note extra blank */
- strcat(buf,num);
- }
- ckfree(masters); ckfree(masters2);
- Tcl_Return(interp,buf,TCL_VOLATILE);
- return(TCL_OK);
-}
-#endif
-
-/*ARGSUSED*/
-int
-Exp_InterpreterCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- if (argc != 1) {
- exp_error(interp,"no arguments allowed");
- return(TCL_ERROR);
- }
-
- return(exp_interpreter(interp));
- /* errors and ok, are caught by exp_interpreter() and discarded */
- /* to return TCL_OK, type "return" */
-}
-
-/* this command supercede's Tcl's builtin CONTINUE command */
-/*ARGSUSED*/
-int
-Exp_ExpContinueDeprecatedCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- if (argc == 1) return(TCL_CONTINUE);
- else if (argc == 2) {
- if (streq(argv[1],"-expect")) {
- debuglog("continue -expect is deprecated, use exp_continue\r\n");
- return(EXP_CONTINUE);
- }
- }
- exp_error(interp,"usage: continue [-expect]\n");
- return(TCL_ERROR);
-}
-
-/* this command supercede's Tcl's builtin CONTINUE command */
-/*ARGSUSED*/
-int
-Exp_ExpContinueCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- if (argc == 1) {
- return EXP_CONTINUE;
- } else if ((argc == 2) && (0 == strcmp(argv[1],"-continue_timer"))) {
- return EXP_CONTINUE_TIMER;
- }
-
- exp_error(interp,"usage: exp_continue [-continue_timer]\n");
- return(TCL_ERROR);
-}
-
-#if TCL_MAJOR_VERSION < 8
-/* most of this is directly from Tcl's definition for return */
-/*ARGSUSED*/
-int
-Exp_InterReturnCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- /* let Tcl's return command worry about args */
- /* if successful (i.e., TCL_RETURN is returned) */
- /* modify the result, so that we will handle it specially */
-
- int result = Tcl_ReturnCmd(clientData,interp,argc,argv);
- if (result == TCL_RETURN)
- result = EXP_TCL_RETURN;
- return result;
-}
-#else
-/* 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[];
-{
- /* let Tcl's return command worry about args */
- /* if successful (i.e., TCL_RETURN is returned) */
- /* modify the result, so that we will handle it specially */
-
-#if TCL_MAJOR_VERSION < 8
- int result = Tcl_ReturnCmd(clientData,interp,objc,objv);
-#else
- int result = Tcl_ReturnObjCmd(clientData,interp,objc,objv);
-#endif
-
- if (result == TCL_RETURN)
- result = EXP_TCL_RETURN;
- return result;
-}
-#endif
-
-/*ARGSUSED*/
-int
-Exp_OpenCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- struct exp_f *f;
- int m = -1;
- int m2;
- int leaveopen = FALSE;
- Tcl_Channel chan;
-
- argc--; argv++;
-
- for (;argc>0;argc--,argv++) {
- if (streq(*argv,"-i")) {
- argc--; argv++;
- if (!*argv) {
- exp_error(interp,"usage: -i spawn_id");
- return TCL_ERROR;
- }
- m = atoi(*argv);
- } else if (streq(*argv,"-leaveopen")) {
- leaveopen = TRUE;
- argc--; argv++;
- } else break;
- }
-
- if (m == -1) {
- if (exp_update_master(interp,&m,0,0) == 0) return TCL_ERROR;
- }
-
- if (0 == (f = exp_fd2f(interp,m,1,0,"exp_open"))) return TCL_ERROR;
-
- /* make a new copy of file descriptor */
- if (-1 == (m2 = dup(m))) {
- exp_error(interp,"fdopen: %s",Tcl_PosixError(interp));
- return TCL_ERROR;
- }
-
- if (!leaveopen) {
- /* remove from Expect's memory in anticipation of passing to Tcl */
- if (f->pid != EXP_NOPID) {
-#if TCL_MAJOR_VERSION < 8
- Tcl_DetachPids(1,&f->pid);
-#else
- Tcl_DetachPids(1,(Tcl_Pid *)&f->pid);
-#endif
- f->pid = EXP_NOPID;
- f->sys_waited = f->user_waited = TRUE;
- }
- exp_close(interp,m);
- }
-
- chan = Tcl_MakeFileChannel(
-#if TCL_MAJOR_VERSION < 8
- (ClientData)m2,
-#endif
- (ClientData)m2,
- TCL_READABLE|TCL_WRITABLE);
- Tcl_RegisterChannel(interp, chan);
- Tcl_AppendResult(interp, Tcl_GetChannelName(chan), (char *) NULL);
- return TCL_OK;
-}
-
-/* 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 */
-{
- for (;*flag;flag++,string++,minlen--) {
- if (*string == '\0') break;
- if (*string != *flag) return 0;
- }
- if (*string == '\0' && minlen <= 0) return 1;
- return 0;
-}
-
-void
-exp_create_commands(interp,c)
-Tcl_Interp *interp;
-struct exp_cmd_data *c;
-{
-#if TCL_MAJOR_VERSION < 8
- Interp *iPtr = (Interp *) interp;
-#else
- Namespace *globalNsPtr = (Namespace *) Tcl_GetGlobalNamespace(interp);
- Namespace *currNsPtr = (Namespace *) Tcl_GetCurrentNamespace(interp);
-#endif
- char cmdnamebuf[80];
-
- for (;c->name;c++) {
-#if TCL_MAJOR_VERSION < 8
- int create = FALSE;
- /* if already defined, don't redefine */
- if (c->flags & EXP_REDEFINE) create = TRUE;
- else if (!Tcl_FindHashEntry(&iPtr->commandTable,c->name)) {
- create = TRUE;
- }
- if (create) {
- Tcl_CreateCommand(interp,c->name,c->proc,
- c->data,exp_deleteProc);
- }
-#else
- /* if already defined, don't redefine */
- if ((c->flags & EXP_REDEFINE) ||
- !(Tcl_FindHashEntry(&globalNsPtr->cmdTable,c->name) ||
- Tcl_FindHashEntry(&currNsPtr->cmdTable,c->name))) {
- if (c->objproc)
- Tcl_CreateObjCommand(interp,c->name,
- c->objproc,c->data,exp_deleteObjProc);
- else
- Tcl_CreateCommand(interp,c->name,c->proc,
- c->data,exp_deleteProc);
- }
-#endif
- if (!(c->name[0] == 'e' &&
- c->name[1] == 'x' &&
- c->name[2] == 'p')
- && !(c->flags & EXP_NOPREFIX)) {
- sprintf(cmdnamebuf,"exp_%s",c->name);
-#if TCL_MAJOR_VERSION < 8
- Tcl_CreateCommand(interp,cmdnamebuf,c->proc,
- c->data,exp_deleteProc);
-#else
- if (c->objproc)
- Tcl_CreateObjCommand(interp,cmdnamebuf,c->objproc,c->data,
- exp_deleteObjProc);
- else
- Tcl_CreateCommand(interp,cmdnamebuf,c->proc,
- c->data,exp_deleteProc);
-#endif
- }
- }
-}
-
-static struct exp_cmd_data cmd_data[] = {
-#if TCL_MAJOR_VERSION < 8
-{"close", Exp_CloseCmd, 0, EXP_REDEFINE},
-#else
-{"close", Exp_CloseObjCmd, 0, 0, EXP_REDEFINE},
-#endif
-#ifdef TCL_DEBUGGER
-{"debug", exp_proc(Exp_DebugCmd), 0, 0},
-#endif
-{"exp_internal",exp_proc(Exp_ExpInternalCmd), 0, 0},
-{"disconnect", exp_proc(Exp_DisconnectCmd), 0, 0},
-{"exit", exp_proc(Exp_ExitCmd), 0, EXP_REDEFINE},
-{"exp_continue",exp_proc(Exp_ExpContinueCmd),0, 0},
-{"fork", exp_proc(Exp_ForkCmd), 0, 0},
-{"exp_pid", exp_proc(Exp_ExpPidCmd), 0, 0},
-{"getpid", exp_proc(Exp_GetpidDeprecatedCmd),0, 0},
-{"interpreter", exp_proc(Exp_InterpreterCmd), 0, 0},
-{"log_file", exp_proc(Exp_LogFileCmd), 0, 0},
-{"log_user", exp_proc(Exp_LogUserCmd), 0, 0},
-{"exp_open", exp_proc(Exp_OpenCmd), 0, 0},
-{"overlay", exp_proc(Exp_OverlayCmd), 0, 0},
-#if TCL_MAJOR_VERSION < 8
-{"inter_return",Exp_InterReturnCmd, 0, 0},
-#else
-{"inter_return",Exp_InterReturnObjCmd, 0, 0, 0},
-#endif
-{"send", exp_proc(Exp_SendCmd), (ClientData)&sendCD_proc, 0},
-{"send_error", exp_proc(Exp_SendCmd), (ClientData)&sendCD_error, 0},
-{"send_log", exp_proc(Exp_SendLogCmd), 0, 0},
-{"send_tty", exp_proc(Exp_SendCmd), (ClientData)&sendCD_tty, 0},
-{"send_user", exp_proc(Exp_SendCmd), (ClientData)&sendCD_user, 0},
-{"sleep", exp_proc(Exp_SleepCmd), 0, 0},
-{"spawn", exp_proc(Exp_SpawnCmd), 0, 0},
-{"strace", exp_proc(Exp_StraceCmd), 0, 0},
-{"wait", exp_proc(Exp_WaitCmd), 0, 0},
-{0}};
-
-void
-exp_init_most_cmds(interp)
-Tcl_Interp *interp;
-{
- exp_create_commands(interp,cmd_data);
-
-#ifdef HAVE_PTYTRAP
- Tcl_InitHashTable(&slaveNames,TCL_STRING_KEYS);
-#endif /* HAVE_PTYTRAP */
-
- exp_close_in_child = exp_close_tcl_files;
-}
-/* cribbed directly from tclBasic.c */
-int
-Tcl_CloseCmd(stuff, interp, argc, argv)
- ClientData *stuff;
- Tcl_Interp *interp;
- int argc;
- char **argv;
-{
-#define NUM_ARGS 20
- Tcl_Obj *(argStorage[NUM_ARGS]);
- register Tcl_Obj **objv = argStorage;
- int i, result;
- Tcl_Obj *objPtr;
-
- /*
- * Create the object argument array "objv". Make sure objv is large
- * enough to hold the objc arguments plus 1 extra for the zero
- * end-of-objv word.
- */
-
- if ((argc + 1) > NUM_ARGS) {
- objv = (Tcl_Obj **)
- Tcl_Alloc((unsigned)(argc + 1) * sizeof(Tcl_Obj *));
- }
-
- for (i = 0; i < argc; i++) {
- objPtr = Tcl_NewStringObj(argv[i], -1);
- Tcl_IncrRefCount(objPtr);
- objv[i] = objPtr;
- }
- objv[argc] = 0;
-
- /*
- * Invoke the command's object-based Tcl_ObjCmdProc.
- */
-
- result = Tcl_CloseObjCmd(stuff, interp, argc, objv);
-
- /*
- * Move the interpreter's object result to the string result,
- * then reset the object result.
- * FAILS IF OBJECT RESULT'S STRING REPRESENTATION CONTAINS NULL BYTES.
- */
-
-#if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION < 3)
- Tcl_SetResult(interp, TclGetStringFromObj(Tcl_GetObjResult(interp), (int *) NULL), TCL_VOLATILE);
-#else
- Tcl_SetResult(interp, TclGetString(Tcl_GetObjResult(interp)), TCL_VOLATILE);
-#endif
- /*
- * Decrement the ref counts for the argument objects created above,
- * then free the objv array if malloc'ed storage was used.
- */
-
- for (i = 0; i < argc; i++) {
- objPtr = objv[i];
- Tcl_DecrRefCount(objPtr);
- }
- if (objv != argStorage) {
- Tcl_Free((char *) objv);
- }
- return result;
-#undef NUM_ARGS
-}
+++ /dev/null
-/* command.h - definitions for expect commands
-
-Written by: Don Libes, NIST, 2/6/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.
-*/
-
-EXTERN struct exp_f * exp_update_master
- _ANSI_ARGS_((Tcl_Interp *,int *,int,int));
-EXTERN char * exp_get_var _ANSI_ARGS_((Tcl_Interp *,char *));
-
-EXTERN int exp_default_match_max;
-EXTERN int exp_default_parity;
-EXTERN int exp_default_rm_nulls;
-
-EXTERN int exp_one_arg_braced _ANSI_ARGS_((char *));
-EXTERN int exp_eval_with_one_arg _ANSI_ARGS_((ClientData,
- Tcl_Interp *,char **));
-EXTERN void exp_lowmemcpy _ANSI_ARGS_((char *,char *,int));
-
-EXTERN int exp_flageq_code _ANSI_ARGS_((char *,char *,int));
-
-#define exp_flageq(flag,string,minlen) \
-(((string)[0] == (flag)[0]) && (exp_flageq_code(((flag)+1),((string)+1),((minlen)-1))))
-
-/* exp_flageq for single char flags */
-#define exp_flageq1(flag,string) \
- ((string[0] == flag) && (string[1] == '\0'))
-
-/*
- * The type of the status returned by wait varies from UNIX system
- * to UNIX system. The macro below defines it:
- * (stolen from tclUnix.h)
- */
-
-#define WAIT_STATUS_TYPE int
-#if 0
-#ifdef AIX
-# define WAIT_STATUS_TYPE pid_t
-#else
-#ifndef NO_UNION_WAIT
-# define WAIT_STATUS_TYPE union wait
-#else
-# define WAIT_STATUS_TYPE int
-#endif
-#endif /* AIX */
-
-/* These macros are taken from tclUnix.h */
-
-#undef WIFEXITED
-#ifndef WIFEXITED
-# define WIFEXITED(stat) (((*((int *) &(stat))) & 0xff) == 0)
-#endif
-
-#undef WEXITSTATUS
-#ifndef WEXITSTATUS
-# define WEXITSTATUS(stat) (((*((int *) &(stat))) >> 8) & 0xff)
-#endif
-
-#undef WIFSIGNALED
-#ifndef WIFSIGNALED
-# define WIFSIGNALED(stat) (((*((int *) &(stat)))) && ((*((int *) &(stat))) == ((*((int *) &(stat))) & 0x00ff)))
-#endif
-
-#undef WTERMSIG
-#ifndef WTERMSIG
-# define WTERMSIG(stat) ((*((int *) &(stat))) & 0x7f)
-#endif
-
-#undef WIFSTOPPED
-#ifndef WIFSTOPPED
-# define WIFSTOPPED(stat) (((*((int *) &(stat))) & 0xff) == 0177)
-#endif
-
-#undef WSTOPSIG
-#ifndef WSTOPSIG
-# define WSTOPSIG(stat) (((*((int *) &(stat))) >> 8) & 0xff)
-#endif
-
-#endif /* 0 */
-
-/* These macros are suggested by the autoconf documentation. */
-
-#undef WIFEXITED
-#ifndef WIFEXITED
-# define WIFEXITED(stat) (((stat) & 0xff) == 0)
-#endif
-
-#undef WEXITSTATUS
-#ifndef WEXITSTATUS
-# define WEXITSTATUS(stat) (((stat) >> 8) & 0xff)
-#endif
-
-#undef WIFSIGNALED
-#ifndef WIFSIGNALED
-# define WIFSIGNALED(stat) ((stat) && ((stat) == ((stat) & 0x00ff)))
-#endif
-
-#undef WTERMSIG
-#ifndef WTERMSIG
-# define WTERMSIG(stat) ((stat) & 0x7f)
-#endif
-
-#undef WIFSTOPPED
-#ifndef WIFSTOPPED
-# define WIFSTOPPED(stat) (((stat) & 0xff) == 0177)
-#endif
-
-#undef WSTOPSIG
-#ifndef WSTOPSIG
-# define WSTOPSIG(stat) (((stat) >> 8) & 0xff)
-#endif
-
-
-
-#define EXP_SPAWN_ID_ANY_VARNAME "any_spawn_id"
-#define EXP_SPAWN_ID_ANY_LIT "-1"
-#define EXP_SPAWN_ID_ANY -1
-
-#define EXP_SPAWN_ID_ERROR_LIT "2"
-#define EXP_SPAWN_ID_USER_LIT "0"
-#define EXP_SPAWN_ID_USER 0
-
-#define exp_is_stdinfd(x) ((x) == 0)
-#define exp_is_devttyfd(x) ((x) == exp_dev_tty)
-
-#define EXP_NOPID 0 /* Used when there is no associated pid to */
- /* wait for. For example: */
- /* 1) When fd opened by someone else, e.g., */
- /* Tcl's open */
- /* 2) When entry not in use */
- /* 3) To tell user pid of "spawn -open" */
- /* 4) stdin, out, error */
-
-#define EXP_NOFD -1
-
-/* these are occasionally useful to distinguish between various expect */
-/* commands and are also used as array indices into the per-fd eg[] arrays */
-#define EXP_CMD_BEFORE 0
-#define EXP_CMD_AFTER 1
-#define EXP_CMD_BG 2
-#define EXP_CMD_FG 3
-
-/* each process is associated with a 'struct exp_f'. An array of these */
-/* ('exp_fs') keeps track of all processes. They are indexed by the true fd */
-/* to the master side of the pty */
-struct exp_f {
- int *fd_ptr;
-#if 0
- struct exp_f **ptr; /* our own address to this exp_f */
- /* since address can change, provide this indirect */
- /* pointer for people (Tk) who require a fixed ptr */
-#endif
- int pid; /* pid or EXP_NOPID if no pid */
- char *buffer; /* input buffer */
- char *lower; /* input buffer in lowercase */
- int size; /* current size of data */
- int msize; /* size of buffer (true size is one greater
- for trailing null) */
- int umsize; /* user view of size of buffer */
- int rm_nulls; /* if nulls should be stripped before pat matching */
- int valid; /* if any of the other fields should be believed */
- int user_closed;/* if user has issued "close" command or close has */
- /* occurred implicitly */
- int sys_closed; /* if close() has been called */
- int user_waited;/* if user has issued "wait" command */
- int sys_waited; /* if wait() (or variant) has been called */
- WAIT_STATUS_TYPE wait; /* raw status from wait() */
- int parity; /* strip parity if false */
- int printed; /* # of characters written to stdout (if logging on) */
- /* but not actually returned via a match yet */
- int echoed; /* additional # of chars (beyond "printed" above) */
- /* echoed back but not actually returned via a match */
- /* yet. This supports interact -echo */
- int key; /* unique id that identifies what command instance */
- /* last touched this buffer */
- int force_read; /* force read to occur (even if buffer already has */
- /* data). This supports interact CAN_MATCH */
- int fg_armed; /* If Tk_CreateFileHandler is active for responding */
- /* to foreground events */
-
-#if TCL_MAJOR_VERSION < 8
- Tcl_File Master; /* corresponds to master fd */
- Tcl_File Slave; /* corresponds to slave_fd */
- Tcl_File MasterOutput; /* corresponds to tcl_output */
- /*
- * Following comment only applies to Tcl 7.6:
- * Explicit fds aren't necessary now, but since the code is already
- * here from before Tcl required Tcl_File, we'll continue using
- * the old fds. If we ever port this code to a non-UNIX system,
- * we'll dump the fds totally.
- */
-#endif /* TCL_MAJOR_VERSION < 8 */
-
- int slave_fd; /* slave fd if "spawn -pty" used */
-#ifdef HAVE_PTYTRAP
- char *slave_name;/* Full name of slave, i.e., /dev/ttyp0 */
-#endif /* HAVE_PTYTRAP */
- char *tcl_handle;/* If opened by someone else, i.e. Tcl's open */
- int tcl_output; /* output fd if opened by someone else */
- /* input fd is the index of this struct (see above) */
- int leaveopen; /* If we should not call Tcl's close when we close - */
- /* only relevant if Tcl does the original open */
- Tcl_Interp *bg_interp; /* interp to process the bg cases */
- int bg_ecount; /* number of background ecases */
- enum {
- blocked, /* blocked because we are processing the */
- /* file handler */
- armed, /* normal state when bg handler in use */
- unarmed, /* no bg handler in use */
- disarm_req_while_blocked /* while blocked, a request */
- /* was received to disarm it. Rather than */
- /* processing the request immediately, defer */
- /* it so that when we later try to unblock */
- /* we will see at that time that it should */
- /* instead be disarmed */
- } bg_status;
-};
-
-extern int exp_fd_max; /* highest fd ever used */
-
-
-#define EXP_TEMPORARY 1 /* expect */
-#define EXP_PERMANENT 2 /* expect_after, expect_before, expect_bg */
-
-#define EXP_DIRECT 1
-#define EXP_INDIRECT 2
-
-EXTERN struct exp_f *exp_fs;
-
-EXTERN struct exp_f * exp_fd2f _ANSI_ARGS_((Tcl_Interp *,int,int,int,char *));
-EXTERN void exp_adjust _ANSI_ARGS_((struct exp_f *));
-EXTERN void exp_buffer_shuffle _ANSI_ARGS_((Tcl_Interp *,struct exp_f *,int,char *,char *));
-EXTERN int exp_close _ANSI_ARGS_((Tcl_Interp *,int));
-EXTERN void exp_close_all _ANSI_ARGS_((Tcl_Interp *));
-EXTERN void exp_ecmd_remove_fd_direct_and_indirect
- _ANSI_ARGS_((Tcl_Interp *,int));
-EXTERN void exp_trap_on _ANSI_ARGS_((int));
-EXTERN int exp_trap_off _ANSI_ARGS_((char *));
-
-EXTERN void exp_strftime();
-
-#define exp_deleteProc (void (*)())0
-#define exp_deleteObjProc (void (*)())0
-
-EXTERN int expect_key;
-EXTERN int exp_configure_count; /* # of times descriptors have been closed */
- /* or indirect lists have been changed */
-EXTERN int exp_nostack_dump; /* TRUE if user has requested unrolling of */
- /* stack with no trace */
-
-EXTERN void exp_init_pty _ANSI_ARGS_((void));
-EXTERN void exp_pty_exit _ANSI_ARGS_((void));
-EXTERN void exp_init_tty _ANSI_ARGS_((void));
-EXTERN void exp_init_stdio _ANSI_ARGS_((void));
-/*EXTERN void exp_init_expect _ANSI_ARGS_((Tcl_Interp *));*/
-EXTERN void exp_init_spawn_ids _ANSI_ARGS_((void));
-EXTERN void exp_init_spawn_id_vars _ANSI_ARGS_((Tcl_Interp *));
-EXTERN void exp_init_trap _ANSI_ARGS_((void));
-EXTERN void exp_init_unit_random _ANSI_ARGS_((void));
-EXTERN void exp_init_sig _ANSI_ARGS_((void));
-
-EXTERN int exp_tcl2_returnvalue _ANSI_ARGS_((int));
-EXTERN int exp_2tcl_returnvalue _ANSI_ARGS_((int));
-
-EXTERN void exp_rearm_sigchld _ANSI_ARGS_((Tcl_Interp *));
-EXTERN int exp_string_to_signal _ANSI_ARGS_((Tcl_Interp *,char *));
-
-EXTERN char *exp_onexit_action;
-
-#define exp_new(x) (x *)malloc(sizeof(x))
-
-struct exp_fd_list {
- int fd;
- struct exp_fd_list *next;
-};
-
-/* describes a -i flag */
-struct exp_i {
- int cmdtype; /* EXP_CMD_XXX. When an indirect update is */
- /* triggered by Tcl, this helps tell us in what */
- /* exp_i list to look in. */
- int direct; /* if EXP_DIRECT, then the spawn ids have been given */
- /* literally, else indirectly through a variable */
- int duration; /* if EXP_PERMANENT, char ptrs here had to be */
- /* malloc'd because Tcl command line went away - */
- /* i.e., in expect_before/after */
- char *variable;
- char *value; /* if type == direct, this is the string that the */
- /* user originally supplied to the -i flag. It may */
- /* lose relevance as the fd_list is manipulated */
- /* over time. If type == direct, this is the */
- /* cached value of variable use this to tell if it */
- /* has changed or not, and ergo whether it's */
- /* necessary to reparse. */
-
- int ecount; /* # of ecases this is used by */
-
- struct exp_fd_list *fd_list;
- struct exp_i *next;
-};
-
-EXTERN struct exp_i * exp_new_i_complex _ANSI_ARGS_((Tcl_Interp *,
- char *, int, Tcl_VarTraceProc *));
-EXTERN struct exp_i * exp_new_i_simple _ANSI_ARGS_((int,int));
-EXTERN struct exp_fd_list *exp_new_fd _ANSI_ARGS_((int));
-EXTERN void exp_free_i _ANSI_ARGS_((Tcl_Interp *,struct exp_i *,
- Tcl_VarTraceProc *));
-EXTERN void exp_free_fd _ANSI_ARGS_((struct exp_fd_list *));
-EXTERN void exp_free_fd_single _ANSI_ARGS_((struct exp_fd_list *));
-EXTERN void exp_i_update _ANSI_ARGS_((Tcl_Interp *,
- struct exp_i *));
-
-/*
- * definitions for creating commands
- */
-
-#define EXP_NOPREFIX 1 /* don't define with "exp_" prefix */
-#define EXP_REDEFINE 2 /* stomp on old commands with same name */
-
-/* a hack for easily supporting both Tcl 7 and 8 CreateCommand/Obj split */
-/* Can be discarded with Tcl 7 is. */
-#if TCL_MAJOR_VERSION < 8
-#define exp_proc(cmdproc) cmdproc
-#else
-#define exp_proc(cmdproc) 0, cmdproc
-#endif
-
-struct exp_cmd_data {
- char *name;
-#if TCL_MAJOR_VERSION >= 8
- Tcl_ObjCmdProc *objproc;
-#endif
- Tcl_CmdProc *proc;
- ClientData data;
- int flags;
-};
-
-EXTERN void exp_create_commands _ANSI_ARGS_((Tcl_Interp *,
- struct exp_cmd_data *));
-EXTERN void exp_init_main_cmds _ANSI_ARGS_((Tcl_Interp *));
-EXTERN void exp_init_expect_cmds _ANSI_ARGS_((Tcl_Interp *));
-EXTERN void exp_init_most_cmds _ANSI_ARGS_((Tcl_Interp *));
-EXTERN void exp_init_trap_cmds _ANSI_ARGS_((Tcl_Interp *));
-EXTERN void exp_init_interact_cmds _ANSI_ARGS_((Tcl_Interp *));
-EXTERN void exp_init_tty_cmds();
-
+++ /dev/null
-/* exp_console.c - grab console. This stuff is in a separate file to
-avoid unpleasantness of AIX (3.2.4) .h files which provide no way to
-reference TIOCCONS and include both sys/ioctl.h and sys/sys/stropts.h
-without getting some sort of warning from the compiler. The problem
-is that both define _IO but only ioctl.h checks to see if it is
-defined first. This would suggest that it is sufficient to include
-ioctl.h after stropts.h. Unfortunately, ioctl.h, having seen that _IO
-is defined, then fails to define other important things (like _IOW).
-
-Written by: Don Libes, NIST, 2/6/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.
-*/
-
-#include "expect_cf.h"
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-
-#ifdef HAVE_STRREDIR_H
-#include <sys/strredir.h>
-# ifdef SRIOCSREDIR
-# undef TIOCCONS
-# endif
-#endif
-
-#ifdef HAVE_SYS_FCNTL_H
-#include <sys/fcntl.h>
-#endif
-
-#include "tcl.h"
-#include "exp_rename.h"
-#include "exp_prog.h"
-#include "exp_log.h"
-
-static void
-exp_console_manipulation_failed(s)
-char *s;
-{
- exp_errorlog("expect: spawn: cannot %s console, check permissions of /dev/console\n",s);
- exit(-1);
-}
-
-void
-exp_console_set()
-{
-#ifdef SRIOCSREDIR
- int fd;
-
- if ((fd = open("/dev/console", O_RDONLY)) == -1) {
- exp_console_manipulation_failed("open");
- }
- if (ioctl(fd, SRIOCSREDIR, 0) == -1) {
- exp_console_manipulation_failed("redirect");
- }
- close(fd);
-#endif
-
-#ifdef TIOCCONS
- int on = 1;
-
- if (ioctl(0,TIOCCONS,(char *)&on) == -1) {
- exp_console_manipulation_failed("redirect");
- }
-#endif /*TIOCCONS*/
-}
+++ /dev/null
-/* exp_event.c - event interface for Expect
-
-Written by: Don Libes, NIST, 2/6/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.
-
-*/
-
-/* Notes:
-I'm only a little worried because Tk does not check for errno == EBADF
-after calling select. I imagine that if the user passes in a bad file
-descriptor, we'll never get called back, and thus, we'll hang forever
-- it would be better to at least issue a diagnostic to the user.
-
-Another possible problem: Tk does not do file callbacks round-robin.
-
-Another possible problem: Calling Create/DeleteFileHandler
-before/after every Tcl_Eval... in expect/interact could be very
-expensive.
-
-*/
-
-#include "expect_cf.h"
-#include <stdio.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/time.h>
-
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-#ifdef HAVE_PTYTRAP
-# include <sys/ptyio.h>
-#endif
-
-#include "tcl.h"
-#include "exp_prog.h"
-#include "exp_command.h" /* for struct exp_f defs */
-#include "exp_event.h"
-
-/* Tcl_DoOneEvent will call our filehandler which will set the following */
-/* vars enabling us to know where and what kind of I/O we can do */
-/*#define EXP_SPAWN_ID_BAD -1*/
-/*#define EXP_SPAWN_ID_TIMEOUT -2*/ /* really indicates a timeout */
-
-static int ready_fd = EXP_SPAWN_ID_BAD;
-static int ready_mask;
-static int default_mask = TCL_READABLE | TCL_EXCEPTION;
-
-
-void
-exp_event_disarm(fd)
-int fd;
-{
-#if TCL_MAJOR_VERSION < 8
- Tcl_DeleteFileHandler(exp_fs[fd].Master);
-#else
- Tcl_DeleteFileHandler(fd);
-#endif
-
- /* remember that filehandler has been disabled so that */
- /* it can be turned on for fg expect's as well as bg */
- exp_fs[fd].fg_armed = FALSE;
-}
-
-void
-exp_event_disarm_fast(fd,filehandler)
-int fd;
-Tcl_FileProc *filehandler;
-{
- /* Temporarily delete the filehandler by assigning it a mask */
- /* that permits no events! */
- /* This reduces the calls to malloc/free inside Tcl_...FileHandler */
- /* Tk insists on having a valid proc here even though it isn't used */
-#if TCL_MAJOR_VERSION < 8
- Tcl_CreateFileHandler(exp_fs[fd].Master,0,filehandler,(ClientData)0);
-#else
- Tcl_CreateFileHandler(fd,0,filehandler,(ClientData)0);
-#endif
-
- /* remember that filehandler has been disabled so that */
- /* it can be turned on for fg expect's as well as bg */
- exp_fs[fd].fg_armed = FALSE;
-}
-
-static void
-exp_arm_background_filehandler_force(m)
-int m;
-{
-#if TCL_MAJOR_VERSION < 8
- Tcl_CreateFileHandler(exp_fs[m].Master,
-#else
- Tcl_CreateFileHandler(m,
-#endif
- TCL_READABLE|TCL_EXCEPTION,
- exp_background_filehandler,
- (ClientData)(exp_fs[m].fd_ptr));
-
- exp_fs[m].bg_status = armed;
-}
-
-void
-exp_arm_background_filehandler(m)
-int m;
-{
- switch (exp_fs[m].bg_status) {
- case unarmed:
- exp_arm_background_filehandler_force(m);
- break;
- case disarm_req_while_blocked:
- exp_fs[m].bg_status = blocked; /* forget request */
- break;
- case armed:
- case blocked:
- /* do nothing */
- break;
- }
-}
-
-void
-exp_disarm_background_filehandler(m)
-int m;
-{
- switch (exp_fs[m].bg_status) {
- case blocked:
- exp_fs[m].bg_status = disarm_req_while_blocked;
- break;
- case armed:
- exp_fs[m].bg_status = unarmed;
- exp_event_disarm(m);
- break;
- case disarm_req_while_blocked:
- case unarmed:
- /* do nothing */
- break;
- }
-}
-
-/* ignore block status and forcibly disarm handler - called from exp_close. */
-/* After exp_close returns, we will not have an opportunity to disarm */
-/* because the fd will be invalid, so we force it here. */
-void
-exp_disarm_background_filehandler_force(m)
-int m;
-{
- switch (exp_fs[m].bg_status) {
- case blocked:
- case disarm_req_while_blocked:
- case armed:
- exp_fs[m].bg_status = unarmed;
- exp_event_disarm(m);
- break;
- case unarmed:
- /* do nothing */
- break;
- }
-}
-
-/* this can only be called at the end of the bg handler in which */
-/* case we know the status is some kind of "blocked" */
-void
-exp_unblock_background_filehandler(m)
-int m;
-{
- switch (exp_fs[m].bg_status) {
- case blocked:
- exp_arm_background_filehandler_force(m);
- break;
- case disarm_req_while_blocked:
- exp_disarm_background_filehandler_force(m);
- break;
- case armed:
- case unarmed:
- /* Not handled, FIXME? */
- break;
- }
-}
-
-/* this can only be called at the beginning of the bg handler in which */
-/* case we know the status must be "armed" */
-void
-exp_block_background_filehandler(m)
-int m;
-{
- exp_fs[m].bg_status = blocked;
- exp_event_disarm_fast(m,exp_background_filehandler);
-}
-
-
-/*ARGSUSED*/
-static void
-exp_timehandler(clientData)
-ClientData clientData;
-{
- *(int *)clientData = TRUE;
-}
-
-static void exp_filehandler(clientData,mask)
-ClientData clientData;
-int mask;
-{
- /* if input appears, record the fd on which it appeared */
-
- ready_fd = *(int *)clientData;
- ready_mask = mask;
- exp_event_disarm_fast(ready_fd,exp_filehandler);
-
-#if 0
- if (ready_fd == *(int *)clientData) {
- /* if input appears from an fd which we've already heard */
- /* forcibly tell it to shut up. We could also shut up */
- /* every instance, but it is more efficient to leave the */
- /* fd enabled with the belief that we may rearm soon enough */
- /* anyway. */
-
- exp_event_disarm_fast(ready_fd,exp_filehandler);
- } else {
- ready_fd = *(int *)clientData;
- ready_mask = mask;
- }
-#endif
-}
-
-/* returns status, one of EOF, TIMEOUT, ERROR or DATA */
-/* can now return RECONFIGURE, too */
-/*ARGSUSED*/
-int exp_get_next_event(interp,masters, n,master_out,timeout,key)
-Tcl_Interp *interp;
-int *masters;
-int n; /* # of masters */
-int *master_out; /* 1st ready master, not set if none */
-int timeout; /* seconds */
-int key;
-{
- static rr = 0; /* round robin ptr */
- int i; /* index into in-array */
-#ifdef HAVE_PTYTRAP
- struct request_info ioctl_info;
-#endif
-
- int old_configure_count = exp_configure_count;
-
- int timer_created = FALSE;
- int timer_fired = FALSE;
- Tcl_TimerToken timetoken;/* handle to Tcl timehandler descriptor */
-
- for (;;) {
- int m;
- struct exp_f *f;
-
- /* if anything has been touched by someone else, report that */
- /* an event has been received */
-
- for (i=0;i<n;i++) {
- rr++;
- if (rr >= n) rr = 0;
-
- m = masters[rr];
- f = exp_fs + m;
-
- if (f->key != key) {
- f->key = key;
- f->force_read = FALSE;
- *master_out = m;
- return(EXP_DATA_OLD);
- } else if ((!f->force_read) && (f->size != 0)) {
- *master_out = m;
- return(EXP_DATA_OLD);
- }
- }
-
- if (!timer_created) {
- if (timeout >= 0) {
- timetoken = Tcl_CreateTimerHandler(1000*timeout,
- exp_timehandler,
- (ClientData)&timer_fired);
- timer_created = TRUE;
- }
- }
-
- for (;;) {
- int j;
-
- /* make sure that all fds that should be armed are */
- for (j=0;j<n;j++) {
- int k = masters[j];
-
- if (!exp_fs[k].fg_armed) {
- Tcl_CreateFileHandler(
-#if TCL_MAJOR_VERSION < 8
- exp_fs[k].Master,
-#else
- k,
-#endif
- default_mask,
- exp_filehandler,
- (ClientData)exp_fs[k].fd_ptr);
- exp_fs[k].fg_armed = TRUE;
- }
- }
-
- Tcl_DoOneEvent(0); /* do any event */
-
- if (timer_fired) return(EXP_TIMEOUT);
-
- if (old_configure_count != exp_configure_count) {
- if (timer_created) Tcl_DeleteTimerHandler(timetoken);
- return EXP_RECONFIGURE;
- }
-
- if (ready_fd == EXP_SPAWN_ID_BAD) continue;
-
- /* if it was from something we're not looking for at */
- /* the moment, ignore it */
- for (j=0;j<n;j++) {
- if (ready_fd == masters[j]) goto found;
- }
-
- /* not found */
- exp_event_disarm_fast(ready_fd,exp_filehandler);
- ready_fd = EXP_SPAWN_ID_BAD;
- continue;
- found:
- *master_out = ready_fd;
- ready_fd = EXP_SPAWN_ID_BAD;
-
- /* this test should be redundant but SunOS */
- /* raises both READABLE and EXCEPTION (for no */
- /* apparent reason) when selecting on a plain file */
- if (ready_mask & TCL_READABLE) {
- if (timer_created) Tcl_DeleteTimerHandler(timetoken);
- return EXP_DATA_NEW;
- }
-
- /* ready_mask must contain TCL_EXCEPTION */
-#ifndef HAVE_PTYTRAP
- if (timer_created) Tcl_DeleteTimerHandler(timetoken);
- return(EXP_EOF);
-#else
- if (ioctl(*master_out,TIOCREQCHECK,&ioctl_info) < 0) {
- if (timer_created)
- Tcl_DeleteTimerHandler(timetoken);
- exp_debuglog("ioctl error on TIOCREQCHECK: %s", Tcl_PosixError(interp));
- return(EXP_TCLERROR);
- }
- if (ioctl_info.request == TIOCCLOSE) {
- if (timer_created)
- Tcl_DeleteTimerHandler(timetoken);
- return(EXP_EOF);
- }
- if (ioctl(*master_out, TIOCREQSET, &ioctl_info) < 0) {
- exp_debuglog("ioctl error on TIOCREQSET after ioctl or open on slave: %s", Tcl_ErrnoMsg(errno));
- }
- /* presumably, we trapped an open here */
- continue;
-#endif /* !HAVE_PTYTRAP */
- }
- }
-}
-
-/* Having been told there was an event for a specific fd, get it */
-/* returns status, one of EOF, TIMEOUT, ERROR or DATA */
-/*ARGSUSED*/
-int
-exp_get_next_event_info(interp,fd,ready_mask)
-Tcl_Interp *interp;
-int fd;
-int ready_mask;
-{
-#ifdef HAVE_PTYTRAP
- struct request_info ioctl_info;
-#endif
-
- if (ready_mask & TCL_READABLE) return EXP_DATA_NEW;
-
- /* ready_mask must contain TCL_EXCEPTION */
-
-#ifndef HAVE_PTYTRAP
- return(EXP_EOF);
-#else
- if (ioctl(fd,TIOCREQCHECK,&ioctl_info) < 0) {
- exp_debuglog("ioctl error on TIOCREQCHECK: %s",
- Tcl_PosixError(interp));
- return(EXP_TCLERROR);
- }
- if (ioctl_info.request == TIOCCLOSE) {
- return(EXP_EOF);
- }
- if (ioctl(fd, TIOCREQSET, &ioctl_info) < 0) {
- exp_debuglog("ioctl error on TIOCREQSET after ioctl or open on slave: %s", Tcl_ErrnoMsg(errno));
- }
- /* presumably, we trapped an open here */
- /* call it an error for lack of anything more descriptive */
- /* it will be thrown away by caller anyway */
- return EXP_TCLERROR;
-#endif
-}
-
-/*ARGSUSED*/
-int /* returns TCL_XXX */
-exp_dsleep(interp,sec)
-Tcl_Interp *interp;
-double sec;
-{
- int timer_fired = FALSE;
-
- Tcl_CreateTimerHandler((int)(sec*1000),exp_timehandler,(ClientData)&timer_fired);
-
- while (1) {
- Tcl_DoOneEvent(0);
- if (timer_fired) return TCL_OK;
-
- if (ready_fd == EXP_SPAWN_ID_BAD) continue;
-
- exp_event_disarm_fast(ready_fd,exp_filehandler);
- ready_fd = EXP_SPAWN_ID_BAD;
- }
-}
-
-#if 0
-/*ARGSUSED*/
-int /* returns TCL_XXX */
-exp_usleep(interp,usec)
-Tcl_Interp *interp;
-long usec;
-{
- int timer_fired = FALSE;
-
- Tcl_CreateTimerHandler(usec/1000,exp_timehandler,(ClientData)&timer_fired);
-
- while (1) {
- Tcl_DoOneEvent(0);
- if (timer_fired) return TCL_OK;
-
- if (ready_fd == EXP_SPAWN_ID_BAD) continue;
-
- exp_event_disarm_fast(ready_fd,exp_filehandler);
- ready_fd = EXP_SPAWN_ID_BAD;
- }
-}
-#endif
-
-static char destroy_cmd[] = "destroy .";
-
-static void
-exp_event_exit_real(interp)
-Tcl_Interp *interp;
-{
- Tcl_Eval(interp,destroy_cmd);
-}
-
-/* set things up for later calls to event handler */
-void
-exp_init_event()
-{
- exp_event_exit = exp_event_exit_real;
-}
+++ /dev/null
-/* exp_event.h - event definitions */
-
-int exp_get_next_event _ANSI_ARGS_((Tcl_Interp *,int *, int, int *, int, int));
-int exp_get_next_event_info _ANSI_ARGS_((Tcl_Interp *, int, int));
-int exp_dsleep _ANSI_ARGS_((Tcl_Interp *, double));
-void exp_init_event _ANSI_ARGS_((void));
-
-extern void (*exp_event_exit) _ANSI_ARGS_((Tcl_Interp *));
-
-void exp_event_disarm _ANSI_ARGS_((int));
-
-void exp_arm_background_filehandler _ANSI_ARGS_((int));
-void exp_disarm_background_filehandler _ANSI_ARGS_((int));
-void exp_disarm_background_filehandler_force _ANSI_ARGS_((int));
-void exp_unblock_background_filehandler _ANSI_ARGS_((int));
-void exp_block_background_filehandler _ANSI_ARGS_((int));
-
-void exp_background_filehandler _ANSI_ARGS_((ClientData,int));
-
+++ /dev/null
-/* exp_glob.c - expect functions for doing glob
-
-Based on Tcl's glob functions but modified to support anchors and to
-return information about the possibility of future matches
-
-Modifications by: Don Libes, NIST, 2/6/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.
-
-*/
-
-#include "expect_cf.h"
-#include "tcl.h"
-#include "exp_int.h"
-
-#if 0
-/* The following functions implement expect's glob-style string matching */
-/* Exp_StringMatch allow's implements the unanchored front (or conversely */
-/* the '^') feature. Exp_StringMatch2 does the rest of the work. */
-int /* returns # of chars that matched */
-Exp_StringMatch(string, pattern,offset)
-char *string;
-char *pattern;
-int *offset; /* offset from beginning of string where pattern matches */
-{
- char *s;
- int sm; /* count of chars matched or -1 */
- int caret = FALSE;
-
- *offset = 0;
-
- if (pattern[0] == '^') {
- caret = TRUE;
- pattern++;
- }
-
- sm = Exp_StringMatch2(string,pattern);
- if (sm >= 0) return(sm);
-
- if (caret) return(-1);
-
- if (pattern[0] == '*') return(-1);
-
- for (s = string;*s;s++) {
- sm = Exp_StringMatch2(s,pattern);
- if (sm != -1) {
- *offset = s-string;
- return(sm);
- }
- }
- return(-1);
-}
-#endif
-
-/* The following functions implement expect's glob-style string matching */
-/* Exp_StringMatch allow's implements the unanchored front (or conversely */
-/* the '^') feature. Exp_StringMatch2 does the rest of the work. */
-int /* returns # of chars that matched */
-Exp_StringMatch(string, pattern,offset)
-char *string;
-char *pattern;
-int *offset; /* offset from beginning of string where pattern matches */
-{
- char *s;
- int sm; /* count of chars matched or -1 */
- int caret = FALSE;
- int star = FALSE;
-
- *offset = 0;
-
- if (pattern[0] == '^') {
- caret = TRUE;
- pattern++;
- } else if (pattern[0] == '*') {
- star = TRUE;
- }
-
- /*
- * test if pattern matches in initial position.
- * This handles front-anchor and 1st iteration of non-front-anchor.
- * Note that 1st iteration must be tried even if string is empty.
- */
-
- sm = Exp_StringMatch2(string,pattern);
- if (sm >= 0) return(sm);
-
- if (caret) return -1;
- if (star) return -1;
-
- if (*string == '\0') return -1;
-
- for (s = string+1;*s;s++) {
- sm = Exp_StringMatch2(s,pattern);
- if (sm != -1) {
- *offset = s-string;
- return(sm);
- }
- }
- return -1;
-}
-
-/* Exp_StringMatch2 --
-
-Like Tcl_StringMatch except that
-1) returns number of characters matched, -1 if failed.
- (Can return 0 on patterns like "" or "$")
-2) does not require pattern to match to end of string
-3) much of code is stolen from Tcl_StringMatch
-4) front-anchor is assumed (Tcl_StringMatch retries for non-front-anchor)
-*/
-
-int Exp_StringMatch2(string,pattern)
- register char *string; /* String. */
- register char *pattern; /* Pattern, which may contain
- * special characters. */
-{
- char c2;
- int match = 0; /* # of chars matched */
-
- while (1) {
- /* If at end of pattern, success! */
- if (*pattern == 0) {
- return match;
- }
-
- /* If last pattern character is '$', verify that entire
- * string has been matched.
- */
- if ((*pattern == '$') && (pattern[1] == 0)) {
- if (*string == 0) return(match);
- else return(-1);
- }
-
- /* Check for a "*" as the next pattern character. It matches
- * any substring. We handle this by calling ourselves
- * recursively for each postfix of string, until either we
- * match or we reach the end of the string.
- */
-
- if (*pattern == '*') {
-#if 1
- int head_len;
- char *tail;
-#endif
- pattern += 1;
- if (*pattern == 0) {
- return(strlen(string)+match); /* DEL */
- }
-#if 1
- /* find longest match - switched to this on 12/31/93 */
- head_len = strlen(string); /* length before tail */
- tail = string + head_len;
- while (head_len >= 0) {
- int rc;
-
- if (-1 != (rc = Exp_StringMatch2(tail, pattern))) {
- return rc + match + head_len; /* DEL */
- }
- tail--;
- head_len--;
- }
-#else
- /* find shortest match */
- while (*string != 0) {
- int rc; /* DEL */
-
- if (-1 != (rc = Exp_StringMatch2(string, pattern))) {
- return rc+match; /* DEL */
- }
- string += 1;
- match++; /* DEL */
- }
- if (*pattern == '$') return 0; /* handle *$ */
-#endif
- return -1; /* DEL */
- }
-
- /*
- * after this point, all patterns must match at least one
- * character, so check this
- */
-
- if (*string == 0) return -1;
-
- /* Check for a "?" as the next pattern character. It matches
- * any single character.
- */
-
- if (*pattern == '?') {
- goto thisCharOK;
- }
-
- /* Check for a "[" as the next pattern character. It is followed
- * by a list of characters that are acceptable, or by a range
- * (two characters separated by "-").
- */
-
- if (*pattern == '[') {
- pattern += 1;
- while (1) {
- if ((*pattern == ']') || (*pattern == 0)) {
- return -1; /* was 0; DEL */
- }
- if (*pattern == *string) {
- break;
- }
- if (pattern[1] == '-') {
- c2 = pattern[2];
- if (c2 == 0) {
- return -1; /* DEL */
- }
- if ((*pattern <= *string) && (c2 >= *string)) {
- break;
- }
- if ((*pattern >= *string) && (c2 <= *string)) {
- break;
- }
- pattern += 2;
- }
- pattern += 1;
- }
-
-/* OOPS! Found a bug in vanilla Tcl - have sent back to Ousterhout */
-/* but he hasn't integrated it yet. - DEL */
-
-#if 0
- while ((*pattern != ']') && (*pattern != 0)) {
-#else
- while (*pattern != ']') {
- if (*pattern == 0) {
- pattern--;
- break;
- }
-#endif
- pattern += 1;
- }
- goto thisCharOK;
- }
-
- /* If the next pattern character is backslash, strip it off
- * so we do exact matching on the character that follows.
- */
-
- if (*pattern == '\\') {
- pattern += 1;
- if (*pattern == 0) {
- return -1;
- }
- }
-
- /* There's no special character. Just make sure that the next
- * characters of each string match.
- */
-
- if (*pattern != *string) {
- return -1;
- }
-
- thisCharOK: pattern += 1;
- string += 1;
- match++;
- }
-}
-
+++ /dev/null
-/* exp_int.h - private symbols common to both expect program and library
-
-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.
-*/
-
-#ifndef _EXPECT_INT_H
-#define _EXPECT_INT_H
-
-#ifndef TRUE
-#define FALSE 0
-#define TRUE 1
-#endif
-
-#ifndef HAVE_MEMCPY
-#define memcpy(x,y,len) bcopy(y,x,len)
-#endif
-
-#include <errno.h>
-
-int Exp_StringMatch();
-int Exp_StringMatch2();
-void exp_console_set _ANSI_ARGS_((void));
-
-#ifdef NO_STDLIB_H
-# include "../compat/stdlib.h"
-#else
-# include <stdlib.h> /* for malloc */
-#endif /*NO_STDLIB_H*/
-
-#endif /* _EXPECT_INT_H */
+++ /dev/null
-/* interact (using select) - give user keyboard control
-
-Written by: Don Libes, NIST, 2/6/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.
-
-*/
-
-#include "expect_cf.h"
-#include <stdio.h>
-#ifdef HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#include <sys/types.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#ifdef TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-# include <sys/time.h>
-# else
-# include <time.h>
-# endif
-#endif
-
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-#include <ctype.h>
-
-#include "tcl.h"
-#include "string.h"
-
-#include "exp_tty_in.h"
-#include "exp_rename.h"
-#include "exp_prog.h"
-#include "exp_command.h"
-#include "exp_log.h"
-#include "exp_tstamp.h" /* remove when timestamp stuff is gone */
-
-#include "tcl_regexp.h"
-#include "exp_regexp.h"
-
-extern char *TclGetRegError();
-extern void Expect_TclRegError();
-
-#define INTER_OUT "interact_out"
-
-/*
- * tests if we are running this using a real tty
- *
- * these tests are currently only used to control what gets written to the
- * logfile. Note that removal of the test of "..._is_tty" means that stdin
- * or stdout could be redirected and yet stdout would still be logged.
- * However, it's not clear why anyone would use log_file when these are
- * redirected in the first place. On the other hand, it is reasonable to
- * run expect as a daemon in which case, stdin/out do not appear to be
- * ttys, yet it makes sense for them to be logged with log_file as if they
- * were.
- */
-#if 0
-#define real_tty_output(x) (exp_stdout_is_tty && (((x)==1) || ((x)==exp_dev_tty)))
-#define real_tty_input(x) (exp_stdin_is_tty && (((x)==0) || ((x)==exp_dev_tty)))
-#endif
-
-#define real_tty_output(x) (((x)==1) || ((x)==exp_dev_tty))
-#define real_tty_input(x) (exp_stdin_is_tty && (((x)==0) || ((x)==exp_dev_tty)))
-
-#define new(x) (x *)ckalloc(sizeof(x))
-
-struct action {
- char *statement;
- int tty_reset; /* if true, reset tty mode upon action */
- int iread; /* if true, reread indirects */
- int iwrite; /* if true, write spawn_id element */
- int timestamp; /* if true, generate timestamp */
- struct action *next; /* chain only for later for freeing */
-};
-
-struct keymap {
- char *keys; /* original pattern provided by user */
- Expect_regexp *re;
- int null; /* true if looking to match 0 byte */
- int case_sensitive;
- int echo; /* if keystrokes should be echoed */
- int writethru; /* if keystrokes should go through to process */
- int indices; /* true if should write indices */
- struct action action;
- struct keymap *next;
-};
-
-struct output {
- struct exp_i *i_list;
- struct action *action_eof;
- struct output *next;
-};
-
-struct input {
- struct exp_i *i_list;
- struct output *output;
- struct action *action_eof;
- struct action *action_timeout;
- struct keymap *keymap;
- int timeout_nominal; /* timeout nominal */
- int timeout_remaining; /* timeout remaining */
- struct input *next;
-};
-
-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();
-
-/* in_keymap() accepts user keystrokes and returns one of MATCH,
-CANMATCH, or CANTMATCH. These describe whether the keystrokes match a
-key sequence, and could or can't if more characters arrive. The
-function assigns a matching keymap if there is a match or can-match.
-A matching keymap is assigned on can-match so we know whether to echo
-or not.
-
-in_keymap is optimized (if you can call it that) towards a small
-number of key mappings, but still works well for large maps, since no
-function calls are made, and we stop as soon as there is a single-char
-mismatch, and go on to the next one. A hash table or compiled DFA
-probably would not buy very much here for most maps.
-
-The basic idea of how this works is it does a smart sequential search.
-At each position of the input string, we attempt to match each of the
-keymaps. If at least one matches, the first match is returned.
-
-If there is a CANMATCH and there are more keymaps to try, we continue
-trying. If there are no more keymaps to try, we stop trying and
-return with an indication of the first keymap that can match.
-
-Note that I've hacked up the regexp pattern matcher in two ways. One
-is to force the pattern to always be anchored at the front. That way,
-it doesn't waste time attempting to match later in the string (before
-we're ready). The other is to return can-match.
-
-*/
-
-static int
-in_keymap(string,stringlen,keymap,km_match,match_length,skip,rm_nulls)
-char *string;
-int stringlen;
-struct keymap *keymap; /* linked list of keymaps */
-struct keymap **km_match; /* keymap that matches or can match */
-int *match_length; /* # of chars that matched */
-int *skip; /* # of chars to skip */
-int rm_nulls; /* skip nulls if true */
-{
- struct keymap *km;
- char *ks; /* string from a keymap */
- char *start_search; /* where in the string to start searching */
- char *string_end;
-
- /* assert (*km == 0) */
-
- /* a shortcut that should help master output which typically */
- /* is lengthy and has no key maps. Otherwise it would mindlessly */
- /* iterate on each character anyway. */
- if (!keymap) {
- *skip = stringlen;
- return(EXP_CANTMATCH);
- }
-
- string_end = string + stringlen;
-
- /* Mark beginning of line for ^ . */
- regbol = string;
-
-/* skip over nulls - Pascal Meheut, pascal@cnam.cnam.fr 18-May-1993 */
-/* for (start_search = string;*start_search;start_search++) {*/
- for (start_search = string;start_search<string_end;start_search++) {
- if (*km_match) break; /* if we've already found a CANMATCH */
- /* don't bother starting search from positions */
- /* further along the string */
-
- for (km=keymap;km;km=km->next) {
- char *s; /* current character being examined */
-
- if (km->null) {
- if (*start_search == 0) {
- *skip = start_search-string;
- *match_length = 1; /* s - start_search == 1 */
- *km_match = km;
- return(EXP_MATCH);
- }
- } else if (!km->re) {
- /* fixed string */
- for (s = start_search,ks = km->keys ;;s++,ks++) {
- /* if we hit the end of this map, must've matched! */
- if (*ks == 0) {
- *skip = start_search-string;
- *match_length = s-start_search;
- *km_match = km;
- return(EXP_MATCH);
- }
-
- /* if we ran out of user-supplied characters, and */
- /* still haven't matched, it might match if the user */
- /* supplies more characters next time */
-
- if (s == string_end) {
- /* skip to next key entry, but remember */
- /* possibility that this entry might match */
- if (!*km_match) *km_match = km;
- break;
- }
-
- /* if this is a problem for you, use exp_parity command */
-/* if ((*s & 0x7f) == *ks) continue;*/
- if (*s == *ks) continue;
- if ((*s == '\0') && rm_nulls) {
- ks--;
- continue;
- }
- break;
- }
- } else {
- /* regexp */
- int r; /* regtry status */
- Expect_regexp *prog = km->re;
-
- /* if anchored, but we're not at beginning, skip pattern */
- if (prog->reganch) {
- if (string != start_search) continue;
- }
-
- /* known starting char - quick test 'fore lotta work */
- if (prog->regstart) {
- /* if this is a problem for you, use exp_parity command */
-/* /* if ((*start_search & 0x7f) != prog->regstart) continue; */
- if (*start_search != prog->regstart) continue;
- }
- r = exp_regtry(prog,start_search,match_length);
- if (r == EXP_MATCH) {
- *km_match = km;
- *skip = start_search-string;
- return(EXP_MATCH);
- }
- if (r == EXP_CANMATCH) {
- if (!*km_match) *km_match = km;
- }
- }
- }
- }
-
- if (*km_match) {
- /* report a can-match */
-
- char *p;
-
- *skip = (start_search-string)-1;
-#if 0
- *match_length = stringlen - *skip;
-#else
- /*
- * there may be nulls in the string in which case
- * the pattern matchers can report CANMATCH when
- * the null is hit. So find the null and compute
- * the length of the possible match.
- *
- * Later, after we squeeze out the nulls, we will
- * retry the match, but for now, go along with
- * calling it a CANMATCH
- */
- p = start_search;
- while (*p) {
- p++;
- }
- *match_length = (p - start_search) + 1;
- /*printf(" match_length = %d\n",*match_length);*/
-#endif
- return(EXP_CANMATCH);
- }
-
- *skip = start_search-string;
- return(EXP_CANTMATCH);
-}
-
-#ifdef SIMPLE_EVENT
-
-/*
-
-The way that the "simple" interact works is that the original Expect
-process reads from the tty and writes to the spawned process. A child
-process is forked to read from the spawned process and write to the
-tty. It looks like this:
-
- user
- --> tty >--
- / \
- ^ v
- child original
- process Expect
- ^ process
- | v
- \ /
- < spawned <
- process
-
-*/
-
-
-
-#ifndef WEXITSTATUS
-#define WEXITSTATUS(stat) (((*((int *) &(stat))) >> 8) & 0xff)
-#endif
-
-#include <setjmp.h>
-
-static jmp_buf env; /* for interruptable read() */
-static int reading; /* while we are reading */
- /* really, while "env" is valid */
-static int deferred_interrupt = FALSE; /* if signal is received, but not */
- /* in i_read record this here, so it will */
- /* be handled next time through i_read */
-
-void sigchld_handler()
-{
- if (reading) longjmp(env,1);
-
- deferred_interrupt = TRUE;
-}
-
-#define EXP_CHILD_EOF -100
-
-/* interruptable read */
-static int
-i_read(fd,buffer,length)
-int fd;
-char *buffer;
-int length;
-{
- int cc = EXP_CHILD_EOF;
-
- if (deferred_interrupt) return(cc);
-
- if (0 == setjmp(env)) {
- reading = TRUE;
- cc = read(fd,buffer,length);
- }
- reading = FALSE;
- return(cc);
-}
-
-/* exit status for the child process created by cmdInteract */
-#define CHILD_DIED -2
-#define SPAWNED_PROCESS_DIED -3
-
-static void
-clean_up_after_child(interp,master)
-Tcl_Interp *interp;
-int master;
-{
-/* should really be recoded using the common wait code in command.c */
- int status;
- int pid;
- int i;
-
- pid = wait(&status); /* for slave */
- for (i=0;i<=exp_fd_max;i++) {
- if (exp_fs[i].pid == pid) {
- exp_fs[i].sys_waited = TRUE;
- exp_fs[i].wait = status;
- }
- }
- pid = wait(&status); /* for child */
- for (i=0;i<=exp_fd_max;i++) {
- if (exp_fs[i].pid == pid) {
- exp_fs[i].sys_waited = TRUE;
- exp_fs[i].wait = status;
- }
- }
-
- deferred_interrupt = FALSE;
- exp_close(interp,master);
- master = -1;
-}
-#endif /*SIMPLE_EVENT*/
-
-static int
-update_interact_fds(interp,fd_count,fd_to_input,fd_list,input_base,
- do_indirect,config_count,real_tty_caller)
-Tcl_Interp *interp;
-int *fd_count;
-struct input ***fd_to_input; /* map from fd's to "struct input"s */
-int **fd_list;
-struct input *input_base;
-int do_indirect; /* if true do indirects */
-int *config_count;
-int *real_tty_caller;
-{
- struct input *inp;
- struct output *outp;
- struct exp_fd_list *fdp;
- int count;
-
- int real_tty = FALSE;
-
- *config_count = exp_configure_count;
-
- count = 0;
- for (inp = input_base;inp;inp=inp->next) {
-
- if (do_indirect) {
- /* do not update "direct" entries (again) */
- /* they were updated upon creation */
- if (inp->i_list->direct == EXP_INDIRECT) {
- exp_i_update(interp,inp->i_list);
- }
- for (outp = inp->output;outp;outp=outp->next) {
- if (outp->i_list->direct == EXP_INDIRECT) {
- exp_i_update(interp,outp->i_list);
- }
- }
- }
-
- /* revalidate all input descriptors */
- for (fdp = inp->i_list->fd_list;fdp;fdp=fdp->next) {
- count++;
- /* have to "adjust" just in case spawn id hasn't had */
- /* a buffer sized yet */
- if (!exp_fd2f(interp,fdp->fd,1,1,"interact"))
- return(TCL_ERROR);
- }
-
- /* revalidate all output descriptors */
- for (outp = inp->output;outp;outp=outp->next) {
- for (fdp = outp->i_list->fd_list;fdp;fdp=fdp->next) {
- /* make user_spawn_id point to stdout */
- if (fdp->fd == 0) {
- fdp->fd = 1;
- } else if (fdp->fd == 1) {
- /* do nothing */
- } else if (!exp_fd2f(interp,fdp->fd,1,0,"interact"))
- return(TCL_ERROR);
- }
- }
- }
- if (!do_indirect) return TCL_OK;
-
- if (*fd_to_input == 0) {
- *fd_to_input = (struct input **)ckalloc(
- (exp_fd_max+1) * sizeof(struct input *));
- *fd_list = (int *)ckalloc(count * sizeof(int));
- } else {
- *fd_to_input = (struct input **)ckrealloc((char *)*fd_to_input,
- (exp_fd_max+1) * sizeof(struct input *));
- *fd_list = (int *)ckrealloc((char *)*fd_list,count * sizeof(int));
- }
-
- count = 0;
- for (inp = input_base;inp;inp=inp->next) {
- for (fdp = inp->i_list->fd_list;fdp;fdp=fdp->next) {
- /* build map to translate from spawn_id to struct input */
- (*fd_to_input)[fdp->fd] = inp;
-
- /* build input to ready() */
- (*fd_list)[count] = fdp->fd;
-
- if (real_tty_input(fdp->fd)) real_tty = TRUE;
-
- count++;
- }
- }
- *fd_count = count;
-
- *real_tty_caller = real_tty; /* tell caller if we have found that */
- /* we are using real tty */
-
- return TCL_OK;
-}
-
-/*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. */
-{
- exp_configure_count++;
- return 0;
-}
-
-#define finish(x) { status = x; goto done; }
-
-static char return_cmd[] = "return";
-static char interpreter_cmd[] = "interpreter";
-
-/*ARGSUSED*/
-int
-Exp_InteractCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- char *arg; /* shorthand for current argv */
-#ifdef SIMPLE_EVENT
- int pid;
-#endif /*SIMPLE_EVENT*/
-
- /*declarations*/
- int input_count; /* count of struct input descriptors */
- struct input **fd_to_input; /* map from fd's to "struct input"s */
- int *fd_list;
- struct keymap *km; /* ptr for above while parsing */
-/* extern char *tclRegexpError; /* declared in tclInt.h */
- int master = EXP_SPAWN_ID_BAD;
- char *master_string = 0;/* string representation of master */
- int need_to_close_master = FALSE; /* if an eof is received */
- /* we use this to defer close until later */
-
- int next_tty_reset = FALSE; /* if we've seen a single -reset */
- int next_iread = FALSE;/* if we've seen a single -iread */
- int next_iwrite = FALSE;/* if we've seen a single -iread */
- int next_re = FALSE; /* if we've seen a single -re */
- int next_null = FALSE; /* if we've seen the null keyword */
- int next_writethru = FALSE;/*if macros should also go to proc output */
- int next_indices = FALSE;/* if we should write indices */
- int next_echo = FALSE; /* if macros should be echoed */
- int next_timestamp = FALSE; /* if we should generate a timestamp */
-/* int next_case_sensitive = TRUE;*/
- char **oldargv = 0; /* save original argv here if we split it */
- int status = TCL_OK; /* final return value */
- int i; /* trusty temp */
-
- int timeout_simple = TRUE; /* if no or global timeout */
-
- int real_tty; /* TRUE if we are interacting with real tty */
- int tty_changed = FALSE;/* true if we had to change tty modes for */
- /* interact to work (i.e., to raw, noecho) */
- int was_raw;
- int was_echo;
- exp_tty tty_old;
-
- char *replace_user_by_process = 0; /* for -u flag */
-
- struct input *input_base;
-#define input_user input_base
- struct input *input_default;
- struct input *inp; /* overused ptr to struct input */
- struct output *outp; /* overused ptr to struct output */
-
- int dash_input_count = 0; /* # of "-input"s seen */
- int arbitrary_timeout;
- int default_timeout;
- struct action action_timeout; /* common to all */
- struct action action_eof; /* common to all */
- struct action **action_eof_ptr; /* allow -input/ouput to */
- /* leave their eof-action assignable by a later */
- /* -eof */
- struct action *action_base = 0;
- struct keymap **end_km;
-
- int key;
- int configure_count; /* monitor reconfigure events */
-
- if ((argc == 2) && exp_one_arg_braced(argv[1])) {
- return(exp_eval_with_one_arg(clientData,interp,argv));
- } else if ((argc == 3) && streq(argv[1],"-brace")) {
- char *new_argv[2];
- new_argv[0] = argv[0];
- new_argv[1] = argv[2];
- return(exp_eval_with_one_arg(clientData,interp,new_argv));
- }
-
- argv++;
- argc--;
-
- default_timeout = EXP_TIME_INFINITY;
- arbitrary_timeout = EXP_TIME_INFINITY; /* if user specifies */
- /* a bunch of timeouts with EXP_TIME_INFINITY, this will be */
- /* left around for us to find. */
-
- input_user = new(struct input);
- input_user->i_list = exp_new_i_simple(0,EXP_TEMPORARY); /* stdin by default */
- input_user->output = 0;
- input_user->action_eof = &action_eof;
- input_user->timeout_nominal = EXP_TIME_INFINITY;
- input_user->action_timeout = 0;
- input_user->keymap = 0;
-
- end_km = &input_user->keymap;
- inp = input_user;
- action_eof_ptr = &input_user->action_eof;
-
- input_default = new(struct input);
- input_default->i_list = exp_new_i_simple(EXP_SPAWN_ID_BAD,EXP_TEMPORARY); /* fix up later */
- input_default->output = 0;
- input_default->action_eof = &action_eof;
- input_default->timeout_nominal = EXP_TIME_INFINITY;
- input_default->action_timeout = 0;
- input_default->keymap = 0;
- input_default->next = 0; /* no one else */
- input_user->next = input_default;
-
- /* default and common -eof action */
- action_eof.statement = return_cmd;
- action_eof.tty_reset = FALSE;
- action_eof.iread = FALSE;
- action_eof.iwrite = FALSE;
- action_eof.timestamp = FALSE;
-
- for (;argc>0;argc--,argv++) {
- arg = *argv;
- if (exp_flageq("eof",arg,3)) {
- struct action *action;
-
- argc--;argv++;
- *action_eof_ptr = action = new_action(&action_base);
-
- action->statement = *argv;
-
- action->tty_reset = next_tty_reset;
- next_tty_reset = FALSE;
- action->iwrite = next_iwrite;
- next_iwrite = FALSE;
- action->iread = next_iread;
- next_iread = FALSE;
- action->timestamp = next_timestamp;
- next_timestamp = FALSE;
- continue;
- } else if (exp_flageq("timeout",arg,7)) {
- int t;
- struct action *action;
-
- argc--;argv++;
- if (argc < 1) {
- exp_error(interp,"timeout needs time");
- return(TCL_ERROR);
- }
- t = atoi(*argv);
- argc--;argv++;
-
- /* we need an arbitrary timeout to start */
- /* search for lowest one later */
- if (t != -1) arbitrary_timeout = t;
-
- timeout_simple = FALSE;
- action = inp->action_timeout = new_action(&action_base);
- inp->timeout_nominal = t;
-
- action->statement = *argv;
-
- action->tty_reset = next_tty_reset;
- next_tty_reset = FALSE;
- action->iwrite = next_iwrite;
- next_iwrite = FALSE;
- action->iread = next_iread;
- next_iread = FALSE;
- action->timestamp = next_timestamp;
- next_timestamp = FALSE;
- continue;
- } else if (exp_flageq("null",arg,4)) {
- next_null = TRUE;
- } else if (arg[0] == '-') {
- arg++;
- if (exp_flageq1('-',arg) /* "--" */
- || (exp_flageq("exact",arg,3))) {
- argc--;argv++;
- } else if (exp_flageq("regexp",arg,2)) {
- if (argc < 1) {
- exp_error(interp,"-re needs pattern");
- return(TCL_ERROR);
- }
- next_re = TRUE;
- argc--;
- argv++;
- } else if (exp_flageq("input",arg,2)) {
- dash_input_count++;
- if (dash_input_count == 2) {
- inp = input_default;
- input_user->next = input_default;
- } else if (dash_input_count > 2) {
- struct input *previous_input = inp;
- inp = new(struct input);
- previous_input->next = inp;
- }
- inp->output = 0;
- inp->action_eof = &action_eof;
- action_eof_ptr = &inp->action_eof;
- inp->timeout_nominal = default_timeout;
- inp->action_timeout = &action_timeout;
- inp->keymap = 0;
- end_km = &inp->keymap;
- inp->next = 0;
- argc--;argv++;
- if (argc < 1) {
- exp_error(interp,"-input needs argument");
- return(TCL_ERROR);
- }
-/* inp->spawn_id = atoi(*argv);*/
- inp->i_list = exp_new_i_complex(interp,*argv,
- EXP_TEMPORARY,inter_updateproc);
- continue;
- } else if (exp_flageq("output",arg,3)) {
- struct output *tmp;
-
- /* imply a "-input" */
- if (dash_input_count == 0) dash_input_count = 1;
-
- outp = new(struct output);
-
- /* link new output in front of others */
- tmp = inp->output;
- inp->output = outp;
- outp->next = tmp;
-
- argc--;argv++;
- if (argc < 1) {
- exp_error(interp,"-output needs argument");
- return(TCL_ERROR);
- }
- outp->i_list = exp_new_i_complex(interp,*argv,
- EXP_TEMPORARY,inter_updateproc);
-
- outp->action_eof = &action_eof;
- action_eof_ptr = &outp->action_eof;
- continue;
- } else if (exp_flageq1('u',arg)) { /* treat process as user */
- argc--;argv++;
- if (argc < 1) {
- exp_error(interp,"-u needs argument");
- return(TCL_ERROR);
- }
- replace_user_by_process = *argv;
-
- /* imply a "-input" */
- if (dash_input_count == 0) dash_input_count = 1;
-
- continue;
- } else if (exp_flageq1('o',arg)) {
- /* apply following patterns to opposite side */
- /* of interaction */
-
- end_km = &input_default->keymap;
-
- /* imply two "-input" */
- if (dash_input_count < 2) {
- dash_input_count = 2;
- inp = input_default;
- action_eof_ptr = &inp->action_eof;
- }
- continue;
- } else if (exp_flageq1('i',arg)) {
- /* substitute master */
-
- argc--;argv++;
-/* master = atoi(*argv);*/
- master_string = *argv;
- /* will be used later on */
-
- end_km = &input_default->keymap;
-
- /* imply two "-input" */
- if (dash_input_count < 2) {
- dash_input_count = 2;
- inp = input_default;
- action_eof_ptr = &inp->action_eof;
- }
- continue;
-/* } else if (exp_flageq("nocase",arg,3)) {*/
-/* next_case_sensitive = FALSE;*/
-/* continue;*/
- } else if (exp_flageq("echo",arg,4)) {
- next_echo = TRUE;
- continue;
- } else if (exp_flageq("nobuffer",arg,3)) {
- next_writethru = TRUE;
- continue;
- } else if (exp_flageq("indices",arg,3)) {
- next_indices = TRUE;
- continue;
- } else if (exp_flageq1('f',arg)) {
- /* leftover from "fast" days */
- continue;
- } else if (exp_flageq("reset",arg,5)) {
- next_tty_reset = TRUE;
- continue;
- } else if (exp_flageq1('F',arg)) {
- /* leftover from "fast" days */
- continue;
- } else if (exp_flageq("iread",arg,2)) {
- next_iread = TRUE;
- continue;
- } else if (exp_flageq("iwrite",arg,2)) {
- next_iwrite = TRUE;
- continue;
- } else if (exp_flageq("eof",arg,3)) {
- struct action *action;
-
- argc--;argv++;
- debuglog("-eof is deprecated, use eof\r\n");
- *action_eof_ptr = action = new_action(&action_base);
- action->statement = *argv;
- action->tty_reset = next_tty_reset;
- next_tty_reset = FALSE;
- action->iwrite = next_iwrite;
- next_iwrite = FALSE;
- action->iread = next_iread;
- next_iread = FALSE;
- action->timestamp = next_timestamp;
- next_timestamp = FALSE;
-
- continue;
- } else if (exp_flageq("timeout",arg,7)) {
- int t;
- struct action *action;
- debuglog("-timeout is deprecated, use timeout\r\n");
-
- argc--;argv++;
- if (argc < 1) {
- exp_error(interp,"-timeout needs time");
- return(TCL_ERROR);
- }
-
- t = atoi(*argv);
- argc--;argv++;
- if (t != -1)
- arbitrary_timeout = t;
- /* we need an arbitrary timeout to start */
- /* search for lowest one later */
-
-#if 0
- /* if -timeout comes before "-input", then applies */
- /* to all descriptors, else just the current one */
- if (dash_input_count > 0) {
- timeout_simple = FALSE;
- action = inp->action_timeout =
- new_action(&action_base);
- inp->timeout_nominal = t;
- } else {
- action = &action_timeout;
- default_timeout = t;
- }
-#endif
- timeout_simple = FALSE;
- action = inp->action_timeout = new_action(&action_base);
- inp->timeout_nominal = t;
-
- action->statement = *argv;
- action->tty_reset = next_tty_reset;
- next_tty_reset = FALSE;
- action->iwrite = next_iwrite;
- next_iwrite = FALSE;
- action->iread = next_iread;
- next_iread = FALSE;
- action->timestamp = next_timestamp;
- next_timestamp = FALSE;
- continue;
- } else if (exp_flageq("timestamp",arg,2)) {
- debuglog("-timestamp is deprecated, use exp_timestamp command\r\n");
- next_timestamp = TRUE;
- continue;
- } else if (exp_flageq("nobrace",arg,7)) {
- /* nobrace does nothing but take up space */
- /* on the command line which prevents */
- /* us from re-expanding any command lines */
- /* of one argument that looks like it should */
- /* be expanded to multiple arguments. */
- continue;
- }
- }
-
- /*
- * pick up the pattern
- */
-
- km = new(struct keymap);
-
- /* so that we can match in order user specified */
- /* link to end of keymap list */
- *end_km = km;
- km->next = 0;
- end_km = &km->next;
-
- km->echo = next_echo;
- km->writethru = next_writethru;
- km->indices = next_indices;
- km->action.tty_reset = next_tty_reset;
- km->action.iwrite = next_iwrite;
- km->action.iread = next_iread;
- km->action.timestamp = next_timestamp;
-/* km->case_sensitive = next_case_sensitive;*/
-
- next_indices = next_echo = next_writethru = FALSE;
- next_tty_reset = FALSE;
- next_iwrite = next_iread = FALSE;
-/* next_case_sensitive = TRUE;*/
-
- km->keys = *argv;
-
- km->null = FALSE;
- km->re = 0;
- if (next_re) {
- Expect_TclRegError((char *)0);
- if (0 == (km->re = Expect_TclRegComp(*argv))) {
- exp_error(interp,"bad regular expression: %s",
- TclGetRegError());
- return(TCL_ERROR);
- }
- next_re = FALSE;
- } if (next_null) {
- km->null = TRUE;
- next_null = FALSE;
- }
-
- argc--;argv++;
-
- km->action.statement = *argv;
- debuglog("defining key %s, action %s\r\n",
- km->keys,
- km->action.statement?(dprintify(km->action.statement))
- :interpreter_cmd);
-
- /* imply a "-input" */
- if (dash_input_count == 0) dash_input_count = 1;
- }
-
- /* if the user has not supplied either "-output" for the */
- /* default two "-input"s, fix them up here */
-
- if (!input_user->output) {
- struct output *o = new(struct output);
- if (master_string == 0) {
- if (0 == exp_update_master(interp,&master,1,1)) {
- return(TCL_ERROR);
- }
- o->i_list = exp_new_i_simple(master,EXP_TEMPORARY);
- } else {
- o->i_list = exp_new_i_complex(interp,master_string,
- EXP_TEMPORARY,inter_updateproc);
- }
-#if 0
- if (master == EXP_SPAWN_ID_BAD) {
- if (0 == exp_update_master(interp,&master,1,1)) {
- return(TCL_ERROR);
- }
- }
- o->i_list = exp_new_i_simple(master,EXP_TEMPORARY);
-#endif
- o->next = 0; /* no one else */
- o->action_eof = &action_eof;
- input_user->output = o;
- }
-
- if (!input_default->output) {
- struct output *o = new(struct output);
- o->i_list = exp_new_i_simple(1,EXP_TEMPORARY);/* stdout by default */
- o->next = 0; /* no one else */
- o->action_eof = &action_eof;
- input_default->output = o;
- }
-
- /* if user has given "-u" flag, substitute process for user */
- /* in first two -inputs */
- if (replace_user_by_process) {
- /* through away old ones */
- exp_free_i(interp,input_user->i_list, inter_updateproc);
- exp_free_i(interp,input_default->output->i_list,inter_updateproc);
-
- /* replace with arg to -u */
- input_user->i_list = exp_new_i_complex(interp,
- replace_user_by_process,
- EXP_TEMPORARY,inter_updateproc);
- input_default->output->i_list = exp_new_i_complex(interp,
- replace_user_by_process,
- EXP_TEMPORARY,inter_updateproc);
- }
-
- /*
- * now fix up for default spawn id
- */
-
- /* user could have replaced it with an indirect, so force update */
- if (input_default->i_list->direct == EXP_INDIRECT) {
- exp_i_update(interp,input_default->i_list);
- }
-
- if (input_default->i_list->fd_list
- && (input_default->i_list->fd_list->fd == EXP_SPAWN_ID_BAD)) {
- if (master_string == 0) {
- if (0 == exp_update_master(interp,&master,1,1)) {
- return(TCL_ERROR);
- }
- input_default->i_list->fd_list->fd = master;
- } else {
- /* discard old one and install new one */
- exp_free_i(interp,input_default->i_list,inter_updateproc);
- input_default->i_list = exp_new_i_complex(interp,master_string,
- EXP_TEMPORARY,inter_updateproc);
- }
-#if 0
- if (master == EXP_SPAWN_ID_BAD) {
- if (0 == exp_update_master(interp,&master,1,1)) {
- return(TCL_ERROR);
- }
- }
- input_default->i_list->fd_list->fd = master;
-#endif
- }
-
- /*
- * check for user attempting to interact with self
- * they're almost certainly just fooling around
- */
-
- /* user could have replaced it with an indirect, so force update */
- if (input_user->i_list->direct == EXP_INDIRECT) {
- exp_i_update(interp,input_user->i_list);
- }
-
- if (input_user->i_list->fd_list && input_default->i_list->fd_list
- && (input_user->i_list->fd_list->fd == input_default->i_list->fd_list->fd)) {
- exp_error(interp,"cannot interact with self - set spawn_id to a spawned process");
- return(TCL_ERROR);
- }
-
- fd_list = 0;
- fd_to_input = 0;
-
- /***************************************************************/
- /* all data structures are sufficiently set up that we can now */
- /* "finish()" to terminate this procedure */
- /***************************************************************/
-
- status = update_interact_fds(interp,&input_count,&fd_to_input,&fd_list,input_base,1,&configure_count,&real_tty);
- if (status == TCL_ERROR) finish(TCL_ERROR);
-
- if (real_tty) {
- tty_changed = exp_tty_raw_noecho(interp,&tty_old,&was_raw,&was_echo);
- }
-
- for (inp = input_base,i=0;inp;inp=inp->next,i++) {
- /* start timers */
- inp->timeout_remaining = inp->timeout_nominal;
- }
-
- key = expect_key++;
-
- /* declare ourselves "in sync" with external view of close/indirect */
- configure_count = exp_configure_count;
-
-#ifndef SIMPLE_EVENT
- /* loop waiting (in event handler) for input */
- for (;;) {
- int te; /* result of Tcl_Eval */
- struct exp_f *u;
- int rc; /* return code from ready. This is further */
- /* refined by matcher. */
- int cc; /* chars count from read() */
- int m; /* master */
- int m_out; /* where master echoes to */
- struct action *action = 0;
- time_t previous_time;
- time_t current_time;
- int match_length, skip;
- int change; /* if action requires cooked mode */
- int attempt_match = TRUE;
- struct input *soonest_input;
- int print; /* # of chars to print */
- int oldprinted; /* old version of u->printed */
-
- int timeout; /* current as opposed to default_timeout */
-
- /* calculate how long to wait */
- /* by finding shortest remaining timeout */
- if (timeout_simple) {
- timeout = default_timeout;
- } else {
- timeout = arbitrary_timeout;
-
- for (inp=input_base;inp;inp=inp->next) {
- if ((inp->timeout_remaining != EXP_TIME_INFINITY) &&
- (inp->timeout_remaining <= timeout)) {
- soonest_input = inp;
- timeout = inp->timeout_remaining;
- }
- }
-
- time(&previous_time);
- /* timestamp here rather than simply saving old */
- /* current time (after ready()) to account for */
- /* possibility of slow actions */
-
- /* timeout can actually be EXP_TIME_INFINITY here if user */
- /* explicitly supplied it in a few cases (or */
- /* the count-down code is broken) */
- }
-
- /* update the world, if necessary */
- if (configure_count != exp_configure_count) {
- status = update_interact_fds(interp,&input_count,
- &fd_to_input,&fd_list,input_base,1,
- &configure_count,&real_tty);
- if (status) finish(status);
- }
-
- rc = exp_get_next_event(interp,fd_list,input_count,&m,timeout,key);
- if (rc == EXP_TCLERROR) return(TCL_ERROR);
-
- if (rc == EXP_RECONFIGURE) continue;
-
- if (rc == EXP_TIMEOUT) {
- if (timeout_simple) {
- action = &action_timeout;
- goto got_action;
- } else {
- action = soonest_input->action_timeout;
- /* arbitrarily pick first fd out of list */
- m = soonest_input->i_list->fd_list->fd;
- }
- }
- if (!timeout_simple) {
- int time_diff;
-
- time(¤t_time);
- time_diff = current_time - previous_time;
-
- /* update all timers */
- for (inp=input_base;inp;inp=inp->next) {
- if (inp->timeout_remaining != EXP_TIME_INFINITY) {
- inp->timeout_remaining -= time_diff;
- if (inp->timeout_remaining < 0)
- inp->timeout_remaining = 0;
- }
- }
- }
-
- /* at this point, we have some kind of event which can be */
- /* immediately processed - i.e. something that doesn't block */
-
- /* figure out who we are */
- inp = fd_to_input[m];
-/* u = inp->f;*/
- u = exp_fs+m;
-
- /* reset timer */
- inp->timeout_remaining = inp->timeout_nominal;
-
- switch (rc) {
- case EXP_DATA_NEW:
- if (u->size == u->msize) {
- /* In theory, interact could be invoked when this situation */
- /* already exists, hence the "probably" in the warning below */
-
- debuglog("WARNING: interact buffer is full, probably because your\r\n");
- debuglog("patterns have matched all of it but require more chars\r\n");
- debuglog("in order to complete the match.\r\n");
- debuglog("Dumping first half of buffer in order to continue\r\n");
- debuglog("Recommend you enlarge the buffer or fix your patterns.\r\n");
- exp_buffer_shuffle(interp,u,0,INTER_OUT,"interact");
- }
- cc = read(m, u->buffer + u->size,
- u->msize - u->size);
- if (cc > 0) {
- u->key = key;
- u->size += cc;
- u->buffer[u->size] = '\0';
-
- /* strip parity if requested */
- if (u->parity == 0) {
- /* do it from end backwards */
- char *p = u->buffer + u->size - 1;
- int count = cc;
- while (count--) {
- *p-- &= 0x7f;
- }
- }
-
- /* avoid another function call if possible */
- if (debugfile || is_debugging) {
- debuglog("spawn id %d sent <%s>\r\n",m,
- exp_printify(u->buffer + u->size - cc));
- }
- break;
- }
-
- rc = EXP_EOF;
- /* Most systems have read() return 0, allowing */
- /* control to fall thru and into this code. On some */
- /* systems (currently HP and new SGI), read() does */
- /* see eof, and it must be detected earlier. Then */
- /* control jumps directly to this EXP_EOF label. */
-
- /*FALLTHRU*/
- case EXP_EOF:
- action = inp->action_eof;
- attempt_match = FALSE;
- skip = u->size;
- debuglog("interact: received eof from spawn_id %d\r\n",m);
- /* actual close is done later so that we have a */
- /* chance to flush out any remaining characters */
- need_to_close_master = TRUE;
-
-#if EOF_SO
- /* should really check for remaining chars and */
- /* flush them but this will only happen in the */
- /* unlikely scenario that there are partially */
- /* matched buffered chars. */
- /* So for now, indicate no chars to skip. */
- skip = 0;
- exp_close(interp,m);
-#endif
- break;
- case EXP_DATA_OLD:
- cc = 0;
- break;
- case EXP_TIMEOUT:
- action = inp->action_timeout;
- attempt_match = FALSE;
- skip = u->size;
- break;
- }
-
- km = 0;
-
- if (attempt_match) {
- rc = in_keymap(u->buffer,u->size,inp->keymap,
- &km,&match_length,&skip,u->rm_nulls);
- } else {
- attempt_match = TRUE;
- }
-
- /* put regexp result in variables */
- if (km && km->re) {
-#define out(var,val) debuglog("expect: set %s(%s) \"%s\"\r\n",INTER_OUT,var, \
- dprintify(val)); \
- Tcl_SetVar2(interp,INTER_OUT,var,val,0);
-
- char name[20], value[20];
- Expect_regexp *re = km->re;
- char match_char;/* place to hold char temporarily */
- /* uprooted by a NULL */
-
- for (i=0;i<NSUBEXP;i++) {
- int offset;
-
- if (re->startp[i] == 0) continue;
-
- if (km->indices) {
- /* start index */
- sprintf(name,"%d,start",i);
- offset = re->startp[i]-u->buffer;
- sprintf(value,"%d",offset);
- out(name,value);
-
- /* end index */
- sprintf(name,"%d,end",i);
- sprintf(value,"%d",re->endp[i]-u->buffer-1);
- out(name,value);
- }
-
- /* string itself */
- sprintf(name,"%d,string",i);
- /* temporarily null-terminate in */
- /* middle */
- match_char = *re->endp[i];
- *re->endp[i] = 0;
- out(name,re->startp[i]);
- *re->endp[i] = match_char;
- }
- }
-
- /*
- * dispose of chars that should be skipped
- * i.e., chars that cannot possibly be part of a match.
- */
-
- /* "skip" is count of chars not involved in match */
- /* "print" is count with chars involved in match */
-
- if (km && km->writethru) {
- print = skip + match_length;
- } else print = skip;
-
- /*
- * echo chars if appropriate
- */
- if (km && km->echo) {
- int seen; /* either printed or echoed */
-
- /* echo to stdout rather than stdin */
- m_out = (m == 0)?1:m;
-
- /* write is unlikely to fail, since we just read */
- /* from same descriptor */
- seen = u->printed + u->echoed;
- if (skip >= seen) {
- write(m_out,u->buffer+skip,match_length);
- } else if ((match_length + skip - seen) > 0) {
- write(m_out,u->buffer+seen,match_length+skip-seen);
- }
- u->echoed = match_length + skip - u->printed;
- }
-
- oldprinted = u->printed;
-
- /* If expect has left characters in buffer, it has */
- /* already echoed them to the screen, thus we must */
- /* prevent them being rewritten. Unfortunately this */
- /* gives the possibility of matching chars that have */
- /* already been output, but we do so since the user */
- /* could have avoided it by flushing the output */
- /* buffers directly. */
- if (print > u->printed) { /* usual case */
- int wc; /* return code from write() */
- for (outp = inp->output;outp;outp=outp->next) {
- struct exp_fd_list *fdp;
- for (fdp = outp->i_list->fd_list;fdp;fdp=fdp->next) {
- int od; /* output descriptor */
-
- /* send to logfile if open */
- /* and user is seeing it */
- if (logfile && real_tty_output(fdp->fd)) {
- fwrite(u->buffer+u->printed,1,
- print - u->printed,logfile);
- }
-
- /* send to each output descriptor */
- od = fdp->fd;
- /* if opened by Tcl, it may use a different */
- /* output descriptor */
- od = (exp_fs[od].tcl_handle?exp_fs[od].tcl_output:od);
-
- wc = write(od,u->buffer+u->printed,
- print - u->printed);
- if (wc <= 0) {
- debuglog("interact: write on spawn id %d failed (%s)\r\n",fdp->fd,Tcl_PosixError(interp));
- action = outp->action_eof;
- change = (action && action->tty_reset);
-
- if (change && tty_changed)
- exp_tty_set(interp,&tty_old,was_raw,was_echo);
- te = inter_eval(interp,action,m);
-
- if (change && real_tty) tty_changed =
- exp_tty_raw_noecho(interp,&tty_old,&was_raw,&was_echo);
- switch (te) {
- case TCL_BREAK:
- case TCL_CONTINUE:
- finish(te);
- case EXP_TCL_RETURN:
- finish(TCL_RETURN);
- case TCL_RETURN:
- finish(TCL_OK);
- case TCL_OK:
- /* god knows what the user might */
- /* have done to us in the way of */
- /* closed fds, so .... */
- action = 0; /* reset action */
- continue;
- default:
- finish(te);
- }
- }
- }
- }
- u->printed = print;
- }
-
- /* u->printed is now accurate with respect to the buffer */
- /* However, we're about to shift the old data out of the */
- /* buffer. Thus, u->size, printed, and echoed must be */
- /* updated */
-
- /* first update size based on skip information */
- /* then set skip to the total amount skipped */
-
- if (rc == EXP_MATCH) {
- action = &km->action;
-
- skip += match_length;
- u->size -= skip;
-
- if (u->size) {
- memcpy(u->buffer, u->buffer + skip, u->size);
- exp_lowmemcpy(u->lower,u->buffer+ skip, u->size);
- }
- } else {
- if (skip) {
- u->size -= skip;
- memcpy(u->buffer, u->buffer + skip, u->size);
- exp_lowmemcpy(u->lower,u->buffer+ skip, u->size);
- }
- }
-
-#if EOF_SO
- /* as long as buffer is still around, null terminate it */
- if (rc != EXP_EOF) {
- u->buffer[u->size] = '\0';
- u->lower [u->size] = '\0';
- }
-#else
- u->buffer[u->size] = '\0';
- u->lower [u->size] = '\0';
-#endif
-
- /* now update printed based on total amount skipped */
-
- u->printed -= skip;
- /* if more skipped than printed (i.e., keymap encountered) */
- /* for printed positive */
- if (u->printed < 0) u->printed = 0;
-
- /* if we are in the middle of a match, force the next event */
- /* to wait for more data to arrive */
- u->force_read = (rc == EXP_CANMATCH);
-
- /* finally reset echoed if necessary */
- if (rc != EXP_CANMATCH) {
- if (skip >= oldprinted + u->echoed) u->echoed = 0;
- }
-
- if (rc == EXP_EOF) {
- exp_close(interp,m);
- need_to_close_master = FALSE;
- }
-
- if (action) {
-got_action:
- change = (action && action->tty_reset);
- if (change && tty_changed)
- exp_tty_set(interp,&tty_old,was_raw,was_echo);
-
- te = inter_eval(interp,action,m);
-
- if (change && real_tty) tty_changed =
- exp_tty_raw_noecho(interp,&tty_old,&was_raw,&was_echo);
- switch (te) {
- case TCL_BREAK:
- case TCL_CONTINUE:
- finish(te);
- case EXP_TCL_RETURN:
- finish(TCL_RETURN);
- case TCL_RETURN:
- finish(TCL_OK);
- case TCL_OK:
- /* god knows what the user might */
- /* have done to us in the way of */
- /* closed fds, so .... */
- action = 0; /* reset action */
- continue;
- default:
- finish(te);
- }
- }
- }
-
-#else /* SIMPLE_EVENT */
-/* deferred_interrupt = FALSE;*/
-{
- int te; /* result of Tcl_Eval */
- struct exp_f *u;
- int rc; /* return code from ready. This is further */
- /* refined by matcher. */
- int cc; /* chars count from read() */
- int m; /* master */
- struct action *action = 0;
- time_t previous_time;
- time_t current_time;
- int match_length, skip;
- int change; /* if action requires cooked mode */
- int attempt_match = TRUE;
- struct input *soonest_input;
- int print; /* # of chars to print */
- int oldprinted; /* old version of u->printed */
-
- int timeout; /* current as opposed to default_timeout */
-
- if (-1 == (pid = fork())) {
- exp_error(interp,"fork: %s",Tcl_PosixError(interp));
- finish(TCL_ERROR);
- }
- if (pid == 0) { /* child - send process output to user */
- exp_close(interp,0);
-
- m = fd_list[1]; /* get 2nd fd */
- input_count = 1;
-
- while (1) {
-
- /* calculate how long to wait */
- /* by finding shortest remaining timeout */
- if (timeout_simple) {
- timeout = default_timeout;
- } else {
- timeout = arbitrary_timeout;
-
- for (inp=input_base;inp;inp=inp->next) {
- if ((inp->timeout_remaining != EXP_TIME_INFINITY) &&
- (inp->timeout_remaining < timeout))
- soonest_input = inp;
- timeout = inp->timeout_remaining;
- }
-
- time(&previous_time);
- /* timestamp here rather than simply saving old */
- /* current time (after ready()) to account for */
- /* possibility of slow actions */
-
- /* timeout can actually be EXP_TIME_INFINITY here if user */
- /* explicitly supplied it in a few cases (or */
- /* the count-down code is broken) */
- }
-
- /* +1 so we can look at the "other" file descriptor */
- rc = exp_get_next_event(interp,fd_list+1,input_count,&m,timeout,key);
- if (!timeout_simple) {
- int time_diff;
-
- time(¤t_time);
- time_diff = current_time - previous_time;
-
- /* update all timers */
- for (inp=input_base;inp;inp=inp->next) {
- if (inp->timeout_remaining != EXP_TIME_INFINITY) {
- inp->timeout_remaining -= time_diff;
- if (inp->timeout_remaining < 0)
- inp->timeout_remaining = 0;
- }
- }
- }
-
- /* at this point, we have some kind of event which can be */
- /* immediately processed - i.e. something that doesn't block */
-
- /* figure out who we are */
- inp = fd_to_input[m];
-/* u = inp->f;*/
- u = exp_fs+m;
-
- switch (rc) {
- case EXP_DATA_NEW:
- cc = read(m, u->buffer + u->size,
- u->msize - u->size);
- if (cc > 0) {
- u->key = key;
- u->size += cc;
- u->buffer[u->size] = '\0';
-
- /* strip parity if requested */
- if (u->parity == 0) {
- /* do it from end backwards */
- char *p = u->buffer + u->size - 1;
- int count = cc;
- while (count--) {
- *p-- &= 0x7f;
- }
- }
-
- /* avoid another function call if possible */
- if (debugfile || is_debugging) {
- debuglog("spawn id %d sent <%s>\r\n",m,
- exp_printify(u->buffer + u->size - cc));
- }
- break;
- }
- /*FALLTHRU*/
-
- /* Most systems have read() return 0, allowing */
- /* control to fall thru and into this code. On some */
- /* systems (currently HP and new SGI), read() does */
- /* see eof, and it must be detected earlier. Then */
- /* control jumps directly to this EXP_EOF label. */
- case EXP_EOF:
- action = inp->action_eof;
- attempt_match = FALSE;
- skip = u->size;
- rc = EXP_EOF;
- debuglog("interact: child received eof from spawn_id %d\r\n",m);
- exp_close(interp,m);
- break;
- case EXP_DATA_OLD:
- cc = 0;
- break;
- }
-
- km = 0;
-
- if (attempt_match) {
- rc = in_keymap(u->buffer,u->size,inp->keymap,
- &km,&match_length,&skip);
- } else {
- attempt_match = TRUE;
- }
-
- /* put regexp result in variables */
- if (km && km->re) {
-#define INTER_OUT "interact_out"
-#define out(i,val) debuglog("expect: set %s(%s) \"%s\"\r\n",INTER_OUT,i, \
- dprintify(val)); \
- Tcl_SetVar2(interp,INTER_OUT,i,val,0);
-
- char name[20], value[20];
- regexp *re = km->re;
- char match_char;/* place to hold char temporarily */
- /* uprooted by a NULL */
-
- for (i=0;i<NSUBEXP;i++) {
- int offset;
-
- if (re->startp[i] == 0) continue;
-
- if (km->indices) {
- /* start index */
- sprintf(name,"%d,start",i);
- offset = re->startp[i]-u->buffer;
- sprintf(value,"%d",offset);
- out(name,value);
-
- /* end index */
- sprintf(name,"%d,end",i);
- sprintf(value,"%d",re->endp[i]-u->buffer-1);
- out(name,value);
- }
-
- /* string itself */
- sprintf(name,"%d,string",i);
- /* temporarily null-terminate in */
- /* middle */
- match_char = *re->endp[i];
- *re->endp[i] = 0;
- out(name,re->startp[i]);
- *re->endp[i] = match_char;
- }
- }
-
- /* dispose of chars that should be skipped */
-
- /* skip is chars not involved in match */
- /* print is with chars involved in match */
-
- if (km && km->writethru) {
- print = skip + match_length;
- } else print = skip;
-
- /* figure out if we should echo any chars */
- if (km && km->echo) {
- int seen; /* either printed or echoed */
-
- /* echo to stdout rather than stdin */
- if (m == 0) m = 1;
-
- /* write is unlikely to fail, since we just read */
- /* from same descriptor */
- seen = u->printed + u->echoed;
- if (skip >= seen) {
- write(m,u->buffer+skip,match_length);
- } else if ((match_length + skip - seen) > 0) {
- write(m,u->buffer+seen,match_length+skip-seen);
- }
- u->echoed = match_length + skip - u->printed;
- }
-
- oldprinted = u->printed;
-
- /* If expect has left characters in buffer, it has */
- /* already echoed them to the screen, thus we must */
- /* prevent them being rewritten. Unfortunately this */
- /* gives the possibility of matching chars that have */
- /* already been output, but we do so since the user */
- /* could have avoided it by flushing the output */
- /* buffers directly. */
- if (print > u->printed) { /* usual case */
- int wc; /* return code from write() */
- for (outp = inp->output;outp;outp=outp->next) {
- struct exp_fd_list *fdp;
- for (fdp = outp->i_list->fd_list;fdp;fdp=fdp->next) {
- int od; /* output descriptor */
-
- /* send to logfile if open */
- /* and user is seeing it */
- if (logfile && real_tty_output(fdp->fd)) {
- fwrite(u->buffer+u->printed,1,
- print - u->printed,logfile);
- }
-
- /* send to each output descriptor */
- od = fdp->fd;
- /* if opened by Tcl, it may use a different */
- /* output descriptor */
- od = (exp_fs[od].tcl_handle?exp_fs[od].tcl_output:od);
-
- wc = write(od,u->buffer+u->printed,
- print - u->printed);
- if (wc <= 0) {
- debuglog("interact: write on spawn id %d failed (%s)\r\n",fdp->fd,Tcl_PosixError(interp));
- action = outp->action_eof;
-
- te = inter_eval(interp,action,m);
-
- switch (te) {
- case TCL_BREAK:
- case TCL_CONTINUE:
- finish(te);
- case EXP_TCL_RETURN:
- finish(TCL_RETURN);
- case TCL_RETURN:
- finish(TCL_OK);
- case TCL_OK:
- /* god knows what the user might */
- /* have done to us in the way of */
- /* closed fds, so .... */
- action = 0; /* reset action */
- continue;
- default:
- finish(te);
- }
- }
- }
- }
- u->printed = print;
- }
-
- /* u->printed is now accurate with respect to the buffer */
- /* However, we're about to shift the old data out of the */
- /* buffer. Thus, u->size, printed, and echoed must be */
- /* updated */
-
- /* first update size based on skip information */
- /* then set skip to the total amount skipped */
-
- if (rc == EXP_MATCH) {
- action = &km->action;
-
- skip += match_length;
- u->size -= skip;
-
- if (u->size)
- memcpy(u->buffer, u->buffer + skip, u->size);
- exp_lowmemcpy(u->lower,u->buffer+ skip, u->size);
- } else {
- if (skip) {
- u->size -= skip;
- memcpy(u->buffer, u->buffer + skip, u->size);
- exp_lowmemcpy(u->lower,u->buffer+ skip, u->size);
- }
- }
-
- /* as long as buffer is still around, null terminate it */
- if (rc != EXP_EOF) {
- u->buffer[u->size] = '\0';
- u->lower [u->size] = '\0';
- }
- /* now update printed based on total amount skipped */
-
- u->printed -= skip;
- /* if more skipped than printed (i.e., keymap encountered) */
- /* for printed positive */
- if (u->printed < 0) u->printed = 0;
-
- /* if we are in the middle of a match, force the next event */
- /* to wait for more data to arrive */
- u->force_read = (rc == EXP_CANMATCH);
-
- /* finally reset echoed if necessary */
- if (rc != EXP_CANMATCH) {
- if (skip >= oldprinted + u->echoed) u->echoed = 0;
- }
-
- if (action) {
- te = inter_eval(interp,action,m);
- switch (te) {
- case TCL_BREAK:
- case TCL_CONTINUE:
- finish(te);
- case EXP_TCL_RETURN:
- finish(TCL_RETURN);
- case TCL_RETURN:
- finish(TCL_OK);
- case TCL_OK:
- /* god knows what the user might */
- /* have done to us in the way of */
- /* closed fds, so .... */
- action = 0; /* reset action */
- continue;
- default:
- finish(te);
- }
- }
- }
- } else { /* parent - send user keystrokes to process */
-#include <signal.h>
-
-#if defined(SIGCLD) && !defined(SIGCHLD)
-#define SIGCHLD SIGCLD
-#endif
- debuglog("fork = %d\r\n",pid);
- signal(SIGCHLD,sigchld_handler);
-/* restart:*/
-/* tty_changed = exp_tty_raw_noecho(interp,&tty_old,&was_raw,&was_echo);*/
-
- m = fd_list[0]; /* get 1st fd */
- input_count = 1;
-
- while (1) {
- /* calculate how long to wait */
- /* by finding shortest remaining timeout */
- if (timeout_simple) {
- timeout = default_timeout;
- } else {
- timeout = arbitrary_timeout;
-
- for (inp=input_base;inp;inp=inp->next) {
- if ((inp->timeout_remaining != EXP_TIME_INFINITY) &&
- (inp->timeout_remaining < timeout))
- soonest_input = inp;
- timeout = inp->timeout_remaining;
- }
-
- time(&previous_time);
- /* timestamp here rather than simply saving old */
- /* current time (after ready()) to account for */
- /* possibility of slow actions */
-
- /* timeout can actually be EXP_TIME_INFINITY here if user */
- /* explicitly supplied it in a few cases (or */
- /* the count-down code is broken) */
- }
-
- rc = exp_get_next_event(interp,fd_list,input_count,&m,timeout,key);
- if (!timeout_simple) {
- int time_diff;
-
- time(¤t_time);
- time_diff = current_time - previous_time;
-
- /* update all timers */
- for (inp=input_base;inp;inp=inp->next) {
- if (inp->timeout_remaining != EXP_TIME_INFINITY) {
- inp->timeout_remaining -= time_diff;
- if (inp->timeout_remaining < 0)
- inp->timeout_remaining = 0;
- }
- }
- }
-
- /* at this point, we have some kind of event which can be */
- /* immediately processed - i.e. something that doesn't block */
-
- /* figure out who we are */
- inp = fd_to_input[m];
-/* u = inp->f;*/
- u = exp_fs+m;
-
- switch (rc) {
- case EXP_DATA_NEW:
- cc = i_read(m, u->buffer + u->size,
- u->msize - u->size);
- if (cc > 0) {
- u->key = key;
- u->size += cc;
- u->buffer[u->size] = '\0';
-
- /* strip parity if requested */
- if (u->parity == 0) {
- /* do it from end backwards */
- char *p = u->buffer + u->size - 1;
- int count = cc;
- while (count--) {
- *p-- &= 0x7f;
- }
- }
-
- /* avoid another function call if possible */
- if (debugfile || is_debugging) {
- debuglog("spawn id %d sent <%s>\r\n",m,
- exp_printify(u->buffer + u->size - cc));
- }
- break;
- } else if (cc == EXP_CHILD_EOF) {
- /* user could potentially have two outputs in which */
- /* case we might be looking at the wrong one, but */
- /* the likelihood of this is nil */
- action = inp->output->action_eof;
- attempt_match = FALSE;
- skip = u->size;
- rc = EXP_EOF;
- debuglog("interact: process died/eof\r\n");
- clean_up_after_child(interp,fd_list[1]);
- break;
- }
- /*FALLTHRU*/
-
- /* Most systems have read() return 0, allowing */
- /* control to fall thru and into this code. On some */
- /* systems (currently HP and new SGI), read() does */
- /* see eof, and it must be detected earlier. Then */
- /* control jumps directly to this EXP_EOF label. */
- case EXP_EOF:
- action = inp->action_eof;
- attempt_match = FALSE;
- skip = u->size;
- rc = EXP_EOF;
- debuglog("user sent EOF or disappeared\n\n");
- break;
- case EXP_DATA_OLD:
- cc = 0;
- break;
- }
-
- km = 0;
-
- if (attempt_match) {
- rc = in_keymap(u->buffer,u->size,inp->keymap,
- &km,&match_length,&skip);
- } else {
- attempt_match = TRUE;
- }
-
- /* put regexp result in variables */
- if (km && km->re) {
- char name[20], value[20];
- regexp *re = km->re;
- char match_char;/* place to hold char temporarily */
- /* uprooted by a NULL */
-
- for (i=0;i<NSUBEXP;i++) {
- int offset;
-
- if (re->startp[i] == 0) continue;
-
- if (km->indices) {
- /* start index */
- sprintf(name,"%d,start",i);
- offset = re->startp[i]-u->buffer;
- sprintf(value,"%d",offset);
- out(name,value);
-
- /* end index */
- sprintf(name,"%d,end",i);
- sprintf(value,"%d",re->endp[i]-u->buffer-1);
- out(name,value);
- }
-
- /* string itself */
- sprintf(name,"%d,string",i);
- /* temporarily null-terminate in */
- /* middle */
- match_char = *re->endp[i];
- *re->endp[i] = 0;
- out(name,re->startp[i]);
- *re->endp[i] = match_char;
- }
- }
-
- /* dispose of chars that should be skipped */
-
- /* skip is chars not involved in match */
- /* print is with chars involved in match */
-
- if (km && km->writethru) {
- print = skip + match_length;
- } else print = skip;
-
- /* figure out if we should echo any chars */
- if (km && km->echo) {
- int seen; /* either printed or echoed */
-
- /* echo to stdout rather than stdin */
- if (m == 0) m = 1;
-
- /* write is unlikely to fail, since we just read */
- /* from same descriptor */
- seen = u->printed + u->echoed;
- if (skip >= seen) {
- write(m,u->buffer+skip,match_length);
- } else if ((match_length + skip - seen) > 0) {
- write(m,u->buffer+seen,match_length+skip-seen);
- }
- u->echoed = match_length + skip - u->printed;
- }
-
- oldprinted = u->printed;
-
- /* If expect has left characters in buffer, it has */
- /* already echoed them to the screen, thus we must */
- /* prevent them being rewritten. Unfortunately this */
- /* gives the possibility of matching chars that have */
- /* already been output, but we do so since the user */
- /* could have avoided it by flushing the output */
- /* buffers directly. */
- if (print > u->printed) { /* usual case */
- int wc; /* return code from write() */
- for (outp = inp->output;outp;outp=outp->next) {
- struct exp_fd_list *fdp;
- for (fdp = outp->i_list->fd_list;fdp;fdp=fdp->next) {
- int od; /* output descriptor */
-
- /* send to logfile if open */
- /* and user is seeing it */
- if (logfile && real_tty_output(fdp->fd)) {
- fwrite(u->buffer+u->printed,1,
- print - u->printed,logfile);
- }
-
- /* send to each output descriptor */
- od = fdp->fd;
- /* if opened by Tcl, it may use a different */
- /* output descriptor */
- od = (exp_fs[od].tcl_handle?exp_fs[od].tcl_output:od);
-
- wc = write(od,u->buffer+u->printed,
- print - u->printed);
- if (wc <= 0) {
- debuglog("interact: write on spawn id %d failed (%s)\r\n",fdp->fd,Tcl_PosixError(interp));
- clean_up_after_child(interp,fdp->fd);
- action = outp->action_eof;
- change = (action && action->tty_reset);
- if (change && tty_changed)
- exp_tty_set(interp,&tty_old,was_raw,was_echo);
- te = inter_eval(interp,action,m);
-
- if (change && real_tty) tty_changed =
- exp_tty_raw_noecho(interp,&tty_old,&was_raw,&was_echo);
- switch (te) {
- case TCL_BREAK:
- case TCL_CONTINUE:
- finish(te);
- case EXP_TCL_RETURN:
- finish(TCL_RETURN);
- case TCL_RETURN:
- finish(TCL_OK);
- case TCL_OK:
- /* god knows what the user might */
- /* have done to us in the way of */
- /* closed fds, so .... */
- action = 0; /* reset action */
- continue;
- default:
- finish(te);
- }
- }
- }
- }
- u->printed = print;
- }
-
- /* u->printed is now accurate with respect to the buffer */
- /* However, we're about to shift the old data out of the */
- /* buffer. Thus, u->size, printed, and echoed must be */
- /* updated */
-
- /* first update size based on skip information */
- /* then set skip to the total amount skipped */
-
- if (rc == EXP_MATCH) {
- action = &km->action;
-
- skip += match_length;
- u->size -= skip;
-
- if (u->size)
- memcpy(u->buffer, u->buffer + skip, u->size);
- exp_lowmemcpy(u->lower,u->buffer+ skip, u->size);
- } else {
- if (skip) {
- u->size -= skip;
- memcpy(u->buffer, u->buffer + skip, u->size);
- exp_lowmemcpy(u->lower,u->buffer+ skip, u->size);
- }
- }
-
- /* as long as buffer is still around, null terminate it */
- if (rc != EXP_EOF) {
- u->buffer[u->size] = '\0';
- u->lower [u->size] = '\0';
- }
- /* now update printed based on total amount skipped */
-
- u->printed -= skip;
- /* if more skipped than printed (i.e., keymap encountered) */
- /* for printed positive */
- if (u->printed < 0) u->printed = 0;
-
- /* if we are in the middle of a match, force the next event */
- /* to wait for more data to arrive */
- u->force_read = (rc == EXP_CANMATCH);
-
- /* finally reset echoed if necessary */
- if (rc != EXP_CANMATCH) {
- if (skip >= oldprinted + u->echoed) u->echoed = 0;
- }
-
- if (action) {
- change = (action && action->tty_reset);
- if (change && tty_changed)
- exp_tty_set(interp,&tty_old,was_raw,was_echo);
-
- te = inter_eval(interp,action,m);
-
- if (change && real_tty) tty_changed =
- exp_tty_raw_noecho(interp,&tty_old,&was_raw,&was_echo);
- switch (te) {
- case TCL_BREAK:
- case TCL_CONTINUE:
- finish(te);
- case EXP_TCL_RETURN:
- finish(TCL_RETURN);
- case TCL_RETURN:
- finish(TCL_OK);
- case TCL_OK:
- /* god knows what the user might */
- /* have done to us in the way of */
- /* closed fds, so .... */
- action = 0; /* reset action */
- continue;
- default:
- finish(te);
- }
- }
- }
- }
-}
-#endif /* SIMPLE_EVENT */
-
- done:
-#ifdef SIMPLE_EVENT
- /* force child to exit upon eof from master */
- if (pid == 0) {
- exit(SPAWNED_PROCESS_DIED);
- }
-#endif /* SIMPLE_EVENT */
-
- if (need_to_close_master) exp_close(interp,master);
-
- if (tty_changed) exp_tty_set(interp,&tty_old,was_raw,was_echo);
- if (oldargv) ckfree((char *)argv);
- if (fd_list) ckfree((char *)fd_list);
- if (fd_to_input) ckfree((char *)fd_to_input);
- free_input(interp,input_base);
- free_action(action_base);
-
- return(status);
-}
-
-/* version of Tcl_Eval for interact */
-static int
-inter_eval(interp,action,spawn_id)
-Tcl_Interp *interp;
-struct action *action;
-int spawn_id;
-{
- int status;
- char value[20];
-
- /* deprecated */
- if (action->timestamp) {
- time_t current_time;
- time(¤t_time);
- exp_timestamp(interp,¤t_time,INTER_OUT);
- }
- /* deprecated */
-
- if (action->iwrite) {
- sprintf(value,"%d",spawn_id);
- out("spawn_id",value);
- }
-
- if (action->statement) {
- status = Tcl_Eval(interp,action->statement);
- } else {
- exp_nflog("\r\n",1);
- status = exp_interpreter(interp);
- }
-
- return status;
-}
-
-static void
-free_keymap(km)
-struct keymap *km;
-{
- if (km == 0) return;
- free_keymap(km->next);
-
- ckfree((char *)km);
-}
-
-static void
-free_action(a)
-struct action *a;
-{
- struct action *next;
-
- while (a) {
- next = a->next;
- ckfree((char *)a);
- a = next;
- }
-}
-
-static void
-free_input(interp,i)
-Tcl_Interp *interp;
-struct input *i;
-{
- if (i == 0) return;
- free_input(interp,i->next);
-
- exp_free_i(interp,i->i_list,inter_updateproc);
- free_output(interp,i->output);
- free_keymap(i->keymap);
- ckfree((char *)i);
-}
-
-static struct action *
-new_action(base)
-struct action **base;
-{
- struct action *o = new(struct action);
-
- /* stick new action into beginning of list of all actions */
- o->next = *base;
- *base = o;
-
- return o;
-}
-
-static void
-free_output(interp,o)
-Tcl_Interp *interp;
-struct output *o;
-{
- if (o == 0) return;
- free_output(interp,o->next);
- exp_free_i(interp,o->i_list,inter_updateproc);
-
- ckfree((char *)o);
-}
-
-static struct exp_cmd_data cmd_data[] = {
-{"interact", exp_proc(Exp_InteractCmd), 0, 0},
-{0}};
-
-void
-exp_init_interact_cmds(interp)
-Tcl_Interp *interp;
-{
- exp_create_commands(interp,cmd_data);
-}
+++ /dev/null
-/* exp_log.c - logging routines and other things common to both Expect
- program and library. Note that this file must NOT have any
- references to Tcl except for including tclInt.h
-*/
-
-#include "expect_cf.h"
-#include <stdio.h>
-/*#include <varargs.h> tclInt.h drags in varargs.h. Since Pyramid */
-/* objects to including varargs.h twice, just */
-/* omit this one. */
-#include "tclInt.h"
-#include "expect_comm.h"
-#include "exp_int.h"
-#include "exp_rename.h"
-#include "exp_log.h"
-
-int loguser = TRUE; /* if TRUE, expect/spawn may write to stdout */
-int logfile_all = FALSE; /* if TRUE, write log of all interactions */
- /* despite value of loguser. */
-FILE *logfile = 0;
-FILE *debugfile = 0;
-int exp_is_debugging = FALSE;
-
-/* Following this are several functions that log the conversation. */
-/* Most of them have multiple calls to printf-style functions. */
-/* At first glance, it seems stupid to reformat the same arguments again */
-/* but we have no way of telling how long the formatted output will be */
-/* and hence cannot allocate a buffer to do so. */
-/* Fortunately, in production code, most of the duplicate reformatting */
-/* will be skipped, since it is due to handling errors and debugging. */
-
-/* send to log if open */
-/* send to stderr if debugging enabled */
-/* use this for logging everything but the parent/child conversation */
-/* (this turns out to be almost nothing) */
-/* uppercase L differentiates if from math function of same name */
-#define LOGUSER (loguser || force_stdout)
-/*VARARGS*/
-void
-exp_log TCL_VARARGS_DEF(int,arg1)
-/*exp_log(va_alist)*/
-/*va_dcl*/
-{
- int force_stdout;
- char *fmt;
- va_list args;
-
- force_stdout = TCL_VARARGS_START(int,arg1,args);
- /*va_start(args);*/
- /*force_stdout = va_arg(args,int);*/
- fmt = va_arg(args,char *);
- if (debugfile) vfprintf(debugfile,fmt,args);
- if (logfile_all || (LOGUSER && logfile)) vfprintf(logfile,fmt,args);
- if (LOGUSER) vfprintf(stdout,fmt,args);
- va_end(args);
-}
-
-/* just like log but does no formatting */
-/* send to log if open */
-/* use this function for logging the parent/child conversation */
-void
-exp_nflog(buf,force_stdout)
-char *buf;
-int force_stdout; /* override value of loguser */
-{
- int length = strlen(buf);
-
- if (debugfile) fwrite(buf,1,length,debugfile);
- if (logfile_all || (LOGUSER && logfile)) fwrite(buf,1,length,logfile);
- if (LOGUSER) fwrite(buf,1,length,stdout);
-#if 0
- if (logfile_all || (LOGUSER && logfile)) {
- int newlength = exp_copy_out(length);
- fwrite(exp_out_buffer,1,newlength,logfile);
- }
-#endif
-}
-#undef LOGUSER
-
-/* send to log if open and debugging enabled */
-/* send to stderr if debugging enabled */
-/* use this function for recording unusual things in the log */
-/*VARARGS*/
-void
-debuglog TCL_VARARGS_DEF(char *,arg1)
-/*debuglog(va_alist)*/
-/*va_dcl*/
-{
- char *fmt;
- va_list args;
-
- fmt = TCL_VARARGS_START(char *,arg1,args);
- /*va_start(args);*/
- /*fmt = va_arg(args,char *);*/
- if (debugfile) vfprintf(debugfile,fmt,args);
- if (is_debugging) {
- vfprintf(stderr,fmt,args);
- if (logfile) vfprintf(logfile,fmt,args);
- }
-
- va_end(args);
-}
-
-/* send to log if open */
-/* send to stderr */
-/* use this function for error conditions */
-/*VARARGS*/
-void
-exp_errorlog TCL_VARARGS_DEF(char *,arg1)
-/*exp_errorlog(va_alist)*/
-/*va_dcl*/
-{
- char *fmt;
- va_list args;
-
- fmt = TCL_VARARGS_START(char *,arg1,args);
- /*va_start(args);*/
- /*fmt = va_arg(args,char *);*/
- vfprintf(stderr,fmt,args);
- if (debugfile) vfprintf(debugfile,fmt,args);
- if (logfile) vfprintf(logfile,fmt,args);
- va_end(args);
-}
-
-/* just like errorlog but does no formatting */
-/* send to log if open */
-/* use this function for logging the parent/child conversation */
-/*ARGSUSED*/
-void
-exp_nferrorlog(buf,force_stdout)
-char *buf;
-int force_stdout; /* not used, only declared here for compat with */
- /* exp_nflog() */
-{
- int length = strlen(buf);
- fwrite(buf,1,length,stderr);
- if (debugfile) fwrite(buf,1,length,debugfile);
- if (logfile) fwrite(buf,1,length,logfile);
-}
-
-#if 0
-static int out_buffer_size;
-static char *outp_last;
-static char *out_buffer;
-static char *outp; /* pointer into out_buffer - static in order */
- /* to update whenever out_buffer is enlarged */
-
-
-void
-exp_init_log()
-{
- out_buffer = ckalloc(BUFSIZ);
- out_buffer_size = BUFSIZ;
- outp_last = out_buffer + BUFSIZ - 1;
-}
-
-char *
-enlarge_out_buffer()
-{
- int offset = outp - out_buffer;
-
- int new_out_buffer_size = out_buffer_size = BUFSIZ;
- realloc(out_buffer,new_out_buffer_size);
-
- out_buffer_size = new_out_buffer_size;
- outp = out_buffer + offset;
-
- outp_last = out_buffer + out_buffer_size - 1;
-
- return(out_buffer);
-}
-
-/* like sprintf, but uses a static buffer enlarged as necessary */
-/* currently supported are %s, %d, and %#d where # is a single-digit */
-void
-exp_sprintf TCL_VARARGS_DEF(char *,arg1)
-/* exp_sprintf(va_alist)*/
-/*va_dcl*/
-{
- char *fmt;
- va_list args;
- char int_literal[20]; /* big enough for an int literal? */
- char *int_litp; /* pointer into int_literal */
- char *width;
- char *string_arg;
- int int_arg;
- char *int_fmt;
-
- fmt = TCL_VARARGS_START(char *,arg1,args);
- /*va_start(args);*/
- /*fmt = va_arg(args,char *);*/
-
- while (*fmt != '\0') {
- if (*fmt != '%') {
- *outp++ = *fmt++;
- continue;
- }
-
- /* currently, only single-digit widths are used */
- if (isdigit(*fmt)) {
- width = fmt++;
- } else width = 0;
-
- switch (*fmt) {
- case 's': /* interpolate string */
- string_arg = va_arg(args,char *);
-
- while (*string_arg) {
- if (outp == outp_last) {
- if (enlarge_out_buffer() == 0) {
- /* FAIL */
- return;
- }
- }
- *outp++ = *string_arg++;
- }
- fmt++;
- break;
- case 'd': /* interpolate int */
- int_arg = va_arg(args,int);
-
- if (width) int_fmt = width;
- else int_fmt = fmt;
-
- sprintf(int_literal,int_fmt,int_arg);
-
- int_litp = int_literal;
- for (int_litp;*int_litp;) {
- if (enlarge_out_buffer() == 0) return;
- *outp++ = *int_litp++;
- }
- fmt++;
- break;
- default: /* anything else is literal */
- if (enlarge_out_buffer() == 0) return; /* FAIL */
- *outp++ = *fmt++;
- break;
- }
- }
-}
-
-/* copy input string to exp_output, replacing \r\n sequences by \n */
-/* return length of new string */
-int
-exp_copy_out(char *s)
-{
- outp = out_buffer;
- int count = 0;
-
- while (*s) {
- if ((*s == '\r') && (*(s+1) =='\n')) s++;
- if (enlarge_out_buffer() == 0) {
- /* FAIL */
- break;
- }
- *outp = *s;
- count++;
- }
- return count;
-}
-#endif
+++ /dev/null
-/* exp_log.h */
-
-#include "exp_printify.h"
-
-/* special version of log for non-null-terminated strings which */
-/* never need printf-style formatting. */
-#define logn(buf,length) { \
- if (logfile) fwrite(buf,1,length,logfile); \
- if (debugfile) fwrite(buf,1,length,debugfile); \
- }
-
-#define dprintify(x) ((is_debugging || debugfile)?exp_printify(x):0)
-/* in circumstances where "debuglog(printify(...))" is written, call */
-/* dprintify instead. This will avoid doing any formatting that would */
-/* occur before debuglog got control and decided not to do anything */
-/* because (is_debugging || debugfile) was false. */
-
-extern void exp_errorlog _ANSI_ARGS_(TCL_VARARGS(char *,fmt));
-extern void exp_log _ANSI_ARGS_(TCL_VARARGS(int,force_stdout));
-extern void exp_debuglog _ANSI_ARGS_(TCL_VARARGS(char *,fmt));
-extern void exp_nflog _ANSI_ARGS_((char *buf, int force_stdout));
-extern void exp_nferrorlog _ANSI_ARGS_((char *buf, int force_stdout));
-
-extern FILE *debugfile;
-extern FILE *logfile;
-extern int logfile_all;
-
-extern int is_debugging; /* useful to know for avoid debug calls */
+++ /dev/null
-/* main.c - main() and some logging routines for expect
-
-Written by: Don Libes, NIST, 2/6/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.
-*/
-
-#include "expect_cf.h"
-#include <stdio.h>
-#include "tcl.h"
-#ifdef USE_ITCL
-#include "itcl.h"
-#endif
-#include "expect_tcl.h"
-
-int
-main(argc, argv)
-int argc;
-char *argv[];
-{
- int rc = 0;
- Tcl_Interp *interp = Tcl_CreateInterp();
-
- /* need this for [info nameofexecutable] to work */
- Tcl_FindExecutable (argv[0]);
-
- if (Tcl_Init(interp) == TCL_ERROR) {
- fprintf(stderr,"Tcl_Init failed: %s\n",interp->result);
- exit(1);
- }
- if (Expect_Init(interp) == TCL_ERROR) {
- fprintf(stderr,"Expect_Init failed: %s\n",interp->result);
- exit(1);
- }
-
-#ifdef USE_ITCL
- if (Itcl_Init(interp) == TCL_ERROR) {
- fprintf(stderr,"Itcl_Init failed: %s\n",interp->result);
- exit(1);
- }
-#endif
- exp_parse_argv(interp,argc,argv);
-
- /* become interactive if requested or "nothing to do" */
- if (exp_interactive)
- (void) exp_interpreter(interp);
- else if (exp_cmdfile)
- rc = exp_interpret_cmdfile(interp,exp_cmdfile);
- else if (exp_cmdfilename)
- rc = exp_interpret_cmdfilename(interp,exp_cmdfilename);
-
- /* assert(exp_cmdlinecmds != 0) */
-
- exp_exit(interp,rc);
- /*NOTREACHED*/
- return 0; /* Needed only to prevent compiler warning. */
-}
-
+++ /dev/null
-/* exp_main_sub.c - miscellaneous subroutines for Expect or Tk main() */
-
-#include "expect_cf.h"
-#include <stdio.h>
-#include <errno.h>
-#ifdef HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#include <sys/types.h>
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-#include "tcl.h"
-#include "tclInt.h"
-#include "exp_rename.h"
-#include "exp_prog.h"
-#include "exp_command.h"
-#include "exp_tty_in.h"
-#include "exp_log.h"
-#include "exp_event.h"
-#ifdef TCL_DEBUGGER
-#include "Dbg.h"
-#endif
-
-#ifdef __CENTERLINE__
-#undef EXP_VERSION
-#define EXP_VERSION "5.0.3" /* I give up! */
- /* It is not necessary that number */
- /* be accurate. It is just here to */
- /* pacify Centerline which doesn't */
- /* seem to be able to get it from */
- /* the Makefile. */
-#undef SCRIPTDIR
-#define SCRIPTDIR "example/"
-#undef EXECSCRIPTDIR
-#define EXECSCRIPTDIR "example/"
-#endif
-char exp_version[] = EXP_VERSION;
-#define NEED_TCL_MAJOR 7
-#define NEED_TCL_MINOR 5
-
-char *exp_argv0 = "this program"; /* default program name */
-void (*exp_app_exit)() = 0;
-void (*exp_event_exit)() = 0;
-FILE *exp_cmdfile = 0;
-char *exp_cmdfilename = 0;
-int exp_cmdlinecmds = FALSE;
-int exp_interactive = FALSE;
-int exp_buffer_command_input = FALSE;/* read in entire cmdfile at once */
-int exp_fgets();
-
-Tcl_Interp *exp_interp; /* for use by signal handlers who can't figure out */
- /* the interpreter directly */
-int exp_tcl_debugger_available = FALSE;
-
-int exp_getpid;
-
-static void
-usage(interp)
-Tcl_Interp *interp;
-{
- errorlog("usage: expect [-div] [-c cmds] [[-f] cmdfile] [args]\r\n");
- exp_exit(interp,1);
-}
-
-/*ARGSUSED*/
-void
-exp_exit(interp,status)
-Tcl_Interp *interp; /* historic */
-int status;
-{
- Tcl_Exit(status);
-}
-
-/* this clumsiness because pty routines don't know Tcl definitions */
-static
-void
-exp_pty_exit_for_tcl(clientData)
-ClientData clientData;
-{
- exp_pty_exit();
-}
-
-static
-void
-exp_init_pty_exit()
-{
- Tcl_CreateExitHandler(exp_pty_exit_for_tcl,(ClientData)0);
-}
-
-/* This can be called twice or even recursively - it's safe. */
-void
-exp_exit_handlers(clientData)
-ClientData clientData;
-{
- extern int exp_forked;
-
- Tcl_Interp *interp = (Tcl_Interp *)clientData;
-
- /* use following checks to prevent recursion in exit handlers */
- /* if this code ever supports multiple interps, these should */
- /* become interp-specific */
-
- static int did_app_exit = FALSE;
- static int did_expect_exit = FALSE;
-
- /* don't think this code is relevant any longer, but not positive! */
- if (!interp) {
- /* if no interp handy (i.e., called from interrupt handler) */
- /* use last one created - it's a hack but we're exiting */
- /* ungracefully to begin with */
- interp = exp_interp;
- }
-
- if (!did_expect_exit) {
- did_expect_exit = TRUE;
- /* called user-defined exit routine if one exists */
- if (exp_onexit_action) {
- int result = Tcl_GlobalEval(interp,exp_onexit_action);
- if (result != TCL_OK) Tcl_BackgroundError(interp);
- }
- } else {
- debuglog("onexit handler called recursively - forcing exit\r\n");
- }
-
- if (exp_app_exit) {
- if (!did_app_exit) {
- did_app_exit = TRUE;
- (*exp_app_exit)(interp);
- } else {
- debuglog("application exit handler called recursively - forcing exit\r\n");
- }
- }
-
- if (!exp_disconnected
- && !exp_forked
- && (exp_dev_tty != -1)
- && isatty(exp_dev_tty)
- && exp_ioctled_devtty) {
- exp_tty_set(interp,&exp_tty_original,exp_dev_tty,0);
- }
- /* all other files either don't need to be flushed or will be
- implicitly closed at exit. Spawned processes are free to continue
- running, however most will shutdown after seeing EOF on stdin.
- Some systems also deliver SIGHUP and other sigs to idle processes
- which will blow them away if not prepared.
- */
-
- exp_close_all(interp);
-}
-
-static int
-history_nextid(interp)
-Tcl_Interp *interp;
-{
- Interp *iPtr = (Interp *)interp;
-
-#if TCL_MAJOR_VERSION < 8
- return iPtr->curEventNum+1;
-#else
- /* unncessarily tricky coding - if nextid isn't defined,
- maintain our own static version */
-
- static int nextid = 0;
- char *nextidstr = Tcl_GetVar2(interp,"tcl::history","nextid",0);
- if (nextidstr) {
- /* intentionally ignore failure */
- (void) sscanf(nextidstr,"%d",&nextid);
- }
- return ++nextid;
-#endif
-}
-
-/* this stupidity because Tcl needs commands in writable space */
-static char prompt1[] = "prompt1";
-static char prompt2[] = "prompt2";
-
-static char *prompt2_default = "+> ";
-static char prompt1_default[] = "expect%d.%d> ";
-
-/*ARGSUSED*/
-int
-Exp_Prompt1Cmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- Interp *iPtr = (Interp *)interp;
-
- sprintf(interp->result,prompt1_default,
- iPtr->numLevels,history_nextid(interp));
- return(TCL_OK);
-}
-
-/*ARGSUSED*/
-int
-Exp_Prompt2Cmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- strcpy(interp->result,prompt2_default);
- return(TCL_OK);
-}
-
-/*ARGSUSED*/
-static int
-ignore_procs(interp,s)
-Tcl_Interp *interp;
-char *s; /* function name */
-{
- return ((s[0] == 'p') &&
- (s[1] == 'r') &&
- (s[2] == 'o') &&
- (s[3] == 'm') &&
- (s[4] == 'p') &&
- (s[5] == 't') &&
- ((s[6] == '1') ||
- (s[6] == '2')) &&
- (s[7] == '\0')
- );
-}
-
-/* handle an error from Tcl_Eval or Tcl_EvalFile */
-static void
-handle_eval_error(interp,check_for_nostack)
-Tcl_Interp *interp;
-int check_for_nostack;
-{
- char *msg;
-
- /* if errorInfo has something, print it */
- /* else use what's in interp->result */
-
- msg = Tcl_GetVar(interp,"errorInfo",TCL_GLOBAL_ONLY);
- if (!msg) msg = interp->result;
- else if (check_for_nostack) {
- /* suppress errorInfo if generated via */
- /* error ... -nostack */
- if (0 == strncmp("-nostack",msg,8)) return;
-
- /*
- * This shouldn't be necessary, but previous test fails
- * because of recent change John made - see eval_trap_action()
- * in exp_trap.c for more info
- */
- if (exp_nostack_dump) {
- exp_nostack_dump = FALSE;
- return;
- }
- }
-
- /* no \n at end, since ccmd will already have one. */
- /* Actually, this is not true if command is last in */
- /* file and has no newline after it, oh well */
- errorlog("%s\r\n",exp_cook(msg,(int *)0));
-}
-
-/* user has pressed escape char from interact or somehow requested expect.
-If a user-supplied command returns:
-
-TCL_ERROR, assume user is experimenting and reprompt
-TCL_OK, ditto
-TCL_RETURN, return TCL_OK (assume user just wants to escape() to return)
-EXP_TCL_RETURN, return TCL_RETURN
-anything else return it
-*/
-int
-exp_interpreter(interp)
-Tcl_Interp *interp;
-{
- int rc;
- char *ccmd; /* pointer to complete command */
- char line[BUFSIZ+1]; /* space for partial command */
- int newcmd = TRUE;
- Tcl_DString dstring;
- Interp *iPtr = (Interp *)interp;
- int tty_changed = FALSE;
-
- exp_tty tty_old;
- int was_raw, was_echo;
-
- int dummy;
- Tcl_Channel outChannel;
- int fd = fileno(stdin);
-
- expect_key++;
-
- Tcl_DStringInit(&dstring);
-
- newcmd = TRUE;
- while (TRUE) {
- outChannel = Tcl_GetStdChannel(TCL_STDOUT);
- if (outChannel) {
- Tcl_Flush(outChannel);
- }
-
- /* force terminal state */
- tty_changed = exp_tty_cooked_echo(interp,&tty_old,&was_raw,&was_echo);
-
- if (newcmd) {
- rc = Tcl_Eval(interp,prompt1);
- if (rc == TCL_OK) exp_log(1,"%s",interp->result);
- else exp_log(1,prompt1_default,iPtr->numLevels,
- history_nextid(interp));
- } else {
- rc = Tcl_Eval(interp,prompt2);
- if (rc == TCL_OK) exp_log(1,"%s",interp->result);
- else exp_log(1,prompt2_default,1);
- }
-
- exp_fs[fd].force_read = 1;
- rc = exp_get_next_event(interp,&fd,1,&dummy,EXP_TIME_INFINITY,
- exp_fs[fd].key);
- /* check for rc == EXP_TCLERROR? */
-
- if (rc != EXP_EOF) {
- rc = read(0,line,BUFSIZ);
-#ifdef SIMPLE_EVENT
- if (rc == -1 && errno == EINTR) {
- if (Tcl_AsyncReady()) {
- (void) Tcl_AsyncInvoke(interp,TCL_OK);
- }
- continue;
- }
-#endif
- if (rc <= 0) {
- if (!newcmd) line[0] = 0;
- else rc = EXP_EOF;
- } else line[rc] = '\0';
- }
-
- if (rc == EXP_EOF) exp_exit(interp,0);
-
- if (debugfile) fwrite(line,1,strlen(line),debugfile);
- /* intentionally always write to logfile */
- if (logfile) fwrite(line,1,strlen(line),logfile);
- /* no need to write to stdout, since they will see */
- /* it just from it having been echoed as they are */
- /* typing it */
-
- ccmd = Tcl_DStringAppend(&dstring,line,rc);
- if (!Tcl_CommandComplete(ccmd)) {
- newcmd = FALSE;
- continue; /* continue collecting command */
- }
- newcmd = TRUE;
-
- if (tty_changed) exp_tty_set(interp,&tty_old,was_raw,was_echo);
-
- rc = Tcl_RecordAndEval(interp,ccmd,0);
- Tcl_DStringFree(&dstring);
- switch (rc) {
- case TCL_OK:
- if (*interp->result != 0)
- exp_log(1,"%s\r\n",exp_cook(interp->result,(int *)0));
- continue;
- case TCL_ERROR:
- handle_eval_error(interp,1);
- /* since user is typing by hand, we expect lots */
- /* of errors, and want to give another chance */
- continue;
-#define finish(x) {rc = x; goto done;}
- case TCL_BREAK:
- case TCL_CONTINUE:
- finish(rc);
- case EXP_TCL_RETURN:
- finish(TCL_RETURN);
- case TCL_RETURN:
- finish(TCL_OK);
- default:
- /* note that ccmd has trailing newline */
- errorlog("error %d: %s\r\n",rc,ccmd);
- continue;
- }
- }
- /* cannot fall thru here, must jump to label */
- done:
- if (tty_changed) exp_tty_set(interp,&tty_old,was_raw,was_echo);
-
- Tcl_DStringFree(&dstring);
-
- return(rc);
-}
-
-/*ARGSUSED*/
-int
-Exp_ExpVersionCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- int emajor, umajor;
- char *user_version; /* user-supplied version string */
-
- if (argc == 1) {
- Tcl_SetResult(interp,exp_version,TCL_STATIC);
- return(TCL_OK);
- }
- if (argc > 3) {
- exp_error(interp,"usage: expect_version [[-exit] version]");
- return(TCL_ERROR);
- }
-
- user_version = argv[argc==2?1:2];
- emajor = atoi(exp_version);
- umajor = atoi(user_version);
-
- /* first check major numbers */
- if (emajor == umajor) {
- int u, e;
-
- /* now check minor numbers */
- char *dot = strchr(user_version,'.');
- if (!dot) {
- exp_error(interp,"version number must include a minor version number");
- return TCL_ERROR;
- }
-
- u = atoi(dot+1);
- dot = strchr(exp_version,'.');
- e = atoi(dot+1);
- if (e >= u) return(TCL_OK);
- }
-
- if (argc == 2) {
- exp_error(interp,"%s requires Expect version %s (but using %s)",
- exp_argv0,user_version,exp_version);
- return(TCL_ERROR);
- }
- errorlog("%s: requires Expect version %s (but using %s)\r\n",
- exp_argv0,user_version,exp_version);
- exp_exit(interp,1);
- /*NOTREACHED*/
-}
-
-static char init_auto_path[] = "lappend auto_path $exp_library $exp_exec_library";
-
-int
-Expect_Init(interp)
-Tcl_Interp *interp;
-{
- static int first_time = TRUE;
-
- if (first_time) {
- int tcl_major = atoi(TCL_VERSION);
- char *dot = strchr(TCL_VERSION,'.');
- int tcl_minor = atoi(dot+1);
-
- if (tcl_major < NEED_TCL_MAJOR ||
- (tcl_major == NEED_TCL_MAJOR && tcl_minor < NEED_TCL_MINOR)) {
- sprintf(interp->result,
- "%s compiled with Tcl %d.%d but needs at least Tcl %d.%d\n",
- exp_argv0,tcl_major,tcl_minor,
- NEED_TCL_MAJOR,NEED_TCL_MINOR);
- return TCL_ERROR;
- }
-
- if (Tcl_PkgRequire(interp, "Tcl", TCL_VERSION, 0) == NULL) {
- return TCL_ERROR;
- }
- if (Tcl_PkgProvide(interp, "Expect", EXP_VERSION) != TCL_OK) {
- return TCL_ERROR;
- }
-
- exp_getpid = getpid();
- exp_init_pty();
- exp_init_pty_exit();
- exp_init_tty(); /* do this only now that we have looked at */
- /* original tty state */
- exp_init_stdio();
- exp_init_sig();
- exp_init_event();
- exp_init_trap();
- exp_init_unit_random();
- exp_init_spawn_ids();
-
- Tcl_CreateExitHandler(exp_exit_handlers,(ClientData)interp);
-
- first_time = FALSE;
- }
-
- /* save last known interp for emergencies */
- exp_interp = interp;
-
- /* initialize commands */
- exp_init_most_cmds(interp); /* add misc cmds to interpreter */
- exp_init_expect_cmds(interp); /* add expect cmds to interpreter */
- exp_init_main_cmds(interp); /* add main cmds to interpreter */
- exp_init_trap_cmds(interp); /* add trap cmds to interpreter */
- exp_init_tty_cmds(interp); /* add tty cmds to interpreter */
- exp_init_interact_cmds(interp); /* add interact cmds to interpreter */
-
- exp_init_spawn_id_vars(interp);
-
- Tcl_SetVar(interp,"expect_library",SCRIPTDIR,0);/* deprecated */
- Tcl_SetVar(interp,"exp_library",SCRIPTDIR,0);
- Tcl_SetVar(interp,"exp_exec_library",EXECSCRIPTDIR,0);
- Tcl_Eval(interp,init_auto_path);
- Tcl_ResetResult(interp);
-
-#ifdef TCL_DEBUGGER
- Dbg_IgnoreFuncs(interp,ignore_procs);
-#endif
-
- return TCL_OK;
-}
-
-static char sigexit_init_default[] = "trap exit {SIGINT SIGTERM}";
-static char debug_init_default[] = "trap {exp_debug 1} SIGINT";
-
-void
-exp_parse_argv(interp,argc,argv)
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- char argc_rep[10]; /* enough space for storing literal rep of argc */
-
- int sys_rc = TRUE; /* read system rc file */
- int my_rc = TRUE; /* read personal rc file */
-
- int c;
- int rc;
-
- extern int optind;
- extern char *optarg;
- char *args; /* ptr to string-rep of all args */
- char *debug_init;
-
- exp_argv0 = argv[0];
-
-#ifdef TCL_DEBUGGER
- Dbg_ArgcArgv(argc,argv,1);
-#endif
-
- /* initially, we must assume we are not interactive */
- /* this prevents interactive weirdness courtesy of unknown via -c */
- /* after handling args, we can change our mind */
- Tcl_SetVar(interp, "tcl_interactive", "0", TCL_GLOBAL_ONLY);
-
- Tcl_Eval(interp,sigexit_init_default);
-
- while ((c = getopt(argc, argv, "b:c:dD:f:inN-v")) != EOF) {
- switch(c) {
- case '-':
- /* getopt already handles -- internally, however */
- /* this allows us to abort getopt when dash is at */
- /* the end of another option which is required */
- /* in order to allow things like -n- on #! line */
- goto abort_getopt;
- case 'c': /* command */
- exp_cmdlinecmds = TRUE;
- rc = Tcl_Eval(interp,optarg);
- if (rc != TCL_OK) {
- errorlog("%s\r\n",exp_cook(Tcl_GetVar(interp,"errorInfo",TCL_GLOBAL_ONLY),(int *)0));
- }
- break;
- case 'd': exp_is_debugging = TRUE;
- debuglog("expect version %s\r\n",exp_version);
- break;
-#ifdef TCL_DEBUGGER
- case 'D':
- exp_tcl_debugger_available = TRUE;
- if (Tcl_GetInt(interp,optarg,&rc) != TCL_OK) {
- errorlog("%s: -D argument must be 0 or 1\r\n",
- exp_argv0);
- exp_exit(interp,1);
- }
-
- /* set up trap handler before Dbg_On so user does */
- /* not have to see it at first debugger prompt */
- if (0 == (debug_init = getenv("EXPECT_DEBUG_INIT"))) {
- debug_init = debug_init_default;
- }
- Tcl_Eval(interp,debug_init);
- if (rc == 1) Dbg_On(interp,0);
- break;
-#endif
- case 'f': /* name of cmd file */
- exp_cmdfilename = optarg;
- break;
- case 'b': /* read cmdfile one part at a time */
- exp_cmdfilename = optarg;
- exp_buffer_command_input = TRUE;
- break;
- case 'i': /* interactive */
- exp_interactive = TRUE;
- break;
- case 'n': /* don't read personal rc file */
- my_rc = FALSE;
- break;
- case 'N': /* don't read system-wide rc file */
- sys_rc = FALSE;
- break;
- case 'v':
- printf("expect version %s\n", exp_version);
- exp_exit (interp, 0);
- break;
- default: usage(interp);
- }
- }
-
- abort_getopt:
-
- for (c = 0;c<argc;c++) {
- debuglog("argv[%d] = %s ",c,argv[c]);
- }
- debuglog("\r\n");
-
- /* if user hasn't explicitly requested we be interactive */
- /* look for a file or some other source of commands */
- if (!exp_interactive) {
- /* get cmd file name, if we haven't got it already */
- if (!exp_cmdfilename && (optind < argc)) {
- exp_cmdfilename = argv[optind];
- optind++;
- }
-
- if (exp_cmdfilename) {
- if (streq(exp_cmdfilename,"-")) {
- exp_cmdfile = stdin;
- exp_cmdfilename = 0;
- } else if (exp_buffer_command_input) {
- errno = 0;
- exp_cmdfile = fopen(exp_cmdfilename,"r");
- if (exp_cmdfile) {
- exp_cmdfilename = 0;
- exp_close_on_exec(fileno(exp_cmdfile));
- } else {
- char *msg;
-
- if (errno == 0) {
- msg = "could not read - odd file name?";
- } else {
- msg = Tcl_ErrnoMsg(errno);
- }
- errorlog("%s: %s\r\n",exp_cmdfilename,msg);
- exp_exit(interp,1);
- }
- }
- } else if (!exp_cmdlinecmds) {
- if (isatty(0)) {
- /* no other source of commands, force interactive */
- exp_interactive = TRUE;
- } else {
- /* read cmds from redirected stdin */
- exp_cmdfile = stdin;
- }
- }
- }
-
- if (exp_interactive) {
- Tcl_SetVar(interp, "tcl_interactive","1",TCL_GLOBAL_ONLY);
- }
-
- /* collect remaining args and make into argc, argv0, and argv */
- sprintf(argc_rep,"%d",argc-optind);
- Tcl_SetVar(interp,"argc",argc_rep,0);
- debuglog("set argc %s\r\n",argc_rep);
-
- if (exp_cmdfilename) {
- Tcl_SetVar(interp,"argv0",exp_cmdfilename,0);
- debuglog("set argv0 \"%s\"\r\n",exp_cmdfilename);
- } else {
- Tcl_SetVar(interp,"argv0",exp_argv0,0);
- debuglog("set argv0 \"%s\"\r\n",exp_argv0);
- }
-
- args = Tcl_Merge(argc-optind,argv+optind);
- debuglog("set argv \"%s\"\r\n",args);
- Tcl_SetVar(interp,"argv",args,0);
- ckfree(args);
-
- exp_interpret_rcfiles(interp,my_rc,sys_rc);
-}
-
-/* read rc files */
-void
-exp_interpret_rcfiles(interp,my_rc,sys_rc)
-Tcl_Interp *interp;
-int my_rc;
-int sys_rc;
-{
- int rc;
-
- if (sys_rc) {
- char file[200];
- int fd;
-
- sprintf(file,"%s/expect.rc",SCRIPTDIR);
- if (-1 != (fd = open(file,0))) {
- if (TCL_ERROR == (rc = Tcl_EvalFile(interp,file))) {
- errorlog("error executing system initialization file: %s\r\n",file);
- if (rc != TCL_ERROR)
- errorlog("Tcl_Eval = %d\r\n",rc);
- if (*interp->result != 0)
- errorlog("%s\r\n",interp->result);
- exp_exit(interp,1);
- }
- close(fd);
- }
- }
- if (my_rc) {
- char file[200];
- char *home;
- int fd;
- char *getenv();
-
- if ((NULL != (home = getenv("DOTDIR"))) ||
- (NULL != (home = getenv("HOME")))) {
- sprintf(file,"%s/.expect.rc",home);
- if (-1 != (fd = open(file,0))) {
- if (TCL_ERROR == (rc = Tcl_EvalFile(interp,file))) {
- errorlog("error executing file: %s\r\n",file);
- if (rc != TCL_ERROR)
- errorlog("Tcl_Eval = %d\r\n",rc);
- if (*interp->result != 0)
- errorlog("%s\r\n",interp->result);
- exp_exit(interp,1);
- }
- close(fd);
- }
- }
- }
-}
-
-int
-exp_interpret_cmdfilename(interp,filename)
-Tcl_Interp *interp;
-char *filename;
-{
- int rc;
-
- debuglog("executing commands from command file %s\r\n",filename);
-
- Tcl_ResetResult(interp);
- if (TCL_OK != (rc = Tcl_EvalFile(interp,filename))) {
- /* EvalFile doesn't bother to copy error to errorInfo */
- /* so force it */
- Tcl_AddErrorInfo(interp, "");
- handle_eval_error(interp,0);
- }
- return rc;
-}
-
-int
-exp_interpret_cmdfile(interp,fp)
-Tcl_Interp *interp;
-FILE *fp;
-{
- int rc = 0;
- int newcmd;
- int eof;
-
- Tcl_DString dstring;
- Tcl_DStringInit(&dstring);
-
- debuglog("executing commands from command file\r\n");
-
- newcmd = TRUE;
- eof = FALSE;
- while (1) {
- char line[BUFSIZ];/* buffer for partial Tcl command */
- char *ccmd; /* pointer to complete Tcl command */
-
- if (fgets(line,BUFSIZ,fp) == NULL) {
- if (newcmd) break;
- eof = TRUE;
- }
- ccmd = Tcl_DStringAppend(&dstring,line,-1);
- if (!Tcl_CommandComplete(ccmd) && !eof) {
- newcmd = FALSE;
- continue; /* continue collecting command */
- }
- newcmd = TRUE;
-
- rc = Tcl_Eval(interp,ccmd);
- Tcl_DStringFree(&dstring);
- if (rc != TCL_OK) {
- handle_eval_error(interp,0);
- break;
- }
- if (eof) break;
- }
- Tcl_DStringFree(&dstring);
- return rc;
-}
-
-#ifdef SHARE_CMD_BUFFER
-/* fgets that shared input buffer with expect_user */
-int
-exp_fgets(interp,buf,max)
-Tcl_Interp *interp;
-char *buf;
-int max;
-{
- char *nl; /* position of newline which signifies end of line */
- int write_count;/* length of first line of incoming data */
-
- int m = fileno(stdin);
- struct exp_f *f;
- int cc;
-
- int dummy;
-
- /* avoid returning no data, just because someone else read it in by */
- /* passing most recent key */
- cc = exp_get_next_event(interp,&m,1,&dummy,EXP_TIME_INFINITY,exp_fs[m].key);
-
- if (cc == EXP_DATA_NEW) {
- /* try to read it */
-
- cc = exp_i_read(m,EXP_TIME_INFINITY);
-
- /* the meaning of 0 from i_read means eof. Muck with it a */
- /* little, so that from now on it means "no new data arrived */
- /* but it should be looked at again anyway". */
- if (cc == 0) {
- cc = EXP_EOF;
- } else if (cc > 0) {
- f = exp_fs + m;
- f->buffer[f->size += cc] = '\0';
- }
- } else if (cc == EXP_DATA_OLD) {
- f = exp_fs + m;
- cc = 0;
- }
-
- /* EOF and TIMEOUT return here */
- /* In such cases, there is no need to update screen since, if there */
- /* was prior data read, it would have been sent to the screen when */
- /* it was read. */
- if (cc < 0) return (cc);
-
- /* copy up to end of first line */
-
- /* calculate end of first line */
- nl = strchr(f->buffer,'\n');
- if (nl) write_count = 1+nl-f->buffer;
- else write_count = f->size;
-
- /* make sure line fits in buffer area */
- if (write_count > max) write_count = max;
-
- /* copy it */
- memcpy(buf,f->buffer,write_count);
- buf[write_count] = '\0';
-
- /* update display and f */
-
- f->printed = 0;
- /* for simplicity force f->printed = 0. This way, the user gets */
- /* to see the commands that are about to be executed. Not seeing */
- /* commands you are supposedly typing sounds very uncomfortable! */
-
- if (logfile_all || (loguser && logfile)) {
- fwrite(f->buffer,1,write_count,logfile);
- }
- if (debugfile) fwrite(f->buffer,1,write_count,debugfile);
-
- f->size -= write_count;
- memcpy(f->buffer,f->buffer+write_count,1+f->size);
- /* copy to lowercase buffer */
- exp_lowmemcpy(f->lower,f->buffer,1+f->size);
-
- return(write_count);
-}
-#endif /*SHARE_CMD_BUFFER*/
-
-static struct exp_cmd_data cmd_data[] = {
-{"expect_version",exp_proc(Exp_ExpVersionCmd), 0, 0}, /* deprecated */
-{"exp_version", exp_proc(Exp_ExpVersionCmd), 0, 0},
-{"prompt1", exp_proc(Exp_Prompt1Cmd), 0, EXP_NOPREFIX},
-{"prompt2", exp_proc(Exp_Prompt2Cmd), 0, EXP_NOPREFIX},
-{0}};
-
-void
-exp_init_main_cmds(interp)
-Tcl_Interp *interp;
-{
- exp_create_commands(interp,cmd_data);
-}
+++ /dev/null
-/* exp_main_tk.c - main for expectk
-
- This file consists of three pieces:
- 1) AppInit for Expectk. This has been suitably modified to invoke
- a modified version of Tk_Init.
- 2) Tk_Init for Expectk. What's wrong with the normal Tk_Init is that
- removes the -- in the cmd-line arg list, so Expect cannot know
- whether args are flags to Expectk or data for the script. Sigh.
- 3) Additions and supporting utilities to Tk's Argv parse table to
- support Expectk's flags.
-
- Author: Don Libes, NIST, 2/20/96
-
-*/
-
-/* Expectk's AppInit */
-
-/*
- * tkAppInit.c --
- *
- * Provides a default version of the Tcl_AppInit procedure for
- * use in wish and similar Tk-based applications.
- *
- * Copyright (c) 1993 The Regents of the University of California.
- * Copyright (c) 1994 Sun Microsystems, Inc.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- */
-
-#ifndef lint
-static char sccsid[] = "@(#) tkAppInit.c 1.19 95/12/23 17:09:24";
-#endif /* not lint */
-
-#include <ctype.h>
-
-#include "tk.h"
-
-#include "expect_tcl.h"
-#include "Dbg.h"
-
-/*
- * The following variable is a special hack that is needed in order for
- * Sun shared libraries to be used for Tcl.
- */
-
-extern int matherr();
-int *tclDummyMathPtr = (int *) matherr;
-
-#ifdef TK_TEST
-EXTERN int Tktest_Init _ANSI_ARGS_((Tcl_Interp *interp));
-#endif /* TK_TEST */
-\f
-/*
- *----------------------------------------------------------------------
- *
- * main --
- *
- * This is the main program for the application.
- *
- * Results:
- * None: Tk_Main never returns here, so this procedure never
- * returns either.
- *
- * Side effects:
- * Whatever the application does.
- *
- *----------------------------------------------------------------------
- */
-
-int
-main(argc, argv)
- int argc; /* Number of command-line arguments. */
- char **argv; /* Values of command-line arguments. */
-{
- Tk_Main(argc, argv, Tcl_AppInit);
- return 0; /* Needed only to prevent compiler warning. */
-}
-\f
-/*
- *----------------------------------------------------------------------
- *
- * Tcl_AppInit --
- *
- * This procedure performs application-specific initialization.
- * Most applications, especially those that incorporate additional
- * packages, will have their own version of this procedure.
- *
- * Results:
- * Returns a standard Tcl completion code, and leaves an error
- * message in interp->result if an error occurs.
- *
- * Side effects:
- * Depends on the startup script.
- *
- *----------------------------------------------------------------------
- */
-
-int
-Tcl_AppInit(interp)
- Tcl_Interp *interp; /* Interpreter for application. */
-{
- if (Tcl_Init(interp) == TCL_ERROR) {
- return TCL_ERROR;
- }
-
- /* do Expect first so we can get access to Expect commands when */
- /* Tk_Init does the argument parsing of -c */
- if (Expect_Init(interp) == TCL_ERROR) {
- return TCL_ERROR;
- }
- Tcl_StaticPackage(interp, "Expect", Expect_Init, (Tcl_PackageInitProc *)NULL);
-
- if (Tk_Init2(interp) == TCL_ERROR) { /* DEL */
- return TCL_ERROR;
- }
- Tcl_StaticPackage(interp, "Tk", Tk_Init, (Tcl_PackageInitProc *) NULL);
-
- /*
- * Call the init procedures for included packages. Each call should
- * look like this:
- *
- * if (Mod_Init(interp) == TCL_ERROR) {
- * return TCL_ERROR;
- * }
- *
- * where "Mod" is the name of the module.
- */
-
- /*
- * Call Tcl_CreateCommand for application-specific commands, if
- * they weren't already created by the init procedures called above.
- */
-
- /*
- * Specify a user-specific startup file to invoke if the application
- * is run interactively. Typically the startup file is "~/.apprc"
- * where "app" is the name of the application. If this line is deleted
- * then no user-specific startup file will be run under any conditions.
- */
-
- Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY);
- return TCL_OK;
-}
-
-
-
-
-/*
- * Count of number of main windows currently open in this process.
- */
-
-static int numMainWindows;
-
-/*
- * The variables and table below are used to parse arguments from
- * the "argv" variable in Tk_Init.
- */
-
-static int synchronize;
-static char *name;
-static char *display;
-static char *geometry;
-static char *colormap;
-static char *visual;
-static int rest = 0;
-
-/* for Expect */
-int my_rc = 1;
-int sys_rc = 1;
-int optcmd_eval();
-#ifdef TCL_DEBUGGER
-int optcmd_debug();
-#endif
-int print_version = 0;
-
-static Tk_ArgvInfo argTable[] = {
- {"-colormap", TK_ARGV_STRING, (char *) NULL, (char *) &colormap,
- "Colormap for main window"},
- {"-display", TK_ARGV_STRING, (char *) NULL, (char *) &display,
- "Display to use"},
- {"-geometry", TK_ARGV_STRING, (char *) NULL, (char *) &geometry,
- "Initial geometry for window"},
- {"-name", TK_ARGV_STRING, (char *) NULL, (char *) &name,
- "Name to use for application"},
- {"-sync", TK_ARGV_CONSTANT, (char *) 1, (char *) &synchronize,
- "Use synchronous mode for display server"},
- {"-visual", TK_ARGV_STRING, (char *) NULL, (char *) &visual,
- "Visual for main window"},
- {"--", TK_ARGV_REST, (char *) 1, (char *) &rest,
- "Pass all remaining arguments through to script"},
-/* for Expect */
- {"-command", TK_ARGV_GENFUNC, (char *) optcmd_eval, (char *)0,
- "Command(s) to execute immediately"},
- {"-diag", TK_ARGV_CONSTANT, (char *) 1, (char *) &exp_is_debugging,
- "Enable diagnostics"},
- {"-norc", TK_ARGV_CONSTANT, (char *) 0, (char *) &my_rc,
- "Don't read ~/.expect.rc"},
- {"-NORC", TK_ARGV_CONSTANT, (char *) 0, (char *) &sys_rc,
- "Don't read system-wide expect.rc"},
- {"-version", TK_ARGV_CONSTANT, (char *) 1, (char *) &print_version,
- "Print version and exit"},
-#if TCL_DEBUGGER
- {"-Debug", TK_ARGV_GENFUNC, (char *) optcmd_debug, (char *)0,
- "Enable debugger"},
-#endif
- {(char *) NULL, TK_ARGV_END, (char *) NULL, (char *) NULL,
- (char *) NULL}
-};
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_Init --
- *
- * This procedure is invoked to add Tk to an interpreter. It
- * incorporates all of Tk's commands into the interpreter and
- * creates the main window for a new Tk application. If the
- * interpreter contains a variable "argv", this procedure
- * extracts several arguments from that variable, uses them
- * to configure the main window, and modifies argv to exclude
- * the arguments (see the "wish" documentation for a list of
- * the arguments that are extracted).
- *
- * Results:
- * Returns a standard Tcl completion code and sets interp->result
- * if there is an error.
- *
- * Side effects:
- * Depends on various initialization scripts that get invoked.
- *
- *----------------------------------------------------------------------
- */
-
-int
-Tk_Init2(interp)
- Tcl_Interp *interp; /* Interpreter to initialize. */
-{
- char *p;
- int argc, code;
- char **argv, *args[20];
- Tcl_DString class;
- char buffer[30];
-
- /*
- * If there is an "argv" variable, get its value, extract out
- * relevant arguments from it, and rewrite the variable without
- * the arguments that we used.
- */
-
- synchronize = 0;
- name = display = geometry = colormap = visual = NULL;
- p = Tcl_GetVar2(interp, "argv", (char *) NULL, TCL_GLOBAL_ONLY);
- argv = NULL;
- if (p != NULL) {
- if (Tcl_SplitList(interp, p, &argc, &argv) != TCL_OK) {
- argError:
- Tcl_AddErrorInfo(interp,
- "\n (processing arguments in argv variable)");
- return TCL_ERROR;
- }
- if (Tk_ParseArgv(interp, (Tk_Window) NULL, &argc, argv,
- argTable, TK_ARGV_DONT_SKIP_FIRST_ARG|TK_ARGV_NO_DEFAULTS)
- != TCL_OK) {
- ckfree((char *) argv);
- goto argError;
- }
-
- if (print_version) {
- extern char exp_version[];
- printf ("expectk version %s\n", exp_version);
- exp_exit (interp, 0);
- }
-
- p = Tcl_Merge(argc, argv);
- Tcl_SetVar2(interp, "argv", (char *) NULL, p, TCL_GLOBAL_ONLY);
- sprintf(buffer, "%d", argc);
- Tcl_SetVar2(interp, "argc", (char *) NULL, buffer, TCL_GLOBAL_ONLY);
- ckfree(p);
- }
-
- /*
- * Figure out the application's name and class.
- */
-
- if (name == NULL) {
- name = Tcl_GetVar(interp, "argv0", TCL_GLOBAL_ONLY);
- if ((name == NULL) || (*name == 0)) {
- name = "tk";
- } else {
- p = (char *)strrchr(name, '/'); /* added cast - DEL */
- if (p != NULL) {
- name = p+1;
- }
- }
- }
- Tcl_DStringInit(&class);
- Tcl_DStringAppend(&class, name, -1);
- p = Tcl_DStringValue(&class);
- if (islower(*p)) {
- *p = toupper((unsigned char) *p);
- }
-
- /*
- * Create an argument list for creating the top-level window,
- * using the information parsed from argv, if any.
- */
-
- args[0] = "toplevel";
- args[1] = ".";
- args[2] = "-class";
- args[3] = Tcl_DStringValue(&class);
- argc = 4;
- if (display != NULL) {
- args[argc] = "-screen";
- args[argc+1] = display;
- argc += 2;
-
- /*
- * If this is the first application for this process, save
- * the display name in the DISPLAY environment variable so
- * that it will be available to subprocesses created by us.
- */
-
- if (numMainWindows == 0) {
- Tcl_SetVar2(interp, "env", "DISPLAY", display, TCL_GLOBAL_ONLY);
- }
- }
- if (colormap != NULL) {
- args[argc] = "-colormap";
- args[argc+1] = colormap;
- argc += 2;
- }
- if (visual != NULL) {
- args[argc] = "-visual";
- args[argc+1] = visual;
- argc += 2;
- }
- args[argc] = NULL;
- code = TkCreateFrame((ClientData) NULL, interp, argc, args, 1, name);
- Tcl_DStringFree(&class);
- if (code != TCL_OK) {
- goto done;
- }
- Tcl_ResetResult(interp);
- if (synchronize) {
- XSynchronize(Tk_Display(Tk_MainWindow(interp)), True);
- }
-
- /*
- * Set the geometry of the main window, if requested. Put the
- * requested geometry into the "geometry" variable.
- */
-
- if (geometry != NULL) {
- Tcl_SetVar(interp, "geometry", geometry, TCL_GLOBAL_ONLY);
- code = Tcl_VarEval(interp, "wm geometry . ", geometry, (char *) NULL);
- if (code != TCL_OK) {
- goto done;
- }
- }
- if (Tcl_PkgRequire(interp, "Tcl", TCL_VERSION, 1) == NULL) {
- code = TCL_ERROR;
- goto done;
- }
- code = Tcl_PkgProvide(interp, "Tk", TK_VERSION);
- if (code != TCL_OK) {
- goto done;
- }
-
- /*
- * Invoke platform-specific initialization.
- */
-
-#if TCL_MAJOR_VERSION < 8
- code = TkPlatformInit(interp);
-#else
- code = TkpInit(interp, 0);
-#endif
-
- done:
- if (argv != NULL) {
- ckfree((char *) argv);
- }
- return code;
-}
-
-/*ARGSUSED*/
-int
-optcmd_eval(dst,interp,key,argc,argv)
-char *dst;
-Tcl_Interp *interp;
-char *key;
-int argc;
-char **argv;
-{
- int i;
- int rc;
-
- exp_cmdlinecmds = 1;
-
- rc = Tcl_Eval(interp,argv[0]);
- if (rc == TCL_ERROR) return -1;
-
- argc--;
- for (i=0;i<argc;i++) {
- argv[i] = argv[i+1];
- }
-
- return argc;
-}
-
-#ifdef TCL_DEBUGGER
-/*ARGSUSED*/
-int
-optcmd_debug(dst,interp,key,argc,argv)
-char *dst;
-Tcl_Interp *interp;
-char *key;
-int argc;
-char **argv;
-{
- int i;
-
- if (argc == 0) {
- strcpy(interp->result,"-Debug flag needs 1 or 0 argument");
- return -1;
- }
-
- if (Tcl_GetInt(interp,argv[0],&i) != TCL_OK) {
- return -1;
- }
-
- if (i) {
- Dbg_On(interp,0);
- }
-
- argc--;
- for (i=0;i<argc;i++) {
- argv[i] = argv[i+1];
- }
-
- return argc;
-}
-#endif /*TCL_DEBUGGER*/
+++ /dev/null
-/* memmove - some systems lack this */
-
-#include "expect_cf.h"
-#include "tcl.h"
-
-/* like memcpy but can handle overlap */
-#ifndef HAVE_MEMMOVE
-char *
-memmove(dest,src,n)
-VOID *dest;
-CONST VOID *src;
-int n;
-{
- char *d;
- CONST char *s;
-
- d = dest;
- s = src;
- if (s<d && (d < s+n)) {
- for (d+=n, s+=n; 0<n; --n)
- *--d = *--s;
- } else for (;0<n;--n) *d++ = *s++;
- return dest;
-}
-#endif /* HAVE_MEMMOVE */
+++ /dev/null
-/* interact (with only one process) - give user keyboard control
-
-Written by: Don Libes, NIST, 2/6/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 file exists for deficient versions of UNIX that lack select,
-poll, or some other multiplexing hook. Instead, this code uses two
-processes per spawned process. One sends characters from the spawnee
-to the spawner; a second send chars the other way.
-
-This will work on any UNIX system. The only sacrifice is that it
-doesn't support multiple processes. Eventually, it should catch
-SIGCHLD on dead processes and do the right thing. But it is pretty
-gruesome to imagine so many processes to do all this. If you change
-it successfully, please mail back the changes to me. - Don
-*/
-
-#include "expect_cf.h"
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/time.h>
-
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-#include "tcl.h"
-#include "exp_prog.h"
-#include "exp_command.h" /* for struct exp_f defs */
-#include "exp_event.h"
-
-/*ARGSUSED*/
-void
-exp_arm_background_filehandler(m)
-int m;
-{
-}
-
-/*ARGSUSED*/
-void
-exp_disarm_background_filehandler(m)
-int m;
-{
-}
-
-/*ARGSUSED*/
-void
-exp_disarm_background_filehandler_force(m)
-int m;
-{
-}
-
-/*ARGSUSED*/
-void
-exp_unblock_background_filehandler(m)
-int m;
-{
-}
-
-/*ARGSUSED*/
-void
-exp_block_background_filehandler(m)
-int m;
-{
-}
-
-/*ARGSUSED*/
-void
-exp_event_disarm(fd)
-int fd;
-{
-}
-
-/* returns status, one of EOF, TIMEOUT, ERROR or DATA */
-/*ARGSUSED*/
-int
-exp_get_next_event(interp,masters, n,master_out,timeout,key)
-Tcl_Interp *interp;
-int *masters;
-int n; /* # of masters */
-int *master_out; /* 1st event master, not set if none */
-int timeout; /* seconds */
-int key;
-{
- int m;
- struct exp_f *f;
-
- if (n > 1) {
- exp_error(interp,"expect not compiled with multiprocess support");
- /* select a different INTERACT_TYPE in Makefile */
- return(TCL_ERROR);
- }
-
- m = *master_out = masters[0];
- f = exp_fs + m;
-
- if (f->key != key) {
- f->key = key;
- f->force_read = FALSE;
- return(EXP_DATA_OLD);
- } else if ((!f->force_read) && (f->size != 0)) {
- return(EXP_DATA_OLD);
- }
-
- return(EXP_DATA_NEW);
-}
-
-/*ARGSUSED*/
-int
-exp_get_next_event_info(interp,fd,ready_mask)
-Tcl_Interp *interp;
-int fd;
-int ready_mask;
-{
-}
-
-/* There is no portable way to do sub-second sleeps on such a system, so */
-/* do the next best thing (without a busy loop) and fake it: sleep the right */
-/* amount of time over the long run. Note that while "subtotal" isn't */
-/* reinitialized, it really doesn't matter for such a gross hack as random */
-/* scheduling pauses will easily introduce occasional one second delays. */
-int /* returns TCL_XXX */
-exp_dsleep(interp,sec)
-Tcl_Interp *interp;
-double sec;
-{
- static double subtotal = 0;
- int seconds;
-
- subtotal += sec;
- if (subtotal < 1) return TCL_OK;
- seconds = subtotal;
- subtotal -= seconds;
- restart:
- if (Tcl_AsyncReady()) {
- int rc = Tcl_AsyncInvoke(interp,TCL_OK);
- if (rc != TCL_OK) return(rc);
- }
- sleep(seconds);
- return TCL_OK;
-}
-
-#if 0
-/* There is no portable way to do sub-second sleeps on such a system, so */
-/* do the next best thing (without a busy loop) and fake it: sleep the right */
-/* amount of time over the long run. Note that while "subtotal" isn't */
-/* reinitialized, it really doesn't matter for such a gross hack as random */
-/* scheduling pauses will easily introduce occasional one second delays. */
-int /* returns TCL_XXX */
-exp_usleep(interp,usec)
-Tcl_Interp *interp;
-long usec; /* microseconds */
-{
- static subtotal = 0;
- int seconds;
-
- subtotal += usec;
- if (subtotal < 1000000) return TCL_OK;
- seconds = subtotal/1000000;
- subtotal = subtotal%1000000;
- restart:
- if (Tcl_AsyncReady()) {
- int rc = Tcl_AsyncInvoke(interp,TCL_OK);
- if (rc != TCL_OK) return(exp_tcl2_returnvalue(rc));
- }
- sleep(seconds);
- return TCL_OK;
-}
-#endif /*0*/
-
-/* set things up for later calls to event handler */
-void
-exp_init_event()
-{
- exp_event_exit = 0;
-}
+++ /dev/null
-/* exp_poll.c - This file contains UNIX specific procedures for
- * poll-based notifier, which is the lowest-level part of the Tcl
- * event loop. This file works together with ../generic/tclNotify.c.
- *
- * 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.
- *
- * Written by Don Libes, NIST, 2/6/90
- * Rewritten by Don Libes, 2/96 for new Tcl notifier paradigm.
- * Rewritten again by Don Libes, 8/97 for yet another Tcl notifier paradigm.
- */
-
-#include "tclInt.h"
-#include "tclPort.h"
-#include <signal.h>
-
-#include <poll.h>
-#include <sys/types.h>
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-/* Some systems require that the poll array be non-empty so provide a
- * 1-elt array for starters. It will be ignored as soon as it grows
- * larger.
- */
-
-static struct pollfd initialFdArray;
-static struct pollfd *fdArray = &initialFdArray;
-static int fdsInUse = 0; /* space in use */
-static int fdsMaxSpace = 1; /* space that has actually been allocated */
-
-#if TCL_MAJOR_VERSION >= 8
-
-/*
- * tclUnixNotify.c --
- *
- * This file contains the implementation of the select-based
- * Unix-specific notifier, which is the lowest-level part of the
- * Tcl event loop. This file works together with
- * ../generic/tclNotify.c.
- *
- * Copyright (c) 1995-1997 Sun Microsystems, Inc.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * SCCS: @(#) tclUnixNotfy.c 1.42 97/07/02 20:55:44
- */
-
-/*
- * This structure is used to keep track of the notifier info for a
- * a registered file.
- */
-
-typedef struct FileHandler {
- int fd;
- int mask; /* Mask of desired events: TCL_READABLE,
- * etc. */
- int readyMask; /* Mask of events that have been seen since the
- * last time file handlers were invoked for
- * this file. */
- Tcl_FileProc *proc; /* Procedure to call, in the style of
- * Tcl_CreateFileHandler. */
- ClientData clientData; /* Argument to pass to proc. */
- int pollArrayIndex; /* index into poll array */
- struct FileHandler *nextPtr;/* Next in list of all files we care about. */
-} FileHandler;
-
-/*
- * The following structure is what is added to the Tcl event queue when
- * file handlers are ready to fire.
- */
-
-typedef struct FileHandlerEvent {
- Tcl_Event header; /* Information that is standard for
- * all events. */
- int fd; /* File descriptor that is ready. Used
- * to find the FileHandler structure for
- * the file (can't point directly to the
- * FileHandler structure because it could
- * go away while the event is queued). */
-} FileHandlerEvent;
-
-/*
- * The following static structure contains the state information for the
- * select based implementation of the Tcl notifier.
- */
-
-static struct {
- FileHandler *firstFileHandlerPtr;
- /* Pointer to head of file handler list. */
- fd_mask checkMasks[3*MASK_SIZE];
- /* This array is used to build up the masks
- * to be used in the next call to select.
- * Bits are set in response to calls to
- * Tcl_CreateFileHandler. */
- fd_mask readyMasks[3*MASK_SIZE];
- /* This array reflects the readable/writable
- * conditions that were found to exist by the
- * last call to select. */
- int numFdBits; /* Number of valid bits in checkMasks
- * (one more than highest fd for which
- * Tcl_WatchFile has been called). */
-} notifier;
-
-/*
- * The following static indicates whether this module has been initialized.
- */
-
-static int initialized = 0;
-
-/*
- * Static routines defined in this file.
- */
-
-static void InitNotifier _ANSI_ARGS_((void));
-static void NotifierExitHandler _ANSI_ARGS_((
- ClientData clientData));
-static int FileHandlerEventProc _ANSI_ARGS_((Tcl_Event *evPtr,
- int flags));
-\f
-/*
- *----------------------------------------------------------------------
- *
- * InitNotifier --
- *
- * Initializes the notifier state.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Creates a new exit handler.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-InitNotifier()
-{
- initialized = 1;
- memset(¬ifier, 0, sizeof(notifier));
- Tcl_CreateExitHandler(NotifierExitHandler, NULL);
-}
-\f
-/*
- *----------------------------------------------------------------------
- *
- * NotifierExitHandler --
- *
- * This function is called to cleanup the notifier state before
- * Tcl is unloaded.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Destroys the notifier window.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-NotifierExitHandler(clientData)
- ClientData clientData; /* Not used. */
-{
- initialized = 0;
-}
-\f
-/*
- *----------------------------------------------------------------------
- *
- * Tcl_SetTimer --
- *
- * This procedure sets the current notifier timer value. This
- * interface is not implemented in this notifier because we are
- * always running inside of Tcl_DoOneEvent.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tcl_SetTimer(timePtr)
- Tcl_Time *timePtr; /* Timeout value, may be NULL. */
-{
- /*
- * The interval timer doesn't do anything in this implementation,
- * because the only event loop is via Tcl_DoOneEvent, which passes
- * timeout values to Tcl_WaitForEvent.
- */
-}
-\f
-/*
- *----------------------------------------------------------------------
- *
- * Tcl_CreateFileHandler --
- *
- * This procedure registers a file handler with the Xt notifier.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Creates a new file handler structure and registers one or more
- * input procedures with Xt.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tcl_CreateFileHandler(fd, mask, proc, clientData)
- int fd; /* Handle of stream to watch. */
- int mask; /* OR'ed combination of TCL_READABLE,
- * TCL_WRITABLE, and TCL_EXCEPTION:
- * indicates conditions under which
- * proc should be called. */
- Tcl_FileProc *proc; /* Procedure to call for each
- * selected event. */
- ClientData clientData; /* Arbitrary data to pass to proc. */
-{
- FileHandler *filePtr;
- int index, bit;
- int cur_fd_index;
-
- if (!initialized) {
- InitNotifier();
- }
-
- for (filePtr = notifier.firstFileHandlerPtr; filePtr != NULL;
- filePtr = filePtr->nextPtr) {
- if (filePtr->fd == fd) {
- break;
- }
- }
- if (filePtr == NULL) {
- filePtr = (FileHandler*) ckalloc(sizeof(FileHandler)); /* MLK */
- filePtr->fd = fd;
- filePtr->readyMask = 0;
- filePtr->nextPtr = notifier.firstFileHandlerPtr;
- notifier.firstFileHandlerPtr = filePtr;
- }
- filePtr->proc = proc;
- filePtr->clientData = clientData;
-#if NOTUSED
- /* remaining junk is left over from select implementation - DEL */
-
- filePtr->mask = mask;
-
- /*
- * Update the check masks for this file.
- */
-
- index = fd/(NBBY*sizeof(fd_mask));
- bit = 1 << (fd%(NBBY*sizeof(fd_mask)));
- if (mask & TCL_READABLE) {
- notifier.checkMasks[index] |= bit;
- } else {
- notifier.checkMasks[index] &= ~bit;
- }
- if (mask & TCL_WRITABLE) {
- (notifier.checkMasks+MASK_SIZE)[index] |= bit;
- } else {
- (notifier.checkMasks+MASK_SIZE)[index] &= ~bit;
- }
- if (mask & TCL_EXCEPTION) {
- (notifier.checkMasks+2*(MASK_SIZE))[index] |= bit;
- } else {
- (notifier.checkMasks+2*(MASK_SIZE))[index] &= ~bit;
- }
- if (notifier.numFdBits <= fd) {
- notifier.numFdBits = fd+1;
- }
-#endif /* notused */
-
- filePtr->pollArrayIndex = fdsInUse;
- cur_fd_index = fdsInUse;
-
- fdsInUse++;
- if (fdsInUse > fdsMaxSpace) {
- if (fdArray != &initialFdArray) ckfree((char *)fdArray);
- fdArray = (struct pollfd *)ckalloc(fdsInUse*sizeof(struct pollfd));
- fdsMaxSpace = fdsInUse;
- }
-
- fdArray[cur_fd_index].fd = fd;
-
- /* I know that POLLIN/OUT is right. But I have no idea if POLLPRI
- * corresponds well to TCL_EXCEPTION.
- */
-
- if (mask & TCL_READABLE) {
- fdArray[cur_fd_index].events = POLLIN;
- }
- if (mask & TCL_WRITABLE) {
- fdArray[cur_fd_index].events = POLLOUT;
- }
- if (mask & TCL_EXCEPTION) {
- fdArray[cur_fd_index].events = POLLPRI;
- }
-}
-\f
-/*
- *----------------------------------------------------------------------
- *
- * Tcl_DeleteFileHandler --
- *
- * Cancel a previously-arranged callback arrangement for
- * a file.
- *
- * Results:
- * None.
- *
- * Side effects:
- * If a callback was previously registered on file, remove it.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tcl_DeleteFileHandler(fd)
- int fd; /* Stream id for which to remove callback procedure. */
-{
- FileHandler *filePtr, *prevPtr, *lastPtr;
- int index, bit, mask, i;
- int cur_fd_index;
-
- if (!initialized) {
- InitNotifier();
- }
-
- /*
- * Find the entry for the given file (and return if there
- * isn't one).
- */
-
- for (prevPtr = NULL, filePtr = notifier.firstFileHandlerPtr; ;
- prevPtr = filePtr, filePtr = filePtr->nextPtr) {
- if (filePtr == NULL) {
- return;
- }
- if (filePtr->fd == fd) {
- break;
- }
- }
-
-#if NOTUSED
- /* remaining junk is left over from select implementation - DEL */
-
- /*
- * Update the check masks for this file.
- */
-
- index = fd/(NBBY*sizeof(fd_mask));
- bit = 1 << (fd%(NBBY*sizeof(fd_mask)));
-
- if (filePtr->mask & TCL_READABLE) {
- notifier.checkMasks[index] &= ~bit;
- }
- if (filePtr->mask & TCL_WRITABLE) {
- (notifier.checkMasks+MASK_SIZE)[index] &= ~bit;
- }
- if (filePtr->mask & TCL_EXCEPTION) {
- (notifier.checkMasks+2*(MASK_SIZE))[index] &= ~bit;
- }
-
- /*
- * Find current max fd.
- */
-
- if (fd+1 == notifier.numFdBits) {
- for (notifier.numFdBits = 0; index >= 0; index--) {
- mask = notifier.checkMasks[index]
- | (notifier.checkMasks+MASK_SIZE)[index]
- | (notifier.checkMasks+2*(MASK_SIZE))[index];
- if (mask) {
- for (i = (NBBY*sizeof(fd_mask)); i > 0; i--) {
- if (mask & (1 << (i-1))) {
- break;
- }
- }
- notifier.numFdBits = index * (NBBY*sizeof(fd_mask)) + i;
- break;
- }
- }
- }
-#endif /* notused */
-
- /*
- * Clean up information in the callback record.
- */
-
- if (prevPtr == NULL) {
- notifier.firstFileHandlerPtr = filePtr->nextPtr;
- } else {
- prevPtr->nextPtr = filePtr->nextPtr;
- }
-
- /* back to poll-specific code - DEL */
-
- cur_fd_index = filePtr->pollArrayIndex;
- fdsInUse--;
-
- /* if this one is last, do nothing special */
- /* else swap with one at end of array */
-
- if (cur_fd_index != fdsInUse) {
- int lastfd_in_array = fdArray[fdsInUse].fd;
- memcpy(&fdArray[cur_fd_index],&fdArray[fdsInUse],sizeof(struct pollfd));
-
- /* update index to reflect new location in array */
- /* first find link corresponding to last element in array */
-
- for (lastPtr = notifier.firstFileHandlerPtr; filePtr; lastPtr = lastPtr->nextPtr) {
- if (lastPtr->fd == lastfd_in_array) {
- lastPtr->pollArrayIndex = cur_fd_index;
- break;
- }
- }
- }
-
- fdsInUse--;
-
- ckfree((char *) filePtr);
-}
-\f
-/*
- *----------------------------------------------------------------------
- *
- * FileHandlerEventProc --
- *
- * This procedure is called by Tcl_ServiceEvent when a file event
- * reaches the front of the event queue. This procedure is
- * responsible for actually handling the event by invoking the
- * callback for the file handler.
- *
- * Results:
- * Returns 1 if the event was handled, meaning it should be removed
- * from the queue. Returns 0 if the event was not handled, meaning
- * it should stay on the queue. The only time the event isn't
- * handled is if the TCL_FILE_EVENTS flag bit isn't set.
- *
- * Side effects:
- * Whatever the file handler's callback procedure does.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-FileHandlerEventProc(evPtr, flags)
- Tcl_Event *evPtr; /* Event to service. */
- int flags; /* Flags that indicate what events to
- * handle, such as TCL_FILE_EVENTS. */
-{
- FileHandler *filePtr;
- FileHandlerEvent *fileEvPtr = (FileHandlerEvent *) evPtr;
- int mask;
-
- if (!(flags & TCL_FILE_EVENTS)) {
- return 0;
- }
-
- /*
- * Search through the file handlers to find the one whose handle matches
- * the event. We do this rather than keeping a pointer to the file
- * handler directly in the event, so that the handler can be deleted
- * while the event is queued without leaving a dangling pointer.
- */
-
- for (filePtr = notifier.firstFileHandlerPtr; filePtr != NULL;
- filePtr = filePtr->nextPtr) {
- if (filePtr->fd != fileEvPtr->fd) {
- continue;
- }
-
- /*
- * The code is tricky for two reasons:
- * 1. The file handler's desired events could have changed
- * since the time when the event was queued, so AND the
- * ready mask with the desired mask.
- * 2. The file could have been closed and re-opened since
- * the time when the event was queued. This is why the
- * ready mask is stored in the file handler rather than
- * the queued event: it will be zeroed when a new
- * file handler is created for the newly opened file.
- */
-
- mask = filePtr->readyMask & filePtr->mask;
- filePtr->readyMask = 0;
- if (mask != 0) {
- (*filePtr->proc)(filePtr->clientData, mask);
- }
- break;
- }
- return 1;
-}
-\f
-/*
- *----------------------------------------------------------------------
- *
- * Tcl_WaitForEvent --
- *
- * This function is called by Tcl_DoOneEvent to wait for new
- * events on the message queue. If the block time is 0, then
- * Tcl_WaitForEvent just polls without blocking.
- *
- * Results:
- * Returns -1 if the select would block forever, otherwise
- * returns 0.
- *
- * Side effects:
- * Queues file events that are detected by the select.
- *
- *----------------------------------------------------------------------
- */
-
-int
-Tcl_WaitForEvent(timePtr)
- Tcl_Time *timePtr; /* Maximum block time, or NULL. */
-{
- FileHandler *filePtr;
- FileHandlerEvent *fileEvPtr;
-#if 0
- struct timeval timeout, *timeoutPtr;
-#endif
- int timeout;
- struct timeval *timeoutPtr;
-
- int bit, index, mask, numFound;
-
- if (!initialized) {
- InitNotifier();
- }
-
- /*
- * Set up the timeout structure. Note that if there are no events to
- * check for, we return with a negative result rather than blocking
- * forever.
- */
-
- if (timePtr) {
-#if 0
- timeout.tv_sec = timePtr->sec;
- timeout.tv_usec = timePtr->usec;
- timeoutPtr = &timeout;
-#endif
- timeout = timePtr->sec*1000 + timePtr->usec/1000;
-
- } else if (notifier.numFdBits == 0) {
- return -1;
- } else {
- timeoutPtr = NULL;
- }
-
- numFound = poll(fdArray,fdsInUse,timeout);
-#if 0
- memcpy((VOID *) notifier.readyMasks, (VOID *) notifier.checkMasks,
- 3*MASK_SIZE*sizeof(fd_mask));
- numFound = select(notifier.numFdBits,
- (SELECT_MASK *) ¬ifier.readyMasks[0],
- (SELECT_MASK *) ¬ifier.readyMasks[MASK_SIZE],
- (SELECT_MASK *) ¬ifier.readyMasks[2*MASK_SIZE], timeoutPtr);
-
- /*
- * Some systems don't clear the masks after an error, so
- * we have to do it here.
- */
-
- if (numFound == -1) {
- memset((VOID *) notifier.readyMasks, 0, 3*MASK_SIZE*sizeof(fd_mask));
- }
-#endif
-
- /*
- * Queue all detected file events before returning.
- */
-
- for (filePtr = notifier.firstFileHandlerPtr;
- (filePtr != NULL) && (numFound > 0);
- filePtr = filePtr->nextPtr) {
- index = filePtr->pollArrayIndex;
- mask = 0;
-
- if (fdArray[index].revents & POLLIN) {
- mask |= TCL_READABLE;
- }
- if (fdArray[index].revents & POLLOUT) {
- mask |= TCL_WRITABLE;
- }
- /* I have no idea if this is right ... */
- if (fdArray[index].revents & (POLLPRI|POLLERR|POLLHUP|POLLNVAL)) {
- mask |= TCL_EXCEPTION;
- }
-
-#if 0
- index = filePtr->fd / (NBBY*sizeof(fd_mask));
- bit = 1 << (filePtr->fd % (NBBY*sizeof(fd_mask)));
- mask = 0;
-
- if (notifier.readyMasks[index] & bit) {
- mask |= TCL_READABLE;
- }
- if ((notifier.readyMasks+MASK_SIZE)[index] & bit) {
- mask |= TCL_WRITABLE;
- }
- if ((notifier.readyMasks+2*(MASK_SIZE))[index] & bit) {
- mask |= TCL_EXCEPTION;
- }
-#endif
-
- if (!mask) {
- continue;
- } else {
- numFound--;
- }
-
- /*
- * Don't bother to queue an event if the mask was previously
- * non-zero since an event must still be on the queue.
- */
-
- if (filePtr->readyMask == 0) {
- fileEvPtr = (FileHandlerEvent *) ckalloc(
- sizeof(FileHandlerEvent));
- fileEvPtr->header.proc = FileHandlerEventProc;
- fileEvPtr->fd = filePtr->fd;
- Tcl_QueueEvent((Tcl_Event *) fileEvPtr, TCL_QUEUE_TAIL);
- }
- filePtr->readyMask = mask;
- }
- return 0;
-}
-
-#else /* TCL_MAJOR_VERSION < 8 */
-
-/*
- *----------------------------------------------------------------------
- *
- * Tcl_WatchFile --
- *
- * Arrange for Tcl_DoOneEvent to include this file in the masks
- * for the next call to select. This procedure is invoked by
- * event sources, which are in turn invoked by Tcl_DoOneEvent
- * before it invokes select.
- *
- * Results:
- * None.
- *
- * Side effects:
- *
- * The notifier will generate a file event when the I/O channel
- * given by fd next becomes ready in the way indicated by mask.
- * If fd is already registered then the old mask will be replaced
- * with the new one. Once the event is sent, the notifier will
- * not send any more events about the fd until the next call to
- * Tcl_NotifyFile.
- *
- * Assumption for poll implementation: Tcl_WatchFile is presumed NOT
- * to be called on the same file descriptior without intervening calls
- * to Tcl_DoOneEvent.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tcl_WatchFile(file, mask)
- Tcl_File file; /* Generic file handle for a stream. */
- int mask; /* OR'ed combination of TCL_READABLE,
- * TCL_WRITABLE, and TCL_EXCEPTION:
- * indicates conditions to wait for
- * in select. */
-{
- int fd, type;
- int cur_fd_index = fdsInUse;
-
- fd = (int) Tcl_GetFileInfo(file, &type);
-
- if (type != TCL_UNIX_FD) {
- panic("Tcl_WatchFile: unexpected file type");
- }
-
- fdsInUse++;
- if (fdsInUse > fdsMaxSpace) {
- if (fdArray != &initialFdArray) ckfree((char *)fdArray);
- fdArray = (struct pollfd *)ckalloc(fdsInUse*sizeof(struct pollfd));
- fdsMaxSpace = fdsInUse;
- }
-
- fdArray[cur_fd_index].fd = fd;
-
- /* I know that POLLIN/OUT is right. But I have no idea if POLLPRI
- * corresponds well to TCL_EXCEPTION.
- */
-
- if (mask & TCL_READABLE) {
- fdArray[cur_fd_index].events = POLLIN;
- }
- if (mask & TCL_WRITABLE) {
- fdArray[cur_fd_index].events = POLLOUT;
- }
- if (mask & TCL_EXCEPTION) {
- fdArray[cur_fd_index].events = POLLPRI;
- }
-}
-
-\f
-/*
- *----------------------------------------------------------------------
- *
- * Tcl_FileReady --
- *
- * Indicates what conditions (readable, writable, etc.) were
- * present on a file the last time the notifier invoked select.
- * This procedure is typically invoked by event sources to see
- * if they should queue events.
- *
- * Results:
- * The return value is 0 if none of the conditions specified by mask
- * was true for fd the last time the system checked. If any of the
- * conditions were true, then the return value is a mask of those
- * that were true.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-int
-Tcl_FileReady(file, mask)
- Tcl_File file; /* Generic file handle for a stream. */
- int mask; /* OR'ed combination of TCL_READABLE,
- * TCL_WRITABLE, and TCL_EXCEPTION:
- * indicates conditions caller cares about. */
-{
- int index, result, type, fd;
- fd_mask bit;
-
- fd = (int) Tcl_GetFileInfo(file, &type);
- if (type != TCL_UNIX_FD) {
- panic("Tcl_FileReady: unexpected file type");
- }
-
- result = 0;
- if ((mask & TCL_READABLE) && (fdArray[fd].revents & POLLIN)) {
- result |= TCL_READABLE;
- }
- if ((mask & TCL_WRITABLE) && (fdArray[fd].revents & POLLOUT)) {
- result |= TCL_WRITABLE;
- }
- /* I have no idea if this is right ... */
- if ((mask & TCL_EXCEPTION) &&
- (fdArray[fd].revents & (POLLPRI|POLLERR|POLLHUP|POLLNVAL))) {
- result |= TCL_EXCEPTION;
- }
- return result;
-}
-\f
-/*
- *----------------------------------------------------------------------
- *
- * Tcl_WaitForEvent --
- *
- * This procedure does the lowest level wait for events in a
- * platform-specific manner. It uses information provided by
- * previous calls to Tcl_WatchFile, plus the timePtr argument,
- * to determine what to wait for and how long to wait.
- *
- * Results:
- * 7.6 The return value is normally TCL_OK. However, if there are
- * no events to wait for (e.g. no files and no timers) so that
- * the procedure would block forever, then it returns TCL_ERROR.
- *
- * Side effects:
- * May put the process to sleep for a while, depending on timePtr.
- * When this procedure returns, an event of interest to the application
- * has probably, but not necessarily, occurred.
- *
- *----------------------------------------------------------------------
- */
-
-int
-Tcl_WaitForEvent(timePtr)
- Tcl_Time *timePtr; /* Specifies the maximum amount of time
- * that this procedure should block before
- * returning. The time is given as an
- * interval, not an absolute wakeup time.
- * NULL means block forever. */
-{
- int timeout;
- struct timeval *timeoutPtr;
-
- /* no need to clear revents */
- if (timePtr == NULL) {
- if (!fdsInUse) return (TCL_ERROR);
- timeout = -1;
- } else {
- timeout = timePtr->sec*1000 + timePtr->usec/1000;
- }
-
- poll(fdArray,fdsInUse,timeout);
-
- fdsInUse = 0;
-
- return TCL_OK;
-}
-\f
-/*
- *----------------------------------------------------------------------
- *
- * Tcl_Sleep --
- *
- * Delay execution for the specified number of milliseconds.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Time passes.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tcl_Sleep(ms)
- int ms; /* Number of milliseconds to sleep. */
-{
- static struct timeval delay;
- Tcl_Time before, after;
-
- /*
- * The only trick here is that select appears to return early
- * under some conditions, so we have to check to make sure that
- * the right amount of time really has elapsed. If it's too
- * early, go back to sleep again.
- */
-
- TclGetTime(&before);
- after = before;
- after.sec += ms/1000;
- after.usec += (ms%1000)*1000;
- if (after.usec > 1000000) {
- after.usec -= 1000000;
- after.sec += 1;
- }
- while (1) {
- delay.tv_sec = after.sec - before.sec;
- delay.tv_usec = after.usec - before.usec;
- if (delay.tv_usec < 0) {
- delay.tv_usec += 1000000;
- delay.tv_sec -= 1;
- }
-
- /*
- * Special note: must convert delay.tv_sec to int before comparing
- * to zero, since delay.tv_usec is unsigned on some platforms.
- */
-
- if ((((int) delay.tv_sec) < 0)
- || ((delay.tv_usec == 0) && (delay.tv_sec == 0))) {
- break;
- }
-
- /* poll understands milliseconds, sigh */
- poll(fdArray,0,delay.tv_sec*1000 + delay.tv_usec/1000);
- TclGetTime(&before);
- }
-}
-
-#endif /* TCL_MAJOR_VERSION < 8 */
-
+++ /dev/null
-/* exp_printify - printable versions of random ASCII strings
-
-Written by: Don Libes, NIST, 2/6/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.
-
-*/
-
-#include "expect_cf.h"
-#include "tcl.h"
-#ifdef NO_STDLIB_H
-#include "../compat/stdlib.h"
-#else
-#include <stdlib.h> /* for malloc */
-#endif
-#include <ctype.h>
-
-/* generate printable versions of random ASCII strings. Primarily used */
-/* by cmdExpect when -d forces it to print strings it is examining. */
-char *
-exp_printify(s)
-char *s;
-{
- static int destlen = 0;
- static char *dest = 0;
- char *d; /* ptr into dest */
- unsigned int need;
-
- if (s == 0) return("<null>");
-
- /* worst case is every character takes 4 to printify */
- need = strlen(s)*4 + 1;
- if (need > destlen) {
- if (dest) ckfree(dest);
- dest = ckalloc(need);
- destlen = need;
- }
-
- for (d = dest;*s;s++) {
- if (*s == '\r') {
- strcpy(d,"\\r"); d += 2;
- } else if (*s == '\n') {
- strcpy(d,"\\n"); d += 2;
- } else if (*s == '\t') {
- strcpy(d,"\\t"); d += 2;
- } else if (isascii(*s) && isprint(*s)) {
- *d = *s; d += 1;
- } else {
- sprintf(d,"\\x%02x",*s & 0xff); d += 4;
- }
- }
- *d = '\0';
- return(dest);
-}
+++ /dev/null
-#ifndef __EXP_PRINTIFY_H__
-#define __EXP_PRINTIFY_H__
-
-char *exp_printify();
-
-#endif /* __EXP_PRINTIFY_H__ */
+++ /dev/null
-/* exp_prog.h - private symbols common to both expect program and library
-
-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.
-*/
-
-#ifndef _EXPECT_PROG_H
-#define _EXPECT_PROG_H
-
-#include "expect_tcl.h"
-#include "exp_int.h"
-
-/* yes, I have a weak mind */
-#define streq(x,y) (0 == strcmp((x),(y)))
-
-#endif /* _EXPECT_PROG_H */
+++ /dev/null
-/* exp_pty.c - generic routines to allocate and test ptys
-
-Written by: Don Libes, NIST, 3/9/93
-
-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.
-
-*/
-
-#include "expect_cf.h"
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#ifdef HAVE_SYS_FCNTL_H
-# include <sys/fcntl.h>
-#else
-# include <fcntl.h>
-#endif
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#ifdef TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-# include <sys/time.h>
-# else
-# include <time.h>
-# endif
-#endif
-
-#include <signal.h>
-#include <setjmp.h>
-#include <sys/file.h>
-#define EXP_AVOID_INCLUDING_TCL_H 1
-#include "expect_comm.h"
-#include "exp_rename.h"
-#include "exp_pty.h"
-
-#include <errno.h>
-
-void debuglog();
-
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
-
-#ifdef O_NOCTTY
-#define RDWR ((O_RDWR)|(O_NOCTTY))
-#else
-#define RDWR O_RDWR
-#endif
-
-static int locked = FALSE;
-static char lock[] = "/tmp/ptylock.XXXX"; /* XX is replaced by pty id */
-static char locksrc[50] = "/tmp/expect.pid"; /* pid is replaced by real pid */
- /* locksrc is used as the link source, i.e., something to link from */
-
-static int i_read_errno;/* place to save errno, if i_read() == -1, so it
- doesn't get overwritten before we get to read it */
-static jmp_buf env; /* for interruptable read() */
-static int env_valid = FALSE; /* whether we can longjmp or not */
-
-/* sigalarm_handler and i_read are here just for supporting the sanity */
-/* checking of pty slave devices. I have only seen this happen on BSD */
-/* systems, but it may need to be done to the other pty implementations */
-/* as well. */
-
-/* Note that this code is virtually replicated from other code in expect */
-/* At some point, I'll dump one, but not until I'm satisfied no other */
-/* changes are needed */
-
-/*ARGSUSED*/
-static RETSIGTYPE
-sigalarm_handler(n)
-int n; /* unused, for compatibility with STDC */
-{
-#ifdef REARM_SIG
- signal(SIGALRM,sigalarm_handler);
-#endif
-
- /* check env_valid first to protect us from the alarm occurring */
- /* in the window between i_read and alarm(0) */
- if (env_valid) longjmp(env,1);
-}
-
-/* interruptable read */
-static int
-i_read(fd,buffer,length,timeout)
-int fd;
-char *buffer;
-int length;
-int timeout;
-{
- int cc = -2;
-
- /* since setjmp insists on returning 1 upon longjmp(,0), */
- /* longjmp(,2) instead. */
-
- /* restart read if setjmp returns 0 (first time) or 2. */
- /* abort if setjmp returns 1. */
-
- alarm(timeout);
-
- if (1 != setjmp(env)) {
- env_valid = TRUE;
- cc = read(fd,buffer,length);
- }
- env_valid = FALSE;
- i_read_errno = errno; /* errno can be overwritten by the */
- /* time we return */
- alarm(0);
- return(cc);
-}
-
-static RETSIGTYPE (*oldAlarmHandler)();
-static RETSIGTYPE (*oldHupHandler)();
-static time_t current_time; /* time when testing began */
-
-/* if TRUE, begin testing, else end testing */
-/* returns -1 for failure, 0 for success */
-int
-exp_pty_test_start()
-{
- int lfd; /* locksrc file descriptor */
-
- oldAlarmHandler = signal(SIGALRM,sigalarm_handler);
-#ifndef O_NOCTTY
- /* Ignore hangup signals generated by pty testing */
- /* when running in background with no control tty. */
- /* Very few systems don't define O_NOCTTY. Only one */
- /* I know of is Next. */
- oldAlarmHandler = signal(SIGHUP,SIG_IGN);
-#endif
-
- time(¤t_time);
-
- /* recreate locksrc to prevent locks from 'looking old', so */
- /* that they are not deleted (later on in this code) */
- sprintf(locksrc,"/tmp/expect.%d",getpid());
- (void) unlink(locksrc);
- if (-1 == (lfd = creat(locksrc,0777))) {
- static char buf[256];
- exp_pty_error = buf;
- sprintf(exp_pty_error,"can't create %s, errno = %d\n",locksrc, errno);
- return(-1);
- }
- close(lfd);
- return 0;
-}
-
-void
-exp_pty_test_end()
-{
- signal(SIGALRM,oldAlarmHandler);
-#ifndef O_NOCTTY
- signal(SIGALRM,oldHupHandler);
-#endif
- (void) unlink(locksrc);
-}
-
-/* returns non-negative if successful */
-int
-exp_pty_test(master_name,slave_name,bank,num)
-char *master_name;
-char *slave_name;
-int bank;
-char *num; /* string representation of number */
-{
- int master, slave;
- int cc;
- char c;
-
- /* make a lock file to prevent others (for now only */
- /* expects) from allocating pty while we are playing */
- /* with it. This allows us to rigorously test the */
- /* pty is usable. */
- if (exp_pty_lock(bank,num) == 0) {
- debuglog("pty master (%s) is locked...skipping\r\n",master_name);
- return(-1);
- }
- /* verify no one else is using slave by attempting */
- /* to read eof from master side */
- if (0 > (master = open(master_name,RDWR))) return(-1);
-
-#ifdef __QNX__
-
- /* QNX ptys don't have a lot of the same properties such as
- read 0 at EOF, etc */
- /* if 1 should pacify C compiler without using nested ifdefs */
- if (1) return master;
-#endif
-
-#ifdef HAVE_PTYTRAP
- if (access(slave_name, R_OK|W_OK) != 0) {
- debuglog("could not open slave for pty master (%s)...skipping\r\n",
- master_name);
- (void) close(master);
- return -1;
- }
- return(master);
-#else
- if (0 > (slave = open(slave_name,RDWR))) {
- (void) close(master);
- return -1;
- }
- (void) close(slave);
- cc = i_read(master,&c,1,10);
- (void) close(master);
- if (!(cc == 0 || cc == -1)) {
- debuglog("%s slave open, skipping\r\n",slave_name);
- locked = FALSE; /* leave lock file around so Expect's avoid */
- /* retrying this pty for near future */
- return -1;
- }
-
- /* verify no one else is using master by attempting */
- /* to read eof from slave side */
- if (0 > (master = open(master_name,RDWR))) return(-1);
- if (0 > (slave = open(slave_name,RDWR))) {
- (void) close(master);
- return -1;
- }
- (void) close(master);
- cc = i_read(slave,&c,1,10);
- (void) close(slave);
- if (!(cc == 0 || cc == -1)) {
- debuglog("%s master open, skipping\r\n",master_name);
- return -1;
- }
-
- /* seems ok, let's use it */
- debuglog("using master pty %s\n",master_name);
- return(open(master_name,RDWR));
-#endif
-}
-
-void
-exp_pty_unlock()
-{
- if (locked) {
- (void) unlink(lock);
- locked = FALSE;
- }
-}
-
-/* returns 1 if successfully locked, 0 otherwise */
-int
-exp_pty_lock(bank,num)
-int bank;
-char *num; /* string representation of number */
-{
- struct stat statbuf;
-
- if (locked) {
- unlink(lock);
- locked = FALSE;
- }
-
- sprintf(lock,"/tmp/ptylock.%c%s",bank,num);
-
- if ((0 == stat(lock,&statbuf)) &&
- (statbuf.st_mtime+3600 < current_time)) {
- (void) unlink(lock);
- }
-
- if (-1 == (link(locksrc,lock))) locked = FALSE;
- else locked = TRUE;
-
- return locked;
-}
-
+++ /dev/null
-/* exp_pty.h - declarations for pty allocation and testing
-
-Written by: Don Libes, NIST, 3/9/93
-
-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.
-
-*/
-
-int exp_pty_test_start();
-void exp_pty_test_end();
-int exp_pty_test();
-void exp_pty_unlock();
-int exp_pty_lock();
-
-extern char *exp_pty_slave_name;
+++ /dev/null
-/*
- * regcomp and regexec -- regsub and regerror are elsewhere
- *
- * Copyright (c) 1986 by University of Toronto.
- * Written by Henry Spencer. Not derived from licensed software.
- *
- * Permission is granted to anyone to use this software for any
- * purpose on any computer system, and to redistribute it freely,
- * subject to the following restrictions:
- *
- * 1. The author is not responsible for the consequences of use of
- * this software, no matter how awful, even if they arise
- * from defects in it.
- *
- * 2. The origin of this software must not be misrepresented, either
- * by explicit claim or by omission.
- *
- * 3. Altered versions must be plainly marked as such, and must not
- * be misrepresented as being the original software.
- *
- * Beware that some of this code is subtly aware of the way operator
- * precedence is structured in regular expressions. Serious changes in
- * regular-expression syntax might require a total rethink.
- *
- * *** NOTE: this code has been altered slightly for use in Tcl. ***
- * *** The only change is to use ckalloc and ckfree instead of ***
- * *** malloc and free. ***
-
- * *** and again for Expect!!! - DEL
-
- * *** More minor corrections stolen from tcl7.5p1/regexp.c - DEL
-
- */
-
-#include "tcl.h"
-#include "expect_cf.h"
-#include "exp_prog.h"
-#include "tcl_regexp.h"
-#include "exp_regexp.h"
-#include "string.h"
-
-#define NOTSTATIC /* was at one time, but Expect needs access */
-
-/*
- * The "internal use only" fields in regexp.h are present to pass info from
- * compile to execute that permits the execute phase to run lots faster on
- * simple cases. They are:
- *
- * regstart char that must begin a match; '\0' if none obvious
- * reganch is the match anchored (at beginning-of-line only)?
- * regmust string (pointer into program) that match must include, or NULL
- * regmlen length of regmust string
- *
- * Regstart and reganch permit very fast decisions on suitable starting points
- * for a match, cutting down the work a lot. Regmust permits fast rejection
- * of lines that cannot possibly match. The regmust tests are costly enough
- * that regcomp() supplies a regmust only if the r.e. contains something
- * potentially expensive (at present, the only such thing detected is * or +
- * at the start of the r.e., which can involve a lot of backup). Regmlen is
- * supplied because the test in regexec() needs it and regcomp() is computing
- * it anyway.
- */
-
-/*
- * Structure for regexp "program". This is essentially a linear encoding
- * of a nondeterministic finite-state machine (aka syntax charts or
- * "railroad normal form" in parsing technology). Each node is an opcode
- * plus a "next" pointer, possibly plus an operand. "Next" pointers of
- * all nodes except BRANCH implement concatenation; a "next" pointer with
- * a BRANCH on both ends of it is connecting two alternatives. (Here we
- * have one of the subtle syntax dependencies: an individual BRANCH (as
- * opposed to a collection of them) is never concatenated with anything
- * because of operator precedence.) The operand of some types of node is
- * a literal string; for others, it is a node leading into a sub-FSM. In
- * particular, the operand of a BRANCH node is the first node of the branch.
- * (NB this is *not* a tree structure: the tail of the branch connects
- * to the thing following the set of BRANCHes.) The opcodes are:
- */
-
-/* definition number opnd? meaning */
-#define END 0 /* no End of program. */
-#define BOL 1 /* no Match "" at beginning of line. */
-#define EOL 2 /* no Match "" at end of line. */
-#define ANY 3 /* no Match any one character. */
-#define ANYOF 4 /* str Match any character in this string. */
-#define ANYBUT 5 /* str Match any character not in this string. */
-#define BRANCH 6 /* node Match this alternative, or the next... */
-#define BACK 7 /* no Match "", "next" ptr points backward. */
-#define EXACTLY 8 /* str Match this string. */
-#define NOTHING 9 /* no Match empty string. */
-#define STAR 10 /* node Match this (simple) thing 0 or more times. */
-#define PLUS 11 /* node Match this (simple) thing 1 or more times. */
-#define OPEN 20 /* no Mark this point in input as start of #n. */
- /* OPEN+1 is number 1, etc. */
-#define CLOSE (OPEN+NSUBEXP) /* no Analogous to OPEN. */
-
-/*
- * Opcode notes:
- *
- * BRANCH The set of branches constituting a single choice are hooked
- * together with their "next" pointers, since precedence prevents
- * anything being concatenated to any individual branch. The
- * "next" pointer of the last BRANCH in a choice points to the
- * thing following the whole choice. This is also where the
- * final "next" pointer of each individual branch points; each
- * branch starts with the operand node of a BRANCH node.
- *
- * BACK Normal "next" pointers all implicitly point forward; BACK
- * exists to make loop structures possible.
- *
- * STAR,PLUS '?', and complex '*' and '+', are implemented as circular
- * BRANCH structures using BACK. Simple cases (one character
- * per match) are implemented with STAR and PLUS for speed
- * and to minimize recursive plunges.
- *
- * OPEN,CLOSE ...are numbered at compile time.
- */
-
-/*
- * A node is one char of opcode followed by two chars of "next" pointer.
- * "Next" pointers are stored as two 8-bit pieces, high order first. The
- * value is a positive offset from the opcode of the node containing it.
- * An operand, if any, simply follows the node. (Note that much of the
- * code generation knows about this implicit relationship.)
- *
- * Using two bytes for the "next" pointer is vast overkill for most things,
- * but allows patterns to get big without disasters.
- */
-#define OP(p) (*(p))
-#define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377))
-#define OPERAND(p) ((p) + 3)
-
-/*
- * See regmagic.h for one further detail of program structure.
- */
-
-
-/*
- * Utility definitions.
- */
-#ifndef CHARBITS
-#define UCHARAT(p) ((int)*(unsigned char *)(p))
-#else
-#define UCHARAT(p) ((int)*(p)&CHARBITS)
-#endif
-
-#define FAIL(m) { regerror(m); return(NULL); }
-#define ISMULT(c) ((c) == '*' || (c) == '+' || (c) == '?')
-#define META "^$.[()|?+*\\"
-
-/*
- * Flags to be passed up and down.
- */
-#define HASWIDTH 01 /* Known never to match null string. */
-#define SIMPLE 02 /* Simple enough to be STAR/PLUS operand. */
-#define SPSTART 04 /* Starts with * or +. */
-#define WORST 0 /* Worst case. */
-
-/*
- * Global work variables for regcomp().
- */
-static char *regparse; /* Input-scan pointer. */
-static int regnpar; /* () count. */
-static char regdummy;
-static char *regcode; /* Code-emit pointer; ®dummy = don't. */
-static long regsize; /* Code size. */
-
-/*
- * The first byte of the regexp internal "program" is actually this magic
- * number; the start node begins in the second byte.
- */
-#define MAGIC 0234
-
-
-/*
- * Forward declarations for regcomp()'s friends.
- */
-#ifndef STATIC
-#define STATIC static
-#endif
-STATIC char *reg();
-STATIC char *regbranch();
-STATIC char *regpiece();
-STATIC char *regatom();
-STATIC char *regnode();
-STATIC char *regnext();
-STATIC void regc();
-STATIC void reginsert();
-STATIC void regtail();
-STATIC void regoptail();
-#ifdef STRCSPN
-STATIC int strcspn();
-#endif
-
-/* regcomp originally appeared here - DEL */
-
-/*
- - reg - regular expression, i.e. main body or parenthesized thing
- *
- * Caller must absorb opening parenthesis.
- *
- * Combining parenthesis handling with the base level of regular expression
- * is a trifle forced, but the need to tie the tails of the branches to what
- * follows makes it hard to avoid.
- */
-static char *
-reg(paren, flagp)
-int paren; /* Parenthesized? */
-int *flagp;
-{
- register char *ret;
- register char *br;
- register char *ender;
- register int parno = 0;
- int flags;
-
- *flagp = HASWIDTH; /* Tentatively. */
-
- /* Make an OPEN node, if parenthesized. */
- if (paren) {
- if (regnpar >= NSUBEXP)
- FAIL("too many ()");
- parno = regnpar;
- regnpar++;
- ret = regnode(OPEN+parno);
- } else
- ret = NULL;
-
- /* Pick up the branches, linking them together. */
- br = regbranch(&flags);
- if (br == NULL)
- return(NULL);
- if (ret != NULL)
- regtail(ret, br); /* OPEN -> first. */
- else
- ret = br;
- if (!(flags&HASWIDTH))
- *flagp &= ~HASWIDTH;
- *flagp |= flags&SPSTART;
- while (*regparse == '|') {
- regparse++;
- br = regbranch(&flags);
- if (br == NULL)
- return(NULL);
- regtail(ret, br); /* BRANCH -> BRANCH. */
- if (!(flags&HASWIDTH))
- *flagp &= ~HASWIDTH;
- *flagp |= flags&SPSTART;
- }
-
- /* Make a closing node, and hook it on the end. */
- ender = regnode((paren) ? CLOSE+parno : END);
- regtail(ret, ender);
-
- /* Hook the tails of the branches to the closing node. */
- for (br = ret; br != NULL; br = regnext(br))
- regoptail(br, ender);
-
- /* Check for proper termination. */
- if (paren && *regparse++ != ')') {
- FAIL("unmatched ()");
- } else if (!paren && *regparse != '\0') {
- if (*regparse == ')') {
- FAIL("unmatched ()");
- } else
- FAIL("junk on end"); /* "Can't happen". */
- /* NOTREACHED */
- }
-
- return(ret);
-}
-
-/*
- - regbranch - one alternative of an | operator
- *
- * Implements the concatenation operator.
- */
-static char *
-regbranch(flagp)
-int *flagp;
-{
- register char *ret;
- register char *chain;
- register char *latest;
- int flags;
-
- *flagp = WORST; /* Tentatively. */
-
- ret = regnode(BRANCH);
- chain = NULL;
- while (*regparse != '\0' && *regparse != '|' && *regparse != ')') {
- latest = regpiece(&flags);
- if (latest == NULL)
- return(NULL);
- *flagp |= flags&HASWIDTH;
- if (chain == NULL) /* First piece. */
- *flagp |= flags&SPSTART;
- else
- regtail(chain, latest);
- chain = latest;
- }
- if (chain == NULL) /* Loop ran zero times. */
- (void) regnode(NOTHING);
-
- return(ret);
-}
-
-/*
- - regpiece - something followed by possible [*+?]
- *
- * Note that the branching code sequences used for ? and the general cases
- * of * and + are somewhat optimized: they use the same NOTHING node as
- * both the endmarker for their branch list and the body of the last branch.
- * It might seem that this node could be dispensed with entirely, but the
- * endmarker role is not redundant.
- */
-static char *
-regpiece(flagp)
-int *flagp;
-{
- register char *ret;
- register char op;
- register char *next;
- int flags;
-
- ret = regatom(&flags);
- if (ret == NULL)
- return(NULL);
-
- op = *regparse;
- if (!ISMULT(op)) {
- *flagp = flags;
- return(ret);
- }
-
- if (!(flags&HASWIDTH) && op != '?')
- FAIL("*+ operand could be empty");
- *flagp = (op != '+') ? (WORST|SPSTART) : (WORST|HASWIDTH);
-
- if (op == '*' && (flags&SIMPLE))
- reginsert(STAR, ret);
- else if (op == '*') {
- /* Emit x* as (x&|), where & means "self". */
- reginsert(BRANCH, ret); /* Either x */
- regoptail(ret, regnode(BACK)); /* and loop */
- regoptail(ret, ret); /* back */
- regtail(ret, regnode(BRANCH)); /* or */
- regtail(ret, regnode(NOTHING)); /* null. */
- } else if (op == '+' && (flags&SIMPLE))
- reginsert(PLUS, ret);
- else if (op == '+') {
- /* Emit x+ as x(&|), where & means "self". */
- next = regnode(BRANCH); /* Either */
- regtail(ret, next);
- regtail(regnode(BACK), ret); /* loop back */
- regtail(next, regnode(BRANCH)); /* or */
- regtail(ret, regnode(NOTHING)); /* null. */
- } else if (op == '?') {
- /* Emit x? as (x|) */
- reginsert(BRANCH, ret); /* Either x */
- regtail(ret, regnode(BRANCH)); /* or */
- next = regnode(NOTHING); /* null. */
- regtail(ret, next);
- regoptail(ret, next);
- }
- regparse++;
- if (ISMULT(*regparse))
- FAIL("nested *?+");
-
- return(ret);
-}
-
-/*
- - regatom - the lowest level
- *
- * Optimization: gobbles an entire sequence of ordinary characters so that
- * it can turn them into a single node, which is smaller to store and
- * faster to run. Backslashed characters are exceptions, each becoming a
- * separate node; the code is simpler that way and it's not worth fixing.
- */
-static char *
-regatom(flagp)
-int *flagp;
-{
- register char *ret;
- int flags;
-
- *flagp = WORST; /* Tentatively. */
-
- switch (*regparse++) {
- case '^':
- ret = regnode(BOL);
- break;
- case '$':
- ret = regnode(EOL);
- break;
- case '.':
- ret = regnode(ANY);
- *flagp |= HASWIDTH|SIMPLE;
- break;
- case '[': {
- register int clss;
- register int classend;
-
- if (*regparse == '^') { /* Complement of range. */
- ret = regnode(ANYBUT);
- regparse++;
- } else
- ret = regnode(ANYOF);
- if (*regparse == ']' || *regparse == '-')
- regc(*regparse++);
- while (*regparse != '\0' && *regparse != ']') {
- if (*regparse == '-') {
- regparse++;
- if (*regparse == ']' || *regparse == '\0')
- regc('-');
- else {
- clss = UCHARAT(regparse-2)+1;
- classend = UCHARAT(regparse);
- if (clss > classend+1)
- FAIL("invalid [] range");
- for (; clss <= classend; clss++)
- regc((char)clss);
- regparse++;
- }
- } else
- regc(*regparse++);
- }
- regc('\0');
- if (*regparse != ']')
- FAIL("unmatched []");
- regparse++;
- *flagp |= HASWIDTH|SIMPLE;
- }
- break;
- case '(':
- ret = reg(1, &flags);
- if (ret == NULL)
- return(NULL);
- *flagp |= flags&(HASWIDTH|SPSTART);
- break;
- case '\0':
- case '|':
- case ')':
- FAIL("internal urp"); /* Supposed to be caught earlier. */
- /* NOTREACHED */
- break;
- case '?':
- case '+':
- case '*':
- FAIL("?+* follows nothing");
- /* NOTREACHED */
- break;
- case '\\':
- if (*regparse == '\0')
- FAIL("trailing \\");
- ret = regnode(EXACTLY);
- regc(*regparse++);
- regc('\0');
- *flagp |= HASWIDTH|SIMPLE;
- break;
- default: {
- register int len;
- register char ender;
-
- regparse--;
- len = strcspn(regparse, META);
- if (len <= 0)
- FAIL("internal disaster");
- ender = *(regparse+len);
- if (len > 1 && ISMULT(ender))
- len--; /* Back off clear of ?+* operand. */
- *flagp |= HASWIDTH;
- if (len == 1)
- *flagp |= SIMPLE;
- ret = regnode(EXACTLY);
- while (len > 0) {
- regc(*regparse++);
- len--;
- }
- regc('\0');
- }
- break;
- }
-
- return(ret);
-}
-
-/*
- - regnode - emit a node
- */
-static char * /* Location. */
-regnode(op)
-int op;
-{
- register char *ret;
- register char *ptr;
-
- ret = regcode;
- if (ret == ®dummy) {
- regsize += 3;
- return(ret);
- }
-
- ptr = ret;
- *ptr++ = (char)op;
- *ptr++ = '\0'; /* Null "next" pointer. */
- *ptr++ = '\0';
- regcode = ptr;
-
- return(ret);
-}
-
-/*
- - regc - emit (if appropriate) a byte of code
- */
-static void
-regc(b)
-int b;
-{
- if (regcode != ®dummy)
- *regcode++ = (char)b;
- else
- regsize++;
-}
-
-/*
- - reginsert - insert an operator in front of already-emitted operand
- *
- * Means relocating the operand.
- */
-static void
-reginsert(op, opnd)
-int op;
-char *opnd;
-{
- register char *src;
- register char *dst;
- register char *place;
-
- if (regcode == ®dummy) {
- regsize += 3;
- return;
- }
-
- src = regcode;
- regcode += 3;
- dst = regcode;
- while (src > opnd)
- *--dst = *--src;
-
- place = opnd; /* Op node, where operand used to be. */
- *place++ = (char)op;
- *place++ = '\0';
- *place = '\0';
-}
-
-/*
- - regtail - set the next-pointer at the end of a node chain
- */
-static void
-regtail(p, val)
-char *p;
-char *val;
-{
- register char *scan;
- register char *temp;
- register int offset;
-
- if (p == ®dummy)
- return;
-
- /* Find last node. */
- scan = p;
- for (;;) {
- temp = regnext(scan);
- if (temp == NULL)
- break;
- scan = temp;
- }
-
- if (OP(scan) == BACK)
- offset = scan - val;
- else
- offset = val - scan;
- *(scan+1) = (char)(offset>>8)&0377;
- *(scan+2) = (char)offset&0377;
-}
-
-/*
- - regoptail - regtail on operand of first argument; nop if operandless
- */
-static void
-regoptail(p, val)
-char *p;
-char *val;
-{
- /* "Operandless" and "op != BRANCH" are synonymous in practice. */
- if (p == NULL || p == ®dummy || OP(p) != BRANCH)
- return;
- regtail(OPERAND(p), val);
-}
-
-/*
- * regexec and friends
- */
-
-/*
- * Global work variables for regexec().
- */
-static char *reginput; /* String-input pointer. */
-NOTSTATIC char *regbol; /* Beginning of input, for ^ check. */
-static char **regstartp; /* Pointer to startp array. */
-static char **regendp; /* Ditto for endp. */
-
-/*
- * Forwards.
- */
-
-NOTSTATIC int regtry();
-STATIC int regmatch();
-STATIC int regrepeat();
-
-#ifdef DEBUG
-int regnarrate = 0;
-void regdump();
-STATIC char *regprop();
-#endif
-
-#if 0
-/*
- - regexec - match a regexp against a string
- */
-int
-regexec(prog, string, stringlength, matchlength)
-register regexp *prog;
-register char *string; /* note: CURRENTLY ASSUMED TO BE NULL-TERMINATED!!! */
-int stringlength; /* length of string */
-int *matchlength; /* number of chars matched (or to be skipped) */
- /* set when MATCH or CANT_MATCH */
-{
- register char *s;
- extern char *strchr();
-
- /* Be paranoid... */
- if (prog == NULL || string == NULL) {
- regerror("NULL parameter");
- return(EXP_TCLERROR);
- }
-
- /* Check validity of program. */
- if (UCHARAT(prog->program) != MAGIC) {
- regerror("corrupted program");
- return(EXP_KM_ERROR);
- }
-
-#if THIS_RUINS_EXP
-/* no need for this shortcut anyway */
- /* If there is a "must appear" string, look for it. */
- if (prog->regmust != NULL) {
- s = string;
- while ((s = strchr(s, prog->regmust[0])) != NULL) {
- if (strncmp(s, prog->regmust, prog->regmlen) == 0)
- break; /* Found it. */
- s++;
- }
- if (s == NULL) /* Not present. */
- return(0);
- }
-#endif
-
- /* Mark beginning of line for ^ . */
- regbol = string;
-
- /* Simplest case: anchored match need be tried only once. */
- if (prog->reganch) {
- int r = regtry(prog,string,matchlength);
- if (r == CANT_MATCH) *matchlength = stringlength;
- return(r);
- }
-
- /* Messy cases: unanchored match. */
- s = string;
- if (prog->regstart != '\0') {
- register char *s2 = s;
-
- /* We know what char it must start with. */
- while (1) {
- int r;
-
- s2 = strchr(s2,prog->regstart);
- if (s2 == 0) {
- *matchlength = stringlength;
- return(CANT_MATCH);
- }
- r = regtry(prog,s2,matchlength);
- if (r == CANT_MATCH) {
- s2++;
- continue;
- }
- if (s2 == s) return(r);
- *matchlength = s2-s;
- return CANT_MATCH;
- }
- } else {
- /* We don't -- general case. */
- register char *s2 = s;
- int r = regtry(prog,s,matchlength);
- if (r == EXP_MATCH) return(r);
- else if (r == EXP_CANMATCH) return(r);
- /* at this point, we know some characters at front */
- /* of string don't match */
- for (s2++;*s2;s2++) {
- r = regtry(prog,s2,matchlength);
- if (r == CANT_MATCH) continue;
- /* if we match or can_match, say cant_match and */
- /* record the number of chars at front that don't match */
- *matchlength = s2-s;
- return(CANT_MATCH);
- }
- /* made it thru string with CANT_MATCH all the way */
- *matchlength = stringlength;
- return(CANT_MATCH);
- }
-}
-#endif
-
-/*
- - regtry - try match at specific point
- */
-/* return CAN_MATCH, CANT_MATCH or MATCH */
-int /* 0 failure, 1 success */
-regtry(prog, string, matchlength)
-Expect_regexp *prog;
-char *string;
-int *matchlength; /* only set for MATCH */
-{
- register int i;
- register char **sp;
- register char **ep;
- int r; /* result of regmatch */
-
- reginput = string;
- regstartp = prog->startp;
- regendp = prog->endp;
-
- sp = prog->startp;
- ep = prog->endp;
- for (i = NSUBEXP; i > 0; i--) {
- *sp++ = NULL;
- *ep++ = NULL;
- }
- r = regmatch(prog->program + 1);
- if (EXP_MATCH == r) {
- prog->startp[0] = string;
- prog->endp[0] = reginput;
- *matchlength = reginput-string;
- return(EXP_MATCH);
- }
- return(r); /* CAN_MATCH or CANT_MATCH */
-}
-
-/*
- - regmatch - main matching routine
- *
- * Conceptually the strategy is simple: check to see whether the current
- * node matches, call self recursively to see whether the rest matches,
- * and then act accordingly. In practice we make some effort to avoid
- * recursion, in particular by going through "ordinary" nodes (that don't
- * need to know whether the rest of the match failed) by a loop instead of
- * by recursion.
- */
-/* returns CAN, CANT or MATCH */
-static int /* 0 failure, 1 success */
-regmatch(prog)
-char *prog;
-{
- register char *scan; /* Current node. */
- char *next; /* Next node. */
-#ifndef strchr /* May be #defined to something else */
- extern char *strchr();
-#endif
-
- scan = prog;
-#ifdef DEBUG
- if (scan != NULL && regnarrate)
- fprintf(stderr, "%s(\n", regprop(scan));
-#endif
- while (scan != NULL) {
-#ifdef DEBUG
- if (regnarrate)
- fprintf(stderr, "%s...\n", regprop(scan));
-#endif
- next = regnext(scan);
-
- switch (OP(scan)) {
- case BOL:
- if (reginput != regbol)
-/* return(0);*/
- return(EXP_CANTMATCH);
- break;
- case EOL:
- if (*reginput != '\0')
-/* return(0);*/
-/* note this implies that "$" must match everything received to this point! */
- return(EXP_CANTMATCH);
- break;
- case ANY:
- if (*reginput == '\0')
-/* return(0);*/
- return(EXP_CANMATCH);
- reginput++;
- break;
- case EXACTLY: {
-/* register int len;*/
- register char *opnd;
-
- opnd = OPERAND(scan);
-
- /* this section of code is totally rewritten - DEL */
- /* group of literal chars in pattern */
- /* compare each one */
- do {
- if (*opnd != *reginput) {
- if (*reginput == '\0') {
- return EXP_CANMATCH;
- } else return EXP_CANTMATCH;
- }
-
- reginput++;
- opnd++;
- } while (*opnd != '\0');
- }
- break;
- case ANYOF:
-/* if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) == NULL)
- return(0);
-*/
- if (*reginput == '\0')
- return(EXP_CANMATCH);
- if (strchr(OPERAND(scan),*reginput) == NULL)
- return(EXP_CANTMATCH);
- reginput++;
- break;
- case ANYBUT:
-/* if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) != NULL)
- return(0);
-*/
- if (*reginput == '\0')
- return(EXP_CANMATCH);
- if (strchr(OPERAND(scan),*reginput) != NULL)
- return(EXP_CANTMATCH);
- reginput++;
- break;
- case NOTHING:
- break;
- case BACK:
- break;
- case OPEN+1:
- case OPEN+2:
- case OPEN+3:
- case OPEN+4:
- case OPEN+5:
- case OPEN+6:
- case OPEN+7:
- case OPEN+8:
- case OPEN+9: {
- register int no;
- register char *save;
- int r; /* result of regmatch */
-
- doOpen:
- no = OP(scan) - OPEN;
- save = reginput;
-
- r = regmatch(next);
- if (r == EXP_MATCH) {
- /*
- * Don't set startp if some later
- * invocation of the same parentheses
- * already has.
- */
- if (regstartp[no] == NULL)
- regstartp[no] = save;
- }
- return(r);
- }
- /* NOTREACHED */
- break;
- case CLOSE+1:
- case CLOSE+2:
- case CLOSE+3:
- case CLOSE+4:
- case CLOSE+5:
- case CLOSE+6:
- case CLOSE+7:
- case CLOSE+8:
- case CLOSE+9: {
- register int no;
- register char *save;
- int r; /* result of regmatch */
-
- doClose:
- no = OP(scan) - CLOSE;
- save = reginput;
-
- r = regmatch(next);
- if (r == EXP_MATCH) {
- /*
- * Don't set endp if some later
- * invocation of the same parentheses
- * already has.
- */
- if (regendp[no] == NULL)
- regendp[no] = save;
- }
- return(r);
- }
- /* NOTREACHED */
- break;
- case BRANCH: {
- register char *save;
- int match_status;
-
- if (OP(next) != BRANCH) /* No choice. */
- next = OPERAND(scan); /* Avoid recursion. */
- else {
- match_status = EXP_CANTMATCH;
-
- do {
- int r;
-
- save = reginput;
- r = regmatch(OPERAND(scan));
- if (r == EXP_MATCH) return(r);
- if (r == EXP_CANMATCH) {
- match_status = r;
- }
- reginput = save;
- scan = regnext(scan);
- } while (scan != NULL && OP(scan) == BRANCH);
- return(match_status);
- /* NOTREACHED */
- }
- }
- /* NOTREACHED */
- break;
- case STAR:
- case PLUS: {
- register char nextch;
- register int no;
- register char *save;
- register int min;
- int match_status;
-
- /*
- * Lookahead to avoid useless match attempts
- * when we know what character comes next.
- */
- match_status = EXP_CANTMATCH;
- nextch = '\0';
- if (OP(next) == EXACTLY)
- nextch = *OPERAND(next);
- min = (OP(scan) == STAR) ? 0 : 1;
- save = reginput;
- no = regrepeat(OPERAND(scan));
- while (no >= min) {
- /* If it could work, try it. */
- /* 3rd condition allows for CAN_MATCH */
- if (nextch == '\0' || *reginput == nextch || *reginput == '\0') {
- int r = regmatch(next);
- if (r == EXP_MATCH)
- return(EXP_MATCH);
- if (r == EXP_CANMATCH)
- match_status = r;
- }
- /* Couldn't or didn't -- back up. */
- no--;
- reginput = save + no;
- }
- return(match_status);
- }
- /* NOTREACHED */
- break;
- case END:
- return(EXP_MATCH); /* Success! */
- /* NOTREACHED */
- break;
- default:
- if (OP(scan) > OPEN && OP(scan) < OPEN+NSUBEXP) {
- goto doOpen;
- } else if (OP(scan) > CLOSE && OP(scan) < CLOSE+NSUBEXP) {
- goto doClose;
- }
- regerror("memory corruption");
- return(EXP_TCLERROR);
- /* NOTREACHED */
- break;
- }
-
- scan = next;
- }
-
- /*
- * We get here only if there's trouble -- normally "case END" is
- * the terminating point.
- */
- regerror("corrupted pointers");
- return(EXP_TCLERROR);
-}
-
-/*
- - regrepeat - repeatedly match something simple, report how many
- */
-static int
-regrepeat(p)
-char *p;
-{
- register int count = 0;
- register char *scan;
- register char *opnd;
-#ifndef strchr /* May be #defined to something else */
-/*DEL*/ extern char *strchr();
-#endif
-
- scan = reginput;
- opnd = OPERAND(p);
- switch (OP(p)) {
- case ANY:
- count = strlen(scan);
- scan += count;
- break;
- case EXACTLY:
- while (*opnd == *scan) {
- count++;
- scan++;
- }
- break;
- case ANYOF:
- while (*scan != '\0' && strchr(opnd, *scan) != NULL) {
- count++;
- scan++;
- }
- break;
- case ANYBUT:
- while (*scan != '\0' && strchr(opnd, *scan) == NULL) {
- count++;
- scan++;
- }
- break;
- default: /* Oh dear. Called inappropriately. */
- regerror("internal foulup");
- count = 0; /* Best compromise. */
- break;
- }
- reginput = scan;
-
- return(count);
-}
-
-/*
- - regnext - dig the "next" pointer out of a node
- */
-static char *
-regnext(p)
-register char *p;
-{
- register int offset;
-
- if (p == ®dummy)
- return(NULL);
-
- offset = NEXT(p);
- if (offset == 0)
- return(NULL);
-
- if (OP(p) == BACK)
- return(p-offset);
- else
- return(p+offset);
-}
-
-#ifdef DEBUG
-
-STATIC char *regprop();
-
-/*
- - regdump - dump a regexp onto stdout in vaguely comprehensible form
- */
-void
-regdump(r)
-Expect_regexp *r;
-{
- register char *s;
- register char op = EXACTLY; /* Arbitrary non-END op. */
- register char *next;
- extern char *strchr();
-
-
- s = r->program + 1;
- while (op != END) { /* While that wasn't END last time... */
- op = OP(s);
- printf("%2d%s", s-r->program, regprop(s)); /* Where, what. */
- next = regnext(s);
- if (next == NULL) /* Next ptr. */
- printf("(0)");
- else
- printf("(%d)", (s-r->program)+(next-s));
- s += 3;
- if (op == ANYOF || op == ANYBUT || op == EXACTLY) {
- /* Literal string, where present. */
- while (*s != '\0') {
- putchar(*s);
- s++;
- }
- s++;
- }
- putchar('\n');
- }
-
- /* Header fields of interest. */
- if (r->regstart != '\0')
- printf("start `%c' ", r->regstart);
- if (r->reganch)
- printf("anchored ");
- if (r->regmust != NULL)
- printf("must have \"%s\"", r->regmust);
- printf("\n");
-}
-
-/*
- - regprop - printable representation of opcode
- */
-static char *
-regprop(op)
-char *op;
-{
- register char *p;
- static char buf[50];
-
- (void) strcpy(buf, ":");
-
- switch (OP(op)) {
- case BOL:
- p = "BOL";
- break;
- case EOL:
- p = "EOL";
- break;
- case ANY:
- p = "ANY";
- break;
- case ANYOF:
- p = "ANYOF";
- break;
- case ANYBUT:
- p = "ANYBUT";
- break;
- case BRANCH:
- p = "BRANCH";
- break;
- case EXACTLY:
- p = "EXACTLY";
- break;
- case NOTHING:
- p = "NOTHING";
- break;
- case BACK:
- p = "BACK";
- break;
- case END:
- p = "END";
- break;
- case OPEN+1:
- case OPEN+2:
- case OPEN+3:
- case OPEN+4:
- case OPEN+5:
- case OPEN+6:
- case OPEN+7:
- case OPEN+8:
- case OPEN+9:
- sprintf(buf+strlen(buf), "OPEN%d", OP(op)-OPEN);
- p = NULL;
- break;
- case CLOSE+1:
- case CLOSE+2:
- case CLOSE+3:
- case CLOSE+4:
- case CLOSE+5:
- case CLOSE+6:
- case CLOSE+7:
- case CLOSE+8:
- case CLOSE+9:
- sprintf(buf+strlen(buf), "CLOSE%d", OP(op)-CLOSE);
- p = NULL;
- break;
- case STAR:
- p = "STAR";
- break;
- case PLUS:
- p = "PLUS";
- break;
- default:
- if (OP(op) > OPEN && OP(op) < OPEN+NSUBEXP) {
- sprintf(buf+strlen(buf), "OPEN%d", OP(op)-OPEN);
- p = NULL;
- break;
- } else if (OP(op) > CLOSE && OP(op) < CLOSE+NSUBEXP) {
- sprintf(buf+strlen(buf), "CLOSE%d", OP(op)-CLOSE);
- p = NULL;
- } else {
- Expect_TclRegError("corrupted opcode");
- }
- break;
- }
- if (p != NULL)
- (void) strcat(buf, p);
- return(buf);
-}
-#endif
-
-/*
- * The following is provided for those people who do not have strcspn() in
- * their C libraries. They should get off their butts and do something
- * about it; at least one public-domain implementation of those (highly
- * useful) string routines has been published on Usenet.
- */
-#ifdef STRCSPN
-/*
- * strcspn - find length of initial segment of s1 consisting entirely
- * of characters not from s2
- */
-
-static int
-strcspn(s1, s2)
-char *s1;
-char *s2;
-{
- register char *scan1;
- register char *scan2;
- register int count;
-
- count = 0;
- for (scan1 = s1; *scan1 != '\0'; scan1++) {
- for (scan2 = s2; *scan2 != '\0';) /* ++ moved down. */
- if (*scan1 == *scan2++)
- return(count);
- count++;
- }
- return(count);
-}
-#endif
+++ /dev/null
-/* access to regexp internals */
-#define regbol exp_regbol
-#define regtry exp_regtry
-#define regexec exp_regexec
-#define regerror TclRegError
-extern char *regbol;
-int regtry();
-
+++ /dev/null
-/* translate.h - preface globals that appear in the expect library
-with "exp_" so we don't conflict with the user. This saves me having
-to use exp_XXX throughout the expect program itself, which was written
-well before the library when I didn't have to worry about name conflicts.
-
-Written by: Don Libes, 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.
-*/
-
-#define errorlog exp_errorlog
-#define debuglog exp_debuglog
-#define is_debugging exp_is_debugging
-#define logfile exp_logfile
-#define debugfile exp_debugfile
-#define loguser exp_loguser
-#define logfile_all exp_logfile_all
-
-#define getptymaster exp_getptymaster
-#define getptyslave exp_getptyslave
+++ /dev/null
-/* exp_select.c - select() interface for Expect
-
-Written by: Don Libes, NIST, 2/6/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.
-
-*/
-
-/* suppress file-empty warnings produced by some compilers */
-void exp_unused() {}
-
-#if 0 /* WHOLE FILE!!!! */
-#include "expect_cf.h"
-#include <stdio.h>
-#include <errno.h>
-#include <sys/types.h>
-
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-
-#ifdef HAVE_SYSSELECT_H
-# include <sys/select.h> /* Intel needs this for timeval */
-#endif
-
-#ifdef HAVE_PTYTRAP
-# include <sys/ptyio.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#ifdef _AIX
-/* AIX has some unusual definition of FD_SET */
-#include <sys/select.h>
-#endif
-
-#if !defined( FD_SET ) && defined( HAVE_SYS_BSDTYPES_H )
- /* like AIX, ISC has it's own definition of FD_SET */
-# include <sys/bsdtypes.h>
-#endif /* ! FD_SET && HAVE_SYS_BSDTYPES_H */
-
-#include "tcl.h"
-#include "exp_prog.h"
-#include "exp_command.h" /* for struct exp_f defs */
-#include "exp_event.h"
-
-#ifdef HAVE_SYSCONF_H
-#include <sys/sysconfig.h>
-#endif
-
-#ifndef FD_SET
-#define FD_SET(fd,fdset) (fdset)->fds_bits[0] |= (1<<(fd))
-#define FD_CLR(fd,fdset) (fdset)->fds_bits[0] &= ~(1<<(fd))
-#define FD_ZERO(fdset) (fdset)->fds_bits[0] = 0
-#define FD_ISSET(fd,fdset) (((fdset)->fds_bits[0]) & (1<<(fd)))
-#ifndef AUX2
-typedef struct fd_set {
- long fds_bits[1];
- /* any implementation so pathetic as to not define FD_SET will just */
- /* have to suffer with only 32 bits worth of fds */
-} fd_set;
-#endif /* AUX2 */
-#endif
-
-static struct timeval zerotime = {0, 0};
-static struct timeval anytime = {0, 0}; /* can be changed by user */
-
-/* returns status, one of EOF, TIMEOUT, ERROR or DATA */
-int
-exp_get_next_event(interp,masters, n,master_out,timeout,key)
-Tcl_Interp *interp;
-int *masters;
-int n; /* # of masters */
-int *master_out; /* 1st event master, not set if none */
-int timeout; /* seconds */
-int key;
-{
- static rr = 0; /* round robin ptr */
-
- int i; /* index into in-array */
- struct timeval *t;
-
- fd_set rdrs;
- fd_set excep;
-/* FIXME: This is really gross, but the folks at Lynx said their select is
- * way hosed and to ignore all exceptions.
- */
-#ifdef __Lynx__
-#define EXCEP 0
-#else
-#define EXCEP &excep
-#endif
-
- for (i=0;i<n;i++) {
- struct exp_f *f;
- int m;
-
- rr++;
- if (rr >= n) rr = 0;
-
- m = masters[rr];
- f = exp_fs + m;
-
- if (f->key != key) {
- f->key = key;
- f->force_read = FALSE;
- *master_out = m;
- return(EXP_DATA_OLD);
- } else if ((!f->force_read) && (f->size != 0)) {
- *master_out = m;
- return(EXP_DATA_OLD);
- }
- }
-
- if (timeout >= 0) {
- t = &anytime;
- t->tv_sec = timeout;
- } else {
- t = NULL;
- }
-
- restart:
- if (Tcl_AsyncReady()) {
- int rc = Tcl_AsyncInvoke(interp,TCL_OK);
- if (rc != TCL_OK) return(exp_tcl2_returnvalue(rc));
-
- /* anything in the environment could have changed */
- return EXP_RECONFIGURE;
- }
-
- FD_ZERO(&rdrs);
- FD_ZERO(&excep);
- for (i = 0;i < n;i++) {
- FD_SET(masters[i],&rdrs);
- FD_SET(masters[i],&excep);
- }
-
- /* The reason all fd masks are (seemingly) redundantly cast to */
- /* SELECT_MASK_TYPE is that the HP defines its mask in terms of */
- /* of int * and yet defines FD_SET in terms of fd_set. */
-
- if (-1 == select(exp_fd_max+1,
- (SELECT_MASK_TYPE *)&rdrs,
- (SELECT_MASK_TYPE *)0,
- (SELECT_MASK_TYPE *)EXCEP,
- t)) {
- /* window refreshes trigger EINTR, ignore */
- if (errno == EINTR) goto restart;
- else if (errno == EBADF) {
- /* someone is rotten */
- for (i=0;i<n;i++) {
- fd_set suspect;
- FD_ZERO(&suspect);
- FD_SET(masters[i],&suspect);
- if (-1 == select(exp_fd_max+1,
- (SELECT_MASK_TYPE *)&suspect,
- (SELECT_MASK_TYPE *)0,
- (SELECT_MASK_TYPE *)0,
- &zerotime)) {
- exp_error(interp,"invalid spawn_id (%d)\r",masters[i]);
- return(EXP_TCLERROR);
- }
- }
- } else {
- /* not prepared to handle anything else */
- exp_error(interp,"select: %s\r",Tcl_PosixError(interp));
- return(EXP_TCLERROR);
- }
- }
-
- for (i=0;i<n;i++) {
- rr++;
- if (rr >= n) rr = 0; /* ">" catches previous readys that */
- /* used more fds then we're using now */
-
- if (FD_ISSET(masters[rr],&rdrs)) {
- *master_out = masters[rr];
- return(EXP_DATA_NEW);
-/*#ifdef HAVE_PTYTRAP*/
- } else if (FD_ISSET(masters[rr], &excep)) {
-#ifndef HAVE_PTYTRAP
- *master_out = masters[rr];
- return(EXP_EOF);
-#else
- struct request_info ioctl_info;
- if (ioctl(masters[rr],TIOCREQCHECK,&ioctl_info) < 0) {
- exp_debuglog("ioctl error on TIOCREQCHECK: %s",Tcl_ErrnoMsg(errno));
- break;
- }
- if (ioctl_info.request == TIOCCLOSE) {
- /* eof */
- *master_out = masters[rr];
- return(EXP_EOF);
- }
- if (ioctl(masters[rr], TIOCREQSET, &ioctl_info) < 0)
- exp_debuglog("ioctl error on TIOCREQSET after ioctl or open on slave: %s", Tcl_ErrnoMsg(errno));
- /* presumably, we trapped an open here */
- goto restart;
-#endif /* HAVE_PTYTRAP */
- }
- }
- return(EXP_TIMEOUT);
-}
-
-/*ARGSUSED*/
-int
-exp_get_next_event_info(interp,fd,ready_mask)
-Tcl_Interp *interp;
-int fd;
-int ready_mask;
-{
- /* this function is only used when running with Tk */
- /* hence, it is merely a stub in this file but to */
- /* pacify lint, return something */
- return 0;
-}
-
-int /* returns TCL_XXX */
-exp_dsleep(interp,sec)
-Tcl_Interp *interp;
-double sec;
-{
- struct timeval t;
-
- t.tv_sec = sec;
- t.tv_usec = (sec - t.tv_sec) * 1000000L;
- restart:
- if (Tcl_AsyncReady()) {
- int rc = Tcl_AsyncInvoke(interp,TCL_OK);
- if (rc != TCL_OK) return rc;
- }
- if (-1 == select(1,
- (SELECT_MASK_TYPE *)0,
- (SELECT_MASK_TYPE *)0,
- (SELECT_MASK_TYPE *)0,
- &t)
- && errno == EINTR)
- goto restart;
- return TCL_OK;
-}
-
-#if 0
-int /* returns TCL_XXX */
-exp_usleep(interp,usec)
-Tcl_Interp *interp;
-long usec; /* microseconds */
-{
- struct timeval t;
-
- t.tv_sec = usec/1000000L;
- t.tv_usec = usec%1000000L;
- restart:
- if (Tcl_AsyncReady()) {
- int rc = Tcl_AsyncInvoke(interp,TCL_OK);
- if (rc != TCL_OK) return(exp_tcl2_returnvalue(rc));
- }
- if (-1 == select(1,
- (SELECT_MASK_TYPE *)0,
- (SELECT_MASK_TYPE *)0,
- (SELECT_MASK_TYPE *)0,
- &t)
- && errno == EINTR)
- goto restart;
- return TCL_OK;
-}
-#endif /*0*/
-
-/* set things up for later calls to event handler */
-void
-exp_init_event()
-{
-#if 0
-#ifdef _SC_OPEN_MAX
- maxfds = sysconf(_SC_OPEN_MAX);
-#else
- maxfds = getdtablesize();
-#endif
-#endif
-
- exp_event_exit = 0;
-}
-#endif /* WHOLE FILE !!!! */
+++ /dev/null
-/*
- * tclUnixNotify.c --
- *
- * This file contains Unix-specific procedures for the notifier,
- * which is the lowest-level part of the Tcl event loop. This file
- * works together with ../generic/tclNotify.c.
- *
- * Copyright (c) 1995 Sun Microsystems, Inc.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- */
-
-static char sccsid[] = "@(#) tclUnixNotify.c 1.27 96/01/19 10:30:23";
-
-#include "tclInt.h"
-#include "tclPort.h"
-#include <signal.h>
-
-/*
- * The information below is used to provide read, write, and
- * exception masks to select during calls to Tcl_DoOneEvent.
- */
-
-static fd_mask checkMasks[3*MASK_SIZE];
- /* This array is used to build up the masks
- * to be used in the next call to select.
- * Bits are set in response to calls to
- * Tcl_WatchFile. */
-static fd_mask readyMasks[3*MASK_SIZE];
- /* This array reflects the readable/writable
- * conditions that were found to exist by the
- * last call to select. */
-static int numFdBits; /* Number of valid bits in checkMasks
- * (one more than highest fd for which
- * Tcl_WatchFile has been called). */
-\f
-/*
- *----------------------------------------------------------------------
- *
- * Tcl_WatchFile --
- *
- * Arrange for Tcl_DoOneEvent to include this file in the masks
- * for the next call to select. This procedure is invoked by
- * event sources, which are in turn invoked by Tcl_DoOneEvent
- * before it invokes select.
- *
- * Results:
- * None.
- *
- * Side effects:
- *
- * The notifier will generate a file event when the I/O channel
- * given by fd next becomes ready in the way indicated by mask.
- * If fd is already registered then the old mask will be replaced
- * with the new one. Once the event is sent, the notifier will
- * not send any more events about the fd until the next call to
- * Tcl_NotifyFile.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tcl_WatchFile(file, mask)
- Tcl_File file; /* Generic file handle for a stream. */
- int mask; /* OR'ed combination of TCL_READABLE,
- * TCL_WRITABLE, and TCL_EXCEPTION:
- * indicates conditions to wait for
- * in select. */
-{
- int fd, type, index;
- fd_mask bit;
-
- fd = (int) Tcl_GetFileInfo(file, &type);
-
- if (type != TCL_UNIX_FD) {
- panic("Tcl_WatchFile: unexpected file type");
- }
-
- if (fd >= FD_SETSIZE) {
- panic("Tcl_WatchFile can't handle file id %d", fd);
- }
-
- index = fd/(NBBY*sizeof(fd_mask));
- bit = 1 << (fd%(NBBY*sizeof(fd_mask)));
- if (mask & TCL_READABLE) {
- checkMasks[index] |= bit;
- }
- if (mask & TCL_WRITABLE) {
- (checkMasks+MASK_SIZE)[index] |= bit;
- }
- if (mask & TCL_EXCEPTION) {
- (checkMasks+2*(MASK_SIZE))[index] |= bit;
- }
- if (numFdBits <= fd) {
- numFdBits = fd+1;
- }
-}
-\f
-/*
- *----------------------------------------------------------------------
- *
- * Tcl_FileReady --
- *
- * Indicates what conditions (readable, writable, etc.) were
- * present on a file the last time the notifier invoked select.
- * This procedure is typically invoked by event sources to see
- * if they should queue events.
- *
- * Results:
- * The return value is 0 if none of the conditions specified by mask
- * was true for fd the last time the system checked. If any of the
- * conditions were true, then the return value is a mask of those
- * that were true.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-int
-Tcl_FileReady(file, mask)
- Tcl_File file; /* Generic file handle for a stream. */
- int mask; /* OR'ed combination of TCL_READABLE,
- * TCL_WRITABLE, and TCL_EXCEPTION:
- * indicates conditions caller cares about. */
-{
- int index, result, type, fd;
- fd_mask bit;
-
- fd = (int) Tcl_GetFileInfo(file, &type);
- if (type != TCL_UNIX_FD) {
- panic("Tcl_FileReady: unexpected file type");
- }
-
- index = fd/(NBBY*sizeof(fd_mask));
- bit = 1 << (fd%(NBBY*sizeof(fd_mask)));
- result = 0;
- if ((mask & TCL_READABLE) && (readyMasks[index] & bit)) {
- result |= TCL_READABLE;
- }
- if ((mask & TCL_WRITABLE) && ((readyMasks+MASK_SIZE)[index] & bit)) {
- result |= TCL_WRITABLE;
- }
- if ((mask & TCL_EXCEPTION) && ((readyMasks+(2*MASK_SIZE))[index] & bit)) {
- result |= TCL_EXCEPTION;
- }
- return result;
-}
-\f
-/*
- *----------------------------------------------------------------------
- *
- * Tcl_WaitForEvent --
- *
- * This procedure does the lowest level wait for events in a
- * platform-specific manner. It uses information provided by
- * previous calls to Tcl_WatchFile, plus the timePtr argument,
- * to determine what to wait for and how long to wait.
- *
- * Results:
- * None.
- *
- * Side effects:
- * May put the process to sleep for a while, depending on timePtr.
- * When this procedure returns, an event of interest to the application
- * has probably, but not necessarily, occurred.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tcl_WaitForEvent(timePtr)
- Tcl_Time *timePtr; /* Specifies the maximum amount of time
- * that this procedure should block before
- * returning. The time is given as an
- * interval, not an absolute wakeup time.
- * NULL means block forever. */
-{
- struct timeval timeout, *timeoutPtr;
- int numFound;
-
- memcpy((VOID *) readyMasks, (VOID *) checkMasks,
- 3*MASK_SIZE*sizeof(fd_mask));
- if (timePtr == NULL) {
- timeoutPtr = NULL;
- } else {
- timeoutPtr = &timeout;
- timeout.tv_sec = timePtr->sec;
- timeout.tv_usec = timePtr->usec;
- }
- numFound = select(numFdBits, (SELECT_MASK *) &readyMasks[0],
- (SELECT_MASK *) &readyMasks[MASK_SIZE],
- (SELECT_MASK *) &readyMasks[2*MASK_SIZE], timeoutPtr);
-
- /*
- * Some systems don't clear the masks after an error, so
- * we have to do it here.
- */
-
- if (numFound == -1) {
- memset((VOID *) readyMasks, 0, 3*MASK_SIZE*sizeof(fd_mask));
- }
-
- /*
- * Reset the check masks in preparation for the next call to
- * select.
- */
-
- numFdBits = 0;
- memset((VOID *) checkMasks, 0, 3*MASK_SIZE*sizeof(fd_mask));
-}
-\f
-/*
- *----------------------------------------------------------------------
- *
- * Tcl_Sleep --
- *
- * Delay execution for the specified number of milliseconds.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Time passes.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tcl_Sleep(ms)
- int ms; /* Number of milliseconds to sleep. */
-{
- static struct timeval delay;
- Tcl_Time before, after;
-
- /*
- * The only trick here is that select appears to return early
- * under some conditions, so we have to check to make sure that
- * the right amount of time really has elapsed. If it's too
- * early, go back to sleep again.
- */
-
- TclGetTime(&before);
- after = before;
- after.sec += ms/1000;
- after.usec += (ms%1000)*1000;
- if (after.usec > 1000000) {
- after.usec -= 1000000;
- after.sec += 1;
- }
- while (1) {
- delay.tv_sec = after.sec - before.sec;
- delay.tv_usec = after.usec - before.usec;
- if (delay.tv_usec < 0) {
- delay.tv_usec += 1000000;
- delay.tv_sec -= 1;
- }
-
- /*
- * Special note: must convert delay.tv_sec to int before comparing
- * to zero, since delay.tv_usec is unsigned on some platforms.
- */
-
- if ((((int) delay.tv_sec) < 0)
- || ((delay.tv_usec == 0) && (delay.tv_sec == 0))) {
- break;
- }
- (void) select(0, (SELECT_MASK *) 0, (SELECT_MASK *) 0,
- (SELECT_MASK *) 0, &delay);
- TclGetTime(&before);
- }
-}
-
-
-
-
-
-
-
-#if 0 /* WHOLE FILE */
-
-
-
-/* interact (with only one process) - give user keyboard control
-
-Written by: Don Libes, NIST, 2/6/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 file exists for deficient versions of UNIX that lack select,
-poll, or some other multiplexing hook. Instead, this code uses two
-processes per spawned process. One sends characters from the spawnee
-to the spawner; a second send chars the other way.
-
-This will work on any UNIX system. The only sacrifice is that it
-doesn't support multiple processes. Eventually, it should catch
-SIGCHLD on dead processes and do the right thing. But it is pretty
-gruesome to imagine so many processes to do all this. If you change
-it successfully, please mail back the changes to me. - Don
-*/
-
-#include "expect_cf.h"
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/time.h>
-
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-#include "tcl.h"
-#include "exp_prog.h"
-#include "exp_command.h" /* for struct exp_f defs */
-#include "exp_event.h"
-
-/*ARGSUSED*/
-void
-exp_arm_background_filehandler(m)
-int m;
-{
-}
-
-/*ARGSUSED*/
-void
-exp_disarm_background_filehandler(m)
-int m;
-{
-}
-
-/*ARGSUSED*/
-void
-exp_disarm_background_filehandler_force(m)
-int m;
-{
-}
-
-/*ARGSUSED*/
-void
-exp_unblock_background_filehandler(m)
-int m;
-{
-}
-
-/*ARGSUSED*/
-void
-exp_block_background_filehandler(m)
-int m;
-{
-}
-
-/*ARGSUSED*/
-void
-exp_event_disarm(fd)
-int fd;
-{
-}
-
-/* returns status, one of EOF, TIMEOUT, ERROR or DATA */
-/*ARGSUSED*/
-int
-exp_get_next_event(interp,masters, n,master_out,timeout,key)
-Tcl_Interp *interp;
-int *masters;
-int n; /* # of masters */
-int *master_out; /* 1st event master, not set if none */
-int timeout; /* seconds */
-int key;
-{
- int m;
- struct exp_f *f;
-
- if (n > 1) {
- exp_error(interp,"expect not compiled with multiprocess support");
- /* select a different INTERACT_TYPE in Makefile */
- return(TCL_ERROR);
- }
-
- m = *master_out = masters[0];
- f = exp_fs + m;
-
- if (f->key != key) {
- f->key = key;
- f->force_read = FALSE;
- return(EXP_DATA_OLD);
- } else if ((!f->force_read) && (f->size != 0)) {
- return(EXP_DATA_OLD);
- }
-
- return(EXP_DATA_NEW);
-}
-
-/*ARGSUSED*/
-int
-exp_get_next_event_info(interp,fd,ready_mask)
-Tcl_Interp *interp;
-int fd;
-int ready_mask;
-{
-}
-
-/* There is no portable way to do sub-second sleeps on such a system, so */
-/* do the next best thing (without a busy loop) and fake it: sleep the right */
-/* amount of time over the long run. Note that while "subtotal" isn't */
-/* reinitialized, it really doesn't matter for such a gross hack as random */
-/* scheduling pauses will easily introduce occasional one second delays. */
-int /* returns TCL_XXX */
-exp_dsleep(interp,sec)
-Tcl_Interp *interp;
-double sec;
-{
- static double subtotal = 0;
- int seconds;
-
- subtotal += sec;
- if (subtotal < 1) return TCL_OK;
- seconds = subtotal;
- subtotal -= seconds;
- restart:
- if (Tcl_AsyncReady()) {
- int rc = Tcl_AsyncInvoke(interp,TCL_OK);
- if (rc != TCL_OK) return(rc);
- }
- sleep(seconds);
- return TCL_OK;
-}
-
-#if 0
-/* There is no portable way to do sub-second sleeps on such a system, so */
-/* do the next best thing (without a busy loop) and fake it: sleep the right */
-/* amount of time over the long run. Note that while "subtotal" isn't */
-/* reinitialized, it really doesn't matter for such a gross hack as random */
-/* scheduling pauses will easily introduce occasional one second delays. */
-int /* returns TCL_XXX */
-exp_usleep(interp,usec)
-Tcl_Interp *interp;
-long usec; /* microseconds */
-{
- static subtotal = 0;
- int seconds;
-
- subtotal += usec;
- if (subtotal < 1000000) return TCL_OK;
- seconds = subtotal/1000000;
- subtotal = subtotal%1000000;
- restart:
- if (Tcl_AsyncReady()) {
- int rc = Tcl_AsyncInvoke(interp,TCL_OK);
- if (rc != TCL_OK) return(exp_tcl2_returnvalue(rc));
- }
- sleep(seconds);
- return TCL_OK;
-}
-#endif /*0*/
-
-/* set things up for later calls to event handler */
-void
-exp_init_event()
-{
- exp_event_exit = 0;
-}
-
-#endif /* WHOLE FILE! */
+++ /dev/null
-/* exp_strp.c - functions for exp_timestamp */
-/*
- * strftime.c
- *
- * Public-domain implementation of ANSI C library routine.
- *
- * It's written in old-style C for maximal portability.
- * However, since I'm used to prototypes, I've included them too.
- *
- * If you want stuff in the System V ascftime routine, add the SYSV_EXT define.
- * For extensions from SunOS, add SUNOS_EXT.
- * For stuff needed to implement the P1003.2 date command, add POSIX2_DATE.
- * For VMS dates, add VMS_EXT.
- * For complete POSIX semantics, add POSIX_SEMANTICS.
- *
- * The code for %c, %x, and %X now follows the 1003.2 specification for
- * the POSIX locale.
- * This version ignores LOCALE information.
- * It also doesn't worry about multi-byte characters.
- * So there.
- *
- * This file is also shipped with GAWK (GNU Awk), gawk specific bits of
- * code are included if GAWK is defined.
- *
- * Arnold Robbins <arnold@skeeve.atl.ga.us>
- * January, February, March, 1991
- * Updated March, April 1992
- * Updated April, 1993
- * Updated February, 1994
- * Updated May, 1994
- * Updated January 1995
- * Updated September 1995
- *
- * Fixes from ado@elsie.nci.nih.gov
- * February 1991, May 1992
- * Fixes from Tor Lillqvist tml@tik.vtt.fi
- * May, 1993
- * Further fixes from ado@elsie.nci.nih.gov
- * February 1994
- * %z code from chip@chinacat.unicom.com
- * Applied September 1995
- *
- *
- * Modified by Don Libes for Expect, 10/93 and 12/95.
- * Forced POSIX semantics.
- * Replaced inline/min/max stuff with a single range function.
- * Removed tzset stuff.
- * Commented out tzname stuff.
- *
- * According to Arnold, the current version of this code can ftp'd from
- * ftp.mathcs.emory.edu:/pub/arnold/strftime.shar.gz
- *
- */
-
-#include "expect_cf.h"
-#include "tcl.h"
-
-#include <stdio.h>
-#include <ctype.h>
-#include "string.h"
-
-/* according to Karl Vogel, time.h is insufficient on Pyramid */
-/* following is recommended by autoconf */
-
-#ifdef TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-# else
-# include <time.h>
-# endif
-#endif
-
-
-
-#include <sys/types.h>
-
-#define SYSV_EXT 1 /* stuff in System V ascftime routine */
-#define POSIX2_DATE 1 /* stuff in Posix 1003.2 date command */
-
-#if defined(POSIX2_DATE) && ! defined(SYSV_EXT)
-#define SYSV_EXT 1
-#endif
-
-#if defined(POSIX2_DATE)
-#define adddecl(stuff) stuff
-#else
-#define adddecl(stuff)
-#endif
-
-#ifndef __STDC__
-#define const
-
-extern char *getenv();
-static int weeknumber();
-adddecl(static int iso8601wknum();)
-#else
-
-#ifndef strchr
-extern char *strchr(const char *str, int ch);
-#endif
-extern char *getenv(const char *v);
-static int weeknumber(const struct tm *timeptr, int firstweekday);
-adddecl(static int iso8601wknum(const struct tm *timeptr);)
-#endif
-
-/* attempt to use strftime to compute timezone, else fallback to */
-/* less portable ways */
-#if !defined(HAVE_STRFTIME)
-# if defined(HAVE_SV_TIMEZONE)
-extern char *tzname[2];
-extern int daylight;
-# else
-# if defined(HAVE_TIMEZONE)
-
-char *
-zone_name (tp)
-struct tm *tp;
-{
- char *timezone ();
- struct timeval tv;
- struct timezone tz;
-
- gettimeofday (&tv, &tz);
-
- return timezone (tz.tz_minuteswest, tp->tm_isdst);
-}
-
-# endif /* HAVE_TIMEZONE */
-# endif /* HAVE_SV_TIMEZONE */
-#endif /* HAVE_STRFTIME */
-
-static int
-range(low,item,hi)
-int low, item, hi;
-{
- if (item < low) return low;
- if (item > hi) return hi;
- return item;
-}
-
-/* strftime --- produce formatted time */
-
-void
-/*size_t*/
-#ifndef __STDC__
-exp_strftime(/*s,*/ format, timeptr, dstring)
-/*char *s;*/
-char *format;
-const struct tm *timeptr;
-Tcl_DString *dstring;
-#else
-/*exp_strftime(char *s, size_t maxsize, const char *format, const struct tm *timeptr)*/
-exp_strftime(char *format, const struct tm *timeptr,Tcl_DString *dstring)
-#endif
-{
- int copied; /* used to suppress copying when called recursively */
-
-#if 0
- char *endp = s + maxsize;
- char *start = s;
-#endif
- char *percentptr;
-
- char tbuf[100];
- int i;
-
- /* various tables, useful in North America */
- static char *days_a[] = {
- "Sun", "Mon", "Tue", "Wed",
- "Thu", "Fri", "Sat",
- };
- static char *days_l[] = {
- "Sunday", "Monday", "Tuesday", "Wednesday",
- "Thursday", "Friday", "Saturday",
- };
- static char *months_a[] = {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
- };
- static char *months_l[] = {
- "January", "February", "March", "April",
- "May", "June", "July", "August", "September",
- "October", "November", "December",
- };
- static char *ampm[] = { "AM", "PM", };
-
-/* for (; *format && s < endp - 1; format++) {*/
- for (; *format ; format++) {
- tbuf[0] = '\0';
- copied = 0; /* has not been copied yet */
- percentptr = strchr(format,'%');
- if (percentptr == 0) {
- Tcl_DStringAppend(dstring,format,-1);
- goto out;
- } else if (percentptr != format) {
- Tcl_DStringAppend(dstring,format,percentptr - format);
- format = percentptr;
- }
-#if 0
- if (*format != '%') {
- *s++ = *format;
- continue;
- }
-#endif
- again:
- switch (*++format) {
- case '\0':
- Tcl_DStringAppend(dstring,"%",1);
-#if 0
- *s++ = '%';
-#endif
- goto out;
-
- case '%':
- Tcl_DStringAppend(dstring,"%",1);
- copied = 1;
- break;
-#if 0
- *s++ = '%';
- continue;
-#endif
-
- case 'a': /* abbreviated weekday name */
- if (timeptr->tm_wday < 0 || timeptr->tm_wday > 6)
- strcpy(tbuf, "?");
- else
- strcpy(tbuf, days_a[timeptr->tm_wday]);
- break;
-
- case 'A': /* full weekday name */
- if (timeptr->tm_wday < 0 || timeptr->tm_wday > 6)
- strcpy(tbuf, "?");
- else
- strcpy(tbuf, days_l[timeptr->tm_wday]);
- break;
-
-#ifdef SYSV_EXT
- case 'h': /* abbreviated month name */
-#endif
- case 'b': /* abbreviated month name */
- if (timeptr->tm_mon < 0 || timeptr->tm_mon > 11)
- strcpy(tbuf, "?");
- else
- strcpy(tbuf, months_a[timeptr->tm_mon]);
- break;
-
- case 'B': /* full month name */
- if (timeptr->tm_mon < 0 || timeptr->tm_mon > 11)
- strcpy(tbuf, "?");
- else
- strcpy(tbuf, months_l[timeptr->tm_mon]);
- break;
-
- case 'c': /* appropriate date and time representation */
- sprintf(tbuf, "%s %s %2d %02d:%02d:%02d %d",
- days_a[range(0, timeptr->tm_wday, 6)],
- months_a[range(0, timeptr->tm_mon, 11)],
- range(1, timeptr->tm_mday, 31),
- range(0, timeptr->tm_hour, 23),
- range(0, timeptr->tm_min, 59),
- range(0, timeptr->tm_sec, 61),
- timeptr->tm_year + 1900);
- break;
-
- case 'd': /* day of the month, 01 - 31 */
- i = range(1, timeptr->tm_mday, 31);
- sprintf(tbuf, "%02d", i);
- break;
-
- case 'H': /* hour, 24-hour clock, 00 - 23 */
- i = range(0, timeptr->tm_hour, 23);
- sprintf(tbuf, "%02d", i);
- break;
-
- case 'I': /* hour, 12-hour clock, 01 - 12 */
- i = range(0, timeptr->tm_hour, 23);
- if (i == 0)
- i = 12;
- else if (i > 12)
- i -= 12;
- sprintf(tbuf, "%02d", i);
- break;
-
- case 'j': /* day of the year, 001 - 366 */
- sprintf(tbuf, "%03d", timeptr->tm_yday + 1);
- break;
-
- case 'm': /* month, 01 - 12 */
- i = range(0, timeptr->tm_mon, 11);
- sprintf(tbuf, "%02d", i + 1);
- break;
-
- case 'M': /* minute, 00 - 59 */
- i = range(0, timeptr->tm_min, 59);
- sprintf(tbuf, "%02d", i);
- break;
-
- case 'p': /* am or pm based on 12-hour clock */
- i = range(0, timeptr->tm_hour, 23);
- if (i < 12)
- strcpy(tbuf, ampm[0]);
- else
- strcpy(tbuf, ampm[1]);
- break;
-
- case 'S': /* second, 00 - 61 */
- i = range(0, timeptr->tm_sec, 61);
- sprintf(tbuf, "%02d", i);
- break;
-
- case 'U': /* week of year, Sunday is first day of week */
- sprintf(tbuf, "%02d", weeknumber(timeptr, 0));
- break;
-
- case 'w': /* weekday, Sunday == 0, 0 - 6 */
- i = range(0, timeptr->tm_wday, 6);
- sprintf(tbuf, "%d", i);
- break;
-
- case 'W': /* week of year, Monday is first day of week */
- sprintf(tbuf, "%02d", weeknumber(timeptr, 1));
- break;
-
- case 'x': /* appropriate date representation */
- sprintf(tbuf, "%s %s %2d %d",
- days_a[range(0, timeptr->tm_wday, 6)],
- months_a[range(0, timeptr->tm_mon, 11)],
- range(1, timeptr->tm_mday, 31),
- timeptr->tm_year + 1900);
- break;
-
- case 'X': /* appropriate time representation */
- sprintf(tbuf, "%02d:%02d:%02d",
- range(0, timeptr->tm_hour, 23),
- range(0, timeptr->tm_min, 59),
- range(0, timeptr->tm_sec, 61));
- break;
-
- case 'y': /* year without a century, 00 - 99 */
- i = timeptr->tm_year % 100;
- sprintf(tbuf, "%02d", i);
- break;
-
- case 'Y': /* year with century */
- sprintf(tbuf, "%d", 1900 + timeptr->tm_year);
- break;
-
- case 'Z': /* time zone name or abbrevation */
-#if defined(HAVE_STRFTIME)
- strftime(tbuf,sizeof tbuf,"%Z",timeptr);
-#else
-# if defined(HAVE_SV_TIMEZONE)
- i = 0;
- if (daylight && timeptr->tm_isdst)
- i = 1;
- strcpy(tbuf, tzname[i]);
-# else
- strcpy(tbuf, zone_name (timeptr));
-# if defined(HAVE_TIMEZONE)
-# endif /* HAVE_TIMEZONE */
- /* no timezone available */
- /* feel free to add others here */
-# endif /* HAVE_SV_TIMEZONE */
-#endif /* HAVE STRFTIME */
- break;
-
-#ifdef SYSV_EXT
- case 'n': /* same as \n */
- tbuf[0] = '\n';
- tbuf[1] = '\0';
- break;
-
- case 't': /* same as \t */
- tbuf[0] = '\t';
- tbuf[1] = '\0';
- break;
-
- case 'D': /* date as %m/%d/%y */
- exp_strftime("%m/%d/%y", timeptr, dstring);
- copied = 1;
-/* exp_strftime(tbuf, sizeof tbuf, "%m/%d/%y", timeptr);*/
- break;
-
- case 'e': /* day of month, blank padded */
- sprintf(tbuf, "%2d", range(1, timeptr->tm_mday, 31));
- break;
-
- case 'r': /* time as %I:%M:%S %p */
- exp_strftime("%I:%M:%S %p", timeptr, dstring);
- copied = 1;
-/* exp_strftime(tbuf, sizeof tbuf, "%I:%M:%S %p", timeptr);*/
- break;
-
- case 'R': /* time as %H:%M */
- exp_strftime("%H:%M", timeptr, dstring);
- copied = 1;
-/* exp_strftime(tbuf, sizeof tbuf, "%H:%M", timeptr);*/
- break;
-
- case 'T': /* time as %H:%M:%S */
- exp_strftime("%H:%M:%S", timeptr, dstring);
- copied = 1;
-/* exp_strftime(tbuf, sizeof tbuf, "%H:%M:%S", timeptr);*/
- break;
-#endif
-
-#ifdef POSIX2_DATE
- case 'C':
- sprintf(tbuf, "%02d", (timeptr->tm_year + 1900) / 100);
- break;
-
-
- case 'E':
- case 'O':
- /* POSIX locale extensions, ignored for now */
- goto again;
- case 'V': /* week of year according ISO 8601 */
- sprintf(tbuf, "%02d", iso8601wknum(timeptr));
- break;
-
- case 'u':
- /* ISO 8601: Weekday as a decimal number [1 (Monday) - 7] */
- sprintf(tbuf, "%d", timeptr->tm_wday == 0 ? 7 :
- timeptr->tm_wday);
- break;
-#endif /* POSIX2_DATE */
- default:
- tbuf[0] = '%';
- tbuf[1] = *format;
- tbuf[2] = '\0';
- break;
- }
- if (!copied)
- Tcl_DStringAppend(dstring,tbuf,-1);
-#if 0
- i = strlen(tbuf);
- if (i) {
- if (s + i < endp - 1) {
- strcpy(s, tbuf);
- s += i;
- } else
- return 0;
-#endif
- }
-out:;
-#if 0
- if (s < endp && *format == '\0') {
- *s = '\0';
- return (s - start);
- } else
- return 0;
-#endif
-}
-
-/* isleap --- is a year a leap year? */
-
-#ifndef __STDC__
-static int
-isleap(year)
-int year;
-#else
-static int
-isleap(int year)
-#endif
-{
- return ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0);
-}
-
-#ifdef POSIX2_DATE
-/* iso8601wknum --- compute week number according to ISO 8601 */
-
-#ifndef __STDC__
-static int
-iso8601wknum(timeptr)
-const struct tm *timeptr;
-#else
-static int
-iso8601wknum(const struct tm *timeptr)
-#endif
-{
- /*
- * From 1003.2:
- * If the week (Monday to Sunday) containing January 1
- * has four or more days in the new year, then it is week 1;
- * otherwise it is the highest numbered week of the previous
- * (52 or 53) year, and the next week is week 1.
- *
- * ADR: This means if Jan 1 was Monday through Thursday,
- * it was week 1, otherwise week 53.
- *
- * XPG4 erroneously included POSIX.2 rationale text in the
- * main body of the standard. Thus it requires week 53.
- */
-
- int weeknum, jan1day, diff;
-
- /* get week number, Monday as first day of the week */
- weeknum = weeknumber(timeptr, 1);
-
- /*
- * With thanks and tip of the hatlo to tml@tik.vtt.fi
- *
- * What day of the week does January 1 fall on?
- * We know that
- * (timeptr->tm_yday - jan1.tm_yday) MOD 7 ==
- * (timeptr->tm_wday - jan1.tm_wday) MOD 7
- * and that
- * jan1.tm_yday == 0
- * and that
- * timeptr->tm_wday MOD 7 == timeptr->tm_wday
- * from which it follows that. . .
- */
- jan1day = timeptr->tm_wday - (timeptr->tm_yday % 7);
- if (jan1day < 0)
- jan1day += 7;
-
- /*
- * If Jan 1 was a Monday through Thursday, it was in
- * week 1. Otherwise it was last year's highest week, which is
- * this year's week 0.
- *
- * What does that mean?
- * If Jan 1 was Monday, the week number is exactly right, it can
- * never be 0.
- * If it was Tuesday through Thursday, the weeknumber is one
- * less than it should be, so we add one.
- * Otherwise, Friday, Saturday or Sunday, the week number is
- * OK, but if it is 0, it needs to be 52 or 53.
- */
- switch (jan1day) {
- case 1: /* Monday */
- break;
- case 2: /* Tuesday */
- case 3: /* Wednesday */
- case 4: /* Thursday */
- weeknum++;
- break;
- case 5: /* Friday */
- case 6: /* Saturday */
- case 0: /* Sunday */
- if (weeknum == 0) {
-#ifdef USE_BROKEN_XPG4
- /* XPG4 (as of March 1994) says 53 unconditionally */
- weeknum = 53;
-#else
- /* get week number of last week of last year */
- struct tm dec31ly; /* 12/31 last year */
- dec31ly = *timeptr;
- dec31ly.tm_year--;
- dec31ly.tm_mon = 11;
- dec31ly.tm_mday = 31;
- dec31ly.tm_wday = (jan1day == 0) ? 6 : jan1day - 1;
- dec31ly.tm_yday = 364 + isleap(dec31ly.tm_year + 1900);
- weeknum = iso8601wknum(& dec31ly);
-#endif
- }
- break;
- }
-
- if (timeptr->tm_mon == 11) {
- /*
- * The last week of the year
- * can be in week 1 of next year.
- * Sigh.
- *
- * This can only happen if
- * M T W
- * 29 30 31
- * 30 31
- * 31
- */
- int wday, mday;
-
- wday = timeptr->tm_wday;
- mday = timeptr->tm_mday;
- if ( (wday == 1 && (mday >= 29 && mday <= 31))
- || (wday == 2 && (mday == 30 || mday == 31))
- || (wday == 3 && mday == 31))
- weeknum = 1;
- }
-
- return weeknum;
-}
-#endif
-
-/* weeknumber --- figure how many weeks into the year */
-
-/* With thanks and tip of the hatlo to ado@elsie.nci.nih.gov */
-
-#ifndef __STDC__
-static int
-weeknumber(timeptr, firstweekday)
-const struct tm *timeptr;
-int firstweekday;
-#else
-static int
-weeknumber(const struct tm *timeptr, int firstweekday)
-#endif
-{
- int wday = timeptr->tm_wday;
- int ret;
-
- if (firstweekday == 1) {
- if (wday == 0) /* sunday */
- wday = 6;
- else
- wday--;
- }
- ret = ((timeptr->tm_yday + 7 - wday) / 7);
- if (ret < 0)
- ret = 0;
- return ret;
-}
+++ /dev/null
-/* exp_trap.c - Expect's trap command
-
-Written by: Don Libes, NIST, 9/1/93
-
-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.
-
-*/
-
-#include "expect_cf.h"
-
-#include <stdio.h>
-#include <signal.h>
-#include <sys/types.h>
-
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-/* Use _NSIG if NSIG not present */
-#ifndef NSIG
-#ifdef _NSIG
-#define NSIG _NSIG
-#endif
-#endif
-
-#if defined(SIGCLD) && !defined(SIGCHLD)
-#define SIGCHLD SIGCLD
-#endif
-
-#include "tcl.h"
-
-#include "exp_rename.h"
-#include "exp_prog.h"
-#include "exp_command.h"
-#include "exp_log.h"
-
-#ifdef TCL_DEBUGGER
-#include "Dbg.h"
-#endif
-
-#define NO_SIG 0
-
-static struct trap {
- char *action; /* Tcl command to execute upon sig */
- /* Each is handled by the eval_trap_action */
- int mark; /* TRUE if signal has occurred */
- Tcl_Interp *interp; /* interp to use or 0 if we should use the */
- /* interpreter active at the time the sig */
- /* is processed */
- int code; /* return our new code instead of code */
- /* available when signal is processed */
- char *name; /* name of signal */
- int reserved; /* if unavailable for trapping */
-} traps[NSIG];
-
-int sigchld_count = 0; /* # of sigchlds caught but not yet processed */
-
-static int eval_trap_action();
-
-static int got_sig; /* this records the last signal received */
- /* it is only a hint and can be wiped out */
- /* by multiple signals, but it will always */
- /* be left with a valid signal that is */
- /* pending */
-
-static Tcl_AsyncHandler async_handler;
-
-static char *
-signal_to_string(sig)
-int sig;
-{
- if (sig <= 0 || sig > NSIG) return("SIGNAL OUT OF RANGE");
- return(traps[sig].name);
-}
-
-/* current sig being processed by user sig handler */
-static int current_sig = NO_SIG;
-
-int exp_nostack_dump = FALSE; /* TRUE if user has requested unrolling of */
- /* stack with no trace */
-
-
-
-/*ARGSUSED*/
-static int
-tophalf(clientData,interp,code)
-ClientData clientData;
-Tcl_Interp *interp;
-int code;
-{
- struct trap *trap; /* last trap processed */
- int rc;
- int i;
- Tcl_Interp *sig_interp;
-/* extern Tcl_Interp *exp_interp;*/
-
- exp_debuglog("sighandler: handling signal(%d)\r\n",got_sig);
-
- if (got_sig <= 0 || got_sig >= NSIG) {
- errorlog("caught impossible signal %d\r\n",got_sig);
- abort();
- }
-
- /* start to work on this sig. got_sig can now be overwritten */
- /* and it won't cause a problem */
- current_sig = got_sig;
- trap = &traps[current_sig];
-
- trap->mark = FALSE;
-
- /* decrement below looks dangerous */
- /* Don't we need to temporarily block bottomhalf? */
- if (current_sig == SIGCHLD) {
- sigchld_count--;
- exp_debuglog("sigchld_count-- == %d\n",sigchld_count);
- }
-
- if (!trap->action) {
- /* In this one case, we let ourselves be called when no */
- /* signaler predefined, since we are calling explicitly */
- /* from another part of the program, and it is just simpler */
- if (current_sig == 0) return code;
- errorlog("caught unexpected signal: %s (%d)\r\n",
- signal_to_string(current_sig),current_sig);
- abort();
- }
-
- if (trap->interp) {
- /* if trap requested original interp, use it */
- sig_interp = trap->interp;
- } else if (!interp) {
- /* else if another interp is available, use it */
- sig_interp = interp;
- } else {
- /* fall back to exp_interp */
- sig_interp = exp_interp;
- }
-
- rc = eval_trap_action(sig_interp,current_sig,trap,code);
- current_sig = NO_SIG;
-
- /*
- * scan for more signals to process
- */
-
- /* first check for additional SIGCHLDs */
- if (sigchld_count) {
- got_sig = SIGCHLD;
- traps[SIGCHLD].mark = TRUE;
- Tcl_AsyncMark(async_handler);
- } else {
- got_sig = -1;
- for (i=1;i<NSIG;i++) {
- if (traps[i].mark) {
- got_sig = i;
- Tcl_AsyncMark(async_handler);
- break;
- }
- }
- }
- return rc;
-}
-
-#ifdef REARM_SIG
-int sigchld_sleep;
-static int rearm_sigchld = FALSE; /* TRUE if sigchld needs to be */
- /* rearmed (i.e., because it has
- /* just gone off) */
-static int rearming_sigchld = FALSE;
-#endif
-
-/* called upon receipt of a user-declared signal */
-static void
-bottomhalf(sig)
-int sig;
-{
-#ifdef REARM_SIG
- /*
- * tiny window of death if same signal should arrive here
- * before we've reinstalled it
- */
-
- /* In SV, sigchld must be rearmed after wait to avoid recursion */
- if (sig != SIGCHLD) {
- signal(sig,bottomhalf);
- } else {
- /* request rearm */
- rearm_sigchld = TRUE;
- if (rearming_sigchld) sigchld_sleep = TRUE;
- }
-#endif
-
- traps[sig].mark = TRUE;
- got_sig = sig; /* just a hint - can be wiped out by another */
- Tcl_AsyncMark(async_handler);
-
- /* if we are called while this particular async is being processed */
- /* original async_proc will turn off "mark" so that when async_proc */
- /* is recalled, it will see that nothing was left to do */
-
- /* In case of SIGCHLD though, we must recall it as many times as
- * we have received it.
- */
- if (sig == SIGCHLD) {
- sigchld_count++;
-/* exp_debuglog(stderr,"sigchld_count++ == %d\n",sigchld_count);*/
- }
-#if 0
- /* if we are doing an i_read, restart it */
- if (env_valid && (sig != 0)) longjmp(env,2);
-#endif
-}
-
-/*ARGSUSED*/
-void
-exp_rearm_sigchld(interp)
-Tcl_Interp *interp;
-{
-#ifdef REARM_SIG
- if (rearm_sigchld) {
- rearm_sigchld = FALSE;
- rearming_sigchld = TRUE;
- signal(SIGCHLD,bottomhalf);
- }
-
- rearming_sigchld = FALSE;
-
- /* if the rearming immediately caused another SIGCHLD, slow down */
- /* It's probably one of Tcl's intermediary pipeline processes that */
- /* Tcl hasn't caught up with yet. */
- if (sigchld_sleep) {
- exp_dsleep(interp,0.2);
- sigchld_sleep = FALSE;
- }
-#endif
-}
-
-
-void
-exp_init_trap()
-{
- int i;
-
- for (i=1;i<NSIG;i++) {
- traps[i].name = Tcl_SignalId(i);
- traps[i].action = 0;
- traps[i].reserved = FALSE;
- }
-
- /*
- * fix up any special cases
- */
-
-#if defined(SIGCLD)
- /* Tcl names it SIGCLD, not good for portable scripts */
- traps[SIGCLD].name = "SIGCHLD";
-#endif
-#if defined(SIGALRM)
- traps[SIGALRM].reserved = TRUE;
-#endif
-#if defined(SIGKILL)
- traps[SIGKILL].reserved = TRUE;
-#endif
-#if defined(SIGSTOP)
- traps[SIGSTOP].reserved = TRUE;
-#endif
-
- async_handler = Tcl_AsyncCreate(tophalf,(ClientData)0);
-
-}
-
-/* given signal index or name as string, */
-/* returns signal index or -1 if bad arg */
-int
-exp_string_to_signal(interp,s)
-Tcl_Interp *interp;
-char *s;
-{
- int sig;
- char *name;
-
- /* try interpreting as an integer */
- if (1 == sscanf(s,"%d",&sig)) {
- if (sig > 0 && sig < NSIG) return sig;
- } else {
- /* try interpreting as a string */
- for (sig=1;sig<NSIG;sig++) {
- name = traps[sig].name;
- if (streq(s,name) || streq(s,name+3)) return(sig);
- }
- }
-
- exp_error(interp,"invalid signal %s",s);
-
- return -1;
-}
-
-/*ARGSUSED*/
-int
-Exp_TrapCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- char *action = 0;
- int n; /* number of signals in list */
- char **list; /* list of signals */
- int len; /* length of action */
- int i;
- int show_name = FALSE; /* if user asked for current sig by name */
- int show_number = FALSE;/* if user asked for current sig by number */
- int show_max = FALSE; /* if user asked for NSIG-1 */
- int rc = TCL_OK;
- int new_code = FALSE; /* if action result should overwrite orig */
- Tcl_Interp *new_interp = interp;/* interp in which to evaluate */
- /* action when signal occurs */
-
- argc--; argv++;
-
- while (*argv) {
- if (streq(*argv,"-code")) {
- argc--; argv++;
- new_code = TRUE;
- } else if (streq(*argv,"-interp")) {
- argc--; argv++;
- new_interp = 0;
- } else if (streq(*argv,"-name")) {
- argc--; argv++;
- show_name = TRUE;
- } else if (streq(*argv,"-number")) {
- argc--; argv++;
- show_number = TRUE;
- } else if (streq(*argv,"-max")) {
- argc--; argv++;
- show_max = TRUE;
- } else break;
- }
-
- if (show_name || show_number || show_max) {
- if (argc > 0) goto usage_error;
- if (show_max) {
- sprintf(interp->result,"%d",NSIG-1);
- return TCL_OK;
- }
-
- if (current_sig == NO_SIG) {
- exp_error(interp,"no signal in progress");
- return TCL_ERROR;
- }
- if (show_name) {
- /* skip over "SIG" */
- interp->result = signal_to_string(current_sig) + 3;
- } else {
- sprintf(interp->result,"%d",current_sig);
- }
- return TCL_OK;
- }
-
- if (argc == 0 || argc > 2) goto usage_error;
-
- if (argc == 1) {
- int sig = exp_string_to_signal(interp,*argv);
- if (sig == -1) return TCL_ERROR;
-
- if (traps[sig].action) {
- Tcl_AppendResult(interp,traps[sig].action,(char *)0);
- } else {
- interp->result = "SIG_DFL";
- }
- return TCL_OK;
- }
-
- action = *argv;
-
- /* argv[1] is the list of signals - crack it open */
- if (TCL_OK != Tcl_SplitList(interp,argv[1],&n,&list)) {
- errorlog("%s\r\n",interp->result);
- goto usage_error;
- }
-
- for (i=0;i<n;i++) {
- int sig = exp_string_to_signal(interp,list[i]);
- if (sig == -1) {
- rc = TCL_ERROR;
- break;
- }
-
- if (traps[sig].reserved) {
- exp_error(interp,"cannot trap %s",signal_to_string(sig));
- rc = TCL_ERROR;
- break;
- }
-
-#if 0
-#ifdef TCL_DEBUGGER
- if (sig == SIGINT && exp_tcl_debugger_available) {
- exp_debuglog("trap: cannot trap SIGINT while using debugger\r\n");
- continue;
- }
-#endif /* TCL_DEBUGGER */
-#endif
-
- exp_debuglog("trap: setting up signal %d (\"%s\")\r\n",sig,list[i]);
-
- if (traps[sig].action) ckfree(traps[sig].action);
-
- if (streq(action,"SIG_DFL")) {
- /* should've been free'd by now if nec. */
- traps[sig].action = 0;
- signal(sig,SIG_DFL);
-#ifdef REARM_SIG
- if (sig == SIGCHLD)
- rearm_sigchld = FALSE;
-#endif /*REARM_SIG*/
- } else {
- len = 1 + strlen(action);
- traps[sig].action = ckalloc(len);
- memcpy(traps[sig].action,action,len);
- traps[sig].interp = new_interp;
- traps[sig].code = new_code;
- if (streq(action,"SIG_IGN")) {
- signal(sig,SIG_IGN);
- } else signal(sig,bottomhalf);
- }
- }
- ckfree((char *)list);
- return(rc);
- usage_error:
- exp_error(interp,"usage: trap [command or SIG_DFL or SIG_IGN] {list of signals}");
- return TCL_ERROR;
-}
-
-/* called by tophalf() to process the given signal */
-static int
-eval_trap_action(interp,sig,trap,oldcode)
-Tcl_Interp *interp;
-int sig;
-struct trap *trap;
-int oldcode;
-{
- int code_flag;
- int newcode;
- Tcl_DString ei; /* errorInfo */
- char *eip;
- Tcl_DString ec; /* errorCode */
- char *ecp;
- Tcl_DString ir; /* interp->result */
-
- exp_debuglog("async event handler: Tcl_Eval(%s)\r\n",trap->action);
-
- /* save to prevent user from redefining trap->code while trap */
- /* is executing */
- code_flag = trap->code;
-
- if (!code_flag) {
- /*
- * save return values
- */
- eip = Tcl_GetVar(interp,"errorInfo",TCL_GLOBAL_ONLY);
- if (eip) {
- Tcl_DStringInit(&ei);
- eip = Tcl_DStringAppend(&ei,eip,-1);
- }
- ecp = Tcl_GetVar(interp,"errorCode",TCL_GLOBAL_ONLY);
- if (ecp) {
- Tcl_DStringInit(&ec);
- ecp = Tcl_DStringAppend(&ec,ecp,-1);
- }
- /* I assume interp->result is always non-zero, right? */
- Tcl_DStringInit(&ir);
- Tcl_DStringAppend(&ir,interp->result,-1);
- }
-
- newcode = Tcl_GlobalEval(interp,trap->action);
-
- /*
- * if new code is to be ignored (usual case - see "else" below)
- * allow only OK/RETURN from trap, otherwise complain
- */
-
- if (code_flag) {
- exp_debuglog("return value = %d for trap %s, action %s\r\n",
- newcode,signal_to_string(sig),trap->action);
- if (*interp->result != 0) {
- errorlog("%s\r\n",interp->result);
-
- /*
- * Check errorinfo and see if it contains -nostack.
- * This shouldn't be necessary, but John changed the
- * top level interp so that it distorts arbitrary
- * return values into TCL_ERROR, so by the time we
- * get back, we'll have lost the value of errorInfo
- */
-
- eip = Tcl_GetVar(interp,"errorInfo",TCL_GLOBAL_ONLY);
- exp_nostack_dump =
- (eip && (0 == strncmp("-nostack",eip,8)));
- }
- } else if (newcode != TCL_OK && newcode != TCL_RETURN) {
- if (newcode != TCL_ERROR) {
- exp_error(interp,"return value = %d for trap %s, action %s\r\n",newcode,signal_to_string(sig),trap->action);
- }
- Tcl_BackgroundError(interp);
- }
-
- if (!code_flag) {
- /*
- * restore values
- */
- Tcl_ResetResult(interp); /* turns off Tcl's internal */
- /* flags: ERR_IN_PROGRESS, ERROR_CODE_SET */
-
- if (eip) {
- Tcl_AddErrorInfo(interp,eip);
- Tcl_DStringFree(&ei);
- } else {
- Tcl_UnsetVar(interp,"errorInfo",0);
- }
-
- /* restore errorCode. Note that Tcl_AddErrorInfo (above) */
- /* resets it to NONE. If the previous value is NONE, it's */
- /* important to avoid calling Tcl_SetErrorCode since this */
- /* with cause Tcl to set its internal ERROR_CODE_SET flag. */
- if (ecp) {
- if (!streq("NONE",ecp))
- Tcl_SetErrorCode(interp,ecp,(char *)0);
- Tcl_DStringFree(&ec);
- } else {
- Tcl_UnsetVar(interp,"errorCode",0);
- }
-
- Tcl_DStringResult(interp,&ir);
- Tcl_DStringFree(&ir);
-
- newcode = oldcode;
-
- /* note that since newcode gets overwritten here by old code */
- /* it is possible to return in the middle of a trap by using */
- /* "return" (or "continue" for that matter)! */
- }
- return newcode;
-}
-
-static struct exp_cmd_data
-cmd_data[] = {
-{"trap", exp_proc(Exp_TrapCmd), (ClientData)EXP_SPAWN_ID_BAD, 0},
-{0}};
-
-void
-exp_init_trap_cmds(interp)
-Tcl_Interp *interp;
-{
- exp_create_commands(interp,cmd_data);
-}
-
+++ /dev/null
-EXTERN void exp_timestamp _ANSI_ARGS_((Tcl_Interp *,time_t *,
- char *));
+++ /dev/null
-/* exp_tty.c - tty support routines */
-
-#include "expect_cf.h"
-#include <stdio.h>
-#include <signal.h>
-#include "string.h"
-
-#ifdef HAVE_SYS_FCNTL_H
-# include <sys/fcntl.h>
-#else
-# include <fcntl.h>
-#endif
-
-#include <sys/stat.h>
-
-#ifdef HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#include <sys/types.h>
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-#if defined(SIGCLD) && !defined(SIGCHLD)
-#define SIGCHLD SIGCLD
-#endif
-
-#include "tcl.h"
-#include "exp_prog.h"
-#include "exp_rename.h"
-#include "exp_tty_in.h"
-#include "exp_log.h"
-#include "exp_command.h"
-
-static int is_raw = FALSE;
-static int is_noecho = FALSE;
-
-int exp_ioctled_devtty = FALSE;
-int exp_stdin_is_tty;
-int exp_stdout_is_tty;
-
-/*static*/ extern exp_tty exp_tty_current, exp_tty_cooked;
-#define tty_current exp_tty_current
-#define tty_cooked exp_tty_cooked
-
-int
-exp_israw()
-{
- return is_raw;
-}
-
-int
-exp_isecho()
-{
- return !is_noecho;
-}
-
-/* if set == 1, set it to raw, else unset it */
-void
-exp_tty_raw(set)
-int set;
-{
- if (set == 1) {
- is_raw = TRUE;
-#if defined(HAVE_TERMIOS) || defined(HAVE_TERMIO) /* had POSIX too */
- tty_current.c_iflag = 0;
- tty_current.c_oflag = 0;
- tty_current.c_lflag &= ECHO; /* disable everything but echo */
- tty_current.c_cc[VMIN] = 1;
- tty_current.c_cc[VTIME] = 0;
- } else {
- tty_current.c_iflag = tty_cooked.c_iflag;
- tty_current.c_oflag = tty_cooked.c_oflag;
-/* tty_current.c_lflag = tty_cooked.c_lflag;*/
-/* attempt 2 tty_current.c_lflag = tty_cooked.c_lflag & ~ECHO;*/
- /* retain current echo setting */
- tty_current.c_lflag = (tty_cooked.c_lflag & ~ECHO) | (tty_current.c_lflag & ECHO);
- tty_current.c_cc[VMIN] = tty_cooked.c_cc[VMIN];
- tty_current.c_cc[VTIME] = tty_cooked.c_cc[VTIME];
-#else
-# if defined(HAVE_SGTTYB)
- tty_current.sg_flags |= RAW;
- } else {
- tty_current.sg_flags = tty_cooked.sg_flags;
-# endif
-#endif
- is_raw = FALSE;
- }
-}
-
-void
-exp_tty_echo(set)
-int set;
-{
- if (set == 1) {
- is_noecho = FALSE;
-#if defined(HAVE_TERMIOS) || defined(HAVE_TERMIO) /* had POSIX too */
- tty_current.c_lflag |= ECHO;
- } else {
- tty_current.c_lflag &= ~ECHO;
-#else
- tty_current.sg_flags |= ECHO;
- } else {
- tty_current.sg_flags &= ~ECHO;
-#endif
- is_noecho = TRUE;
- }
-}
-
-int
-exp_tty_set_simple(tty)
-exp_tty *tty;
-{
-#ifdef HAVE_TCSETATTR
- return(tcsetattr(exp_dev_tty, TCSADRAIN,tty));
-#else
- return(ioctl (exp_dev_tty, TCSETSW ,tty));
-#endif
-}
-
-int
-exp_tty_get_simple(tty)
-exp_tty *tty;
-{
-#ifdef HAVE_TCSETATTR
- return(tcgetattr(exp_dev_tty, tty));
-#else
- return(ioctl (exp_dev_tty, TCGETS, tty));
-#endif
-}
-
-/* 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;
-{
- if (exp_disconnected) return(0);
- if (is_raw && is_noecho) return(0);
- if (exp_dev_tty == -1) return(0);
-
- *tty_old = tty_current; /* save old parameters */
- *was_raw = is_raw;
- *was_echo = !is_noecho;
- debuglog("tty_raw_noecho: was raw = %d echo = %d\r\n",is_raw,!is_noecho);
-
- exp_tty_raw(1);
- exp_tty_echo(-1);
-
- if (exp_tty_set_simple(&tty_current) == -1) {
- errorlog("ioctl(raw): %s\r\n",Tcl_PosixError(interp));
- exp_exit(interp,1);
- }
-
- exp_ioctled_devtty = TRUE;
- return(1);
-}
-
-/* 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;
-{
- if (exp_disconnected) return(0);
- if (!is_raw && !is_noecho) return(0);
- if (exp_dev_tty == -1) return(0);
-
- *tty_old = tty_current; /* save old parameters */
- *was_raw = is_raw;
- *was_echo = !is_noecho;
- debuglog("tty_cooked_echo: was raw = %d echo = %d\r\n",is_raw,!is_noecho);
-
- exp_tty_raw(-1);
- exp_tty_echo(1);
-
- if (exp_tty_set_simple(&tty_current) == -1) {
- errorlog("ioctl(noraw): %s\r\n",Tcl_PosixError(interp));
- exp_exit(interp,1);
- }
- exp_ioctled_devtty = TRUE;
-
- return(1);
-}
-
-void
-exp_tty_set(interp,tty,raw,echo)
-Tcl_Interp *interp;
-exp_tty *tty;
-int raw;
-int echo;
-{
- if (exp_tty_set_simple(tty) == -1) {
- errorlog("ioctl(set): %s\r\n",Tcl_PosixError(interp));
- exp_exit(interp,1);
- }
- is_raw = raw;
- is_noecho = !echo;
- tty_current = *tty;
- debuglog("tty_set: raw = %d, echo = %d\r\n",is_raw,!is_noecho);
- exp_ioctled_devtty = TRUE;
-}
-
-#if 0
-/* avoids scoping problems */
-void
-exp_update_cooked_from_current() {
- tty_cooked = tty_current;
-}
-
-int
-exp_update_real_tty_from_current() {
- return(exp_tty_set_simple(&tty_current));
-}
-
-int
-exp_update_current_from_real_tty() {
- return(exp_tty_get_simple(&tty_current));
-}
-#endif
-
-void
-exp_init_stdio()
-{
- exp_stdin_is_tty = isatty(0);
- exp_stdout_is_tty = isatty(1);
-
- setbuf(stdout,(char *)0); /* unbuffer stdout */
-}
-
-/*ARGSUSED*/
-void
-exp_tty_break(interp,fd)
-Tcl_Interp *interp;
-int fd;
-{
-#ifdef POSIX
- tcsendbreak(fd,0);
-#else
-# ifdef TIOCSBRK
- ioctl(fd,TIOCSBRK,0);
- exp_dsleep(interp,0.25); /* sleep for at least a quarter of a second */
- ioctl(fd,TIOCCBRK,0);
-# else
- /* dunno how to do this - ignore */
-# endif
-#endif
-}
-
-/* take strings with newlines and insert carriage-returns. This allows user */
-/* to write send_user strings without always putting in \r. */
-/* 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 */
-{
- static int destlen = 0;
- static char *dest = 0;
- char *d; /* ptr into dest */
- unsigned int need;
-
- if (s == 0) return("<null>");
-
- if (!is_raw) return(s);
-
- /* worst case is every character takes 2 to represent */
- need = 1 + 2*(len?*len:strlen(s));
- if (need > destlen) {
- if (dest) ckfree(dest);
- dest = ckalloc(need);
- destlen = need;
- }
-
- for (d = dest;*s;s++) {
- if (*s == '\n') {
- *d++ = '\r';
- *d++ = '\n';
- } else {
- *d++ = *s;
- }
- }
- *d = '\0';
- if (len) *len = d-dest;
- return(dest);
-}
-
-/* this stupidity because Tcl needs commands in writable space */
-static char exec_cmd[] = "exec";
-static char stty_cmd[] = "/bin/stty";
-
-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 */
-{
- char **new_argv;
- int i;
- int rc;
-
- /* insert "system" at front, null at end, */
- /* and optional redirect in middle, hence "+3" */
- new_argv = (char **)ckalloc((3+argc)*sizeof(char *));
- new_argv[0] = exec_cmd;
- new_argv[1] = stty_cmd;
- for (i=1;i<argc;i++) {
- new_argv[i+1] = argv[i];
- }
- if (devtty) new_argv[++i] =
-#ifdef STTY_READS_STDOUT
- ">/dev/tty";
-#else
- "</dev/tty";
-#endif
-
- new_argv[i+1] = (char *)0;
-
- Tcl_ResetResult(interp);
-
- /* normally, I wouldn't set one of Tcl's own variables, but in this */
- /* case, I only only want to see if Tcl resets it to non-NONE, */
- /* and I don't know any other way of doing it */
- Tcl_SetVar(interp,"errorCode","NONE",0);
-
-#if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION < 3)
- rc = Tcl_ExecCmd((ClientData)0,interp,argc+1+devtty,new_argv);
-#else
- rc = Tcl_ExecObjCmd((ClientData)0,interp,argc+1+devtty,Tcl_NewStringObj(new_argv,-1));
-#endif
- ckfree((char *)new_argv);
-
- /* if stty-reads-stdout, stty will fail since Exec */
- /* will detect the stderr. Only by examining errorCode */
- /* can we tell if a real error occurred. */
-
-#ifdef STTY_READS_STDOUT
- if (rc == TCL_ERROR) {
- char *ec = Tcl_GetVar(interp,"errorCode",TCL_GLOBAL_ONLY);
- if (ec && !streq(ec,"NONE")) return TCL_ERROR;
- }
-#endif
- return TCL_OK;
-}
-
-/*ARGSUSED*/
-static int
-Exp_SttyCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- /* redirection symbol is not counted as a stty arg in terms */
- /* of recognition. */
- int saw_unknown_stty_arg = FALSE;
- int saw_known_stty_arg = FALSE;
- int no_args = TRUE;
-
- int rc = TCL_OK;
- int cooked = FALSE;
- int was_raw, was_echo;
-
-
- char **redirect; /* location of "<" */
- char *infile = 0;
- int fd; /* (slave) fd of infile */
- int master = -1; /* master fd of infile */
- char **argv0 = argv;
-
- for (argv=argv0+1;*argv;argv++) {
- if (argv[0][0] == '<') {
- redirect = argv;
- infile = *(argv+1);
- if (!infile) {
- errorlog("usage: < ttyname");
- return TCL_ERROR;
- }
- if (streq(infile,"/dev/tty")) {
- infile = 0;
- *argv = 0;
- *(argv+1) = 0;
- argc -= 2;
- } else {
- master = exp_trap_off(infile);
- if (-1 == (fd = open(infile,2))) {
- errorlog("couldn't open %s: %s",
- infile,Tcl_PosixError(interp));
- return TCL_ERROR;
- }
- }
- break;
- }
- }
-
- if (!infile) { /* work on /dev/tty */
- was_raw = exp_israw();
- was_echo = exp_isecho();
-
- exp_ioctled_devtty = TRUE;
-
- for (argv=argv0+1;*argv;argv++) {
- if (streq(*argv,"raw") ||
- streq(*argv,"-cooked")) {
- exp_tty_raw(1);
- saw_known_stty_arg = TRUE;
- no_args = FALSE;
- } else if (streq(*argv,"-raw") ||
- streq(*argv,"cooked")) {
- cooked = TRUE;
- exp_tty_raw(-1);
- saw_known_stty_arg = TRUE;
- no_args = FALSE;
- } else if (streq(*argv,"echo")) {
- exp_tty_echo(1);
- saw_known_stty_arg = TRUE;
- no_args = FALSE;
- } else if (streq(*argv,"-echo")) {
- exp_tty_echo(-1);
- saw_known_stty_arg = TRUE;
- no_args = FALSE;
- } else if (streq(*argv,"rows")) {
- if (*(argv+1)) {
- exp_win_rows_set(*(argv+1));
- argv++;
- no_args = FALSE;
- } else {
- exp_win_rows_get(interp->result);
- return TCL_OK;
- }
- } else if (streq(*argv,"columns")) {
- if (*(argv+1)) {
- exp_win_columns_set(*(argv+1));
- argv++;
- no_args = FALSE;
- } else {
- exp_win_columns_get(interp->result);
- return TCL_OK;
- }
- } else {
- saw_unknown_stty_arg = TRUE;
- }
- }
- /* if any unknown args, let real stty try */
- if (saw_unknown_stty_arg || no_args) {
- /* let real stty try */
- rc = exec_stty(interp,argc,argv0,1);
-
- /* find out what weird options user asked for */
- if (exp_tty_get_simple(&tty_current) == -1) {
- exp_error(interp,"stty: ioctl(get): %s\r\n",Tcl_PosixError(interp));
- rc = TCL_ERROR;
- }
- if (cooked) {
- /* find out user's new defn of 'cooked' */
- tty_cooked = tty_current;
- }
- } else if (saw_known_stty_arg) {
- if (exp_tty_set_simple(&tty_current) == -1) {
- if (exp_disconnected || (exp_dev_tty == -1) || !isatty(exp_dev_tty)) {
- errorlog("stty: impossible in this context\n");
- errorlog("are you disconnected or in a batch, at, or cron script?");
- /* user could've conceivably closed /dev/tty as well */
- }
- exp_error(interp,"stty: ioctl(user): %s\r\n",Tcl_PosixError(interp));
- rc = TCL_ERROR;
- }
- }
-
- /* if no result, make a crude one */
- if (interp->result[0] == '\0') {
- sprintf(interp->result,"%sraw %secho",
- (was_raw?"":"-"),
- (was_echo?"":"-"));
- }
- } else {
- /* a different tty */
-
- /* temporarily zap redirect */
- char *redirect_save = *redirect;
- *redirect = 0;
-
- for (argv=argv0+1;*argv;argv++) {
- if (streq(*argv,"rows")) {
- if (*(argv+1)) {
- exp_win2_rows_set(fd,*(argv+1));
- argv++;
- no_args = FALSE;
- } else {
- exp_win2_rows_get(fd,interp->result);
- goto done;
- }
- } else if (streq(*argv,"columns")) {
- if (*(argv+1)) {
- exp_win2_columns_set(fd,*(argv+1));
- argv++;
- no_args = FALSE;
- } else {
- exp_win2_columns_get(fd,interp->result);
- goto done;
- }
- } else if (streq(*argv,"<")) {
- break;
- } else {
- saw_unknown_stty_arg = TRUE;
- break;
- }
- }
-
- /* restore redirect */
- *redirect = redirect_save;
-
- close(fd); /* no more use for this, from now on */
- /* pass by name */
-
- if (saw_unknown_stty_arg || no_args) {
-#ifdef STTY_READS_STDOUT
- /* switch "<" to ">" */
- char original_redirect_char = (*redirect)[0];
- (*redirect)[0] = '>';
- /* stderr unredirected so we can get it directly! */
-#endif
- rc = exec_stty(interp,argc,argv0,0);
-#ifdef STTY_READS_STDOUT
- /* restore redirect - don't know if necessary */
- (*redirect)[0] = original_redirect_char;
-#endif
- }
- }
- done:
- exp_trap_on(master);
-
- return rc;
-}
-
-/*ARGSUSED*/
-static int
-Exp_SystemCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- int result = TCL_OK;
- RETSIGTYPE (*old)(); /* save old sigalarm handler */
-#define MAX_ARGLIST 10240
- int i;
-
- WAIT_STATUS_TYPE waitStatus;
- int systemStatus
-;
- int abnormalExit = FALSE;
- char buf[MAX_ARGLIST];
- char *bufp = buf;
- int total_len = 0, arg_len;
-
- int stty_args_recognized = TRUE;
- int cmd_is_stty = FALSE;
- int cooked = FALSE;
- int was_raw, was_echo;
-
- if (argc == 1) return TCL_OK;
-
- if (streq(argv[1],"stty")) {
- debuglog("system stty is deprecated, use stty\r\n");
-
- cmd_is_stty = TRUE;
- was_raw = exp_israw();
- was_echo = exp_isecho();
- }
-
- if (argc > 2 && cmd_is_stty) {
- exp_ioctled_devtty = TRUE;
-
- for (i=2;i<argc;i++) {
- if (streq(argv[i],"raw") ||
- streq(argv[i],"-cooked")) {
- exp_tty_raw(1);
- } else if (streq(argv[i],"-raw") ||
- streq(argv[i],"cooked")) {
- cooked = TRUE;
- exp_tty_raw(-1);
- } else if (streq(argv[i],"echo")) {
- exp_tty_echo(1);
- } else if (streq(argv[i],"-echo")) {
- exp_tty_echo(-1);
- } else stty_args_recognized = FALSE;
- }
-
- /* if unknown args, fall thru and let real stty have a go */
- if (stty_args_recognized) {
-#ifdef HAVE_TCSETATTR
- if (tcsetattr(exp_dev_tty,TCSADRAIN, &tty_current) == -1) {
-#else
- if (ioctl(exp_dev_tty, TCSETSW, &tty_current) == -1) {
-#endif
- if (exp_disconnected || (exp_dev_tty == -1) || !isatty(exp_dev_tty)) {
- errorlog("system stty: impossible in this context\n");
- errorlog("are you disconnected or in a batch, at, or cron script?");
- /* user could've conceivably closed /dev/tty as well */
- }
- exp_error(interp,"system stty: ioctl(user): %s\r\n",Tcl_PosixError(interp));
- return(TCL_ERROR);
- }
- if (cmd_is_stty) {
- sprintf(interp->result,"%sraw %secho",
- (was_raw?"":"-"),
- (was_echo?"":"-"));
- }
- return(TCL_OK);
- }
- }
-
- for (i = 1;i<argc;i++) {
- total_len += (1 + (arg_len = strlen(argv[i])));
- if (total_len > MAX_ARGLIST) {
- exp_error(interp,"args too long (>=%d chars)",
- total_len);
- return(TCL_ERROR);
- }
- memcpy(bufp,argv[i],arg_len);
- bufp += arg_len;
- /* no need to check bounds, we accted for it earlier */
- memcpy(bufp," ",1);
- bufp += 1;
- }
-
- *(bufp-1) = '\0';
- old = signal(SIGCHLD, SIG_DFL);
- systemStatus = system(buf);
- signal(SIGCHLD, old); /* restore signal handler */
- debuglog("system(%s) = %d\r\n",buf,i);
-
- if (systemStatus == -1) {
- exp_error(interp,Tcl_PosixError(interp));
- return TCL_ERROR;
- }
- *(int *)&waitStatus = systemStatus;
-
- if (!stty_args_recognized) {
- /* find out what weird options user asked for */
-#ifdef HAVE_TCSETATTR
- if (tcgetattr(exp_dev_tty, &tty_current) == -1) {
-#else
- if (ioctl(exp_dev_tty, TCGETS, &tty_current) == -1) {
-#endif
- errorlog("ioctl(get): %s\r\n",Tcl_PosixError(interp));
- exp_exit(interp,1);
- }
- if (cooked) {
- /* find out user's new defn of 'cooked' */
- tty_cooked = tty_current;
- }
- }
-
- if (cmd_is_stty) {
- sprintf(interp->result,"%sraw %secho",
- (was_raw?"":"-"),
- (was_echo?"":"-"));
- }
-
-/* following macros stolen from Tcl's tclUnix.h file */
-/* we can't include the whole thing because it depends on other macros */
-/* that come out of Tcl's Makefile, sigh */
-
-#if 0
-
-#undef WIFEXITED
-#ifndef WIFEXITED
-# define WIFEXITED(stat) (((*((int *) &(stat))) & 0xff) == 0)
-#endif
-
-#undef WEXITSTATUS
-#ifndef WEXITSTATUS
-# define WEXITSTATUS(stat) (((*((int *) &(stat))) >> 8) & 0xff)
-#endif
-
-#undef WIFSIGNALED
-#ifndef WIFSIGNALED
-# define WIFSIGNALED(stat) (((*((int *) &(stat)))) && ((*((int *) &(stat))) == ((*((int *) &(stat))) & 0x00ff)))
-#endif
-
-#undef WTERMSIG
-#ifndef WTERMSIG
-# define WTERMSIG(stat) ((*((int *) &(stat))) & 0x7f)
-#endif
-
-#undef WIFSTOPPED
-#ifndef WIFSTOPPED
-# define WIFSTOPPED(stat) (((*((int *) &(stat))) & 0xff) == 0177)
-#endif
-
-#undef WSTOPSIG
-#ifndef WSTOPSIG
-# define WSTOPSIG(stat) (((*((int *) &(stat))) >> 8) & 0xff)
-#endif
-
-#endif /* 0 */
-
-/* stolen from Tcl. Again, this is embedded in another routine */
-/* (CleanupChildren in tclUnixAZ.c) that we can't use directly. */
-
- if (!WIFEXITED(waitStatus) || (WEXITSTATUS(waitStatus) != 0)) {
- char msg1[20], msg2[20];
- int pid = 0; /* fake a pid, since system() won't tell us */
-
- result = TCL_ERROR;
- sprintf(msg1, "%d", pid);
- if (WIFEXITED(waitStatus)) {
- sprintf(msg2, "%d", WEXITSTATUS(waitStatus));
- Tcl_SetErrorCode(interp, "CHILDSTATUS", msg1, msg2,
- (char *) NULL);
- abnormalExit = TRUE;
- } else if (WIFSIGNALED(waitStatus)) {
- char *p;
-
- p = Tcl_SignalMsg((int) (WTERMSIG(waitStatus)));
- Tcl_SetErrorCode(interp, "CHILDKILLED", msg1,
- Tcl_SignalId((int) (WTERMSIG(waitStatus))), p,
- (char *) NULL);
- Tcl_AppendResult(interp, "child killed: ", p, "\n",
- (char *) NULL);
- } else if (WIFSTOPPED(waitStatus)) {
- char *p;
-
- p = Tcl_SignalMsg((int) (WSTOPSIG(waitStatus)));
- Tcl_SetErrorCode(interp, "CHILDSUSP", msg1,
- Tcl_SignalId((int) (WSTOPSIG(waitStatus))), p, (char *) NULL);
- Tcl_AppendResult(interp, "child suspended: ", p, "\n",
- (char *) NULL);
- } else {
- Tcl_AppendResult(interp,
- "child wait status didn't make sense\n",
- (char *) NULL);
- }
- }
-
- if (abnormalExit && (*interp->result == 0)) {
- Tcl_AppendResult(interp, "child process exited abnormally",
- (char *) NULL);
- }
-
- return result;
-}
-
-static struct exp_cmd_data
-cmd_data[] = {
-{"stty", exp_proc(Exp_SttyCmd), 0, 0},
-{"system", exp_proc(Exp_SystemCmd), 0, 0},
-{0}};
-
-void
-exp_init_tty_cmds(interp)
-struct Tcl_Interp *interp;
-{
- exp_create_commands(interp,cmd_data);
-}
+++ /dev/null
-/* exp_tty.h - tty support definitions
-
-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.
-*/
-
-#ifndef __EXP_TTY_H__
-#define __EXP_TTY_H__
-
-#include "expect_cf.h"
-
-extern int exp_dev_tty;
-extern int exp_ioctled_devtty;
-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_set();
-int exp_tty_set_simple();
-int exp_tty_get_simple();
-
-#endif /* __EXP_TTY_H__ */
+++ /dev/null
-/* exp_tty_comm.c - tty support routines common to both Expect program
- and library */
-
-#include "expect_cf.h"
-#include <stdio.h>
-
-#include "exp_tty_in.h"
-#include "exp_rename.h"
-#define EXP_AVOID_INCLUDING_TCL_H
-#include "expect_comm.h"
-#include "exp_log.h"
-
-#ifndef TRUE
-#define FALSE 0
-#define TRUE 1
-#endif
-
-int exp_disconnected = FALSE; /* not disc. from controlling tty */
-
-/*static*/ exp_tty exp_tty_current, exp_tty_cooked;
-#define tty_current exp_tty_current
-#define tty_cooked exp_tty_cooked
-
-void
-exp_init_tty()
-{
- extern exp_tty exp_tty_original;
-
- /* save original user tty-setting in 'cooked', just in case user */
- /* asks for it without earlier telling us what cooked means to them */
- tty_cooked = exp_tty_original;
-
- /* save our current idea of the terminal settings */
- tty_current = exp_tty_original;
-}
-
+++ /dev/null
-/* exp_tty_in.h - internal tty support definitions */
-
-/* Definitions for handling termio inclusion are localized here */
-/* This file should be included only if direct access to tty structures are */
-/* required. This file is necessary to avoid mismatch between gcc's and */
-/* vendor's include files */
-
-/* Written by Rob Savoye <rob@cygnus.com>. Mon Feb 22 11:16:53 RMT 1993 */
-
-#ifndef __EXP_TTY_IN_H__
-#define __EXP_TTY_IN_H__
-
-#include "expect_cf.h"
-
-#ifdef __MACHTEN__
-#include "sys/types.h"
-#endif
-
-/*
- * Set up some macros to isolate tty differences
- */
-
-/* On some hosts, termio is incomplete (broken) and sgtty is a better
-choice. At the same time, termio has some definitions for modern
-stuff like window sizes that sgtty lacks - that's why termio.h
-is included even when we claim the basic style is sgtty
-*/
-
-/* test for pyramid may be unnecessary, but only Pyramid people have */
-/* complained - notably pclink@qus102.qld.npb.telecom.com.au (Rick) */
-#if defined(pyr) && defined(HAVE_TERMIO) && defined(HAVE_SGTTYB)
-#undef HAVE_SGTTYB
-#endif
-
-/* on ISC SVR3.2, termios is skeletal and termio is a better choice. */
-/* sgttyb must also be avoided because it redefines same things that */
-/* termio does */
-/* note that both SVR3.2 and AIX lacks TCGETS or TCGETA in termios.h */
-/* but SVR3.2 lacks both TCSETATTR and TCGETS/A */
-#if defined(HAVE_TERMIO) && defined(HAVE_TERMIOS) && !defined(HAVE_TCGETS_OR_TCGETA_IN_TERMIOS_H) && !defined(HAVE_TCSETATTR)
-# undef HAVE_TERMIOS
-# undef HAVE_SGTTYB
-#endif
-
-#if defined(HAVE_TERMIO) && !defined(HAVE_TERMIOS)
-# include <termio.h>
-# undef POSIX
-# define TERMINAL termio
-# ifndef TCGETS
-# define TCGETS TCGETA
-# define TCSETS TCSETA
-# define TCSETSW TCSETAW
-# define TCSETSF TCSETAF
-# endif
-#endif
-
-#if defined(HAVE_SGTTYB) && !defined(HAVE_TERMIOS)
-# undef HAVE_TERMIO
-# undef POSIX
-#ifndef TCGETS
-# define TCGETS TIOCGETP
-# define TCSETS TIOCSETP
-#endif
-#ifndef TCSETSW
-# define TCSETSW TIOCSETN
-#endif
-# define TERMINAL sgttyb
-# ifdef HAVE_SYS_FCNTL_H
-# include <sys/fcntl.h>
-# else
-# include <fcntl.h>
-# endif
-# include <sgtty.h>
-# include <sys/ioctl.h>
-#endif
-
-
-#if defined(HAVE_TERMIOS)
-# undef HAVE_TERMIO
-# undef HAVE_SGTTYB
-# include <termios.h>
-# define TERMINAL termios
-# if !defined(TCGETS) || !defined(TCSETS)
-# define TCGETS TCGETA
-# define TCSETS TCSETA
-# define TCSETSW TCSETAW
-# define TCSETSF TCSETAF
-# endif
-#endif
-
-/* This section was written by: Don Libes, NIST, 2/6/90 */
-
-typedef struct TERMINAL exp_tty;
-extern exp_tty exp_tty_original;
-extern exp_tty exp_tty_current;
-extern exp_tty exp_tty_cooked;
-
-#include "exp_tty.h"
-
-#endif /* __EXP_TTY_IN_H__ */
+++ /dev/null
-/* exp_win.c - window support
-
-Written by: Don Libes, NIST, 10/25/93
-
-This file is in the public domain. However, the author and NIST
-would appreciate credit if you use this file or parts of it.
-
-*/
-
-#include "expect_cf.h"
-#include "tcl.h"
-
-#ifdef NO_STDLIB_H
-#include "../compat/stdlib.h"
-#else
-#include <stdlib.h>
-#endif
-
-/* _IBCS2 required on some Intel platforms to allow the include files */
-/* to produce a definition for winsize. */
-#define _IBCS2 1
-
-/*
- * get everyone's window size definitions
- *
-note that this is tricky because (of course) everyone puts them in
-different places. Worse, on some systems, some .h files conflict
-and cannot both be included even though both exist. This is the
-case, for example, on SunOS 4.1.3 using gcc where termios.h
-conflicts with sys/ioctl.h
- */
-
-#ifdef HAVE_TERMIOS
-# include <termios.h>
-#else
-# include <sys/ioctl.h>
-#endif
-
-/* Sigh. On AIX 2.3, termios.h exists but does not define TIOCGWINSZ */
-/* Instead, it has to come from ioctl.h. However, As I said above, this */
-/* can't be cavalierly included on all machines, even when it exists. */
-#if defined(HAVE_TERMIOS) && !defined(HAVE_TIOCGWINSZ_IN_TERMIOS_H)
-# include <sys/ioctl.h>
-#endif
-
-/* SCO defines window size structure in PTEM and TIOCGWINSZ in termio.h */
-/* Sigh... */
-#if defined(HAVE_SYS_PTEM_H)
-# include <sys/types.h> /* for stream.h's caddr_t */
-# include <sys/stream.h> /* for ptem.h's mblk_t */
-# include <sys/ptem.h>
-#endif /* HAVE_SYS_PTEM_H */
-
-#include "exp_tty.h"
-#include "exp_win.h"
-
-#ifdef TIOCGWINSZ
-typedef struct winsize exp_winsize;
-#define columns ws_col
-#define rows ws_row
-#define EXP_WIN
-#endif
-
-#if !defined(EXP_WIN) && defined(TIOCGSIZE)
-typedef struct ttysize exp_winsize;
-#define columns ts_cols
-#define rows ts_lines
-#define EXP_WIN
-#endif
-
-#if !defined(EXP_WIN)
-typedef struct {
- int columns;
- int rows;
-} exp_winsize;
-#endif
-
-static exp_winsize winsize = {0, 0};
-static exp_winsize win2size = {0, 0};
-
-int exp_window_size_set(fd)
-int fd;
-{
-#ifdef TIOCSWINSZ
- ioctl(fd,TIOCSWINSZ,&winsize);
-#endif
-#if defined(TIOCSSIZE) && !defined(TIOCSWINSZ)
- ioctl(fd,TIOCSSIZE,&winsize);
-#endif
-}
-
-int exp_window_size_get(fd)
-int fd;
-{
-#ifdef TIOCGWINSZ
- ioctl(fd,TIOCGWINSZ,&winsize);
-#endif
-#if defined(TIOCGSIZE) && !defined(TIOCGWINSZ)
- ioctl(fd,TIOCGSIZE,&winsize);
-#endif
-#if !defined(EXP_WIN)
- winsize.rows = 0;
- winsize.columns = 0;
-#endif
-}
-
-void
-exp_win_rows_set(rows)
-char *rows;
-{
- winsize.rows = atoi(rows);
- exp_window_size_set(exp_dev_tty);
-}
-
-void
-exp_win_rows_get(rows)
-char *rows;
-{
- exp_window_size_get(exp_dev_tty);
- sprintf(rows,"%d",winsize.rows);
-}
-
-void
-exp_win_columns_set(columns)
-char *columns;
-{
- winsize.columns = atoi(columns);
- exp_window_size_set(exp_dev_tty);
-}
-
-void
-exp_win_columns_get(columns)
-char *columns;
-{
- exp_window_size_get(exp_dev_tty);
- sprintf(columns,"%d",winsize.columns);
-}
-
-/*
- * separate copy of everything above - used for handling user stty requests
- */
-
-int exp_win2_size_set(fd)
-int fd;
-{
-#ifdef TIOCSWINSZ
- ioctl(fd,TIOCSWINSZ,&win2size);
-#endif
-#if defined(TIOCSSIZE) && !defined(TIOCSWINSZ)
- ioctl(fd,TIOCSSIZE,&win2size);
-#endif
-}
-
-int exp_win2_size_get(fd)
-int fd;
-{
-#ifdef TIOCGWINSZ
- ioctl(fd,TIOCGWINSZ,&win2size);
-#endif
-#if defined(TIOCGSIZE) && !defined(TIOCGWINSZ)
- ioctl(fd,TIOCGSIZE,&win2size);
-#endif
-}
-
-void
-exp_win2_rows_set(fd,rows)
-int fd;
-char *rows;
-{
- exp_win2_size_get(fd);
- win2size.rows = atoi(rows);
- exp_win2_size_set(fd);
-}
-
-void
-exp_win2_rows_get(fd,rows)
-int fd;
-char *rows;
-{
- exp_win2_size_get(fd);
- sprintf(rows,"%d",win2size.rows);
-#if !defined(EXP_WIN)
- win2size.rows = 0;
- win2size.columns = 0;
-#endif
-}
-
-void
-exp_win2_columns_set(fd,columns)
-int fd;
-char *columns;
-{
- exp_win2_size_get(fd);
- win2size.columns = atoi(columns);
- exp_win2_size_set(fd);
-}
-
-void
-exp_win2_columns_get(fd,columns)
-int fd;
-char *columns;
-{
- exp_win2_size_get(fd);
- sprintf(columns,"%d",win2size.columns);
-}
+++ /dev/null
-/* exp_win.h - window support
-
-Written by: Don Libes, NIST, 10/25/93
-
-This file is in the public domain. However, the author and NIST
-would appreciate credit if you use this file or parts of it.
-*/
-
-int exp_window_size_set();
-int exp_window_size_get();
-
-void exp_win_rows_set();
-void exp_win_rows_get();
-void exp_win_columns_set();
-void exp_win_columns_get();
-
-void exp_win2_rows_set();
-void exp_win2_rows_get();
-void exp_win2_columns_set();
-void exp_win2_columns_get();
+++ /dev/null
-/* expect.c - expect commands
-
-Written by: Don Libes, NIST, 2/6/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.
-
-*/
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <signal.h>
-#include <errno.h>
-#include <ctype.h> /* for isspace */
-#include <time.h> /* for time(3) */
-#if 0
-#include <setjmp.h>
-#endif
-
-#include "expect_cf.h"
-
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#include "tcl.h"
-
-#include "string.h"
-
-#include "tcl_regexp.h"
-#include "exp_rename.h"
-#include "exp_prog.h"
-#include "exp_command.h"
-#include "exp_log.h"
-#include "exp_event.h"
-#include "exp_tty.h"
-#include "exp_tstamp.h" /* this should disappear when interact */
- /* loses ref's to it */
-#ifdef TCL_DEBUGGER
-#include "Dbg.h"
-#endif
-
-/* initial length of strings that we can guarantee patterns can match */
-int exp_default_match_max = 2000;
-#define INIT_EXPECT_TIMEOUT_LIT "10" /* seconds */
-#define INIT_EXPECT_TIMEOUT 10 /* seconds */
-int exp_default_parity = TRUE;
-int exp_default_rm_nulls = TRUE;
-
-/* user variable names */
-#define EXPECT_TIMEOUT "timeout"
-#define EXPECT_OUT "expect_out"
-
-/* 1 ecase struct is reserved for each case in the expect command. Note that
-eof/timeout don't use any of theirs, but the algorithm is simpler this way. */
-
-struct ecase { /* case for expect command */
- struct exp_i *i_list;
- char *pat; /* original pattern spec */
- char *body; /* ptr to body to be executed upon match */
-#define PAT_EOF 1
-#define PAT_TIMEOUT 2
-#define PAT_DEFAULT 3
-#define PAT_FULLBUFFER 4
-#define PAT_GLOB 5 /* glob-style pattern list */
-#define PAT_RE 6 /* regular expression */
-#define PAT_EXACT 7 /* exact string */
-#define PAT_NULL 8 /* ASCII 0 */
-#define PAT_TYPES 9 /* used to size array of pattern type descriptions */
- int use; /* PAT_XXX */
- int simple_start;/* offset from start of buffer denoting where a */
- /* glob or exact match begins */
- int transfer; /* if false, leave matched chars in input stream */
- int indices; /* if true, write indices */
-/* int iwrite;*/ /* if true write spawn_id */
- int iread; /* if true, reread indirects */
- int timestamp; /* if true, write timestamps */
-#define CASE_UNKNOWN 0
-#define CASE_NORM 1
-#define CASE_LOWER 2
- int Case; /* convert case before doing match? */
- Expect_regexp *re; /* if this is 0, then pattern match via glob */
-};
-
-/* descriptions of the pattern types, used for debugging */
-char *pattern_style[PAT_TYPES];
-
-struct exp_cases_descriptor {
- int count;
- struct ecase **cases;
-};
-
-/* This describes an Expect command */
-static
-struct exp_cmd_descriptor {
- int cmdtype; /* bg, before, after */
- int duration; /* permanent or temporary */
- int timeout_specified_by_flag; /* if -timeout flag used */
- int timeout; /* timeout period if flag used */
- struct exp_cases_descriptor ecd;
- struct exp_i *i_list;
-} exp_cmds[4];
-/* note that exp_cmds[FG] is just a fake, the real contents is stored
- in some dynamically-allocated variable. We use exp_cmds[FG] mostly
- as a well-known address and also as a convenience and so we allocate
- just a few of its fields that we need. */
-
-static void
-exp_cmd_init(cmd,cmdtype,duration)
-struct exp_cmd_descriptor *cmd;
-int duration;
-int cmdtype;
-{
- cmd->duration = duration;
- cmd->cmdtype = cmdtype;
- cmd->ecd.cases = 0;
- cmd->ecd.count = 0;
- cmd->i_list = 0;
-}
-
-static int i_read_errno;/* place to save errno, if i_read() == -1, so it
- doesn't get overwritten before we get to read it */
-#if 0
-static jmp_buf env; /* for interruptable read() */
- /* longjmp(env,1) times out the read */
- /* longjmp(env,2) restarts the read */
-static int env_valid = FALSE; /* whether we can longjmp or not */
-#endif
-
-#ifdef SIMPLE_EVENT
-static int alarm_fired; /* if alarm occurs */
-#endif
-
-void exp_background_filehandlers_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 int exp_i_read _ANSI_ARGS_((Tcl_Interp *,int,int,int));
-
-#ifdef SIMPLE_EVENT
-/*ARGSUSED*/
-static RETSIGTYPE
-sigalarm_handler(n)
-int n; /* unused, for compatibility with STDC */
-{
- alarm_fired = TRUE;
-#if 0
- /* check env_valid first to protect us from the alarm occurring */
- /* in the window between i_read and alarm(0) */
- if (env_valid) longjmp(env,1);
-#endif /*0*/
-}
-#endif /*SIMPLE_EVENT*/
-
-#if 0
-/*ARGSUSED*/
-static RETSIGTYPE
-sigalarm_handler(n)
-int n; /* unused, for compatibility with STDC */
-{
-#ifdef REARM_SIG
- signal(SIGALRM,sigalarm_handler);
-#endif
-
- /* check env_valid first to protect us from the alarm occurring */
- /* in the window between i_read and alarm(0) */
- if (env_valid) longjmp(env,1);
-}
-#endif /*0*/
-
-#if 0
-
-/* upon interrupt, act like timeout */
-/*ARGSUSED*/
-static RETSIGTYPE
-sigint_handler(n)
-int n; /* unused, for compatibility with STDC */
-{
-#ifdef REARM_SIG
- signal(SIGINT,sigint_handler);/* not nec. for BSD, but doesn't hurt */
-#endif
-
-#ifdef TCL_DEBUGGER
- if (exp_tcl_debugger_available) {
- /* if the debugger is active and we're reading something, */
- /* force the debugger to go interactive now and when done, */
- /* restart the read. */
-
- Dbg_On(exp_interp,env_valid);
-
- /* restart the read */
- if (env_valid) longjmp(env,2);
-
- /* if no read is in progess, just let debugger start at */
- /* the next command. */
- return;
- }
-#endif
-
-#if 0
-/* the ability to timeout a read via ^C is hereby removed 8-Mar-1993 - DEL */
-
- /* longjmp if we are executing a read inside of expect command */
- if (env_valid) longjmp(env,1);
-#endif
-
- /* if anywhere else in code, prepare to exit */
- exp_exit(exp_interp,0);
-}
-#endif /*0*/
-
-/* remove nulls from s. Initially, the number of chars in s is c, */
-/* not strlen(s). This count does not include the trailing null. */
-/* returns number of nulls removed. */
-static int
-rm_nulls(s,c)
-char *s;
-int c;
-{
- char *s2 = s; /* points to place in original string to put */
- /* next non-null character */
- int count = 0;
- int i;
-
- for (i=0;i<c;i++,s++) {
- if (0 == *s) {
- count++;
- continue;
- }
- if (count) *s2 = *s;
- s2++;
- }
- return(count);
-}
-
-/* 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 */
-{
- if (ec->re) ckfree((char *)ec->re);
-
- if (ec->i_list->duration == EXP_PERMANENT) {
- if (ec->pat) ckfree(ec->pat);
- if (ec->body) ckfree(ec->body);
- }
-
- if (free_ilist) {
- ec->i_list->ecount--;
- if (ec->i_list->ecount == 0)
- exp_free_i(interp,ec->i_list,exp_indirect_update2);
- }
-
- ckfree((char *)ec); /* NEW */
-}
-
-/* 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 */
-{
- int i;
-
- if (!eg->ecd.cases) return;
-
- for (i=0;i<eg->ecd.count;i++) {
- free_ecase(interp,eg->ecd.cases[i],free_ilist);
- }
- ckfree((char *)eg->ecd.cases);
-
- eg->ecd.cases = 0;
- eg->ecd.count = 0;
-}
-
-
-#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;
-{
- char *news = ckalloc(strlen(s) + 1);
- strcpy(news,s);
- return(news);
-}
-#endif
-
-/* In many places, there is no need to malloc a copy of a string, since it */
-/* will be freed before we return to Tcl */
-static void
-save_str(lhs,rhs,nosave)
-char **lhs; /* left hand side */
-char *rhs; /* right hand side */
-int nosave;
-{
- if (nosave || (rhs == 0)) {
- *lhs = rhs;
- } else {
- *lhs = ckalloc(strlen(rhs) + 1);
- strcpy(*lhs,rhs);
- }
-}
-
-/* return TRUE if string appears to be a set of arguments
- The intent of this test is to support the ability of commands to have
- all their args braced as one. This conflicts with the possibility of
- actually intending to have a single argument.
- The bad case is in expect which can have a single argument with embedded
- \n's although it's rare. Examples that this code should handle:
- \n FALSE (pattern)
- \n\n FALSE
- \n \n \n FALSE
- foo FALSE
- foo\n FALSE
- \nfoo\n TRUE (set of args)
- \nfoo\nbar TRUE
-
- Current test is very cheap and almost always right :-)
-*/
-int
-exp_one_arg_braced(p)
-char *p;
-{
- int seen_nl = FALSE;
-
- for (;*p;p++) {
- if (*p == '\n') {
- seen_nl = TRUE;
- continue;
- }
-
- if (!isspace(*p)) {
- return(seen_nl);
- }
- }
- return FALSE;
-}
-
-/* called to execute a command of only one argument - a hack to commands */
-/* to be called with all args surrounded by an outer set of braces */
-/* returns TCL_whatever */
-/*ARGSUSED*/
-int
-exp_eval_with_one_arg(clientData,interp,argv)
-ClientData clientData;
-Tcl_Interp *interp;
-char **argv;
-{
- char *buf;
- int rc;
- char *a;
-
- /* + 11 is for " -nobrace " and null at end */
- buf = ckalloc(strlen(argv[0]) + strlen(argv[1]) + 11);
- /* recreate statement (with -nobrace to prevent recursion) */
- sprintf(buf,"%s -nobrace %s",argv[0],argv[1]);
-
- /*
- * replace top-level newlines with blanks
- */
-
- /* Should only be necessary to run over argv[1] and then sprintf */
- /* that into the buffer, but the ICEM guys insist that writing */
- /* back over the original arguments makes their Tcl compiler very */
- /* unhappy. */
- for (a=buf;*a;) {
- extern char *TclWordEnd();
-
- for (;isspace(*a);a++) {
- if (*a == '\n') *a = ' ';
- }
-#if TCL_MAJOR_VERSION < 8
- a = TclWordEnd(a,0,(int *)0)+1;
-#else
- a = TclWordEnd(a,&a[strlen(a)],0,(int *)0)+1;
-#endif
- }
-
- rc = Tcl_Eval(interp,buf);
-
- ckfree(buf);
- return(rc);
-}
-
-static void
-ecase_clear(ec)
-struct ecase *ec;
-{
- ec->i_list = 0;
- ec->pat = 0;
- ec->body = 0;
- ec->transfer = TRUE;
- ec->indices = FALSE;
-/* ec->iwrite = FALSE;*/
- ec->iread = FALSE;
- ec->timestamp = FALSE;
- ec->re = 0;
- ec->Case = CASE_NORM;
- ec->use = PAT_GLOB;
-}
-
-static struct ecase *
-ecase_new()
-{
- struct ecase *ec = (struct ecase *)ckalloc(sizeof(struct ecase));
-
- ecase_clear(ec);
- return ec;
-}
-
-/*
-
-parse_expect_args parses the arguments to expect or its variants.
-It normally returns TCL_OK, and returns TCL_ERROR for failure.
-(It can't return i_list directly because there is no way to differentiate
-between clearing, say, expect_before and signalling an error.)
-
-eg (expect_global) is initialized to reflect the arguments parsed
-eg->ecd.cases is an array of ecases
-eg->ecd.count is the # of ecases
-eg->i_list is a linked list of exp_i's which represent the -i info
-
-Each exp_i is chained to the next so that they can be easily free'd if
-necessary. Each exp_i has a reference count. If the -i is not used
-(e.g., has no following patterns), the ref count will be 0.
-
-Each ecase points to an exp_i. Several ecases may point to the same exp_i.
-Variables named by indirect exp_i's are read for the direct values.
-
-If called from a foreground expect and no patterns or -i are given, a
-default exp_i is forced so that the command "expect" works right.
-
-The exp_i chain can be broken by the caller if desired.
-
-*/
-
-static int
-parse_expect_args(interp,eg,default_spawn_id,argc,argv)
-Tcl_Interp *interp;
-struct exp_cmd_descriptor *eg;
-int default_spawn_id; /* suggested master if called as expect_user or _tty */
-int argc;
-char **argv;
-{
- int i;
- char *arg;
- struct ecase ec; /* temporary to collect args */
-
- argv++;
- argc--;
-
- eg->timeout_specified_by_flag = FALSE;
-
- ecase_clear(&ec);
-
- /* Allocate an array to store the ecases. Force array even if 0 */
- /* cases. This will often be too large (i.e., if there are flags) */
- /* but won't affect anything. */
-
- eg->ecd.cases = (struct ecase **)ckalloc(
- sizeof(struct ecase *) * (1+(argc/2)));
-
- eg->ecd.count = 0;
-
- for (i = 0;i<argc;i++) {
- arg = argv[i];
-
- if (exp_flageq("timeout",arg,7)) {
- ec.use = PAT_TIMEOUT;
- } else if (exp_flageq("eof",arg,3)) {
- ec.use = PAT_EOF;
- } else if (exp_flageq("full_buffer",arg,11)) {
- ec.use = PAT_FULLBUFFER;
- } else if (exp_flageq("default",arg,7)) {
- ec.use = PAT_DEFAULT;
- } else if (exp_flageq("null",arg,4)) {
- ec.use = PAT_NULL;
- } else if (arg[0] == '-') {
- arg++;
- if (exp_flageq1('-',arg) /* "--" is deprecated */
- || exp_flageq("glob",arg,2)) {
- i++;
- /* assignment here is not actually necessary */
- /* since cases are initialized this way above */
- /* ec.use = PAT_GLOB; */
- } else if (exp_flageq("regexp",arg,2)) {
- i++;
- ec.use = PAT_RE;
- Expect_TclRegError((char *)0);
- if (!(ec.re = Expect_TclRegComp(argv[i]))) {
- exp_error(interp,"bad regular expression: %s",
- TclGetRegError());
- goto error;
- }
- } else if (exp_flageq("exact",arg,2)) {
- i++;
- ec.use = PAT_EXACT;
- } else if (exp_flageq("notransfer",arg,1)) {
- ec.transfer = 0;
- continue;
- } else if (exp_flageq("nocase",arg,3)) {
- ec.Case = CASE_LOWER;
- continue;
- } else if (exp_flageq1('i',arg)) {
- i++;
- if (i>=argc) {
- exp_error(interp,"-i requires following spawn_id");
- goto error;
- }
-
- ec.i_list = exp_new_i_complex(interp,argv[i],
- eg->duration,exp_indirect_update2);
-
- ec.i_list->cmdtype = eg->cmdtype;
-
- /* link new i_list to head of list */
- ec.i_list->next = eg->i_list;
- eg->i_list = ec.i_list;
-
- continue;
- } else if (exp_flageq("indices",arg,2)) {
- ec.indices = TRUE;
- continue;
- } else if (exp_flageq("iwrite",arg,2)) {
-/* ec.iwrite = TRUE;*/
- continue;
- } else if (exp_flageq("iread",arg,2)) {
- ec.iread = TRUE;
- continue;
- } else if (exp_flageq("timestamp",arg,2)) {
- ec.timestamp = TRUE;
- continue;
- } else if (exp_flageq("timeout",arg,2)) {
- i++;
- if (i>=argc) {
- exp_error(interp,"-timeout requires following # of seconds");
- goto error;
- }
-
- eg->timeout = atoi(argv[i]);
- eg->timeout_specified_by_flag = TRUE;
- continue;
- } else if (exp_flageq("nobrace",arg,7)) {
- /* nobrace does nothing but take up space */
- /* on the command line which prevents */
- /* us from re-expanding any command lines */
- /* of one argument that looks like it should */
- /* be expanded to multiple arguments. */
- continue;
- } else {
- exp_error(interp,"usage: unrecognized flag <%s>",arg);
- goto error;
- }
- }
-
- /* if no -i, use previous one */
- if (!ec.i_list) {
- /* if no -i flag has occurred yet, use default */
- if (!eg->i_list) {
- if (default_spawn_id != EXP_SPAWN_ID_BAD) {
- eg->i_list = exp_new_i_simple(default_spawn_id,eg->duration);
- } else {
- /* it'll be checked later, if used */
- (void) exp_update_master(interp,&default_spawn_id,0,0);
- eg->i_list = exp_new_i_simple(default_spawn_id,eg->duration);
- }
- }
- ec.i_list = eg->i_list;
- }
- ec.i_list->ecount++;
-
- /* save original pattern spec */
- /* keywords such as "-timeout" are saved as patterns here */
- /* useful for debugging but not otherwise used */
- save_str(&ec.pat,argv[i],eg->duration == EXP_TEMPORARY);
- save_str(&ec.body,argv[i+1],eg->duration == EXP_TEMPORARY);
-
- i++;
-
- *(eg->ecd.cases[eg->ecd.count] = ecase_new()) = ec;
-
- /* clear out for next set */
- ecase_clear(&ec);
-
- eg->ecd.count++;
- }
-
- /* if no patterns at all have appeared force the current */
- /* spawn id to be added to list anyway */
-
- if (eg->i_list == 0) {
- if (default_spawn_id != EXP_SPAWN_ID_BAD) {
- eg->i_list = exp_new_i_simple(default_spawn_id,eg->duration);
- } else {
- /* it'll be checked later, if used */
- (void) exp_update_master(interp,&default_spawn_id,0,0);
- eg->i_list = exp_new_i_simple(default_spawn_id,eg->duration);
- }
- }
-
- return(TCL_OK);
-
- error:
- /* very hard to free case_master_list here if it hasn't already */
- /* been attached to a case, ugh */
-
- /* note that i_list must be avail to free ecases! */
- free_ecases(interp,eg,0);
-
- /* undo temporary ecase */
- /* free_ecase doesn't quite handle this right, so do it by hand */
- if (ec.re) ckfree((char *)ec.re);
- if (eg->duration == EXP_PERMANENT) {
- if (ec.pat) ckfree(ec.pat);
- if (ec.body) ckfree(ec.body);
- }
-
- if (eg->i_list)
- exp_free_i(interp,eg->i_list,exp_indirect_update2);
- return(TCL_ERROR);
-}
-
-#define EXP_IS_DEFAULT(x) ((x) == EXP_TIMEOUT || (x) == EXP_EOF)
-
-static char yes[] = "yes\r\n";
-static char no[] = "no\r\n";
-
-/* this describes status of a successful match */
-struct eval_out {
- struct ecase *e; /* ecase that matched */
- struct exp_f *f; /* struct exp_f that matched */
- char *buffer; /* buffer that matched */
- int match; /* # of chars in buffer that matched */
- /* or # of chars in buffer at EOF */
-};
-
-
-/* like eval_cases, but handles only a single cases that needs a real */
-/* string match */
-/* returns EXP_X where X is MATCH, NOMATCH, FULLBUFFER, TCLERRROR */
-static int
-eval_case_string(interp,e,m,o,last_f,last_case,suffix)
-Tcl_Interp *interp;
-struct ecase *e;
-int m;
-struct eval_out *o; /* 'output' - i.e., final case of interest */
-/* next two args are for debugging, when they change, reprint buffer */
-struct exp_f **last_f;
-int *last_case;
-char *suffix;
-{
- struct exp_f *f = exp_fs + m;
- char *buffer;
-
- /* if -nocase, use the lowerized buffer */
- buffer = ((e->Case == CASE_NORM)?f->buffer:f->lower);
-
- /* if master or case changed, redisplay debug-buffer */
- if ((f != *last_f) || e->Case != *last_case) {
- debuglog("\r\nexpect%s: does \"%s\" (spawn_id %d) match %s ",
- suffix,
- dprintify(buffer),f-exp_fs,
- pattern_style[e->use]);
- *last_f = f;
- *last_case = e->Case;
- }
-
- if (e->use == PAT_RE) {
- debuglog("\"%s\"? ",dprintify(e->pat));
- Expect_TclRegError((char *)0);
- if (buffer && Expect_TclRegExec(e->re,buffer,buffer)) {
- o->e = e;
- o->match = e->re->endp[0]-buffer;
- o->buffer = buffer;
- o->f = f;
- debuglog(yes);
- return(EXP_MATCH);
- } else {
- debuglog(no);
- if (TclGetRegError()) {
- exp_error(interp,"-re failed: %s",TclGetRegError());
- return(EXP_TCLERROR);
- }
- }
- } else if (e->use == PAT_GLOB) {
- int match; /* # of chars that matched */
-
- debuglog("\"%s\"? ",dprintify(e->pat));
- if (buffer && (-1 != (match = Exp_StringMatch(
- buffer,e->pat,&e->simple_start)))) {
- o->e = e;
- o->match = match;
- o->buffer = buffer;
- o->f = f;
- debuglog(yes);
- return(EXP_MATCH);
- } else debuglog(no);
- } else if (e->use == PAT_EXACT) {
- char *p = strstr(buffer,e->pat);
- debuglog("\"%s\"? ",dprintify(e->pat));
- if (p) {
- e->simple_start = p - buffer;
- o->e = e;
- o->match = strlen(e->pat);
- o->buffer = buffer;
- o->f = f;
- debuglog(yes);
- return(EXP_MATCH);
- } else debuglog(no);
- } else if (e->use == PAT_NULL) {
- int i = 0;
- debuglog("null? ");
- for (;i<f->size;i++) {
- if (buffer[i] == 0) {
- o->e = e;
- o->match = i+1; /* in this case, match is */
- /* just the # of chars + 1 */
- /* before the null */
- o->buffer = buffer;
- o->f = f;
- debuglog(yes);
- return EXP_MATCH;
- }
- }
- debuglog(no);
- } else if ((f->size == f->msize) && (f->size > 0)) {
- debuglog("%s? ",e->pat);
- o->e = e;
- o->match = f->umsize;
- o->buffer = f->buffer;
- o->f = f;
- debuglog(yes);
- return(EXP_FULLBUFFER);
- }
- return(EXP_NOMATCH);
-}
-
-/* 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,m,o,last_f,last_case,status,masters,mcount,suffix)
-Tcl_Interp *interp;
-struct exp_cmd_descriptor *eg;
-int m;
-struct eval_out *o; /* 'output' - i.e., final case of interest */
-/* next two args are for debugging, when they change, reprint buffer */
-struct exp_f **last_f;
-int *last_case;
-int status;
-int *masters;
-int mcount;
-char *suffix;
-{
- int i;
- int em; /* master of ecase */
- struct ecase *e;
-
- if (o->e || status == EXP_TCLERROR || eg->ecd.count == 0) return(status);
-
- if (status == EXP_TIMEOUT) {
- for (i=0;i<eg->ecd.count;i++) {
- e = eg->ecd.cases[i];
- if (e->use == PAT_TIMEOUT || e->use == PAT_DEFAULT) {
- o->e = e;
- break;
- }
- }
- return(status);
- } else if (status == EXP_EOF) {
- for (i=0;i<eg->ecd.count;i++) {
- e = eg->ecd.cases[i];
- if (e->use == PAT_EOF || e->use == PAT_DEFAULT) {
- struct exp_fd_list *fdl;
-
- for (fdl=e->i_list->fd_list; fdl ;fdl=fdl->next) {
- em = fdl->fd;
- if (em == EXP_SPAWN_ID_ANY || em == m) {
- o->e = e;
- return(status);
- }
- }
- }
- }
- return(status);
- }
-
- /* the top loops are split from the bottom loop only because I can't */
- /* split'em further. */
-
- /* The bufferful condition does not prevent a pattern match from */
- /* occurring and vice versa, so it is scanned with patterns */
- for (i=0;i<eg->ecd.count;i++) {
- struct exp_fd_list *fdl;
- int j;
-
- e = eg->ecd.cases[i];
- if (e->use == PAT_TIMEOUT ||
- e->use == PAT_DEFAULT ||
- e->use == PAT_EOF) continue;
-
- for (fdl = e->i_list->fd_list; fdl; fdl = fdl->next) {
- em = fdl->fd;
- /* if em == EXP_SPAWN_ID_ANY, then user is explicitly asking */
- /* every case to be checked against every master */
- if (em == EXP_SPAWN_ID_ANY) {
- /* test against each spawn_id */
- for (j=0;j<mcount;j++) {
- status = eval_case_string(interp,e,masters[j],o,last_f,last_case,suffix);
- if (status != EXP_NOMATCH) return(status);
- }
- } else {
- /* reject things immediately from wrong spawn_id */
- if (em != m) continue;
-
- status = eval_case_string(interp,e,m,o,last_f,last_case,suffix);
- if (status != EXP_NOMATCH) return(status);
- }
- }
- }
- return(EXP_NOMATCH);
-}
-
-static void
-ecases_remove_by_expi(interp,ecmd,exp_i)
-Tcl_Interp *interp;
-struct exp_cmd_descriptor *ecmd;
-struct exp_i *exp_i;
-{
- int i;
-
- /* delete every ecase dependent on it */
- for (i=0;i<ecmd->ecd.count;) {
- struct ecase *e = ecmd->ecd.cases[i];
- if (e->i_list == exp_i) {
- free_ecase(interp,e,0);
-
- /* shift remaining elements down */
- /* but only if there are any left */
- if (i+1 != ecmd->ecd.count) {
- memcpy(&ecmd->ecd.cases[i],
- &ecmd->ecd.cases[i+1],
- ((ecmd->ecd.count - i) - 1) *
- sizeof(struct exp_cmd_descriptor *));
- }
- ecmd->ecd.count--;
- if (0 == ecmd->ecd.count) {
- ckfree((char *)ecmd->ecd.cases);
- ecmd->ecd.cases = 0;
- }
- } else {
- i++;
- }
- }
-}
-
-/* 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 */
-{
- /* since it's in middle of list, free exp_i by hand */
- for (;*ei; ei = &(*ei)->next) {
- if (*ei == exp_i) {
- *ei = exp_i->next;
- exp_i->next = 0;
- exp_free_i(interp,exp_i,exp_indirect_update2);
- break;
- }
- }
-}
-
-/* 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;
-{
- ecases_remove_by_expi(interp,ecmd,exp_i);
- exp_i_remove(interp,&ecmd->i_list,exp_i);
-}
-
-/* remove ecases tied to a single direct spawn id */
-static void
-ecmd_remove_fd(interp,ecmd,m,direct)
-Tcl_Interp *interp;
-struct exp_cmd_descriptor *ecmd;
-int m;
-int direct;
-{
- struct exp_i *exp_i, *next;
- struct exp_fd_list **fdl;
-
- for (exp_i=ecmd->i_list;exp_i;exp_i=next) {
- next = exp_i->next;
-
- if (!(direct & exp_i->direct)) continue;
-
- for (fdl = &exp_i->fd_list;*fdl;) {
- if (m == ((*fdl)->fd)) {
- struct exp_fd_list *tmp = *fdl;
- *fdl = (*fdl)->next;
- exp_free_fd_single(tmp);
-
- /* if last bg ecase, disarm spawn id */
- if ((ecmd->cmdtype == EXP_CMD_BG) && (m != EXP_SPAWN_ID_ANY)) {
- exp_fs[m].bg_ecount--;
- if (exp_fs[m].bg_ecount == 0) {
- exp_disarm_background_filehandler(m);
- exp_fs[m].bg_interp = 0;
- }
- }
-
- continue;
- }
- fdl = &(*fdl)->next;
- }
-
- /* if left with no fds (and is direct), get rid of it */
- /* and any dependent ecases */
- if (exp_i->direct == EXP_DIRECT && !exp_i->fd_list) {
- exp_i_remove_with_ecases(interp,ecmd,exp_i);
- }
- }
-}
-
-/* this is called from exp_close to clean up the fd */
-void
-exp_ecmd_remove_fd_direct_and_indirect(interp,m)
-Tcl_Interp *interp;
-int m;
-{
- ecmd_remove_fd(interp,&exp_cmds[EXP_CMD_BEFORE],m,EXP_DIRECT|EXP_INDIRECT);
- ecmd_remove_fd(interp,&exp_cmds[EXP_CMD_AFTER],m,EXP_DIRECT|EXP_INDIRECT);
- ecmd_remove_fd(interp,&exp_cmds[EXP_CMD_BG],m,EXP_DIRECT|EXP_INDIRECT);
-
- /* force it - explanation in exp_tk.c where this func is defined */
- exp_disarm_background_filehandler_force(m);
-}
-
-/* arm a list of background fd's */
-static void
-fd_list_arm(interp,fdl)
-Tcl_Interp *interp;
-struct exp_fd_list *fdl;
-{
- /* for each spawn id in list, arm if necessary */
- for (;fdl;fdl=fdl->next) {
- int m = fdl->fd;
- if (m == EXP_SPAWN_ID_ANY) continue;
-
- if (exp_fs[m].bg_ecount == 0) {
- exp_arm_background_filehandler(m);
- exp_fs[m].bg_interp = interp;
- }
- exp_fs[m].bg_ecount++;
- }
-}
-
-/* return TRUE if this ecase is used by this fd */
-static int
-exp_i_uses_fd(exp_i,fd)
-struct exp_i *exp_i;
-int fd;
-{
- struct exp_fd_list *fdp;
-
- for (fdp = exp_i->fd_list;fdp;fdp=fdp->next) {
- if (fdp->fd == fd) return 1;
- }
- return 0;
-}
-
-static void
-ecase_append(interp,ec)
-Tcl_Interp *interp;
-struct ecase *ec;
-{
- if (!ec->transfer) Tcl_AppendElement(interp,"-notransfer");
- if (ec->indices) Tcl_AppendElement(interp,"-indices");
-/* if (ec->iwrite) Tcl_AppendElement(interp,"-iwrite");*/
- if (!ec->Case) Tcl_AppendElement(interp,"-nocase");
-
- if (ec->re) Tcl_AppendElement(interp,"-re");
- else if (ec->use == PAT_GLOB) Tcl_AppendElement(interp,"-gl");
- else if (ec->use == PAT_EXACT) Tcl_AppendElement(interp,"-ex");
- Tcl_AppendElement(interp,ec->pat);
- Tcl_AppendElement(interp,ec->body?ec->body:"");
-}
-
-/* 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;
-{
- int i;
- for (i=0;i<ecmd->ecd.count;i++) {
- if (ecmd->ecd.cases[i]->i_list == exp_i) {
- ecase_append(interp,ecmd->ecd.cases[i]);
- }
- }
-}
-
-static void
-exp_i_append(interp,exp_i)
-Tcl_Interp *interp;
-struct exp_i *exp_i;
-{
- Tcl_AppendElement(interp,"-i");
- if (exp_i->direct == EXP_INDIRECT) {
- Tcl_AppendElement(interp,exp_i->variable);
- } else {
- struct exp_fd_list *fdp;
-
- /* if more than one element, add braces */
- if (exp_i->fd_list->next)
- Tcl_AppendResult(interp," {",(char *)0);
-
- for (fdp = exp_i->fd_list;fdp;fdp=fdp->next) {
- char buf[10]; /* big enough for a small int */
- sprintf(buf,"%d",fdp->fd);
- Tcl_AppendElement(interp,buf);
- }
-
- if (exp_i->fd_list->next)
- Tcl_AppendResult(interp,"} ",(char *)0);
- }
-}
-
-#if 0
-/* delete ecases based on named -i descriptors */
-int
-expect_delete(interp,ecmd,argc,argv)
-Tcl_Interp *interp;
-struct exp_cmd_descriptor *ecmd;
-int argc;
-char **argv;
-{
- while (*argv) {
- if (streq(argv[0],"-i") && argv[1]) {
- iflag = argv[1];
- argc-=2; argv+=2;
- } else if (streq(argv[0],"-all")) {
- all = TRUE;
- argc--; argv++;
- } else if (streq(argv[0],"-noindirect")) {
- direct &= ~EXP_INDIRECT;
- argc--; argv++;
- } else {
- exp_error(interp,"usage: -delete [-all | -i spawn_id]\n");
- return TCL_ERROR;
- }
- }
-
- if (all) {
- /* same logic as at end of regular expect cmd */
- free_ecases(interp,ecmd,0);
- exp_free_i(interp,ecmd->i_list,exp_indirect_update2);
- return TCL_OK;
- }
-
- if (!iflag) {
- if (0 == exp_update_master(interp,&m,0,0)) {
- return TCL_ERROR;
- }
- } else if (Tcl_GetInt(interp,iflag,&m) != TCL_OK) {
- /* handle as in indirect */
-
- struct exp_i **old_i;
-
- for (old_i=&ecmd->i_list;*old_i;) {
- struct exp_i *tmp;
-
- if ((*old_i)->direct == EXP_DIRECT) continue;
- if (!streq((*old_i)->variable,iflag)) continue;
-
- ecases_remove_by_expi(interp,ecmd,*old_i);
-
- /* unlink from middle of list */
- tmp = *old_i;
- *old_i = tmp->next;
- tmp->next = 0;
- exp_free_i(interp,tmp_i,exp_indirect_update2);
- } else {
- old_i = &(*old_i)->next;
- }
- return TCL_OK;
- }
-
- /* delete ecases of this direct_fd */
- /* unfinish after this ... */
- for (exp_i=ecmd->i_list;exp_i;exp_i=exp_i->next) {
- if (!(direct & exp_i->direct)) continue;
- if (!exp_i_uses_fd(exp_i,m)) continue;
-
- /* delete each ecase that uses this exp_i */
-
-
- ecase_by_exp_i_append(interp,ecmd,exp_i);
- }
-
- return TCL_OK;
-}
-#endif
-
-/* return current setting of the permanent expect_before/after/bg */
-int
-expect_info(interp,ecmd,argc,argv)
-Tcl_Interp *interp;
-struct exp_cmd_descriptor *ecmd;
-int argc;
-char **argv;
-{
- struct exp_i *exp_i;
- int i;
- int direct = EXP_DIRECT|EXP_INDIRECT;
- char *iflag = 0;
- int all = FALSE; /* report on all fds */
- int m;
-
- while (*argv) {
- if (streq(argv[0],"-i") && argv[1]) {
- iflag = argv[1];
- argc-=2; argv+=2;
- } else if (streq(argv[0],"-all")) {
- all = TRUE;
- argc--; argv++;
- } else if (streq(argv[0],"-noindirect")) {
- direct &= ~EXP_INDIRECT;
- argc--; argv++;
- } else {
- exp_error(interp,"usage: -info [-all | -i spawn_id]\n");
- return TCL_ERROR;
- }
- }
-
- if (all) {
- /* avoid printing out -i when redundant */
- struct exp_i *previous = 0;
-
- for (i=0;i<ecmd->ecd.count;i++) {
- if (previous != ecmd->ecd.cases[i]->i_list) {
- exp_i_append(interp,ecmd->ecd.cases[i]->i_list);
- previous = ecmd->ecd.cases[i]->i_list;
- }
- ecase_append(interp,ecmd->ecd.cases[i]);
- }
- return TCL_OK;
- }
-
- if (!iflag) {
- if (0 == exp_update_master(interp,&m,0,0)) {
- return TCL_ERROR;
- }
- } else if (Tcl_GetInt(interp,iflag,&m) != TCL_OK) {
- /* handle as in indirect */
- Tcl_ResetResult(interp);
- for (i=0;i<ecmd->ecd.count;i++) {
- if (ecmd->ecd.cases[i]->i_list->direct == EXP_INDIRECT &&
- streq(ecmd->ecd.cases[i]->i_list->variable,iflag)) {
- ecase_append(interp,ecmd->ecd.cases[i]);
- }
- }
- return TCL_OK;
- }
-
- /* print ecases of this direct_fd */
- for (exp_i=ecmd->i_list;exp_i;exp_i=exp_i->next) {
- if (!(direct & exp_i->direct)) continue;
- if (!exp_i_uses_fd(exp_i,m)) continue;
- ecase_by_exp_i_append(interp,ecmd,exp_i);
- }
-
- return TCL_OK;
-}
-
-/* Exp_ExpectGlobalCmd is invoked to process expect_before/after */
-/*ARGSUSED*/
-int
-Exp_ExpectGlobalCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- int result = TCL_OK;
- struct exp_i *exp_i, **eip;
- struct exp_fd_list *fdl; /* temp for interating over fd_list */
- struct exp_cmd_descriptor eg;
- int count;
-
- struct exp_cmd_descriptor *ecmd = (struct exp_cmd_descriptor *) clientData;
-
- if ((argc == 2) && exp_one_arg_braced(argv[1])) {
- return(exp_eval_with_one_arg(clientData,interp,argv));
- } else if ((argc == 3) && streq(argv[1],"-brace")) {
- char *new_argv[2];
- new_argv[0] = argv[0];
- new_argv[1] = argv[2];
- return(exp_eval_with_one_arg(clientData,interp,new_argv));
- }
-
- if (argc > 1 && (argv[1][0] == '-')) {
- if (exp_flageq("info",&argv[1][1],4)) {
- return(expect_info(interp,ecmd,argc-2,argv+2));
- }
- }
-
- exp_cmd_init(&eg,ecmd->cmdtype,EXP_PERMANENT);
-
- if (TCL_ERROR == parse_expect_args(interp,&eg,EXP_SPAWN_ID_BAD,
- argc,argv)) {
- return TCL_ERROR;
- }
-
- /*
- * visit each NEW direct exp_i looking for spawn ids.
- * When found, remove them from any OLD exp_i's.
- */
-
- /* visit each exp_i */
- for (exp_i=eg.i_list;exp_i;exp_i=exp_i->next) {
- if (exp_i->direct == EXP_INDIRECT) continue;
-
- /* for each spawn id, remove it from ecases */
- for (fdl=exp_i->fd_list;fdl;fdl=fdl->next) {
- int m = fdl->fd;
-
- /* validate all input descriptors */
- if (m != EXP_SPAWN_ID_ANY) {
- if (!exp_fd2f(interp,m,1,1,"expect")) {
- result = TCL_ERROR;
- goto cleanup;
- }
- }
-
- /* remove spawn id from exp_i */
- ecmd_remove_fd(interp,ecmd,m,EXP_DIRECT);
- }
- }
-
- /*
- * For each indirect variable, release its old ecases and
- * clean up the matching spawn ids.
- * Same logic as in "expect_X delete" command.
- */
-
- for (exp_i=eg.i_list;exp_i;exp_i=exp_i->next) {
- struct exp_i **old_i;
-
- if (exp_i->direct == EXP_DIRECT) continue;
-
- for (old_i = &ecmd->i_list;*old_i;) {
- struct exp_i *tmp;
-
- if (((*old_i)->direct == EXP_DIRECT) ||
- (!streq((*old_i)->variable,exp_i->variable))) {
- old_i = &(*old_i)->next;
- continue;
- }
-
- ecases_remove_by_expi(interp,ecmd,*old_i);
-
- /* unlink from middle of list */
- tmp = *old_i;
- *old_i = tmp->next;
- tmp->next = 0;
- exp_free_i(interp,tmp,exp_indirect_update2);
- }
-
- /* if new one has ecases, update it */
- if (exp_i->ecount) {
- char *msg = exp_indirect_update1(interp,ecmd,exp_i);
- if (msg) {
- /* unusual way of handling error return */
- /* because of Tcl's variable tracing */
- strcpy(interp->result,msg);
- result = TCL_ERROR;
- goto indirect_update_abort;
- }
- }
- }
- /* empty i_lists have to be removed from global eg.i_list */
- /* before returning, even if during error */
- indirect_update_abort:
-
- /*
- * New exp_i's that have 0 ecases indicate fd/vars to be deleted.
- * Now that the deletions have been done, discard the new exp_i's.
- */
-
- for (exp_i=eg.i_list;exp_i;) {
- struct exp_i *next = exp_i->next;
-
- if (exp_i->ecount == 0) {
- exp_i_remove(interp,&eg.i_list,exp_i);
- }
- exp_i = next;
- }
- if (result == TCL_ERROR) goto cleanup;
-
- /*
- * arm all new bg direct fds
- */
-
- if (ecmd->cmdtype == EXP_CMD_BG) {
- for (exp_i=eg.i_list;exp_i;exp_i=exp_i->next) {
- if (exp_i->direct == EXP_DIRECT) {
- fd_list_arm(interp,exp_i->fd_list);
- }
- }
- }
-
- /*
- * now that old ecases are gone, add new ecases and exp_i's (both
- * direct and indirect).
- */
-
- /* append ecases */
-
- count = ecmd->ecd.count + eg.ecd.count;
- if (eg.ecd.count) {
- int start_index; /* where to add new ecases in old list */
-
- if (ecmd->ecd.count) {
- /* append to end */
- ecmd->ecd.cases = (struct ecase **)ckrealloc((char *)ecmd->ecd.cases, count * sizeof(struct ecase *));
- start_index = ecmd->ecd.count;
- } else {
- /* append to beginning */
- ecmd->ecd.cases = (struct ecase **)ckalloc(eg.ecd.count * sizeof(struct ecase *));
- start_index = 0;
- }
- memcpy(&ecmd->ecd.cases[start_index],eg.ecd.cases,
- eg.ecd.count*sizeof(struct ecase *));
- ecmd->ecd.count = count;
- }
-
- /* append exp_i's */
- for (eip = &ecmd->i_list;*eip;eip = &(*eip)->next) {
- /* empty loop to get to end of list */
- }
- /* *exp_i now points to end of list */
-
- *eip = eg.i_list; /* connect new list to end of current list */
-
- cleanup:
- if (result == TCL_ERROR) {
- /* in event of error, free any unreferenced ecases */
- /* but first, split up i_list so that exp_i's aren't */
- /* freed twice */
-
- for (exp_i=eg.i_list;exp_i;) {
- struct exp_i *next = exp_i->next;
- exp_i->next = 0;
- exp_i = next;
- }
- free_ecases(interp,&eg,1);
- } else {
- if (eg.ecd.cases) ckfree((char *)eg.ecd.cases);
- }
-
- if (ecmd->cmdtype == EXP_CMD_BG) {
- exp_background_filehandlers_run_all();
- }
-
- return(result);
-}
-
-/* adjusts file according to user's size request */
-void
-exp_adjust(f)
-struct exp_f *f;
-{
- int new_msize;
-
- /* get the latest buffer size. Double the user input for */
- /* two reasons. 1) Need twice the space in case the match */
- /* straddles two bufferfuls, 2) easier to hack the division */
- /* by two when shifting the buffers later on. The extra */
- /* byte in the malloc's is just space for a null we can slam on the */
- /* end. It makes the logic easier later. The -1 here is so that */
- /* requests actually come out to even/word boundaries (if user */
- /* gives "reasonable" requests) */
- new_msize = f->umsize*2 - 1;
- if (new_msize != f->msize) {
- if (!f->buffer) {
- /* allocate buffer space for 1st time */
- f->buffer = ckalloc((unsigned)new_msize+1);
- f->lower = ckalloc((unsigned)new_msize+1);
- f->size = 0;
- } else {
- /* buffer already exists - resize */
-
- /* if truncated, forget about some data */
- if (f->size > new_msize) {
- /* copy end of buffer down */
- memmove(f->buffer,f->buffer+(f->size - new_msize),new_msize);
- memmove(f->lower, f->lower +(f->size - new_msize),new_msize);
- f->size = new_msize;
-
- f->key = expect_key++;
- }
-
- f->buffer = ckrealloc(f->buffer,new_msize+1);
- f->lower = ckrealloc(f->lower,new_msize+1);
- }
- f->msize = new_msize;
- f->buffer[f->size] = '\0';
- f->lower[f->size] = '\0';
- }
-}
-
-
-/*
-
- expect_read() does the logical equivalent of a read() for the
-expect command. This includes figuring out which descriptor should
-be read from.
-
-The result of the read() is left in a spawn_id's buffer rather than
-explicitly passing it back. Note that if someone else has modified a
-buffer either before or while this expect is running (i.e., if we or
-some event has called Tcl_Eval which did another expect/interact),
-expect_read will also call this a successful read (for the purposes if
-needing to pattern match against it).
-
-*/
-/* if it returns a negative number, it corresponds to a EXP_XXX result */
-/* 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
-expect_read(interp,masters,masters_max,m,timeout,key)
-Tcl_Interp *interp;
-int *masters; /* If 0, then m is already known and set. */
-int masters_max; /* If *masters is not-zero, then masters_max */
- /* is the number of masters. */
- /* If *masters is zero, then masters_max */
- /* is used as the mask (ready vs except). */
- /* Crude but simplifies the interface. */
-int *m; /* Out variable to leave new master. */
-int timeout;
-int key;
-{
- struct exp_f *f;
- int cc;
- int write_count;
- int tcl_set_flags; /* if we have to discard chars, this tells */
- /* whether to show user locally or globally */
-
- if (masters == 0) {
- /* we already know the master, just find out what happened */
- cc = exp_get_next_event_info(interp,*m,masters_max);
- tcl_set_flags = TCL_GLOBAL_ONLY;
- } else {
- cc = exp_get_next_event(interp,masters,masters_max,m,timeout,key);
- tcl_set_flags = 0;
- }
-
- if (cc == EXP_DATA_NEW) {
- /* try to read it */
-
- cc = exp_i_read(interp,*m,timeout,tcl_set_flags);
-
- /* the meaning of 0 from i_read means eof. Muck with it a */
- /* little, so that from now on it means "no new data arrived */
- /* but it should be looked at again anyway". */
- if (cc == 0) {
- cc = EXP_EOF;
- } else if (cc > 0) {
- f = exp_fs + *m;
- f->buffer[f->size += cc] = '\0';
-
- /* strip parity if requested */
- if (f->parity == 0) {
- /* do it from end backwards */
- char *p = f->buffer + f->size - 1;
- int count = cc;
- while (count--) {
- *p-- &= 0x7f;
- }
- }
- } /* else {
- assert(cc < 0) in which case some sort of error was
- encountered such as an interrupt with that forced an
- error return
- } */
- } else if (cc == EXP_DATA_OLD) {
- f = exp_fs + *m;
- cc = 0;
- } else if (cc == EXP_RECONFIGURE) {
- return EXP_RECONFIGURE;
- }
-
- if (cc == EXP_ABEOF) { /* abnormal EOF */
- /* On many systems, ptys produce EIO upon EOF - sigh */
- if (i_read_errno == EIO) {
- /* Sun, Cray, BSD, and others */
- cc = EXP_EOF;
- } else if (i_read_errno == EINVAL) {
- /* Solaris 2.4 occasionally returns this */
- cc = EXP_EOF;
- } else {
- if (i_read_errno == EBADF) {
- exp_error(interp,"bad spawn_id (process died earlier?)");
- } else {
- exp_error(interp,"i_read(spawn_id=%d): %s",*m,
- Tcl_PosixError(interp));
- exp_close(interp,*m);
- }
- return(EXP_TCLERROR);
- /* was goto error; */
- }
- }
-
- /* EOF, TIMEOUT, and ERROR return here */
- /* In such cases, there is no need to update screen since, if there */
- /* was prior data read, it would have been sent to the screen when */
- /* it was read. */
- if (cc < 0) return (cc);
-
- /* update display */
-
- if (f->size) write_count = f->size - f->printed;
- else write_count = 0;
-
- if (write_count) {
- if (logfile_all || (loguser && logfile)) {
- fwrite(f->buffer + f->printed,1,write_count,logfile);
- }
- /* don't write to user if they're seeing it already, */
- /* that is, typing it! */
- if (loguser && !exp_is_stdinfd(*m) && !exp_is_devttyfd(*m))
- fwrite(f->buffer + f->printed,
- 1,write_count,stdout);
- if (debugfile) fwrite(f->buffer + f->printed,
- 1,write_count,debugfile);
-
- /* remove nulls from input, since there is no way */
- /* for Tcl to deal with such strings. Doing it here */
- /* lets them be sent to the screen, just in case */
- /* they are involved in formatting operations */
- if (f->rm_nulls) {
- f->size -= rm_nulls(f->buffer + f->printed,write_count);
- }
- f->buffer[f->size] = '\0';
-
- /* copy to lowercase buffer */
- exp_lowmemcpy(f->lower+f->printed,
- f->buffer+f->printed,
- 1 + f->size - f->printed);
-
- f->printed = f->size; /* count'm even if not logging */
- }
- return(cc);
-}
-
-/* when buffer fills, copy second half over first and */
-/* continue, so we can do matches over multiple buffers */
-void
-exp_buffer_shuffle(interp,f,save_flags,array_name,caller_name)
-Tcl_Interp *interp;
-struct exp_f *f;
-int save_flags;
-char *array_name;
-char *caller_name;
-{
- char spawn_id[10]; /* enough for a %d */
- char match_char; /* place to hold char temporarily */
- /* uprooted by a NULL */
-
- int first_half = f->size/2;
- int second_half = f->size - first_half;
-
- /*
- * allow user to see data we are discarding
- */
-
- sprintf(spawn_id,"%d",f-exp_fs);
- debuglog("%s: set %s(spawn_id) \"%s\"\r\n",
- caller_name,array_name,dprintify(spawn_id));
- Tcl_SetVar2(interp,array_name,"spawn_id",spawn_id,save_flags);
-
- /* temporarily null-terminate buffer in middle */
- match_char = f->buffer[first_half];
- f->buffer[first_half] = 0;
-
- debuglog("%s: set %s(buffer) \"%s\"\r\n",
- caller_name,array_name,dprintify(f->buffer));
- Tcl_SetVar2(interp,array_name,"buffer",f->buffer,save_flags);
-
- /* remove middle-null-terminator */
- f->buffer[first_half] = match_char;
-
- memcpy(f->buffer,f->buffer+first_half,second_half);
- memcpy(f->lower, f->lower +first_half,second_half);
- f->size = second_half;
- f->printed -= first_half;
- if (f->printed < 0) f->printed = 0;
-}
-
-/* map EXP_ style return value to TCL_ style return value */
-/* not defined to work on TCL_OK */
-int
-exp_tcl2_returnvalue(x)
-int x;
-{
- switch (x) {
- case TCL_ERROR: return EXP_TCLERROR;
- case TCL_RETURN: return EXP_TCLRET;
- case TCL_BREAK: return EXP_TCLBRK;
- case TCL_CONTINUE: return EXP_TCLCNT;
- case EXP_CONTINUE: return EXP_TCLCNTEXP;
- case EXP_CONTINUE_TIMER: return EXP_TCLCNTTIMER;
- case EXP_TCL_RETURN: return EXP_TCLRETTCL;
- }
-}
-
-/* map from EXP_ style return value to TCL_ style return values */
-int
-exp_2tcl_returnvalue(x)
-int x;
-{
- switch (x) {
- case EXP_TCLERROR: return TCL_ERROR;
- case EXP_TCLRET: return TCL_RETURN;
- case EXP_TCLBRK: return TCL_BREAK;
- case EXP_TCLCNT: return TCL_CONTINUE;
- case EXP_TCLCNTEXP: return EXP_CONTINUE;
- case EXP_TCLCNTTIMER: return EXP_CONTINUE_TIMER;
- case EXP_TCLRETTCL: return EXP_TCL_RETURN;
- }
-}
-
-/* returns # of chars read or (non-positive) error of form EXP_XXX */
-/* returns 0 for end of file */
-/* If timeout is non-zero, set an alarm before doing the read, else assume */
-/* the read will complete immediately. */
-/*ARGSUSED*/
-static int
-exp_i_read(interp,m,timeout,save_flags)
-Tcl_Interp *interp;
-int m;
-int timeout;
-int save_flags;
-{
- struct exp_f *f;
- int cc = EXP_TIMEOUT;
-
- f = exp_fs + m;
- if (f->size == f->msize)
- exp_buffer_shuffle(interp,f,save_flags,EXPECT_OUT,"expect");
-
-#ifdef SIMPLE_EVENT
- restart:
-
- alarm_fired = FALSE;
-
- if (timeout > -1) {
- signal(SIGALRM,sigalarm_handler);
- alarm((timeout > 0)?timeout:1);
- }
-#endif
-
- cc = read(m,f->buffer+f->size, f->msize-f->size);
- i_read_errno = errno;
-
-#ifdef SIMPLE_EVENT
- alarm(0);
-
- if (cc == -1) {
- /* check if alarm went off */
- if (i_read_errno == EINTR) {
- if (alarm_fired) {
- return EXP_TIMEOUT;
- } else {
- if (Tcl_AsyncReady()) {
- int rc = Tcl_AsyncInvoke(interp,TCL_OK);
- if (rc != TCL_OK) return(exp_tcl2_returnvalue(rc));
- }
- if (!f->valid) {
- exp_error(interp,"spawn_id %d no longer valid",f-exp_fs);
- return EXP_TCLERROR;
- }
- goto restart;
- }
- }
- }
-#endif
- return(cc);
-}
-
-/* variables predefined by expect are retrieved using this routine
-which looks in the global space if they are not in the local space.
-This allows the user to localize them if desired, and also to
-avoid having to put "global" in procedure definitions.
-*/
-char *
-exp_get_var(interp,var)
-Tcl_Interp *interp;
-char *var;
-{
- char *val;
-
- if (NULL != (val = Tcl_GetVar(interp,var,0 /* local */)))
- return(val);
- return(Tcl_GetVar(interp,var,TCL_GLOBAL_ONLY));
-}
-
-static int
-get_timeout(interp)
-Tcl_Interp *interp;
-{
- static int timeout = INIT_EXPECT_TIMEOUT;
- char *t;
-
- if (NULL != (t = exp_get_var(interp,EXPECT_TIMEOUT))) {
- timeout = atoi(t);
- }
- return(timeout);
-}
-
-/* make a copy of a linked list (1st arg) and attach to end of another (2nd
-arg) */
-static int
-update_expect_fds(i_list,fd_union)
-struct exp_i *i_list;
-struct exp_fd_list **fd_union;
-{
- struct exp_i *p;
-
- /* for each i_list in an expect statement ... */
- for (p=i_list;p;p=p->next) {
- struct exp_fd_list *fdl;
-
- /* for each fd in the i_list */
- for (fdl=p->fd_list;fdl;fdl=fdl->next) {
- struct exp_fd_list *tmpfdl;
- struct exp_fd_list *u;
-
- if (fdl->fd == EXP_SPAWN_ID_ANY) continue;
-
- /* check this one against all so far */
- for (u = *fd_union;u;u=u->next) {
- if (fdl->fd == u->fd) goto found;
- }
- /* if not found, link in as head of list */
- tmpfdl = exp_new_fd(fdl->fd);
- tmpfdl->next = *fd_union;
- *fd_union = tmpfdl;
- found:;
- }
- }
- return TCL_OK;
-}
-
-char *
-exp_cmdtype_printable(cmdtype)
-int cmdtype;
-{
- switch (cmdtype) {
- case EXP_CMD_FG: return("expect");
- case EXP_CMD_BG: return("expect_background");
- case EXP_CMD_BEFORE: return("expect_before");
- case EXP_CMD_AFTER: return("expect_after");
- }
-#ifdef LINT
- return("unknown expect command");
-#endif
-}
-
-/* exp_indirect_update2 is called back via Tcl's trace handler whenever */
-/* 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. */
-{
- char *msg;
-
- struct exp_i *exp_i = (struct exp_i *)clientData;
- exp_configure_count++;
- msg = exp_indirect_update1(interp,&exp_cmds[exp_i->cmdtype],exp_i);
-
- exp_background_filehandlers_run_all();
-
- return msg;
-}
-
-static char *
-exp_indirect_update1(interp,ecmd,exp_i)
-Tcl_Interp *interp;
-struct exp_cmd_descriptor *ecmd;
-struct exp_i *exp_i;
-{
- struct exp_fd_list *fdl; /* temp for interating over fd_list */
-
- /*
- * disarm any fd's that lose all their ecases
- */
-
- if (ecmd->cmdtype == EXP_CMD_BG) {
- /* clean up each spawn id used by this exp_i */
- for (fdl=exp_i->fd_list;fdl;fdl=fdl->next) {
- int m = fdl->fd;
-
- if (m == EXP_SPAWN_ID_ANY) continue;
-
- /* silently skip closed or preposterous fds */
- /* since we're just disabling them anyway */
- /* preposterous fds will have been reported */
- /* by code in next section already */
- if (!exp_fd2f(interp,fdl->fd,1,0,"")) continue;
-
- exp_fs[m].bg_ecount--;
- if (exp_fs[m].bg_ecount == 0) {
- exp_disarm_background_filehandler(m);
- exp_fs[m].bg_interp = 0;
- }
- }
- }
-
- /*
- * reread indirect variable
- */
-
- exp_i_update(interp,exp_i);
-
- /*
- * check validity of all fd's in variable
- */
-
- for (fdl=exp_i->fd_list;fdl;fdl=fdl->next) {
- /* validate all input descriptors */
- if (fdl->fd == EXP_SPAWN_ID_ANY) continue;
-
- if (!exp_fd2f(interp,fdl->fd,1,1,
- exp_cmdtype_printable(ecmd->cmdtype))) {
- static char msg[200];
- sprintf(msg,"%s from indirect variable (%s)",
- interp->result,exp_i->variable);
- return msg;
- }
- }
-
- /* for each spawn id in list, arm if necessary */
- if (ecmd->cmdtype == EXP_CMD_BG) {
- fd_list_arm(interp,exp_i->fd_list);
- }
-
- return (char *)0;
-}
-
-void
-exp_background_filehandlers_run_all()
-{
- int m;
- struct exp_f *f;
-
- /* kick off any that already have input waiting */
- for (m=0;m<=exp_fd_max;m++) {
- f = exp_fs + m;
- if (!f->valid) continue;
-
- /* is bg_interp the best way to check if armed? */
- if (f->bg_interp && (f->size > 0)) {
- exp_background_filehandler((ClientData)f->fd_ptr,0/*ignored*/);
- }
- }
-}
-
-/* this function is called from the background when input arrives */
-/*ARGSUSED*/
-void
-exp_background_filehandler(clientData,mask)
-ClientData clientData;
-int mask;
-{
- int m;
-
- Tcl_Interp *interp;
- int cc; /* number of chars returned in a single read */
- /* or negative EXP_whatever */
- struct exp_f *f; /* file associated with master */
-
- int i; /* trusty temporary */
-
- struct eval_out eo; /* final case of interest */
- struct exp_f *last_f; /* for differentiating when multiple f's */
- /* to print out better debugging messages */
- int last_case; /* as above but for case */
-
- /* restore our environment */
- m = *(int *)clientData;
- f = exp_fs + m;
- interp = f->bg_interp;
-
- /* temporarily prevent this handler from being invoked again */
- exp_block_background_filehandler(m);
-
- /* if mask == 0, then we've been called because the patterns changed */
- /* not because the waiting data has changed, so don't actually do */
- /* any I/O */
-
- if (mask == 0) {
- cc = 0;
- } else {
- cc = expect_read(interp,(int *)0,mask,&m,EXP_TIME_INFINITY,0);
- }
-
-do_more_data:
- eo.e = 0; /* no final case yet */
- eo.f = 0; /* no final file selected yet */
- eo.match = 0; /* nothing matched yet */
-
- /* force redisplay of buffer when debugging */
- last_f = 0;
-
- if (cc == EXP_EOF) {
- /* do nothing */
- } else if (cc < 0) { /* EXP_TCLERROR or any other weird value*/
- goto finish;
- /* if we were going to do this right, we should */
- /* differentiate between things like HP ioctl-open-traps */
- /* that fall out here and should rightfully be ignored */
- /* and real errors that should be reported. Come to */
- /* think of it, the only errors will come from HP */
- /* ioctl handshake botches anyway. */
- } else {
- /* normal case, got data */
- /* new data if cc > 0, same old data if cc == 0 */
-
- /* below here, cc as general status */
- cc = EXP_NOMATCH;
- }
-
- cc = eval_cases(interp,&exp_cmds[EXP_CMD_BEFORE],
- m,&eo,&last_f,&last_case,cc,&m,1,"_background");
- cc = eval_cases(interp,&exp_cmds[EXP_CMD_BG],
- m,&eo,&last_f,&last_case,cc,&m,1,"_background");
- cc = eval_cases(interp,&exp_cmds[EXP_CMD_AFTER],
- m,&eo,&last_f,&last_case,cc,&m,1,"_background");
- if (cc == EXP_TCLERROR) {
- /* only likely problem here is some internal regexp botch */
- Tcl_BackgroundError(interp);
- goto finish;
- }
- /* special eof code that cannot be done in eval_cases */
- /* or above, because it would then be executed several times */
- if (cc == EXP_EOF) {
- eo.f = exp_fs + m;
- eo.match = eo.f->size;
- eo.buffer = eo.f->buffer;
- debuglog("expect_background: read eof\r\n");
- goto matched;
- }
- if (!eo.e) {
- /* if we get here, there must not have been a match */
- goto finish;
- }
-
- matched:
-#define out(i,val) debuglog("expect_background: set %s(%s) \"%s\"\r\n",EXPECT_OUT,i, \
- dprintify(val)); \
- Tcl_SetVar2(interp,EXPECT_OUT,i,val,TCL_GLOBAL_ONLY);
- {
-/* int iwrite = FALSE;*/ /* write spawn_id? */
- char *body = 0;
- char *buffer; /* pointer to normal or lowercased data */
- struct ecase *e = 0; /* points to current ecase */
- int match = -1; /* characters matched */
- char match_char; /* place to hold char temporarily */
- /* uprooted by a NULL */
- char *eof_body = 0;
-
- if (eo.e) {
- e = eo.e;
- body = e->body;
-/* iwrite = e->iwrite;*/
- if (cc != EXP_TIMEOUT) {
- f = eo.f;
- match = eo.match;
- buffer = eo.buffer;
- }
-#if 0
- if (e->timestamp) {
- char value[20];
-
- time(¤t_time);
- elapsed_time = current_time - start_time;
- elapsed_time_total = current_time - start_time_total;
- sprintf(value,"%d",elapsed_time);
- out("seconds",value);
- sprintf(value,"%d",elapsed_time_total);
- out("seconds_total",value);
- /* deprecated */
- exp_timestamp(interp,¤t_time,EXPECT_OUT);
- }
-#endif
- } else if (cc == EXP_EOF) {
- /* read an eof but no user-supplied case */
- f = eo.f;
- match = eo.match;
- buffer = eo.buffer;
- }
-
- if (match >= 0) {
- char name[20], value[20];
-
- if (e && e->use == PAT_RE) {
- Expect_regexp *re = e->re;
-
- for (i=0;i<NSUBEXP;i++) {
- int offset;
-
- if (re->startp[i] == 0) continue;
-
- if (e->indices) {
- /* start index */
- sprintf(name,"%d,start",i);
- offset = re->startp[i]-buffer;
- sprintf(value,"%d",offset);
- out(name,value);
-
- /* end index */
- sprintf(name,"%d,end",i);
- sprintf(value,"%d",
- re->endp[i]-buffer-1);
- out(name,value);
- }
-
- /* string itself */
- sprintf(name,"%d,string",i);
-
- /* temporarily null-terminate in */
- /* middle */
- match_char = *re->endp[i];
- *re->endp[i] = 0;
- out(name,re->startp[i]);
- *re->endp[i] = match_char;
- }
- /* redefine length of string that */
- /* matched for later extraction */
- match = re->endp[0]-buffer;
- } else if (e && (e->use == PAT_GLOB || e->use == PAT_EXACT)) {
- char *str;
-
- if (e->indices) {
- /* start index */
- sprintf(value,"%d",e->simple_start);
- out("0,start",value);
-
- /* end index */
- sprintf(value,"%d",e->simple_start + match - 1);
- out("0,end",value);
- }
-
- /* string itself */
- str = f->buffer + e->simple_start;
- /* temporarily null-terminate in middle */
- match_char = str[match];
- str[match] = 0;
- out("0,string",str);
- str[match] = match_char;
-
- /* redefine length of string that */
- /* matched for later extraction */
- match += e->simple_start;
- } else if (e && e->use == PAT_NULL && e->indices) {
- /* start index */
- sprintf(value,"%d",match-1);
- out("0,start",value);
- /* end index */
- sprintf(value,"%d",match-1);
- out("0,end",value);
- } else if (e && e->use == PAT_FULLBUFFER) {
- debuglog("expect_background: full buffer\r\n");
- }
- }
-
- /* this is broken out of (match > 0) (above) since it can */
- /* that an EOF occurred with match == 0 */
- if (eo.f) {
- char spawn_id[10]; /* enough for a %d */
-
-/* if (iwrite) {*/
- sprintf(spawn_id,"%d",f-exp_fs);
- out("spawn_id",spawn_id);
-/* }*/
-
- /* save buf[0..match] */
- /* temporarily null-terminate string in middle */
- match_char = f->buffer[match];
- f->buffer[match] = 0;
- out("buffer",f->buffer);
- /* remove middle-null-terminator */
- f->buffer[match] = match_char;
-
- /* "!e" means no case matched - transfer by default */
- if (!e || e->transfer) {
- /* delete matched chars from input buffer */
- f->size -= match;
- f->printed -= match;
- if (f->size != 0) {
- memmove(f->buffer,f->buffer+match,f->size);
- memmove(f->lower,f->lower+match,f->size);
- }
- f->buffer[f->size] = '\0';
- f->lower[f->size] = '\0';
- }
-
- if (cc == EXP_EOF) {
- /* exp_close() deletes all background bodies */
- /* so save eof body temporarily */
- if (body) {
- eof_body = ckalloc(strlen(body)+1);
- strcpy(eof_body,body);
- body = eof_body;
- }
-
- exp_close(interp,f - exp_fs);
- }
-
- }
-
- if (body) {
- int result = Tcl_GlobalEval(interp,body);
- if (result != TCL_OK) Tcl_BackgroundError(interp);
-
- if (eof_body) ckfree(eof_body);
- }
-
-
- /*
- * Event handler will not call us back if there is more input
- * pending but it has already arrived. bg_status will be
- * "blocked" only if armed.
- */
- if (exp_fs[m].valid && (exp_fs[m].bg_status == blocked)
- && (f->size > 0)) {
- cc = f->size;
- goto do_more_data;
- }
- }
- finish:
- /* fd could have gone away, so check before using */
- if (exp_fs[m].valid)
- exp_unblock_background_filehandler(m);
-}
-#undef out
-
-/*ARGSUSED*/
-int
-Exp_ExpectCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- int cc; /* number of chars returned in a single read */
- /* or negative EXP_whatever */
- int m; /* before doing an actual read, attempt */
- /* to match upon any spawn_id */
- struct exp_f *f; /* file associated with master */
-
- int i; /* trusty temporary */
- struct exp_cmd_descriptor eg;
- struct exp_fd_list *fd_list; /* list of masters to watch */
- struct exp_fd_list *fdl; /* temp for interating over fd_list */
- int *masters; /* array of masters to watch */
- int mcount; /* number of masters to watch */
-
- struct eval_out eo; /* final case of interest */
-
- int result; /* Tcl result */
-
- time_t start_time_total;/* time at beginning of this procedure */
- time_t start_time = 0; /* time when restart label hit */
- time_t current_time = 0;/* current time (when we last looked)*/
- time_t end_time; /* future time at which to give up */
- time_t elapsed_time_total;/* time from now to match/fail/timeout */
- time_t elapsed_time; /* time from restart to (ditto) */
-
- struct exp_f *last_f; /* for differentiating when multiple f's */
- /* to print out better debugging messages */
- int last_case; /* as above but for case */
- int first_time = 1; /* if not "restarted" */
-
- int key; /* identify this expect command instance */
- int configure_count; /* monitor exp_configure_count */
-
- int timeout; /* seconds */
- int remtime; /* remaining time in timeout */
- int reset_timer; /* should timer be reset after continue? */
-
- if ((argc == 2) && exp_one_arg_braced(argv[1])) {
- return(exp_eval_with_one_arg(clientData,interp,argv));
- } else if ((argc == 3) && streq(argv[1],"-brace")) {
- char *new_argv[2];
- new_argv[0] = argv[0];
- new_argv[1] = argv[2];
- return(exp_eval_with_one_arg(clientData,interp,new_argv));
- }
-
- time(&start_time_total);
- start_time = start_time_total;
- reset_timer = TRUE;
-
- /* make arg list for processing cases */
- /* do it dynamically, since expect can be called recursively */
-
- exp_cmd_init(&eg,EXP_CMD_FG,EXP_TEMPORARY);
- fd_list = 0;
- masters = 0;
- if (TCL_ERROR == parse_expect_args(interp,&eg,
- *(int *)clientData,argc,argv))
- return TCL_ERROR;
-
- restart_with_update:
- /* validate all descriptors */
- /* and flatten fds into array */
-
- if ((TCL_ERROR == update_expect_fds(exp_cmds[EXP_CMD_BEFORE].i_list,&fd_list))
- || (TCL_ERROR == update_expect_fds(exp_cmds[EXP_CMD_AFTER].i_list, &fd_list))
- || (TCL_ERROR == update_expect_fds(eg.i_list,&fd_list))) {
- result = TCL_ERROR;
- goto cleanup;
- }
-
- /* declare ourselves "in sync" with external view of close/indirect */
- configure_count = exp_configure_count;
-
- /* count and validate fd_list */
- mcount = 0;
- for (fdl=fd_list;fdl;fdl=fdl->next) {
- mcount++;
- /* validate all input descriptors */
- if (!exp_fd2f(interp,fdl->fd,1,1,"expect")) {
- result = TCL_ERROR;
- goto cleanup;
- }
- }
-
- /* make into an array */
- masters = (int *)ckalloc(mcount * sizeof(int));
- for (fdl=fd_list,i=0;fdl;fdl=fdl->next,i++) {
- masters[i] = fdl->fd;
- }
-
- restart:
- if (first_time) first_time = 0;
- else time(&start_time);
-
- if (eg.timeout_specified_by_flag) {
- timeout = eg.timeout;
- } else {
- /* get the latest timeout */
- timeout = get_timeout(interp);
- }
-
- key = expect_key++;
-
- result = TCL_OK;
- last_f = 0;
-
- /* end of restart code */
-
- eo.e = 0; /* no final case yet */
- eo.f = 0; /* no final file selected yet */
- eo.match = 0; /* nothing matched yet */
-
- /* timeout code is a little tricky, be very careful changing it */
- if (timeout != EXP_TIME_INFINITY) {
- /* if exp_continue -continue_timer, do not update end_time */
- if (reset_timer) {
- time(¤t_time);
- end_time = current_time + timeout;
- } else {
- reset_timer = TRUE;
- }
- }
-
- /* remtime and current_time updated at bottom of loop */
- remtime = timeout;
-
- for (;;) {
- if ((timeout != EXP_TIME_INFINITY) && (remtime < 0)) {
- cc = EXP_TIMEOUT;
- } else {
- cc = expect_read(interp,masters,mcount,&m,remtime,key);
- }
-
- /*SUPPRESS 530*/
- if (cc == EXP_EOF) {
- /* do nothing */
- } else if (cc == EXP_TIMEOUT) {
- debuglog("expect: timed out\r\n");
- } else if (cc == EXP_RECONFIGURE) {
- reset_timer = FALSE;
- goto restart_with_update;
- } else if (cc < 0) { /* EXP_TCLERROR or any other weird value*/
- goto error;
- } else {
- /* new data if cc > 0, same old data if cc == 0 */
-
- f = exp_fs + m;
-
- /* below here, cc as general status */
- cc = EXP_NOMATCH;
-
- /* force redisplay of buffer when debugging */
- last_f = 0;
- }
-
- cc = eval_cases(interp,&exp_cmds[EXP_CMD_BEFORE],
- m,&eo,&last_f,&last_case,cc,masters,mcount,"");
- cc = eval_cases(interp,&eg,
- m,&eo,&last_f,&last_case,cc,masters,mcount,"");
- cc = eval_cases(interp,&exp_cmds[EXP_CMD_AFTER],
- m,&eo,&last_f,&last_case,cc,masters,mcount,"");
- if (cc == EXP_TCLERROR) goto error;
- /* special eof code that cannot be done in eval_cases */
- /* or above, because it would then be executed several times */
- if (cc == EXP_EOF) {
- eo.f = exp_fs + m;
- eo.match = eo.f->size;
- eo.buffer = eo.f->buffer;
- debuglog("expect: read eof\r\n");
- break;
- } else if (cc == EXP_TIMEOUT) break;
- /* break if timeout or eof and failed to find a case for it */
-
- if (eo.e) break;
-
- /* no match was made with current data, force a read */
- f->force_read = TRUE;
-
- if (timeout != EXP_TIME_INFINITY) {
- time(¤t_time);
- remtime = end_time - current_time;
- }
- }
-
- goto done;
-
-error:
- result = exp_2tcl_returnvalue(cc);
- done:
-#define out(i,val) debuglog("expect: set %s(%s) \"%s\"\r\n",EXPECT_OUT,i, \
- dprintify(val)); \
- Tcl_SetVar2(interp,EXPECT_OUT,i,val,0);
-
- if (result != TCL_ERROR) {
-/* int iwrite = FALSE;*/ /* write spawn_id? */
- char *body = 0;
- char *buffer; /* pointer to normal or lowercased data */
- struct ecase *e = 0; /* points to current ecase */
- int match = -1; /* characters matched */
- char match_char; /* place to hold char temporarily */
- /* uprooted by a NULL */
- char *eof_body = 0;
-
- if (eo.e) {
- e = eo.e;
- body = e->body;
-/* iwrite = e->iwrite;*/
- if (cc != EXP_TIMEOUT) {
- f = eo.f;
- match = eo.match;
- buffer = eo.buffer;
- }
- if (e->timestamp) {
- char value[20];
-
- time(¤t_time);
- elapsed_time = current_time - start_time;
- elapsed_time_total = current_time - start_time_total;
- sprintf(value,"%d",elapsed_time);
- out("seconds",value);
- sprintf(value,"%d",elapsed_time_total);
- out("seconds_total",value);
-
- /* deprecated */
- exp_timestamp(interp,¤t_time,EXPECT_OUT);
- }
- } else if (cc == EXP_EOF) {
- /* read an eof but no user-supplied case */
- f = eo.f;
- match = eo.match;
- buffer = eo.buffer;
- }
-
- if (match >= 0) {
- char name[20], value[20];
-
- if (e && e->use == PAT_RE) {
- Expect_regexp *re = e->re;
-
- for (i=0;i<NSUBEXP;i++) {
- int offset;
-
- if (re->startp[i] == 0) continue;
-
- if (e->indices) {
- /* start index */
- sprintf(name,"%d,start",i);
- offset = re->startp[i]-buffer;
- sprintf(value,"%d",offset);
- out(name,value);
-
- /* end index */
- sprintf(name,"%d,end",i);
- sprintf(value,"%d",
- re->endp[i]-buffer-1);
- out(name,value);
- }
-
- /* string itself */
- sprintf(name,"%d,string",i);
-
- /* temporarily null-terminate in */
- /* middle */
- match_char = *re->endp[i];
- *re->endp[i] = 0;
- out(name,re->startp[i]);
- *re->endp[i] = match_char;
- }
- /* redefine length of string that */
- /* matched for later extraction */
- match = re->endp[0]-buffer;
- } else if (e && (e->use == PAT_GLOB || e->use == PAT_EXACT)) {
- char *str;
-
- if (e->indices) {
- /* start index */
- sprintf(value,"%d",e->simple_start);
- out("0,start",value);
-
- /* end index */
- sprintf(value,"%d",e->simple_start + match - 1);
- out("0,end",value);
- }
-
- /* string itself */
- str = f->buffer + e->simple_start;
- /* temporarily null-terminate in middle */
- match_char = str[match];
- str[match] = 0;
- out("0,string",str);
- str[match] = match_char;
-
- /* redefine length of string that */
- /* matched for later extraction */
- match += e->simple_start;
- } else if (e && e->use == PAT_NULL && e->indices) {
- /* start index */
- sprintf(value,"%d",match-1);
- out("0,start",value);
- /* end index */
- sprintf(value,"%d",match-1);
- out("0,end",value);
- } else if (e && e->use == PAT_FULLBUFFER) {
- debuglog("expect: full buffer\r\n");
- }
- }
-
- /* this is broken out of (match > 0) (above) since it can */
- /* that an EOF occurred with match == 0 */
- if (eo.f) {
- char spawn_id[10]; /* enough for a %d */
-
-/* if (iwrite) {*/
- sprintf(spawn_id,"%d",f-exp_fs);
- out("spawn_id",spawn_id);
-/* }*/
-
- /* save buf[0..match] */
- /* temporarily null-terminate string in middle */
- match_char = f->buffer[match];
- f->buffer[match] = 0;
- out("buffer",f->buffer);
- /* remove middle-null-terminator */
- f->buffer[match] = match_char;
-
- /* "!e" means no case matched - transfer by default */
- if (!e || e->transfer) {
- /* delete matched chars from input buffer */
- f->size -= match;
- f->printed -= match;
- if (f->size != 0) {
- memmove(f->buffer,f->buffer+match,f->size);
- memmove(f->lower,f->lower+match,f->size);
- }
- f->buffer[f->size] = '\0';
- f->lower[f->size] = '\0';
- }
-
- if (cc == EXP_EOF) {
- /* exp_close() deletes all background bodies */
- /* so save eof body temporarily */
- if (body) {
- eof_body = ckalloc(strlen(body)+1);
- strcpy(eof_body,body);
- body = eof_body;
- }
-
- exp_close(interp,f - exp_fs);
- }
-
- }
-
- if (body) {
- result = Tcl_Eval(interp,body);
-
- if (eof_body) ckfree(eof_body);
- }
- }
-
- cleanup:
- if (result == EXP_CONTINUE_TIMER) {
- reset_timer = FALSE;
- result = EXP_CONTINUE;
- }
-
- if ((result == EXP_CONTINUE)
- && (configure_count == exp_configure_count)) {
- debuglog("expect: continuing expect\r\n");
- goto restart;
- }
-
- if (fd_list) {
- exp_free_fd(fd_list);
- fd_list = 0;
- }
- if (masters) {
- ckfree((char *)masters);
- masters = 0;
- }
-
- if (result == EXP_CONTINUE) {
- debuglog("expect: continuing expect after update\r\n");
- goto restart_with_update;
- }
-
- free_ecases(interp,&eg,0); /* requires i_lists to be avail */
- exp_free_i(interp,eg.i_list,exp_indirect_update2);
-
- return(result);
-}
-#undef out
-
-/* beginning of deprecated code */
-
-#define out(elt) Tcl_SetVar2(interp,array,elt,ascii,0);
-void
-exp_timestamp(interp,timeval,array)
-Tcl_Interp *interp;
-time_t *timeval;
-char *array;
-{
- struct tm *tm;
- char *ascii;
-
- tm = localtime(timeval); /* split */
- ascii = asctime(tm); /* print */
- ascii[24] = '\0'; /* zap trailing \n */
-
- out("timestamp");
-
- sprintf(ascii,"%ld",*timeval);
- out("epoch");
-
- sprintf(ascii,"%d",tm->tm_sec);
- out("sec");
- sprintf(ascii,"%d",tm->tm_min);
- out("min");
- sprintf(ascii,"%d",tm->tm_hour);
- out("hour");
- sprintf(ascii,"%d",tm->tm_mday);
- out("mday");
- sprintf(ascii,"%d",tm->tm_mon);
- out("mon");
- sprintf(ascii,"%d",tm->tm_year);
- out("year");
- sprintf(ascii,"%d",tm->tm_wday);
- out("wday");
- sprintf(ascii,"%d",tm->tm_yday);
- out("yday");
- sprintf(ascii,"%d",tm->tm_isdst);
- out("isdst");
-}
-/* end of deprecated code */
-
-/*ARGSUSED*/
-static int
-Exp_TimestampCmd(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- char *format = 0;
- time_t seconds = -1;
- int gmt = FALSE; /* local time by default */
- struct tm *tm;
- Tcl_DString dstring;
-
- argc--; argv++;
-
- while (*argv) {
- if (streq(*argv,"-format")) {
- argc--; argv++;
- if (!*argv) goto usage_error;
- format = *argv;
- argc--; argv++;
- } else if (streq(*argv,"-seconds")) {
- argc--; argv++;
- if (!*argv) goto usage_error;
- seconds = atoi(*argv);
- argc--; argv++;
- } else if (streq(*argv,"-gmt")) {
- gmt = TRUE;
- argc--; argv++;
- } else break;
- }
-
- if (argc) goto usage_error;
-
- if (seconds == -1) {
- time(&seconds);
- }
-
- Tcl_DStringInit(&dstring);
-
- if (format) {
- if (gmt) {
- tm = gmtime(&seconds);
- } else {
- tm = localtime(&seconds);
- }
-/* exp_strftime(interp->result,TCL_RESULT_SIZE,format,tm);*/
- exp_strftime(format,tm,&dstring);
- Tcl_DStringResult(interp,&dstring);
- } else {
- sprintf(interp->result,"%ld",seconds);
- }
-
- return TCL_OK;
- usage_error:
- exp_error(interp,"args: [-seconds #] [-format format]");
- return TCL_ERROR;
-
-}
-
-/* lowmemcpy - like memcpy but it lowercases result */
-void
-exp_lowmemcpy(dest,src,n)
-char *dest;
-char *src;
-int n;
-{
- for (;n>0;n--) {
- *dest = ((isascii(*src) && isupper(*src))?tolower(*src):*src);
- src++; dest++;
- }
-}
-
-/*ARGSUSED*/
-int
-Exp_MatchMaxCmd(clientData,interp,argc,argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- int size = -1;
- int m = -1;
- struct exp_f *f;
- int Default = FALSE;
-
- argc--; argv++;
-
- for (;argc>0;argc--,argv++) {
- if (streq(*argv,"-d")) {
- Default = TRUE;
- } else if (streq(*argv,"-i")) {
- argc--;argv++;
- if (argc < 1) {
- exp_error(interp,"-i needs argument");
- return(TCL_ERROR);
- }
- m = atoi(*argv);
- } else break;
- }
-
- if (!Default) {
- if (m == -1) {
- if (!(f = exp_update_master(interp,&m,0,0)))
- return(TCL_ERROR);
- } else {
- if (!(f = exp_fd2f(interp,m,0,0,"match_max")))
- return(TCL_ERROR);
- }
- } else if (m != -1) {
- exp_error(interp,"cannot do -d and -i at the same time");
- return(TCL_ERROR);
- }
-
- if (argc == 0) {
- if (Default) {
- size = exp_default_match_max;
- } else {
- size = f->umsize;
- }
- sprintf(interp->result,"%d",size);
- return(TCL_OK);
- }
-
- if (argc > 1) {
- exp_error(interp,"too many arguments");
- return(TCL_OK);
- }
-
- /* all that's left is to set the size */
- size = atoi(argv[0]);
- if (size <= 0) {
- exp_error(interp,"must be positive");
- return(TCL_ERROR);
- }
-
- if (Default) exp_default_match_max = size;
- else f->umsize = size;
-
- return(TCL_OK);
-}
-
-/*ARGSUSED*/
-int
-Exp_RemoveNullsCmd(clientData,interp,argc,argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- int value = -1;
- int m = -1;
- struct exp_f *f;
- int Default = FALSE;
-
- argc--; argv++;
-
- for (;argc>0;argc--,argv++) {
- if (streq(*argv,"-d")) {
- Default = TRUE;
- } else if (streq(*argv,"-i")) {
- argc--;argv++;
- if (argc < 1) {
- exp_error(interp,"-i needs argument");
- return(TCL_ERROR);
- }
- m = atoi(*argv);
- } else break;
- }
-
- if (!Default) {
- if (m == -1) {
- if (!(f = exp_update_master(interp,&m,0,0)))
- return(TCL_ERROR);
- } else {
- if (!(f = exp_fd2f(interp,m,0,0,"remove_nulls")))
- return(TCL_ERROR);
- }
- } else if (m != -1) {
- exp_error(interp,"cannot do -d and -i at the same time");
- return(TCL_ERROR);
- }
-
- if (argc == 0) {
- if (Default) {
- value = exp_default_match_max;
- } else {
- value = f->rm_nulls;
- }
- sprintf(interp->result,"%d",value);
- return(TCL_OK);
- }
-
- if (argc > 1) {
- exp_error(interp,"too many arguments");
- return(TCL_OK);
- }
-
- /* all that's left is to set the value */
- value = atoi(argv[0]);
- if (value != 0 && value != 1) {
- exp_error(interp,"must be 0 or 1");
- return(TCL_ERROR);
- }
-
- if (Default) exp_default_rm_nulls = value;
- else f->rm_nulls = value;
-
- return(TCL_OK);
-}
-
-/*ARGSUSED*/
-int
-Exp_ParityCmd(clientData,interp,argc,argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- int parity;
- int m = -1;
- struct exp_f *f;
- int Default = FALSE;
-
- argc--; argv++;
-
- for (;argc>0;argc--,argv++) {
- if (streq(*argv,"-d")) {
- Default = TRUE;
- } else if (streq(*argv,"-i")) {
- argc--;argv++;
- if (argc < 1) {
- exp_error(interp,"-i needs argument");
- return(TCL_ERROR);
- }
- m = atoi(*argv);
- } else break;
- }
-
- if (!Default) {
- if (m == -1) {
- if (!(f = exp_update_master(interp,&m,0,0)))
- return(TCL_ERROR);
- } else {
- if (!(f = exp_fd2f(interp,m,0,0,"parity")))
- return(TCL_ERROR);
- }
- } else if (m != -1) {
- exp_error(interp,"cannot do -d and -i at the same time");
- return(TCL_ERROR);
- }
-
- if (argc == 0) {
- if (Default) {
- parity = exp_default_parity;
- } else {
- parity = f->parity;
- }
- sprintf(interp->result,"%d",parity);
- return(TCL_OK);
- }
-
- if (argc > 1) {
- exp_error(interp,"too many arguments");
- return(TCL_OK);
- }
-
- /* all that's left is to set the parity */
- parity = atoi(argv[0]);
-
- if (Default) exp_default_parity = parity;
- else f->parity = parity;
-
- return(TCL_OK);
-}
-
-#if DEBUG_PERM_ECASES
-/* This big chunk of code is just for debugging the permanent */
-/* expect cases */
-void
-exp_fd_print(fdl)
-struct exp_fd_list *fdl;
-{
- if (!fdl) return;
- printf("%d ",fdl->fd);
- exp_fd_print(fdl->next);
-}
-
-void
-exp_i_print(exp_i)
-struct exp_i *exp_i;
-{
- if (!exp_i) return;
- printf("exp_i %x",exp_i);
- printf((exp_i->direct == EXP_DIRECT)?" direct":" indirect");
- printf((exp_i->duration == EXP_PERMANENT)?" perm":" tmp");
- printf(" ecount = %d\n",exp_i->ecount);
- printf("variable %s, value %s\n",
- ((exp_i->variable)?exp_i->variable:"--"),
- ((exp_i->value)?exp_i->value:"--"));
- printf("fds: ");
- exp_fd_print(exp_i->fd_list); printf("\n");
- exp_i_print(exp_i->next);
-}
-
-void
-exp_ecase_print(ecase)
-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;
-{
- int i;
-
- printf("%d cases\n",ecd->count);
- for (i=0;i<ecd->count;i++) exp_ecase_print(ecd->cases[i]);
-}
-
-void
-exp_cmd_print(ecmd)
-struct exp_cmd_descriptor *ecmd;
-{
- printf("expect cmd type: %17s",exp_cmdtype_printable(ecmd->cmdtype));
- printf((ecmd->duration==EXP_PERMANENT)?" perm ": "tmp ");
- /* printdict */
- exp_ecases_print(&ecmd->ecd);
- exp_i_print(ecmd->i_list);
-}
-
-void
-exp_cmds_print()
-{
- exp_cmd_print(&exp_cmds[EXP_CMD_BEFORE]);
- exp_cmd_print(&exp_cmds[EXP_CMD_AFTER]);
- exp_cmd_print(&exp_cmds[EXP_CMD_BG]);
-}
-
-/*ARGSUSED*/
-int
-cmdX(clientData, interp, argc, argv)
-ClientData clientData;
-Tcl_Interp *interp;
-int argc;
-char **argv;
-{
- exp_cmds_print();
- return TCL_OK;
-}
-#endif /*DEBUG_PERM_ECASES*/
-
-/* need address for passing into cmdExpect */
-static int spawn_id_bad = EXP_SPAWN_ID_BAD;
-static int spawn_id_user = EXP_SPAWN_ID_USER;
-
-static struct exp_cmd_data
-cmd_data[] = {
-{"expect", exp_proc(Exp_ExpectCmd), (ClientData)&spawn_id_bad, 0},
-{"expect_after",exp_proc(Exp_ExpectGlobalCmd),(ClientData)&exp_cmds[EXP_CMD_AFTER],0},
-{"expect_before",exp_proc(Exp_ExpectGlobalCmd),(ClientData)&exp_cmds[EXP_CMD_BEFORE],0},
-{"expect_user", exp_proc(Exp_ExpectCmd), (ClientData)&spawn_id_user, 0},
-{"expect_tty", exp_proc(Exp_ExpectCmd), (ClientData)&exp_dev_tty, 0},
-{"expect_background",exp_proc(Exp_ExpectGlobalCmd),(ClientData)&exp_cmds[EXP_CMD_BG],0},
-{"match_max", exp_proc(Exp_MatchMaxCmd), 0, 0},
-{"remove_nulls",exp_proc(Exp_RemoveNullsCmd), 0, 0},
-{"parity", exp_proc(Exp_ParityCmd), 0, 0},
-{"timestamp", exp_proc(Exp_TimestampCmd), 0, 0},
-{0}};
-
-void
-exp_init_expect_cmds(interp)
-Tcl_Interp *interp;
-{
- exp_create_commands(interp,cmd_data);
-
- Tcl_SetVar(interp,EXPECT_TIMEOUT,INIT_EXPECT_TIMEOUT_LIT,0);
- Tcl_SetVar(interp,EXP_SPAWN_ID_ANY_VARNAME,EXP_SPAWN_ID_ANY_LIT,0);
-
- exp_cmd_init(&exp_cmds[EXP_CMD_BEFORE],EXP_CMD_BEFORE,EXP_PERMANENT);
- exp_cmd_init(&exp_cmds[EXP_CMD_AFTER ],EXP_CMD_AFTER, EXP_PERMANENT);
- exp_cmd_init(&exp_cmds[EXP_CMD_BG ],EXP_CMD_BG, EXP_PERMANENT);
- exp_cmd_init(&exp_cmds[EXP_CMD_FG ],EXP_CMD_FG, EXP_TEMPORARY);
-
- /* preallocate to one element, so future realloc's work */
- exp_cmds[EXP_CMD_BEFORE].ecd.cases = 0;
- exp_cmds[EXP_CMD_AFTER ].ecd.cases = 0;
- exp_cmds[EXP_CMD_BG ].ecd.cases = 0;
-
- pattern_style[PAT_EOF] = "eof";
- pattern_style[PAT_TIMEOUT] = "timeout";
- pattern_style[PAT_DEFAULT] = "default";
- pattern_style[PAT_FULLBUFFER] = "full buffer";
- pattern_style[PAT_GLOB] = "glob pattern";
- pattern_style[PAT_RE] = "regular expression";
- pattern_style[PAT_EXACT] = "exact string";
- pattern_style[PAT_NULL] = "null";
-
-#if 0
- Tcl_CreateCommand(interp,"x",
- cmdX,(ClientData)0,exp_deleteProc);
-#endif
-}
-
-void
-exp_init_sig() {
-#if 0
- signal(SIGALRM,sigalarm_handler);
- signal(SIGINT,sigint_handler);
-#endif
-}
+++ /dev/null
-/* 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.
-*/
-
-#ifndef _EXPECT_H
-#define _EXPECT_H
-
-#include "expect_comm.h"
-
-enum exp_type {
- 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 */
- char *pattern;
- Expect_regexp *re;
- enum exp_type type;
- 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 */
- /* do allocation */
-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 jmp_buf exp_readenv; /* for interruptable read() */
-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_logfile_all;
-EXTERN FILE *exp_debugfile;
-EXTERN FILE *exp_logfile;
-
-EXTERN int exp_disconnect _ANSI_ARGS_((void));
-EXTERN FILE *exp_popen _ANSI_ARGS_((char *command));
-EXTERN void (*exp_child_exec_prelude) _ANSI_ARGS_((void));
-
-#ifndef EXP_DEFINE_FNS
-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));
-#endif
-
-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));
-
-#endif /* _EXPECT_H */
+++ /dev/null
-.TH EXPECT 1 "29 December 1994"
-.SH NAME
-expect \- programmed dialogue with interactive programs, Version 5
-.SH SYNOPSIS
-.B expect
-[
-.B \-dDinN
-]
-[
-.B \-c
-.I cmds
-]
-[
-.BR \- [ f | b ]
-]
-.I cmdfile
-]
-[
-.I args
-]
-.SH INTRODUCTION
-.B Expect
-is a program that "talks" to other interactive programs according to a
-script. Following the script,
-.B Expect
-knows what can be expected from
-a program and what the correct response should be. An interpreted
-language provides branching and high-level control structures to
-direct the dialogue. In addition, the user can take control
-and interact directly when desired, afterward returning control to the
-script.
-.PP
-.B Expectk
-is a mixture of
-.B Expect
-and
-.BR Tk .
-It behaves just like
-.B Expect
-and
-.BR Tk 's
-.BR wish .
-.B Expect
-can also be used directly in C or C++ (that is, without Tcl).
-See libexpect(3).
-.PP
-The name "Expect" comes from the idea of
-.I send/expect
-sequences popularized
-by uucp, kermit and other modem control programs.
-However unlike uucp,
-.B Expect
-is generalized so that it can be run as a user-level command
-with any program and task in mind.
-.B Expect
-can actually talk to several programs at the same time.
-.PP
-For example, here are some things
-.B Expect
-can do:
-.RS
-.TP 4
-\(bu
-Cause your computer to dial you back,
-so that you can login without paying for the call.
-.TP
-\(bu
-Start a game (e.g., rogue) and if the optimal configuration doesn't appear,
-restart it (again and again) until it does,
-then hand over control to you.
-.TP
-\(bu
-Run fsck, and in response to its questions, answer "yes", "no" or give control back to you,
-based on predetermined criteria.
-.TP
-\(bu
-Connect to another network or BBS (e.g., MCI Mail, CompuServe) and
-automatically retrieve your mail so that it appears as if
-it was originally sent to your local system.
-.TP
-\(bu
-Carry environment variables, current directory,
-or any kind of information across rlogin, telnet, tip, su, chgrp, etc.
-.RE
-.PP
-There are a variety of reasons why the shell cannot perform these tasks.
-(Try, you'll see.)
-All are possible with
-.BR Expect .
-.PP
-In general,
-.B Expect
-is useful for running any program which requires
-interaction between the program and the user.
-All that is necessary is that the interaction can be characterized
-programmatically.
-.B Expect
-can also give the user back control
-(without halting the program being controlled) if desired.
-Similarly, the user can return control to the script at any time.
-.SH USAGE
-.B Expect
-reads
-.I cmdfile
-for a list of commands to execute.
-.B Expect
-may also be invoked implicitly on systems which support the #! notation
-by marking the script executable, and making the first line in your script:
-
- #!/usr/local/bin/expect \-f
-
-Of course, the path must accurately describe where
-.B Expect
-lives. /usr/local/bin is just an example.
-
-The
-.B \-c
-flag prefaces a command to be executed before any in the script.
-The command should be quoted to prevent being broken up by the shell.
-This option may be used multiple times.
-Multiple commands may be
-executed with a single
-.B \-c
-by separating them with semicolons.
-Commands are executed in the order they appear.
-(When using Expectk, this option is specified as
-.BR \-command .)
-.PP
-The
-.B \-d
-flag enables some diagnostic output, which
-primarily reports internal activity of commands such as
-.B expect
-and
-.BR interact .
-This flag has the same effect as "exp_internal 1" at the beginning of an Expect
-script, plus the version of
-.B Expect
-is printed.
-(The
-.B strace
-command is useful for tracing statements, and the
-.B trace
-command is useful for tracing variable assignments.)
-(When using Expectk, this option is specified as
-.BR \-diag .)
-.PP
-The
-.B \-D
-flag enables an interactive debugger. An integer value should follow.
-The debugger will take control before the next Tcl procedure
-if the value is non-zero
-or if a ^C is pressed (or a breakpoint is hit, or other appropriate debugger
-command appears in the script). See the README file or SEE ALSO (below)
-for more information on the debugger.
-(When using Expectk, this option is specified as
-.BR \-Debug .)
-.PP
-The
-.B \-f
-flag prefaces a file from which to read commands from.
-The flag itself is optional as it is only useful when using
-the #! notation (see above),
-so that other arguments may be supplied on the command line.
-(When using Expectk, this option is specified as
-.BR \-file .)
-.PP
-By default, the command file is read into memory and executed in its entirety.
-It is occasionally desirable to read files one line at a time. For example,
-stdin is read this way. In order to force arbitrary files to be handled this
-way, use the
-.B \-b
-flag.
-(When using Expectk, this option is specified as
-.BR \-buffer .)
-.PP
-If the string "\-" is supplied as a filename, standard input is read instead.
-(Use "./\-" to read from a file actually named "\-".)
-.PP
-The
-.B \-i
-flag causes
-.B Expect
-to interactively prompt for commands instead of reading
-them from a file.
-Prompting is terminated via the
-.B exit
-command or upon EOF.
-See
-.B interpreter
-(below) for more information.
-.B \-i
-is assumed if neither a command file nor
-.B \-c
-is used.
-(When using Expectk, this option is specified as
-.BR \-interactive .)
-.PP
-.B \-\-
-may be used to delimit the end of the options. This is useful if
-you want to pass an option-like argument to your script without it being
-interpreted by
-.BR Expect .
-This can usefully be placed in the #! line to prevent any flag-like
-interpretation by Expect. For example, the following will leave the
-original arguments (including the script name) in the variable
-.IR argv .
-
- #!/usr/local/bin/expect \-\-
-
-Note that the usual getopt(3) and execve(2) conventions must be observed
-when adding arguments to the #! line.
-.PP
-The file $exp_library/expect.rc is sourced automatically if present, unless
-the
-.B \-N
-flag is used.
-(When using Expectk, this option is specified as
-.BR \-NORC .)
-Immediately after this,
-the file ~/.expect.rc is sourced automatically, unless the
-.B \-n
-flag is used. If the environment variable DOTDIR is defined,
-it is treated as a directory and .expect.rc is read from there.
-(When using Expectk, this option is specified as
-.BR \-norc .)
-This sourcing occurs only after executing any
-.B \-c
-flags.
-.PP
-.B \-v
-causes Expect to print its version number and exit. (The corresponding flag
-in Expectk, which uses long flag names, is \-version.)
-.PP
-Optional
-.I args
-are constructed into a list and stored in the variable named
-.IR argv .
-.I argc
-is initialized to the length of argv.
-.PP
-.I argv0
-is defined to be the name of the script (or binary if no script is used).
-For example,
-the following prints out the name of the script and the first three arguments:
-.nf
-
- send_user "$argv0 [lrange $argv 0 2]\\n"
-
-.fi
-.SH COMMANDS
-.B Expect
-uses
-.I Tcl
-(Tool Command Language).
-Tcl provides control flow (e.g., if, for, break),
-expression evaluation and several other features such as recursion,
-procedure definition, etc.
-Commands used here but not defined (e.g.,
-.BR set ,
-.BR if ,
-.BR exec )
-are Tcl commands (see tcl(3)).
-.B Expect
-supports additional commands, described below.
-Unless otherwise specified, commands return the empty string.
-.PP
-Commands are listed alphabetically so that they can be quickly located.
-However, new users may find it easier to start by reading the descriptions
-of
-.BR spawn ,
-.BR send ,
-.BR expect ,
-and
-.BR interact ,
-in that order.
-
-Note that the best introduction to the language (both Expect and Tcl)
-is provided in the book "Exploring Expect" (see SEE ALSO below).
-Examples are included in this man page but they are very limited since
-this man page is meant primarily as reference material.
-
-Note that in the text of this man page, "Expect" with an uppercase "E"
-refers to the
-.B Expect
-program while "expect" with a lower-case "e" refers to the
-.B expect
-command within the
-.B Expect
-program.)
-.I
-.TP 6
-.BI close " [-slave] [\-onexec 0|1] [\-i spawn_id]"
-closes the connection to the current process.
-Most interactive programs will detect EOF on their stdin and exit;
-thus
-.B close
-usually suffices to kill the process as well.
-The
-.B \-i
-flag declares the process to close corresponding to the named spawn_id.
-
-Both
-.B expect
-and
-.B interact
-will detect when the current process exits and implicitly do a
-.BR close .
-But if you kill the process by, say, "exec kill $pid",
-you will need to explicitly call
-.BR close .
-
-The
-.BR \-onexec
-flag determines whether the spawn id will be closed in any new spawned
-processes or if the process is overlayed. To leave a spawn id open,
-use the value 0. A non-zero integer value will force the spawn closed
-(the default) in any new processes.
-
-The
-.B \-slave
-flag closes the slave associated with the spawn id. (See "spawn -pty".)
-When the connection is closed, the slave is automatically closed as
-well if still open.
-
-No matter whether the connection is closed implicitly or explicitly,
-you should call
-.B wait
-to clear up the corresponding kernel process slot.
-.B close
-does not call
-.B wait
-since there is no guarantee that closing a process connection will cause
-it to exit.
-See
-.B wait
-below for more info.
-.TP
-.BI debug " [[-now] 0|1]"
-controls a Tcl debugger allowing you to step through statements, set
-breakpoints, etc.
-
-With no arguments, a 1 is returned if the debugger is not running, otherwise
-a 0 is returned.
-
-With a 1 argument, the debugger is started. With a 0 argument, the
-debugger is stopped. If a 1 argument is preceded by the
-.B \-now
-flag, the debugger is started immediately (i.e., in the middle of the
-.B debug
-command itself). Otherwise, the debugger is started with the next
-Tcl statement.
-
-The
-.B debug
-command does not change any traps. Compare this to starting Expect with the
-.B -D
-flag (see above).
-
-See the README file or SEE ALSO (below)
-for more information on the debugger.
-.TP
-.B disconnect
-disconnects a forked process from the terminal. It continues running in the
-background. The process is given its own process group (if possible).
-Standard I/O is redirected to /dev/null.
-.IP
-The following fragment uses
-.B disconnect
-to continue running the script in the background.
-.nf
-
- if [fork]!=0 exit
- disconnect
- . . .
-
-.fi
-The following script reads a password, and then runs a program
-every hour that demands a password each time it is run. The script supplies
-the password so that you only have to type it once.
-(See the
-.B stty
-command which demonstrates how to turn off password echoing.)
-.nf
-
- send_user "password?\\ "
- expect_user -re "(.*)\\n"
- for {} 1 {} {
- if [fork]!=0 {sleep 3600;continue}
- disconnect
- spawn priv_prog
- expect Password:
- send "$expect_out(1,string)\\r"
- . . .
- exit
- }
-
-.fi
-An advantage to using
-.B disconnect
-over the shell asynchronous process feature (&) is that
-.B Expect
-can
-save the terminal parameters prior to disconnection, and then later
-apply them to new ptys. With &,
-.B Expect
-does not have a chance
-to read the terminal's parameters since the terminal is already
-disconnected by the time
-.B Expect
-receives control.
-.TP
-.BI exit " [\-opts] [status]"
-causes
-.B Expect
-to exit or otherwise prepare to do so.
-
-The
-.B \-onexit
-flag causes the next argument to be used as an exit handler.
-Without an argument, the current exit handler is returned.
-
-The
-.B \-noexit
-flag causes
-.B Expect
-to prepare to exit but stop short of actually returning control to the
-operating system. The user-defined exit handler is run as well as Expect's
-own internal handlers.
-No further Expect commands should be executed.
-This is useful if you are running Expect with other Tcl extensions.
-The current interpreter (and main window if in the Tk environment) remain
-so that other Tcl extensions can clean up. If Expect's
-.B exit
-is called again (however this might occur), the handlers are not rerun.
-
-Upon exiting,
-all connections to spawned processes are closed. Closure will be detected
-as an EOF by spawned processes.
-.B exit
-takes no other actions beyond what the normal _exit(2) procedure does.
-Thus, spawned processes that do not check for EOF may continue to run.
-(A variety of conditions are important to determining, for example, what
-signals a spawned process will be sent, but these are system-dependent,
-typically documented under exit(3).)
-Spawned processes that continue to run will be inherited by init.
-
-.I status
-(or 0 if not specified) is returned as the exit status of
-.BR Expect .
-.B exit
-is implicitly executed if the end of the script is reached.
-.TP
-.B exp_continue
-The command
-.B exp_continue
-allows
-.B expect
-itself to continue
-executing rather than returning as it normally would.
-(See
-.B expect
-for more information.)
-.TP
-.BI exp_internal " [\-f file] value"
-causes further commands to send diagnostic information internal to
-.B Expect
-to stderr if
-.I value
-is non-zero. This output is disabled if
-.I value
-is 0. The diagnostic information includes every character received,
-and every attempt made to match the current output against the patterns.
-.IP
-If the optional
-.I file
-is supplied, all normal and debugging output is written to that file
-(regardless of the value of
-.IR value ).
-Any previous diagnostic output file is closed.
-
-The
-.B \-info
-flag causes exp_internal to return a description of the
-most recent non-info arguments given.
-.TP
-.BI exp_open " [args] [\-i spawn_id]"
-returns a Tcl file identifier that corresponds to the original spawn id.
-The file identifier can then be used as if it were opened by Tcl's
-.B open
-command. (The spawn id should no longer be used. A
-.B wait
-should not be executed.
-
-The
-.B \-leaveopen
-flag leaves the spawn id open for access through
-Expect commands. A
-.B wait
-must be executed on the spawn id.
-.TP
-.BI exp_pid " [\-i spawn_id]"
-returns the process id corresponding to the currently spawned process.
-If the
-.B \-i
-flag is used, the pid returned corresponds to that of the given spawn id.
-.TP
-.B exp_send
-is an alias for
-.BR send .
-.TP
-.B exp_send_error
-is an alias for
-.BR send_error .
-.TP
-.B exp_send_log
-is an alias for
-.BR send_log .
-.TP
-.B exp_send_tty
-is an alias for
-.BR send_tty .
-.TP
-.B exp_send_user
-is an alias for
-.BR send_user .
-.TP
-.BI exp_version " [[\-exit] version]"
-is useful for assuring that the script is compatible with the current
-version of Expect.
-.IP
-With no arguments, the current version of
-.B Expect
-is returned. This version
-may then be encoded in your script. If you actually know that you are not
-using features of recent versions, you can specify an earlier version.
-.IP
-Versions consist of three numbers separated by dots. First
-is the major number. Scripts written for versions of
-.B Expect
-with a
-different major number will almost certainly not work.
-.B exp_version
-returns an error if the major numbers do not match.
-.IP
-Second is the minor number. Scripts written for a version with a
-greater minor number than the current version
-may depend upon some new feature and might not run.
-.B exp_version
-returns an error if the major numbers match, but the script minor number
-is greater than that of the running
-.BR Expect .
-.IP
-Third is a number that plays no part in the version comparison.
-However, it is incremented when the
-.B Expect
-software
-distribution is changed in any way, such as by additional documentation
-or optimization. It is reset to 0 upon each new minor version.
-.IP
-With the
-.B \-exit
-flag,
-.B Expect
-prints an error and exits if the version is out of date.
-.TP
-.BI expect " [[\-opts] pat1 body1] ... [\-opts] patn [bodyn]"
-waits until one of the patterns matches the output of a spawned process,
-a specified time period has passed, or an end-of-file is seen.
-If the final body is empty, it may be omitted.
-.IP
-Patterns from the most recent
-.B expect_before
-command are implicitly used before any other patterns.
-Patterns from the most recent
-.B expect_after
-command are implicitly used after any other patterns.
-.IP
-If the arguments to the entire
-.B expect
-statement require more than one line,
-all the arguments may be "braced" into one so as to avoid terminating each
-line with a backslash. In this one case, the usual Tcl substitutions will
-occur despite the braces.
-.IP
-If a pattern is the keyword
-.BR eof ,
-the corresponding body is executed upon end-of-file.
-If a pattern is the keyword
-.BR timeout ,
-the corresponding body is executed upon timeout. If no timeout keyword
-is used, an implicit null action is executed upon timeout.
-The default timeout period is 10 seconds but may be set, for example to 30,
-by the command "set timeout 30". An infinite timeout may be designated
-by the value \-1.
-If a pattern is the keyword
-.BR default ,
-the corresponding body is executed upon either timeout or end-of-file.
-.IP
-If a pattern matches, then the corresponding body is executed.
-.B expect
-returns the result of the body (or the empty string if no pattern matched).
-In the event that multiple patterns match, the one appearing first is
-used to select a body.
-.IP
-Each time new output arrives, it is compared to each pattern in the order
-they are listed. Thus, you may test for absence of a match by making
-the last pattern something guaranteed to appear, such as a prompt.
-In situations where there is no prompt, you must use
-.B timeout
-(just like you would if you were interacting manually).
-.IP
-Patterns are specified in three ways. By default,
-patterns are specified as with Tcl's
-.B string match
-command. (Such patterns are also similar to C-shell regular expressions
-usually referred to as "glob" patterns). The
-.B \-gl
-flag may may
-be used to protect patterns that might otherwise match
-.B expect
-flags from doing so.
-Any pattern beginning with a "-" should be protected this way. (All strings
-starting with "-" are reserved for future options.)
-
-.IP
-For example, the following fragment looks for a successful login.
-(Note that
-.B abort
-is presumed to be a procedure defined elsewhere in the script.)
-.nf
-
-.ta \w' expect 'u +\w'invalid password 'u
- expect {
- busy {puts busy\\n ; exp_continue}
- failed abort
- "invalid password" abort
- timeout abort
- connected
- }
-
-.fi
-Quotes are necessary on the fourth pattern since it contains a space, which
-would otherwise separate the pattern from the action.
-Patterns with the same action (such as the 3rd and 4th) require listing the
-actions again. This can be avoid by using regexp-style patterns (see below).
-More information on forming glob-style patterns can be found in the Tcl manual.
-.IP
-Regexp-style patterns follow the syntax defined by Tcl's
-.B regexp
-(short for "regular expression") command.
-regexp patterns are introduced with the flag
-.BR \-re .
-The previous example can be rewritten using a regexp as:
-.nf
-
-.ta \w' expect 'u +\w'connected 'u
- expect {
- busy {puts busy\\n ; exp_continue}
- \-re "failed|invalid password" abort
- timeout abort
- connected
- }
-
-.fi
-Both types of patterns are "unanchored". This means that patterns
-do not have to match the entire string, but can begin and end the
-match anywhere in the string (as long as everything else matches).
-Use ^ to match the beginning of a string, and $ to match the end.
-Note that if you do not wait for the end of a string, your responses
-can easily end up in the middle of the string as they are echoed from
-the spawned process. While still producing correct results, the output
-can look unnatural. Thus, use of $ is encouraged if you can exactly
-describe the characters at the end of a string.
-
-Note that in many editors, the ^ and $ match the beginning and end of
-lines respectively. However, because expect is not line oriented,
-these characters match the beginning and end of the data (as opposed
-to lines) currently in the expect matching buffer. (Also, see the
-note below on "system indigestion.")
-
-The
-.B \-ex
-flag causes the pattern to be matched as an "exact" string. No
-interpretation of *, ^, etc is made (although the usual Tcl
-conventions must still be observed).
-Exact patterns are always unanchored.
-
-.IP
-The
-.B \-nocase
-flag causes uppercase characters of the output to compare as if they were
-lowercase characters. The pattern is not affected.
-.IP
-While reading output,
-more than 2000 bytes can force earlier bytes to be "forgotten".
-This may be changed with the function
-.BR match_max .
-(Note that excessively large values can slow down the pattern matcher.)
-If
-.I patlist
-is
-.BR full_buffer ,
-the corresponding body is executed if
-.I match_max
-bytes have been received and no other patterns have matched.
-Whether or not the
-.B full_buffer
-keyword is used, the forgotten characters are written to
-expect_out(buffer).
-
-If
-.I patlist
-is the keyword
-.BR null ,
-and nulls are allowed (via the
-.B remove_nulls
-command), the corresponding body is executed if a single ASCII
-0 is matched.
-It is not possible to
-match 0 bytes via glob or regexp patterns.
-
-Upon matching a pattern (or eof or full_buffer),
-any matching and previously unmatched output is saved in the variable
-.IR expect_out(buffer) .
-Up to 9 regexp substring matches are saved in the variables
-.I expect_out(1,string)
-through
-.IR expect_out(9,string) .
-If the
-.B -indices
-flag is used before a pattern,
-the starting and ending indices (in a form suitable for
-.BR lrange )
-of the
-10 strings are stored in the variables
-.I expect_out(X,start)
-and
-.I expect_out(X,end)
-where X is a digit, corresponds to the substring position in the buffer.
-0 refers to strings which matched the entire pattern
-and is generated for glob patterns as well as regexp patterns.
-For example, if a process has produced output of "abcdefgh\\n", the result of:
-.nf
-
- expect "cd"
-
-.fi
-is as if the following statements had executed:
-.nf
-
- set expect_out(0,string) cd
- set expect_out(buffer) abcd
-
-.fi
-and "efgh\\n" is left in the output buffer.
-If a process produced the output "abbbcabkkkka\\n", the result of:
-.nf
-
- expect \-indices \-re "b(b*).*(k+)"
-
-.fi
-is as if the following statements had executed:
-.nf
-
- set expect_out(0,start) 1
- set expect_out(0,end) 10
- set expect_out(0,string) bbbcabkkkk
- set expect_out(1,start) 2
- set expect_out(1,end) 3
- set expect_out(1,string) bb
- set expect_out(2,start) 10
- set expect_out(2,end) 10
- set expect_out(2,string) k
- set expect_out(buffer) abbbcabkkkk
-
-.fi
-and "a\\n" is left in the output buffer. The pattern "*" (and -re ".*") will
-flush the output buffer without reading any more output from the
-process.
-.IP
-Normally, the matched output is discarded from Expect's internal buffers.
-This may be prevented by prefixing a pattern with the
-.B \-notransfer
-flag. This flag is especially useful in experimenting (and can be
-abbreviated to "-n" for convenience while experimenting).
-
-The spawn id associated with the matching output (or eof or
-full_buffer) is stored in
-.IR expect_out(spawn_id) .
-
-The
-.B \-timeout
-flag causes the current expect command to use the following value
-as a timeout instead of using the value of the timeout variable.
-
-By default,
-patterns are matched against output from the current process, however the
-.B \-i
-flag declares the output from the named spawn_id list be matched against
-any following patterns (up to the next
-.BR \-i ).
-The spawn_id list should either be a whitespace separated list of spawn_ids
-or a variable referring to such a list of spawn_ids.
-
-For example, the following example waits for
-"connected" from the current process, or "busy", "failed" or "invalid
-password" from the spawn_id named by $proc2.
-.nf
-
- expect {
- \-i $proc2 busy {puts busy\\n ; exp_continue}
- \-re "failed|invalid password" abort
- timeout abort
- connected
- }
-
-.fi
-The value of the global variable
-.I any_spawn_id
-may be used to match patterns to any spawn_ids that are named
-with all other
-.B \-i
-flags in the current
-.B expect
-command.
-The spawn_id from a
-.B \-i
-flag with no associated pattern (i.e., followed immediately
-by another
-.BR \-i )
-is made available to any other patterns
-in the same
-.B expect
-command associated with
-.I any_spawn_id.
-
-The
-.B \-i
-flag may also name a global variable in which case the variable is read
-for a list of spawn ids. The variable is reread whenever it changes.
-This provides a way of changing the I/O source while the command is in
-execution. Spawn ids provided this way are called "indirect" spawn ids.
-
-Actions such as
-.B break
-and
-.B continue
-cause control structures (i.e.,
-.BR for ,
-.BR proc )
-to behave in the usual way.
-The command
-.B exp_continue
-allows
-.B expect
-itself to continue
-executing rather than returning as it normally would.
-.IP
-This is useful for avoiding explicit loops or repeated expect statements.
-The following example is part of a fragment to automate rlogin. The
-.B exp_continue
-avoids having to write a second
-.B expect
-statement (to look for the prompt again) if the rlogin prompts for a password.
-.nf
-
- expect {
- Password: {
- stty -echo
- send_user "password (for $user) on $host: "
- expect_user -re "(.*)\\n"
- send_user "\\n"
- send "$expect_out(1,string)\\r"
- stty echo
- exp_continue
- } incorrect {
- send_user "invalid password or account\\n"
- exit
- } timeout {
- send_user "connection to $host timed out\\n"
- exit
- } eof {
- send_user \\
- "connection to host failed: $expect_out(buffer)"
- exit
- } -re $prompt
- }
-
-.fi
-For example, the following fragment might help a user guide
-an interaction that is already totally automated. In this case, the terminal
-is put into raw mode. If the user presses "+", a variable is incremented.
-If "p" is pressed, several returns are sent to the process,
-perhaps to poke it in some way, and "i" lets the user interact with the
-process, effectively stealing away control from the script.
-In each case, the
-.B exp_continue
-allows the current
-.B expect
-to continue pattern matching after executing the
-current action.
-.nf
-
- stty raw \-echo
- expect_after {
- \-i $user_spawn_id
- "p" {send "\\r\\r\\r"; exp_continue}
- "+" {incr foo; exp_continue}
- "i" {interact; exp_continue}
- "quit" exit
- }
-
-.fi
-.IP
-By default,
-.B exp_continue
-resets the timeout timer. The timer is not restarted, if
-.B exp_continue
-is called with the
-.B \-continue_timer
-flag.
-.TP
-.BI expect_after " [expect_args]"
-works identically to the
-.B expect_before
-except that if patterns from both
-.B expect
-and
-.B expect_after
-can match, the
-.B expect
-pattern is used. See the
-.B expect_before
-command for more information.
-.TP
-.BI expect_background " [expect_args]"
-takes the same arguments as
-.BR expect ,
-however it returns immediately.
-Patterns are tested whenever new input arrives.
-The pattern
-.B timeout
-and
-.B default
-are meaningless to
-.BR expect_background
-and are silently discarded.
-Otherwise, the
-.B expect_background
-command uses
-.B expect_before
-and
-.B expect_after
-patterns just like
-.B expect
-does.
-
-When
-.B expect_background
-actions are being evaluated, background processing for the same
-spawn id is blocked. Background processing is unblocked when
-the action completes. While background processing is blocked,
-it is possible to do a (foreground)
-.B expect
-on the same spawn id.
-
-It is not possible to execute an
-.B expect
-while an
-.B expect_background
-is unblocked.
-.B expect_background
-for a particular spawn id is deleted by
-declaring a new expect_background with the same spawn id. Declaring
-.B expect_background
-with no pattern removes the given spawn id
-from the ability to match patterns in the background.
-.TP
-.BI expect_before " [expect_args]"
-takes the same arguments as
-.BR expect ,
-however it returns immediately.
-Pattern-action pairs from the most recent
-.B expect_before
-with the same spawn id are implicitly added to any following
-.B expect
-commands. If a pattern matches, it is treated as if it had been
-specified in the
-.B expect
-command itself, and the associated body is executed in the context
-of the
-.B expect
-command.
-If patterns from both
-.B expect_before
-and
-.B expect
-can match, the
-.B expect_before
-pattern is used.
-
-If no pattern is specified, the spawn id is not checked for any patterns.
-
-Unless overridden by a
-.B \-i
-flag,
-.B expect_before
-patterns match against the spawn id defined at the time that the
-.B expect_before
-command was executed (not when its pattern is matched).
-
-The \-info flag causes
-.B expect_before
-to return the current specifications of what patterns it will match.
-By default, it reports on the current spawn id. An optional spawn id specification may be given for information on that spawn id. For example
-.nf
-
- expect_before -info -i $proc
-
-.fi
-At most one spawn id specification may be given. The flag \-indirect
-suppresses direct spawn ids that come only from indirect specifications.
-
-Instead of a spawn id specification, the flag "-all" will cause
-"-info" to report on all spawn ids.
-
-The output of the \-info flag can be reused as the argument to expect_before.
-.TP
-.BI expect_tty " [expect_args]"
-is like
-.B expect
-but it reads characters from /dev/tty (i.e. keystrokes from the user).
-By default, reading is performed in cooked mode.
-Thus, lines must end with a return in order for
-.B expect
-to see them.
-This may be changed via
-.B stty
-(see the
-.B stty
-command below).
-.TP
-.BI expect_user " [expect_args]"
-is like
-.B expect
-but it reads characters from stdin (i.e. keystrokes from the user).
-By default, reading is performed in cooked mode.
-Thus, lines must end with a return in order for
-.B expect
-to see them.
-This may be changed via
-.B stty
-(see the
-.B stty
-command below).
-.TP
-.B fork
-creates a new process. The new process is an exact copy of the current
-.B Expect
-process. On success,
-.B fork
-returns 0 to the new (child) process and returns the process ID of the child
-process to the parent process.
-On failure (invariably due to lack of resources, e.g., swap space, memory),
-.B fork
-returns \-1 to the parent process, and no child process is created.
-.IP
-Forked processes exit via the
-.B exit
-command, just like the original process.
-Forked processes are allowed to write to the log files. If you do not
-disable debugging or logging in most of the processes, the result can be
-confusing.
-.IP
-Some pty implementations may be confused by multiple readers and writers,
-even momentarily. Thus, it is safest to
-.B fork
-before spawning processes.
-.TP
-.BI interact " [string1 body1] ... [stringn [bodyn]]"
-gives control of the current process to the user, so that
-keystrokes are sent to the current process,
-and the stdout and stderr of the current process are returned.
-.IP
-String-body pairs may be specified as arguments, in which case the
-body is executed when the corresponding string is entered. (By default, the
-string is not sent to the current process.) The
-.B interpreter
-command is assumed, if the final body is missing.
-.IP
-If the arguments to the entire
-.B interact
-statement require more than one line,
-all the arguments may be "braced" into one so as to avoid terminating each
-line with a backslash. In this one case, the usual Tcl substitutions will
-occur despite the braces.
-.IP
-For example, the following command runs interact with the following
-string-body pairs defined: When ^Z is pressed,
-.B Expect
-is suspended.
-(The
-.B \-reset
-flag restores the terminal modes.)
-When ^A is pressed, the user sees "you typed a control-A" and the
-process is sent a ^A. When $ is pressed, the user sees the date.
-When ^C is pressed,
-.B Expect
-exits. If "foo" is entered, the user sees "bar".
-When ~~ is pressed, the
-.B Expect
-interpreter runs interactively.
-.nf
-
-.ta \w' interact 'u +\w'$CTRLZ 'u +\w'{'u
- set CTRLZ \\032
- interact {
- -reset $CTRLZ {exec kill \-STOP [pid]}
- \\001 {send_user "you typed a control\-A\\n";
- send "\\001"
- }
- $ {send_user "The date is [exec date]."}
- \\003 exit
- foo {send_user "bar"}
- ~~
- }
-
-.fi
-.IP
-In string-body pairs, strings are matched in the order they are listed
-as arguments. Strings that partially match are not sent to the
-current process in anticipation of the remainder coming. If
-characters are then entered such that there can no longer possibly be
-a match, only the part of the string will be sent to the process that cannot
-possibly begin another match. Thus, strings that are substrings of
-partial matches can match later, if the original strings that was attempting
-to be match ultimately fails.
-.IP
-By default, string matching is exact with no wild cards. (In contrast,
-the
-.B expect
-command uses glob-style patterns by default.) The
-.B \-ex
-flag may be used to protect patterns that might otherwise match
-.B interact
-flags from doing so.
-Any pattern beginning with a "-" should be protected this way. (All strings
-starting with "-" are reserved for future options.)
-
-The
-.B \-re
-flag forces the string to be interpreted as a regexp-style pattern. In this
-case, matching substrings are stored in the variable
-.I interact_out
-similarly to the way
-.B expect
-stores its output in the variable
-.BR expect_out .
-The
-.B \-indices
-flag is similarly supported.
-
-The pattern
-.B eof
-introduces an action that is
-executed upon end-of-file. A separate
-.B eof
-pattern may also follow the
-.B \-output
-flag in which case it is matched if an eof is detected while writing output.
-The default
-.B eof
-action is "return", so that
-.B interact
-simply returns upon any EOF.
-
-The pattern
-.B timeout
-introduces a timeout (in seconds) and action that is executed
-after no characters have been read for a given time.
-The
-.B timeout
-pattern applies to the most recently specified process.
-There is no default timeout.
-The special variable "timeout" (used by the
-.B expect
-command) has no affect on this timeout.
-
-For example, the following statement could be used to autologout users who have
-not typed anything for an hour but who still get frequent system
-messages:
-.nf
-
- interact -input $user_spawn_id timeout 3600 return -output \\
- $spawn_id
-
-.fi
-
-If the pattern is the keyword
-.BR null ,
-and nulls are allowed (via the
-.B remove_nulls
-command), the corresponding body is executed if a single ASCII
-0 is matched.
-It is not possible to
-match 0 bytes via glob or regexp patterns.
-
-Prefacing a pattern with the flag
-.B \-iwrite
-causes the variable
-.I interact_out(spawn_id)
-to be set to the spawn_id which matched the pattern
-(or eof).
-
-Actions such as
-.B break
-and
-.B continue
-cause control structures (i.e.,
-.BR for ,
-.BR proc )
-to behave in the usual way.
-However
-.B return
-causes interact to return to its caller, while
-.B inter_return
-causes
-.B interact
-to cause a return in its caller. For example, if "proc foo" called
-.B interact
-which then executed the action
-.BR inter_return ,
-.B proc foo
-would return. (This means that if
-.B interact
-calls
-.B interpreter
-interactively typing
-.B return
-will cause the interact to continue, while
-.B inter_return
-will cause the interact to return to its caller.)
-.IP
-During
-.BR interact ,
-raw mode is used so that all characters may be passed to the current process.
-If the current process does not catch job control signals,
-it will stop if sent a stop signal (by default ^Z).
-To restart it, send a continue signal (such as by "kill \-CONT <pid>").
-If you really want to send a SIGSTOP to such a process (by ^Z),
-consider spawning csh first and then running your program.
-On the other hand, if you want to send a SIGSTOP to
-.B Expect
-itself, first press the escape character, and then press ^Z.
-.IP
-String-body pairs can be used as a shorthand for avoiding having
-to enter the interpreter and execute commands interactively. The previous
-terminal mode is used while the body of a string-body pair is being executed.
-.IP
-For speed, actions execute in raw mode by default. The
-.B \-reset
-flag resets the terminal to the mode it had before
-.B interact
-was executed (invariably, cooked mode).
-Note that characters entered when the mode is being switched may be lost
-(an unfortunate feature of the terminal driver on some systems).
-The only reason to use
-.B \-reset
-is if your action
-depends on running in cooked mode.
-.IP
-The
-.B \-echo
-flag sends characters that match the following pattern back to the process
-that generated them as each character is read. This may be useful
-when the user needs to see feedback from partially typed patterns.
-.IP
-If a pattern is being echoed but eventually fails to match,
-the characters are sent to the spawned process. If the spawned
-process then echoes them, the user will see the characters twice.
-.B \-echo
-is probably only appropriate in situations where the user is
-unlikely to not complete the pattern. For example, the following
-excerpt is from rftp, the recursive-ftp script, where the user is
-prompted to enter ~g, ~p, or ~l, to get, put, or list the current
-directory recursively. These are so far away from the normal ftp
-commands, that the user is unlikely to type ~ followed by anything
-else, except mistakenly, in which case, they'll probably just ignore
-the result anyway.
-.nf
-
- interact {
- -echo ~g {getcurdirectory 1}
- -echo ~l {getcurdirectory 0}
- -echo ~p {putcurdirectory}
- }
-
-.fi
-The
-.B \-nobuffer
-flag sends characters that match the following pattern on to
-the output process as characters are read.
-
-This is useful when you wish to let a program echo back the pattern.
-For example, the following might be used to monitor where a person is
-dialing (a Hayes-style modem). Each time "atd" is seen the script
-logs the rest of the line.
-.nf
-
- proc lognumber {} {
- interact -nobuffer -re "(.*)\\r" return
- puts $log "[exec date]: dialed $interact_out(1,string)"
- }
-
- interact -nobuffer "atd" lognumber
-
-.fi
-.IP
-During
-.BR interact ,
-previous use of
-.B log_user
-is ignored. In particular,
-.B interact
-will force its output to be logged (sent to the standard output)
-since it is presumed the user doesn't wish to interact blindly.
-.IP
-The
-.B \-o
-flag causes any following key-body pairs to be applied to the output of
-the current process.
-This can be useful, for example, when dealing with hosts that
-send unwanted characters during a telnet session.
-.IP
-By default,
-.B interact
-expects the user to be writing stdin and reading stdout of the
-.B Expect
-process
-itself.
-The
-.B \-u
-flag (for "user") makes
-.B interact
-look for the user as the process named by its argument
-(which must be a spawned id).
-.IP
-This allows two unrelated processes to be joined
-together without using an explicit loop. To aid in debugging, Expect
-diagnostics always go to stderr (or stdout for certain logging and
-debugging information). For the same reason, the
-.B interpreter
-command will read interactively from stdin.
-.IP
-For example, the following fragment creates a login process.
-Then it dials the user (not shown), and finally connects the two together.
-Of course, any process may be substituted for login.
-A shell, for example, would allow the user to work without supplying an
-account and password.
-.nf
-
- spawn login
- set login $spawn_id
- spawn tip modem
- # dial back out to user
- # connect user to login
- interact \-u $login
-
-.fi
-To send output to multiple processes, list each spawn id list prefaced by a
-.B \-output
-flag. Input for a group of output spawn ids may be determined
-by a spawn id list prefaced by a
-.B \-input
-flag. (Both
-.B \-input
-and
-.B \-output
-may take lists in the same form as the
-.B \-i
-flag in the
-.B expect
-command, except that any_spawn_id is not meaningful in
-.BR interact .)
-All following flags and
-strings (or patterns) apply to this input until another -input flag appears.
-If no
-.B \-input
-appears,
-.B \-output
-implies "\-input $user_spawn_id \-output".
-(Similarly, with patterns that do not have
-.BR \-input .)
-If one
-.B \-input
-is specified, it overrides $user_spawn_id. If a second
-.B \-input
-is specified,
-it overrides $spawn_id. Additional
-.B \-input
-flags may be specified.
-
-The two implied input processes default to having their outputs specified as
-$spawn_id and $user_spawn_id (in reverse).
-If a
-.B \-input
-flag appears
-with no
-.B \-output
-flag, characters from that process are discarded.
-
-The
-.B \-i
-flag introduces a replacement for the current spawn_id when no
-other
-.B \-input
-or
-.B \-output
-flags are used. A \-i flag implies a \-o flag.
-
-It is possible to change the processes that are being interacted with
-by using indirect spawn ids. (Indirect spawn ids are described in the
-section on the expect command.) Indirect spawn ids may be specified
-with the -i, -u, -input, or -output flags.
-.TP
-.B interpreter
-causes the user to be interactively prompted for
-.B Expect
-and Tcl commands.
-The result of each command is printed.
-.IP
-Actions such as
-.B break
-and
-.B continue
-cause control structures (i.e.,
-.BR for ,
-.BR proc )
-to behave in the usual way.
-However
-.B return
-causes interpreter to return to its caller, while
-.B inter_return
-causes
-.B interpreter
-to cause a return in its caller. For example, if "proc foo" called
-.B interpreter
-which then executed the action
-.BR inter_return ,
-.B proc foo
-would return.
-Any other command causes
-.B interpreter
-to continue prompting for new commands.
-.IP
-By default, the prompt contains two integers.
-The first integer describes the depth of
-the evaluation stack (i.e., how many times Tcl_Eval has been called). The
-second integer is the Tcl history identifier. The prompt can be set by
-defining a procedure called "prompt1" whose return value becomes the next
-prompt. If a statement has open quotes, parens, braces, or brackets, a
-secondary prompt (by default "+> ") is issued upon newline. The secondary
-prompt may be set by defining a procedure called "prompt2".
-.IP
-During
-.BR interpreter ,
-cooked mode is used, even if the its caller was using raw mode.
-.TP
-.BI log_file " [args] [[\-a] file]"
-If a filename is provided,
-.B log_file
-will record a transcript of the session (beginning at that point) in the file.
-.B log_file
-will stop recording if no argument is given. Any previous log file is closed.
-
-Instead of a filename, a Tcl file identifier may be provided by using the
-.B \-open
-or
-.B \-leaveopen
-flags. This is similar to the
-.B spawn
-command. (See
-.B spawn
-for more info.)
-
-The
-.B \-a
-flag forces output to be logged that was suppressed by the
-.B log_user
-command.
-
-By default, the
-.B log_file
-command
-.I appends
-to old files rather than truncating them,
-for the convenience of being able to turn logging off and on multiple
-times in one session.
-To truncate files, use the
-.B \-noappend
-flag.
-
-The
-.B -info
-flag causes log_file to return a description of the
-most recent non-info arguments given.
-.TP
-.BI log_user " -info|0|1"
-By default, the send/expect dialogue is logged to stdout
-(and a logfile if open).
-The logging to stdout is disabled by the command "log_user 0"
-and reenabled by "log_user 1". Logging to the logfile is unchanged.
-
-The
-.B -info
-flag causes log_user to return a description of the
-most recent non-info arguments given.
-.TP
-.BI match_max " [\-d] [\-i spawn_id] [size]"
-defines the size of the buffer (in bytes) used internally by
-.BR expect .
-With no
-.I size
-argument, the current size is returned.
-.IP
-With the
-.B \-d
-flag, the default size is set. (The initial default is 2000.)
-With the
-.B \-i
-flag, the size is set for the named spawn id, otherwise it is set for
-the current process.
-.TP
-.BI overlay " [\-# spawn_id] [\-# spawn_id] [...] program [args]"
-executes
-.IR "program args"
-in place of the current
-.B Expect
-program, which terminates.
-A bare hyphen argument forces a hyphen in front of the command name as if
-it was a login shell.
-All spawn_ids are closed except for those named as arguments. These
-are mapped onto the named file identifiers.
-.IP
-Spawn_ids are mapped to file identifiers for the new program to inherit.
-For example, the following line runs chess and allows it to be
-controlled by the current process \- say, a chess master.
-.nf
-
- overlay \-0 $spawn_id \-1 $spawn_id \-2 $spawn_id chess
-
-.fi
-This is more efficient than
-"interact \-u", however, it sacrifices the ability to do programmed
-interaction since the
-.B Expect
-process is no longer in control.
-.IP
-Note that no controlling terminal is provided. Thus, if you
-disconnect or remap standard input, programs that do
-job control (shells, login, etc) will not function properly.
-.TP
-.BI parity " [\-d] [\-i spawn_id] [value]"
-defines whether parity should be retained or stripped from the output of
-spawned processes. If
-.I value
-is zero, parity is stripped, otherwise it is not stripped.
-With no
-.I value
-argument, the current value is returned.
-.IP
-With the
-.B \-d
-flag, the default parity value is set. (The initial default is 1, i.e.,
-parity is not stripped.)
-With the
-.B \-i
-flag, the parity value is set for the named spawn id, otherwise it is set for
-the current process.
-.TP
-.BI remove_nulls " [\-d] [\-i spawn_id] [value]"
-defines whether nulls are retained or removed from the output of
-spawned processes before pattern matching
-or storing in the variable
-.I expect_out
-or
-.IR interact_out .
-If
-.I value
-is 1, nulls are removed. If
-.I value
-is 0, nulls are not removed.
-With no
-.I value
-argument, the current value is returned.
-.IP
-With the
-.B \-d
-flag, the default value is set. (The initial default is 1, i.e.,
-nulls are removed.)
-With the
-.B \-i
-flag, the value is set for the named spawn id, otherwise it is set for
-the current process.
-
-Whether or not nulls are removed,
-.B Expect
-will record null bytes to the log and stdout.
-.TP
-.BI send " [\-flags] string"
-Sends
-.IR string
-to the current process.
-For example, the command
-.nf
-
- send "hello world\\r"
-
-.fi
-sends the characters, h e l l o <blank> w o r l d <return> to the
-current process.
-(Tcl includes a printf-like command (called
-.BR format )
-which can build arbitrarily complex strings.)
-.IP
-Characters are sent immediately although programs with line-buffered input
-will not read the characters until a return character is sent. A return
-character is denoted "\\r".
-
-The
-.B \-\-
-flag forces the next argument to be interpreted as a string rather than a flag.
-Any string can be preceded by "\-\-" whether or not it actually looks
-like a flag. This provides a reliable mechanism to specify variable strings
-without being tripped up by those that accidentally look like flags.
-(All strings starting with "-" are reserved for future options.)
-
-The
-.B \-i
-flag declares that the string be sent to the named spawn_id.
-If the spawn_id is
-.IR user_spawn_id ,
-and the terminal is in raw mode, newlines in the string are translated
-to return-newline
-sequences so that they appear as it the terminal was in cooked mode.
-The
-.B \-raw
-flag disables this translation.
-
-The
-.BR \-null
-flag sends null characters (0 bytes). By default, one null is sent.
-An integer may follow the
-.BR \-null
-to indicate how many nulls to send.
-
-The
-.B \-break
-flag generates a break condition. This only makes sense if the spawn
-id refers to a tty device opened via "spawn -open". If you have
-spawned a process such as tip, you should use tip's convention for
-generating a break.
-
-The
-.B \-s
-flag forces output to be sent "slowly", thus avoid the common situation
-where a computer outtypes an input buffer that was designed for a
-human who would never outtype the same buffer. This output is
-controlled by the value of the variable "send_slow" which takes a two
-element list. The first element is an integer that describes the
-number of bytes to send atomically. The second element is a real
-number that describes the number of seconds by which the atomic sends
-must be separated. For example, "set send_slow {10 .001}" would force
-"send \-s" to send strings with 1 millisecond in between each 10
-characters sent.
-
-The
-.B \-h
-flag forces output to be sent (somewhat) like a human actually typing.
-Human-like delays appear between the characters. (The algorithm is
-based upon a Weibull distribution, with modifications to suit this
-particular application.) This output is controlled by the value of
-the variable "send_human" which takes a five element list. The first
-two elements are average interarrival time of characters in seconds.
-The first is used by default. The second is used at word endings, to
-simulate the subtle pauses that occasionally occur at such
-transitions. The third parameter is a measure of variability where .1
-is quite variable, 1 is reasonably variable, and 10 is quite
-invariable. The extremes are 0 to infinity. The last two parameters
-are, respectively, a minimum and maximum interarrival time.
-The minimum and maximum are used last and "clip" the final time.
-The ultimate average can be quite different from the given average
-if the minimum and maximum clip enough values.
-
-As an
-example, the following command emulates a fast and
-consistent typist:
-.nf
-
- set send_human {.1 .3 1 .05 2}
- send \-h "I'm hungry. Let's do lunch."
-
-.fi
-while the following might be more suitable after a hangover:
-.nf
-
- set send_human {.4 .4 .2 .5 100}
- send \-h "Goodd party lash night!"
-
-.fi
-Note that errors are not simulated, although you can set up error
-correction situations yourself by embedding mistakes and corrections
-in a send argument.
-
-The flags for sending null characters, for sending breaks, for forcing slow
-output and for human-style output are mutually exclusive. Only the one
-specified last will be used. Furthermore, no
-.I string
-argument can be specified with the flags for sending null characters or breaks.
-
-It is a good idea to precede the first
-.B send
-to a process by an
-.BR expect .
-.B expect
-will wait for the process to start, while
-.B send
-cannot.
-In particular, if the first
-.B send
-completes before the process starts running,
-you run the risk of having your data ignored.
-In situations where interactive programs offer no initial prompt,
-you can precede
-.B send
-by a delay as in:
-.nf
-
- # To avoid giving hackers hints on how to break in,
- # this system does not prompt for an external password.
- # Wait for 5 seconds for exec to complete
- spawn telnet very.secure.gov
- sleep 5
- send password\\r
-
-.fi
-.B exp_send
-is an alias for
-.BI send .
-If you are using Expectk or some other variant of Expect in the Tk environment,
-.B send
-is defined by Tk for an entirely different purpose.
-.B exp_send
-is provided for compatibility between environments.
-Similar aliases are provided for other Expect's other send commands.
-.TP
-.BI send_error " [\-flags] string"
-is like
-.BR send ,
-except that the output is sent to stderr rather than the current
-process.
-.TP
-.BI send_log " [\--] string"
-is like
-.BR send ,
-except that the string is only sent to the log file (see
-.BR log_file .)
-The arguments are ignored if no log file is open.
-.TP
-.BI send_tty " [\-flags] string"
-is like
-.BR send ,
-except that the output is sent to /dev/tty rather than the current
-process.
-.TP
-.BI send_user " [\-flags] string"
-is like
-.BR send ,
-except that the output is sent to stdout rather than the current
-process.
-.TP
-.BI sleep " seconds"
-causes the script to sleep for the given number of seconds.
-Seconds may be a decimal number. Interrupts (and Tk events if you
-are using Expectk) are processed while Expect sleeps.
-.TP
-.BI spawn " [args] program [args]"
-creates a new process running
-.IR "program args" .
-Its stdin, stdout and stderr are connected to Expect,
-so that they may be read and written by other
-.B Expect
-commands.
-The connection is broken by
-.B close
-or if the process itself closes any of the file identifiers.
-.IP
-When a process is started by
-.BR spawn ,
-the variable
-.I spawn_id
-is set to a descriptor referring to that process.
-The process described by
-.I spawn_id
-is considered the
-.IR "current process" .
-.I spawn_id
-may be read or written, in effect providing job control.
-.IP
-.I user_spawn_id
-is a global variable containing a descriptor which refers to the user.
-For example, when
-.I spawn_id
-is set to this value,
-.B expect
-behaves like
-.BR expect_user .
-
-.I
-.I error_spawn_id
-is a global variable containing a descriptor which refers to the standard
-error.
-For example, when
-.I spawn_id
-is set to this value,
-.B send
-behaves like
-.BR send_error .
-.IP
-.I tty_spawn_id
-is a global variable containing a descriptor which refers to /dev/tty.
-If /dev/tty does not exist (such as in a cron, at, or batch script), then
-.I tty_spawn_id
-is not defined. This may be tested as:
-.nf
-
- if [info vars tty_spawn_id] {
- # /dev/tty exists
- } else {
- # /dev/tty doesn't exist
- # probably in cron, batch, or at script
- }
-
-.fi
-.IP
-.B spawn
-returns the UNIX process id. If no process is spawned, 0 is returned.
-The variable
-.I spawn_out(slave,name)
-is set to the name of the pty slave device.
-.IP
-By default,
-.B spawn
-echoes the command name and arguments. The
-.B \-noecho
-flag stops
-.B spawn
-from doing this.
-.IP
-The
-.B \-console
-flag causes console output to be redirected to the spawned process.
-This is not supported on all systems.
-
-Internally,
-.B spawn
-uses a pty, initialized the same way as the user's tty. This is further
-initialized so that all settings are "sane" (according to stty(1)).
-If the variable
-.I stty_init
-is defined, it is interpreted in the style of stty arguments
-as further configuration.
-For example, "set stty_init raw" will cause further spawned processes's
-terminals to start in raw mode.
-.B \-nottycopy
-skips the initialization based on the user's tty.
-.B \-nottyinit
-skips the "sane" initialization.
-.IP
-Normally,
-.B spawn
-takes little time to execute. If you notice spawn taking a
-significant amount of time, it is probably encountering ptys that are
-wedged. A number of tests are run on ptys to avoid entanglements with
-errant processes. (These take 10 seconds per wedged pty.) Running
-Expect with the
-.B \-d
-option will show if
-.B Expect
-is encountering many ptys in odd states. If you cannot kill
-the processes to which these ptys are attached, your only recourse may
-be to reboot.
-
-If
-.I program
-cannot be spawned successfully because exec(2) fails (e.g. when
-.I program
-doesn't exist), an error message will be returned by the next
-.B interact
-or
-.B expect
-command as if
-.I program
-had run and produced the error message as output.
-This behavior is a natural consequence of the implementation of
-.BR spawn .
-Internally, spawn forks, after which the spawned process has no
-way to communicate with the original
-.B Expect
-process except by communication
-via the spawn_id.
-
-The
-.B \-open
-flag causes the next argument to be interpreted as a Tcl file identifier
-(i.e., returned by
-.BR open .)
-The spawn id can then be used as if it were a spawned process. (The file
-identifier should no longer be used.)
-This lets you treat raw devices, files, and
-pipelines as spawned processes without using a pty. 0 is returned to
-indicate there is no associated process. When the connection to
-the spawned process is closed, so is the Tcl file identifier.
-The
-.B \-leaveopen
-flag is similar to
-.B \-open
-except that
-.B \-leaveopen
-causes the file identifier to be left open even after the spawn id is closed.
-
-The
-.B \-pty
-flag causes a pty to be opened but no process spawned. 0 is returned
-to indicate there is no associated process. Spawn_id is set as usual.
-
-The variable
-.I spawn_out(slave,fd)
-is set to a file identifier corresponding to the pty slave.
-It can be closed using "close -slave".
-
-The
-.B \-ignore
-flag names a signal to be ignored in the spawned process.
-Otherwise, signals get the default behavior.
-Signals are named as in the
-.B trap
-command, except that each signal requires a separate flag.
-.TP
-.BI strace " level"
-causes following statements to be printed before being executed.
-(Tcl's trace command traces variables.)
-.I level
-indicates how far down in the call stack to trace.
-For example,
-the following command runs
-.B Expect
-while tracing the first 4 levels of calls,
-but none below that.
-.nf
-
- expect \-c "strace 4" script.exp
-
-.fi
-
-The
-.B -info
-flag causes strace to return a description of the
-most recent non-info arguments given.
-.TP
-.BI stty " args"
-changes terminal modes similarly to the external stty command.
-
-By default, the controlling terminal is accessed. Other terminals can
-be accessed by appending "< /dev/tty..." to the command. (Note that
-the arguments should not be grouped into a single argument.)
-
-Requests for status return it as the result of the command. If no status
-is requested and the controlling terminal is accessed, the previous
-status of the raw and echo attributes are returned in a form which can
-later be used by the command.
-
-For example, the arguments
-.B raw
-or
-.B \-cooked
-put the terminal into raw mode.
-The arguments
-.B \-raw
-or
-.B cooked
-put the terminal into cooked mode.
-The arguments
-.B echo
-and
-.B \-echo
-put the terminal into echo and noecho mode respectively.
-.IP
-The following example illustrates how to temporarily disable echoing.
-This could be used in otherwise-automatic
-scripts to avoid embedding passwords in them.
-(See more discussion on this under EXPECT HINTS below.)
-.nf
-
- stty \-echo
- send_user "Password: "
- expect_user -re "(.*)\\n"
- set password $expect_out(1,string)
- stty echo
-
-.fi
-.TP
-.BI system " args"
-gives
-.I args
-to sh(1) as input,
-just as if it had been typed as a command from a terminal.
-.B Expect
-waits until the shell terminates.
-The return status from sh is handled the same way that
-.B exec
-handles its return status.
-.IP
-In contrast to
-.B exec
-which redirects stdin and stdout to the script,
-.B system
-performs no redirection
-(other than that indicated by the string itself).
-Thus, it is possible to use programs which must talk directly to /dev/tty.
-For the same reason, the results of
-.B system
-are not recorded in the log.
-.TP
-.BI timestamp " [args]"
-returns a timestamp.
-With no arguments, the number of
-seconds since the epoch is returned.
-
-The
-.B \-format
-flag introduces a string which is returned but with
-substitutions made according to the
-POSIX rules for strftime. For example %a is replaced by an abbreviated
-weekday name (i.e., Sat). Others are:
-.nf
- %a abbreviated weekday name
- %A full weekday name
- %b abbreviated month name
- %B full month name
- %c date-time as in: Wed Oct 6 11:45:56 1993
- %d day of the month (01-31)
- %H hour (00-23)
- %I hour (01-12)
- %j day (001-366)
- %m month (01-12)
- %M minute (00-59)
- %p am or pm
- %S second (00-61)
- %u day (1-7, Monday is first day of week)
- %U week (00-53, first Sunday is first day of week one)
- %V week (01-53, ISO 8601 style)
- %w day (0-6)
- %W week (00-53, first Monday is first day of week one)
- %x date-time as in: Wed Oct 6 1993
- %X time as in: 23:59:59
- %y year (00-99)
- %Y year as in: 1993
- %Z timezone (or nothing if not determinable)
- %% a bare percent sign
-
-.fi
-Other % specifications are undefined. Other characters will be passed
-through untouched. Only the C locale is supported.
-
-The
-.B \-seconds
-flag introduces a number of seconds since the epoch to be used as a source
-from which to format. Otherwise, the current time is used.
-
-The
-.B \-gmt
-flag forces timestamp output to use the GMT timezone. With no flag,
-the local timezone is used.
-.TP
-.BI trap " [[command] signals]"
-causes the given
-.I command
-to be executed upon future receipt of any of the given signals.
-The command is executed in the global scope.
-If
-.I command
-is absent, the signal action is returned.
-If
-.I command
-is the string SIG_IGN, the signals are ignored.
-If
-.I command
-is the string SIG_DFL, the signals are result to the system default.
-.I signals
-is either a single signal or a list of signals. Signals may be specified
-numerically or symbolically as per signal(3). The "SIG" prefix may be omitted.
-
-With no arguments (or the argument \-number),
-.B trap
-returns the signal number of the trap command currently being executed.
-
-The
-.B \-code
-flag uses the return code of the command in place of whatever code Tcl
-was about to return when the command originally started running.
-
-The
-.B \-interp
-flag causes the command to be evaluated using the interpreter
-active at the time the command started running
-rather than when the trap was declared.
-
-The
-.B \-name
-flag causes the
-.B trap
-command to return the signal name of the trap command currently being executed.
-
-The
-.B \-max
-flag causes the
-.B trap
-command to return the largest signal number that can be set.
-
-For example, the command "trap {send_user "Ouch!"} SIGINT" will print "Ouch!"
-each time the user presses ^C.
-
-By default, SIGINT (which can usually be generated by pressing ^C) and
-SIGTERM cause Expect to exit. This is due to the following trap, created
-by default when Expect starts.
-.nf
-
- trap exit {SIGINT SIGTERM}
-
-.fi
-If you use the -D flag to start the debugger, SIGINT is redefined
-to start the interactive debugger. This is due to the following trap:
-.nf
-
- trap {exp_debug 1} SIGINT
-
-.fi
-The debugger trap can be changed by setting the environment variable
-EXPECT_DEBUG_INIT to a new trap command.
-
-You can, of course, override both of these just by adding trap
-commands to your script. In particular, if you have your own "trap
-exit SIGINT", this will override the debugger trap. This is useful
-if you want to prevent users from getting to the debugger at all.
-
-If you want to define your own trap on SIGINT but still trap to the
-debugger when it is running, use:
-.nf
-
- if ![exp_debug] {trap mystuff SIGINT}
-
-.fi
-Alternatively, you can trap to the debugger using some other signal.
-
-.B trap
-will not let you override the action for SIGALRM as this is used internally
-to
-.BR Expect .
-The disconnect command sets SIGALRM to SIG_IGN (ignore). You can reenable
-this as long as you disable it during subsequent spawn commands.
-
-See signal(3) for more info.
-.TP
-.BI wait " [args]"
-delays until a spawned process (or
-the current process if none is named) terminates.
-.IP
-.B wait
-normally returns a list of four integers.
-The first integer is the pid of the process that was waited upon.
-The second integer is the corresponding spawn id.
-The third integer is -1 if an operating system error occurred, or 0 otherwise.
-If the third integer was 0, the fourth integer is the status returned by
-the spawned process. If the third integer was -1, the fourth integer is
-the value of errno set by the operating system. The global variable
-errorCode is also set.
-
-Additional elements may appear at the end of the return value from
-.BR wait .
-An optional fifth element identifies a class of information.
-Currently, the only possible value for this element is CHILDKILLED in
-which case the next two values are the C-style signal name and a short
-textual description.
-.IP
-The
-.B \-i
-flag declares the process to wait corresponding to the named spawn_id
-(NOT the process id).
-Inside a SIGCHLD handler,
-it is possible to wait for any spawned process by using the spawn id -1.
-
-The
-.B \-nowait
-flag causes the wait to return immediately with the indication of a
-successful wait. When the process exits (later), it will automatically
-disappear without the need for an explicit wait.
-
-The
-.B wait
-command may also be used wait for a forked process using the arguments
-"-i -1". Unlike its use with spawned processes, this command can be
-executed at any time. There is no control over which process is
-reaped. However, the return value can be checked for the process id.
-
-.SH LIBRARIES
-Expect automatically knows about two built-in libraries for Expect scripts.
-These are defined by the directories named in the variables
-exp_library and exp_exec_library. Both are meant to contain utility
-files that can be used by other scripts.
-
-exp_library contains architecture-independent files. exp_exec_library
-contains architecture-dependent files. Depending on your system, both
-directories may be totally empty. The existence of the file
-$exp_exec_library/cat-buffers describes whether your /bin/cat buffers
-by default.
-.SH PRETTY-PRINTING
-A vgrind definition is available for pretty-printing
-.B Expect
-scripts.
-Assuming the vgrind definition supplied with the
-.B Expect
-distribution is
-correctly installed, you can use it as:
-.nf
-
- vgrind \-lexpect file
-
-.fi
-.SH EXAMPLES
-It many not be apparent how to put everything together that the man page
-describes. I encourage you to read and try out the examples in
-the example directory of the
-.B Expect
-distribution.
-Some of them are real programs. Others are simply illustrative
-of certain techniques, and of course, a couple are just quick hacks.
-The INSTALL file has a quick overview of these programs.
-.PP
-The
-.B Expect
-papers (see SEE ALSO) are also useful. While some papers
-use syntax corresponding to earlier versions of Expect, the accompanying
-rationales are still valid and go into a lot more detail than this
-man page.
-.SH CAVEATS
-Extensions may collide with Expect's command names. For example,
-.B send
-is defined by Tk for an entirely different purpose.
-For this reason, most of the
-.B Expect
-commands are also available as "exp_XXXX".
-Commands and variables beginning with "exp", "inter", "spawn",
-and "timeout" do not have aliases.
-Use the extended command names if you need this compatibility between environments.
-
-.B Expect
-takes a rather liberal view of scoping.
-In particular, variables read by commands specific to the
-.B Expect
-program will be sought first from the local scope, and if not found, in the
-global scope. For example, this
-obviates the need to place "global timeout" in every
-procedure you write that uses
-.BR expect .
-On the other hand, variables written are always in the local scope (unless
-a "global" command has been issued). The most common problem this causes
-is when spawn is executed in a procedure. Outside the procedure,
-.I spawn_id
-no longer exists, so the spawned process is no longer accessible
-simply because of scoping. Add a "global spawn_id" to such a procedure.
-
-If you cannot enable the multispawning capability
-(i.e., your system supports neither select (BSD *.*), poll (SVR>2),
-nor something equivalent),
-.B Expect
-will only be able to control a single process at a time.
-In this case, do not attempt to set
-.IR spawn_id ,
-nor should you execute processes via exec while a spawned process
-is running. Furthermore, you will not be able to
-.B expect
-from multiple processes (including the user as one) at the same time.
-
-Terminal parameters can have a big effect on scripts. For example, if
-a script is written to look for echoing, it will misbehave if echoing
-is turned off. For this reason, Expect forces sane terminal
-parameters by default. Unfortunately, this can make things unpleasant
-for other programs. As an example, the emacs shell wants to change
-the "usual" mappings: newlines get mapped to newlines instead of
-carriage-return newlines, and echoing is disabled. This allows one to
-use emacs to edit the input line. Unfortunately, Expect cannot
-possibly guess this.
-
-You can request that Expect not override its default setting of
-terminal parameters, but you must then be very careful when writing
-scripts for such environments. In the case of emacs, avoid depending
-upon things like echoing and end-of-line mappings.
-
-The commands that accepted arguments braced into a single list (the
-.B expect
-variants and
-.BR interact )
-use a heuristic to decide if the list is actually one argument or many.
-The heuristic can fail only in the case when the list actually does
-represent a single argument which has multiple embedded \\n's with
-non-whitespace characters between them. This seems sufficiently improbable,
-however the argument "-brace" can be used to force a single argument
-to be handled as a single argument. This could conceivably be used
-with machine-generated Expect code.
-.SH BUGS
-It was really tempting to name the program "sex" (for either "Smart EXec"
-or "Send-EXpect"), but good sense (or perhaps just Puritanism) prevailed.
-
-On some systems, when a shell is spawned, it complains about not being
-able to access the tty but runs anyway. This means your system has a
-mechanism for gaining the controlling tty that
-.B Expect
-doesn't know about. Please find out what it is, and send this information
-back to me.
-
-Ultrix 4.1 (at least the latest versions around here) considers
-timeouts of above 1000000 to be equivalent to 0.
-
-Digital UNIX 4.0A (and probably other versions) refuses to allocate
-ptys if you define a SIGCHLD handler. See grantpt page for more info.
-
-IRIX 6.0 does not handle pty permissions correctly so that if Expect
-attempts to allocate a pty previously used by someone else, it fails.
-Upgrade to IRIX 6.1.
-
-Telnet (verified only under SunOS 4.1.2) hangs if TERM is not set.
-This is a problem under cron, at and in cgi scripts, which do not
-define TERM. Thus, you must set it explicitly - to what type is
-usually irrelevant. It just has to be set to something! The
-following probably suffices for most cases.
-.nf
-
- set env(TERM) vt100
-
-.fi
-
-Tip (verified only under BSDI BSD/OS 3.1 i386) hangs if SHELL and HOME
-are not set. This is a problem under cron, at and in cgi scripts,
-which do not define these environment variables. Thus, you must set
-them explicitly - to what type is usually irrelevant. It just has to
-be set to something! The following probably suffices for most cases.
-.nf
-
- set env(SHELL) /bin/sh
- set env(HOME) /usr/local/bin
-
-.fi
-
-
-Some implementations of ptys are designed so that the kernel throws
-away any unread output after 10 to 15 seconds (actual number is
-implementation-dependent) after the process has closed the file
-descriptor. Thus
-.B Expect
-programs such as
-.nf
-
- spawn date
- sleep 20
- expect
-
-.fi
-will fail. To avoid this, invoke non-interactive programs with
-.B exec
-rather than
-.BR spawn .
-While such situations are conceivable, in practice I have never
-encountered a situation in which the final output of a truly
-interactive program would be lost due to this behavior.
-
-On the other hand, Cray UNICOS ptys throw away any unread output
-immediately after the process has closed the file descriptor. I have
-reported this to Cray and they are working on a fix.
-
-Sometimes a delay is required between a prompt and a response, such as
-when a tty interface is changing UART settings or matching baud rates
-by looking for start/stop bits. Usually, all this is require is to
-sleep for a second or two. A more robust technique is to retry until
-the hardware is ready to receive input. The following example uses
-both strategies:
-.nf
-
- send "speed 9600\\r";
- sleep 1
- expect {
- timeout {send "\\r"; exp_continue}
- $prompt
- }
-
-.fi
-
-.SH EXPECT HINTS
-There are a couple of things about
-.B Expect
-that may be non-intuitive.
-This section attempts to address some of these things with a couple of
-suggestions.
-
-A common expect problem is how to recognize shell prompts. Since
-these are customized differently by differently people and different
-shells, portably automating rlogin can be difficult without knowing
-the prompt. A reasonable convention is to have users store a regular
-expression describing their prompt (in particular, the end of it) in
-the environment variable EXPECT_PROMPT. Code like the following
-can be used. If EXPECT_PROMPT doesn't exist, the code still has a good chance of functioning correctly.
-.nf
-
- set prompt "(%|#|\\\\$) $" ;# default prompt
- catch {set prompt $env(EXPECT_PROMPT)}
-
- expect -re $prompt
-
-.fi
-I encourage you to write
-.B expect
-patterns that include the end of whatever
-you expect to see. This avoids the possibility of answering a question
-before seeing the entire thing. In addition, while you may well be
-able to answer questions before seeing them entirely, if you answer
-early, your answer may appear echoed back in the middle of the question.
-In other words, the resulting dialogue will be correct but look scrambled.
-
-Most prompts include a space character at the end.
-For example, the prompt from ftp is 'f', 't', 'p', '>' and <blank>.
-To match this prompt, you must account for each of these characters.
-It is a common mistake not to include the blank.
-Put the blank in explicitly.
-
-If you use a pattern of the form X*, the * will match all the output
-received from the end of X to the last thing received.
-This sounds intuitive but can be somewhat confusing because the phrase
-"last thing received" can vary depending upon the speed of the computer
-and the processing of I/O both by the kernel and the device driver.
-.PP
-In particular, humans tend to see program output arriving in huge chunks
-(atomically) when in reality most programs produce output one
-line at a time. Assuming this is the case, the * in the pattern of the
-previous paragraph may only match the end of the current line even though
-there seems to be more, because at the time of the match that was all
-the output that had been received.
-.PP
-.B expect
-has no way of knowing that further output is coming unless your
-pattern specifically accounts for it.
-.PP
-Even depending on line-oriented buffering is unwise. Not only do programs
-rarely make promises about the type of buffering they do, but system
-indigestion can break output lines up so that lines break at seemingly
-random places. Thus, if you can express the last few characters
-of a prompt when writing patterns, it is wise to do so.
-
-If you are waiting for a pattern in the last output of a program
-and the program emits something else instead, you will not be able to
-detect that with the
-.B timeout
-keyword. The reason is that
-.B expect
-will not timeout \- instead it will get an
-.B eof
-indication.
-Use that instead. Even better, use both. That way if that line
-is ever moved around, you won't have to edit the line itself.
-
-Newlines are usually converted to carriage return, linefeed sequences
-when output by the terminal driver. Thus, if you want a pattern that
-explicitly matches the two lines, from, say, printf("foo\\nbar"),
-you should use the pattern "foo\\r\\nbar".
-.PP
-A similar translation occurs when reading from the user, via
-.BR expect_user .
-In this case, when you press return, it will be
-translated to a newline. If
-.B Expect
-then passes that to a program
-which sets its terminal to raw mode (like telnet), there is going to
-be a problem, as the program expects a true return. (Some programs
-are actually forgiving in that they will automatically translate
-newlines to returns, but most don't.) Unfortunately, there is no way to find
-out that a program put its terminal into raw mode.
-.PP
-Rather than manually replacing newlines with returns, the solution is to
-use the command "stty raw", which will stop the translation.
-Note, however, that this means that you will no longer get the cooked
-line-editing features.
-.PP
-.B interact
-implicitly sets your terminal to raw mode so this problem will not arise then.
-
-It is often useful to store passwords (or other private information)
-in
-.B Expect
-scripts. This is not recommended since anything that is
-stored on a computer is susceptible to being accessed by anyone.
-Thus, interactively prompting for passwords from a script is a smarter
-idea than embedding them literally. Nonetheless, sometimes such embedding
-is the only possibility.
-.PP
-Unfortunately, the UNIX file system has no direct way of creating
-scripts which are executable but unreadable. Systems which support
-setgid shell scripts may indirectly simulate this as follows:
-.PP
-Create the
-.B Expect
-script (that contains the secret data) as usual.
-Make its permissions be 750 (\-rwxr\-x\-\-\-) and owned by a trusted group,
-i.e., a group which is allowed to read it. If necessary, create a new
-group for this purpose. Next, create a /bin/sh script with
-permissions 2751 (\-rwxr\-s\-\-x) owned by the same group as before.
-.PP
-The result is a script which may be executed (and read) by anyone.
-When invoked, it runs the
-.B Expect
-script.
-.SH SEE ALSO
-.BR Tcl (3),
-.BR libexpect (3)
-.br
-.I
-"Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Programs"
-\fRby Don Libes, pp. 602, ISBN 1-56592-090-2, O'Reilly and Associates, 1995.
-.br
-.I
-"expect: Curing Those Uncontrollable Fits of Interactivity" \fRby Don Libes,
-Proceedings of the Summer 1990 USENIX Conference,
-Anaheim, California, June 11-15, 1990.
-.br
-.I
-"Using
-.B expect
-to Automate System Administration Tasks" \fRby Don Libes,
-Proceedings of the 1990 USENIX Large Installation Systems Administration
-Conference, Colorado Springs, Colorado, October 17-19, 1990.
-.br
-.I
-"Tcl: An Embeddable Command Language" \fRby John Ousterhout,
-Proceedings of the Winter 1990 USENIX Conference,
-Washington, D.C., January 22-26, 1990.
-.br
-.I
-"expect: Scripts for Controlling Interactive Programs" \fRby Don Libes,
-Computing Systems, Vol. 4, No. 2, University of California Press Journals,
-November 1991.
-.br
-.I
-"Regression Testing and Conformance Testing Interactive Programs", \fRby Don
-Libes, Proceedings of the Summer 1992 USENIX Conference, pp. 135-144,
-San Antonio, TX, June 12-15, 1992.
-.br
-.I
-"Kibitz \- Connecting Multiple Interactive Programs Together", \fRby Don Libes,
-Software \- Practice & Experience, John Wiley & Sons, West Sussex, England,
-Vol. 23, No. 5, May, 1993.
-.br
-.I
-"A Debugger for Tcl Applications", \fRby Don Libes,
-Proceedings of the 1993 Tcl/Tk Workshop, Berkeley, CA, June 10-11, 1993.
-.SH AUTHOR
-Don Libes, National Institute of Standards and Technology
-.SH ACKNOWLEDGMENTS
-Thanks to John Ousterhout for Tcl, and Scott Paisley for inspiration.
-Thanks to Rob Savoye for Expect's autoconfiguration code.
-.PP
-The HISTORY file documents much of the evolution of
-.BR expect .
-It makes interesting reading and might give you further insight to this
-software. Thanks to the people mentioned in it who sent me bug fixes
-and gave other assistance.
-.PP
-Design and implementation of
-.B Expect
-was paid for in part by the U.S. government and is therefore in the public
-domain.
-However the author and NIST would like credit
-if this program and documentation or portions of them are used.
+++ /dev/null
-/*
- * Check for headers
- */
-#ifndef __EXPECT_CF_H__
-#define __EXPECT_CF_H__
-
-#undef NO_STDLIB_H /* Tcl requires this name */
-#undef HAVE_STDARG_H
-#undef HAVE_VARARGS_H
-#undef HAVE_STROPTS_H
-#undef HAVE_SYSCONF_H
-#undef HAVE_SYS_FCNTL_H
-#undef HAVE_SYS_WAIT_H
-#undef HAVE_SYS_BSDTYPES_H /* nice ISC special */
-#undef HAVE_SYS_SELECT_H /* nice ISC special */
-#undef HAVE_SYS_TIME_H /* nice ISC special */
-#undef HAVE_SYS_PTEM_H /* SCO needs this for window size */
-#undef HAVE_STRREDIR_H /* Solaris needs this for console redir */
-#undef HAVE_STRPTY_H /* old-style Dynix ptys need this */
-#undef HAVE_UNISTD_H
-#undef HAVE_SYSMACROS_H
-#undef HAVE_INTTYPES_H
-#undef HAVE_TIOCGWINSZ_IN_TERMIOS_H
-#undef HAVE_TCGETS_OR_TCGETA_IN_TERMIOS_H
-
-#undef pid_t
-#undef RETSIGTYPE
-#undef TIME_WITH_SYS_TIME /* ok to include both time.h and sys/time.h */
-
-/*
- * This section is for compile macros needed by
- * everything else.
- */
-
-/*
- * Check for functions
- */
-#undef HAVE_MEMCPY
-#undef HAVE_SYSCONF
-#undef SIMPLE_EVENT
-#undef HAVE_STRFTIME
-#undef HAVE_MEMMOVE
-#undef HAVE_TIMEZONE /* timezone() a la Pyramid */
-#undef HAVE_STRCHR
-
-#ifndef HAVE_STRCHR
-#define strchr(s,c) index(s,c)
-#endif /* HAVE_STRCHR */
-
-/*
- * timezone
- */
-#undef HAVE_SV_TIMEZONE
-
-/*
- * wait status type
- */
-#undef NO_UNION_WAIT
-
-#undef WNOHANG_REQUIRES_POSIX_SOURCE
-
-/*
- * Signal stuff. Setup the return type
- * and if signals need to be re-armed.
- */
-/*#ifndef RETSIGTYPE*/
-/*#define RETSIGTYPE void*/
-/*#endif*/
-#undef REARM_SIG
-
-/*
- * Generate correct type for select mask
- */
-#ifndef SELECT_MASK_TYPE
-#define SELECT_MASK_TYPE fd_set
-#endif
-
-/*
- * Check how stty works
- */
-#undef STTY_READS_STDOUT
-
-/*
- * Check for tty/pty functions and structures
- */
-#undef POSIX
-#undef HAVE_TCSETATTR
-#undef HAVE_TERMIO
-#undef HAVE_TERMIOS
-#undef HAVE_SGTTYB
-#undef HAVE__GETPTY
-#undef HAVE_GETPTY
-#undef HAVE_OPENPTY
-#undef HAVE_PTC
-#undef HAVE_PTC_PTS
-#undef HAVE_PTYM
-#undef HAVE_PTYTRAP
-#undef HAVE_PTMX
-#undef HAVE_PTMX_BSD
-#undef HAVE_SCO_CLIST_PTYS
-
-/*
- * Special hacks
- */
-#undef CONVEX
-#undef SOLARIS
-#undef _XOPEN_SOURCE
-
-#ifdef SOLARIS
-#define __EXTENSIONS__
-#endif /* SOLARIS */
-
-#undef WNOHANG_BACKUP_VALUE
-
-#endif /* __EXPECT_CF_H__ */
+++ /dev/null
-/* expectcomm.h - public symbols common to both expect.h and expect_tcl.h
-
-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.
-*/
-
-#ifndef _EXPECT_COMM_H
-#define _EXPECT_COMM_H
-
-#if 0
-#include "expect_cf.h"
-#endif
-
-#include <stdio.h>
-#include <setjmp.h>
-
-/* since it's possible that the caller may include tcl.h before including
- this file, we cannot include varargs/stdargs ourselves */
-
-/* Much of the following stdarg/prototype support is taken from tcl.h
- * (7.5) with modifications. What's going on here is that don't want
- * to simply include tcl.h everywhere, because one of the files is the
- * Tcl-less Expect library.)
- */
-
-
-/* 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. */
-
-/* in Tcl 7.5, Tcl now supplies these definitions */
-#if !defined(TCL_VARARGS)
-# if defined(__STDC__) || defined(HAVE_STDARG_H)
-# include <stdarg.h>
-# 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)
-# else
-# include <varargs.h>
-# ifdef __cplusplus
-# define TCL_VARARGS(type, name) (type name, ...)
-# define TCL_VARARGS_DEF(type, name) (type va_alist, ...)
-# else
-# define TCL_VARARGS(type, name) ()
-# define TCL_VARARGS_DEF(type, name) (va_alist)
-# endif
-# define TCL_VARARGS_START(type, name, list) \
- (va_start(list), va_arg(list, type))
-# endif /* use stdarg.h */
-
-/*
- * Definitions that allow this header file to be used either with or
- * without ANSI C features like function prototypes.
- */
-
-# undef _ANSI_ARGS_
-# undef CONST
-
-# if ((defined(__STDC__) || defined(SABER)) && !defined(NO_PROTOTYPE)) || defined(__cplusplus) || defined(USE_PROTOTYPE)
-# define _USING_PROTOTYPES_ 1
-# define _ANSI_ARGS_(x) x
-# define CONST const
-# else
-# define _ANSI_ARGS_(x) ()
-# define CONST
-# endif
-
-# ifdef __cplusplus
-# define EXTERN extern "C"
-# else
-# define EXTERN extern
-# endif
-
-#endif /* defined(TCL_VARARGS) */
-
-/* Arghhh! Tcl pulls in all of tcl.h in order to get the regexp funcs */
-/* Tcl offers us a way to avoid this: temporarily define _TCL. Here goes: */
-
-#ifdef EXP_AVOID_INCLUDING_TCL_H
-# ifdef _TCL
-# define EXP__TCL_WAS_DEFINED
-# else
-# define _TCL
-# endif
-#endif
-
-#include "tcl_regexp.h"
-
-/* clean up the mess */
-#ifdef EXP_AVOID_INCLUDING_TCL_H
-# ifdef EXP__TCL_WAS_DEFINED
-# undef EXP__TCL_WAS_DEFINED
-# else
-# undef _TCL
-# endif
-#endif
-
-#if 0
-/* moved to exp_int.h so expect_cf.h no longer needs to be installed */
-#ifdef NO_STDLIB_H
-# include "../compat/stdlib.h"
-#else
-# include <stdlib.h> /* for malloc */
-#endif /*NO_STDLIB_H*/
-#endif
-
-/* common return codes for Expect functions */
-/* The library actually only uses TIMEOUT and EOF */
-#define EXP_ABEOF -1 /* abnormal eof in Expect */
- /* when in library, this define is not used. */
- /* Instead "-1" is used literally in the */
- /* usual sense to check errors in system */
- /* calls */
-#define EXP_TIMEOUT -2
-#define EXP_TCLERROR -3
-#define EXP_FULLBUFFER -5
-#define EXP_MATCH -6
-#define EXP_NOMATCH -7
-#define EXP_CANTMATCH EXP_NOMATCH
-#define EXP_CANMATCH -8
-#define EXP_DATA_NEW -9 /* if select says there is new data */
-#define EXP_DATA_OLD -10 /* if we already read data in another cmd */
-#define EXP_EOF -11
-#define EXP_RECONFIGURE -12 /* changes to indirect spawn id lists */
- /* require us to reconfigure things */
-
-/* in the unlikely event that a signal handler forces us to return this */
-/* through expect's read() routine, we temporarily convert it to this. */
-#define EXP_TCLRET -20
-#define EXP_TCLCNT -21
-#define EXP_TCLCNTTIMER -22
-#define EXP_TCLBRK -23
-#define EXP_TCLCNTEXP -24
-#define EXP_TCLRETTCL -25
-
-/* yet more TCL return codes */
-/* Tcl does not safely provide a way to define the values of these, so */
-/* use ridiculously numbers for safety */
-#define EXP_CONTINUE -101 /* continue expect command */
- /* and restart timer */
-#define EXP_CONTINUE_TIMER -102 /* continue expect command */
- /* and continue timer */
-#define EXP_TCL_RETURN -103 /* converted by interact */
- /* and interpeter from */
- /* inter_return into */
- /* TCL_RETURN*/
-
-#define EXP_TIME_INFINITY -1
-#define EXP_SPAWN_ID_BAD -1
-
-EXTERN int exp_is_debugging;
-EXTERN int exp_loguser;
-EXTERN int exp_disconnected; /* proc. disc'd from controlling tty */
-
-EXTERN void (*exp_close_in_child)(); /* procedure to close files in child */
-EXTERN void exp_close_tcl_files(); /* deflt proc: close all Tcl's files */
-
-EXTERN void exp_slave_control _ANSI_ARGS_((int,int));
-
-EXTERN char *exp_pty_error; /* place to pass a string generated */
- /* deep in the innards of the pty */
- /* code but needed by anyone */
-
-#endif /* _EXPECT_COMM_H */
+++ /dev/null
-/* expect_tcl.h - include file for using the expect library, libexpect.a
-with Tcl (and optionally Tk)
-
-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.
-
-*/
-
-#ifndef _EXPECT_TCL_H
-#define _EXPECT_TCL_H
-
-#include "expect_comm.h"
-
-EXTERN int exp_cmdlinecmds;
-EXTERN int exp_interactive;
-EXTERN FILE *exp_cmdfile;
-EXTERN char *exp_cmdfilename;
-EXTERN int exp_getpid; /* pid of Expect itself */
-EXTERN int exp_buffer_command_input;
-
-EXTERN int exp_tcl_debugger_available;
-
-EXTERN Tcl_Interp *exp_interp;
-
-#define Exp_Init Expect_Init
-EXTERN int Expect_Init _ANSI_ARGS_((Tcl_Interp *)); /* for Tcl_AppInit apps */
-EXTERN void exp_parse_argv _ANSI_ARGS_((Tcl_Interp *,int argc,char **argv));
-EXTERN int exp_interpreter _ANSI_ARGS_((Tcl_Interp *));
-EXTERN int exp_interpret_cmdfile _ANSI_ARGS_((Tcl_Interp *,FILE *));
-EXTERN int exp_interpret_cmdfilename _ANSI_ARGS_((Tcl_Interp *,char *));
-EXTERN void exp_interpret_rcfiles _ANSI_ARGS_((Tcl_Interp *,int my_rc,int sys_rc));
-
-EXTERN char * exp_cook _ANSI_ARGS_((char *s,int *len));
-
-EXTERN void exp_close_on_exec _ANSI_ARGS_((int));
-
- /* app-specific exit handler */
-EXTERN void (*exp_app_exit)_ANSI_ARGS_((Tcl_Interp *));
-EXTERN void exp_exit _ANSI_ARGS_((Tcl_Interp *,int status));
-EXTERN void exp_exit_handlers _ANSI_ARGS_((ClientData));
-
-EXTERN void exp_error _ANSI_ARGS_(TCL_VARARGS(Tcl_Interp *,interp));
-
-#endif /* _EXPECT_TCL_H */
+++ /dev/null
-.TH EXPECTK 1 "15 February 1993"
-.SH NAME
-expectk \- Expect with Tk support
-.SH SYNOPSIS
-.B expectk
-[
-.I args
-]
-.SH INTRODUCTION
-.B Expectk
-is a combination of Expect with Tk. (See their respective man pages for a more comprehensive explanation
-of either.)
-.B Expectk
-should run any
-.B wish
-or
-.B Expect
-script (with minor changes - see below).
-.PP
-The differences between the Expectk and Expect environment follows.
-.PP
-The
-.B send
-command is Tk's. Expect's
-.B send
-command can be invoked by the name
-.BR exp_send .
-(For compatibility, Expect allows either
-.B send
-or
-.B exp_send
-to be used.)
-.PP
-Scripts may be invoked implicitly on systems which support the #! notation
-by marking the script executable, and making the first line in your script:
-
- #!/usr/local/bin/expectk \-f
-
-Of course, the path must accurately describe where
-.B Expectk
-lives. /usr/local/bin is just an example.
-
+++ /dev/null
-#!expect --
-# Synopsis: fixcat
-# Author: Don Libes
-
-# Description: test to see if /bin/cat is unbuffered (i.e., -u is needed)
-# Return 0 if buffered, 1 if unbuffered.
-#
-# If this file is sitting in an architecture-specific library directory,
-# then it serves as a marker that your /bin/cat buffers by default.
-
-# test for when catting to/from files
-log_user 0
-spawn -open [open "|cat" "r+"]
-send "\r"
-expect "\r" {exit 1}
-
-# test for when catting to real tty
-#log_user 0
-#spawn /bin/cat
-#send "\r"
-#expect "\r\n\r\n" {exit 1}
+++ /dev/null
-#!expect --
-# Synopsis: fixline1 newpath < input > output
-# Author: Don Libes
-
-# Description: change first line of script to reflect new binary
-# try to match any of the following first lines
-#!expect ...
-#!../expect ...
-#!expectk ...
-#!foo/bar/expectk ...
-#
-regsub "^#!(.*/)*(.*)" [gets stdin] "#!$argv/\\2" line1
-puts -nonewline "$line1\n[read stdin]"
+++ /dev/null
-#!/bin/sh
-#
-# install - install a program, script, or datafile
-# This comes from X11R5.
-#
-# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
-# when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch.
-#
-
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
-
-
-# put in absolute paths if you don't have them in your path; or use env. vars.
-
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
-
-transformbasename=""
-transform_arg=""
-instcmd="$mvprog"
-chmodcmd="$chmodprog 0755"
-chowncmd=""
-chgrpcmd=""
-stripcmd=""
-rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-src=""
-dst=""
-dir_arg=""
-
-while [ x"$1" != x ]; do
- case $1 in
- -c) instcmd="$cpprog"
- shift
- continue;;
-
- -d) dir_arg=true
- shift
- continue;;
-
- -m) chmodcmd="$chmodprog $2"
- shift
- shift
- continue;;
-
- -o) chowncmd="$chownprog $2"
- shift
- shift
- continue;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift
- shift
- continue;;
-
- -s) stripcmd="$stripprog"
- shift
- continue;;
-
- -t=*) transformarg=`echo $1 | sed 's/-t=//'`
- shift
- continue;;
-
- -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
- shift
- continue;;
-
- *) if [ x"$src" = x ]
- then
- src=$1
- else
- # this colon is to work around a 386BSD /bin/sh bug
- :
- dst=$1
- fi
- shift
- continue;;
- esac
-done
-
-if [ x"$src" = x ]
-then
- echo "install: no input file specified"
- exit 1
-else
- true
-fi
-
-if [ x"$dir_arg" != x ]; then
- dst=$src
- src=""
-
- if [ -d $dst ]; then
- instcmd=:
- else
- instcmd=mkdir
- fi
-else
-
-# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad
-# if $src (and thus $dsttmp) contains '*'.
-
- if [ -f $src -o -d $src ]
- then
- true
- else
- echo "install: $src does not exist"
- exit 1
- fi
-
- if [ x"$dst" = x ]
- then
- echo "install: no destination specified"
- exit 1
- else
- true
- fi
-
-# If destination is a directory, append the input filename; if your system
-# does not like double slashes in filenames, you may need to add some logic
-
- if [ -d $dst ]
- then
- dst="$dst"/`basename $src`
- else
- true
- fi
-fi
-
-## this sed command emulates the dirname command
-dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
-
-# Make sure that the destination directory exists.
-# this part is taken from Noah Friedman's mkinstalldirs script
-
-# Skip lots of stat calls in the usual case.
-if [ ! -d "$dstdir" ]; then
-defaultIFS='
-'
-IFS="${IFS-${defaultIFS}}"
-
-oIFS="${IFS}"
-# Some sh's can't handle IFS=/ for some reason.
-IFS='%'
-set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
-IFS="${oIFS}"
-
-pathcomp=''
-
-while [ $# -ne 0 ] ; do
- pathcomp="${pathcomp}${1}"
- shift
-
- if [ ! -d "${pathcomp}" ] ;
- then
- $mkdirprog "${pathcomp}"
- else
- true
- fi
-
- pathcomp="${pathcomp}/"
-done
-fi
-
-if [ x"$dir_arg" != x ]
-then
- $doit $instcmd $dst &&
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
-else
-
-# If we're going to rename the final executable, determine the name now.
-
- if [ x"$transformarg" = x ]
- then
- dstfile=`basename $dst`
- else
- dstfile=`basename $dst $transformbasename |
- sed $transformarg`$transformbasename
- fi
-
-# don't allow the sed command to completely eliminate the filename
-
- if [ x"$dstfile" = x ]
- then
- dstfile=`basename $dst`
- else
- true
- fi
-
-# Make a temp file name in the proper directory.
-
- dsttmp=$dstdir/#inst.$$#
-
-# Move or copy the file name to the temp name
-
- $doit $instcmd $src $dsttmp &&
-
- trap "rm -f ${dsttmp}" 0 &&
-
-# and set any options; do chmod last to preserve setuid bits
-
-# If any of these fail, we abort the whole thing. If we want to
-# ignore errors from any of these, just make sure not to ignore
-# errors from the above "$doit $instcmd $src $dsttmp" command.
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
-
-# Now rename the file to the real destination.
-
- $doit $rmcmd -f $dstdir/$dstfile &&
- $doit $mvcmd $dsttmp $dstdir/$dstfile
-
-fi &&
-
-
-exit 0
+++ /dev/null
-.TH LIBEXPECT 3 "12 December 1991"
-.SH NAME
-libexpect \- programmed dialogue with interactive programs \- C functions
-.SH DESCRIPTION
-This library contains functions that allow Expect to be used as
-a Tcl extension or to be used directly from C or C++ (without Tcl).
-Adding Expect as a Tcl extension is very short and simple, so that will be
-covered first.
-.SH SYNOPSIS
-.nf
-
-.B #include "expect_tcl.h"
-.B Expect_Init(interp);
-
-.B cc files... \-lexpect5.20 \-ltcl7.5 \-lm
-
-.fi
-Note: library versions may differ in the actual release.
-
-The Expect_Init function adds expect commands to the named
-interpreter. It avoids overwriting commands that already exist,
-however aliases beginning with "exp_" are always created for expect
-commands. So for example, "send" can be used as "exp_send".
-
-Generally, you should only call Expect commands via Tcl_Eval.
-Certain auxiliary functions may be called directly. They are summarized
-below. They may be useful in constructing your own main. Look
-at the file exp_main_exp.c in the Expect distribution as
-a prototype main. Another prototype is tclAppInit.c in the
-Tcl source distribution. A prototype for working with Tk is in
-exp_main_tk.c in the Expect distribution.
-.nf
-
-int exp_cmdlinecmds;
-int exp_interactive;
-FILE *exp_cmdfile;
-char *exp_cmdfilename;
-int exp_tcl_debugger_available;
-
-void exp_parse_argv(Tcl_Interp *,int argc,char **argv);
-int exp_interpreter(Tcl_Interp *);
-void exp_interpret_cmdfile(Tcl_Interp *,FILE *);
-void exp_interpret_cmdfilename(Tcl_Interp *,char *);
-void exp_interpret_rcfiles(Tcl_Interp *,int my_rc,int sys_rc);
-char * exp_cook(char *s,int *len);
-void (*exp_app_exit)EXP_PROTO((Tcl_Interp *);
-void exp_exit(Tcl_Interp *,int status);
-void exp_exit_handlers(Tcl_Interp *);
-void exp_error(Tcl_Interp,char *,...);
-
-.fi
-.B exp_cmdlinecmds
-is 1 if Expect has been invoked with commands on the program command-line (using "-c" for example).
-.B exp_interactive
-is 1 if Expect has been invoked with the -i flag or if no commands or script is being invoked.
-.B exp_cmdfile
-is a stream from which Expect will read commands.
-.B exp_cmdfilename
-is the name of a file which Expect will open and read commands from.
-.B exp_tcl_debugger_available
-is 1 if the debugger has been armed.
-
-.B exp_parse_argv
-reads the representation of the command line.
-Based on what is found, any of the other variables listed here
-are initialized appropriately.
-.B exp_interpreter
-interactively prompts the user for commands and evaluates them.
-.B exp_interpret_cmdfile
-reads the given stream and evaluates any commands found.
-.B exp_interpret_cmdfilename
-opens the named file and evaluates any commands found.
-.B exp_interpret_rcfiles
-reads and evalutes the .rc files. If my_rc is zero,
-then ~/.expectrc is skipped. If sys_rc is zero, then the system-wide
-expectrc file is skipped.
-.B exp_cook
-returns a static buffer containing the argument reproduced with
-newlines replaced by carriage-return linefeed sequences.
-The primary purpose of this is to allow messages to be produced
-without worrying about whether the terminal is in raw mode or
-cooked mode.
-If length is zero, it is computed via strlen.
-.B exp_error is a printf-like function that writes the result
-to interp->result.
-.SH SYNOPSIS
-.nf
-.B #include <expect.h>
-
-.B int
-.B "exp_spawnl(file, arg0 [, arg1, ..., argn] (char *)0);"
-.B char *file;
-.B char *arg0, *arg1, ... *argn;
-
-.B int
-.B exp_spawnv(file,argv);
-.B char *file, *argv[ ];
-
-.B int
-.B exp_spawnfd(fd);
-.B int fd;
-
-.B FILE *
-.B exp_popen(command);
-.B char *command;
-
-.B extern int exp_pid;
-.B extern int exp_ttyinit;
-.B extern int exp_ttycopy;
-.B extern int exp_console;
-.B extern char *exp_stty_init;
-.B extern void (*exp_close_in_child)();
-.B extern void (*exp_child_exec_prelude)();
-.B extern void exp_close_tcl_files();
-
-.B cc files... \-lexpect \-ltcl \-lm
-.fi
-
-.SH DESCRIPTION
-.B exp_spawnl
-and
-.B exp_spawnv
-fork a new process so that its stdin,
-stdout, and stderr can be written and read by the current process.
-.I file
-is the name of a file to be executed. The
-.I arg
-pointers are
-null-terminated strings. Following the style of execve(),
-.I arg0
-(or
-.IR argv[0] )
-is customarily a duplicate of the name of the file.
-.PP
-Four interfaces are available,
-.B exp_spawnl
-is useful when the number of
-arguments is known at compile time.
-.B exp_spawnv
-is useful when the number of arguments is not known at compile time.
-.B exp_spawnfd
-is useful when an open file descriptor is already available as a source.
-.B exp_popen
-is explained later on.
-.PP
-If the process is successfully created, a file descriptor is returned
-which corresponds to the process's stdin, stdout and stderr.
-A stream may be associated with the file descriptor by using fdopen().
-(This should almost certainly be followed by setbuf() to unbuffer the I/O.)
-.PP
-Closing the file descriptor will typically be detected by the
-process as an EOF. Once such a process exits, it should be waited
-upon (via wait) in order to free up the kernel process slot. (Some systems
-allow you to avoid this if you ignore the SIGCHLD signal).
-.PP
-.B exp_popen
-is yet another interface, styled after popen(). It takes a Bourne
-shell command line, and returns a stream that corresponds to the process's
-stdin, stdout and stderr. The actual implementation of
-.B exp_popen
-below demonstrates
-.BR exp_spawnl .
-.nf
-
-FILE *
-exp_popen(program)
-char *program;
-{
- FILE *fp;
- int ec;
-
- if (0 > (ec = exp_spawnl("sh","sh","-c",program,(char *)0)))
- return(0);
- if (NULL == (fp = fdopen(ec,"r+")) return(0);
- setbuf(fp,(char *)0);
- return(fp);
-}
-.fi
-
-After a process is started, the variable
-.B exp_pid
-is set to the process-id of the new process. The variable
-.B exp_pty_slave_name
-is set to the name of the slave side of the pty.
-
-The spawn functions uses a pty to communicate with the process. By
-default, the pty is initialized the same way as the user's tty (if
-possible, i.e., if the environment has a controlling terminal.) This
-initialization can be skipped by setting exp_ttycopy to 0.
-
-The pty is further initialized to some system wide defaults if
-exp_ttyinit is non-zero. The default is generally comparable to "stty sane".
-
-The tty setting can be further modified by setting the variable
-.BR exp_stty_init .
-This variable is interpreted in the style of stty arguments. For
-example, exp_stty_init = "sane"; repeats the default initialization.
-
-On some systems, it is possible to redirect console output to ptys.
-If this is supported, you can force the next spawn to obtain the
-console output by setting the variable
-.B exp_console
-to 1.
-
-Between the time a process is started and the new program is given
-control, the spawn functions can clean up the environment by closing
-file descriptors. By default, the only file descriptors closed are
-ones internal to Expect and any marked "close-on-exec".
-
-If needed, you can close additional file descriptors by creating
-an appropriate function and assigning it to exp_close_in_child.
-The function will be called after the fork and before the exec.
-(This also modifies the behavior of the spawn command in Expect.)
-
-If you are also using Tcl, it may be convenient to use the function
-exp_close_tcl_files which closes all files between the default
-standard file descriptors and the highest descriptor known to Tcl.
-(Expect does this.)
-
-The function exp_child_exec_prelude is the last function called prior
-to the actual exec in the child. You can redefine this for effects
-such as manipulating the uid or the signals.
-
-.SH "IF YOU WANT TO ALLOCATE YOUR OWN PTY"
-.nf
-
-.B extern int exp_autoallocpty;
-.B extern int exp_pty[2];
-.fi
-
-The spawn functions use a pty to communicate with the process. By
-default, a pty is automatically allocated each time a process is spawned.
-If you want to allocate ptys yourself, before calling one of the spawn
-functions, set
-.B exp_autoallocpty
-to 0,
-.B exp_pty[0]
-to the master pty file descriptor and
-.B exp_pty[1]
-to the slave pty file descriptor.
-The expect library will not do any pty initializations (e.g., exp_stty_init will not be used).
-The slave pty file descriptor will be
-automatically closed when the process is spawned. After the process is
-started, all further communication takes place with the master pty file
-descriptor.
-.PP
-.B exp_spawnl
-and
-.B exp_spawnv
-duplicate the shell's actions
-in searching for an executable file in a list of directories. The
-directory list is obtained from the environment.
-.SH EXPECT PROCESSING
-While it is possible to use read() to read information from a process
-spawned by
-.B exp_spawnl
-or
-.BR exp_spawnv ,
-more convenient functions are provided. They are as
-follows:
-.nf
-
-.B int
-.B exp_expectl(fd,type1,pattern1,[re1,],value1,type2,...,exp_end);
-.B int fd;
-.B enum exp_type type;
-.B char *pattern1, *pattern2, ...;
-.B regexp *re1, *re2, ...;
-.B int value1, value2, ...;
-.B
-
-.B int
-.B exp_fexpectl(fp,type1,pattern1,[re1,]value1,type2,...,exp_end);
-.B FILE *fp;
-.B enum exp_type type;
-.B char *pattern1, *pattern2, ...;
-.B regexp *re1, *re2, ...;
-.B int value1, value2, ...;
-
-.B enum exp_type {
-.B exp_end,
-.B exp_glob,
-.B exp_exact,
-.B exp_regexp,
-.B exp_compiled,
-.B exp_null,
-.B };
-
-.B struct exp_case {
-.B char *pattern;
-.B regexp *re;
-.B enum exp_type type;
-.B int value;
-.B };
-
-.B int
-.B exp_expectv(fd,cases);
-.B int fd;
-.B struct exp_case *cases;
-
-.B int
-.B exp_fexpectv(fp,cases);
-.B FILE *fp;
-.B struct exp_case *cases;
-
-.B extern int exp_timeout;
-.B extern char *exp_match;
-.B extern char *exp_match_end;
-.B extern char *exp_buffer;
-.B extern char *exp_buffer_end;
-.B extern int exp_match_max;
-.B extern int exp_full_buffer;
-.B extern int exp_remove_nulls;
-.fi
-
-The functions wait until the output from a process matches one of the
-patterns, a specified time period has passed, or an EOF is seen.
-.PP
-The first argument to each function is either a file descriptor or a stream.
-Successive sets of arguments describe patterns and associated integer values
-to return when the pattern matches.
-.PP
-The type argument is one of four values. exp_end indicates that no more
-patterns appear.
-exp_glob indicates that the pattern is a glob-style string pattern.
-exp_exact indicates that the pattern is an exact string.
-exp_regexp indicates that the pattern is a regexp-style string pattern.
-exp_compiled indicates that the pattern is a regexp-style string pattern,
-and that its compiled form is also provided.
-exp_null indicates that the pattern is a null (for debugging purposes,
-a string pattern must also follow).
-.PP
-If the compiled form is not provided with the functions
-.B exp_expectl
-and
-.BR exp_fexpectl ,
-any pattern compilation done internally is
-thrown away after the function returns. The functions
-.B exp_expectv
-and
-.B exp_fexpectv
-will automatically compile patterns and will not throw them away.
-Instead, they must be discarded by the user, by calling free on each
-pattern. It is only necessary to discard them, the last time the
-cases are used.
-.PP
-Regexp subpatterns matched are stored in the compiled regexp.
-Assuming "re" contains a compiled regexp, the matched string can be
-found in re->startp[0]. The match substrings (according to the parentheses)
-in the original pattern can be found in re->startp[1], re->startp[2], and
-so on, up to re->startp[9]. The corresponding strings ends are re->endp[x]
-where x is that same index as for the string start.
-
-The type exp_null matches if a null appears in the input. The
-variable exp_remove_nulls must be set to 0 to prevent nulls from
-being automatically stripped. By default, exp_remove_nulls is set
-to 1 and nulls are automatically stripped.
-
-.B exp_expectv
-and
-.B exp_fexpectv
-are useful when the number of patterns is
-not known in advance. In this case, the sets are provided in an array.
-The end of the array is denoted by a struct exp_case with type exp_end.
-For the rest
-of this discussion, these functions will be referred to generically as
-.IR expect.
-.PP
-If a pattern matches, then the corresponding integer value is returned.
-Values need not be unique, however they should be positive to avoid
-being mistaken for EXP_EOF, EXP_TIMEOUT, or EXP_FULLBUFFER.
-Upon EOF or timeout, the value
-.B EXP_EOF
-or
-.B EXP_TIMEOUT
-is returned. The
-default timeout period is 10 seconds but may be changed by setting the
-variable
-.BR exp_timeout .
-A value of -1
-disables a timeout from occurring.
-A value of 0 causes the expect function to return immediately (i.e., poll)
-after one read().
-However it must be preceded by a function such as select, poll, or
-an event manager callback to guarantee that there is data to be read.
-
-If the variable exp_full_buffer is 1, then EXP_FULLBUFFER is returned
-if exp_buffer fills with no pattern having matched.
-
-When the expect function returns,
-.B exp_buffer
-points to the buffer
-of characters that was being considered for matching.
-.B exp_buffer_end
-points to one past the last character in exp_buffer.
-If a match occurred,
-.B exp_match
-points into
-.B exp_buffer
-where the match began.
-.B exp_match_end
-points to one character past where the match ended.
-.PP
-Each time new input arrives, it is compared to each pattern in the
-order they are listed. Thus, you may test for absence of a match by
-making the last pattern something guaranteed to appear, such as a
-prompt. In situations where there is no prompt, you must check for
-.B EXP_TIMEOUT
-(just like you would if you were interacting manually). More philosophy
-and strategies on specifying
-.B expect
-patterns can be found in the
-documentation on the
-.B expect
-program itself. See SEE ALSO below.
-.PP
-Patterns are the usual C-shell-style regular expressions. For
-example, the following fragment looks for a successful login, such
-as from a telnet dialogue.
-.nf
-
- switch (exp_expectl(
- exp_glob,"connected",CONN,
- exp_glob,"busy",BUSY,
- exp_glob,"failed",ABORT,
- exp_glob,"invalid password",ABORT,
- exp_end)) {
- case CONN: /* logged in successfully */
- break;
- case BUSY: /* couldn't log in at the moment */
- break;
- case EXP_TIMEOUT:
- case ABORT: /* can't log in at any moment! */
- break;
- default: /* problem with expect */
- }
-.fi
-
-Asterisks (as in the
-example above) are a useful shorthand for omitting line-termination
-characters and other detail.
-Patterns must match the entire output of the current process (since
-the previous read on the descriptor or stream).
-More than 2000 bytes of output can
-force earlier bytes to be "forgotten". This may be changed by setting
-the variable
-.BR exp_match_max .
-Note that excessively large values can slow down the pattern matcher.
-.SH RUNNING IN THE BACKGROUND
-.nf
-
-.B extern int exp_disconnected;
-.B int exp_disconnect();
-
-.fi
-It is possible to move a process into the background after it has
-begun running. A typical use for this is to read passwords and then
-go into the background to sleep before using the passwords to do real
-work.
-.PP
-To move a process into the background, fork, call exp_disconnect() in the
-child process and exit() in the parent process. This disassociates
-your process from the controlling terminal. If you wish to move a
-process into the background in a different way, you must set the
-variable exp_disconnected to 1. This allows processes spawned after
-this point to be started correctly.
-.SH MULTIPLEXING
-By default, the expect functions block inside of a read on a single file
-descriptor. If you want to wait on patterns from multiple file
-descriptors,
-use select, poll, or an event manager.
-They will tell you what file descriptor is ready to read.
-
-When a file descriptor is ready to read, you can use the expect
-functions to do one and only read by setting timeout to 0.
-.SH SLAVE CONTROL
-
-.nf
-
-.B void
-.B exp_slave_control(fd,enable)
-.B int fd;
-.B int enable;
-
-.fi
-
-Pty trapping is normally done automatically by the expect functions.
-However, if you want to issue an ioctl, for example, directly on the
-slave device, you should temporary disable trapping.
-
-Pty trapping can be controlled with exp_slave_control. The first
-argument is the file descriptor corresponding to the spawned process.
-The second argument is a 0 if trapping is to be disabled and 1 if it
-is to be enabled.
-
-.SH ERRORS
-All functions indicate errors by returning \-1 and setting errno.
-.PP
-Errors that occur after the spawn functions fork (e.g., attempting to
-spawn a non-existent program) are written to the process's stderr,
-and will be read by the first
-.BR expect .
-.SH SIGNALS
-.nf
-.B extern int exp_reading;
-.B extern jmp_buf exp_readenv;
-.fi
-
-.B expect
-uses alarm() to timeout, thus if you generate alarms during
-.BR expect ,
-it will timeout prematurely.
-.PP
-Internally,
-.B expect
-calls read() which can be interrupted by signals. If
-you define signal handlers, you can choose to restart or abort
-.BR expect 's
-internal read. The variable,
-.BR exp_reading ,
-is true if (and only if)
-.BR expect 's
-read has been interrupted. longjmp(exp_readenv,EXP_ABORT) will abort
-the read. longjmp(exp_readenv,EXP_RESTART) will restart the read.
-.SH LOGGING
-.nf
-
-.B extern int exp_loguser;
-.B extern int exp_logfile_all
-.B extern FILE *exp_logfile;
-.fi
-
-If
-.B exp_loguser
-is nonzero,
-.B expect
-sends any output from the spawned process to
-stdout. Since interactive programs typically echo their input, this
-usually suffices to show both sides of the conversation. If
-.B exp_logfile
-is also nonzero, this same output is written to the stream defined by
-.BR exp_logfile .
-If
-.B exp_logfile_all
-is non-zero,
-.B exp_logfile
-is written regardless of the value of
-.BR exp_loguser .
-
-.SH DEBUGGING
-While I consider the library to be easy to use, I think that the
-standalone expect program is much, much, easier to use than working
-with the C compiler and its usual edit, compile, debug cycle. Unlike
-typical C programs, most of the debugging isn't getting the C compiler
-to accept your programs - rather, it is getting the dialogue correct.
-Also, translating scripts from expect to C is usually not necessary.
-For example, the speed of interactive dialogues is virtually never an
-issue. So please try the standalone 'expect' program first. I
-suspect it is a more appropriate solution for most people than the
-library.
-.PP
-Nonetheless, if you feel compelled to debug in C,
-here are some tools to help you.
-.nf
-
-.B extern int exp_is_debugging;
-.B extern FILE *exp_debugfile;
-.fi
-
-While expect dialogues seem very intuitive, trying to codify them in a
-program can reveal many surprises in a program's interface. Therefore
-a variety of debugging aids are available. They are controlled by the
-above variables, all 0 by default.
-
-Debugging information internal to
-.B expect
-is sent to stderr when
-.B exp_is_debugging
-is non-zero. The debugging information includes
-every character received, and every attempt made to match the current
-input against the patterns. In addition, non-printable characters are
-translated to a printable form. For example, a control-C appears as a
-caret followed by a C. If
-.B exp_logfile
-is non-zero, this information
-is also written to that stream.
-.PP
-If
-.B exp_debugfile
-is non-zero, all normal and debugging information is
-written to that stream, regardless of the value of
-.BR exp_is_debugging .
-.SH CAVEATS
-The stream versions of the
-.B expect
-functions are much slower than the
-file descriptor versions because there is no way to portably read
-an unknown number of bytes without the potential of timing out.
-Thus, characters are read one at a time. You are therefore strongly
-encouraged to use the file descriptor versions of
-.B expect
-(although,
-automated versions of interactive programs don't usually demand high speed
-anyway).
-.PP
-You can actually get the best of both worlds, writing with the usual
-stream functions and reading with the file descriptor versions of
-.B expect
-as long as you don't attempt to intermix other stream input
-functions (e.g., fgetc).
-To do this, pass fileno(stream) as the file descriptor each time.
-Fortunately, there is little reason to use anything but the
-.B expect
-functions when reading from interactive programs.
-.PP
-There is no matching exp_pclose to exp_popen (unlike popen and pclose).
-It only takes two functions to close down a connection (fclose() followed
-by waiting on the pid), but it is not uncommon to separate these two
-actions by large time intervals, so the function seems of little value.
-.PP
-If you are running on a Cray running Unicos (all I know for sure from
-experience), you must run your compiled program as root or setuid. The
-problem is that the Cray only allows root processes to open ptys.
-You should observe as much precautions as possible: If you don't need
-permissions, setuid(0) only immediately before calling one of the spawn
-functions and immediately set it back afterwards.
-.PP
-Normally,
-.B spawn
-takes little time to execute. If you notice spawn taking a
-significant amount of time, it is probably encountering ptys that are
-wedged. A number of tests are run on ptys to avoid entanglements with
-errant processes. (These take 10 seconds per wedged pty.) Running
-expect with the \-d option will show if
-.B expect
-is encountering many ptys in odd states. If you cannot kill
-the processes to which these ptys are attached, your only recourse may
-be to reboot.
-.SH BUGS
-The
-.B exp_fexpect
-functions don't work at all under HP-UX - it appears to be a bug in getc.
-Follow the
-advice (above) about using the
-.B exp_expect
-functions (which doesn't need to call getc). If you fix the problem (before
-I do - please check the latest release) let me know.
-.SH SEE ALSO
-An alternative to this library is the
-.B expect
-program.
-.B expect
-interprets scripts written in a high-level language
-which direct the dialogue.
-In addition, the user can take control and interact directly when desired.
-If it is not absolutely necessary to write your own C program, it is much
-easier to use
-.B expect
-to perform the entire interaction.
-It is described further in the following references:
-.PP
-.I
-"expect: Curing Those Uncontrollable Fits of Interactivity" \fRby Don Libes,
-Proceedings of the Summer 1990 USENIX Conference,
-Anaheim, California, June 11-15, 1990.
-.PP
-.I
-"Using expect to Automate System Administration Tasks" \fRby Don Libes,
-Proceedings of the 1990 USENIX Large Installation Systems Administration
-Conference, Colorado Springs, Colorado, October 17-19, 1990.
-.PP
-expect(1), alarm(3), read(2), write(2), fdopen(3), execve(2), execvp(3),
-longjmp(3), pty(4).
-.PP
-There are several examples C programs in the test directory of
-.BR expect 's
-source distribution which use the expect library.
-.PP
-.SH AUTHOR
-Don Libes, libes@nist.gov, National Institute of Standards and Technology
-.SH ACKNOWLEDGEMENTS
-Thanks to John Ousterhout (UCBerkeley) for supplying the pattern
-matcher.
-.PP
-Design and implementation of the
-.B expect
-library was paid for by the U.S. government and is therefore in the public
-domain.
-However the author and NIST would like credit
-if this program and documentation or portions of them are used.
+++ /dev/null
-#! /bin/sh
-# mkinstalldirs --- make directory hierarchy
-# Author: Noah Friedman <friedman@prep.ai.mit.edu>
-# Created: 1993-05-16
-# Last modified: 1994-03-25
-# Public domain
-
-errstatus=0
-
-for file in ${1+"$@"} ; do
- set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
- shift
-
- pathcomp=
- for d in ${1+"$@"} ; do
- pathcomp="$pathcomp$d"
- case "$pathcomp" in
- -* ) pathcomp=./$pathcomp ;;
- esac
-
- if test ! -d "$pathcomp"; then
- echo "mkdir $pathcomp" 1>&2
- mkdir "$pathcomp" || errstatus=$?
- fi
-
- pathcomp="$pathcomp/"
- done
-done
-
-exit $errstatus
-
-# mkinstalldirs ends here
+++ /dev/null
-# Tcl package index file, version 1.0
-# This file is sourced either when an application starts up or
-# by a "package unknown" script. It invokes the
-# "package ifneeded" command to set up package-related
-# information so that packages will be loaded automatically
-# in response to "package require" commands. When this
-# script is sourced, the variable $dir must contain the
-# full path name of this file's directory.
-
-package ifneeded Expect @EXP_VERSION_FULL@ [list load [file join $dir .. @EXP_SHARED_LIB_FILE@]]
+++ /dev/null
-/* pty_bsd.c - routines to allocate ptys - BSD version
-
-Written by: Don Libes, NIST, 2/6/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.
-
-*/
-
-#include <stdio.h> /* tmp for debugging */
-#include <signal.h>
-
-#if defined(SIGCLD) && !defined(SIGCHLD)
-#define SIGCHLD SIGCLD
-#endif
-
-#include <sys/types.h>
-#include <sys/stat.h>
-/*** #include <sys/ioctl.h> ***/
-#include <sys/file.h>
-#include <signal.h>
-#include <setjmp.h>
-#include "expect_cf.h"
-#include "exp_rename.h"
-#include "exp_tty_in.h"
-#include "exp_pty.h"
-
-void debuglog();
-
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
-
-static char master_name[] = "/dev/ptyXX"; /* master */
-static char slave_name[] = "/dev/ttyXX"; /* slave */
-static char *tty_type; /* ptr to char [pt] denoting
- whether it is a pty or tty */
-static char *tty_bank; /* ptr to char [p-z] denoting
- which bank it is */
-static char *tty_num; /* ptr to char [0-f] denoting
- which number it is */
-char *exp_pty_slave_name;
-char *exp_pty_error;
-
-static void
-pty_stty(s,name)
-char *s; /* args to stty */
-char *name; /* name of pty */
-{
-#define MAX_ARGLIST 10240
- char buf[MAX_ARGLIST]; /* overkill is easier */
- RETSIGTYPE (*old)(); /* save old sigalarm handler */
-
-#ifdef STTY_READS_STDOUT
- sprintf(buf,"/bin/stty %s > %s",s,name);
-#else
- sprintf(buf,"/bin/stty %s < %s",s,name);
-#endif
- old = signal(SIGCHLD, SIG_DFL);
- system(buf);
- signal(SIGCHLD, old); /* restore signal handler */
-}
-
-int exp_dev_tty; /* file descriptor to /dev/tty or -1 if none */
-static int knew_dev_tty;/* true if we had our hands on /dev/tty at any time */
-
-#ifdef TIOCGWINSZ
-static struct winsize winsize = {0, 0};
-#endif
-#if defined(TIOCGSIZE) && !defined(TIOCGWINSZ)
-static struct ttysize winsize = {0, 0};
-#endif
-
-exp_tty exp_tty_original;
-
-#define GET_TTYTYPE 0
-#define SET_TTYTYPE 1
-static void
-ttytype(request,fd,ttycopy,ttyinit,s)
-int request;
-int fd;
- /* following are used only if request == SET_TTYTYPE */
-int ttycopy; /* if true, copy from /dev/tty */
-int ttyinit; /* if true, initialize to sane state */
-char *s; /* stty args */
-{
- static struct tchars tc; /* special characters */
- static struct ltchars lc; /* local special characters */
- static struct winsize win; /* window size */
- static int lb; /* local modes */
- static int l; /* line discipline */
-
- if (request == GET_TTYTYPE) {
- if (-1 == ioctl(fd, TIOCGETP, (char *)&exp_tty_original)
- || -1 == ioctl(fd, TIOCGETC, (char *)&tc)
- || -1 == ioctl(fd, TIOCGETD, (char *)&l)
- || -1 == ioctl(fd, TIOCGLTC, (char *)&lc)
- || -1 == ioctl(fd, TIOCLGET, (char *)&lb)
- || -1 == ioctl(fd, TIOCGWINSZ, (char *)&win)) {
- knew_dev_tty = FALSE;
- exp_dev_tty = -1;
- }
-#ifdef TIOCGWINSZ
- ioctl(fd,TIOCGWINSZ,&winsize);
-#endif
-#if defined(TIOCGSIZE) && !defined(TIOCGWINSZ)
- ioctl(fd,TIOCGSIZE,&winsize);
-#endif
- } else { /* type == SET_TTYTYPE */
- if (ttycopy && knew_dev_tty) {
- (void) ioctl(fd, TIOCSETP, (char *)&exp_tty_current);
- (void) ioctl(fd, TIOCSETC, (char *)&tc);
- (void) ioctl(fd, TIOCSLTC, (char *)&lc);
- (void) ioctl(fd, TIOCLSET, (char *)&lb);
- (void) ioctl(fd, TIOCSETD, (char *)&l);
- (void) ioctl(fd, TIOCSWINSZ, (char *)&win);
-#ifdef TIOCSWINSZ
- ioctl(fd,TIOCSWINSZ,&winsize);
-#endif
-#if defined(TIOCSSIZE) && !defined(TIOCSWINSZ)
- ioctl(fd,TIOCGSIZE,&winsize);
-#endif
- }
-
-#ifdef __CENTERLINE__
-#undef DFLT_STTY
-#define DFLT_STTY "sane"
-#endif
-
-/* Apollo Domain doesn't need this */
-#ifdef DFLT_STTY
- if (ttyinit) {
- /* overlay parms originally supplied by Makefile */
- pty_stty(DFLT_STTY,slave_name);
- }
-#endif
-
- /* lastly, give user chance to override any terminal parms */
- if (s) {
- pty_stty(s,slave_name);
- }
- }
-}
-
-void
-exp_init_pty()
-{
- tty_type = & slave_name[strlen("/dev/")];
- tty_bank = &master_name[strlen("/dev/pty")];
- tty_num = &master_name[strlen("/dev/ptyp")];
-
- exp_dev_tty = open("/dev/tty",O_RDWR);
-
-#if experimental
- /* code to allocate force expect to get a controlling tty */
- /* even if it doesn't start with one (i.e., under cron). */
- /* This code is not necessary, but helpful for testing odd things. */
- if (exp_dev_tty == -1) {
- /* give ourselves a controlling tty */
- int master = getptymaster();
- fcntl(master,F_SETFD,1); /* close-on-exec */
- setpgrp(0,0);
- close(0);
- close(1);
- getptyslave(exp_get_var(exp_interp,"stty_init"));
- close(2);
- fcntl(0,F_DUPFD,2); /* dup 0 onto 2 */
- }
-#endif
-
- knew_dev_tty = (exp_dev_tty != -1);
- if (knew_dev_tty) ttytype(GET_TTYTYPE,exp_dev_tty,0,0,(char *)0);
-}
-
-/* returns fd of master end of pseudotty */
-int
-getptymaster()
-{
- int master = -1;
- char *hex, *bank;
- struct stat statbuf;
-
- exp_pty_error = 0;
-
- if (exp_pty_test_start() == -1) return -1;
-
- for (bank = "pqrstuvwxyzPQRSTUVWXYZ";*bank;bank++) {
- *tty_bank = *bank;
- *tty_num = '0';
- if (stat(master_name, &statbuf) < 0) break;
- for (hex = "0123456789abcdef";*hex;hex++) {
- *tty_num = *hex;
-
- /* generate slave name from master */
- strcpy(slave_name,master_name);
- *tty_type = 't';
-
- master = exp_pty_test(master_name,slave_name,
- *tty_bank,tty_num);
- if (master >= 0) goto done;
- }
- }
- done:
- exp_pty_test_end();
- exp_pty_slave_name = slave_name;
- return(master);
-}
-
-/* see comment in pty_termios.c */
-/*ARGSUSED*/
-void
-exp_slave_control(master,control)
-int master;
-int control;
-{
-}
-
-int
-getptyslave(ttycopy,ttyinit,stty_args)
-int ttycopy;
-int ttyinit;
-char *stty_args;
-{
- int slave;
-
- if (0 > (slave = open(slave_name, O_RDWR))) return(-1);
-
- if (0 == slave) {
- /* if opened in a new process, slave will be 0 (and */
- /* ultimately, 1 and 2 as well) */
-
- /* duplicate 0 onto 1 and 2 to prepare for stty */
- fcntl(0,F_DUPFD,1);
- fcntl(0,F_DUPFD,2);
- }
-
- ttytype(SET_TTYTYPE,slave,ttycopy,ttyinit,stty_args);
- (void) exp_pty_unlock();
- return(slave);
-}
-
-void
-exp_pty_exit()
-{
- /* a stub so we can do weird things on the cray */
-}
+++ /dev/null
-/* pty_termios.c - routines to allocate ptys - termios version
-
-Written by: Don Libes, NIST, 2/6/90
-
-This file is in the public domain. However, the author and NIST
-would appreciate credit if you use this file or parts of it.
-
-*/
-
-/* Must be first, so that _XOPEN_SOURCE works. */
-#include "expect_cf.h"
-
-#include <stdio.h>
-#include <signal.h>
-
-#if defined(SIGCLD) && !defined(SIGCHLD)
-#define SIGCHLD SIGCLD
-#endif
-
-/*
- The following functions are linked from the Tcl library. They
- don't cause anything else in the library to be dragged in, so it
- shouldn't cause any problems (e.g., bloat).
-
- The functions are relatively small but painful enough that I don't care
- to recode them. You may, if you absolutely want to get rid of any
- vestiges of Tcl.
-*/
-extern char *TclGetRegError();
-
-
-
-#if defined(HAVE_PTYM) && defined(HAVE_PTMX)
-/*
- * HP-UX 10.0 with streams (optional) have both PTMX and PTYM. I don't
- * know which is preferred but seeing as how the HP trap stuff is so
- * unusual, it is probably safer to stick with the native HP pty support,
- * too.
- */
-#undef HAVE_PTMX
-#endif
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#ifdef HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#ifdef NO_STDLIB_H
-#include "../compat/stdlib.h"
-#else
-#include <stdlib.h>
-#endif
-
-#ifdef HAVE_SYSMACROS_H
-#include <sys/sysmacros.h>
-#endif
-
-#ifdef HAVE_PTYTRAP
-#include <sys/ptyio.h>
-#endif
-
-#include <sys/file.h>
-
-#ifdef HAVE_SYS_FCNTL_H
-# include <sys/fcntl.h>
-#else
-# include <fcntl.h>
-#endif
-
-#if defined(_SEQUENT_)
-# include <sys/strpty.h>
-#endif
-
-#if defined(HAVE_PTMX) && !defined(__CYGWIN__)
-# include <sys/stropts.h>
-#endif
-
-#include "exp_win.h"
-
-#include "exp_tty_in.h"
-#include "exp_rename.h"
-#include "exp_pty.h"
-
-void debuglog();
-
-#include <errno.h>
-/*extern char *sys_errlist[];*/
-
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
-
-/* Convex getpty is different than older-style getpty */
-/* Convex getpty is really just a cover function that does the traversal */
-/* across the domain of pty names. It makes no attempt to verify that */
-/* they can actually be used. Indded, the logic in the man page is */
-/* wrong because it will allow you to allocate ptys that your own account */
-/* already has in use. */
-#if defined(HAVE_GETPTY) && defined(CONVEX)
-#undef HAVE_GETPTY
-#define HAVE_CONVEX_GETPTY
-extern char *getpty();
-static char *master_name;
-static char slave_name[] = "/dev/ptyXX";
-static char *tty_bank; /* ptr to char [p-z] denoting
- which bank it is */
-static char *tty_num; /* ptr to char [0-f] denoting
- which number it is */
-#endif
-
-#if defined(_SEQUENT_) && !defined(HAVE_PTMX)
-/* old-style SEQUENT, new-style uses ptmx */
-static char *master_name, *slave_name;
-#endif /* _SEQUENT */
-
-/* very old SGIs prefer _getpty over ptc */
-#if defined(HAVE__GETPTY) && defined(HAVE_PTC) && !defined(HAVE_GETPTY)
-#undef HAVE_PTC
-#endif
-
-#if defined(HAVE_PTC)
-static char slave_name[] = "/dev/ttyqXXX";
-/* some machines (e.g., SVR4.0 StarServer) have all of these and */
-/* HAVE_PTC works best */
-#undef HAVE_GETPTY
-#undef HAVE__GETPTY
-#endif
-
-#if defined(HAVE__GETPTY) || defined(HAVE_PTC_PTS) || defined(HAVE_PTMX)
-static char *slave_name;
-#endif
-
-#if defined(HAVE_GETPTY)
-#include <sys/vty.h>
-static char master_name[MAXPTYNAMELEN];
-static char slave_name[MAXPTYNAMELEN];
-#endif
-
-#if !defined(HAVE_GETPTY) && !defined(HAVE__GETPTY) && !defined(HAVE_PTC) && !defined(HAVE_PTC_PTS) && !defined(HAVE_PTMX) && !defined(HAVE_CONVEX_GETPTY) && !defined(_SEQUENT_) && !defined(HAVE_SCO_CLIST_PTYS) && !defined(HAVE_OPENPTY)
-#ifdef HAVE_PTYM
- /* strange order and missing d is intentional */
-static char banks[] = "pqrstuvwxyzabcefghijklo";
-static char master_name[] = "/dev/ptym/ptyXXXX";
-static char slave_name[] = "/dev/pty/ttyXXXX";
-static char *slave_bank;
-static char *slave_num;
-#else
-static char banks[] = "pqrstuvwxyzPQRSTUVWXYZ";
-static char master_name[] = "/dev/ptyXX";
-static char slave_name [] = "/dev/ttyXX";
-#endif /* HAVE_PTYM */
-
-static char *tty_type; /* ptr to char [pt] denoting
- whether it is a pty or tty */
-static char *tty_bank; /* ptr to char [p-z] denoting
- which bank it is */
-static char *tty_num; /* ptr to char [0-f] denoting
- which number it is */
-#endif
-
-#if defined(HAVE_SCO_CLIST_PTYS)
-# define MAXPTYNAMELEN 64
-static char master_name[MAXPTYNAMELEN];
-static char slave_name[MAXPTYNAMELEN];
-#endif /* HAVE_SCO_CLIST_PTYS */
-
-#ifdef HAVE_OPENPTY
-static char master_name[64];
-static char slave_name[64];
-#endif
-
-char *exp_pty_slave_name;
-char *exp_pty_error;
-
-#if 0
-static void
-pty_stty(s,name)
-char *s; /* args to stty */
-char *name; /* name of pty */
-{
-#define MAX_ARGLIST 10240
- char buf[MAX_ARGLIST]; /* overkill is easier */
- RETSIGTYPE (*old)(); /* save old sigalarm handler */
- int pid;
-
- old = signal(SIGCHLD, SIG_DFL);
- switch (pid = fork()) {
- case 0: /* child */
- exec_stty("/bin/stty","/bin/stty",s);
- break;
- case -1: /* fail */
- default: /* parent */
- waitpid(pid);
- break;
- }
-
- signal(SIGCHLD, old); /* restore signal handler */
-}
-
-exec_stty(s)
-char *s;
-{
- char *args[50];
- char *cp;
- int argi = 0;
- int quoting = FALSE;
- int in_token = FALSE; /* TRUE if we are reading a token */
-
- args[0] = cp = s;
- while (*s) {
- if (quoting) {
- if (*s == '\\' && *(s+1) == '"') { /* quoted quote */
- s++; /* get past " */
- *cp++ = *s++;
- } else if (*s == '\"') { /* close quote */
- end_token
- quoting = FALSE;
- } else *cp++ = *s++; /* suck up anything */
- } else if (*s == '\"') { /* open quote */
- in_token = TRUE;
- quoting = TRUE;
- s++;
- } else if (isspace(*s)) {
- end_token
- } else {
- *cp++ = *s++;
- in_token = TRUE;
- }
- }
- end_token
- args[argi] = (char *) 0; /* terminate argv */
- execvp(args[0],args);
-}
-#endif /*0*/
-
-static void
-pty_stty(s,name)
-char *s; /* args to stty */
-char *name; /* name of pty */
-{
-#define MAX_ARGLIST 10240
- char buf[MAX_ARGLIST]; /* overkill is easier */
- RETSIGTYPE (*old)(); /* save old sigalarm handler */
-
-#ifdef STTY_READS_STDOUT
- sprintf(buf,"/bin/stty %s > %s",s,name);
-#else
-#ifdef __CYGWIN__
- sprintf(buf,"stty %s < %s",s,name);
-#else
- sprintf(buf,"/bin/stty %s < %s",s,name);
-#endif
-#endif
- old = signal(SIGCHLD, SIG_DFL);
- system(buf);
- signal(SIGCHLD, old); /* restore signal handler */
-}
-
-int exp_dev_tty; /* file descriptor to /dev/tty or -1 if none */
-static int knew_dev_tty;/* true if we had our hands on /dev/tty at any time */
-
-exp_tty exp_tty_original;
-
-#define GET_TTYTYPE 0
-#define SET_TTYTYPE 1
-static void
-ttytype(request,fd,ttycopy,ttyinit,s)
-int request;
-int fd;
- /* following are used only if request == SET_TTYTYPE */
-int ttycopy; /* true/false, copy from /dev/tty */
-int ttyinit; /* if true, initialize to sane state */
-char *s; /* stty args */
-{
- if (request == GET_TTYTYPE) {
-#ifdef HAVE_TCSETATTR
- if (-1 == tcgetattr(fd, &exp_tty_original)) {
-#else
- if (-1 == ioctl(fd, TCGETS, (char *)&exp_tty_original)) {
-#endif
- knew_dev_tty = FALSE;
- exp_dev_tty = -1;
- }
- exp_window_size_get(fd);
- } else { /* type == SET_TTYTYPE */
- if (ttycopy && knew_dev_tty) {
-#ifdef HAVE_TCSETATTR
- (void) tcsetattr(fd, TCSADRAIN, &exp_tty_current);
-#else
- (void) ioctl(fd, TCSETS, (char *)&exp_tty_current);
-#endif
-
- exp_window_size_set(fd);
- }
-
-#ifdef __CENTERLINE__
-#undef DFLT_STTY
-#define DFLT_STTY "sane"
-#endif
-
-/* Apollo Domain doesn't need this */
-#ifdef DFLT_STTY
- if (ttyinit) {
- /* overlay parms originally supplied by Makefile */
-/* As long as BSD stty insists on stdout == stderr, we can no longer write */
-/* diagnostics to parent stderr, since stderr has is now child's */
-/* Maybe someday they will fix stty? */
-/* debuglog("getptyslave: (default) stty %s\n",DFLT_STTY);*/
- pty_stty(DFLT_STTY,slave_name);
- }
-#endif
-
- /* lastly, give user chance to override any terminal parms */
- if (s) {
- /* give user a chance to override any terminal parms */
-/* debuglog("getptyslave: (user-requested) stty %s\n",s);*/
- pty_stty(s,slave_name);
- }
- }
-}
-
-void
-exp_init_pty()
-{
-#if !defined(HAVE_GETPTY) && !defined(HAVE__GETPTY) && !defined(HAVE_PTC) && !defined(HAVE_PTC_PTS) && !defined(HAVE_PTMX) && !defined(HAVE_CONVEX_GETPTY) && !defined(_SEQUENT_) && !defined(HAVE_SCO_CLIST_PTYS) && !defined(HAVE_OPENPTY)
-#ifdef HAVE_PTYM
- static char dummy;
- tty_bank = &master_name[strlen("/dev/ptym/pty")];
- tty_num = &master_name[strlen("/dev/ptym/ptyX")];
- slave_bank = &slave_name[strlen("/dev/pty/tty")];
- slave_num = &slave_name[strlen("/dev/pty/ttyX")];
-#else
- tty_bank = &master_name[strlen("/dev/pty")];
- tty_num = &master_name[strlen("/dev/ptyp")];
- tty_type = &slave_name[strlen("/dev/")];
-#endif
-
-#endif /* HAVE_PTYM */
-
-
- exp_dev_tty = open("/dev/tty",O_RDWR);
- knew_dev_tty = (exp_dev_tty != -1);
- if (knew_dev_tty) ttytype(GET_TTYTYPE,exp_dev_tty,0,0,(char *)0);
-}
-
-#ifndef R_OK
-/* 3b2 doesn't define these according to jthomas@nmsu.edu. */
-#define R_OK 04
-#define W_OK 02
-#endif
-
-int
-getptymaster()
-{
- char *hex, *bank;
- struct stat stat_buf;
- int master = -1;
- int slave = -1;
- int num;
-
- exp_pty_error = 0;
-
-#define TEST_PTY 1
-
-#if defined(HAVE_PTMX) || defined(HAVE_PTMX_BSD)
-#undef TEST_PTY
-#if defined(HAVE_PTMX_BSD)
- if ((master = open("/dev/ptmx_bsd", O_RDWR)) == -1) return(-1);
-#else
- if ((master = open("/dev/ptmx", O_RDWR)) == -1) return(-1);
-#endif
- if ((slave_name = (char *)ptsname(master)) == NULL || unlockpt(master)) {
- close(master);
- return(-1);
- } else if (grantpt(master)) {
- static char buf[500];
- exp_pty_error = buf;
- sprintf(exp_pty_error,"grantpt(%d) failed - likely reason is that your system administrator (in a rage of blind passion to rid the system of security holes) removed setuid from the utility used internally by grantpt to change pty permissions. Tell your system admin to reestablish setuid on the utility. Get the utility name by running Expect under truss or trace.");
- close(master);
- return(-1);
- }
-#ifdef TIOCFLUSH
- (void) ioctl(master,TIOCFLUSH,(char *)0);
-#endif /* TIOCFLUSH */
-
- exp_pty_slave_name = slave_name;
- return(master);
-#endif
-
-#if defined(HAVE__GETPTY) /* SGI needs it this way */
-#undef TEST_PTY
- slave_name = _getpty(&master, O_RDWR, 0600, 0);
- if (slave_name == NULL)
- return (-1);
- exp_pty_slave_name = slave_name;
- return(master);
-#endif
-
-#if defined(HAVE_PTC) && !defined(HAVE__GETPTY) /* old SGI, version 3 */
-#undef TEST_PTY
- master = open("/dev/ptc", O_RDWR);
- if (master >= 0) {
- int ptynum;
-
- if (fstat(master, &stat_buf) < 0) {
- close(master);
- return(-1);
- }
- ptynum = minor(stat_buf.st_rdev);
- sprintf(slave_name,"/dev/ttyq%d",ptynum);
- }
- exp_pty_slave_name = slave_name;
- return(master);
-#endif
-
-#if defined(HAVE_GETPTY) && !defined(HAVE__GETPTY)
-#undef TEST_PTY
- master = getpty(master_name, slave_name, O_RDWR);
- /* is it really necessary to verify slave side is usable? */
- exp_pty_slave_name = slave_name;
- return master;
-#endif
-
-#if defined(HAVE_PTC_PTS)
-#undef TEST_PTY
- master = open("/dev/ptc",O_RDWR);
- if (master >= 0) {
- /* never fails */
- slave_name = ttyname(master);
- }
- exp_pty_slave_name = slave_name;
- return(master);
-#endif
-
-#if defined(_SEQUENT_) && !defined(HAVE_PTMX)
-#undef TEST_PTY
- /* old-style SEQUENT, new-style uses ptmx */
- master = getpseudotty(&slave_name, &master_name);
- exp_pty_slave_name = slave_name;
- return(master);
-#endif /* _SEQUENT_ */
-
-#if defined(HAVE_OPENPTY)
-#undef TEST_PTY
- if (openpty(&master, &slave, master_name, 0, 0) != 0) {
- close(master);
- close(slave);
- return -1;
- }
- strcpy(slave_name, ttyname(slave));
- exp_pty_slave_name = slave_name;
- close(slave);
- return master;
-#endif /* HAVE_OPENPTY */
-
-#if defined(TEST_PTY)
- /*
- * all pty allocation mechanisms after this require testing
- */
- if (exp_pty_test_start() == -1) return -1;
-
-#if !defined(HAVE_CONVEX_GETPTY) && !defined(HAVE_PTYM) && !defined(HAVE_SCO_CLIST_PTYS)
- for (bank = banks;*bank;bank++) {
- *tty_bank = *bank;
- *tty_num = '0';
- if (stat(master_name, &stat_buf) < 0) break;
- for (hex = "0123456789abcdef";*hex;hex++) {
- *tty_num = *hex;
- strcpy(slave_name,master_name);
- *tty_type = 't';
- master = exp_pty_test(master_name,slave_name,*tty_bank,tty_num);
- if (master >= 0) goto done;
- }
- }
-#endif
-
-#ifdef HAVE_SCO_CLIST_PTYS
- for (num = 0; ; num++) {
- char num_str [16];
-
- sprintf (num_str, "%d", num);
- sprintf (master_name, "%s%s", "/dev/ptyp", num_str);
- if (stat (master_name, &stat_buf) < 0)
- break;
- sprintf (slave_name, "%s%s", "/dev/ttyp", num_str);
-
- master = exp_pty_test (master_name, slave_name, 0, num_str);
- if (master >= 0)
- goto done;
- }
-#endif
-
-#ifdef HAVE_PTYM
- /* systems with PTYM follow this idea:
-
- /dev/ptym/pty[a-ce-z][0-9a-f] master pseudo terminals
- /dev/pty/tty[a-ce-z][0-9a-f] slave pseudo terminals
- /dev/ptym/pty[a-ce-z][0-9][0-9] master pseudo terminals
- /dev/pty/tty[a-ce-z][0-9][0-9] slave pseudo terminals
-
- SPPUX (Convex's HPUX compatible) follows the PTYM convention but
- extends it:
-
- /dev/ptym/pty[a-ce-z][0-9][0-9][0-9] master pseudo terminals
- /dev/pty/tty[a-ce-z][0-9][0-9][0-9] slave pseudo terminals
-
- The code does not distinguish between HPUX and SPPUX because there
- is no reason to. HPUX will merely fail the extended SPPUX tests.
- In fact, most SPPUX systems will fail simply because few systems
- will actually have the extended ptys. However, the tests are
- fast so it is no big deal.
- */
-
- /*
- * pty[a-ce-z][0-9a-f]
- */
-
- for (bank = banks;*bank;bank++) {
- *tty_bank = *bank;
- sprintf(tty_num,"0");
- if (stat(master_name, &stat_buf) < 0) break;
- *(slave_num+1) = '\0';
- for (hex = "0123456789abcdef";*hex;hex++) {
- *tty_num = *hex;
- *slave_bank = *tty_bank;
- *slave_num = *tty_num;
- master = exp_pty_test(master_name,slave_name,*tty_bank,tty_num);
- if (master >= 0) goto done;
- }
- }
-
- /*
- * tty[p-za-ce-o][0-9][0-9]
- */
-
- for (bank = banks;*bank;bank++) {
- *tty_bank = *bank;
- sprintf(tty_num,"00");
- if (stat(master_name, &stat_buf) < 0) break;
- for (num = 0; num<100; num++) {
- *slave_bank = *tty_bank;
- sprintf(tty_num,"%02d",num);
- strcpy(slave_num,tty_num);
- master = exp_pty_test(master_name,slave_name,tty_bank,tty_num);
- if (master >= 0) goto done;
- }
- }
-
- /*
- * tty[p-za-ce-o][0-9][0-9][0-9]
- */
- for (bank = banks;*bank;bank++) {
- *tty_bank = *bank;
- sprintf(tty_num,"000");
- if (stat(master_name, &stat_buf) < 0) break;
- for (num = 0; num<1000; num++) {
- *slave_bank = *tty_bank;
- sprintf(tty_num,"%03d",num);
- strcpy(slave_num,tty_num);
- master = exp_pty_test(master_name,slave_name,tty_bank,tty_num);
- if (master >= 0) goto done;
- }
- }
-
-#endif /* HAVE_PTYM */
-
-#if defined(HAVE_CONVEX_GETPTY)
- for (;;) {
- if ((master_name = getpty()) == NULL) return -1;
-
- strcpy(slave_name,master_name);
- slave_name[5] = 't';/* /dev/ptyXY ==> /dev/ttyXY */
-
- tty_bank = &slave_name[8];
- tty_num = &slave_name[9];
- master = exp_pty_test(master_name,slave_name,*tty_bank,tty_num);
- if (master >= 0) goto done;
- }
-#endif
-
- done:
- exp_pty_test_end();
- exp_pty_slave_name = slave_name;
- return(master);
-
-#endif /* defined(TEST_PTY) */
-}
-
-/* if slave is opened in a child, slave_control(1) must be executed after */
-/* master is opened (when child is opened is irrelevent) */
-/* if slave is opened in same proc as master, slave_control(1) must executed */
-/* after slave is opened */
-/*ARGSUSED*/
-void
-exp_slave_control(master,control)
-int master;
-int control; /* if 1, enable pty trapping of close/open/ioctl */
-{
-#ifdef HAVE_PTYTRAP
- ioctl(master, TIOCTRAP, &control);
-#endif /* HAVE_PTYTRAP */
-}
-
-int
-getptyslave(ttycopy,ttyinit,stty_args)
-int ttycopy;
-int ttyinit;
-char *stty_args;
-{
- int slave, slave2;
- char buf[10240];
-
- if (0 > (slave = open(slave_name, O_RDWR))) return(-1);
-
-#if defined(HAVE_PTMX_BSD)
- if (ioctl (slave, I_LOOK, buf) != 0)
- if (ioctl (slave, I_PUSH, "ldterm")) {
- debuglog("ioctl(%s,I_PUSH,\"ldterm\") = %s\n",Tcl_ErrnoMsg(errno));
- }
-#else
-#if defined(HAVE_PTMX) && !defined(__CYGWIN__)
- if (ioctl(slave, I_PUSH, "ptem")) {
- debuglog("ioctl(%s,I_PUSH,\"ptem\") = %s\n",Tcl_ErrnoMsg(errno));
- }
- if (ioctl(slave, I_PUSH, "ldterm")) {
- debuglog("ioctl(%s,I_PUSH,\"ldterm\") = %s\n",Tcl_ErrnoMsg(errno));
- }
- if (ioctl(slave, I_PUSH, "ttcompat")) {
- debuglog("ioctl(%s,I_PUSH,\"ttcompat\") = %s\n",Tcl_ErrnoMsg(errno));
- }
-#endif
-#endif
-
- if (0 == slave) {
- /* if opened in a new process, slave will be 0 (and */
- /* ultimately, 1 and 2 as well) */
-
- /* duplicate 0 onto 1 and 2 to prepare for stty */
- fcntl(0,F_DUPFD,1);
- fcntl(0,F_DUPFD,2);
- }
-
- ttytype(SET_TTYTYPE,slave,ttycopy,ttyinit,stty_args);
-
-#if 0
-#ifdef HAVE_PTYTRAP
- /* do another open, to tell master that slave is done fiddling */
- /* with pty and master does not have to wait to do further acks */
- if (0 > (slave2 = open(slave_name, O_RDWR))) return(-1);
- close(slave2);
-#endif /* HAVE_PTYTRAP */
-#endif
-
- (void) exp_pty_unlock();
- return(slave);
-}
-
-#ifdef HAVE_PTYTRAP
-#include <sys/ptyio.h>
-#include <sys/time.h>
-
-/* This function attempts to deal with HP's pty interface. This
-function simply returns an indication of what was trapped (or -1 for
-failure), the parent deals with the details.
-
-Originally, I tried to just trap open's but that is not enough. When
-the pty is initialized, ioctl's are generated and if not trapped will
-hang the child if no further trapping is done. (This could occur if
-parent spawns a process and then immediatley does a close.) So
-instead, the parent must trap the ioctl's. It probably suffices to
-trap the write ioctl's (and tiocsctty which some hp's need) -
-conceivably, stty could be smart enough not to do write's if the tty
-settings are already correct. In that case, we'll have to rethink
-this.
-
-Suggestions from HP engineers encouraged. I cannot imagine how this
-interface was intended to be used!
-
-*/
-
-int
-exp_wait_for_slave_open(fd)
-int fd;
-{
- fd_set excep;
- struct timeval t;
- struct request_info ioctl_info;
- int rc;
- int found = 0;
-
- int maxfds = sysconf(_SC_OPEN_MAX);
-
- t.tv_sec = 30; /* 30 seconds */
- t.tv_usec = 0;
-
- FD_ZERO(&excep);
- FD_SET(fd,&excep);
-
- rc = select(maxfds,
- (SELECT_MASK_TYPE *)0,
- (SELECT_MASK_TYPE *)0,
- (SELECT_MASK_TYPE *)&excep,
- &t);
- if (rc != 1) {
- debuglog("spawned process never started, errno = %d\n",errno);
- return(-1);
- }
- if (ioctl(fd,TIOCREQCHECK,&ioctl_info) < 0) {
- debuglog("ioctl(TIOCREQCHECK) failed, errno = %d\n",errno);
- return(-1);
- }
-
- found = ioctl_info.request;
-
- debuglog("trapped pty op = %x",found);
- if (found == TIOCOPEN) {
- debuglog(" TIOCOPEN");
- } else if (found == TIOCCLOSE) {
- debuglog(" TIOCCLOSE");
- }
-
-#ifdef TIOCSCTTY
- if (found == TIOCSCTTY) {
- debuglog(" TIOCSCTTY");
- }
-#endif
-
- if (found & IOC_IN) {
- debuglog(" IOC_IN (set)");
- } else if (found & IOC_OUT) {
- debuglog(" IOC_OUT (get)");
- }
-
- debuglog("\n");
-
- if (ioctl(fd, TIOCREQSET, &ioctl_info) < 0) {
- debuglog("ioctl(TIOCREQSET) failed, errno = %d\n",errno);
- return(-1);
- }
- return(found);
-}
-#endif
-
-void
-exp_pty_exit()
-{
- /* a stub so we can do weird things on the cray */
-}
+++ /dev/null
-/* pty_unicos.c - routines to allocate ptys - for CRAY UNICOS 5.1 and 6.0 */
-
-/*
-
-Original by: Don Libes, NIST, 2/6/90
-Hacked for Unicos 5.1 by: Frank Terhaar-Yonkers, US EPA, 1/10/91
-Hacked for Unicos 6.0 by: Pete TerMaat, pete@willow.cray.com, 3/27/91
-
-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.
-
-*/
-
-#include "expect_cf.h"
-#include <stdio.h>
-#include <signal.h>
-
-#if defined(SIGCLD) && !defined(SIGCHLD)
-#define SIGCHLD SIGCLD
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#else
-extern int fork(), execl(), wait();
-#endif
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <sys/file.h>
-#ifdef HAVE_SYS_FCNTL_H
-# include <sys/fcntl.h>
-#else
-# include <fcntl.h>
-#endif
-/*#if CRAY>=60*/
-#if defined(HAVE_TERMIOS)
-# include <sys/termios.h>
-#else
-# include <sys/termio.h>
-/*#endif /* 60 */*/
-#endif /* defined(HAVE_TERMIOS) */
-#if CRAY>=70 && defined(_CRAY2)
-#include <sys/session.h>
-#endif /* 70 */
-#include <sys/pty.h>
-#include <pwd.h>
-#include <utmp.h>
-#include <signal.h>
-#include "exp_tty_in.h"
-#include "exp_rename.h"
-
-#ifdef HAVE_SYSCONF_H
-#include <sys/sysconfig.h>
-#endif
-
-void debuglog();
-
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
-
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 64
-#endif /* MAXHOSTNAMELEN */
-
-static char linep[] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
-static char linet[] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
-static int lowpty;
-static int highpty;
-static int realuid;
-static int realgid;
-static int *ptys;
-static char myname[32];
-static char hostname[MAXHOSTNAMELEN];
-char *exp_pty_slave_name;
-char *exp_pty_error;
-
-static void
-pty_stty(s,name)
-char *s; /* args to stty */
-char *name; /* name of pty */
-{
-#define MAX_ARGLIST 10240
- char buf[MAX_ARGLIST]; /* overkill is easier */
- RETSIGTYPE (*old)(); /* save old sigalarm handler */
-
-#ifdef STTY_READS_STDOUT
- sprintf(buf,"/bin/stty %s > %s",s,name);
-#else
- sprintf(buf,"/bin/stty %s < %s",s,name);
-#endif
- old = signal(SIGCHLD, SIG_DFL);
- system(buf);
- signal(SIGCHLD, old); /* restore signal handler */
-}
-
-int exp_dev_tty; /* file descriptor to /dev/tty or -1 if none */
-static int knew_dev_tty;/* true if we had our hands on /dev/tty at any time */
-
-#ifdef TIOCGWINSZ
-static struct winsize winsize = {0, 0};
-#endif
-#if defined(TIOCGSIZE) && !defined(TIOCGWINSZ)
-static struct ttysize winsize = {0, 0};
-#endif
-
-/*struct termio exp_tty_original;*/
-exp_tty exp_tty_original;
-
-#define GET_TTYTYPE 0
-#define SET_TTYTYPE 1
-static void
-ttytype(request,fd,ttycopy,ttyinit,s)
-int request;
-int fd;
- /* following are used only if request == SET_TTYTYPE */
-int ttycopy; /* true/false, copy from /dev/tty */
-int ttyinit; /* if true, initialize to sane state */
-char *s; /* stty args, used only if request == SET_TTYTYPE */
-{
- if (request == GET_TTYTYPE) {
- if (-1 == ioctl(fd, TCGETA, (char *)&exp_tty_original)) {
- knew_dev_tty = FALSE;
- exp_dev_tty = -1;
- }
-#ifdef TIOCGWINSZ
- ioctl(fd,TIOCGWINSZ,&winsize);
-#endif
-#if defined(TIOCGSIZE) && !defined(TIOCGWINSZ)
- ioctl(fd,TIOCGSIZE,&winsize);
-#endif
- } else { /* type == SET_TTYTYPE */
- if (ttycopy && knew_dev_tty) {
- (void) ioctl(fd, TCSETA, (char *)&exp_tty_current);
-#ifdef TIOCSWINSZ
- ioctl(fd,TIOCSWINSZ,&winsize);
-#endif
-#if defined(TIOCSSIZE) && !defined(TIOCSWINSZ)
- ioctl(fd,TIOCGSIZE,&winsize);
-#endif
- }
-
- if (ttyinit) {
- /* overlay parms originally supplied by Makefile */
- pty_stty(DFLT_STTY,linet);
- }
-
- /* lastly, give user chance to override any terminal parms */
- if (s) {
- pty_stty(s,linet);
- }
- }
-}
-
-void
-exp_init_pty()
-{
- int npty;
- char *myline;
-
- lowpty=0;
-#ifdef _SC_CRAY_NPTY
- highpty=sysconf(_SC_CRAY_NPTY);
-#else
- highpty=128;
-#endif /* _SC_CRAY_NPTY */
-
- ptys = (int *) malloc(sizeof(int)*(highpty+1));
- if (ptys == NULL) {
- fprintf(stderr,"exp_init_pty: couldn't allocate pty array\n");
- exit(1);
- }
- for (npty = lowpty;npty <= highpty;npty++)
- ptys[npty] = 0;
-
- realuid=getuid(); /* get REAL uid */
- realgid=getgid(); /* get REAL uid */
-
- exp_dev_tty = open("/dev/tty",O_RDWR);
- knew_dev_tty = (exp_dev_tty != -1);
- if (knew_dev_tty) ttytype(GET_TTYTYPE,exp_dev_tty,0,0,(char *)0);
-
- /*
- * Acquire (as root) current user name and host.
- */
- (void) cuserid(myname);
- (void) gethostname(hostname,sizeof(hostname));
-
- /*
- * Set the real and effective userids to root using 'setuid'. Then
- * set the real and effective userids to the actual user using
- * 'setreuid'. This allows using 'seteuid' to go back and forth from
- * root and the actual userid. Don't ask me why it works.
- */
- setuid(0);
- setreuid(realuid,realuid);
-}
-
-/* returns fd of master end of pseudotty */
-int
-getptymaster()
-{
- struct stat sb;
- int master;
- int npty;
-
- exp_pty_error = 0;
-
- debuglog("getptymaster: lowpty=%d highpty=%d\n",lowpty,highpty);
- for (npty = lowpty; npty <= highpty; npty++) {
- if (seteuid(0) == -1) { /* we need to be root! */
- debuglog("getptymaster: seteuid root errno=%d\n",
- errno);
- }
- (void) sprintf(linep, "/dev/pty/%03d", npty);
- master = open(linep, O_RDWR);
-
- if (master < 0) {
- debuglog("getptymaster: open linep=%s errno=%d\n",
- linep,errno);
- continue;
- }
-
- (void) sprintf(linet, "/dev/ttyp%03d", npty);
- if(stat(linet, &sb) < 0) {
- debuglog("getptymaster: stat linet=%s errno=%d\n",
- linet,errno);
- (void) close(master);
- continue;
- }
- if (sb.st_uid || sb.st_gid || sb.st_mode != 0600) {
- if (chown(linet, realuid, realgid) == -1) {
- debuglog("getptymaster: chown linet=%s errno=%d\n",
- linet,errno);
- }
- if (chmod(linet, 0600) == -1) {
- debuglog("getptymaster: chmod linet=%s errno=%d\n",
- linet,errno);
- }
- (void)close(master);
- master = open(linep, 2);
- if (master < 0) {
- debuglog("getptymaster: reopen linep=%s errno=%d\n",
- linep,errno);
- continue;
- }
- }
- if (seteuid(realuid) == -1) { /* back to who we are! */
- debuglog("getptymaster: seteuid user errno=%d\n",
- errno);
- }
- if (access(linet, R_OK|W_OK) != 0) {
- debuglog("getptymaster: access linet=%s errno=%d\n",
- linet,errno);
- (void) close(master);
- continue;
- }
- debuglog("getptymaster: allocated %s\n",linet);
- ptys[npty] = -1;
- exp_pty_slave_name = linet;
- return(master);
- }
- if (seteuid(realuid) == -1) { /* back to who we are! */
- debuglog("getptymaster: seteuid user errno=%d\n",errno);
- }
- return(-1);
-}
-
-/* see comment in pty_termios.c */
-/*ARGSUSED*/
-void
-exp_slave_control(master,control)
-int master;
-int control;
-{
-}
-
-int
-getptyslave(ttycopy,ttyinit,stty_args)
-int ttycopy;
-int ttyinit;
-char *stty_args;
-{
- int slave;
-
- if (0 > (slave = open(linet, O_RDWR))) {
- debuglog("getptyslave: open linet=%s errno=%d\n",linet,errno);
- return(-1);
- }
-
- /* sanity check - if slave not 0, skip rest of this and return */
- /* to what will later be detected as an error in caller */
- if (0 != slave) {
- debuglog("getptyslave: slave fd not 0\n");
- return(slave);
- }
-
- if (0 == slave) {
- /* if opened in a new process, slave will be 0 (and */
- /* ultimately, 1 and 2 as well) */
-
- /* duplicate 0 onto 1 and 2 to prepare for stty */
- fcntl(0,F_DUPFD,1);
- fcntl(0,F_DUPFD,2);
- }
-
- ttytype(SET_TTYTYPE,slave,ttycopy,ttyinit,stty_args);
- return(slave);
-}
-
-setptyutmp()
-{
- struct utmp utmp;
-
- if (seteuid(0) == -1) { /* Need to be root */
- debuglog("setptyutmp: setuid root errno=%d\n",errno);
- return(-1);
- }
- (void) time(&utmp.ut_time);
- utmp.ut_type = USER_PROCESS;
- utmp.ut_pid = getpid();
- strncpy(utmp.ut_user,myname,sizeof(utmp.ut_user));
- strncpy(utmp.ut_host,hostname,sizeof(utmp.ut_host));
- strncpy(utmp.ut_line,linet+5,sizeof(utmp.ut_line));
- strncpy(utmp.ut_id,linet+8,sizeof(utmp.ut_id));
- if (pututline(&utmp) == NULL) {
- debuglog("setptyutmp: pututline failed\n");
- }
- endutent();
- if (seteuid(realuid) == -1)
- debuglog("setptyutmp: seteuid user errno=%d\n",errno);
- return(0);
-}
-
-setptypid(pid)
-int pid;
-{
- int npty;
-
- for (npty = lowpty; npty <= highpty; npty++) {
- if (ptys[npty] < 0) {
- debuglog("setptypid: ttyp%03d pid=%d\n",npty,pid);
- ptys[npty] = pid;
- break;
- }
- }
-}
-
-ttyp_reset()
-{
- int npty;
-
- if (seteuid(0) == -1) { /* we need to be root! */
- debuglog("ttyp_reset: seteuid root errno=%d\n",errno);
- }
- for (npty = lowpty; npty <= highpty; npty++) {
- if (ptys[npty] <= 0)
- continue;
-
- (void) sprintf(linet, "/dev/ttyp%03d", npty);
- debuglog("ttyp_reset: resetting %s, killing %d\n",
- linet,ptys[npty]);
- if (chown(linet,0,0) == -1) {
- debuglog("ttyp_reset: chown %s errno=%d\n",linet,errno);
- }
- if (chmod(linet, 0666) == -1) {
- debuglog("ttyp_reset: chmod %s errno=%d\n",linet,errno);
- }
- resetptyutmp();
- if (kill(ptys[npty],SIGKILL) == -1) {
- debuglog("ttyp_reset: kill pid=%d errno=%d\n",
- ptys[npty],errno);
- }
- }
- if (seteuid(realuid) == -1) { /* Back to who we really are */
- debuglog("ttyp_reset: seteuid user errno=%d\n",errno);
- }
-}
-
-void
-exp_pty_exit()
-{
- ttyp_reset();
-}
-
-resetptyutmp()
-{
- struct utmp utmp;
-
- (void) setutent ();
- /* set up entry to search for */
- (void) strncpy(utmp.ut_id, linet + strlen(linet) - 4,
- sizeof (utmp.ut_id));
- utmp.ut_type = USER_PROCESS;
-
- /* position to entry in utmp file */
- if(getutid(&utmp) == NULL) {
- debuglog("resetptyutmp: no utmp entry for %s\n",linet);
- return(-1); /* no utmp entry for this line ??? */
- }
-
- /* set up the new entry */
- strncpy(utmp.ut_name,"",sizeof(utmp.ut_name));
- strncpy(utmp.ut_host,"",sizeof(utmp.ut_host));
- time(&utmp.ut_time);
- utmp.ut_type = DEAD_PROCESS;
- utmp.ut_exit.e_exit = 0;
-
- /* write out the entry */
- pututline(&utmp);
-
- /* close the file */
- (void) endutent();
- return(0);
-}
+++ /dev/null
-
-/* Expect depends on these Tcl functions, which have been removed
- in the latest version of Tcl/Tk 8.3. */
-
-/*
- * tclParse.c --
- *
- * This file contains a collection of procedures that are used
- * to parse Tcl commands or parts of commands (like quoted
- * strings or nested sub-commands).
- *
- * Copyright (c) 1987-1993 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * RCS: @(#) $Id$
- */
-
-/* Only do this for Tcl8.3 and above. */
-#include "tcl.h"
-#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 2
-#include "tclInt.h"
-
-
-static char *QuoteEnd(char *string, char *lastChar, int term);
-static char *VarNameEnd(char *string, char *lastChar);
-static char *ScriptEnd(char *p, char *lastChar, int nested);
-/*
- *----------------------------------------------------------------------
- *
- * TclWordEnd --
- *
- * Given a pointer into a Tcl command, find the end of the next
- * word of the command.
- *
- * Results:
- * The return value is a pointer to the last character that's part
- * of the word pointed to by "start". If the word doesn't end
- * properly within the string then the return value is the address
- * of the null character at the end of the string.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-char *
-TclWordEnd(start, lastChar, nested, semiPtr)
- char *start; /* Beginning of a word of a Tcl command. */
- char *lastChar; /* Terminating character in string. */
- int nested; /* Zero means this is a top-level command.
- * One means this is a nested command (close
- * bracket is a word terminator). */
- int *semiPtr; /* Set to 1 if word ends with a command-
- * terminating semi-colon, zero otherwise.
- * If NULL then ignored. */
-{
- register char *p;
- int count;
-
- if (semiPtr != NULL) {
- *semiPtr = 0;
- }
-
- /*
- * Skip leading white space (backslash-newline must be treated like
- * white-space, except that it better not be the last thing in the
- * command).
- */
-
- for (p = start; ; p++) {
- if (isspace(UCHAR(*p))) {
- continue;
- }
- if ((p[0] == '\\') && (p[1] == '\n')) {
- if (p+2 == lastChar) {
- return p+2;
- }
- continue;
- }
- break;
- }
-
- /*
- * Handle words beginning with a double-quote or a brace.
- */
-
- if (*p == '"') {
- p = QuoteEnd(p+1, lastChar, '"');
- if (p == lastChar) {
- return p;
- }
- p++;
- } else if (*p == '{') {
- int braces = 1;
- while (braces != 0) {
- p++;
- while (*p == '\\') {
- (void) Tcl_Backslash(p, &count);
- p += count;
- }
- if (*p == '}') {
- braces--;
- } else if (*p == '{') {
- braces++;
- } else if (p == lastChar) {
- return p;
- }
- }
- p++;
- }
-
- /*
- * Handle words that don't start with a brace or double-quote.
- * This code is also invoked if the word starts with a brace or
- * double-quote and there is garbage after the closing brace or
- * quote. This is an error as far as Tcl_Eval is concerned, but
- * for here the garbage is treated as part of the word.
- */
-
- while (1) {
- if (*p == '[') {
- p = ScriptEnd(p+1, lastChar, 1);
- if (p == lastChar) {
- return p;
- }
- p++;
- } else if (*p == '\\') {
- if (p[1] == '\n') {
- /*
- * Backslash-newline: it maps to a space character
- * that is a word separator, so the word ends just before
- * the backslash.
- */
-
- return p-1;
- }
- (void) Tcl_Backslash(p, &count);
- p += count;
- } else if (*p == '$') {
- p = VarNameEnd(p, lastChar);
- if (p == lastChar) {
- return p;
- }
- p++;
- } else if (*p == ';') {
- /*
- * Include the semi-colon in the word that is returned.
- */
-
- if (semiPtr != NULL) {
- *semiPtr = 1;
- }
- return p;
- } else if (isspace(UCHAR(*p))) {
- return p-1;
- } else if ((*p == ']') && nested) {
- return p-1;
- } else if (p == lastChar) {
- if (nested) {
- /*
- * Nested commands can't end because of the end of the
- * string.
- */
- return p;
- }
- return p-1;
- } else {
- p++;
- }
- }
-}
-\f
-/*
- *----------------------------------------------------------------------
- *
- * QuoteEnd --
- *
- * Given a pointer to a string that obeys the parsing conventions
- * for quoted things in Tcl, find the end of that quoted thing.
- * The actual thing may be a quoted argument or a parenthesized
- * index name.
- *
- * Results:
- * The return value is a pointer to the last character that is
- * part of the quoted string (i.e the character that's equal to
- * term). If the quoted string doesn't terminate properly then
- * the return value is a pointer to the null character at the
- * end of the string.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static char *
-QuoteEnd(string, lastChar, term)
- char *string; /* Pointer to character just after opening
- * "quote". */
- char *lastChar; /* Terminating character in string. */
- int term; /* This character will terminate the
- * quoted string (e.g. '"' or ')'). */
-{
- register char *p = string;
- int count;
-
- while (*p != term) {
- if (*p == '\\') {
- (void) Tcl_Backslash(p, &count);
- p += count;
- } else if (*p == '[') {
- for (p++; *p != ']'; p++) {
- p = TclWordEnd(p, lastChar, 1, (int *) NULL);
- if (*p == 0) {
- return p;
- }
- }
- p++;
- } else if (*p == '$') {
- p = VarNameEnd(p, lastChar);
- if (*p == 0) {
- return p;
- }
- p++;
- } else if (p == lastChar) {
- return p;
- } else {
- p++;
- }
- }
- return p-1;
-}
-\f
-/*
- *----------------------------------------------------------------------
- *
- * VarNameEnd --
- *
- * Given a pointer to a variable reference using $-notation, find
- * the end of the variable name spec.
- *
- * Results:
- * The return value is a pointer to the last character that
- * is part of the variable name. If the variable name doesn't
- * terminate properly then the return value is a pointer to the
- * null character at the end of the string.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static char *
-VarNameEnd(string, lastChar)
- char *string; /* Pointer to dollar-sign character. */
- char *lastChar; /* Terminating character in string. */
-{
- register char *p = string+1;
-
- if (*p == '{') {
- for (p++; (*p != '}') && (p != lastChar); p++) {
- /* Empty loop body. */
- }
- return p;
- }
- while (isalnum(UCHAR(*p)) || (*p == '_')) {
- p++;
- }
- if ((*p == '(') && (p != string+1)) {
- return QuoteEnd(p+1, lastChar, ')');
- }
- return p-1;
-}
-
-\f
-/*
- *----------------------------------------------------------------------
- *
- * ScriptEnd --
- *
- * Given a pointer to the beginning of a Tcl script, find the end of
- * the script.
- *
- * Results:
- * The return value is a pointer to the last character that's part
- * of the script pointed to by "p". If the command doesn't end
- * properly within the string then the return value is the address
- * of the null character at the end of the string.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static char *
-ScriptEnd(p, lastChar, nested)
- char *p; /* Script to check. */
- char *lastChar; /* Terminating character in string. */
- int nested; /* Zero means this is a top-level command.
- * One means this is a nested command (the
- * last character of the script must be
- * an unquoted ]). */
-{
- int commentOK = 1;
- int length;
-
- while (1) {
- while (isspace(UCHAR(*p))) {
- if (*p == '\n') {
- commentOK = 1;
- }
- p++;
- }
- if ((*p == '#') && commentOK) {
- do {
- if (*p == '\\') {
- /*
- * If the script ends with backslash-newline, then
- * this command isn't complete.
- */
-
- if ((p[1] == '\n') && (p+2 == lastChar)) {
- return p+2;
- }
- Tcl_Backslash(p, &length);
- p += length;
- } else {
- p++;
- }
- } while ((p != lastChar) && (*p != '\n'));
- continue;
- }
- p = TclWordEnd(p, lastChar, nested, &commentOK);
- if (p == lastChar) {
- return p;
- }
- p++;
- if (nested) {
- if (*p == ']') {
- return p;
- }
- } else {
- if (p == lastChar) {
- return p-1;
- }
- }
- }
-}
-
-#endif /* Tcl8.3 and above. */
+++ /dev/null
-/*
- * TclRegComp and TclRegExec -- TclRegSub is elsewhere
- *
- * Copyright (c) 1986 by University of Toronto.
- * Written by Henry Spencer. Not derived from licensed software.
- *
- * Permission is granted to anyone to use this software for any
- * purpose on any computer system, and to redistribute it freely,
- * subject to the following restrictions:
- *
- * 1. The author is not responsible for the consequences of use of
- * this software, no matter how awful, even if they arise
- * from defects in it.
- *
- * 2. The origin of this software must not be misrepresented, either
- * by explicit claim or by omission.
- *
- * 3. Altered versions must be plainly marked as such, and must not
- * be misrepresented as being the original software.
- *
- * Beware that some of this code is subtly aware of the way operator
- * precedence is structured in regular expressions. Serious changes in
- * regular-expression syntax might require a total rethink.
- *
- * *** NOTE: this code has been altered slightly for use in Tcl: ***
- * *** 1. Use ckalloc and ckfree instead of malloc and free. ***
- * *** 2. Add extra argument to regexp to specify the real ***
- * *** start of the string separately from the start of the ***
- * *** current search. This is needed to search for multiple ***
- * *** matches within a string. ***
- * *** 3. Names have been changed, e.g. from regcomp to ***
- * *** TclRegComp, to avoid clashes with other ***
- * *** regexp implementations used by applications. ***
- * *** 4. Added errMsg declaration and TclRegError procedure ***
- * *** 5. Various lint-like things, such as casting arguments ***
- * *** in procedure calls. ***
- *
- * *** NOTE: This code has been altered for use in MT-Sturdy Tcl ***
- * *** 1. All use of static variables has been changed to access ***
- * *** fields of a structure. ***
- * *** 2. This in addition to changes to TclRegError makes the ***
- * *** code multi-thread safe. ***
- *
- * RCS: @(#) $Id$
- */
-
-#include "tclInt.h"
-#include "tclPort.h"
-
-#include "tcl_regexp.h"
-
-/*
- * The variable below is set to NULL before invoking regexp functions
- * and checked after those functions. If an error occurred then TclRegError
- * will set the variable to point to a (static) error message. This
- * mechanism unfortunately does not support multi-threading, but the
- * procedures TclRegError and TclGetRegError can be modified to use
- * thread-specific storage for the variable and thereby make the code
- * thread-safe.
- */
-
-static char *errMsg = NULL;
-
-/*
- * The "internal use only" fields in regexp.h are present to pass info from
- * compile to execute that permits the execute phase to run lots faster on
- * simple cases. They are:
- *
- * regstart char that must begin a match; '\0' if none obvious
- * reganch is the match anchored (at beginning-of-line only)?
- * regmust string (pointer into program) that match must include, or NULL
- * regmlen length of regmust string
- *
- * Regstart and reganch permit very fast decisions on suitable starting points
- * for a match, cutting down the work a lot. Regmust permits fast rejection
- * of lines that cannot possibly match. The regmust tests are costly enough
- * that TclRegComp() supplies a regmust only if the r.e. contains something
- * potentially expensive (at present, the only such thing detected is * or +
- * at the start of the r.e., which can involve a lot of backup). Regmlen is
- * supplied because the test in TclRegExec() needs it and TclRegComp() is
- * computing it anyway.
- */
-
-/*
- * Structure for regexp "program". This is essentially a linear encoding
- * of a nondeterministic finite-state machine (aka syntax charts or
- * "railroad normal form" in parsing technology). Each node is an opcode
- * plus a "next" pointer, possibly plus an operand. "Next" pointers of
- * all nodes except BRANCH implement concatenation; a "next" pointer with
- * a BRANCH on both ends of it is connecting two alternatives. (Here we
- * have one of the subtle syntax dependencies: an individual BRANCH (as
- * opposed to a collection of them) is never concatenated with anything
- * because of operator precedence.) The operand of some types of node is
- * a literal string; for others, it is a node leading into a sub-FSM. In
- * particular, the operand of a BRANCH node is the first node of the branch.
- * (NB this is *not* a tree structure: the tail of the branch connects
- * to the thing following the set of BRANCHes.) The opcodes are:
- */
-
-/* definition number opnd? meaning */
-#define END 0 /* no End of program. */
-#define BOL 1 /* no Match "" at beginning of line. */
-#define EOL 2 /* no Match "" at end of line. */
-#define ANY 3 /* no Match any one character. */
-#define ANYOF 4 /* str Match any character in this string. */
-#define ANYBUT 5 /* str Match any character not in this string. */
-#define BRANCH 6 /* node Match this alternative, or the next... */
-#define BACK 7 /* no Match "", "next" ptr points backward. */
-#define EXACTLY 8 /* str Match this string. */
-#define NOTHING 9 /* no Match empty string. */
-#define STAR 10 /* node Match this (simple) thing 0 or more times. */
-#define PLUS 11 /* node Match this (simple) thing 1 or more times. */
-#define OPEN 20 /* no Mark this point in input as start of #n. */
- /* OPEN+1 is number 1, etc. */
-#define CLOSE (OPEN+NSUBEXP) /* no Analogous to OPEN. */
-
-/*
- * Opcode notes:
- *
- * BRANCH The set of branches constituting a single choice are hooked
- * together with their "next" pointers, since precedence prevents
- * anything being concatenated to any individual branch. The
- * "next" pointer of the last BRANCH in a choice points to the
- * thing following the whole choice. This is also where the
- * final "next" pointer of each individual branch points; each
- * branch starts with the operand node of a BRANCH node.
- *
- * BACK Normal "next" pointers all implicitly point forward; BACK
- * exists to make loop structures possible.
- *
- * STAR,PLUS '?', and complex '*' and '+', are implemented as circular
- * BRANCH structures using BACK. Simple cases (one character
- * per match) are implemented with STAR and PLUS for speed
- * and to minimize recursive plunges.
- *
- * OPEN,CLOSE ...are numbered at compile time.
- */
-
-/*
- * A node is one char of opcode followed by two chars of "next" pointer.
- * "Next" pointers are stored as two 8-bit pieces, high order first. The
- * value is a positive offset from the opcode of the node containing it.
- * An operand, if any, simply follows the node. (Note that much of the
- * code generation knows about this implicit relationship.)
- *
- * Using two bytes for the "next" pointer is vast overkill for most things,
- * but allows patterns to get big without disasters.
- */
-#define OP(p) (*(p))
-#define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377))
-#define OPERAND(p) ((p) + 3)
-
-/*
- * See regmagic.h for one further detail of program structure.
- */
-
-
-/*
- * Utility definitions.
- */
-#ifndef CHARBITS
-#define UCHARAT(p) ((int)*(unsigned char *)(p))
-#else
-#define UCHARAT(p) ((int)*(p)&CHARBITS)
-#endif
-
-#define FAIL(m) { Expect_TclRegError(m); return(NULL); }
-#define ISMULT(c) ((c) == '*' || (c) == '+' || (c) == '?')
-#define META "^$.[()|?+*\\"
-
-/*
- * Flags to be passed up and down.
- */
-#define HASWIDTH 01 /* Known never to match null string. */
-#define SIMPLE 02 /* Simple enough to be STAR/PLUS operand. */
-#define SPSTART 04 /* Starts with * or +. */
-#define WORST 0 /* Worst case. */
-
-/*
- * Global work variables for TclRegComp().
- */
-struct regcomp_state {
- char *regparse; /* Input-scan pointer. */
- int regnpar; /* () count. */
- char *regcode; /* Code-emit pointer; ®dummy = don't. */
- long regsize; /* Code size. */
-};
-
-static char regdummy;
-
-/*
- * The first byte of the regexp internal "program" is actually this magic
- * number; the start node begins in the second byte.
- */
-#define MAGIC 0234
-
-
-/*
- * Forward declarations for TclRegComp()'s friends.
- */
-
-static char * reg _ANSI_ARGS_((int paren, int *flagp,
- struct regcomp_state *rcstate));
-static char * regatom _ANSI_ARGS_((int *flagp,
- struct regcomp_state *rcstate));
-static char * regbranch _ANSI_ARGS_((int *flagp,
- struct regcomp_state *rcstate));
-static void regc _ANSI_ARGS_((int b,
- struct regcomp_state *rcstate));
-static void reginsert _ANSI_ARGS_((int op, char *opnd,
- struct regcomp_state *rcstate));
-static char * regnext _ANSI_ARGS_((char *p));
-static char * regnode _ANSI_ARGS_((int op,
- struct regcomp_state *rcstate));
-static void regoptail _ANSI_ARGS_((char *p, char *val));
-static char * regpiece _ANSI_ARGS_((int *flagp,
- struct regcomp_state *rcstate));
-static void regtail _ANSI_ARGS_((char *p, char *val));
-
-#ifdef STRCSPN
-static int strcspn _ANSI_ARGS_((char *s1, char *s2));
-#endif
-
-/*
- - TclRegComp - compile a regular expression into internal code
- *
- * We can't allocate space until we know how big the compiled form will be,
- * but we can't compile it (and thus know how big it is) until we've got a
- * place to put the code. So we cheat: we compile it twice, once with code
- * generation turned off and size counting turned on, and once "for real".
- * This also means that we don't allocate space until we are sure that the
- * thing really will compile successfully, and we never have to move the
- * code and thus invalidate pointers into it. (Note that it has to be in
- * one piece because free() must be able to free it all.)
- *
- * Beware that the optimization-preparation code in here knows about some
- * of the structure of the compiled regexp.
- */
-Expect_regexp *
-Expect_TclRegComp(exp)
-char *exp;
-{
- register Expect_regexp *r;
- register char *scan;
- register char *longest;
- register int len;
- int flags;
- struct regcomp_state state;
- struct regcomp_state *rcstate= &state;
-
- if (exp == NULL)
- FAIL("NULL argument");
-
- /* First pass: determine size, legality. */
- rcstate->regparse = exp;
- rcstate->regnpar = 1;
- rcstate->regsize = 0L;
- rcstate->regcode = ®dummy;
- regc(MAGIC, rcstate);
- if (reg(0, &flags, rcstate) == NULL)
- return(NULL);
-
- /* Small enough for pointer-storage convention? */
- if (rcstate->regsize >= 32767L) /* Probably could be 65535L. */
- FAIL("regexp too big");
-
- /* Allocate space. */
- r = (Expect_regexp *)ckalloc(sizeof(Expect_regexp) + (unsigned)rcstate->regsize);
- if (r == NULL)
- FAIL("out of space");
-
- /* Second pass: emit code. */
- rcstate->regparse = exp;
- rcstate->regnpar = 1;
- rcstate->regcode = r->program;
- regc(MAGIC, rcstate);
- if (reg(0, &flags, rcstate) == NULL)
- return(NULL);
-
- /* Dig out information for optimizations. */
- r->regstart = '\0'; /* Worst-case defaults. */
- r->reganch = 0;
- r->regmust = NULL;
- r->regmlen = 0;
- scan = r->program+1; /* First BRANCH. */
- if (OP(regnext(scan)) == END) { /* Only one top-level choice. */
- scan = OPERAND(scan);
-
- /* Starting-point info. */
- if (OP(scan) == EXACTLY)
- r->regstart = *OPERAND(scan);
- else if (OP(scan) == BOL)
- r->reganch++;
-
- /*
- * If there's something expensive in the r.e., find the
- * longest literal string that must appear and make it the
- * regmust. Resolve ties in favor of later strings, since
- * the regstart check works with the beginning of the r.e.
- * and avoiding duplication strengthens checking. Not a
- * strong reason, but sufficient in the absence of others.
- */
- if (flags&SPSTART) {
- longest = NULL;
- len = 0;
- for (; scan != NULL; scan = regnext(scan))
- if (OP(scan) == EXACTLY && ((int) strlen(OPERAND(scan))) >= len) {
- longest = OPERAND(scan);
- len = strlen(OPERAND(scan));
- }
- r->regmust = longest;
- r->regmlen = len;
- }
- }
-
- return(r);
-}
-
-/*
- - reg - regular expression, i.e. main body or parenthesized thing
- *
- * Caller must absorb opening parenthesis.
- *
- * Combining parenthesis handling with the base level of regular expression
- * is a trifle forced, but the need to tie the tails of the branches to what
- * follows makes it hard to avoid.
- */
-static char *
-reg(paren, flagp, rcstate)
-int paren; /* Parenthesized? */
-int *flagp;
-struct regcomp_state *rcstate;
-{
- register char *ret;
- register char *br;
- register char *ender;
- register int parno = 0;
- int flags;
-
- *flagp = HASWIDTH; /* Tentatively. */
-
- /* Make an OPEN node, if parenthesized. */
- if (paren) {
- if (rcstate->regnpar >= NSUBEXP)
- FAIL("too many ()");
- parno = rcstate->regnpar;
- rcstate->regnpar++;
- ret = regnode(OPEN+parno,rcstate);
- } else
- ret = NULL;
-
- /* Pick up the branches, linking them together. */
- br = regbranch(&flags,rcstate);
- if (br == NULL)
- return(NULL);
- if (ret != NULL)
- regtail(ret, br); /* OPEN -> first. */
- else
- ret = br;
- if (!(flags&HASWIDTH))
- *flagp &= ~HASWIDTH;
- *flagp |= flags&SPSTART;
- while (*rcstate->regparse == '|') {
- rcstate->regparse++;
- br = regbranch(&flags,rcstate);
- if (br == NULL)
- return(NULL);
- regtail(ret, br); /* BRANCH -> BRANCH. */
- if (!(flags&HASWIDTH))
- *flagp &= ~HASWIDTH;
- *flagp |= flags&SPSTART;
- }
-
- /* Make a closing node, and hook it on the end. */
- ender = regnode((paren) ? CLOSE+parno : END,rcstate);
- regtail(ret, ender);
-
- /* Hook the tails of the branches to the closing node. */
- for (br = ret; br != NULL; br = regnext(br))
- regoptail(br, ender);
-
- /* Check for proper termination. */
- if (paren && *rcstate->regparse++ != ')') {
- FAIL("unmatched ()");
- } else if (!paren && *rcstate->regparse != '\0') {
- if (*rcstate->regparse == ')') {
- FAIL("unmatched ()");
- } else
- FAIL("junk on end"); /* "Can't happen". */
- /* NOTREACHED */
- }
-
- return(ret);
-}
-
-/*
- - regbranch - one alternative of an | operator
- *
- * Implements the concatenation operator.
- */
-static char *
-regbranch(flagp, rcstate)
-int *flagp;
-struct regcomp_state *rcstate;
-{
- register char *ret;
- register char *chain;
- register char *latest;
- int flags;
-
- *flagp = WORST; /* Tentatively. */
-
- ret = regnode(BRANCH,rcstate);
- chain = NULL;
- while (*rcstate->regparse != '\0' && *rcstate->regparse != '|' &&
- *rcstate->regparse != ')') {
- latest = regpiece(&flags, rcstate);
- if (latest == NULL)
- return(NULL);
- *flagp |= flags&HASWIDTH;
- if (chain == NULL) /* First piece. */
- *flagp |= flags&SPSTART;
- else
- regtail(chain, latest);
- chain = latest;
- }
- if (chain == NULL) /* Loop ran zero times. */
- (void) regnode(NOTHING,rcstate);
-
- return(ret);
-}
-
-/*
- - regpiece - something followed by possible [*+?]
- *
- * Note that the branching code sequences used for ? and the general cases
- * of * and + are somewhat optimized: they use the same NOTHING node as
- * both the endmarker for their branch list and the body of the last branch.
- * It might seem that this node could be dispensed with entirely, but the
- * endmarker role is not redundant.
- */
-static char *
-regpiece(flagp, rcstate)
-int *flagp;
-struct regcomp_state *rcstate;
-{
- register char *ret;
- register char op;
- register char *next;
- int flags;
-
- ret = regatom(&flags,rcstate);
- if (ret == NULL)
- return(NULL);
-
- op = *rcstate->regparse;
- if (!ISMULT(op)) {
- *flagp = flags;
- return(ret);
- }
-
- if (!(flags&HASWIDTH) && op != '?')
- FAIL("*+ operand could be empty");
- *flagp = (op != '+') ? (WORST|SPSTART) : (WORST|HASWIDTH);
-
- if (op == '*' && (flags&SIMPLE))
- reginsert(STAR, ret, rcstate);
- else if (op == '*') {
- /* Emit x* as (x&|), where & means "self". */
- reginsert(BRANCH, ret, rcstate); /* Either x */
- regoptail(ret, regnode(BACK,rcstate)); /* and loop */
- regoptail(ret, ret); /* back */
- regtail(ret, regnode(BRANCH,rcstate)); /* or */
- regtail(ret, regnode(NOTHING,rcstate)); /* null. */
- } else if (op == '+' && (flags&SIMPLE))
- reginsert(PLUS, ret, rcstate);
- else if (op == '+') {
- /* Emit x+ as x(&|), where & means "self". */
- next = regnode(BRANCH,rcstate); /* Either */
- regtail(ret, next);
- regtail(regnode(BACK,rcstate), ret); /* loop back */
- regtail(next, regnode(BRANCH,rcstate)); /* or */
- regtail(ret, regnode(NOTHING,rcstate)); /* null. */
- } else if (op == '?') {
- /* Emit x? as (x|) */
- reginsert(BRANCH, ret, rcstate); /* Either x */
- regtail(ret, regnode(BRANCH,rcstate)); /* or */
- next = regnode(NOTHING,rcstate); /* null. */
- regtail(ret, next);
- regoptail(ret, next);
- }
- rcstate->regparse++;
- if (ISMULT(*rcstate->regparse))
- FAIL("nested *?+");
-
- return(ret);
-}
-
-/*
- - regatom - the lowest level
- *
- * Optimization: gobbles an entire sequence of ordinary characters so that
- * it can turn them into a single node, which is smaller to store and
- * faster to run. Backslashed characters are exceptions, each becoming a
- * separate node; the code is simpler that way and it's not worth fixing.
- */
-static char *
-regatom(flagp, rcstate)
-int *flagp;
-struct regcomp_state *rcstate;
-{
- register char *ret;
- int flags;
-
- *flagp = WORST; /* Tentatively. */
-
- switch (*rcstate->regparse++) {
- case '^':
- ret = regnode(BOL,rcstate);
- break;
- case '$':
- ret = regnode(EOL,rcstate);
- break;
- case '.':
- ret = regnode(ANY,rcstate);
- *flagp |= HASWIDTH|SIMPLE;
- break;
- case '[': {
- register int clss;
- register int classend;
-
- if(rcstate->regparse[0] != '\\' &&
- rcstate->regparse[0] != '^' &&
- rcstate->regparse[1] == ']') {
- ret = regnode(EXACTLY,rcstate);
- regc(*rcstate->regparse++,rcstate);
- regc('\0',rcstate);
- rcstate->regparse++;
- *flagp |= HASWIDTH|SIMPLE;
- break;
- }
- if (*rcstate->regparse == '^') { /* Complement of range. */
- ret = regnode(ANYBUT,rcstate);
- rcstate->regparse++;
- } else
- ret = regnode(ANYOF,rcstate);
- if (*rcstate->regparse == ']' || *rcstate->regparse == '-')
- regc(*rcstate->regparse++,rcstate);
- while (*rcstate->regparse != '\0' && *rcstate->regparse != ']') {
- if (*rcstate->regparse == '-') {
- rcstate->regparse++;
- if (*rcstate->regparse == ']' || *rcstate->regparse == '\0')
- regc('-',rcstate);
- else {
- clss = UCHARAT(rcstate->regparse-2)+1;
- classend = UCHARAT(rcstate->regparse);
- if (clss > classend+1)
- FAIL("invalid [] range");
- for (; clss <= classend; clss++)
- regc((char)clss,rcstate);
- rcstate->regparse++;
- }
- } else
- regc(*rcstate->regparse++,rcstate);
- }
- regc('\0',rcstate);
- if (*rcstate->regparse != ']')
- FAIL("unmatched []");
- rcstate->regparse++;
- *flagp |= HASWIDTH|SIMPLE;
- }
- break;
- case '(':
- ret = reg(1, &flags, rcstate);
- if (ret == NULL)
- return(NULL);
- *flagp |= flags&(HASWIDTH|SPSTART);
- break;
- case '\0':
- case '|':
- case ')':
- FAIL("internal urp"); /* Supposed to be caught earlier. */
- /* NOTREACHED */
- case '?':
- case '+':
- case '*':
- FAIL("?+* follows nothing");
- /* NOTREACHED */
- case '\\':
- if (*rcstate->regparse == '\0')
- FAIL("trailing \\");
- ret = regnode(EXACTLY,rcstate);
- regc(*rcstate->regparse++,rcstate);
- regc('\0',rcstate);
- *flagp |= HASWIDTH|SIMPLE;
- break;
- default: {
- register int len;
- register char ender;
-
- rcstate->regparse--;
- len = strcspn(rcstate->regparse, META);
- if (len <= 0)
- FAIL("internal disaster");
- ender = *(rcstate->regparse+len);
- if (len > 1 && ISMULT(ender))
- len--; /* Back off clear of ?+* operand. */
- *flagp |= HASWIDTH;
- if (len == 1)
- *flagp |= SIMPLE;
- ret = regnode(EXACTLY,rcstate);
- while (len > 0) {
- regc(*rcstate->regparse++,rcstate);
- len--;
- }
- regc('\0',rcstate);
- }
- break;
- }
-
- return(ret);
-}
-
-/*
- - regnode - emit a node
- */
-static char * /* Location. */
-regnode(op, rcstate)
-int op;
-struct regcomp_state *rcstate;
-{
- register char *ret;
- register char *ptr;
-
- ret = rcstate->regcode;
- if (ret == ®dummy) {
- rcstate->regsize += 3;
- return(ret);
- }
-
- ptr = ret;
- *ptr++ = (char)op;
- *ptr++ = '\0'; /* Null "next" pointer. */
- *ptr++ = '\0';
- rcstate->regcode = ptr;
-
- return(ret);
-}
-
-/*
- - regc - emit (if appropriate) a byte of code
- */
-static void
-regc(b, rcstate)
-int b;
-struct regcomp_state *rcstate;
-{
- if (rcstate->regcode != ®dummy)
- *rcstate->regcode++ = (char)b;
- else
- rcstate->regsize++;
-}
-
-/*
- - reginsert - insert an operator in front of already-emitted operand
- *
- * Means relocating the operand.
- */
-static void
-reginsert(op, opnd, rcstate)
-int op;
-char *opnd;
-struct regcomp_state *rcstate;
-{
- register char *src;
- register char *dst;
- register char *place;
-
- if (rcstate->regcode == ®dummy) {
- rcstate->regsize += 3;
- return;
- }
-
- src = rcstate->regcode;
- rcstate->regcode += 3;
- dst = rcstate->regcode;
- while (src > opnd)
- *--dst = *--src;
-
- place = opnd; /* Op node, where operand used to be. */
- *place++ = (char)op;
- *place++ = '\0';
- *place = '\0';
-}
-
-/*
- - regtail - set the next-pointer at the end of a node chain
- */
-static void
-regtail(p, val)
-char *p;
-char *val;
-{
- register char *scan;
- register char *temp;
- register int offset;
-
- if (p == ®dummy)
- return;
-
- /* Find last node. */
- scan = p;
- for (;;) {
- temp = regnext(scan);
- if (temp == NULL)
- break;
- scan = temp;
- }
-
- if (OP(scan) == BACK)
- offset = scan - val;
- else
- offset = val - scan;
- *(scan+1) = (char)((offset>>8)&0377);
- *(scan+2) = (char)(offset&0377);
-}
-
-/*
- - regoptail - regtail on operand of first argument; nop if operandless
- */
-static void
-regoptail(p, val)
-char *p;
-char *val;
-{
- /* "Operandless" and "op != BRANCH" are synonymous in practice. */
- if (p == NULL || p == ®dummy || OP(p) != BRANCH)
- return;
- regtail(OPERAND(p), val);
-}
-
-/*
- * TclRegExec and friends
- */
-
-/*
- * Global work variables for TclRegExec().
- */
-struct regexec_state {
- char *reginput; /* String-input pointer. */
- char *regbol; /* Beginning of input, for ^ check. */
- char **regstartp; /* Pointer to startp array. */
- char **regendp; /* Ditto for endp. */
-};
-
-/*
- * Forwards.
- */
-static int regtry _ANSI_ARGS_((Expect_regexp *prog, char *string,
- struct regexec_state *restate));
-static int regmatch _ANSI_ARGS_((char *prog,
- struct regexec_state *restate));
-static int regrepeat _ANSI_ARGS_((char *p,
- struct regexec_state *restate));
-
-#ifdef DEBUG
-int regnarrate = 0;
-void regdump _ANSI_ARGS_((Expect_regexp *r));
-static char *regprop _ANSI_ARGS_((char *op));
-#endif
-
-/*
- - TclRegExec - match a regexp against a string
- */
-int
-Expect_TclRegExec(prog, string, start)
-register Expect_regexp *prog;
-register char *string;
-char *start;
-{
- register char *s;
- struct regexec_state state;
- struct regexec_state *restate= &state;
-
- /* Be paranoid... */
- if (prog == NULL || string == NULL) {
- Expect_TclRegError("NULL parameter");
- return(0);
- }
-
- /* Check validity of program. */
- if (UCHARAT(prog->program) != MAGIC) {
- Expect_TclRegError("corrupted program");
- return(0);
- }
-
- /* If there is a "must appear" string, look for it. */
- if (prog->regmust != NULL) {
- s = string;
- while ((s = strchr(s, prog->regmust[0])) != NULL) {
- if (strncmp(s, prog->regmust, (size_t) prog->regmlen)
- == 0)
- break; /* Found it. */
- s++;
- }
- if (s == NULL) /* Not present. */
- return(0);
- }
-
- /* Mark beginning of line for ^ . */
- restate->regbol = start;
-
- /* Simplest case: anchored match need be tried only once. */
- if (prog->reganch)
- return(regtry(prog, string, restate));
-
- /* Messy cases: unanchored match. */
- s = string;
- if (prog->regstart != '\0')
- /* We know what char it must start with. */
- while ((s = strchr(s, prog->regstart)) != NULL) {
- if (regtry(prog, s, restate))
- return(1);
- s++;
- }
- else
- /* We don't -- general case. */
- do {
- if (regtry(prog, s, restate))
- return(1);
- } while (*s++ != '\0');
-
- /* Failure. */
- return(0);
-}
-
-/*
- - regtry - try match at specific point
- */
-static int /* 0 failure, 1 success */
-regtry(prog, string, restate)
-Expect_regexp *prog;
-char *string;
-struct regexec_state *restate;
-{
- register int i;
- register char **sp;
- register char **ep;
-
- restate->reginput = string;
- restate->regstartp = prog->startp;
- restate->regendp = prog->endp;
-
- sp = prog->startp;
- ep = prog->endp;
- for (i = NSUBEXP; i > 0; i--) {
- *sp++ = NULL;
- *ep++ = NULL;
- }
- if (regmatch(prog->program + 1,restate)) {
- prog->startp[0] = string;
- prog->endp[0] = restate->reginput;
- return(1);
- } else
- return(0);
-}
-
-/*
- - regmatch - main matching routine
- *
- * Conceptually the strategy is simple: check to see whether the current
- * node matches, call self recursively to see whether the rest matches,
- * and then act accordingly. In practice we make some effort to avoid
- * recursion, in particular by going through "ordinary" nodes (that don't
- * need to know whether the rest of the match failed) by a loop instead of
- * by recursion.
- */
-static int /* 0 failure, 1 success */
-regmatch(prog, restate)
-char *prog;
-struct regexec_state *restate;
-{
- register char *scan; /* Current node. */
- char *next; /* Next node. */
-
- scan = prog;
-#ifdef DEBUG
- if (scan != NULL && regnarrate)
- fprintf(stderr, "%s(\n", regprop(scan));
-#endif
- while (scan != NULL) {
-#ifdef DEBUG
- if (regnarrate)
- fprintf(stderr, "%s...\n", regprop(scan));
-#endif
- next = regnext(scan);
-
- switch (OP(scan)) {
- case BOL:
- if (restate->reginput != restate->regbol) {
- return 0;
- }
- break;
- case EOL:
- if (*restate->reginput != '\0') {
- return 0;
- }
- break;
- case ANY:
- if (*restate->reginput == '\0') {
- return 0;
- }
- restate->reginput++;
- break;
- case EXACTLY: {
- register int len;
- register char *opnd;
-
- opnd = OPERAND(scan);
- /* Inline the first character, for speed. */
- if (*opnd != *restate->reginput) {
- return 0 ;
- }
- len = strlen(opnd);
- if (len > 1 && strncmp(opnd, restate->reginput, (size_t) len)
- != 0) {
- return 0;
- }
- restate->reginput += len;
- break;
- }
- case ANYOF:
- if (*restate->reginput == '\0'
- || strchr(OPERAND(scan), *restate->reginput) == NULL) {
- return 0;
- }
- restate->reginput++;
- break;
- case ANYBUT:
- if (*restate->reginput == '\0'
- || strchr(OPERAND(scan), *restate->reginput) != NULL) {
- return 0;
- }
- restate->reginput++;
- break;
- case NOTHING:
- break;
- case BACK:
- break;
- case OPEN+1:
- case OPEN+2:
- case OPEN+3:
- case OPEN+4:
- case OPEN+5:
- case OPEN+6:
- case OPEN+7:
- case OPEN+8:
- case OPEN+9: {
- register int no;
- register char *save;
-
- doOpen:
- no = OP(scan) - OPEN;
- save = restate->reginput;
-
- if (regmatch(next,restate)) {
- /*
- * Don't set startp if some later invocation of the
- * same parentheses already has.
- */
- if (restate->regstartp[no] == NULL) {
- restate->regstartp[no] = save;
- }
- return 1;
- } else {
- return 0;
- }
- }
- case CLOSE+1:
- case CLOSE+2:
- case CLOSE+3:
- case CLOSE+4:
- case CLOSE+5:
- case CLOSE+6:
- case CLOSE+7:
- case CLOSE+8:
- case CLOSE+9: {
- register int no;
- register char *save;
-
- doClose:
- no = OP(scan) - CLOSE;
- save = restate->reginput;
-
- if (regmatch(next,restate)) {
- /*
- * Don't set endp if some later
- * invocation of the same parentheses
- * already has.
- */
- if (restate->regendp[no] == NULL)
- restate->regendp[no] = save;
- return 1;
- } else {
- return 0;
- }
- }
- case BRANCH: {
- register char *save;
-
- if (OP(next) != BRANCH) { /* No choice. */
- next = OPERAND(scan); /* Avoid recursion. */
- } else {
- do {
- save = restate->reginput;
- if (regmatch(OPERAND(scan),restate))
- return(1);
- restate->reginput = save;
- scan = regnext(scan);
- } while (scan != NULL && OP(scan) == BRANCH);
- return 0;
- }
- break;
- }
- case STAR:
- case PLUS: {
- register char nextch;
- register int no;
- register char *save;
- register int min;
-
- /*
- * Lookahead to avoid useless match attempts
- * when we know what character comes next.
- */
- nextch = '\0';
- if (OP(next) == EXACTLY)
- nextch = *OPERAND(next);
- min = (OP(scan) == STAR) ? 0 : 1;
- save = restate->reginput;
- no = regrepeat(OPERAND(scan),restate);
- while (no >= min) {
- /* If it could work, try it. */
- if (nextch == '\0' || *restate->reginput == nextch)
- if (regmatch(next,restate))
- return(1);
- if (nextch != '\0' && no > (min + 1)) {
- char tmp = *(save + no);
- char *p;
- *(save + no) = 0;
- p = strrchr(save, nextch);
- *(save + no) = tmp;
- if (p != NULL)
- no = p - save + 1;
- else
- no = 0;
- }
-
- /* Couldn't or didn't -- back up. */
- no--;
- restate->reginput = save + no;
- }
- return(0);
- }
- case END:
- return(1); /* Success! */
- default:
- if (OP(scan) > OPEN && OP(scan) < OPEN+NSUBEXP) {
- goto doOpen;
- } else if (OP(scan) > CLOSE && OP(scan) < CLOSE+NSUBEXP) {
- goto doClose;
- }
- Expect_TclRegError("memory corruption");
- return 0;
- }
-
- scan = next;
- }
-
- /*
- * We get here only if there's trouble -- normally "case END" is
- * the terminating point.
- */
- Expect_TclRegError("corrupted pointers");
- return(0);
-}
-
-/*
- - regrepeat - repeatedly match something simple, report how many
- */
-static int
-regrepeat(p, restate)
-char *p;
-struct regexec_state *restate;
-{
- register int count = 0;
- register char *scan;
- register char *opnd;
-
- scan = restate->reginput;
- opnd = OPERAND(p);
- switch (OP(p)) {
- case ANY:
- count = strlen(scan);
- scan += count;
- break;
- case EXACTLY:
- while (*opnd == *scan) {
- count++;
- scan++;
- }
- break;
- case ANYOF:
- while (*scan != '\0' && strchr(opnd, *scan) != NULL) {
- count++;
- scan++;
- }
- break;
- case ANYBUT:
- while (*scan != '\0' && strchr(opnd, *scan) == NULL) {
- count++;
- scan++;
- }
- break;
- default: /* Oh dear. Called inappropriately. */
- Expect_TclRegError("internal foulup");
- count = 0; /* Best compromise. */
- break;
- }
- restate->reginput = scan;
-
- return(count);
-}
-
-/*
- - regnext - dig the "next" pointer out of a node
- */
-static char *
-regnext(p)
-register char *p;
-{
- register int offset;
-
- if (p == ®dummy)
- return(NULL);
-
- offset = NEXT(p);
- if (offset == 0)
- return(NULL);
-
- if (OP(p) == BACK)
- return(p-offset);
- else
- return(p+offset);
-}
-
-#ifdef DEBUG
-
-static char *regprop();
-
-/*
- - regdump - dump a regexp onto stdout in vaguely comprehensible form
- */
-void
-regdump(r)
-Expect_regexp *r;
-{
- register char *s;
- register char op = EXACTLY; /* Arbitrary non-END op. */
- register char *next;
-
-
- s = r->program + 1;
- while (op != END) { /* While that wasn't END last time... */
- op = OP(s);
- printf("%2d%s", s-r->program, regprop(s)); /* Where, what. */
- next = regnext(s);
- if (next == NULL) /* Next ptr. */
- printf("(0)");
- else
- printf("(%d)", (s-r->program)+(next-s));
- s += 3;
- if (op == ANYOF || op == ANYBUT || op == EXACTLY) {
- /* Literal string, where present. */
- while (*s != '\0') {
- putchar(*s);
- s++;
- }
- s++;
- }
- putchar('\n');
- }
-
- /* Header fields of interest. */
- if (r->regstart != '\0')
- printf("start `%c' ", r->regstart);
- if (r->reganch)
- printf("anchored ");
- if (r->regmust != NULL)
- printf("must have \"%s\"", r->regmust);
- printf("\n");
-}
-
-/*
- - regprop - printable representation of opcode
- */
-static char *
-regprop(op)
-char *op;
-{
- register char *p;
- static char buf[50];
-
- (void) strcpy(buf, ":");
-
- switch (OP(op)) {
- case BOL:
- p = "BOL";
- break;
- case EOL:
- p = "EOL";
- break;
- case ANY:
- p = "ANY";
- break;
- case ANYOF:
- p = "ANYOF";
- break;
- case ANYBUT:
- p = "ANYBUT";
- break;
- case BRANCH:
- p = "BRANCH";
- break;
- case EXACTLY:
- p = "EXACTLY";
- break;
- case NOTHING:
- p = "NOTHING";
- break;
- case BACK:
- p = "BACK";
- break;
- case END:
- p = "END";
- break;
- case OPEN+1:
- case OPEN+2:
- case OPEN+3:
- case OPEN+4:
- case OPEN+5:
- case OPEN+6:
- case OPEN+7:
- case OPEN+8:
- case OPEN+9:
- sprintf(buf+strlen(buf), "OPEN%d", OP(op)-OPEN);
- p = NULL;
- break;
- case CLOSE+1:
- case CLOSE+2:
- case CLOSE+3:
- case CLOSE+4:
- case CLOSE+5:
- case CLOSE+6:
- case CLOSE+7:
- case CLOSE+8:
- case CLOSE+9:
- sprintf(buf+strlen(buf), "CLOSE%d", OP(op)-CLOSE);
- p = NULL;
- break;
- case STAR:
- p = "STAR";
- break;
- case PLUS:
- p = "PLUS";
- break;
- default:
- if (OP(op) > OPEN && OP(op) < OPEN+NSUBEXP) {
- sprintf(buf+strlen(buf), "OPEN%d", OP(op)-OPEN);
- p = NULL;
- break;
- } else if (OP(op) > CLOSE && OP(op) < CLOSE+NSUBEXP) {
- sprintf(buf+strlen(buf), "CLOSE%d", OP(op)-CLOSE);
- p = NULL;
- } else {
- Expect_TclRegError("corrupted opcode");
- }
- break;
- }
- if (p != NULL)
- (void) strcat(buf, p);
- return(buf);
-}
-#endif
-
-/*
- * The following is provided for those people who do not have strcspn() in
- * their C libraries. They should get off their butts and do something
- * about it; at least one public-domain implementation of those (highly
- * useful) string routines has been published on Usenet.
- */
-#ifdef STRCSPN
-/*
- * strcspn - find length of initial segment of s1 consisting entirely
- * of characters not from s2
- */
-
-static int
-strcspn(s1, s2)
-char *s1;
-char *s2;
-{
- register char *scan1;
- register char *scan2;
- register int count;
-
- count = 0;
- for (scan1 = s1; *scan1 != '\0'; scan1++) {
- for (scan2 = s2; *scan2 != '\0';) /* ++ moved down. */
- if (*scan1 == *scan2++)
- return(count);
- count++;
- }
- return(count);
-}
-#endif
-\f
-/*
- *----------------------------------------------------------------------
- *
- * Expect_TclRegError --
- *
- * This procedure is invoked by the regexp code when an error
- * occurs. It saves the error message so it can be seen by the
- * code that called Spencer's code.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The value of "string" is saved in "errMsg".
- *
- *----------------------------------------------------------------------
- */
-
-void
-Expect_TclRegError(string)
- char *string; /* Error message. */
-{
- errMsg = string;
-}
-
-#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 2
-char *
-TclGetRegError()
-{
- return errMsg;
-}
-#endif
+++ /dev/null
-/*
- * Definitions etc. for regexp(3) routines.
- *
- * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof],
- * not the System V one.
- *
- * RCS: @(#) $Id$
- */
-
-#ifndef _TCL_REGEXP
-#define _TCL_REGEXP 1
-
-/*
- * NSUBEXP must be at least 10, and no greater than 117 or the parser
- * will not work properly.
- */
-
-#define NSUBEXP 20
-
-typedef struct Expect_regexp {
- char *startp[NSUBEXP];
- char *endp[NSUBEXP];
- 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. */
-} Expect_regexp;
-
-EXTERN Expect_regexp *Expect_TclRegComp _ANSI_ARGS_((char *exp));
-EXTERN int Expect_TclRegExec _ANSI_ARGS_((Expect_regexp *prog, char *string, char *start));
-EXTERN void Expect_TclRegSub _ANSI_ARGS_((Expect_regexp *prog, char *source, char *dest));
-EXTERN void Expect_TclRegError _ANSI_ARGS_((char *msg));
-EXTERN char *Expect_TclGetRegError _ANSI_ARGS_((void));
-
-#endif /* TCL_REGEXP */
-
+++ /dev/null
-Expect Test Suite
---------------
-
-This directory contains a set of validation tests for the Expect
-commands. Each of the files whose name ends in ".test" is intended to
-fully exercise one or a few Expect commands. The commands tested by a
-given file are listed in the first line of the file.
-
-You can run the tests in two ways:
- (a) type "make test" in the parent directory to this one; this
- will run all of the tests.
- (b) start up expect in this directory, then "source" the test
- file (for example, type "source parse.test"). To run all
- of the tests, type "source all".
-In either case no output will be generated if all goes well, except
-for a listing of the tests. If there are errors then additional
-messages will appear in the format described below.
-
-The rest of this file provides additional information on the
-features of the testing environment.
-
-This approach to testing (and most of this file) was copied from the
-Tcl distribution.
-
-Definitions file:
------------------
-
-The file "defs" defines a collection of procedures and variables
-used to run the tests. It is read in automatically by each of the
-.test files if needed, but once it has been read once it will not
-be read again by the .test files. If you change defs while running
-tests you'll have to "source" it by hand to load its new contents.
-
-Test output:
-------------
-
-Normally, output only appears when there are errors. However, if
-the variable VERBOSE is set to 1 then tests will be run in "verbose"
-mode and output will be generated for each test regardless of
-whether it succeeded or failed. Test output consists of the
-following information:
-
- - the test identifier (which can be used to locate the test code
- in the .test file)
- - a brief description of the test
- - the contents of the test code
- - the actual results produced by the tests
- - a "PASSED" or "FAILED" message
- - the expected results (if the test failed)
-
-You can set VERBOSE either interactively (after the defs file has been
-read in), or you can change the default value in "defs".
-
-Selecting tests for execution:
-------------------------------
-
-Normally, all the tests in a file are run whenever the file is
-"source"d. However, you can select a specific set of tests using
-the global variable TESTS. This variable contains a pattern; any
-test whose identifier matches TESTS will be run. For example,
-the following interactive command causes all of the "for" tests in
-groups 2 and 4 to be executed:
-
- set TESTS {for-[24]*}
-
-TESTS defaults to *, but you can change the default in "defs" if
-you wish.
-
-Saving keystrokes:
-------------------
-
-A convenience procedure named "dotests" is included in file
-"defs". It takes two arguments--the name of the test file (such
-as "parse.test"), and a pattern selecting the tests you want to
-execute. It sets TESTS to the second argument, calls "source" on
-the file specified in the first argument, and restores TESTS to
-its pre-call value at the end.
-
-Batch vs. interactive execution:
---------------------------------
-
-The tests can be run in either batch or interactive mode. Batch
-mode refers to using I/O redirection from a UNIX shell. For example,
-the following command causes the tests in the file named "parse.test"
-to be executed:
-
- expect < parse.test > parse.test.results
-
-Users who want to execute the tests in this fashion need to first
-ensure that the file "defs" has proper values for the global
-variables that control the testing environment (VERBOSE and TESTS).
+++ /dev/null
-# This file contains a top-level script to run all of the Tcl
-# tests. Execute it by invoking "source all" when running tclTest
-# in this directory.
-#
-
-foreach i [lsort [glob *.test]] {
- puts stdout $i
- source $i
-}
-exit ;# required for DejaGNU, I don't know why - DEL
\ No newline at end of file
+++ /dev/null
-# Commands covered: cat (UNIX)
-#
-# This file contains a collection of tests for one or more of the Tcl
-# built-in commands. Sourcing this file into Tcl runs the tests and
-# generates output for errors. No output means no errors were found.
-
-if {[string compare test [info procs test]] == 1} then {source defs}
-
-#exp_internal -f /dev/ttyp5 0
-
-catch {unset x}
-
-log_user 0
-
-test cat-1.1 {basic cat operation} {
- exp_spawn cat -u
- exp_send "\r"
- set timeout 10
- expect \r {set x 1} timeout {set x 0}
- exp_close
- exp_wait
- set x
-} {1}
-
-#exp_internal 0
-
+++ /dev/null
-# This file contains support code for the Tcl test suite. It is
-# normally sourced by the individual files in the test suite before
-# they run their tests. This improved approach to testing was designed
-# and initially implemented by Mary Ann May-Pumphrey of Sun Microsystems.
-
-if ![info exists VERBOSE] {
- set VERBOSE 0
-}
-set TESTS {}
-set auto_noexec 1
-set auto_noload 1
-catch {rename unknown ""}
-
-# If tests are being run as root, issue a warning message and set a
-# variable to prevent some tests from running at all.
-
-set user {}
-catch {set user [exec whoami]}
-if {$user == "root"} {
- puts stdout "Warning: you're executing as root. I'll have to"
- puts stdout "skip some of the tests, since they'll fail as root."
-}
-
-# Some of the tests don't work on some system configurations due to
-# configuration quirks, not due to Tcl problems; in order to prevent
-# false alarms, these tests are only run in the master source directory
-# at Berkeley. The presence of a file "Berkeley" in this directory is
-# used to indicate that these tests should be run.
-
-set atBerkeley [file exists Berkeley]
-
-proc print_verbose {test_name test_description contents_of_test code answer} {
- puts stdout "\n"
- puts stdout "==== $test_name $test_description"
- puts stdout "==== Contents of test case:"
- puts stdout "$contents_of_test"
- if {$code != 0} {
- if {$code == 1} {
- puts stdout "==== Test generated error:"
- puts stdout $answer
- } elseif {$code == 2} {
- puts stdout "==== Test generated return exception; result was:"
- puts stdout $answer
- } elseif {$code == 3} {
- puts stdout "==== Test generated break exception"
- } elseif {$code == 4} {
- puts stdout "==== Test generated continue exception"
- } else {
- puts stdout "==== Test generated exception $code; message was:"
- puts stdout $answer
- }
- } else {
- puts stdout "==== Result was:"
- puts stdout "$answer"
- }
-}
-
-proc test {test_name test_description contents_of_test passing_results} {
- global VERBOSE
- global TESTS
- if {[string compare $TESTS ""] != 0} then {
- set ok 0
- foreach test $TESTS {
- if [string match $test $test_name] then {
- set ok 1
- break
- }
- }
- if !$ok then return
- }
- set code [catch {uplevel $contents_of_test} answer]
- if {$code != 0} {
- print_verbose $test_name $test_description $contents_of_test \
- $code $answer
- } elseif {[string compare $answer $passing_results] == 0} then {
- if $VERBOSE then {
- print_verbose $test_name $test_description $contents_of_test \
- $code $answer
- puts stdout "++++ $test_name PASSED"
- }
- } else {
- print_verbose $test_name $test_description $contents_of_test $code \
- $answer
- puts stdout "---- Result should have been:"
- puts stdout "$passing_results"
- puts stdout "---- $test_name FAILED"
- }
-}
-
-# stick it in a file, run, and test by looking at output
-proc ftest {test_name test_description contents_of_test passing_results} {
- global VERBOSE
- global TESTS
- global objdir
- if {[string compare $TESTS ""] != 0} then {
- set ok 0
- foreach test $TESTS {
- if [string match $test $test_name] then {
- set ok 1
- break
- }
- }
- if !$ok then return
- }
-
- set file [open /tmp/[pid] w]
- puts $file $contents_of_test
- close $file
-
- set code [catch {exec $objdir/expect /tmp/[pid]} answer]
- if {$code != 0} {
- print_verbose $test_name $test_description $contents_of_test \
- $code $answer
- } elseif {[string compare $answer $passing_results] == 0} then {
- if $VERBOSE then {
- print_verbose $test_name $test_description $contents_of_test \
- $code $answer
- puts stdout "++++ $test_name PASSED"
- }
- } else {
- print_verbose $test_name $test_description $contents_of_test $code \
- $answer
- puts stdout "---- Result should have been:"
- puts stdout "$passing_results"
- puts stdout "---- $test_name FAILED"
- }
- catch {exec rm -f /tmp/[pid]}
-}
-
-proc dotests {file args} {
- global TESTS
- set savedTests $TESTS
- set TESTS $args
- source $file
- set TESTS $savedTests
-}
+++ /dev/null
-# Commands covered: cat (UNIX), expect
-#
-# This file contains a collection of tests for one or more of the Tcl
-# built-in commands. Sourcing this file into Tcl runs the tests and
-# generates output for errors. No output means no errors were found.
-
-if {[string compare test [info procs test]] == 1} then {source defs}
-
-catch {unset x}
-
-log_user 0
-
-exp_spawn cat -u
-exp_stty -echo < $spawn_out(slave,name)
-
-test expect-1.1 {exact pattern} {
- expect "*"
- exp_send "a\r"
-
- set timeout 10
- set x 0
- expect -ex a {set x 1}
- set x
-} {1}
-
-test expect-1.2 {exact pattern buffering} {
- expect "*"
- exp_send "hiahi\r"
-
- set timeout 10
- set x 0
- expect -ex hi
- expect -ex hi {set x 1}
- set x
-} {1}
-
-# if only this test fails, then configure has guessed incorrectly and
-# stty accesses the control terminal from stdout. The quick fix is
-# to edit expect_cf.h and define STTY_READS_STDOUT to 1. (It should
-# be commented out.) If you figure out a way to fix the configure test,
-# let me know. Else, let me know a way to test for your particular
-# machine and os version so it can be hardwired.
-test expect-1.3 {exact pattern failure} {
- expect "*"
- exp_send "hiahi\r"
-
- set timeout 10
- set x 0
- expect -ex hi {set x 1}
- expect -ex hi {set x 2}
- expect -ex hi {set x 3}
- set x
-} {2}
-
-test expect-1.4 {glob pattern} {
- expect "*"
- exp_send "a\r"
-
- set timeout 10
- set x 0
- expect "a" {set x 1}
- set x
-} {1}
-
-test expect-1.5 {glob pattern buffering} {
- expect "*"
- exp_send "a\r"
-
- set timeout 10
- set x 0
- expect "*" {set x 1}
- set x
-} {1}
-
-test expect-1.6 {glob buffer} {
- expect "*"
- exp_send "philosophic\r"
-
- set timeout 10
- set x 0
- expect "hi"
- set x [string match *phi $expect_out(buffer)]
-} {1}
-
-test expect-1.7 {glob string} {
- expect "*"
- exp_send "philosophic\r"
-
- set timeout 10
- set x 0
- expect "hi"
- set expect_out(0,string)
-} {hi}
-
-close
-wait
+++ /dev/null
-# Commands covered: pid
-#
-# This file contains a collection of tests for one or more of the Tcl
-# built-in commands. Sourcing this file into Tcl runs the tests and
-# generates output for errors. No output means no errors were found.
-
-if {[string compare test [info procs test]] == 1} then {source defs}
-
-catch {unset x}
-
-#exp_internal -f /dev/ttyp5 0
-
-test pid-1.2 {basic pid operation} {
- set cat [exp_spawn -noecho cat]
- set x [expr 0!=$cat]
- set y [expr 0==[string compare $cat [exp_pid -i $spawn_id]]]
- exp_close;exp_wait
- list $x $y
-} {1 1}
-
-test pid-1.3 {basic pid operation} {
- exp_spawn -noecho cat; set cat $spawn_id
- exp_spawn -noecho cat; set cat2 $spawn_id
- set x [expr {0!=[string compare [exp_pid -i $cat2] [exp_pid -i $cat]]}]
- exp_close -i $cat;exp_wait -i $cat;exp_close -i $cat2;exp_wait -i $cat2
- set x
-} {1}
-
-test pid-1.4 {basic pid operation} {
- list [catch {exp_pid -i 100} msg] $msg
-} {1 {exp_pid: invalid spawn id (100)}}
-
-test pid-1.5 {basic pid operation} {
- list [catch {exp_pid -j} msg] $msg
-} {1 {usage: -i spawn_id}}
-
+++ /dev/null
-# Commands covered: spawn
-#
-# This file contains a collection of tests for one or more of the Tcl
-# built-in commands. Sourcing this file into Tcl runs the tests and
-# generates output for errors. No output means no errors were found.
-
-if {[string compare test [info procs test]] == 1} then {source defs}
-
-log_user 0
-
-#exp_internal -f /dev/ttyp5 0
-
-test spawn-1.1 {basic spawn operation} {
- set x [catch {exp_spawn cat}]
- set first_spawn_id $spawn_id; # save for later test
- exp_close;exp_wait
- set x
-} {0}
-
-test spawn-1.2 {spawn cat, then simple send/expect sequence} {
- set cat [exp_spawn -noecho cat -u]
- exp_send "a\r"
- expect "a" {set x 1} timeout {set x 0}
- exp_close;exp_wait
- set x
-} {1}
-
-test spawn-1.3 {spawn two processes simultaneously} {
- exp_spawn -noecho cat; set cat $spawn_id
- exp_spawn -noecho cat; set cat2 $spawn_id
- set x [expr {0!=[string compare [exp_pid -i $cat2] [exp_pid -i $cat]]}]
- exp_close -i $cat;exp_wait -i $cat;exp_close -i $cat2;exp_wait -i $cat2
- set x
-} {1}
-
-test spawn-1.4 {spawn open file} {
- set x 0
- set y 0
-
- set file [open /tmp/[pid] w]
- puts $file "testing expect's spawn -open"
- exp_close $file
- set pid [exp_spawn -open [open /tmp/[pid]]]
- expect "testing expect's spawn -open" {set x 1}
- expect eof {set y 1}
- exec rm /tmp/[pid]
- exp_wait
- list $x $y $pid
-} {1 1 0}
-
-test spawn-1.5 {spawn with no fd leak} {
- exp_spawn cat
- set x [expr $first_spawn_id==$spawn_id]
- exp_close; exp_wait
- set x
-} {1}
-
-# looks to be some control-char problem
-#ftest spawn-1.6 {spawn with echo} {
-# exp_spawn cat
-#} {spawn cat}
-
-#ftest spawn-1.7 {spawn with -noecho} {
-# exp_spawn -noecho cat
-#} {}
+++ /dev/null
-# Commands covered: stty
-#
-# This file contains a collection of tests for one or more of the Tcl
-# built-in commands. Sourcing this file into Tcl runs the tests and
-# generates output for errors. No output means no errors were found.
-
-if {[string compare test [info procs test]] == 1} then {source defs}
-
-#exp_internal -f /dev/ttyp5 0
-
-catch {unset x}
-
-log_user 0
-
-test stty-1.1 {basic stty operation} {
- exp_spawn cat -u
- catch {exp_stty < $spawn_out(slave,name)}
-} {0}
-
-test stty-1.2 {basic stty operation} {
- exp_spawn cat -u
- catch {exp_stty -echo < $spawn_out(slave,name)}
-} {0}
-
-#exp_internal 0
-
+++ /dev/null
-Thu Mar 26 22:17:45 1998 Felix Lee <flee@cygnus.como>
-
- * configure.in: sinclude(../aclocal.m4)
- * configure: rebuilt
-
-Tue Mar 24 16:21:05 1998 Stu Grossman <grossman@bhuna.cygnus.co.uk>
-
- * configure: Regenerate with autoconf 2.12.1 to fix shell issues for
- NT native builds.
-
-Sun Dec 28 11:05:45 1997 Jeffrey A Law (law@cygnus.com)
-
- * Makefile.in: Change "gxx_includedir" to "gxx_include_dir".
-
-Wed Sep 4 15:55:40 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * expect.tests/expect-tests.exp: Use regexp submatches, not
- lindex, to extract test names.
-
-Mon Aug 26 12:07:17 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * configure: Rebuilt.
-
- * Makefile.in (configure): --localdir is always "..".
-
-Fri Aug 23 15:55:37 1996 Tom Tromey <tromey@creche.cygnus.com>
-
- * Makefile.in (.PHONY): New target.
-
-Fri Aug 23 13:45:41 1996 Doug Evans <dje@canuck.cygnus.com>
-
- * Makefile.in (configure): Delete dependencies.
-
-Mon Feb 22 07:54:03 1993 Mike Werner (mtw@poseidon.cygnus.com)
-
- * expect/testsuite: made modifications to testcases, etc., to allow
- them to work properly given the reorganization of deja-gnu and the
- relocation of the testcases from deja-gnu to a "tool" subdirectory.
-
-Sun Feb 21 10:55:55 1993 Mike Werner (mtw@poseidon.cygnus.com)
-
- * expect/testsuite: Initial creation of expect/testsuite.
- Migrated dejagnu testcases and support files for testing nm to
- expect/testsuite from deja-gnu. These files were moved "as is"
- with no modifications. This migration is part of a major overhaul
- of dejagnu. The modifications to these testcases, etc., which
- will allow them to work with the new version of dejagnu will be
- made in a future update.
-
+++ /dev/null
-VPATH = @srcdir@
-srcdir = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-host = @host@
-bindir = @bindir@
-libdir = @libdir@
-tooldir = $(libdir)/$(target_alias)
-
-includedir = @includedir@
-gxx_include_dir = $(tooldir)/g++-include
-targetdir = $(datadir)/$(target_alias)
-
-SHELL = /bin/sh
-
-CC = @CC@
-TCLHDIR = @TCLHDIR@
-
-CC_FOR_TARGET = ` \
- if [ -f $${rootme}../gcc/Makefile ] ; then \
- echo $${rootme}../gcc/xgcc -B$${rootme}../gcc/; \
- else \
- if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
- echo $(CC); \
- else \
- t='$(program_transform_name)'; echo gcc | sed -e '' $$t; \
- fi; \
- fi`
-
-EXPECT = `if [ -f $${rootme}/expect ] ; \
- then echo $${rootme}/expect ; \
- else echo expect; fi`
-
-RUNTEST = ` \
- if [ -f ${srcdir}/../../dejagnu/runtest ] ; then \
- echo ${srcdir}/../../dejagnu/runtest ; \
- else echo runtest ; fi`
-RUNTESTFLAGS =
-
-all:
-
-.PHONY: info install-info check installcheck
-info:
-install-info:
-check:
-installcheck:
-.NOEXPORT:
-
-check: exp_test site.exp
- rootme=`cd .. && pwd`; export rootme; \
- EXPECT=${EXPECT}; export EXPECT; \
- if [ -f ../expect ] ; then \
- TCL_LIBRARY=`echo ${TCLHDIR} | sed -e 's/-I//' -e 's/generic//'`/library ; \
- export TCL_LIBRARY ; \
- else true ; fi ; \
- $(RUNTEST) $(RUNTESTFLAGS) --tool expect EXPECT=$$EXPECT --srcdir $(srcdir)
-
-install:
-uninstall: force
-
-exp_test.o: ${srcdir}/exp_test.c
-
-site.exp: ./config.status
- @echo "Making a new config file..."
- -@rm -f ./tmp?
- @touch site.exp
- -@mv site.exp site.bak
- @echo "## these variables are automatically generated by make ##" > ./tmp0
- @echo "# Do not edit here. If you wish to override these values" >> ./tmp0
- @echo "# add them to the last section" >> ./tmp0
- @echo "set tool expect" >> ./tmp0
- @echo "set srcdir ${srcdir}" >> ./tmp0
- @echo "set objdir `pwd`" >> ./tmp0
- @echo "set host_triplet ${host}" >> ./tmp0
- @echo "## All variables above are generated by configure. Do Not Edit ##" >> ./tmp0
- @cat ./tmp0 > site.exp
- @cat site.bak | sed \
- -e '1,/^## All variables above are.*##/ d' >> site.exp
- @rm -f ./tmp1 ./tmp0
-
-clean mostlyclean:
- -rm -f *~ core *.o a.out *.x
-
-distclean realclean: clean
- -rm -f *~ core
- -rm -f Makefile config.status
- -rm -fr *.log summary detail
-
-Makefile : $(srcdir)/Makefile.in $(host_makefile_frag)
- $(SHELL) ./config.status
-
-# Original aclocal.m4 comes from DejaGnu
-# CYGNUS LOCAL: this hack lets "make -f Makefile.in" produce a configure file
-.PHONY: configure
-configure:
- @echo "Rebuilding configure..."
- (cd ${srcdir}; autoconf --localdir=..)
-
-config.status: $(srcdir)/configure
- @echo "Rebuilding config.status..."
- $(SHELL) ./config.status --recheck
-
-force:
+++ /dev/null
-# Copyright (C) 1988, 1990, 1991, 1992, 1996, 1997 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-# Please email any bugs, comments, and/or additions to this file to:
-# bug-dejagnu@prep.ai.mit.edu
-
-# This file was written by Rob Savoye. (rob@cygnus.com)
-
-global EXPECT
-if ![info exists EXPECT] then {
- set EXPECT $objdir/expect
-}
-
-set eprompt "expect\[0-9.\-\]*> "
-global eprompt
-
-#
-# expect_version -- extract and print the version number of expect
-#
-proc expect_version { } {
- global EXPECT
-
- catch {exec echo "puts \[exp_version\]\n" | $EXPECT} version
- if [info exists version] then {
- clone_output "[which $EXPECT] version is $version\n"
- unset version
-}
-}
-
-#
-# expect_exit -- exit the test driver for expect
-#
-proc expect_exit {} {
-}
-
-#
-# expect_start -- start expect
-#
-proc expect_start { } {
- global spawn_id
- global srcdir
- global EXPECT
- global eprompt
- global objdir
-
- set defs "$srcdir/../tests/defs"
-
- if {[which $EXPECT] != 0} then {
- spawn $EXPECT
- } else {
- error "Can't find $EXPECT"
- }
-
- expect {
- -re "expect.*> " {
- verbose "Started the child expect shell"
- }
- timeout {
- error "Timed out starting the child expect shell."
- }
- }
-
- exp_send "set objdir $objdir\r"
- verbose "Sourcing $defs..."
- exp_send "source $defs\r"
- expect {
- -re ".*source $defs.*$" {
- verbose "Sourced $defs"
- }
- "Error: couldn't read file*" {
- error "Couldn't source $defs"
- return -1
- }
- -re "$eprompt" {
- verbose "Got prompt, sourced $defs"
- }
- timeout {
- error "Timed out sourcing $defs."
- return 1
- }
- }
-
- sleep 2
- exp_send "set VERBOSE 1\r"
- expect {
- -re "set VERBOSE 1\[\r\n\]*1\[\r\n\]*$eprompt" {
- verbose "Set verbose flag for tests"
- }
- timeout {
- perror "Timed out setting verbose flag."
- }
- }
- return $spawn_id
-}
+++ /dev/null
-#! /bin/sh
-
-# Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.13
-# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
-#
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-
-# Defaults:
-ac_help=
-ac_default_prefix=/usr/local
-# Any additions from configure.in:
-ac_help="$ac_help
- --with-tclconfig directory containing tcl configuration (tclConfig.sh)"
-ac_help="$ac_help
- --with-tclinclude directory where tcl private headers are"
-
-# Initialize some variables set by options.
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-build=NONE
-cache_file=./config.cache
-exec_prefix=NONE
-host=NONE
-no_create=
-nonopt=NONE
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-target=NONE
-verbose=
-x_includes=NONE
-x_libraries=NONE
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datadir='${prefix}/share'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-libdir='${exec_prefix}/lib'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-infodir='${prefix}/info'
-mandir='${prefix}/man'
-
-# Initialize some other variables.
-subdirs=
-MFLAGS= MAKEFLAGS=
-SHELL=${CONFIG_SHELL-/bin/sh}
-# Maximum number of lines to put in a shell here document.
-ac_max_here_lines=12
-
-ac_prev=
-for ac_option
-do
-
- # If the previous option needs an argument, assign it.
- if test -n "$ac_prev"; then
- eval "$ac_prev=\$ac_option"
- ac_prev=
- continue
- fi
-
- case "$ac_option" in
- -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
- *) ac_optarg= ;;
- esac
-
- # Accept the important Cygnus configure options, so we can diagnose typos.
-
- case "$ac_option" in
-
- -bindir | --bindir | --bindi | --bind | --bin | --bi)
- ac_prev=bindir ;;
- -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
- bindir="$ac_optarg" ;;
-
- -build | --build | --buil | --bui | --bu)
- ac_prev=build ;;
- -build=* | --build=* | --buil=* | --bui=* | --bu=*)
- build="$ac_optarg" ;;
-
- -cache-file | --cache-file | --cache-fil | --cache-fi \
- | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
- ac_prev=cache_file ;;
- -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
- | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
- cache_file="$ac_optarg" ;;
-
- -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
- ac_prev=datadir ;;
- -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
- | --da=*)
- datadir="$ac_optarg" ;;
-
- -disable-* | --disable-*)
- ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
- fi
- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
- eval "enable_${ac_feature}=no" ;;
-
- -enable-* | --enable-*)
- ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
- { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
- fi
- ac_feature=`echo $ac_feature| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes ;;
- esac
- eval "enable_${ac_feature}='$ac_optarg'" ;;
-
- -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
- | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
- | --exec | --exe | --ex)
- ac_prev=exec_prefix ;;
- -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
- | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
- | --exec=* | --exe=* | --ex=*)
- exec_prefix="$ac_optarg" ;;
-
- -gas | --gas | --ga | --g)
- # Obsolete; use --with-gas.
- with_gas=yes ;;
-
- -help | --help | --hel | --he)
- # Omit some internal or obsolete options to make the list less imposing.
- # This message is too long to be a string in the A/UX 3.1 sh.
- cat << EOF
-Usage: configure [options] [host]
-Options: [defaults in brackets after descriptions]
-Configuration:
- --cache-file=FILE cache test results in FILE
- --help print this message
- --no-create do not create output files
- --quiet, --silent do not print \`checking...' messages
- --version print the version of autoconf that created configure
-Directory and file names:
- --prefix=PREFIX install architecture-independent files in PREFIX
- [$ac_default_prefix]
- --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
- [same as prefix]
- --bindir=DIR user executables in DIR [EPREFIX/bin]
- --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
- --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
- --datadir=DIR read-only architecture-independent data in DIR
- [PREFIX/share]
- --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
- --sharedstatedir=DIR modifiable architecture-independent data in DIR
- [PREFIX/com]
- --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
- --libdir=DIR object code libraries in DIR [EPREFIX/lib]
- --includedir=DIR C header files in DIR [PREFIX/include]
- --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
- --infodir=DIR info documentation in DIR [PREFIX/info]
- --mandir=DIR man documentation in DIR [PREFIX/man]
- --srcdir=DIR find the sources in DIR [configure dir or ..]
- --program-prefix=PREFIX prepend PREFIX to installed program names
- --program-suffix=SUFFIX append SUFFIX to installed program names
- --program-transform-name=PROGRAM
- run sed PROGRAM on installed program names
-EOF
- cat << EOF
-Host type:
- --build=BUILD configure for building on BUILD [BUILD=HOST]
- --host=HOST configure for HOST [guessed]
- --target=TARGET configure for TARGET [TARGET=HOST]
-Features and packages:
- --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
- --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
- --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
- --x-includes=DIR X include files are in DIR
- --x-libraries=DIR X library files are in DIR
-EOF
- if test -n "$ac_help"; then
- echo "--enable and --with options recognized:$ac_help"
- fi
- exit 0 ;;
-
- -host | --host | --hos | --ho)
- ac_prev=host ;;
- -host=* | --host=* | --hos=* | --ho=*)
- host="$ac_optarg" ;;
-
- -includedir | --includedir | --includedi | --included | --include \
- | --includ | --inclu | --incl | --inc)
- ac_prev=includedir ;;
- -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
- | --includ=* | --inclu=* | --incl=* | --inc=*)
- includedir="$ac_optarg" ;;
-
- -infodir | --infodir | --infodi | --infod | --info | --inf)
- ac_prev=infodir ;;
- -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
- infodir="$ac_optarg" ;;
-
- -libdir | --libdir | --libdi | --libd)
- ac_prev=libdir ;;
- -libdir=* | --libdir=* | --libdi=* | --libd=*)
- libdir="$ac_optarg" ;;
-
- -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
- | --libexe | --libex | --libe)
- ac_prev=libexecdir ;;
- -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
- | --libexe=* | --libex=* | --libe=*)
- libexecdir="$ac_optarg" ;;
-
- -localstatedir | --localstatedir | --localstatedi | --localstated \
- | --localstate | --localstat | --localsta | --localst \
- | --locals | --local | --loca | --loc | --lo)
- ac_prev=localstatedir ;;
- -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
- | --localstate=* | --localstat=* | --localsta=* | --localst=* \
- | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
- localstatedir="$ac_optarg" ;;
-
- -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
- ac_prev=mandir ;;
- -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
- mandir="$ac_optarg" ;;
-
- -nfp | --nfp | --nf)
- # Obsolete; use --without-fp.
- with_fp=no ;;
-
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c)
- no_create=yes ;;
-
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
- no_recursion=yes ;;
-
- -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
- | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
- | --oldin | --oldi | --old | --ol | --o)
- ac_prev=oldincludedir ;;
- -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
- | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
- | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
- oldincludedir="$ac_optarg" ;;
-
- -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
- ac_prev=prefix ;;
- -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
- prefix="$ac_optarg" ;;
-
- -program-prefix | --program-prefix | --program-prefi | --program-pref \
- | --program-pre | --program-pr | --program-p)
- ac_prev=program_prefix ;;
- -program-prefix=* | --program-prefix=* | --program-prefi=* \
- | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
- program_prefix="$ac_optarg" ;;
-
- -program-suffix | --program-suffix | --program-suffi | --program-suff \
- | --program-suf | --program-su | --program-s)
- ac_prev=program_suffix ;;
- -program-suffix=* | --program-suffix=* | --program-suffi=* \
- | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
- program_suffix="$ac_optarg" ;;
-
- -program-transform-name | --program-transform-name \
- | --program-transform-nam | --program-transform-na \
- | --program-transform-n | --program-transform- \
- | --program-transform | --program-transfor \
- | --program-transfo | --program-transf \
- | --program-trans | --program-tran \
- | --progr-tra | --program-tr | --program-t)
- ac_prev=program_transform_name ;;
- -program-transform-name=* | --program-transform-name=* \
- | --program-transform-nam=* | --program-transform-na=* \
- | --program-transform-n=* | --program-transform-=* \
- | --program-transform=* | --program-transfor=* \
- | --program-transfo=* | --program-transf=* \
- | --program-trans=* | --program-tran=* \
- | --progr-tra=* | --program-tr=* | --program-t=*)
- program_transform_name="$ac_optarg" ;;
-
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- silent=yes ;;
-
- -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
- ac_prev=sbindir ;;
- -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
- | --sbi=* | --sb=*)
- sbindir="$ac_optarg" ;;
-
- -sharedstatedir | --sharedstatedir | --sharedstatedi \
- | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
- | --sharedst | --shareds | --shared | --share | --shar \
- | --sha | --sh)
- ac_prev=sharedstatedir ;;
- -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
- | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
- | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
- | --sha=* | --sh=*)
- sharedstatedir="$ac_optarg" ;;
-
- -site | --site | --sit)
- ac_prev=site ;;
- -site=* | --site=* | --sit=*)
- site="$ac_optarg" ;;
-
- -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
- ac_prev=srcdir ;;
- -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
- srcdir="$ac_optarg" ;;
-
- -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
- | --syscon | --sysco | --sysc | --sys | --sy)
- ac_prev=sysconfdir ;;
- -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
- | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
- sysconfdir="$ac_optarg" ;;
-
- -target | --target | --targe | --targ | --tar | --ta | --t)
- ac_prev=target ;;
- -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
- target="$ac_optarg" ;;
-
- -v | -verbose | --verbose | --verbos | --verbo | --verb)
- verbose=yes ;;
-
- -version | --version | --versio | --versi | --vers)
- echo "configure generated by autoconf version 2.13"
- exit 0 ;;
-
- -with-* | --with-*)
- ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
- fi
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- case "$ac_option" in
- *=*) ;;
- *) ac_optarg=yes ;;
- esac
- eval "with_${ac_package}='$ac_optarg'" ;;
-
- -without-* | --without-*)
- ac_package=`echo $ac_option|sed -e 's/-*without-//'`
- # Reject names that are not valid shell variable names.
- if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
- { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
- fi
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- eval "with_${ac_package}=no" ;;
-
- --x)
- # Obsolete; use --with-x.
- with_x=yes ;;
-
- -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
- | --x-incl | --x-inc | --x-in | --x-i)
- ac_prev=x_includes ;;
- -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
- | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
- x_includes="$ac_optarg" ;;
-
- -x-libraries | --x-libraries | --x-librarie | --x-librari \
- | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
- ac_prev=x_libraries ;;
- -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
- | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
- x_libraries="$ac_optarg" ;;
-
- -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
- ;;
-
- *)
- if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
- echo "configure: warning: $ac_option: invalid host type" 1>&2
- fi
- if test "x$nonopt" != xNONE; then
- { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
- fi
- nonopt="$ac_option"
- ;;
-
- esac
-done
-
-if test -n "$ac_prev"; then
- { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
-fi
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-# File descriptor usage:
-# 0 standard input
-# 1 file creation
-# 2 errors and warnings
-# 3 some systems may open it to /dev/tty
-# 4 used on the Kubota Titan
-# 6 checking for... messages and results
-# 5 compiler messages saved in config.log
-if test "$silent" = yes; then
- exec 6>/dev/null
-else
- exec 6>&1
-fi
-exec 5>./config.log
-
-echo "\
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-" 1>&5
-
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Also quote any args containing shell metacharacters.
-ac_configure_args=
-for ac_arg
-do
- case "$ac_arg" in
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c) ;;
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
- ac_configure_args="$ac_configure_args '$ac_arg'" ;;
- *) ac_configure_args="$ac_configure_args $ac_arg" ;;
- esac
-done
-
-# NLS nuisances.
-# Only set these to C if already set. These must not be set unconditionally
-# because not all systems understand e.g. LANG=C (notably SCO).
-# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
-# Non-C LC_CTYPE values break the ctype check.
-if test "${LANG+set}" = set; then LANG=C; export LANG; fi
-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
-if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
-if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -rf conftest* confdefs.h
-# AIX cpp loses on an empty file, so make sure it contains at least a newline.
-echo > confdefs.h
-
-# A filename unique to this package, relative to the directory that
-# configure is in, which we can look for to find out if srcdir is correct.
-ac_unique_file=exp_test.c
-
-# Find the source files, if location was not specified.
-if test -z "$srcdir"; then
- ac_srcdir_defaulted=yes
- # Try the directory containing this script, then its parent.
- ac_prog=$0
- ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
- test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
- srcdir=$ac_confdir
- if test ! -r $srcdir/$ac_unique_file; then
- srcdir=..
- fi
-else
- ac_srcdir_defaulted=no
-fi
-if test ! -r $srcdir/$ac_unique_file; then
- if test "$ac_srcdir_defaulted" = yes; then
- { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
- else
- { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
- fi
-fi
-srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
-
-# Prefer explicitly selected file to automatically selected ones.
-if test -z "$CONFIG_SITE"; then
- if test "x$prefix" != xNONE; then
- CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
- else
- CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
- fi
-fi
-for ac_site_file in $CONFIG_SITE; do
- if test -r "$ac_site_file"; then
- echo "loading site script $ac_site_file"
- . "$ac_site_file"
- fi
-done
-
-if test -r "$cache_file"; then
- echo "loading cache $cache_file"
- . $cache_file
-else
- echo "creating cache $cache_file"
- > $cache_file
-fi
-
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-ac_exeext=
-ac_objext=o
-if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
- # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
- if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
- ac_n= ac_c='
-' ac_t=' '
- else
- ac_n=-n ac_c= ac_t=
- fi
-else
- ac_n= ac_c='\c' ac_t=
-fi
-
-
-
-
-#
-# Ok, lets find the tcl configuration
-# First, look for one uninstalled.
-# the alternative search directory is invoked by --with-tclconfig
-#
-
-if test x"${no_tcl}" = x ; then
- # we reset no_tcl in case something fails here
- no_tcl=true
- # Check whether --with-tclconfig or --without-tclconfig was given.
-if test "${with_tclconfig+set}" = set; then
- withval="$with_tclconfig"
- with_tclconfig=${withval}
-fi
-
- echo $ac_n "checking for Tcl configuration""... $ac_c" 1>&6
-echo "configure:547: checking for Tcl configuration" >&5
- if eval "test \"`echo '$''{'ac_cv_c_tclconfig'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
-
-
- # First check to see if --with-tclconfig was specified.
- if test x"${with_tclconfig}" != x ; then
- if test -f "${with_tclconfig}/tclConfig.sh" ; then
- ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
- else
- { echo "configure: error: ${with_tclconfig} directory doesn't contain tclConfig.sh" 1>&2; exit 1; }
- fi
- fi
-
- # then check for a private Tcl installation
-
- if test x"${ac_cv_c_tclconfig}" = x ; then
- for i in \
- ../tcl \
- `ls -dr ../tcl[7-9].[0-9] 2>/dev/null` \
- ../../tcl \
- `ls -dr ../../tcl[7-9].[0-9] 2>/dev/null` \
- ../../../tcl \
- `ls -dr ../../../tcl[7-9].[0-9] 2>/dev/null` ; do
- if test -f "$i/unix/tclConfig.sh" ; then
- ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
- break
- fi
- if test -f "$i/win/tclConfig.sh" ; then
- ac_cv_c_tclconfig=`(cd $i/win; pwd)`
- break
- fi
- done
- fi
-
- # check in a few common install locations
- if test x"${ac_cv_c_tclconfig}" = x ; then
- for i in `ls -d ${prefix}/lib /usr/local/lib 2>/dev/null` ; do
- if test -f "$i/tclConfig.sh" ; then
- ac_cv_c_tclconfig=`(cd $i; pwd)`
- break
- fi
- done
- fi
- # check in a few other private locations
-
- if test x"${ac_cv_c_tclconfig}" = x ; then
- for i in \
- ${srcdir}/../tcl \
- `ls -dr ${srcdir}/../tcl[7-9].[0-9] 2>/dev/null` ; do
- if test -f "$i/unix/tclConfig.sh" ; then
- ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
- break
- fi
- done
- fi
-
-
-fi
-
- if test x"${ac_cv_c_tclconfig}" = x ; then
- TCLCONFIG="# no Tcl configs found"
- echo "configure: warning: Can't find Tcl configuration definitions" 1>&2
- else
- no_tcl=
- TCLCONFIG=${ac_cv_c_tclconfig}/tclConfig.sh
- echo "$ac_t""found $TCLCONFIG" 1>&6
- fi
-fi
-
-
- . $TCLCONFIG
-
-
-
-
-
-
-
-
-# Tcl defines TCL_SHLIB_SUFFIX but TCL_SHARED_LIB_SUFFIX then looks for it
-# as just SHLIB_SUFFIX. How bizarre.
- SHLIB_SUFFIX=$TCL_SHLIB_SUFFIX
-
-
-
-
-
-
-
-
-
-
-
-
-CC=$TCL_CC
-
-# Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:648: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_dummy="$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_CC="gcc"
- break
- fi
- done
- IFS="$ac_save_ifs"
-fi
-fi
-CC="$ac_cv_prog_CC"
-if test -n "$CC"; then
- echo "$ac_t""$CC" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
-if test -z "$CC"; then
- # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:678: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_prog_rejected=no
- ac_dummy="$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
- ac_prog_rejected=yes
- continue
- fi
- ac_cv_prog_CC="cc"
- break
- fi
- done
- IFS="$ac_save_ifs"
-if test $ac_prog_rejected = yes; then
- # We found a bogon in the path, so make sure we never use it.
- set dummy $ac_cv_prog_CC
- shift
- if test $# -gt 0; then
- # We chose a different compiler from the bogus one.
- # However, it has the same basename, so the bogon will be chosen
- # first if we set CC to just the basename; use the full file name.
- shift
- set dummy "$ac_dir/$ac_word" "$@"
- shift
- ac_cv_prog_CC="$@"
- fi
-fi
-fi
-fi
-CC="$ac_cv_prog_CC"
-if test -n "$CC"; then
- echo "$ac_t""$CC" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
-
- if test -z "$CC"; then
- case "`uname -s`" in
- *win32* | *WIN32*)
- # Extract the first word of "cl", so it can be a program name with args.
-set dummy cl; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:729: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_dummy="$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$ac_word; then
- ac_cv_prog_CC="cl"
- break
- fi
- done
- IFS="$ac_save_ifs"
-fi
-fi
-CC="$ac_cv_prog_CC"
-if test -n "$CC"; then
- echo "$ac_t""$CC" 1>&6
-else
- echo "$ac_t""no" 1>&6
-fi
- ;;
- esac
- fi
- test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
-fi
-
-echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:761: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
-
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-cat > conftest.$ac_ext << EOF
-
-#line 772 "configure"
-#include "confdefs.h"
-
-main(){return(0);}
-EOF
-if { (eval echo configure:777: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- ac_cv_prog_cc_works=yes
- # If we can't run a trivial program, we are probably using a cross compiler.
- if (./conftest; exit) 2>/dev/null; then
- ac_cv_prog_cc_cross=no
- else
- ac_cv_prog_cc_cross=yes
- fi
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- ac_cv_prog_cc_works=no
-fi
-rm -fr conftest*
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
-if test $ac_cv_prog_cc_works = no; then
- { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
-fi
-echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:803: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
-echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
-cross_compiling=$ac_cv_prog_cc_cross
-
-echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:808: checking whether we are using GNU C" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.c <<EOF
-#ifdef __GNUC__
- yes;
-#endif
-EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:817: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
- ac_cv_prog_gcc=yes
-else
- ac_cv_prog_gcc=no
-fi
-fi
-
-echo "$ac_t""$ac_cv_prog_gcc" 1>&6
-
-if test $ac_cv_prog_gcc = yes; then
- GCC=yes
-else
- GCC=
-fi
-
-ac_test_CFLAGS="${CFLAGS+set}"
-ac_save_CFLAGS="$CFLAGS"
-CFLAGS=
-echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:836: checking whether ${CC-cc} accepts -g" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- echo 'void f(){}' > conftest.c
-if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
- ac_cv_prog_cc_g=yes
-else
- ac_cv_prog_cc_g=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
-if test "$ac_test_CFLAGS" = set; then
- CFLAGS="$ac_save_CFLAGS"
-elif test $ac_cv_prog_cc_g = yes; then
- if test "$GCC" = yes; then
- CFLAGS="-g -O2"
- else
- CFLAGS="-g"
- fi
-else
- if test "$GCC" = yes; then
- CFLAGS="-O2"
- else
- CFLAGS=
- fi
-fi
-
-# If we cannot compile and link a trivial program, we can't expect anything to work
-echo $ac_n "checking whether the compiler ($CC) actually works""... $ac_c" 1>&6
-echo "configure:869: checking whether the compiler ($CC) actually works" >&5
-cat > conftest.$ac_ext <<EOF
-#line 871 "configure"
-#include "confdefs.h"
-
-int main() {
-/* don't need anything here */
-; return 0; }
-EOF
-if { (eval echo configure:878: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- c_compiles=yes
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- c_compiles=no
-fi
-rm -f conftest*
-
-cat > conftest.$ac_ext <<EOF
-#line 890 "configure"
-#include "confdefs.h"
-
-int main() {
-/* don't need anything here */
-; return 0; }
-EOF
-if { (eval echo configure:897: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- c_links=yes
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- c_links=no
-fi
-rm -f conftest*
-
-if test x"${c_compiles}" = x"no" ; then
- { echo "configure: error: the native compiler is broken and won't compile." 1>&2; exit 1; }
-fi
-
-if test x"${c_links}" = x"no" ; then
- { echo "configure: error: the native compiler is broken and won't link." 1>&2; exit 1; }
-fi
-echo "$ac_t""yes" 1>&6
-
-
-# This is for LynxOS, which needs a flag to force true POSIX when
-# building. It's weirder than that, cause the flag varies depending
-# how old the compiler is. So...
-# -X is for the old "cc" and "gcc" (based on 1.42)
-# -mposix is for the new gcc (at least 2.5.8)
-# This modifies the value of $CC to have the POSIX flag added
-# so it'll configure correctly
-echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:926: checking how to run the C preprocessor" >&5
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
- CPP=
-fi
-if test -z "$CPP"; then
-if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- # This must be in double quotes, not single quotes, because CPP may get
- # substituted into the Makefile and "${CC-cc}" will confuse make.
- CPP="${CC-cc} -E"
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp.
- cat > conftest.$ac_ext <<EOF
-#line 941 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:947: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- CPP="${CC-cc} -E -traditional-cpp"
- cat > conftest.$ac_ext <<EOF
-#line 958 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:964: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- CPP="${CC-cc} -nologo -E"
- cat > conftest.$ac_ext <<EOF
-#line 975 "configure"
-#include "confdefs.h"
-#include <assert.h>
-Syntax Error
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:981: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- :
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- CPP=/lib/cpp
-fi
-rm -f conftest*
-fi
-rm -f conftest*
-fi
-rm -f conftest*
- ac_cv_prog_CPP="$CPP"
-fi
- CPP="$ac_cv_prog_CPP"
-else
- ac_cv_prog_CPP="$CPP"
-fi
-echo "$ac_t""$CPP" 1>&6
-
-
-echo $ac_n "checking if running LynxOS""... $ac_c" 1>&6
-echo "configure:1007: checking if running LynxOS" >&5
-if eval "test \"`echo '$''{'ac_cv_os_lynx'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1012 "configure"
-#include "confdefs.h"
-/*
- * The old Lynx "cc" only defines "Lynx", but the newer one uses "__Lynx__"
- */
-#if defined(__Lynx__) || defined(Lynx)
-yes
-#endif
-
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "yes" >/dev/null 2>&1; then
- rm -rf conftest*
- ac_cv_os_lynx=yes
-else
- rm -rf conftest*
- ac_cv_os_lynx=no
-fi
-rm -f conftest*
-
-fi
-
-#
-if test "$ac_cv_os_lynx" = "yes" ; then
- echo "$ac_t""yes" 1>&6
- cat >> confdefs.h <<\EOF
-#define LYNX 1
-EOF
-
- echo $ac_n "checking whether -mposix or -X is available""... $ac_c" 1>&6
-echo "configure:1042: checking whether -mposix or -X is available" >&5
- if eval "test \"`echo '$''{'ac_cv_c_posix_flag'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1047 "configure"
-#include "confdefs.h"
-
-int main() {
-
- /*
- * This flag varies depending on how old the compiler is.
- * -X is for the old "cc" and "gcc" (based on 1.42).
- * -mposix is for the new gcc (at least 2.5.8).
- */
- #if defined(__GNUC__) && __GNUC__ >= 2
- choke me
- #endif
-
-; return 0; }
-EOF
-if { (eval echo configure:1063: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
- rm -rf conftest*
- ac_cv_c_posix_flag=" -mposix"
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- ac_cv_c_posix_flag=" -X"
-fi
-rm -f conftest*
-fi
-
- CC="$CC $ac_cv_c_posix_flag"
- echo "$ac_t""$ac_cv_c_posix_flag" 1>&6
- else
- echo "$ac_t""no" 1>&6
-fi
-
-
-#
-# Ok, lets find the tcl source trees so we can use the headers
-# Warning: transition of version 9 to 10 will break this algorithm
-# because 10 sorts before 9. We also look for just tcl. We have to
-# be careful that we don't match stuff like tclX by accident.
-# the alternative search directory is involked by --with-tclinclude
-#
-no_tcl=true
-echo $ac_n "checking for Tcl private headers""... $ac_c" 1>&6
-echo "configure:1091: checking for Tcl private headers" >&5
-# Check whether --with-tclinclude or --without-tclinclude was given.
-if test "${with_tclinclude+set}" = set; then
- withval="$with_tclinclude"
- with_tclinclude=${withval}
-fi
-
-if eval "test \"`echo '$''{'ac_cv_c_tclh'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
-
-# first check to see if --with-tclinclude was specified
-if test x"${with_tclinclude}" != x ; then
- if test -f ${with_tclinclude}/tclInt.h ; then
- ac_cv_c_tclh=`(cd ${with_tclinclude}; pwd)`
- elif test -f ${with_tclinclude}/generic/tclInt.h ; then
- ac_cv_c_tclh=`(cd ${with_tclinclude}/generic; pwd)`
- else
- { echo "configure: error: ${with_tclinclude} directory doesn't contain private headers" 1>&2; exit 1; }
- fi
-fi
-
-# next check if it came with Tcl configuration file
-if test x"${ac_cv_c_tclconfig}" != x ; then
- if test -f $ac_cv_c_tclconfig/../generic/tclInt.h ; then
- ac_cv_c_tclh=`(cd $ac_cv_c_tclconfig/../generic; pwd)`
- fi
-fi
-
-# next check in private source directory
-#
-# since ls returns lowest version numbers first, reverse its output
-
-if test x"${ac_cv_c_tclh}" = x ; then
- for i in \
- ${srcdir}/../tcl \
- `ls -dr ${srcdir}/../tcl[7-9].[0-9] 2>/dev/null` \
- ${srcdir}/../../tcl \
- `ls -dr ${srcdir}/../../tcl[7-9].[0-9] 2>/dev/null` \
- ${srcdir}/../../../tcl \
- `ls -dr ${srcdir}/../../../tcl[7-9].[0-9] 2>/dev/null ` ; do
- if test -f $i/generic/tclInt.h ; then
- ac_cv_c_tclh=`(cd $i/generic; pwd)`
- break
- fi
- done
-fi
-
-# finally check in a few common install locations
-#
-# since ls returns lowest version numbers first, reverse its output
-
-if test x"${ac_cv_c_tclh}" = x ; then
- for i in \
- `ls -dr /usr/local/src/tcl[7-9].[0-9] 2>/dev/null` \
- `ls -dr /usr/local/lib/tcl[7-9].[0-9] 2>/dev/null` \
- /usr/local/src/tcl \
- /usr/local/lib/tcl \
- ${prefix}/include ; do
- if test -f $i/generic/tclInt.h ; then
- ac_cv_c_tclh=`(cd $i/generic; pwd)`
- break
- fi
- done
-fi
-
-# see if one is installed
-if test x"${ac_cv_c_tclh}" = x ; then
- ac_safe=`echo "tclInt.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for tclInt.h""... $ac_c" 1>&6
-echo "configure:1161: checking for tclInt.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 1166 "configure"
-#include "confdefs.h"
-#include <tclInt.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1171: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=yes"
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- ac_cv_c_tclh=installed
-else
- echo "$ac_t""no" 1>&6
-ac_cv_c_tclh=""
-fi
-
-fi
-
-fi
-
-if test x"${ac_cv_c_tclh}" = x ; then
- TCLHDIR="# no Tcl private headers found"
- TCLHDIRDASHI="# no Tcl private headers found"
- { echo "configure: error: Can't find Tcl private headers" 1>&2; exit 1; }
-fi
-if test x"${ac_cv_c_tclh}" != x ; then
- no_tcl=""
- if test x"${ac_cv_c_tclh}" = x"installed" ; then
- echo "$ac_t""is installed" 1>&6
- TCLHDIR=""
- TCLHDIRDASHI=""
- TCL_LIBRARY=""
- else
- echo "$ac_t""found in ${ac_cv_c_tclh}" 1>&6
- # this hack is cause the TCLHDIR won't print if there is a "-I" in it.
- TCLHDIR="${ac_cv_c_tclh}"
- TCLHDIRDASHI="-I${ac_cv_c_tclh}"
- TCL_LIBRARY=`echo $TCLHDIR | sed -e 's/generic//'`library
- fi
-fi
-
-
-
-
-
-
-
-
-
-trap '' 1 2 15
-cat > confcache <<\EOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs. It is not useful on other systems.
-# If it contains results you don't want to keep, you may remove or edit it.
-#
-# By default, configure uses ./config.cache as the cache file,
-# creating it if it does not exist already. You can give configure
-# the --cache-file=FILE option to use a different cache file; that is
-# what configure does when it calls configure scripts in
-# subdirectories, so they share the cache.
-# Giving --cache-file=/dev/null disables caching, for debugging configure.
-# config.status only pays attention to the cache file if you give it the
-# --recheck option to rerun configure.
-#
-EOF
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, don't put newlines in cache variables' values.
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-(set) 2>&1 |
- case `(ac_space=' '; set | grep ac_space) 2>&1` in
- *ac_space=\ *)
- # `set' does not quote correctly, so add quotes (double-quote substitution
- # turns \\\\ into \\, and sed turns \\ into \).
- sed -n \
- -e "s/'/'\\\\''/g" \
- -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
- ;;
- *)
- # `set' quotes correctly as required by POSIX, so do not add quotes.
- sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
- ;;
- esac >> confcache
-if cmp -s $cache_file confcache; then
- :
-else
- if test -w $cache_file; then
- echo "updating cache $cache_file"
- cat confcache > $cache_file
- else
- echo "not updating unwritable cache $cache_file"
- fi
-fi
-rm -f confcache
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-# Any assignment to VPATH causes Sun make to only execute
-# the first set of double-colon rules, so remove it if not needed.
-# If there is a colon in the path, we need to keep it.
-if test "x$srcdir" = x.; then
- ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
-fi
-
-trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
-
-# Transform confdefs.h into DEFS.
-# Protect against shell expansion while executing Makefile rules.
-# Protect against Makefile macro expansion.
-#
-# If the first sed substitution is executed (which looks for macros that
-# take arguments), then we branch to the quote section. Otherwise,
-# look for a macro that doesn't take arguments.
-cat >confdef2opt.sed <<\_ACEOF
-t clear
-: clear
-s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\),-D\1=\2,g
-t quote
-s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\),-D\1=\2,g
-t quote
-d
-: quote
-s,[ `~#$^&*(){}\\|;'"<>?],\\&,g
-s,\[,\\&,g
-s,\],\\&,g
-s,\$,$$,g
-p
-_ACEOF
-# We use echo to avoid assuming a particular line-breaking character.
-# The extra dot is to prevent the shell from consuming trailing
-# line-breaks from the sub-command output. A line-break within
-# single-quotes doesn't work because, if this script is created in a
-# platform that uses two characters for line-breaks (e.g., DOS), tr
-# would break.
-ac_LF_and_DOT=`echo; echo .`
-DEFS=`sed -n -f confdef2opt.sed confdefs.h | tr "$ac_LF_and_DOT" ' .'`
-rm -f confdef2opt.sed
-
-
-# Without the "./", some shells look in PATH for config.status.
-: ${CONFIG_STATUS=./config.status}
-
-echo creating $CONFIG_STATUS
-rm -f $CONFIG_STATUS
-cat > $CONFIG_STATUS <<EOF
-#! /bin/sh
-# Generated automatically by configure.
-# Run this file to recreate the current configuration.
-# This directory was configured as follows,
-# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-#
-# $0 $ac_configure_args
-#
-# Compiler output produced by configure, useful for debugging
-# configure, is in ./config.log if it exists.
-
-ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
-for ac_option
-do
- case "\$ac_option" in
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
- exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
- -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
- echo "$CONFIG_STATUS generated by autoconf version 2.13"
- exit 0 ;;
- -help | --help | --hel | --he | --h)
- echo "\$ac_cs_usage"; exit 0 ;;
- *) echo "\$ac_cs_usage"; exit 1 ;;
- esac
-done
-
-ac_given_srcdir=$srcdir
-
-trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-# Protect against being on the right side of a sed subst in config.status.
-sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
- s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
-$ac_vpsub
-$extrasub
-s%@SHELL@%$SHELL%g
-s%@CFLAGS@%$CFLAGS%g
-s%@CPPFLAGS@%$CPPFLAGS%g
-s%@CXXFLAGS@%$CXXFLAGS%g
-s%@FFLAGS@%$FFLAGS%g
-s%@DEFS@%$DEFS%g
-s%@LDFLAGS@%$LDFLAGS%g
-s%@LIBS@%$LIBS%g
-s%@exec_prefix@%$exec_prefix%g
-s%@prefix@%$prefix%g
-s%@program_transform_name@%$program_transform_name%g
-s%@bindir@%$bindir%g
-s%@sbindir@%$sbindir%g
-s%@libexecdir@%$libexecdir%g
-s%@datadir@%$datadir%g
-s%@sysconfdir@%$sysconfdir%g
-s%@sharedstatedir@%$sharedstatedir%g
-s%@localstatedir@%$localstatedir%g
-s%@libdir@%$libdir%g
-s%@includedir@%$includedir%g
-s%@oldincludedir@%$oldincludedir%g
-s%@infodir@%$infodir%g
-s%@mandir@%$mandir%g
-s%@TCL_DEFS@%$TCL_DEFS%g
-s%@TCL_SHLIB_LD@%$TCL_SHLIB_LD%g
-s%@SHLIB_SUFFIX@%$SHLIB_SUFFIX%g
-s%@TCL_LD_FLAGS@%$TCL_LD_FLAGS%g
-s%@TCL_RANLIB@%$TCL_RANLIB%g
-s%@TCL_BUILD_LIB_SPEC@%$TCL_BUILD_LIB_SPEC%g
-s%@TCL_LIB_SPEC@%$TCL_LIB_SPEC%g
-s%@TCL_SHARED_LIB_SUFFIX@%$TCL_SHARED_LIB_SUFFIX%g
-s%@CC@%$CC%g
-s%@CPP@%$CPP%g
-s%@TCLHDIR@%$TCLHDIR%g
-s%@TCLHDIRDASHI@%$TCLHDIRDASHI%g
-s%@TCL_LIBRARY@%$TCL_LIBRARY%g
-s%@host@%$host%g
-
-CEOF
-EOF
-
-cat >> $CONFIG_STATUS <<\EOF
-
-# Split the substitutions into bite-sized pieces for seds with
-# small command number limits, like on Digital OSF/1 and HP-UX.
-ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
-ac_file=1 # Number of current file.
-ac_beg=1 # First line for current file.
-ac_end=$ac_max_sed_cmds # Line after last line for current file.
-ac_more_lines=:
-ac_sed_cmds=""
-while $ac_more_lines; do
- if test $ac_beg -gt 1; then
- sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
- else
- sed "${ac_end}q" conftest.subs > conftest.s$ac_file
- fi
- if test ! -s conftest.s$ac_file; then
- ac_more_lines=false
- rm -f conftest.s$ac_file
- else
- if test -z "$ac_sed_cmds"; then
- ac_sed_cmds="sed -f conftest.s$ac_file"
- else
- ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
- fi
- ac_file=`expr $ac_file + 1`
- ac_beg=$ac_end
- ac_end=`expr $ac_end + $ac_max_sed_cmds`
- fi
-done
-if test -z "$ac_sed_cmds"; then
- ac_sed_cmds=cat
-fi
-EOF
-
-cat >> $CONFIG_STATUS <<EOF
-
-CONFIG_FILES=\${CONFIG_FILES-"Makefile"}
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
- # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
- case "$ac_file" in
- *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
- ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
- *) ac_file_in="${ac_file}.in" ;;
- esac
-
- # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
-
- # Remove last slash and all that follows it. Not all systems have dirname.
- ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
- if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
- # The file is in a subdirectory.
- test ! -d "$ac_dir" && mkdir "$ac_dir"
- ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
- # A "../" for each directory in $ac_dir_suffix.
- ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
- else
- ac_dir_suffix= ac_dots=
- fi
-
- case "$ac_given_srcdir" in
- .) srcdir=.
- if test -z "$ac_dots"; then top_srcdir=.
- else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
- /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
- *) # Relative path.
- srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
- top_srcdir="$ac_dots$ac_given_srcdir" ;;
- esac
-
-
- echo creating "$ac_file"
- rm -f "$ac_file"
- configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
- case "$ac_file" in
- *Makefile*) ac_comsub="1i\\
-# $configure_input" ;;
- *) ac_comsub= ;;
- esac
-
- ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
- sed -e "$ac_comsub
-s%@configure_input@%$configure_input%g
-s%@srcdir@%$srcdir%g
-s%@top_srcdir@%$top_srcdir%g
-" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
-fi; done
-rm -f conftest.s*
-
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-
-exit 0
-EOF
-chmod +x $CONFIG_STATUS
-rm -fr confdefs* $ac_clean_files
-test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
-
+++ /dev/null
-dnl Process this file with autoconf to produce a configure script.
-sinclude(../aclocal.m4)
-AC_INIT(exp_test.c)
-
-CY_AC_PATH_TCLCONFIG
-CY_AC_LOAD_TCLCONFIG
-CC=$TCL_CC
-
-AC_PROG_CC
-CY_AC_C_WORKS
-
-# This is for LynxOS, which needs a flag to force true POSIX when
-# building. It's weirder than that, cause the flag varies depending
-# how old the compiler is. So...
-# -X is for the old "cc" and "gcc" (based on 1.42)
-# -mposix is for the new gcc (at least 2.5.8)
-# This modifies the value of $CC to have the POSIX flag added
-# so it'll configure correctly
-CY_AC_TCL_LYNX_POSIX
-CY_AC_PATH_TCLH
-
-AC_SUBST(CC)
-AC_SUBST(TCLHDIR)
-AC_SUBST(host)
-AC_OUTPUT(Makefile)
+++ /dev/null
-/*
- * exp-test -- this is a simple C program to test the interactive functions of expect.
- */
-
-#include <stdio.h>
-#include <string.h>
-
-#define ARRAYSIZE 128
-
-main (argc, argv)
-int argc;
-char *argv[];
-{
- char line[ARRAYSIZE];
-
- do {
- memset (line, 0, ARRAYSIZE);
- fgets (line, ARRAYSIZE, stdin);
- *(line + strlen(line)-1) = '\0'; /* get rid of the newline */
-
- /* look for a few simple commands */
- if (strncmp (line,"prompt ", 6) == 0) {
- printf ("%s (y or n) ?", line + 6);
- if (getchar() == 'y')
- puts ("YES");
- else
- puts ("NO");
- }
- if (strncmp (line, "print ", 6) == 0) {
- puts (line + 6);
- }
- } while (strncmp (line, "quit", 4));
-}
+++ /dev/null
-# Copyright (C) 1988, 1990, 1991, 1992, 1996, 1997 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-# Please email any bugs, comments, and/or additions to this file to:
-# bug-dejagnu@prep.ai.mit.edu
-
-# This file was written by Rob Savoye. (rob@cygnus.com)
-
-#
-# the initial work on the version of these tests from the tcl release was done
-# by Mary Ann May-Pumphrey of Sun Microsystems.
-#
-if $tracelevel then {
- strace $tracelevel
- }
-
-expect_before buffer_full { error "Buffer full" }
-expect_start
-
-set timeoutmsg "Timed out: Never got started, "
-set timeout 20
-set file all
-set command "unidentified test in $file"
-
-if ![file exists ${srcdir}/../tests] {
- perror "The source for the test cases is missing." 0
- return -1
-}
-send "cd ${srcdir}/../tests\r"
-expect {
- -re "set VERBOSE 1\[\r\n\]*1\[\r\n\]*$eprompt" {
- verbose "Set verbose flag for tests"
- exp_continue
- }
- -re "cd $srcdir/../tests\[\r\n\]*$eprompt" {
- verbose "Changed directory to $srcdir/../tests" 2
- }
- -re "no files matched glob pattern" {
- warning "Didn't cd to $srcdir/../tests"
- }
- timeout {
- perror "Couldn't change directories" 0
- return -1
- }
-}
-
-exp_send "source $file\r"
-expect {
- -re "source $file\[\r\n\]*$eprompt" {
- verbose "Sourced test $file ..."
- set timeoutmsg "Never got to the end of "
- exp_continue
- }
- "install Tcl or set your TCL_LIBRARY environment variable" {
- perror "You need to set the TCL_LIBRARY environment variable"
- return -1
- }
- -re "no files matched glob pattern" {
- warning "Didn't cd to $srcdir/../tests"
- }
- -re "\[\r\n\]*\\+\\+\\+\\+ (\[a-z\]*-\[.0-9\]*) PASSED\[\r\n\]*" {
- pass $expect_out(1,string)
- exp_continue
- }
- -re "\[\r\n\]*\\+* (\[a-z\]*-\[.0-9\]*) FAILED\[\r\n\]*" {
- fail $expect_out(1,string)
- exp_continue
- }
- -re "Test generated error:\[\r\n\]*.*\[\r\n\]*" {
- regsub "Test generated error:\[\r\n\]+" $expect_out(0,string) "" tmp
- regsub -all "\[\r\n\]*\[a-z.\]test\[\r\n\]*" $tmp "" tmp
- regsub -all "\[\r\n\]*" $tmp "" tmp
- perror "Got a test case bug \"$tmp\""
- exp_continue
- }
- -re "\[x\]+ \[a-i\]+ \[A-K\]+ \[0-9\]+ " {
- verbose "Got standard output message from exec 8.1 test." 3
- exp_continue
- }
- "*Error: bad option *" {
- fail "$command (Got a bad option)"
- }
- eof {
- verbose "Done" 2
- }
- timeout {
- warning "$timeoutmsg $file"
- }
-}
-
-catch close
+++ /dev/null
-# vgrindefs for Expect
-# Author: Brian Fitzgerald <fitz@mml0.meche.rpi.edu>
-# Department of Mechanical Engineering
-# Rensselaer Polytechnic Institute
-# Date: Sat, 12 Oct 91 13:41:36 EDT
-#
-# To install this file, append it to /usr/lib/vgrindefs
-#
-# vgrind is a troff pretty-printer. For example, to use it on a Sun with the
-# Adobe Transcript package, install this file and do:
-#
-# setenv TROFF ptroff
-# vgrind -lexpect file
-#
-expect|tcl:\
- :pb=(^|;)\d?proc\d\p\d:\
- :id=!$%&'()*+,-./\:<=>?@^_`|}~:\
- :bb={:be=}:\
- :cb=#:ce=$:\
- :sb=":se=\e":\
- :kw=debug disconnect exit\
- expect expect_user expect_before expect_after expect_version\
- fork\
- interact log_file log_user overlay\
- send send_spawn send_user send_log send_error\
- spawn system trace trap wait\
- break case catch concat continue error eval exec expr file for foreach\
- format glob global history if then else index info length list print\
- proc range rename return scan set source string time uplevel upvar:
-