Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site rlgvax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!teddy!panda!talcott!harvard!seismo!rlgvax!guy From: guy@rlgvax.UUCP (Guy Harris) Newsgroups: net.sources.bugs Subject: Re: umodem source - System V compatible? (Probably not!) Message-ID: <349@rlgvax.UUCP> Date: Sat, 12-Jan-85 19:26:01 EST Article-I.D.: rlgvax.349 Posted: Sat Jan 12 19:26:01 1985 Date-Received: Mon, 14-Jan-85 03:16:01 EST References: <144@green.UUCP> Distribution: net Organization: CCI Office Systems Group, Reston, VA Lines: 113 A few comments on the configuration options: > /* 4.2bsd unix */ > #ifdef V4.2 > #include> #endif This works on our system, to my great surprise, but (from K&R): 2.2 Identifiers (Names) An identifier is a sequence of letters and digits; the first character must be a letter. The underscore _ counts as a letter. 12.3 Conditional compilation ...A control line of the form #ifdef identifier checks whether the identifier is currently defined in the preprocessor... Someday you may find a C compiler which objects to "V4.2" as a #define identifier. You might try "BSD4_2" instead (that seems to be what most programs use). > /* UNIX SYSTEM III tty parameter file */ > #ifdef SYS3 > #include > #endif > > /* UNIX SYSTEM V tty parameter file */ > #ifdef SYS5 > #include > #endif Nope. System III and System V both use "termio.h". One or the other system may *provide* "sgtty.h", but that's just for backward compatibility (and backward compatibility with UNIX/TS 1.0 and PWB/UNIX 2.0, not with V7, to boot). > > /* UNIX SYSTEM III structures */ > #ifdef SYS3 > struct sgttyb ttys, ttysnew, ttystemp; /* for stty terminal mode calls */ > #endif > > /* UNIX SYSTEM V structures */ > #ifdef SYS4 > struct termio ttys, ttysnew, ttystemp; /* for stty terminal mode calls */ > #endif Again, same point; also, that "SYS4" should be "SYS5". > /* Device Characteristics for UNIX SYSTEM III */ > #ifdef SYS5 ... The comment is typoed (minor nit). > /* transfer current modes to new structure */ > ttysnew.c_version = ttys.c_version; /* termio structure version */ > ttysnew.c_iflag = ttys.c_iflag; /* input flags */ ... All System V systems should support structure assignment, if you want it. "c_version" must have been something that Ridge (or somebody) added; it is not present in standard System V. Using structure assignment would make this code work, whether or not there was a "c_version" field. > > ttysnew.sg_flags |= RAW; /* set for RAW Mode */ ... This is completely wrong. This is just the V7 code, which won't work on a "termio" structure (as it doesn't have an "sg_flags" field. Replace all the code that fiddles with the "sg_flags" field with: ttysnew.c_iflag = 0; /* turn off all input mapping */ ttysnew.c_oflag &= ~OPOST; /* turn off all output mapping */ ttysnew.c_cflag &= ~(CSIZE|PARENB|PARODD); /* turn off parity, clear out character size */ ttysnew.c_cflag |= CS8; /* set character size to 8 bits */ ttysnew.c_lflag = 0; /* turn off all special processing */ > /* restore normal tty modes */ > restoremodes(errcall) > int errcall; > { ... This has no #define for System V. The correct code for System III and System V is: > /* Device characteristic restoration for UNIX SYSTEM III */ > #ifdef SYS3 > if (wason) > if (chmod(tty, statbuf.st_mode | 022) < 0) > error("Can't change TTY mode", FALSE); > > if (ioctl(0, TCSETAW, &ttys) < 0) /* restore original tty modes */ ... > /* print data on TTY setting */ > ttyparams() > { ... This has no code for System V. Code should be written for System V, and the same code used for System III. Guy Harris {seismo,ihnp4,allegra}!rlgvax!guy