/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
/* Portions Copyright(c) 1988, Sun Microsystems, Inc. */
/* All Rights Reserved. */
/*
* script: Produce a record of a terminal session.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <locale.h>
#include <time.h>
#include <errno.h>
int grantpt();
int unlockpt();
char *ptsname();
void doinput() __NORETURN;
void dooutput();
void doshell();
void fixtty();
void fail();
void done() __NORETURN;
void getmaster();
void getslave();
char *shell;
int child;
int subchild;
void sigwinch();
void finish();
struct termios b;
int lb;
int l;
int aflg;
int
{
#if !defined(TEXT_DOMAIN)
#endif
(void) textdomain(TEXT_DOMAIN);
switch (argv[0][1]) {
case 'a':
aflg++;
break;
default:
gettext("usage: script [ -a ] [ typescript ]\n"));
exit(1);
}
}
if (argc > 0)
fail();
}
getmaster();
fixtty();
if (child < 0) {
perror("fork");
fail();
}
if (child == 0) {
if (child < 0) {
perror("fork");
fail();
}
if (child)
dooutput();
else
doshell();
}
doinput();
/* NOTREACHED */
return (0);
}
void
doinput()
{
int cc;
if (cc == -1) {
continue;
} else {
break;
}
}
}
done();
}
void
sigwinch()
{
}
void
finish()
{
int status;
register int pid;
register int die = 0;
die = 1;
if (die)
done();
}
void
dooutput()
{
int cc;
(void) close(0);
for (;;) {
if (cc <= 0)
break;
}
done();
}
void
doshell()
{
setpgrp(); /* relinquish control terminal */
getslave();
fail();
}
void
fixtty()
{
sbuf = b;
}
void
fail()
{
done();
}
void
done()
{
if (subchild) {
} else {
}
exit(0);
}
void
{
return;
} else { /* out of pseudo-tty's */
fail();
}
}
void
getslave()
{
if (slave < 0) { /* error on opening slave */
fail();
}
}