Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ukma!uflorida!novavax!infocenter!mhoffman From: mhoffman@infocenter.UUCP (Mike Hoffman) Newsgroups: comp.unix.questions Subject: Re: To curse or not to curse Message-ID: <2663@infocenter.UUCP> Date: 9 Jun 89 13:56:11 GMT References: <1cIi02Ph32aV01@amdahl.uts.amdahl.com> Organization: Gould CSD, Fort Lauderdale, FL Lines: 49 in article <1cIi02Ph32aV01@amdahl.uts.amdahl.com>, kucharsk@uts.amdahl.com (William Kucharski) says: > > Here's a program which demonstrates one way of doing things: > > #include > #include > > main() > { > int a,c; > char ch[BUF]; > struct termio o,t; > > if (ioctl(0, TCGETA, &o)) > perror("ioctl: get"); > > t = o; > t.c_lflag = 0; /* shut off everything */ > t.c_cc[VEOF] = 1; /* MIN chars == 1 */ > > [rest of code deleted...] This works OK on every system I've worked on, but I understand that some unfortunate souls must work without the benefits of structure assignment. To make the code more portable for those systems without, a #define statement could indicate this capability: . . . #ifdef STRUCTURE_ASST t = o; /* copy structure in one swell foop */ #else t.c_iflag = o.c_iflag; /* copy element by element. . . */ t.c_oflag = o.c_oflag; t.c_cflag = o.c_cflag; t.c_lflag = 0; /* inserting the desired changes */ t.c_line = o.c_line; *t.cc = *o.cc; t.cc[VEOF] = 1; #endif . . . [rest of code] Michael J. Hoffman Voice: (407)255-8116 Manufacturing Engineering FAX: (407)255-8186 Encore Computer Corporation Email: mhoffman USnail: 100 N. Babcock St. UUCP: {uunet,codas!novavax,sun,pur-ee}!gould!mhoffman Melbourne, Fl 32935 "My opinions are my own and are not to be employed with those of my confuser."