From 97cbb707127ae47d7361516acfa34aedf4f41ac4 Mon Sep 17 00:00:00 2001 From: Roker Date: Fri, 4 May 2018 12:24:30 +0200 Subject: [PATCH] --add-sharks --- html/interactive.js | 25 ++++++++++++++++++++++++- server/ev_server.cc | 10 ++++++++++ server/ev_server.hh | 4 ++++ server/main.cc | 8 ++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/html/interactive.js b/html/interactive.js index d7b5326..3c34c86 100644 --- a/html/interactive.js +++ b/html/interactive.js @@ -498,7 +498,30 @@ function init_pep_functions() optionList += ' —— ':'>') + f.name + "\n"; } document.getElementById("fn_name").innerHTML = optionList; - document.getElementById("spn_version").innerHTML = "version: " + server_version + " “" + server_version_name + "”" + document.getElementById("spn_version").innerHTML = "version: " + server_version + " “" + server_version_name + "”"; + + if(add_sharks) + { + var h1 = document.getElementsByTagName("h1")[0]; + var shark = document.createElement("img"); + shark.src = "data:image/png;base64," + + "iVBORw0KGgoAAAANSUhEUgAAAMQAAABYAQMAAACQzMoQAAAABlBMVEUAAAAAAAClZ7nPAA" + + "AAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElN" + + "RQfiBQQJFzochG6lAAAB0UlEQVRIx62WPW7cMBCFH8NCnXUBI8oxXBjRVXyELV1FzClyHQ" + + "IpfA3eIAQCrFUIfCkokjNaMYAXZrWLbzX75s0PBbTzBb0z9InrkdF3SeiSeAdZu2T7OJnS" + + "HYSfS9wdxPeJJclb+2b+JklyuyXlxC5hnxweWhpJ5+SNPGRWHvhFDKpZbCURUIUfC3kD8H" + + "wqLQJ4OPsbukMnmwI2ADCCDCQTSQYAMF4LSM2ZoAVcSa43ZNnJHuZFC7g2x4J24Pqnuhy0" + + "A+/VSqFtyqQU2rpjCQKweD3nzRlDL32zwplxk14PNRhg6BCBKAQUZ2ZvPfBjzzKpxTBiV7" + + "KXs+Rg4yuAeRX1LE799XU4s4DaFlkiXQ1XHbnkX4cSrYkIOcW1eFObOTeBIUt3uMNyJF0W" + + "0II9FpNDFtBqdSmdsWYBzV1fHEtQyWBqLv9UydQ5sHmUmrK6go3ocwCw27HOvoTwJ4MbjR" + + "5rMeyHgZ80WU/m84YM/yWh9NsiF5XlNvnciytmTeLYDNAkjCK0Iv6r+JIkcY9iKBXBk5iW" + + "JFXjmxhxSZLeS4JsvcthPGy5HhnYuyytIJPapkYSfYNIonfz0r7OhzsAPTK1j9+7bxav3Z" + + "eMS5e84IPnH+BiDVEeA5CdAAAAAElFTkSuQmCC"; + shark.alt = "Shark. CC_BY Rachel Haley (AU)."; + shark.width = 98; + shark.height = 44; + h1.insertBefore(shark, h1.childNodes[0]); + } } diff --git a/server/ev_server.cc b/server/ev_server.cc index 91a028b..c0a80dd 100644 --- a/server/ev_server.cc +++ b/server/ev_server.cc @@ -142,6 +142,9 @@ const FunctionMap functions = { FP( "shutdown", new Func>( &JsonAdapter::shutdown_now ) ), }; + + bool add_sharks = false; + } // end of anonymous namespace @@ -250,6 +253,7 @@ void ev_server::OnGetFunctions(evhttp_request* req, void*) "\n" "var server_version_name = \"" + version.name + "\";\n" "var server_version = \"" + version.major_minor_patch() + "\";\n" + "var add_sharks = " + (add_sharks?"true":"false") + ";\n" "var pep_functions = "; js::Array jsonfunctions; @@ -327,4 +331,10 @@ void ev_server::setLogfile(std::ostream* new_logfile) } +void ev_server::addSharks() +{ + add_sharks = true; +} + + std::ostream* ev_server::log_file = &nulllogger; diff --git a/server/ev_server.hh b/server/ev_server.hh index 14bcad9..95b68f9 100644 --- a/server/ev_server.hh +++ b/server/ev_server.hh @@ -37,6 +37,10 @@ public: // if new_logfile is NULL, the logfile is reset to nulllogger. static void setLogfile(std::ostream* new_logfile); + + // add sharks to the JSON Adapter + static + void addSharks(); protected: // prints "evserver:" to the log and returns it to allow << chaining diff --git a/server/main.cc b/server/main.cc index c07e9f8..7139a44 100644 --- a/server/main.cc +++ b/server/main.cc @@ -16,6 +16,8 @@ namespace po = boost::program_options; bool debug_mode = false; bool do_sync = false; bool ignore_missing_session = false; +bool add_sharks = false; + uintptr_t status_handle = 0; std::string address = "127.0.0.1"; @@ -56,6 +58,7 @@ try ("html-directory,H", po::value(&ev_server::path_to_html)->default_value(ev_server::path_to_html), "Path to the HTML and JavaScript files") ("logfile,l", po::value(&logfile)->default_value(logfile), "Name of the logfile. Can be \"stderr\" for log to stderr or empty for no log.") ("ignore-missing-session", po::bool_switch(&ignore_missing_session), "Ignore when no PEP_SESSION can be created.") + ("add-sharks", po::bool_switch(&add_sharks), "Add sharks to the JSON Adapter.") #ifdef _WIN32 ((STATUS_HANDLE), po::value(&status_handle)->default_value(0), "Status file handle, for internal use.") #endif @@ -94,6 +97,11 @@ try my_logfile = real_logfile.get(); } + if(add_sharks) + { + ev_server::addSharks(); + } + if( debug_mode == false ) daemonize (!debug_mode, (const uintptr_t) status_handle);