Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/nto/conio.h

Go to the documentation of this file.
00001 #ifndef __J2K_NTO__CONIO_H__
00002 #define __J2K_NTO__CONIO_H__
00003 
00004 #include <stdio.h>
00005 #include <unistd.h>
00006 #include <termios.h>
00007 #include <time.h>
00008 
00009 inline char getch()
00010 {
00011     fflush( stdin  );
00012     fflush( stdout );
00013     register char ch = 0;
00014     struct timespec rqtp;
00015 
00016    struct termios raw_tios =
00017    {                                        
00018     /* c_iflag */       0,
00019     /* c_oflag */       0,
00020    #ifdef __QNXNTO__
00021     /* c_cflag */       (CREAD|HUPCL),
00022    #else
00023     /* c_cflag */       (CREAD),
00024    #endif
00025    #ifdef __QNXNTO__
00026     /* c_lflag */       0,
00027    #else
00028     /* c_lflag */       (IEXTEN),
00029    #endif
00030    };
00031    struct termios tios;
00032 
00033     rqtp.tv_sec = 0;
00034     rqtp.tv_nsec = 5000000;
00035    tcgetattr(0, &tios);
00036    while (tcischars(0) == 0) {nanosleep(&rqtp, NULL);}
00037    tcsetattr(0, TCSANOW, &raw_tios);
00038 
00039    read (0, &ch, 1);
00040 
00041    tcsetattr(0, TCSANOW, &tios);
00042    return ch;
00043 }
00044 
00045 inline char getche()
00046 {
00047  register char ch = getch();
00048  putc( ch, stdout );
00049  fflush( stdout );
00050  return ch;
00051 }
00052 
00053 inline int kbhit()
00054 {
00055   return ( (tcischars(1) > 0) ? 1 : 0 );
00056 }
00057 
00058 #endif

Generated on Sun Oct 14 18:46:22 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001