diff --git a/CMakeLists.txt b/CMakeLists.txt index 249e023..6071a54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,31 +1,22 @@ cmake_minimum_required(VERSION 3.3 FATAL_ERROR) list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) -project(tawashi_top VERSION 0.1.11 LANGUAGES NONE) +project(duckbin_top LANGUAGES NONE) include(CTest) -option(TAWASHI_WITH_IP_LOGGING "Enable code in Tawashi that may result in users IPs being stored in the DB or in logs" ON) - set(INCREDIS_FORCE_DISABLE_TESTS ON) set(TAWASHI_SOURCE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}") -set(TAWASHI_GEN_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/include") -set(TAWASHI_CONFIG_PATH "etc" CACHE STRING "Path where config file will be located, absolute or relative to the install prefix") -set(TAWASHI_CONFIG_FILE "tawashi.ini" CACHE STRING "Filename of the config file in TAWASHI_CONFIG_PATH") configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/src/tawashiConfig.h.in" - "${TAWASHI_GEN_INCLUDE_DIR}/tawashiConfig.h" -) -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/config/debug_tawashi.ini.in" - "${CMAKE_CURRENT_BINARY_DIR}/tawashi.ini" + "${CMAKE_CURRENT_SOURCE_DIR}/config/debug_duckbin.ini.in" + "${CMAKE_CURRENT_BINARY_DIR}/duckbin.ini" ) add_subdirectory(lib/incredis) add_subdirectory(lib/mstch) add_subdirectory(lib/houdini) -add_subdirectory(src/tawashi_implem) add_subdirectory(src/tawashi) +add_subdirectory(src/duckbin) install(DIRECTORY html/website/ DESTINATION html) diff --git a/config/debug_tawashi.ini.in b/config/debug_duckbin.ini.in similarity index 77% rename from config/debug_tawashi.ini.in rename to config/debug_duckbin.ini.in index 56aa2ec..d1386c3 100644 --- a/config/debug_tawashi.ini.in +++ b/config/debug_duckbin.ini.in @@ -1,4 +1,4 @@ -[tawashi] +[duckbin] redis_server = 127.0.0.1 redis_port = 6379 redis_mode = inet @@ -7,4 +7,4 @@ host_port = from_downstream highlight_css = sh_greenlcd.css website_root = @CMAKE_CURRENT_BINARY_DIR@/html logging_level = trace -log_file = @CMAKE_CURRENT_BINARY_DIR@/tawashi.log +log_file = @CMAKE_CURRENT_BINARY_DIR@/duckbin.log diff --git a/config/tawashi.ini b/config/duckbin.ini similarity index 93% rename from config/tawashi.ini rename to config/duckbin.ini index 8507a7b..522f32a 100644 --- a/config/tawashi.ini +++ b/config/duckbin.ini @@ -1,4 +1,4 @@ -[tawashi] +[duckbin] redis_server = 127.0.0.1 redis_port = 6379 redis_mode = inet diff --git a/config/nginx/tawashi.conf b/config/nginx/duckbin.conf similarity index 90% rename from config/nginx/tawashi.conf rename to config/nginx/duckbin.conf index 8c9a145..28944db 100644 --- a/config/nginx/tawashi.conf +++ b/config/nginx/duckbin.conf @@ -1,6 +1,6 @@ server { listen 8080; - #server_name tawashi.domain.*; + #server_name duckbin.domain.*; server_name 127.0.0.1; #charset koi8-r; @@ -10,10 +10,10 @@ server { index index.cgi; include uwsgi_params; uwsgi_modifier1 9; - uwsgi_pass unix:/run/uwsgi/tawashi.sock; + uwsgi_pass unix:/run/uwsgi/duckbin.sock; } location ~ (\.css$|Pictures/) { - root /srv/http/tawashi; + root /srv/http/duckbin; } #error_page 404 /404.html; diff --git a/config/uwsgi/tawashi.ini b/config/uwsgi/duckbin.ini similarity index 67% rename from config/uwsgi/tawashi.ini rename to config/uwsgi/duckbin.ini index 5abf2e7..51c4f51 100644 --- a/config/uwsgi/tawashi.ini +++ b/config/uwsgi/duckbin.ini @@ -2,9 +2,9 @@ processes = 4 master = 1 socket = /run/uwsgi/%n.sock -cgi = /srv/http/tawashi/%n.cgi +cgi = /srv/http/duckbin/%n.cgi chmod-socket = 664 strict = true gid = http plugins = cgi -chdir = /srv/http/tawashi +chdir = /srv/http/duckbin diff --git a/src/duckbin/CMakeLists.txt b/src/duckbin/CMakeLists.txt new file mode 100644 index 0000000..8d5bb0f --- /dev/null +++ b/src/duckbin/CMakeLists.txt @@ -0,0 +1,35 @@ +project(duckbin VERSION 0.1.0 LANGUAGES CXX) + +set(DUCKBIN_CONFIG_PATH "etc" CACHE STRING "Path where config file will be located, absolute or relative to the install prefix") +set(DUCKBIN_CONFIG_FILE "duckbin.ini" CACHE STRING "Filename of the config file in DUCKBIN_CONFIG_PATH") + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_executable(${PROJECT_NAME} + main.cpp +) +target_link_libraries(${PROJECT_NAME} + PRIVATE tawashi + #hack - add duckhandy to the project instead of picking from inside redis + PRIVATE duckhandy +) + +set_target_properties( + ${PROJECT_NAME} + PROPERTIES SUFFIX .cgi +) + +target_include_directories(${PROJECT_NAME} + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include +) +install(TARGETS ${PROJECT_NAME} + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin + ARCHIVE DESTINATION lib/static +) + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/duckbin_config.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/include/duckbin_config.h" +) diff --git a/src/duckbin/duckbin_config.h.in b/src/duckbin/duckbin_config.h.in new file mode 100644 index 0000000..e717d11 --- /dev/null +++ b/src/duckbin/duckbin_config.h.in @@ -0,0 +1,25 @@ +/* Copyright 2017, Michele Santullo + * This file is part of "duckbin". + * + * "duckbin" is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * "duckbin" is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with "duckbin". If not, see . + */ + +#pragma once + +#define DUCKBIN_CONFIG_PATH "@DUCKBIN_CONFIG_PATH@" +#define DUCKBIN_CONFIG_FILE "@DUCKBIN_CONFIG_FILE@" +#define DUCKBIN_PATH_PREFIX "@CMAKE_INSTALL_PREFIX@" +#define VERSION_MAJOR @PROJECT_VERSION_MAJOR@ +#define VERSION_MINOR @PROJECT_VERSION_MINOR@ +#define VERSION_PATCH @PROJECT_VERSION_PATCH@ diff --git a/src/tawashi/main.cpp b/src/duckbin/main.cpp similarity index 88% rename from src/tawashi/main.cpp rename to src/duckbin/main.cpp index 79ca02c..10e738e 100644 --- a/src/tawashi/main.cpp +++ b/src/duckbin/main.cpp @@ -1,21 +1,21 @@ /* Copyright 2017, Michele Santullo - * This file is part of "tawashi". + * This file is part of "duckbin". * - * "tawashi" is free software: you can redistribute it and/or modify + * "duckbin" is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * "tawashi" is distributed in the hope that it will be useful, + * "duckbin" is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with "tawashi". If not, see . + * along with "duckbin". If not, see . */ -#include "tawashiConfig.h" +#include "duckbin_config.h" #include "submit_paste_response.hpp" #include "quick_submit_paste_response.hpp" #include "pastie_response.hpp" @@ -43,16 +43,16 @@ namespace { std::string config_file_path() a_pure; std::string config_file_path() { - mchlib::PathName config_path(TAWASHI_CONFIG_PATH); + mchlib::PathName config_path(DUCKBIN_CONFIG_PATH); mchlib::PathName full_path(""); if (config_path.is_absolute()) { full_path = std::move(config_path); } else { - full_path = mchlib::PathName(TAWASHI_PATH_PREFIX); + full_path = mchlib::PathName(DUCKBIN_PATH_PREFIX); full_path.join(config_path); } - full_path.join(TAWASHI_CONFIG_FILE); + full_path.join(DUCKBIN_CONFIG_FILE); return full_path.path(); } @@ -95,9 +95,9 @@ namespace { std::cout << "no (Debug build)"; #endif std::cout << '\n'; - std::cout << "TAWASHI_CONFIG_FILE: \"" << TAWASHI_CONFIG_FILE << "\"\n"; - std::cout << "TAWASHI_CONFIG_PATH: \"" << TAWASHI_CONFIG_PATH << "\"\n"; - std::cout << "TAWASHI_PATH_PREFIX: \"" << TAWASHI_PATH_PREFIX << "\"\n"; + std::cout << "DUCKBIN_CONFIG_FILE: \"" << DUCKBIN_CONFIG_FILE << "\"\n"; + std::cout << "DUCKBIN_CONFIG_PATH: \"" << DUCKBIN_CONFIG_PATH << "\"\n"; + std::cout << "DUCKBIN_PATH_PREFIX: \"" << DUCKBIN_PATH_PREFIX << "\"\n"; std::cout << "VERSION_MAJOR: " << VERSION_MAJOR << '\n'; std::cout << "VERSION_MINOR: " << VERSION_MINOR << '\n'; std::cout << "VERSION_PATCH: " << VERSION_PATCH << '\n'; @@ -147,11 +147,11 @@ int main (int parArgc, char* parArgv[], char* parEnvp[]) { } SafeStackObject ini = load_ini(); - auto settings = SafeStackObject(ini); + auto settings = SafeStackObject(ini, "duckbin"); fill_defaults(*settings); auto statuslog = setup_logging(*settings); - SPDLOG_DEBUG(statuslog, "tawashi started"); + SPDLOG_DEBUG(statuslog, "duckbin started"); int retval = 0; try { statuslog->info("Loaded config: \"{}\"", config_file_path()); @@ -178,6 +178,6 @@ int main (int parArgc, char* parArgv[], char* parEnvp[]) { retval = 1; } - SPDLOG_DEBUG(statuslog, "tawashi done, quitting with {}", retval); + SPDLOG_DEBUG(statuslog, "duckbin done, quitting with {}", retval); return retval; } diff --git a/src/tawashi/CMakeLists.txt b/src/tawashi/CMakeLists.txt index 2816030..d764fd8 100644 --- a/src/tawashi/CMakeLists.txt +++ b/src/tawashi/CMakeLists.txt @@ -1,27 +1,70 @@ -project(tawashi LANGUAGES CXX) +project(tawashi VERSION 0.1.11 LANGUAGES CXX C) + +option(TAWASHI_WITH_IP_LOGGING "Enable code in Tawashi that may result in users IPs being stored in the DB or in logs" ON) + +find_package(Boost 1.53.0 REQUIRED COMPONENTS program_options filesystem system) +find_package(SourceHighlight REQUIRED) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) -add_executable(${PROJECT_NAME} - main.cpp +add_library(${PROJECT_NAME} STATIC + split_get_vars.cpp + response.cpp + submit_paste_response.cpp + cgi_environment_vars.cpp + cgi_env.cpp + num_to_token.cpp + cgi_post.cpp + escapist.cpp + index_response.cpp + pastie_response.cpp + ini_file.cpp + pathname/pathname.cpp + response_factory.cpp + list_highlight_langs.cpp + settings_bag.cpp + sanitized_utf8.cpp + tiger.c + error_response.cpp + tawashi_exception.cpp + http_header.cpp + quick_submit_paste_response.cpp + ip_utils.cpp + mime_split.cpp +) + +target_include_directories(${PROJECT_NAME} + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include + PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/kakoune + PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/mstch/include + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} +) +target_include_directories(${PROJECT_NAME} SYSTEM + PUBLIC ${Boost_INCLUDE_DIRS} + PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/better-enums + PRIVATE ${SourceHighlight_INCLUDE_DIR} + PRIVATE ${TAWASHI_SOURCE_ROOT}/lib/utf8_v2_3_4/source + PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/spdlog/include ) target_link_libraries(${PROJECT_NAME} - PRIVATE tawashi_implem - #hack - add duckhandy to the project instead of picking from inside redis - PRIVATE duckhandy + PRIVATE ${Boost_LIBRARIES} + PRIVATE incredis + PRIVATE ${SourceHighlight_LIBRARIES} + PUBLIC mstch + PRIVATE houdini + PRIVATE pthread ) - -set_target_properties( - ${PROJECT_NAME} - PROPERTIES SUFFIX .cgi +target_compile_definitions(${PROJECT_NAME} + PRIVATE BOOST_SPIRIT_USE_PHOENIX_V3=1 + PUBLIC $<$:SPDLOG_DEBUG_ON> + PUBLIC $<$:SPDLOG_TRACE_ON> ) - -target_include_directories(${PROJECT_NAME} - PRIVATE ${TAWASHI_GEN_INCLUDE_DIR} +target_compile_options(${PROJECT_NAME} + PRIVATE -fdiagnostics-color=always ) -install(TARGETS ${PROJECT_NAME} - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin - ARCHIVE DESTINATION lib/static + +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/tawashi_config.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/include/tawashi_config.h" ) diff --git a/src/tawashi_implem/cgi_env.cpp b/src/tawashi/cgi_env.cpp similarity index 100% rename from src/tawashi_implem/cgi_env.cpp rename to src/tawashi/cgi_env.cpp diff --git a/src/tawashi_implem/cgi_env.hpp b/src/tawashi/cgi_env.hpp similarity index 100% rename from src/tawashi_implem/cgi_env.hpp rename to src/tawashi/cgi_env.hpp diff --git a/src/tawashi_implem/cgi_environment_vars.cpp b/src/tawashi/cgi_environment_vars.cpp similarity index 100% rename from src/tawashi_implem/cgi_environment_vars.cpp rename to src/tawashi/cgi_environment_vars.cpp diff --git a/src/tawashi_implem/cgi_environment_vars.hpp b/src/tawashi/cgi_environment_vars.hpp similarity index 100% rename from src/tawashi_implem/cgi_environment_vars.hpp rename to src/tawashi/cgi_environment_vars.hpp diff --git a/src/tawashi_implem/cgi_post.cpp b/src/tawashi/cgi_post.cpp similarity index 100% rename from src/tawashi_implem/cgi_post.cpp rename to src/tawashi/cgi_post.cpp diff --git a/src/tawashi_implem/cgi_post.hpp b/src/tawashi/cgi_post.hpp similarity index 100% rename from src/tawashi_implem/cgi_post.hpp rename to src/tawashi/cgi_post.hpp diff --git a/src/tawashi_implem/error_reasons.hpp b/src/tawashi/error_reasons.hpp similarity index 100% rename from src/tawashi_implem/error_reasons.hpp rename to src/tawashi/error_reasons.hpp diff --git a/src/tawashi_implem/error_response.cpp b/src/tawashi/error_response.cpp similarity index 100% rename from src/tawashi_implem/error_response.cpp rename to src/tawashi/error_response.cpp diff --git a/src/tawashi_implem/error_response.hpp b/src/tawashi/error_response.hpp similarity index 100% rename from src/tawashi_implem/error_response.hpp rename to src/tawashi/error_response.hpp diff --git a/src/tawashi_implem/escapist.cpp b/src/tawashi/escapist.cpp similarity index 100% rename from src/tawashi_implem/escapist.cpp rename to src/tawashi/escapist.cpp diff --git a/src/tawashi_implem/escapist.hpp b/src/tawashi/escapist.hpp similarity index 100% rename from src/tawashi_implem/escapist.hpp rename to src/tawashi/escapist.hpp diff --git a/src/tawashi_implem/http_header.cpp b/src/tawashi/http_header.cpp similarity index 100% rename from src/tawashi_implem/http_header.cpp rename to src/tawashi/http_header.cpp diff --git a/src/tawashi_implem/http_header.hpp b/src/tawashi/http_header.hpp similarity index 100% rename from src/tawashi_implem/http_header.hpp rename to src/tawashi/http_header.hpp diff --git a/src/tawashi_implem/index_response.cpp b/src/tawashi/index_response.cpp similarity index 100% rename from src/tawashi_implem/index_response.cpp rename to src/tawashi/index_response.cpp diff --git a/src/tawashi_implem/index_response.hpp b/src/tawashi/index_response.hpp similarity index 100% rename from src/tawashi_implem/index_response.hpp rename to src/tawashi/index_response.hpp diff --git a/src/tawashi_implem/ini_file.cpp b/src/tawashi/ini_file.cpp similarity index 100% rename from src/tawashi_implem/ini_file.cpp rename to src/tawashi/ini_file.cpp diff --git a/src/tawashi_implem/ini_file.hpp b/src/tawashi/ini_file.hpp similarity index 100% rename from src/tawashi_implem/ini_file.hpp rename to src/tawashi/ini_file.hpp diff --git a/src/tawashi_implem/ip_utils.cpp b/src/tawashi/ip_utils.cpp similarity index 99% rename from src/tawashi_implem/ip_utils.cpp rename to src/tawashi/ip_utils.cpp index 9a0c9fd..7ac25d9 100644 --- a/src/tawashi_implem/ip_utils.cpp +++ b/src/tawashi/ip_utils.cpp @@ -19,7 +19,7 @@ #include "duckhandy/lexical_cast.hpp" #include "duckhandy/int_to_string_ary.hpp" #include "cgi_env.hpp" -#include "tawashiConfig.h" +#include "tawashi_config.h" #include #include #include diff --git a/src/tawashi_implem/ip_utils.hpp b/src/tawashi/ip_utils.hpp similarity index 100% rename from src/tawashi_implem/ip_utils.hpp rename to src/tawashi/ip_utils.hpp diff --git a/src/tawashi_implem/list_highlight_langs.cpp b/src/tawashi/list_highlight_langs.cpp similarity index 100% rename from src/tawashi_implem/list_highlight_langs.cpp rename to src/tawashi/list_highlight_langs.cpp diff --git a/src/tawashi_implem/list_highlight_langs.hpp b/src/tawashi/list_highlight_langs.hpp similarity index 100% rename from src/tawashi_implem/list_highlight_langs.hpp rename to src/tawashi/list_highlight_langs.hpp diff --git a/src/tawashi_implem/logger.hpp b/src/tawashi/logger.hpp similarity index 100% rename from src/tawashi_implem/logger.hpp rename to src/tawashi/logger.hpp diff --git a/src/tawashi_implem/logging_levels.hpp b/src/tawashi/logging_levels.hpp similarity index 100% rename from src/tawashi_implem/logging_levels.hpp rename to src/tawashi/logging_levels.hpp diff --git a/src/tawashi_implem/mime_split.cpp b/src/tawashi/mime_split.cpp similarity index 100% rename from src/tawashi_implem/mime_split.cpp rename to src/tawashi/mime_split.cpp diff --git a/src/tawashi_implem/mime_split.hpp b/src/tawashi/mime_split.hpp similarity index 100% rename from src/tawashi_implem/mime_split.hpp rename to src/tawashi/mime_split.hpp diff --git a/src/tawashi_implem/num_conv.hpp b/src/tawashi/num_conv.hpp similarity index 100% rename from src/tawashi_implem/num_conv.hpp rename to src/tawashi/num_conv.hpp diff --git a/src/tawashi_implem/num_to_token.cpp b/src/tawashi/num_to_token.cpp similarity index 100% rename from src/tawashi_implem/num_to_token.cpp rename to src/tawashi/num_to_token.cpp diff --git a/src/tawashi_implem/num_to_token.hpp b/src/tawashi/num_to_token.hpp similarity index 100% rename from src/tawashi_implem/num_to_token.hpp rename to src/tawashi/num_to_token.hpp diff --git a/src/tawashi_implem/pastie_response.cpp b/src/tawashi/pastie_response.cpp similarity index 100% rename from src/tawashi_implem/pastie_response.cpp rename to src/tawashi/pastie_response.cpp diff --git a/src/tawashi_implem/pastie_response.hpp b/src/tawashi/pastie_response.hpp similarity index 100% rename from src/tawashi_implem/pastie_response.hpp rename to src/tawashi/pastie_response.hpp diff --git a/src/tawashi_implem/pathname/pathname.cpp b/src/tawashi/pathname/pathname.cpp similarity index 100% rename from src/tawashi_implem/pathname/pathname.cpp rename to src/tawashi/pathname/pathname.cpp diff --git a/src/tawashi_implem/pathname/pathname.hpp b/src/tawashi/pathname/pathname.hpp similarity index 100% rename from src/tawashi_implem/pathname/pathname.hpp rename to src/tawashi/pathname/pathname.hpp diff --git a/src/tawashi_implem/pathname/stringpool.hpp b/src/tawashi/pathname/stringpool.hpp similarity index 100% rename from src/tawashi_implem/pathname/stringpool.hpp rename to src/tawashi/pathname/stringpool.hpp diff --git a/src/tawashi_implem/pathname/stringpool.inl b/src/tawashi/pathname/stringpool.inl similarity index 100% rename from src/tawashi_implem/pathname/stringpool.inl rename to src/tawashi/pathname/stringpool.inl diff --git a/src/tawashi_implem/quick_submit_paste_response.cpp b/src/tawashi/quick_submit_paste_response.cpp similarity index 100% rename from src/tawashi_implem/quick_submit_paste_response.cpp rename to src/tawashi/quick_submit_paste_response.cpp diff --git a/src/tawashi_implem/quick_submit_paste_response.hpp b/src/tawashi/quick_submit_paste_response.hpp similarity index 100% rename from src/tawashi_implem/quick_submit_paste_response.hpp rename to src/tawashi/quick_submit_paste_response.hpp diff --git a/src/tawashi_implem/request_method_type.hpp b/src/tawashi/request_method_type.hpp similarity index 100% rename from src/tawashi_implem/request_method_type.hpp rename to src/tawashi/request_method_type.hpp diff --git a/src/tawashi_implem/response.cpp b/src/tawashi/response.cpp similarity index 99% rename from src/tawashi_implem/response.cpp rename to src/tawashi/response.cpp index 78b3c50..9fbc648 100644 --- a/src/tawashi_implem/response.cpp +++ b/src/tawashi/response.cpp @@ -18,7 +18,7 @@ #include "response.hpp" #include "incredis/incredis.hpp" #include "settings_bag.hpp" -#include "tawashiConfig.h" +#include "tawashi_config.h" #include "duckhandy/stringize.h" #include "duckhandy/lexical_cast.hpp" #include "pathname/pathname.hpp" diff --git a/src/tawashi_implem/response.hpp b/src/tawashi/response.hpp similarity index 100% rename from src/tawashi_implem/response.hpp rename to src/tawashi/response.hpp diff --git a/src/tawashi_implem/response_factory.cpp b/src/tawashi/response_factory.cpp similarity index 100% rename from src/tawashi_implem/response_factory.cpp rename to src/tawashi/response_factory.cpp diff --git a/src/tawashi_implem/response_factory.hpp b/src/tawashi/response_factory.hpp similarity index 100% rename from src/tawashi_implem/response_factory.hpp rename to src/tawashi/response_factory.hpp diff --git a/src/tawashi_implem/safe_stack_object.hpp b/src/tawashi/safe_stack_object.hpp similarity index 100% rename from src/tawashi_implem/safe_stack_object.hpp rename to src/tawashi/safe_stack_object.hpp diff --git a/src/tawashi_implem/sanitized_utf8.cpp b/src/tawashi/sanitized_utf8.cpp similarity index 100% rename from src/tawashi_implem/sanitized_utf8.cpp rename to src/tawashi/sanitized_utf8.cpp diff --git a/src/tawashi_implem/sanitized_utf8.hpp b/src/tawashi/sanitized_utf8.hpp similarity index 100% rename from src/tawashi_implem/sanitized_utf8.hpp rename to src/tawashi/sanitized_utf8.hpp diff --git a/src/tawashi_implem/settings_bag.cpp b/src/tawashi/settings_bag.cpp similarity index 90% rename from src/tawashi_implem/settings_bag.cpp rename to src/tawashi/settings_bag.cpp index bbb8277..d23609d 100644 --- a/src/tawashi_implem/settings_bag.cpp +++ b/src/tawashi/settings_bag.cpp @@ -21,26 +21,26 @@ #include #include #include -#include +#include namespace tawashi { namespace { - const IniFile::KeyValueMapType* get_tawashi_node (const IniFile& parIni) { - auto it_found = parIni.parsed().find("tawashi"); + const IniFile::KeyValueMapType* get_tawashi_node (const IniFile& parIni, boost::string_ref parSectionName) { + auto it_found = parIni.parsed().find(parSectionName); if (parIni.parsed().end() != it_found) { return &it_found->second; } else { - spdlog::get("statuslog")->warn("Couldn't find section [tawashi] in the settings file"); + std::cerr << "Couldn't find section [" << parSectionName << "] in the settings file\n"; static const IniFile::KeyValueMapType empty_key_values; return &empty_key_values; } } } //unnamed namespace - SettingsBag::SettingsBag (const Kakoune::SafePtr& parIni) : + SettingsBag::SettingsBag (const Kakoune::SafePtr& parIni, boost::string_ref parSectionName) : m_ini(parIni), - m_values(get_tawashi_node(*parIni)) + m_values(get_tawashi_node(*parIni, parSectionName)) { assert(m_values); } diff --git a/src/tawashi_implem/settings_bag.hpp b/src/tawashi/settings_bag.hpp similarity index 95% rename from src/tawashi_implem/settings_bag.hpp rename to src/tawashi/settings_bag.hpp index 105ace4..93d6756 100644 --- a/src/tawashi_implem/settings_bag.hpp +++ b/src/tawashi/settings_bag.hpp @@ -31,7 +31,7 @@ namespace tawashi { class SettingsBag : public Kakoune::SafeCountable { typedef std::map MapType; public: - explicit SettingsBag (const Kakoune::SafePtr& parIni); + SettingsBag (const Kakoune::SafePtr& parIni, boost::string_ref parSectionName); ~SettingsBag() noexcept; const boost::string_ref& operator[] (boost::string_ref parIndex) const; diff --git a/src/tawashi_implem/spdlog.hpp b/src/tawashi/spdlog.hpp similarity index 100% rename from src/tawashi_implem/spdlog.hpp rename to src/tawashi/spdlog.hpp diff --git a/src/tawashi_implem/split_get_vars.cpp b/src/tawashi/split_get_vars.cpp similarity index 100% rename from src/tawashi_implem/split_get_vars.cpp rename to src/tawashi/split_get_vars.cpp diff --git a/src/tawashi_implem/split_get_vars.hpp b/src/tawashi/split_get_vars.hpp similarity index 100% rename from src/tawashi_implem/split_get_vars.hpp rename to src/tawashi/split_get_vars.hpp diff --git a/src/tawashi_implem/string_lengths.hpp b/src/tawashi/string_lengths.hpp similarity index 100% rename from src/tawashi_implem/string_lengths.hpp rename to src/tawashi/string_lengths.hpp diff --git a/src/tawashi_implem/submit_paste_response.cpp b/src/tawashi/submit_paste_response.cpp similarity index 100% rename from src/tawashi_implem/submit_paste_response.cpp rename to src/tawashi/submit_paste_response.cpp diff --git a/src/tawashi_implem/submit_paste_response.hpp b/src/tawashi/submit_paste_response.hpp similarity index 100% rename from src/tawashi_implem/submit_paste_response.hpp rename to src/tawashi/submit_paste_response.hpp diff --git a/src/tawashiConfig.h.in b/src/tawashi/tawashi_config.h.in similarity index 85% rename from src/tawashiConfig.h.in rename to src/tawashi/tawashi_config.h.in index 1956ee2..5827a36 100644 --- a/src/tawashiConfig.h.in +++ b/src/tawashi/tawashi_config.h.in @@ -17,9 +17,6 @@ #pragma once -#define TAWASHI_CONFIG_PATH "@TAWASHI_CONFIG_PATH@" -#define TAWASHI_CONFIG_FILE "@TAWASHI_CONFIG_FILE@" -#define TAWASHI_PATH_PREFIX "@CMAKE_INSTALL_PREFIX@" #define VERSION_MAJOR @PROJECT_VERSION_MAJOR@ #define VERSION_MINOR @PROJECT_VERSION_MINOR@ #define VERSION_PATCH @PROJECT_VERSION_PATCH@ diff --git a/src/tawashi_implem/tawashi_exception.cpp b/src/tawashi/tawashi_exception.cpp similarity index 100% rename from src/tawashi_implem/tawashi_exception.cpp rename to src/tawashi/tawashi_exception.cpp diff --git a/src/tawashi_implem/tawashi_exception.hpp b/src/tawashi/tawashi_exception.hpp similarity index 100% rename from src/tawashi_implem/tawashi_exception.hpp rename to src/tawashi/tawashi_exception.hpp diff --git a/src/tawashi_implem/tiger.c b/src/tawashi/tiger.c similarity index 100% rename from src/tawashi_implem/tiger.c rename to src/tawashi/tiger.c diff --git a/src/tawashi_implem/tiger.h b/src/tawashi/tiger.h similarity index 100% rename from src/tawashi_implem/tiger.h rename to src/tawashi/tiger.h diff --git a/src/tawashi_implem/CMakeLists.txt b/src/tawashi_implem/CMakeLists.txt deleted file mode 100644 index 7b27dc8..0000000 --- a/src/tawashi_implem/CMakeLists.txt +++ /dev/null @@ -1,63 +0,0 @@ -project(tawashi_implem LANGUAGES CXX C) - -find_package(Boost 1.53.0 REQUIRED COMPONENTS program_options filesystem system) -find_package(SourceHighlight REQUIRED) - -set(CMAKE_CXX_STANDARD 14) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -add_library(${PROJECT_NAME} STATIC - split_get_vars.cpp - response.cpp - submit_paste_response.cpp - cgi_environment_vars.cpp - cgi_env.cpp - num_to_token.cpp - cgi_post.cpp - escapist.cpp - index_response.cpp - pastie_response.cpp - ini_file.cpp - pathname/pathname.cpp - response_factory.cpp - list_highlight_langs.cpp - settings_bag.cpp - sanitized_utf8.cpp - tiger.c - error_response.cpp - tawashi_exception.cpp - http_header.cpp - quick_submit_paste_response.cpp - ip_utils.cpp - mime_split.cpp -) - -target_include_directories(${PROJECT_NAME} - PRIVATE ${TAWASHI_GEN_INCLUDE_DIR} - PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/kakoune - PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/mstch/include - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} -) -target_include_directories(${PROJECT_NAME} SYSTEM - PUBLIC ${Boost_INCLUDE_DIRS} - PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/better-enums - PRIVATE ${SourceHighlight_INCLUDE_DIR} - PRIVATE ${TAWASHI_SOURCE_ROOT}/lib/utf8_v2_3_4/source - PUBLIC ${TAWASHI_SOURCE_ROOT}/lib/spdlog/include -) -target_link_libraries(${PROJECT_NAME} - PRIVATE ${Boost_LIBRARIES} - PRIVATE incredis - PRIVATE ${SourceHighlight_LIBRARIES} - PUBLIC mstch - PRIVATE houdini - PRIVATE pthread -) -target_compile_definitions(${PROJECT_NAME} - PRIVATE BOOST_SPIRIT_USE_PHOENIX_V3=1 - PUBLIC $<$:SPDLOG_DEBUG_ON> - PUBLIC $<$:SPDLOG_TRACE_ON> -) -target_compile_options(${PROJECT_NAME} - PRIVATE -fdiagnostics-color=always -)