0707070000020015771006440001460001440000010340050363463552700000500000000003Size90 0707070000020016421007770001460001440000010037630363463643700001100000000045MAKEcpiocat Files | cpio -ocBv > PHONESRC+IN 0707070000020016361007770001460001440000010337320363463552700001100000000044MAKEflopcat Files | cpio -ocBv > /dev/fp021 0707070000020042611006660001460001440000010023100363463707400001100000000131MakefilePHONE: ate.o ld /lib/crt0s.o /lib/shlib.ifile -o PHONE ate.o ate.o: ate.c cc -cg ate.c 0707070000020016351006660001460001440000010337210363463665300000500000000065NamePHONESRC - Source for PHONE - 3/86 - from THE STORE! 0707070000020015611007770001460001440000010337230363463552700000700000000261RemoveNAME=ROSE FOLDER=/u/$LOGNAME/Filecabinet/SRC rm -rf ${FOLDER}/$NAME > /dev/null 2>&1 NAME=ROSE.DOC FOLDER=/u/$LOGNAME/Filecabinet/DOCS rm -rf ${FOLDER}/$NAME > /dev/null 2>&1 0707070000020015761006440001460001440000010337450363463637700000600000000122Files./Size ./MAKEcpio ./MAKEflop ./Makefile ./Name ./Remove ./Files ./Install ./ate.c 0707070000020016411007770001460001440000010337460363463634400001000000001454InstallNAME=PHONE FOLDER=/u/$LOGNAME/Filecabinet/SRC if [ -d $FOLDER ] then message -i "A new folder called $NAME will be created in your Filecabinet/SRC folder. The source code will be placed in this folder for your use.\n\nTouch to continue." else message -i "A folder called SRC is being created in your Filecabinet. A second folder called SRC/$NAME will then be created to hold the source code for your use.\n\nTouch to continue." mkdir $FOLDER chown $LOGNAME $FOLDER fi mkdir ${FOLDER}/$NAME chown $LOGNAME ${FOLDER}/$NAME DEST=${FOLDER}/$NAME for i in ate.c Makefile do ln $i ${DEST}/$i chown $LOGNAME ${DEST}/$i done message -i "OK - source is in Filecabinet/SRC/${NAME}.\n\nThere is a makefile along with one "C" source.\n\nThe source is called "ate.c".\n\nTouch to continue." 0707070000020015661006440000000001440000010033110363463702000000600000015141ate.c/* ate.c use 7300 as an (expensive) terminal * and demonstrate how the UNIX PC internal modem and * dialler can be made to work. * * Author: Kevin O'Gorman * Anarm Software Systems * ...!ihnp4!wcom!kosman!install * * Last Modified 10 Mar 1986 * * This routine is a minimal terminal emulator, which is * capable of originating a phone call and communicating * with a remote system. The routine terminates when * carrier is lost; because this can be inconvenient, this * routine is intended only as a demonstration of the C * coding techniques for using the on-board modem and dialler. * * Some attention is also given to the use of uucp locks to * prevent contention for the line, and to controlling the * getty(1m) which will usually be competing for incoming * characters on the phone line. * * The baud rate is fixed at 300, touchtone dialling, on * line 2 (/dev/ph1). This could be made more flexible, * but there's a limit on the effort I wanted to put into * a demonstration. * * To make the program: * cc -cO ate.c * ld /lib/crt0s.o /lib/shlib.ifile -o PHONE ate.o * *******************************************************************/ #include #include #include #include #include #include #include #include #include /* termio structure to condition the console for running in binary mode. (See termio(7)) */ struct termio termdir = { IGNBRK | IGNPAR , /* c_iflag */ 0, /* c_oflag */ CLOCAL | B9600 | CS8 | CREAD | HUPCL, /* c_cflag */ 0, /* c_lflag, allowing 1-char input */ 0, /* c_line */ {0377,0377,0377,0377, 1, /* wake up on each char */ 10 /* ignored */ }} ; /* termio structure to condition the phone line for running at 300 baud in binary mode. (See termio(7)). */ struct termio termlin = { IGNBRK | IGNPAR , /* c_iflag */ 0, /* c_oflag */ B300 | CS8 | CREAD | HUPCL , /* c_cflag */ 0, /* c_lflag, allowing 1-char input */ 0, /* c_line */ {0377,0377,0377,0377, 1, /* wake up on each char */ 10 /* ignored */ }} ; /* condition the dialer for a data call, with touchtone signalling */ /* (see phone(7)) */ struct updata updata = { DATA|DTMF, /* outgoing call, touchtone */ 5, /* 5-second max wait for dialtone */ 0, /* used only for voice */ SPEAKERON|NORMSPK, /* control the sounds */ 500}; /* .5 second hook-switch flash (when used) */ char line[] = "/dev/ph1"; char dest[35]; static char Systmcmd[32]; static char Lock_nam[32]; static int Lock_fil; static int Offreslt; static int mypid, pid2; static jmp_buf env; /* Getty-get-off function. This function gets the 'getty(1m)' off the indicated line. The return codes seen (when you do this in the shell) are: 0: Can't do it. Probably a user logged on. 1: No need. No getty on that line. 2: Done. You should restore the getty when you're done. Oddly, the return codes from system(3) seem to be 0, 256, and 512. I am in the dark about why this is. Maybe someone who reads this could educate me. */ static int Getoffsh(path) register char *path; { while (*path != '\0') path++; path -= 3; sprintf(Systmcmd,"/usr/bin/getoff.sh %s",path); return system(Systmcmd); } static void Getonshl(path) register char *path; { while (*path != '\0') path++; path -= 3; sprintf(Systmcmd,"/usr/bin/geton.sh %s",path); system(Systmcmd); } static void Unlock(fd) int fd; { if (fd>0) close(fd); if (Lock_fil > 0) { close(Lock_fil); Lock_fil = -1; if (unlink(Lock_nam) < 0) { fprintf(stderr,"Can't unlink lock-file\r\n"); } } if (Offreslt == 512) { Getonshl(line); } } static int Lockline(path) char *path; { strcat(strcpy(Lock_nam,"/usr/spool/uucp/LCK.."),strrchr(path,'/')+1); Lock_fil = -1; if ((geteuid() || access(Lock_nam,0)) && (Lock_fil = creat(Lock_nam,0444)) >= 0) { mypid = getpid(); write(Lock_fil,&mypid,sizeof mypid); if ((Offreslt = Getoffsh(line)) <= 0) { Unlock(-1); return -1; } else { return 0; } } else { return -1; } } static void Hangup(fd) int fd; { kill(pid2,9); ioctl(fd,PIOCDISC); Unlock(fd); } static int takint() { longjmp(env,1); } int main(argc,argv) int argc; char *argv[]; { int obm, obmfd, console; char ch; char *telno; int rc1; char rb1[20]; printf("\nPhone number: "); read(0,dest,32); if ((console = open("/dev/window",O_RDWR,0)) == -1) { printf("\nSorry, cannot open another window.\n"); exit (1); } signal(SIGWIND,SIG_IGN); signal(SIGPHONE,SIG_IGN); Lock_fil = -1; Offreslt = -1; if (setjmp(env)) { goto unlock; } signal(SIGQUIT,takint); signal(SIGINT,takint); if (Lockline(line)) { printf("\nSorry, cannot lock the phone line.\n"); goto unlock; } obmfd = -1; if (setjmp(env)) { goto disconn; } obmfd = open(line,O_RDWR|O_NDELAY); /* open line to clean up */ if (obmfd < 0) { perror("Sorry, cannot open phone line: "); goto disconn; } (void) ioctl(obmfd,PIOCUNHOLD); (void) ioctl(obmfd,PIOCDISC); close(obmfd); /* because PIOCDISC messes up the line */ obmfd = open(line,O_RDWR|O_NDELAY); /* open line for dialing */ if (obmfd < 0) { perror("Sorry, cannot open phone line: "); goto disconn; } if (ioctl(obmfd,TCSETA,&termlin) < 0) { perror("Sorry, cannot condition phone line: "); goto disconn; } if (ioctl(obmfd,PIOCSETP,&updata) != 0) { perror("Sorry, cannot set modem parameters: "); goto disconn; } if (ioctl(obmfd,PIOCOFFHOOK) != 0) { perror("Sorry, cannot go offhook: "); goto disconn; } sleep(1); for (telno = dest; *telno != '\0'; telno++) { if (ioctl(obmfd,PIOCDIAL,telno) != 0) { perror("Sorry, error in dialing: "); goto disconn; } } if (ioctl(obmfd,PIOCDIAL,"@") != 0) { perror("Sorry, error in dialing: "); goto disconn; } do { if (ioctl(obmfd,PIOCGETP,&updata) != 0) { perror("cannot get connect status: "); goto disconn; } } while ((updata.c_linestatus & MODEMCONNECTED) == 0); fcntl(obmfd,F_SETFL,O_RDWR); close(open(line,O_RDWR)); ioctl(obmfd,TCSRTS,1); /* termio(7) turn on RTS */ ioctl(obmfd,TCXONC,1); /* termio(7) resume suspended output */ ioctl(console,TCSETA,&termdir); pid2 = fork(); if (!pid2) { while (1) { int wrln; if (read(console,&ch,1) == 1) { if ((wrln = write(obmfd,&ch,1)) != 1) { char msg[80]; sprintf(msg, "\nerror on write: length=%d, errno=%d\n",wrln,errno); write(1,msg,strlen(msg)); } } } } if (setjmp(env)) { Hangup(obmfd); exit(1); } while (1) { if (read(obmfd,&ch,1) == 1) { write(console,&ch,1); } else break; } Hangup(obmfd); exit(0); unlock: Unlock(-1); exit(1); disconn: if (obmfd != -1) { ioctl(obmfd,PIOCDISC); } Unlock(obmfd); exit(1); } 0707070000020015661006440000000001440000010033110363463702000001300000000000TRAILER!!! could educate me. */ static int Getoffsh(path) register char *path; { while (*path != '\0') path++; path -= 3; sprintf(Systmcmd,"/usr/bin/getoff.sh %s",path); return system(Systmcmd); } static void Getonshl(path) register char *path; { while (*path != '\0') path++; path -= 3; sprintf(Systmcmd,"/usr/bin/geton.sh %s",path); system(Systmcmd); } static void Unlock(fd) int fd; { if (fd>0) close(fd); if (Lock_fil > 0) { close(Lock_fil); Lock_fil = -1; if (unlink(Lock_nam) < 0) { fprintf(stderr,"Can't unlink lock-file\r\n"); } } if (Offreslt == 512) { Getonshl(line); } } static int Lockline(path) char *path; { strcat(strcpy(Lock_nam,"/usr/spool/uucp/LCK.."),strrchr(path,'/')+1); Lock_fil = -1; if ((geteuid() || access(Lock_nam,0)) && (Lock_fil = creat(Lock_nam,0444)) >= 0) { mypid = getpid(); write(Lock_fil,&mypid,sizeof mypid); if ((Offreslt = Getoffsh(line)) <= 0) { Unlock(-1); return -1; } else { return 0; } } else { return -1; } } static void Hangup(fd) int fd; { kill(pid2,9); ioctl(fd,PIOCDISC); Unlock(fd); } static int takint() { longjmp(env,1); } int main(argc,argv) int argc; char *argv[]; { int obm, obmfd, console; char ch; char *telno; int rc1; char rb1[20]; printf("\nPhone number: "); read(0,dest,32); if ((console = open("/dev/window",O_RDWR,0)) == -1) { printf("\nSorry