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"
|
EXEC_FILE="$PROJECT.exe"
|
||||||
SHARED_LIB_FILE="$PROJECT.dll"
|
SHARED_LIB_FILE="$PROJECT.dll"
|
||||||
INCLUDE="$INCLUDE "
|
INCLUDE="$INCLUDE "
|
||||||
LINKER_LIBS="-lpthread -lws2_32 -lreadline"
|
LINKER_LIBS="-lpthread -lws2_32"
|
||||||
;;
|
;;
|
||||||
LINUX)
|
LINUX)
|
||||||
EXEC_FILE="$PROJECT"
|
EXEC_FILE="$PROJECT"
|
||||||
SHARED_LIB_FILE="$PROJECT.so"
|
SHARED_LIB_FILE="$PROJECT.so"
|
||||||
INCLUDE="$INCLUDE "
|
INCLUDE="$INCLUDE "
|
||||||
LINKER_LIBS="-lreadline"
|
LINKER_LIBS=""
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
error "operating system $OS has no configuration variants"
|
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 "client.h"
|
||||||
#include <stdio.h>
|
|
||||||
#include <readline/readline.h>
|
|
||||||
#include <readline/history.h>
|
|
||||||
#include "term.h"
|
#include "term.h"
|
||||||
|
|
||||||
static const str greeting_art = STR(
|
static const str greeting_art = STR(
|
||||||
@ -46,25 +41,23 @@ Result(void) client_run() {
|
|||||||
if(!term_init()){
|
if(!term_init()){
|
||||||
Return RESULT_ERROR("can't init terminal", false);
|
Return RESULT_ERROR("can't init terminal", false);
|
||||||
}
|
}
|
||||||
using_history();
|
|
||||||
|
|
||||||
fputs(greeting_art.data, stdout);
|
fputs(greeting_art.data, stdout);
|
||||||
try_void(askUserNameAndPassword(&_client_credential));
|
try_void(askUserNameAndPassword(&_client_credential));
|
||||||
|
|
||||||
char* command_input_prev = NULL;
|
Array(char) input_buf = Array_alloc(char, 10000);
|
||||||
char* command_input_raw = NULL;
|
|
||||||
Defer(rl_free(command_input_prev));
|
|
||||||
str command_input = str_null;
|
str command_input = str_null;
|
||||||
bool stop = false;
|
bool stop = false;
|
||||||
while(!stop && (command_input_raw = readline("> "))){
|
while(!stop){
|
||||||
rl_free(command_input_prev);
|
fputs("> ", stdout);
|
||||||
command_input_prev = command_input_raw;
|
if(fgets(input_buf.data, input_buf.size, stdin) == NULL)
|
||||||
command_input = str_from_cstr(command_input_raw);
|
continue;
|
||||||
|
|
||||||
|
command_input = str_from_cstr(input_buf.data);
|
||||||
str_trim(&command_input, true);
|
str_trim(&command_input, true);
|
||||||
if(command_input.size == 0)
|
if(command_input.size == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
add_history(command_input.data);
|
|
||||||
Result(void) com_result = commandExec(command_input, &stop);
|
Result(void) com_result = commandExec(command_input, &stop);
|
||||||
if(com_result.error){
|
if(com_result.error){
|
||||||
str e_str = Error_toStr(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);
|
ClientCredential_free(_client_credential);
|
||||||
ServerConnection_close(_server_connection);
|
ServerConnection_close(_server_connection);
|
||||||
Return RESULT_VOID;
|
Return RESULT_VOID;
|
||||||
@ -123,7 +117,7 @@ static Result(void) commandExec(str command, bool* stop){
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Return RESULT_ERROR_FMT("unknown kommand: '%s'\n"
|
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);
|
command.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user