Пример #1
0
void
end_of_input()
{
	settty("End of input?\n");
	clearlocks();
	exit(0);
}
Пример #2
0
/* ARGSUSED */
void
tstpcont(int sig)
{
	int save_errno = errno;

	if (sig == SIGTSTP) {
		signal(SIGCONT, tstpcont);
		gettty(&ttyedit);
		settty(&ttysaved);		
	} else {
		signal(SIGTSTP, tstpcont);
		settty(&ttyedit);		
	}
	signal(sig, SIG_DFL);
	kill(0, sig);
	errno = save_errno;
}
Пример #3
0
int dosave (void)
{
    if (dosave0 (true)) {
	settty ("Be seeing you ...\n");
	exit (EXIT_SUCCESS);
    }
    return 0;
}
Пример #4
0
dosave(){
	if(dosave0(0)) {
		settty("Be seeing you ...\n");
		exit(0);
	}
#ifdef lint
	return(0);
#endif lint
}
Пример #5
0
static Sgttyb *STTY0(int fd,const char *command){
	Sgttyb *tty;

	if( NO_TTY ) return 0;
	tty = (Sgttyb*)STRUCT_ALLOC( sizeof(*tty) );
	cached_gtty(fd,tty);
	settty(fd,command);
	return tty;
}
Пример #6
0
int
dosave(void)
{
	if (dosave0(0)) {
		settty("Be seeing you ...\n");
		exit(0);
	}
	return (0);
}
Пример #7
0
/* fatal error */
void
error(char *s, ...)
{
	va_list ap;

	if(settty_needed)
		settty((char *) 0);
	va_start(ap, s);
	vprintf(s, ap);
	va_end(ap);
	putchar('\n');
	exit(1);
}
Пример #8
0
/* This cannot be part of hack.tty.c (as it was earlier) since on some
   systems (e.g. MUNIX) the include files <termio.h> and <sgtty.h>
   define the same constants, and the C preprocessor complains. */
#include <stdio.h>
#include "config.h"
#ifdef BSD
#include	<sgtty.h>
struct ltchars ltc, ltc0;
#else
#include	<termio.h>	/* also includes part of <sgtty.h> */
struct termio termio;
#endif BSD

getioctls() {
#ifdef BSD
	(void) ioctl(fileno(stdin), TIOCGLTC, (char *) &ltc);
	(void) ioctl(fileno(stdin), TIOCSLTC, (char *) &ltc0);
#else
	(void) ioctl(fileno(stdin), TCGETA, &termio);
#endif BSD
}

setioctls() {
#ifdef BSD
	(void) ioctl(fileno(stdin), TIOCSLTC, (char *) &ltc);
#else
	(void) ioctl(fileno(stdin), TCSETA, &termio);
#endif BSD
}

