@@ -29,7 +29,7 @@ See the Mulan PSL v2 for more details. */
29
29
30
30
#include " common/defs.h"
31
31
#include " common/lang/string.h"
32
- #include " common/linereader/line_interface .h"
32
+ #include " common/linereader/line_reader .h"
33
33
34
34
#define MAX_MEM_BUFFER_SIZE 8192
35
35
#define PORT_DEFAULT 6789
@@ -45,7 +45,7 @@ const std::string LINE_HISTORY_FILE = "./.obclient.history";
45
45
*/
46
46
bool is_exit_command (const char *cmd)
47
47
{
48
- return is_exit_command (cmd, LINE_HISTORY_FILE);
48
+ return LineReaderManager:: is_exit_command (cmd, LINE_HISTORY_FILE);
49
49
}
50
50
51
51
int init_unix_sock (const char *unix_sock_path)
@@ -142,9 +142,8 @@ int main(int argc, char *argv[])
142
142
143
143
char *input_command = nullptr ;
144
144
static time_t previous_history_save_time = 0 ;
145
- static LineInterface reader;
146
145
147
- while ((input_command = my_readline (prompt_str, LINE_HISTORY_FILE)) != nullptr ) {
146
+ while ((input_command = LineReaderManager:: my_readline (prompt_str, LINE_HISTORY_FILE)) != nullptr ) {
148
147
if (common::is_blank (input_command)) {
149
148
free (input_command);
150
149
input_command = nullptr ;
@@ -158,7 +157,7 @@ int main(int argc, char *argv[])
158
157
}
159
158
160
159
if (time (NULL ) - previous_history_save_time > 5 ) {
161
- reader. history_save ( LINE_HISTORY_FILE);
160
+ LineReaderManager::is_exit_command ( " " , LINE_HISTORY_FILE);
162
161
previous_history_save_time = time (NULL );
163
162
}
164
163
@@ -203,7 +202,7 @@ int main(int argc, char *argv[])
203
202
}
204
203
close (sockfd);
205
204
206
- reader. history_save ( LINE_HISTORY_FILE);
205
+ LineReaderManager::is_exit_command ( " " , LINE_HISTORY_FILE);
207
206
printf (" Command history saved to: %s\n " , LINE_HISTORY_FILE.c_str ());
208
207
209
208
return 0 ;
0 commit comments