Path: utzoo!utgpu!jarvis.csri.toronto.edu!torsqnt!tmsoft!masnet!canremote!perry@macom1.uucp From: perry@macom1.uucp@canremote.uucp (perry@macom1.UUCP) Newsgroups: comp.dcom.modems Subject: Re: Telebit config Question c Message-ID: <89122504055414@masnet.uucp> Date: 21 Dec 89 05:05:00 GMT Organization: Canada Remote Systems Limited, Mississauga, ON, Canada Lines: 98 From: perry@macom1.UUCP (Guru's Inc.) Subj: Telebit config Question c-code uugetty Orga: CENTEL Federal Systems, Reston, VA. 22091-1506 *-*-*-*-* Message continued from prior message *-*-*-*-* hangups */ signal( SIGINT, trap2 ); /* 02 watch for interrupts */ signal( SIGQUIT, trap3 ); /* 03 watch for quit */ signal( SIGTERM, trap15 ); /* 15 watch for termination */ strcpy( &prg[0], argv[0] ); if (argc < 1) { sprintf(buf, "%s: Not Enough Arguments\n", prg); conprint(60); } device = argv[1]; strcpy( &port[5], argv[1] ); /* /dev/tty?? */ strcpy( &Lock[21], argv[1] ); /* LCK..tty?? */ strcpy( &mtty[16], argv[1] ); /* ttyxxx/tty??t */ strcpy( &mtty[22], "/" ); /* ttyxxx/tty??t */ strcpy( &mtty[23], argv[1] ); /* ttyxxx/tty??t */ sprintf(pbuf, "%10d\n", (getpid()) ); /* get lockf ready */ fd1 = creat(mtty, 4); write(fd1, pbuf, 10 ); if(!(access(Lock, 0))) checkout(Lock); /* remove old lock if any */ if ((pterm = open( port, 2 )) < 0) { track("erropen"); sprintf( buf, "%s: cannot open port %s\n",prg, port ); conprint(60); } sprintf(buf, "chown uucp %s", port ); system(buf); /* give ownership */ while( wait_on_CR( pterm ) ) intread(); /* wait for connect request */ while (inithookup) { parent = getpid(); /* get id of this process */ if ((child = fork()) == 0) { sleep(5); exit(0); /* child holds line open */ } else { if (inithookup) { inithookup = 0; /* hookup is done */ sprintf(buf, "stty sane"); system(buf); execl("/etc/login", "login", 0); } } } return(0); } /*** end main ***/ wait_on_CR( term ) /*** Wait for connect message. ***/ int term; { char k, c; track("listen"); while (1) { if (read( term, &c, 1 ) <= 0) /* get a character from unix */ { k = c = '\0'; return (1); /* interrupt returned */ } if (!(access(Lock, 0))) checkout(Lock); if ( c == CR ) { if (k == CR ) { mask = umask(0); /* change mask */ lockfd = creat( Lock, 0444 ); /* create the lock file */ umask(mask); /* restore mask */ if ( lockfd < 0) { track("errlock"); sprintf(buf, "%s: cannot create lock %s\n",prg, device); conprint(60); } write( lockfd, pbuf, (unsigned)strlen(pbuf) ); close( lockfd ); track("incoming"); return(0); } } k = c; } } checkout(lock) char *lock; { *-*-*-*-* Message continued in next message *-*-*-*-* --- * Via MaSNet/HST96/HST144/V32 - UN Datacommun./Modems * Via Usenet Newsgroup comp.dcom.modems