removed libreadline dependency
This commit is contained in:
parent
60a4542328
commit
6bf06a7d3e
2
dependencies/tlibc
vendored
2
dependencies/tlibc
vendored
@ -1 +1 @@
|
||||
Subproject commit a0affaa6d0e4764c9a906bba516c1f7d1ded5405
|
||||
Subproject commit 75c94e88d9a7e12839d343bf4c7978cb7ecf91e1
|
||||
@ -34,13 +34,13 @@ case "$OS" in
|
||||
EXEC_FILE="$PROJECT.exe"
|
||||
SHARED_LIB_FILE="$PROJECT.dll"
|
||||
INCLUDE="$INCLUDE "
|
||||
LINKER_LIBS="-lpthread -lws2_32 -lreadline"
|
||||
LINKER_LIBS="-lpthread -lws2_32"
|
||||
;;
|
||||
LINUX)
|
||||
EXEC_FILE="$PROJECT"
|
||||
SHARED_LIB_FILE="$PROJECT.so"
|
||||
INCLUDE="$INCLUDE "
|
||||
LINKER_LIBS="-lreadline"
|
||||
LINKER_LIBS=""
|
||||
;;
|
||||
*)
|
||||
error "operating system $OS has no configuration variants"
|
||||
|
||||
@ -1,9 +1,4 @@
|
||||
// readline.h doesn't include stdio.h
|
||||
// This bug is older than me)))
|
||||
#include "client.h"
|
||||
#include <stdio.h>
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
#include "term.h"
|
||||
|
||||
static const str greeting_art = STR(
|
||||
@ -46,25 +41,23 @@ Result(void) client_run() {
|
||||
if(!term_init()){
|
||||
Return RESULT_ERROR("can't init terminal", false);
|
||||
}
|
||||
using_history();
|
||||
|
||||
fputs(greeting_art.data, stdout);
|
||||
try_void(askUserNameAndPassword(&_client_credential));
|
||||
|
||||
char* command_input_prev = NULL;
|
||||
char* command_input_raw = NULL;
|
||||
Defer(rl_free(command_input_prev));
|
||||
Array(char) input_buf = Array_alloc(char, 10000);
|
||||
str command_input = str_null;
|
||||
bool stop = false;
|
||||
while(!stop && (command_input_raw = readline("> "))){
|
||||
rl_free(command_input_prev);
|
||||
command_input_prev = command_input_raw;
|
||||
command_input = str_from_cstr(command_input_raw);
|
||||
while(!stop){
|
||||
fputs("> ", stdout);
|
||||
if(fgets(input_buf.data, input_buf.size, stdin) == NULL)
|
||||
continue;
|
||||
|
||||
command_input = str_from_cstr(input_buf.data);
|
||||
str_trim(&command_input, true);
|
||||
if(command_input.size == 0)
|
||||
continue;
|
||||
|
||||
add_history(command_input.data);
|
||||
Result(void) com_result = commandExec(command_input, &stop);
|
||||
if(com_result.error){
|
||||
str e_str = Error_toStr(com_result.error);
|
||||
@ -74,6 +67,7 @@ Result(void) client_run() {
|
||||
}
|
||||
}
|
||||
|
||||
free(input_buf.data);
|
||||
ClientCredential_free(_client_credential);
|
||||
ServerConnection_close(_server_connection);
|
||||
Return RESULT_VOID;
|
||||
@ -123,7 +117,7 @@ static Result(void) commandExec(str command, bool* stop){
|
||||
}
|
||||
else {
|
||||
Return RESULT_ERROR_FMT("unknown kommand: '%s'\n"
|
||||
"Use 'h' to see list of avaliable commands\n",
|
||||
"Use 'h' to see list of avaliable commands",
|
||||
command.data);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user