C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 7th, 2003, 11:20 AM
bass20 bass20 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 16 bass20 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
ioctl() and termios for "canonical" read

Well, this app is giving me quite a headache
I need to have a program read a char at a time and then process it, using read(). Therefore, I'll have to set the terminal to canonical mode (correct?), using ioctl() along with termios' flags. What I just can't get is what flag to use and wich values to set (I've already read ALL the man page...). My best bet is using the c_lflag and manipulating it's ICANON value. Can somebody point out a good solution for this problem? Some sample code would be usefull, I'm not very skilled...

Thanx in advance!

PS: I can't use getchar

Reply With Quote
  #2  
Old May 8th, 2003, 05:49 PM
bass20 bass20 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 16 bass20 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Here's how to, if anyone ever needs it

main(){

struct termios oldT, newT;
char c;

ioctl(0,TCGETS,&oldT); /*get current mode

newT=oldT;
newT.c_lflag &= ~ECHO; /* echo off */
newT.c_lflag &= ~ICANON; /*one char @ a time*/

ioctl(0,TCSETS,&newT); /* set new terminal mode */

read(0,&c,1); /*read 1 char @ a time from stdin*/

ioctl(0,TCSETS,&oldT); /* restore previous terminal mode */

}

Detailed info on: http://www.unidata.ucar.edu/cgi-bin/man-cgi?termio+7

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > ioctl() and termios for "canonical" read

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap