@@ -58,8 +58,16 @@ struct nc_client_context *nc_client_context_location(void);
5858#define ssh_opts nc_client_context_location()->ssh_opts
5959#define ssh_ch_opts nc_client_context_location()->ssh_ch_opts
6060
61+ /**
62+ * @brief Open a terminal FILE with no echo.
63+ *
64+ * @param[in] path Filesystem terminal path.
65+ * @param[in] oldterm Old terminal options.
66+ * @return Opened terminal;
67+ * @return NULL on error.
68+ */
6169static FILE *
62- open_tty_noecho (const char * path , struct termios * oldterm )
70+ nc_open_tty_noecho (const char * path , struct termios * oldterm )
6371{
6472 struct termios newterm ;
6573 FILE * ret ;
@@ -88,6 +96,14 @@ open_tty_noecho(const char *path, struct termios *oldterm)
8896 return ret ;
8997}
9098
99+ /**
100+ * @brief Open an input terminal FILE.
101+ *
102+ * @param[in] echo Whether to turn echo on or off.
103+ * @param[in] oldterm Old terminal options.
104+ * @return Opened terminal;
105+ * @return NULL on error.
106+ */
91107static FILE *
92108nc_open_in (int echo , struct termios * oldterm )
93109{
@@ -96,7 +112,7 @@ nc_open_in(int echo, struct termios *oldterm)
96112 FILE * in ;
97113
98114 if (!echo ) {
99- in = open_tty_noecho ("/dev/tty" , oldterm );
115+ in = nc_open_tty_noecho ("/dev/tty" , oldterm );
100116 } else {
101117 in = fopen ("/dev/tty" , "r" );
102118 if (!in ) {
@@ -111,7 +127,7 @@ nc_open_in(int echo, struct termios *oldterm)
111127 }
112128
113129 if (!echo ) {
114- in = open_tty_noecho (buf , oldterm );
130+ in = nc_open_tty_noecho (buf , oldterm );
115131 } else {
116132 in = fopen (buf , "r" );
117133 if (!in ) {
@@ -123,6 +139,12 @@ nc_open_in(int echo, struct termios *oldterm)
123139 return in ;
124140}
125141
142+ /**
143+ * @brief Open an output terminal FILE.
144+ *
145+ * @return Opened terminal;
146+ * @return NULL on error.
147+ */
126148static FILE *
127149nc_open_out (void )
128150{
@@ -148,6 +170,14 @@ nc_open_out(void)
148170 return out ;
149171}
150172
173+ /**
174+ * @brief Close an input/output terminal FILE.
175+ *
176+ * @param[in] inout Terminal FILE to close.
177+ * @param[in] echo Old terminal options.
178+ * @return Opened terminal;
179+ * @return NULL on error.
180+ */
151181static void
152182nc_close_inout (FILE * inout , int echo , struct termios * oldterm )
153183{
0 commit comments