/* 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 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>
#ifdef NO_STDLIB_H
/*
* Tcl's compat/stdlib.h
*/
/*
* stdlib.h --
*
* Declares facilities exported by the "stdlib" portion of
* the C library. This file isn't complete in the ANSI-C
* sense; it only declares things that are needed by Tcl.
* This file is needed even on many systems with their own
* stdlib.h (e.g. SunOS) because not all stdlib.h files
* declare all the procedures needed here (such as strtod).
*
* Copyright (c) 1991 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.
*
* RCS: @(#) $Id: exp_clib.c,v 5.30 2002/03/23 04:55:04 libes Exp $
*/
#ifndef _STDLIB
#define _STDLIB
#include <tcl.h>
extern void abort _ANSI_ARGS_((void));
extern double atof _ANSI_ARGS_((CONST char *string));
extern int atoi _ANSI_ARGS_((CONST char *string));
extern long atol _ANSI_ARGS_((CONST char *string));
extern char * calloc _ANSI_ARGS_((unsigned int numElements,
unsigned int size));
extern void exit _ANSI_ARGS_((int status));
extern int free _ANSI_ARGS_((char *blockPtr));
extern char * getenv _ANSI_ARGS_((CONST char *name));
extern char * malloc _ANSI_ARGS_((unsigned int numBytes));
extern void qsort _ANSI_ARGS_((VOID *base, int n, int size,
int (*compar)(CONST VOID *element1, CONST VOID
*element2)));
extern char * realloc _ANSI_ARGS_((char *ptr, unsigned int numBytes));
extern double strtod _ANSI_ARGS_((CONST char *string, char **endPtr));
extern long strtol _ANSI_ARGS_((CONST char *string, char **endPtr,
int base));
extern unsigned long strtoul _ANSI_ARGS_((CONST char *string,
char **endPtr, int base));
#endif /* _STDLIB */
/*
* end of Tcl's compat/stdlib.h
*/
#else
#include <stdlib.h> /* for malloc */
#endif
#include "expect.h"
#define TclRegError exp_TclRegError
/*
* regexp code - from tcl8.0.4/generic/regexp.c
*/
/*
* 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: exp_clib.c,v 5.30 2002/03/23 04:55:04 libes Exp $
*/
#if 0
#include "tclInt.h"
#include "tclPort.h"
#endif
/*
* 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 Ma
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
expect for redhat linux as4 (151个子文件)
archie 829B
autoexpect 7KB
autopasswd 261B
exp_clib.c 82KB
expect.c 77KB
exp_command.c 75KB
exp_inter.c 58KB
Dbg.c 30KB
exp_regexp.c 28KB
exp_main_sub.c 23KB
pty_termios.c 20KB
exp_chan.c 18KB
exp_tty.c 18KB
exp_log.c 16KB
exp_strf.c 14KB
exp_poll.c 14KB
exp_trap.c 13KB
exp_simple.c 12KB
exp_main_tk.c 11KB
pty_unicos.c 10KB
exp_event.c 8KB
exp_pty.c 8KB
exp_select.c 6KB
pty_sgttyb.c 6KB
exp_glob.c 6KB
exp_noevent.c 4KB
exp_win.c 4KB
exp_console.c 2KB
chesslib++.c 1KB
chesslib.c 1KB
exp_main_exp.c 1KB
chesslib2.c 1KB
exp_tty_comm.c 835B
exp_test.c 685B
exp_memmove.c 404B
exp_closetcl.c 383B
unbuffer.c 176B
carpal 792B
passwd.cgi 3KB
ChangeLog 21KB
ChangeLog 773B
configure 198KB
configure 48KB
cryptdir 1KB
Dbgconfigure 52KB
decryptdir 1KB
dislocate 8KB
dvorak 979B
expect-tests.exp 3KB
beer.exp 3KB
default.exp 3KB
chess.exp 1KB
rogue.exp 315B
FAQ 73KB
fixcat 526B
fixline1 708B
ftp-inband 7KB
ftp-rfc 569B
gethostbyaddr 8KB
config.guess 38KB
expect.h 13KB
exp_command.h 12KB
exp_tty_in.h 3KB
expect_comm.h 2KB
exp_log.h 2KB
expect_tcl.h 2KB
tcldbg.h 2KB
exp_int.h 1KB
exp_event.h 939B
exp_tty.h 656B
exp_prog.h 534B
exp_rename.h 530B
exp_win.h 472B
exp_pty.h 454B
exp_regexp.h 229B
exp_tstamp.h 77B
HISTORY 140KB
passwd.html 819B
configure.in 36KB
Makefile.in 32KB
DbgMkfl.in 8KB
Dbgconfig.in 3KB
Makefile.in 3KB
expect_cf.h.in 2KB
configure.in 630B
pkgIndex.in 518B
DbgpkgInd.in 515B
tcldbgcf.h.in 399B
INSTALL 10KB
install-sh 5KB
irsh 325B
kibitz 11KB
lpunlock 2KB
aclocal.m4 20KB
Makefile 1KB
expect.man 77KB
libexpect.man 22KB
tknewsbiff.man 14KB
multixterm.man 9KB
kibitz.man 7KB
共 151 条
- 1
- 2
puheavy123
- 粉丝: 67
- 资源: 31
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论4