#ifdef SUSPEND		/* implies BSD */
dosuspend() {
#include	<signal.h>
#ifdef SIGTSTP
	if(signal(SIGTSTP, SIG_IGN) == SIG_DFL) {
		settty((char *) 0);
		(void) signal(SIGTSTP, SIG_DFL);
		(void) kill(0, SIGTSTP);
		gettty();
		setftty();
		docrt();
	} else {
		pline("I don't think your shell has job control.");
	}
#else SIGTSTP
	pline("Sorry, it seems we have no SIGTSTP here. Try ! or S.");
#endif SIGTSTP
	return(0);
}
Пример #9
0
main(int argc, char *argv[])   // invoked by exec("login /dev/ttyxx")
{
  char username[64], password[64];
  char *tty =  argv[1];
  int len;

// 1. 
  close(0); close(1); close(2); // login process may run on different terms

// 2. // open its own tty (passed in by INIT) as stdin, stdout, stderr
  stdin = open(tty, 0);
  stdout = open(tty, 1);
  stderr = open(tty, 2);
// 3. 
  settty(tty);   // store tty string in PROC.tty[] for putc()

  // NOW we can use printf, which calls putc() to our tty
  printf("SkyLogin : open %s as stdin, stdout, stderr\n", tty);

  signal(2,1);  // ignore Control-C interrupts so that 
                // Control-C KILLs other procs on this tty but not the main sh

  while(1){
//1. show login:           to stdout
//2. read user name        from stdin
    printf("Skynet Login: "******"code: "); 
    len = getline(password);
    password[len-1] = '\0';
//5. verify user name and passwd from /etc/passwd file
    if( verify( username, password) ) 
    {
      exec("/bin/sh");
    }
    
    printf("login failed, try again\n");
  }
}
Пример #10
0
int
child(int wt)
{
	int status;
	int f;
	char *home;
	gid_t gid;

	f = fork();
	if(f == 0){		/* child */
		settty((char *) 0);		/* also calls end_screen() */
		/* revoke privs */
		gid = getgid();
		setresgid(gid, gid, gid);
#ifdef CHDIR
		home = getenv("HOME");
		if (home == NULL || *home == '\0')
			home = "/";
		(void) chdir(home);
#endif /* CHDIR */
		return(1);
	}
	if(f == -1) {	/* cannot fork */
		pline("Fork failed. Try again.");
		return(0);
	}
	/* fork succeeded; wait for child to exit */
	(void) signal(SIGINT,SIG_IGN);
	(void) signal(SIGQUIT,SIG_IGN);
	(void) wait(&status);
	gettty();
	setftty();
	(void) signal(SIGINT,done1);
#ifdef WIZARD
	if(wizard) (void) signal(SIGQUIT,SIG_DFL);
#endif /* WIZARD */
	if(wt) getret();
	docrt();
	return(0);
}
Пример #11
0
bool
child(bool wt)
{
	int status;
	int f;

	f = fork();
	if (f == 0) {		/* child */
		settty(NULL);	/* also calls end_screen() */
		/* revoke */
		setgid(getgid());
#ifdef CHDIR
		chdir(getenv("HOME"));
#endif /* CHDIR */
		return (1);
	}
	if (f == -1) {		/* cannot fork */
		pline("Fork failed. Try again.");
		return (0);
	}
	/* fork succeeded; wait for child to exit */
	signal(SIGINT, SIG_IGN);
	signal(SIGQUIT, SIG_IGN);
	wait(&status);
	gettty();
	setftty();
	signal(SIGINT, done1);
#ifdef WIZARD
	if (wizard)
		signal(SIGQUIT, SIG_DFL);
#endif /* WIZARD */
	if (wt)
		getret();
	docrt();
	return (0);
}
Пример #12
0
Файл: ey4.c Проект: dank101/2BSD
output(){ /* print the output for the states */

  int i, j, k, c;

  settab();
  arrset("yyact");

  for( i=0; i<nstate; ++i ){ /* output the stuff for state i */
    nolook = (tystate[i]==0);
    closure(i);
    /* output actions */
    aryfil( temp1, nterms+1, 0 );
    for( j=0; j<cwset; ++j ){ /* look at the items */
      c = *( wsets[j].pitem );
      if( c>0 && c<NTBASE && temp1[c]==0 ) temp1[c] = go2(i,c);
      }

    if( i == 1 ) temp1[1] = ACCEPTCODE;

    /* now, we have the shifts; look at the reductions */

    lastred = 0;
    for( j=0; j<cwset; ++j ){
      c = *( wsets[j].pitem );
      if( c<=0 ){ /* reduction */
        lastred = -c;
        for( k=1; k<=nterms; ++k ){
          if( ((wsets[j].ws[k>>4])&(1<<(k&017))) != 0 ) {
            if( temp1[k] == 0 ) temp1[k] = c;
            else if( temp1[k]<0 ){ /* reduce/reduce conflict */
              settty();
              printf("\n%d: reduce/reduce conflict (red'ns %d and %d ) on %s",
                i, -temp1[k], lastred, symnam(k) );
              if( -temp1[k] > lastred ) temp1[k] = -lastred;
              ++zzrrconf;
              settab();
              }
            else { /* potential shift/reduce conflict */
              switch( precftn( lastred, k ) ) {

            case 0: /* precedence does not apply */

                settty();
                printf("\n%d: shift/reduce conflict (shift %d, red'n %d) on %s", i,
			temp1[k], lastred, symnam(k) );
                ++zzsrconf;
                settab();
                break;

            case 1: /*  reduce */

                temp1[k] = -lastred;
                break;

            case 2: /* error, binary operator */

                temp1[k] = ERRCODE;
                break;

            case 3: /* shift ... leave the entry alone */

                break;
                }
              }
            }
          }
        }
      }
    wract(i);
    }
Пример #13
0
/* Be careful not to call panic from here! */
void
done(const char *st1)
{

#ifdef WIZARD
	if(wizard && *st1 == 'd'){
		u.uswldtim = 0;
		if(u.uhpmax < 0) u.uhpmax = 100;	/* arbitrary */
		u.uhp = u.uhpmax;
		pline("For some reason you are still alive.");
		flags.move = 0;
		if(multi > 0) multi = 0; else multi = -1;
		flags.botl = 1;
		return;
	}
#endif /* WIZARD */
	signal(SIGINT, done_intr);
	signal(SIGQUIT, done_intr);
	signal(SIGHUP, done_hangup);
	if(*st1 == 'q' && u.uhp < 1){
		st1 = "died";
		killer = "quit while already on Charon's boat";
	}
	if(*st1 == 's') killer = "starvation"; else
	if(*st1 == 'd' && st1[1] == 'r') killer = "drowning"; else
	if(*st1 == 'p') killer = "panic"; else
	if(*st1 == 't') killer = "trickery"; else
	if(!index("bcd", *st1)) killer = st1;
	paybill();
	clearlocks();
	if(flags.toplin == 1) more();
	if(index("bcds", *st1)){
#ifdef WIZARD
	    if(!wizard)
#endif /* WIZARD */
		savebones();
		if(!flags.notombstone)
			outrip();
	}
	if(*st1 == 'c') killer = st1;		/* after outrip() */
	settty(NULL);				/* does a clear_screen() */
	if(!done_stopprint)
		printf("Goodbye %s %s...\n\n", pl_character, plname);
	{ long int tmp;
	  tmp = u.ugold - u.ugold0;
	  if(tmp < 0)
		tmp = 0;
	  if(*st1 == 'd' || *st1 == 'b')
		tmp -= tmp/10;
	  u.urexp += tmp;
	  u.urexp += 50 * maxdlevel;
	  if(maxdlevel > 20)
		u.urexp += 1000*((maxdlevel > 30) ? 10 : maxdlevel - 20);
	}
	if(*st1 == 'e') {
		struct monst *mtmp;
		struct obj *otmp;
		int i;
		unsigned worthlessct = 0;
		boolean has_amulet = FALSE;

		killer = st1;
		keepdogs();
		mtmp = mydogs;
		if(mtmp) {
			if(!done_stopprint) printf("You");
			while(mtmp) {
				if(!done_stopprint)
					printf(" and %s", monnam(mtmp));
				if(mtmp->mtame)
					u.urexp += mtmp->mhp;
				mtmp = mtmp->nmon;
			}
			if(!done_stopprint)
		    printf("\nescaped from the dungeon with %ld points,\n",
			u.urexp);
		} else
		if(!done_stopprint)
		  printf("You escaped from the dungeon with %ld points,\n",
		    u.urexp);
		for(otmp = invent; otmp; otmp = otmp->nobj) {
			if(otmp->olet == GEM_SYM){
				i = otmp->quan*objects[otmp->otyp].g_val;
				if(i == 0) {
					worthlessct += otmp->quan;
					continue;
				}
				u.urexp += i;
				if(!done_stopprint)
				  printf("\t%s (worth %d Zorkmids),\n",
				    doname(otmp), i);
			} else if(otmp->olet == AMULET_SYM) {
				i = (otmp->spe < 0) ? 2 : 5000;
				u.urexp += i;
				if(!done_stopprint)
				  printf("\t%s (worth %d Zorkmids),\n",
				    doname(otmp), i);
				if(otmp->spe >= 0) {
					has_amulet = TRUE;
					killer = "escaped (with amulet)";
				}
			}
		}
		if(worthlessct) if(!done_stopprint)
		  printf("\t%u worthless piece%s of coloured glass,\n",
		  worthlessct, plur(worthlessct));
		if(has_amulet) u.urexp *= 2;
	} else
		if(!done_stopprint)
		  printf("You %s on dungeon level %d with %ld points,\n",
		    st1, dlevel, u.urexp);
	if(!done_stopprint)
	  printf("and %ld piece%s of gold, after %ld move%s.\n",
	    u.ugold, plur(u.ugold), moves, plur(moves));
	if(!done_stopprint)
  printf("You were level %u with a maximum of %d hit points when you %s.\n",
	    u.ulevel, u.uhpmax, st1);
	if(*st1 == 'e' && !done_stopprint){
		getret();	/* all those pieces of coloured glass ... */
		cls();
	}
#ifdef WIZARD
	if(!wizard)
#endif /* WIZARD */
		topten();
	if(done_stopprint) printf("\n\n");
	exit(0);
}
Пример #14
0
int setTTyMode(int fd,const char *mode){
	int rcode;
	rcode = settty(fd,mode);
	return rcode;
}
Пример #15
0
/*
 *	clearvt100() 	 	
 *		Subroutine to clean up terminal when the game is over
 *	Attributes off, clear screen, unset scrolling region, restore tty mode 
 */
clearvt100 ()
{
	resetscroll();  
	settty();
}
Пример #16
0
void vInitScreen()
{
        settty(1);
        printf("\033[?25l\033[2J");
}
Пример #17
0
void vRestoreScreen()
{
        printf("\033[24;1H\033[1m\033[40;34m\033[?25h");
        settty(0);
}