Skip to content

Commit

Permalink
remove helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
anoushk1234 committed Feb 22, 2025
1 parent e89429e commit ab6acb5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 30 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;
}
2 changes: 0 additions & 2 deletions src/app/fdctl/monitor/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,4 @@ printf_pct( char ** buf,
ulong den_then,
double lhopital_den );

int
fd_getch(void);
#endif /* HEADER_fd_src_app_fdctl_monitor_helper_h */

0 comments on commit ab6acb5

Please sign in to comment.