To curse or not to curse
Mike Hoffman
mhoffman at infocenter.UUCP
Fri Jun 9 23:56:11 AEST 1989
in article <1cIi02Ph32aV01 at amdahl.uts.amdahl.com>, kucharsk at uts.amdahl.com (William Kucharski) says:
>
> Here's a program which demonstrates one way of doing things:
>
> #include <stdio.h>
> #include <termio.h>
>
> 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."
More information about the Comp.unix.questions
mailing list