diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-09-04 13:47:12 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-09-04 13:47:12 +0200 |
commit | cd0e606efe969d8361fd38b4ca959183feeddc9b (patch) | |
tree | 708fd6bc11897513c46a773442d9fa5d24442c5b | |
parent | 1eb9f4df776adc5dc5cf74a587288199bbf8b703 (diff) | |
download | mad-cd0e606efe969d8361fd38b4ca959183feeddc9b.tar mad-cd0e606efe969d8361fd38b4ca959183feeddc9b.zip |
Don't use GNU readline
-rw-r--r-- | CMakeLists.txt | 19 | ||||
-rw-r--r-- | FindReadline.cmake | 17 | ||||
-rw-r--r-- | src/Common/XmlData.cpp | 2 | ||||
-rw-r--r-- | src/Common/XmlData.h | 2 | ||||
-rw-r--r-- | src/madc.cpp | 30 | ||||
-rw-r--r-- | src/modules/CMakeLists.txt | 8 |
6 files changed, 33 insertions, 45 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 70ef036..d0d1ebb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,19 +3,14 @@ project(MAD) set(CMAKE_MODULE_PATH ${MAD_SOURCE_DIR}) +find_package(Boost REQUIRED date_time filesystem regex signals system thread) +find_package(Editline REQUIRED) find_package(LibXml2 REQUIRED) find_package(Mhash REQUIRED) find_package(OpenSSL REQUIRED) -find_package(Boost REQUIRED date_time filesystem regex signals system thread) -find_package(MySQL) -find_package(KRB5 COMPONENTS krb5 kadm-client) -find_package(Editline) -if(NOT EDITLINE_FOUND) - find_package(Readline REQUIRED) - set(EDITLINE_LIBRARY ${READLINE_LIBRARY}) - set(EDITLINE_INCLUDE_DIR ${READLINE_INCLUDE_DIR}) -endif(NOT EDITLINE_FOUND) +find_package(KRB5 COMPONENTS krb5 kadm-client) +find_package(MySQL) if(WIN32) add_definitions(-DWINVER=0x0501 -D_WIN32_WINNT=0x0501) @@ -37,12 +32,12 @@ configure_file(${MAD_SOURCE_DIR}/config.h.in ${MAD_BINARY_DIR}/config.h) set(INCLUDES ${MAD_SOURCE_DIR}/src ${MAD_BINARY_DIR} - ${LIBXML2_INCLUDE_DIR} - ${MHASH_INCLUDE_DIR} + ${Boost_INCLUDE_DIR} ${DL_INCLUDE_DIR} ${EDITLINE_INCLUDE_DIR} + ${LIBXML2_INCLUDE_DIR} + ${MHASH_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} - ${Boost_INCLUDE_DIR} ) add_subdirectory(src) diff --git a/FindReadline.cmake b/FindReadline.cmake deleted file mode 100644 index 74dc302..0000000 --- a/FindReadline.cmake +++ /dev/null @@ -1,17 +0,0 @@ -FIND_PATH(READLINE_INCLUDE_DIR readline/readline.h) -FIND_LIBRARY(READLINE_LIBRARY NAMES readline) - -IF (READLINE_INCLUDE_DIR AND READLINE_LIBRARY) - SET(READLINE_FOUND TRUE) -ENDIF (READLINE_INCLUDE_DIR AND READLINE_LIBRARY) - -IF (READLINE_FOUND) - IF (NOT Readline_FIND_QUIETLY) - MESSAGE(STATUS "Found GNU readline: ${READLINE_LIBRARY}") - ENDIF (NOT Readline_FIND_QUIETLY) -ELSE (READLINE_FOUND) - IF (Readline_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could not find GNU readline") - ENDIF (Readline_FIND_REQUIRED) -ENDIF (READLINE_FOUND) - diff --git a/src/Common/XmlData.cpp b/src/Common/XmlData.cpp index d3c948b..4d1da6e 100644 --- a/src/Common/XmlData.cpp +++ b/src/Common/XmlData.cpp @@ -22,8 +22,6 @@ #include <cstdlib> #include <cstring> -#include <iostream> - namespace Mad { namespace Common { diff --git a/src/Common/XmlData.h b/src/Common/XmlData.h index 216b0f1..6be2b1d 100644 --- a/src/Common/XmlData.h +++ b/src/Common/XmlData.h @@ -37,8 +37,6 @@ #include <boost/variant/variant.hpp> #include <boost/smart_ptr.hpp> -#include <iostream> - namespace Mad { namespace Common { diff --git a/src/madc.cpp b/src/madc.cpp index 1017912..fc95266 100644 --- a/src/madc.cpp +++ b/src/madc.cpp @@ -36,14 +36,10 @@ #include <boost/regex.hpp> +#include <cstdio> #include <iostream> -#ifdef EDITLINE_FOUND -# include <editline/readline.h> -#else -# include <readline/readline.h> -# include <readline/history.h> -#endif +#include <histedit.h> using namespace Mad; @@ -53,6 +49,10 @@ static void usage(const std::string &cmd) { std::cerr << "Usage: " << cmd << " [host[:port]]" << std::endl; } +static char* prompt(EditLine* /*e*/) { + return const_cast<char*>("mad> "); +} + int main(int argc, char *argv[]) { if(argc > 2) { usage(argv[0]); @@ -125,19 +125,33 @@ int main(int argc, char *argv[]) { Client::CommandParser commandParser(&application, connection); + EditLine *el = el_init(argv[0], stdin, stdout, stderr); + + el_set(el, EL_EDITOR, "emacs"); + el_set(el, EL_PROMPT, &prompt); + + HistEvent histEv; + History *hist = history_init(); + history(hist, &histEv, H_SETSIZE, 800); + + el_set(el, EL_HIST, history, hist); + while(connection->isConnected() && !commandParser.willDisconnect()) { - char *cmd = readline("mad> "); + const char *cmd = el_gets(el, 0); if(!cmd) { commandParser.requestDisconnect(); } else if(*cmd) { commandParser.parse(cmd); - add_history(cmd); + history(hist, &histEv, H_ENTER, cmd); } else continue; } + history_end(hist); + el_end(el); + connection->waitWhileConnected(); application.getUserManager()->unregisterBackend(networkUserBackend); diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt index e87d6af..b09fff3 100644 --- a/src/modules/CMakeLists.txt +++ b/src/modules/CMakeLists.txt @@ -44,14 +44,14 @@ add_subdirectory(SystemBackendProc) add_subdirectory(UserConfigBackendHome) endif(UNIX) -if(MYSQL_FOUND) -add_subdirectory(UserDBBackendMysql) -endif(MYSQL_FOUND) - if(KRB5_FOUND) add_subdirectory(UserConfigBackendKrb5) endif(KRB5_FOUND) +if(MYSQL_FOUND) +add_subdirectory(UserDBBackendMysql) +endif(MYSQL_FOUND) + SET(STATIC_MODULE_LOADERS "") SET(STATIC_MODULE_LIST "") |