Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!venera!isi.edu!raveling From: raveling@isi.edu (Paul Raveling) Newsgroups: comp.sys.hp Subject: Re: CBREAK mode Message-ID: <11956@venera.UUCP> Date: 21 Feb 90 01:48:48 GMT References: Sender: news@venera.UUCP Reply-To: raveling@isi.edu (Paul Raveling) Organization: USC Information Sciences Institute Lines: 89 In article , sukmi@cs.psu.edu (Sukmi Lim) writes: > I was in the middle of installing rn on HP9000 series 300 running HP-UX6.5. > I've got a syntax error saying "CBREAK not defined." > I understand CBREAK is defined in ioctl.h on BSD Unix. > But it was not the case on our machine. But, I know CBREAK mode is supported > on HP machine. Could anyone tell me the mode which is equivalent to CBREAK > mode? Thank you in advance. Appended below are cbreak() and normal() functions, which are equivalent to setting or clearing CBREAK, respectively. Credit for these goes to Dave Decot. This copy came from an article on this newsgroup in the dim past, but the same code keeps on working like a champ as time goes by. ---------------- Paul Raveling Raveling@isi.edu -------------------------------- Cut Here --------------------------------- /* Routines for managing nonechoing, one-character-at-a-time tty reads */ /* Dave Decot, hpda!decot, 851023 */ /* cbreak() - sets terminal up for one-char-at-a-time reads */ /* normal() - restores terminal to initial state */ #include #include #include #ifndef hpux /* BSD style */ # include #else hpux /* HP-UX style (and other System V systems) */ # include #endif hpux static int tty_mode = 0; #ifdef TCGETA static struct termio orig_tty; static struct termio new_tty; #else static struct sgttyb orig_tty; static struct sgttyb new_tty; #endif cbreak() { if (tty_mode == 0) { #ifdef TCGETA ioctl(0, TCGETA, &orig_tty); #else ioctl(0, TIOCGETP, &orig_tty); #endif tty_mode = 1; new_tty = orig_tty; } #ifdef ICANON new_tty.c_lflag &= ~(ICANON | ECHO); new_tty.c_cc[VMIN] = 1; new_tty.c_cc[VTIME] = 0; ioctl(0, TCSETA, &new_tty); #else new_tty.sg_flags |= CBREAK; new_tty.sg_flags &= ~ECHO; ioctl(0, TIOCSETN, &new_tty); #endif } normal() { if (tty_mode == 1) { #ifdef TCSETA ioctl(0, TCSETA, &orig_tty); #else ioctl(0, TIOCSETN, &orig_tty); #endif new_tty = orig_tty; } }