Skip to content

Commit

Permalink
remove helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
anoushk1234 committed Jan 7, 2025
1 parent ee87073 commit 7a06199
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions src/app/fdctl/monitor/helper.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "helper.h"
#include <termios.h>
#include <fcntl.h>

#include <stdio.h>

#define PRINT( ... ) do { \
Expand Down Expand Up @@ -175,29 +174,3 @@ printf_pct( char ** buf,
if( pct<=999.999 ) { PRINT( " %7.3f", pct ); return; }
/**/ PRINT( ">999.999" );
}


int
fd_getch()
{
struct termios oldt, newt;
int ch;
int oldf;
/* Disables character echo and canonical mode since we want the input to be processes immediately.
* Terminal also set to non blocking in case the user doesn't send any input.
* */
tcgetattr(STDIN_FILENO, &oldt);
newt = oldt;
newt.c_lflag &= (tcflag_t)~(ICANON | ECHO);
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
oldf = fcntl(STDIN_FILENO, F_GETFL, 0);
fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK);

ch = getchar();

/*Restore the terminal back to it's original configuration*/
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
fcntl(STDIN_FILENO, F_SETFL, oldf);

return ch;
}

0 comments on commit 7a06199

Please sign in to comment.