X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=term-utils%2Fscript.c;h=9b5aa778d8f513d328f6524654da3914ce361302;hb=70062aad13552c9508b73f61c6dd157e61603a99;hp=7aaf6da7bbf8c12bbfa7a824331f71d476655956;hpb=93af8d8bf3e59c881f08999848ddf3a25f7d1867;p=thirdparty%2Futil-linux.git diff --git a/term-utils/script.c b/term-utils/script.c index 7aaf6da7bb..9b5aa778d8 100644 --- a/term-utils/script.c +++ b/term-utils/script.c @@ -12,8 +12,8 @@ * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. + * This product includes software developed by the University of + * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -41,9 +41,6 @@ * - fixed a rare deadlock after child termination */ -/* - * script - */ #include #include #include @@ -63,12 +60,35 @@ #include #include #include +#include +#include +#include #include "closestream.h" #include "nls.h" #include "c.h" #include "ttyutils.h" #include "all-io.h" +#include "monotonic.h" +#include "timeutils.h" +#include "strutils.h" +#include "xalloc.h" +#include "optutils.h" + +#include "debug.h" + +static UL_DEBUG_DEFINE_MASK(script); +UL_DEBUG_DEFINE_MASKNAMES(script) = UL_DEBUG_EMPTY_MASKNAMES; + +#define SCRIPT_DEBUG_INIT (1 << 1) +#define SCRIPT_DEBUG_POLL (1 << 2) +#define SCRIPT_DEBUG_SIGNAL (1 << 3) +#define SCRIPT_DEBUG_IO (1 << 4) +#define SCRIPT_DEBUG_MISC (1 << 5) +#define SCRIPT_DEBUG_ALL 0xFFFF + +#define DBG(m, x) __UL_DBG(script, SCRIPT_DEBUG_, m, x) +#define ON_DBG(m, x) __UL_DBG_CALL(script, SCRIPT_DEBUG_, m, x) #if defined(HAVE_LIBUTIL) && defined(HAVE_PTY_H) # include @@ -78,38 +98,67 @@ # include #endif -#define DEFAULT_OUTPUT "typescript" - -char *shell; -FILE *fscript; -FILE *timingfd; -int master = -1; -int slave; -pid_t child; -pid_t subchild; -int childstatus; -char *fname; - -struct termios tt; -struct winsize win; -int lb; -int l; +#define DEFAULT_TYPESCRIPT_FILENAME "typescript" + +enum { + SCRIPT_FMT_RAW = 1, /* raw slave/master data */ + SCRIPT_FMT_TIMING_SIMPLE, /* timing info in classic "