diff options
Diffstat (limited to 'common/rfb')
38 files changed, 61 insertions, 842 deletions
diff --git a/common/rfb/CConnection.cxx b/common/rfb/CConnection.cxx index d7b5bfab..725ba5cd 100644 --- a/common/rfb/CConnection.cxx +++ b/common/rfb/CConnection.cxx @@ -27,6 +27,7 @@ #include <algorithm> +#include <core/LogWriter.h> #include <core/util.h> #include <rfb/Exception.h> @@ -47,14 +48,12 @@ #define XK_XKB_KEYS #include <rfb/keysymdef.h> -#include <rfb/LogWriter.h> - #include <rdr/InStream.h> #include <rdr/OutStream.h> using namespace rfb; -static LogWriter vlog("CConnection"); +static core::LogWriter vlog("CConnection"); CConnection::CConnection() : csecurity(nullptr), diff --git a/common/rfb/CMakeLists.txt b/common/rfb/CMakeLists.txt index 6afff9fc..dfdc463b 100644 --- a/common/rfb/CMakeLists.txt +++ b/common/rfb/CMakeLists.txt @@ -25,10 +25,6 @@ add_library(rfb STATIC JpegDecompressor.cxx KeyRemapper.cxx KeysymStr.c - LogWriter.cxx - Logger.cxx - Logger_file.cxx - Logger_stdio.cxx PixelBuffer.cxx PixelFormat.cxx RREEncoder.cxx @@ -77,10 +73,6 @@ if(ENABLE_H264 AND NOT H264_LIBS STREQUAL "NONE") target_link_directories(rfb PUBLIC ${H264_LIBRARY_DIRS}) endif() -if(UNIX) - target_sources(rfb PRIVATE Logger_syslog.cxx) -endif() - if(WIN32) target_include_directories(rfb PUBLIC ${CMAKE_SOURCE_DIR}/win) target_sources(rfb PRIVATE WinPasswdValidator.cxx) diff --git a/common/rfb/CMsgHandler.cxx b/common/rfb/CMsgHandler.cxx index 932b89fe..051a997d 100644 --- a/common/rfb/CMsgHandler.cxx +++ b/common/rfb/CMsgHandler.cxx @@ -23,14 +23,14 @@ #include <stdio.h> +#include <core/LogWriter.h> #include <core/util.h> -#include <rfb/LogWriter.h> #include <rfb/CMsgHandler.h> #include <rfb/clipboardTypes.h> #include <rfb/screenTypes.h> -static rfb::LogWriter vlog("CMsgHandler"); +static core::LogWriter vlog("CMsgHandler"); using namespace rfb; diff --git a/common/rfb/CMsgReader.cxx b/common/rfb/CMsgReader.cxx index 208899ac..e00cb083 100644 --- a/common/rfb/CMsgReader.cxx +++ b/common/rfb/CMsgReader.cxx @@ -26,6 +26,7 @@ #include <vector> +#include <core/LogWriter.h> #include <core/util.h> #include <rdr/InStream.h> @@ -34,14 +35,13 @@ #include <rfb/msgTypes.h> #include <rfb/clipboardTypes.h> #include <rfb/Exception.h> -#include <rfb/LogWriter.h> #include <rfb/CMsgHandler.h> #include <rfb/CMsgReader.h> #include <rfb/PixelBuffer.h> #include <rfb/ScreenSet.h> #include <rfb/encodings.h> -static rfb::LogWriter vlog("CMsgReader"); +static core::LogWriter vlog("CMsgReader"); static core::IntParameter maxCutText("MaxCutText", "Maximum permitted length of an incoming clipboard update", 256*1024); diff --git a/common/rfb/CSecurityRSAAES.cxx b/common/rfb/CSecurityRSAAES.cxx index daa266d9..0a0a5ca0 100644 --- a/common/rfb/CSecurityRSAAES.cxx +++ b/common/rfb/CSecurityRSAAES.cxx @@ -35,11 +35,11 @@ #include <nettle/sha1.h> #include <nettle/sha2.h> +#include <core/LogWriter.h> #include <core/util.h> #include <rfb/CSecurityRSAAES.h> #include <rfb/CConnection.h> -#include <rfb/LogWriter.h> #include <rfb/Exception.h> #include <rdr/AESInStream.h> @@ -60,7 +60,7 @@ const int MaxKeyLength = 8192; using namespace rfb; -static LogWriter vlog("CSecurityRSAAES"); +static core::LogWriter vlog("CSecurityRSAAES"); CSecurityRSAAES::CSecurityRSAAES(CConnection* cc_, uint32_t _secType, int _keySize, bool _isAllEncrypted) diff --git a/common/rfb/CSecurityTLS.cxx b/common/rfb/CSecurityTLS.cxx index 94e022c8..fbd3fe81 100644 --- a/common/rfb/CSecurityTLS.cxx +++ b/common/rfb/CSecurityTLS.cxx @@ -34,11 +34,11 @@ #include <unistd.h> #endif +#include <core/LogWriter.h> #include <core/util.h> #include <rfb/CSecurityTLS.h> #include <rfb/CConnection.h> -#include <rfb/LogWriter.h> #include <rfb/Exception.h> #include <rdr/TLSException.h> @@ -58,7 +58,7 @@ core::StringParameter CSecurityTLS::X509CA("X509CA", "X509 CA certificate", core::StringParameter CSecurityTLS::X509CRL("X509CRL", "X509 CRL file", configdirfn("x509_crl.pem")); -static LogWriter vlog("TLS"); +static core::LogWriter vlog("TLS"); static const char* configdirfn(const char* fn) { diff --git a/common/rfb/CSecurityVeNCrypt.cxx b/common/rfb/CSecurityVeNCrypt.cxx index 1b6ecf22..a6e30947 100644 --- a/common/rfb/CSecurityVeNCrypt.cxx +++ b/common/rfb/CSecurityVeNCrypt.cxx @@ -29,16 +29,17 @@ #include <algorithm> #include <list> +#include <core/LogWriter.h> + #include <rfb/Exception.h> #include <rdr/InStream.h> #include <rdr/OutStream.h> #include <rfb/CConnection.h> #include <rfb/CSecurityVeNCrypt.h> -#include <rfb/LogWriter.h> using namespace rfb; -static LogWriter vlog("CVeNCrypt"); +static core::LogWriter vlog("CVeNCrypt"); CSecurityVeNCrypt::CSecurityVeNCrypt(CConnection* cc_, SecurityClient* sec) diff --git a/common/rfb/ComparingUpdateTracker.cxx b/common/rfb/ComparingUpdateTracker.cxx index f858fee6..6e4d1d9d 100644 --- a/common/rfb/ComparingUpdateTracker.cxx +++ b/common/rfb/ComparingUpdateTracker.cxx @@ -25,15 +25,14 @@ #include <vector> +#include <core/LogWriter.h> #include <core/util.h> -#include <rfb/LogWriter.h> - #include <rfb/ComparingUpdateTracker.h> using namespace rfb; -static LogWriter vlog("ComparingUpdateTracker"); +static core::LogWriter vlog("ComparingUpdateTracker"); ComparingUpdateTracker::ComparingUpdateTracker(PixelBuffer* buffer) : fb(buffer), oldFb(fb->getPF(), 0, 0), firstCompare(true), diff --git a/common/rfb/Congestion.cxx b/common/rfb/Congestion.cxx index 68ad54c9..afe66399 100644 --- a/common/rfb/Congestion.cxx +++ b/common/rfb/Congestion.cxx @@ -49,10 +49,10 @@ #include <linux/sockios.h> #endif +#include <core/LogWriter.h> #include <core/util.h> #include <rfb/Congestion.h> -#include <rfb/LogWriter.h> // Debug output on what the congestion control is up to #undef CONGESTION_DEBUG @@ -79,7 +79,7 @@ static inline bool isAfter(unsigned a, unsigned b) { return a != b && a - b <= UINT_MAX / 2; } -static LogWriter vlog("Congestion"); +static core::LogWriter vlog("Congestion"); Congestion::Congestion() : lastPosition(0), extraBuffer(0), diff --git a/common/rfb/Cursor.cxx b/common/rfb/Cursor.cxx index 764c5b62..e094e4ed 100644 --- a/common/rfb/Cursor.cxx +++ b/common/rfb/Cursor.cxx @@ -26,12 +26,13 @@ #include <stdexcept> +#include <core/LogWriter.h> + #include <rfb/Cursor.h> -#include <rfb/LogWriter.h> using namespace rfb; -static LogWriter vlog("Cursor"); +static core::LogWriter vlog("Cursor"); Cursor::Cursor(int width, int height, const core::Point& hotspot, const uint8_t* data_) : diff --git a/common/rfb/DecodeManager.cxx b/common/rfb/DecodeManager.cxx index 6479b93e..3bd671b5 100644 --- a/common/rfb/DecodeManager.cxx +++ b/common/rfb/DecodeManager.cxx @@ -23,6 +23,7 @@ #include <assert.h> #include <string.h> +#include <core/LogWriter.h> #include <core/Region.h> #include <core/util.h> @@ -30,7 +31,6 @@ #include <rfb/DecodeManager.h> #include <rfb/Decoder.h> #include <rfb/Exception.h> -#include <rfb/LogWriter.h> #include <rdr/MemOutStream.h> @@ -38,7 +38,7 @@ using namespace rfb; -static LogWriter vlog("DecodeManager"); +static core::LogWriter vlog("DecodeManager"); DecodeManager::DecodeManager(CConnection *conn_) : conn(conn_), threadException(nullptr) diff --git a/common/rfb/EncodeManager.cxx b/common/rfb/EncodeManager.cxx index 6087bf28..2d2c7e8a 100644 --- a/common/rfb/EncodeManager.cxx +++ b/common/rfb/EncodeManager.cxx @@ -25,6 +25,7 @@ #include <stdlib.h> +#include <core/LogWriter.h> #include <core/util.h> #include <rfb/Cursor.h> @@ -34,7 +35,6 @@ #include <rfb/SConnection.h> #include <rfb/SMsgWriter.h> #include <rfb/UpdateTracker.h> -#include <rfb/LogWriter.h> #include <rfb/encodings.h> #include <rfb/RawEncoder.h> @@ -46,7 +46,7 @@ using namespace rfb; -static LogWriter vlog("EncodeManager"); +static core::LogWriter vlog("EncodeManager"); // Split each rectangle into smaller ones no larger than this area, // and no wider than this width. diff --git a/common/rfb/KeyRemapper.cxx b/common/rfb/KeyRemapper.cxx index ca4a65b2..eb8635d2 100644 --- a/common/rfb/KeyRemapper.cxx +++ b/common/rfb/KeyRemapper.cxx @@ -24,15 +24,15 @@ #include <string.h> #include <core/Configuration.h> +#include <core/LogWriter.h> #include <os/Mutex.h> #include <rfb/KeyRemapper.h> -#include <rfb/LogWriter.h> using namespace rfb; -static LogWriter vlog("KeyRemapper"); +static core::LogWriter vlog("KeyRemapper"); KeyRemapper KeyRemapper::defInstance; diff --git a/common/rfb/LogWriter.cxx b/common/rfb/LogWriter.cxx deleted file mode 100644 index ad759ff4..00000000 --- a/common/rfb/LogWriter.cxx +++ /dev/null @@ -1,139 +0,0 @@ -/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. - * - * This 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 2 of the License, or - * (at your option) any later version. - * - * This software 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 this software; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - * USA. - */ - -// -=- LogWriter.cxx - client-side logging interface - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdlib.h> -#include <string.h> - -#include <core/Configuration.h> -#include <core/util.h> - -#include <rfb/LogWriter.h> - -rfb::LogParameter rfb::logParams; - -// Temporary during transition to new structure: -using namespace core; -using namespace rfb; - - -LogWriter::LogWriter(const char* name) - : m_name(name), m_level(0), m_log(nullptr), m_next(log_writers) { - log_writers = this; -} - -LogWriter::~LogWriter() { - // *** Should remove this logger here! -} - -void LogWriter::setLog(Logger *logger) { - m_log = logger; -} - -void LogWriter::setLevel(int level) { - m_level = level; -} - -void -LogWriter::listLogWriters(int /*width*/) { - // *** make this respect width... - LogWriter* current = log_writers; - fprintf(stderr, " "); - while (current) { - fprintf(stderr, "%s", current->m_name); - current = current->m_next; - if (current) fprintf(stderr, ", "); - } - fprintf(stderr, "\n"); -} - -LogWriter* LogWriter::log_writers; - -LogWriter* -LogWriter::getLogWriter(const char* name) { - LogWriter* current = log_writers; - while (current) { - if (strcasecmp(name, current->m_name) == 0) return current; - current = current->m_next; - } - return nullptr; -} - -bool LogWriter::setLogParams(const char* params) { - std::vector<std::string> parts; - parts = split(params, ':'); - if (parts.size() != 3) { - fprintf(stderr, "Failed to parse log params:%s\n",params); - return false; - } - int level = atoi(parts[2].c_str()); - Logger* logger = nullptr; - if (!parts[1].empty()) { - logger = Logger::getLogger(parts[1].c_str()); - if (!logger) - fprintf(stderr, "No logger found! %s\n", parts[1].c_str()); - } - if (parts[0] == "*") { - LogWriter* current = log_writers; - while (current) { - current->setLog(logger); - current->setLevel(level); - current = current->m_next; - } - return true; - } else { - LogWriter* logwriter = getLogWriter(parts[0].c_str()); - if (!logwriter) { - fprintf(stderr, "No logwriter found! %s\n", parts[0].c_str()); - } else { - logwriter->setLog(logger); - logwriter->setLevel(level); - return true; - } - } - return false; -} - - -LogParameter::LogParameter() - : StringParameter("Log", - "Specifies which log output should be directed to " - "which target logger, and the level of output to log. " - "Format is <log>:<target>:<level>[, ...].", - "") { -} - -bool LogParameter::setParam(const char* v) { - if (immutable) return true; - LogWriter::setLogParams("*::0"); - StringParameter::setParam(v); - std::vector<std::string> parts; - parts = split(v, ','); - for (size_t i = 0; i < parts.size(); i++) { - if (parts[i].empty()) - continue; - if (!LogWriter::setLogParams(parts[i].c_str())) - return false; - } - return true; -} diff --git a/common/rfb/LogWriter.h b/common/rfb/LogWriter.h deleted file mode 100644 index 5b0057a4..00000000 --- a/common/rfb/LogWriter.h +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. - * - * This 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 2 of the License, or - * (at your option) any later version. - * - * This software 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 this software; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - * USA. - */ - -// -=- LogWriter.h - The Log writer class. - -#ifndef __RFB_LOG_WRITER_H__ -#define __RFB_LOG_WRITER_H__ - -#include <stdarg.h> - -#include <core/Configuration.h> - -#include <rfb/Logger.h> - -// Each log writer instance has a unique textual name, -// and is attached to a particular Log instance and -// is assigned a particular log level. - -#define DEF_LOGFUNCTION(name, level) \ - inline void v##name(const char* fmt, va_list ap) \ - __attribute__((__format__ (__printf__, 2, 0))) \ - { \ - if (m_log && (level <= m_level)) \ - m_log->write(level, m_name, fmt, ap); \ - } \ - inline void name(const char* fmt, ...) \ - __attribute__((__format__ (__printf__, 2, 3))) \ - { \ - if (m_log && (level <= m_level)) { \ - va_list ap; va_start(ap, fmt); \ - m_log->write(level, m_name, fmt, ap);\ - va_end(ap); \ - } \ - } - -namespace rfb { - - class LogWriter; - - class LogWriter { - public: - LogWriter(const char* name); - ~LogWriter(); - - const char *getName() {return m_name;} - - void setLog(Logger *logger); - void setLevel(int level); - int getLevel(void) { return m_level; } - - inline void write(int level, const char* format, ...) - __attribute__((__format__ (__printf__, 3, 4))) - { - if (m_log && (level <= m_level)) { - va_list ap; - va_start(ap, format); - m_log->write(level, m_name, format, ap); - va_end(ap); - } - } - - static const int LEVEL_ERROR = 0; - static const int LEVEL_STATUS = 10; - static const int LEVEL_INFO = 30; - static const int LEVEL_DEBUG = 100; - - DEF_LOGFUNCTION(error, LEVEL_ERROR) - DEF_LOGFUNCTION(status, LEVEL_STATUS) - DEF_LOGFUNCTION(info, LEVEL_INFO) - DEF_LOGFUNCTION(debug, LEVEL_DEBUG) - - // -=- DIAGNOSTIC & HELPER ROUTINES - - static void listLogWriters(int width=79); - - // -=- CLASS FIELDS & FUNCTIONS - - static LogWriter* log_writers; - - static LogWriter* getLogWriter(const char* name); - - static bool setLogParams(const char* params); - - private: - const char* m_name; - int m_level; - Logger* m_log; - LogWriter* m_next; - }; - - class LogParameter : public core::StringParameter { - public: - LogParameter(); - bool setParam(const char* v) override; - }; - extern LogParameter logParams; - -}; - -#endif // __RFB_LOG_WRITER_H__ diff --git a/common/rfb/Logger.cxx b/common/rfb/Logger.cxx deleted file mode 100644 index 25f7ccb7..00000000 --- a/common/rfb/Logger.cxx +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. - * - * This 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 2 of the License, or - * (at your option) any later version. - * - * This software 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 this software; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - * USA. - */ - -// -=- Logger.cxx - support for the Logger and LogWriter classes - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdarg.h> -#include <stdio.h> -#include <string.h> - -#include <rfb/Logger.h> -#include <rfb/LogWriter.h> - -using namespace rfb; - -Logger* Logger::loggers = nullptr; - -Logger::Logger(const char* name) - : registered(false), m_name(name), m_next(nullptr) -{ -} - -Logger::~Logger() { - // *** Should remove this logger here! -} - -void Logger::write(int level, const char *logname, const char* format, - va_list ap) -{ - // - Format the supplied data, and pass it to the - // actual log_message function - // The log level is included as a hint for loggers capable of representing - // different log levels in some way. - char buf1[4096]; - vsnprintf(buf1, sizeof(buf1)-1, format, ap); - buf1[sizeof(buf1)-1] = 0; - char *buf = buf1; - while (true) { - char *end = strchr(buf, '\n'); - if (end) - *end = '\0'; - write(level, logname, buf); - if (!end) - break; - buf = end + 1; - } -} - -void -Logger::registerLogger() { - if (!registered) { - registered = true; - m_next = loggers; - loggers=this; - } -} - -Logger* -Logger::getLogger(const char* name) { - Logger* current = loggers; - while (current) { - if (strcasecmp(name, current->m_name) == 0) return current; - current = current->m_next; - } - return nullptr; -} - -void -Logger::listLoggers() { - Logger* current = loggers; - while (current) { - printf(" %s\n", current->m_name); - current = current->m_next; - } -} - - diff --git a/common/rfb/Logger.h b/common/rfb/Logger.h deleted file mode 100644 index 76f03535..00000000 --- a/common/rfb/Logger.h +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. - * - * This 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 2 of the License, or - * (at your option) any later version. - * - * This software 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 this software; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - * USA. - */ - -// -=- Logger.h - The Logger class. - -#ifndef __RFB_LOGGER_H__ -#define __RFB_LOGGER_H__ - -#include <stdarg.h> -#include <stdio.h> - -// Each log writer instance has a unique textual name, -// and is attached to a particular Logger instance and -// is assigned a particular log level. - -namespace rfb { - - class Logger { - public: - - // -=- Create / Destroy a logger - - Logger(const char* name); - virtual ~Logger(); - - // -=- Get the name of a logger - - const char *getName() {return m_name;} - - // -=- Write data to a log - - virtual void write(int level, const char *logname, const char *text) = 0; - void write(int level, const char *logname, const char* format, va_list ap) - __attribute__((__format__ (__printf__, 4, 0))); - - // -=- Register a logger - - void registerLogger(); - - // -=- CLASS FIELDS & FUNCTIONS - - static Logger* loggers; - - static Logger* getLogger(const char* name); - - static void listLoggers(); - - private: - bool registered; - const char *m_name; - Logger *m_next; - }; - -}; - -#endif // __RFB_LOGGER_H__ diff --git a/common/rfb/Logger_file.cxx b/common/rfb/Logger_file.cxx deleted file mode 100644 index 0bb18f84..00000000 --- a/common/rfb/Logger_file.cxx +++ /dev/null @@ -1,122 +0,0 @@ -/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. - * - * This 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 2 of the License, or - * (at your option) any later version. - * - * This software 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 this software; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - * USA. - */ - -// -=- Logger_file.cxx - Logger instance for a file - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <limits.h> -#include <stdlib.h> -#include <string.h> - -#include <rfb/Logger_file.h> - -using namespace rfb; - -Logger_File::Logger_File(const char* loggerName) - : Logger(loggerName), indent(13), width(79), m_file(nullptr), - m_lastLogTime(0) -{ - m_filename[0] = '\0'; -} - -Logger_File::~Logger_File() -{ - closeFile(); -} - -void Logger_File::write(int /*level*/, const char *logname, const char *message) -{ - if (!m_file) { - if (m_filename[0] == '\0') - return; - char bakFilename[PATH_MAX]; - if (snprintf(bakFilename, sizeof(bakFilename), - "%s.bak", m_filename) >= (int)sizeof(bakFilename)) { - remove(m_filename); - } else { - remove(bakFilename); - rename(m_filename, bakFilename); - } - m_file = fopen(m_filename, "w+"); - if (!m_file) return; - } - - time_t current = time(nullptr); - if (current != m_lastLogTime) { - m_lastLogTime = current; - fprintf(m_file, "\n%s", ctime(&m_lastLogTime)); - } - - fprintf(m_file," %s:", logname); - int column = strlen(logname) + 2; - if (column < indent) { - fprintf(m_file,"%*s",indent-column,""); - column = indent; - } - while (true) { - const char* s = strchr(message, ' '); - int wordLen; - if (s) wordLen = s-message; - else wordLen = strlen(message); - - if (column + wordLen + 1 > width) { - fprintf(m_file,"\n%*s",indent,""); - column = indent; - } - fprintf(m_file," %.*s",wordLen,message); - column += wordLen + 1; - message += wordLen + 1; - if (!s) break; - } - fprintf(m_file,"\n"); - fflush(m_file); -} - -void Logger_File::setFilename(const char* filename) -{ - closeFile(); - m_filename[0] = '\0'; - if (strlen(filename) >= sizeof(m_filename)) - return; - strcpy(m_filename, filename); -} - -void Logger_File::setFile(FILE* file) -{ - closeFile(); - m_file = file; -} - -void Logger_File::closeFile() -{ - if (m_file) { - fclose(m_file); - m_file = nullptr; - } -} - -static Logger_File logger("file"); - -bool rfb::initFileLogger(const char* filename) { - logger.setFilename(filename); - logger.registerLogger(); - return true; -} diff --git a/common/rfb/Logger_file.h b/common/rfb/Logger_file.h deleted file mode 100644 index f736d43b..00000000 --- a/common/rfb/Logger_file.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. - * - * This 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 2 of the License, or - * (at your option) any later version. - * - * This software 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 this software; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - * USA. - */ - -// -=- Logger_file - log to a file - -#ifndef __RFB_LOGGER_FILE_H__ -#define __RFB_LOGGER_FILE_H__ - -#include <time.h> -#include <limits.h> - -#include <rfb/Logger.h> - -namespace rfb { - - class Logger_File : public Logger { - public: - Logger_File(const char* loggerName); - ~Logger_File(); - - void write(int level, const char *logname, const char *message) override; - void setFilename(const char* filename); - void setFile(FILE* file); - - int indent; - int width; - - protected: - void closeFile(); - char m_filename[PATH_MAX]; - FILE* m_file; - time_t m_lastLogTime; - }; - - bool initFileLogger(const char* filename); -}; - -#endif diff --git a/common/rfb/Logger_stdio.cxx b/common/rfb/Logger_stdio.cxx deleted file mode 100644 index 5e5c6dea..00000000 --- a/common/rfb/Logger_stdio.cxx +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. - * - * This 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 2 of the License, or - * (at your option) any later version. - * - * This software 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 this software; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - * USA. - */ - -// -=- Logger_stdio.cxx - Logger instances for stderr and stdout - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <rfb/Logger_stdio.h> - -using namespace rfb; - -static Logger_StdIO logStdErr("stderr", stderr); -static Logger_StdIO logStdOut("stdout", stdout); - -bool rfb::initStdIOLoggers() { - logStdErr.registerLogger(); - logStdOut.registerLogger(); - return true; -} diff --git a/common/rfb/Logger_stdio.h b/common/rfb/Logger_stdio.h deleted file mode 100644 index a1d17a0f..00000000 --- a/common/rfb/Logger_stdio.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. - * - * This 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 2 of the License, or - * (at your option) any later version. - * - * This software 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 this software; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - * USA. - */ - -// -=- Logger_stdio - standard output logger instances - -#ifndef __RFB_LOGGER_STDIO_H__ -#define __RFB_LOGGER_STDIO_H__ - -#include <rfb/Logger_file.h> - -namespace rfb { - - class Logger_StdIO : public Logger_File { - public: - Logger_StdIO(const char *name, FILE* file) : Logger_File(name) { - setFile(file); - } - }; - - bool initStdIOLoggers(); - -}; - -#endif diff --git a/common/rfb/Logger_syslog.cxx b/common/rfb/Logger_syslog.cxx deleted file mode 100644 index de9e425e..00000000 --- a/common/rfb/Logger_syslog.cxx +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright (C) 2015 TigerVNC - * - * This 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 2 of the License, or - * (at your option) any later version. - * - * This software 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 this software; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - * USA. - */ - -// -=- Logger_syslog.cxx - Logger instance for a syslog - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdlib.h> -#include <string.h> -#include <syslog.h> - -#include <rfb/Logger_syslog.h> -#include <rfb/LogWriter.h> - -using namespace rfb; - - -Logger_Syslog::Logger_Syslog(const char* loggerName) - : Logger(loggerName) -{ - openlog(nullptr, LOG_CONS | LOG_PID, LOG_USER); -} - -Logger_Syslog::~Logger_Syslog() -{ - closelog(); -} - -void Logger_Syslog::write(int level, const char *logname, const char *message) -{ - // Convert our priority level into syslog level - int priority; - if (level >= LogWriter::LEVEL_DEBUG) { - priority = LOG_DEBUG; - } else if (level >= LogWriter::LEVEL_INFO) { - priority = LOG_INFO; - } else if (level >= LogWriter::LEVEL_STATUS) { - priority = LOG_NOTICE; - } else { - priority = LOG_ERR; - } - - syslog(priority, "%s: %s", logname, message); -} - -static Logger_Syslog logger("syslog"); - -void rfb::initSyslogLogger() { - logger.registerLogger(); -} diff --git a/common/rfb/Logger_syslog.h b/common/rfb/Logger_syslog.h deleted file mode 100644 index 20c46a5f..00000000 --- a/common/rfb/Logger_syslog.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2015 TigerVNC - * - * This 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 2 of the License, or - * (at your option) any later version. - * - * This software 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 this software; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - * USA. - */ - -// -=- Logger_syslog - log to syslog - -#ifndef __RFB_LOGGER_SYSLOG_H__ -#define __RFB_LOGGER_SYSLOG_H__ - -#include <time.h> -#include <rfb/Logger.h> - -namespace rfb { - - class Logger_Syslog : public Logger { - public: - Logger_Syslog(const char* loggerName); - virtual ~Logger_Syslog(); - - void write(int level, const char *logname, const char *message) override; - }; - - void initSyslogLogger(); -}; - -#endif diff --git a/common/rfb/PixelBuffer.cxx b/common/rfb/PixelBuffer.cxx index 8c743984..8ee54c74 100644 --- a/common/rfb/PixelBuffer.cxx +++ b/common/rfb/PixelBuffer.cxx @@ -30,14 +30,14 @@ #include <stdexcept> +#include <core/LogWriter.h> #include <core/util.h> -#include <rfb/LogWriter.h> #include <rfb/PixelBuffer.h> using namespace rfb; -static LogWriter vlog("PixelBuffer"); +static core::LogWriter vlog("PixelBuffer"); // We do a lot of byte offset calculations that assume the result fits // inside a signed 32 bit integer. Limit the maximum size of pixel diff --git a/common/rfb/SConnection.cxx b/common/rfb/SConnection.cxx index 078a924a..876521a8 100644 --- a/common/rfb/SConnection.cxx +++ b/common/rfb/SConnection.cxx @@ -26,6 +26,7 @@ #include <algorithm> +#include <core/LogWriter.h> #include <core/util.h> #include <rdr/OutStream.h> @@ -43,11 +44,9 @@ #include <rfb/EncodeManager.h> #include <rfb/SSecurity.h> -#include <rfb/LogWriter.h> - using namespace rfb; -static LogWriter vlog("SConnection"); +static core::LogWriter vlog("SConnection"); SConnection::SConnection(AccessRights accessRights_) : readyForSetColourMapEntries(false), is(nullptr), os(nullptr), diff --git a/common/rfb/SMsgHandler.cxx b/common/rfb/SMsgHandler.cxx index 882047c0..01e7003d 100644 --- a/common/rfb/SMsgHandler.cxx +++ b/common/rfb/SMsgHandler.cxx @@ -21,9 +21,9 @@ #include <config.h> #endif +#include <core/LogWriter.h> #include <core/util.h> -#include <rfb/LogWriter.h> #include <rfb/SMsgHandler.h> #include <rfb/ScreenSet.h> #include <rfb/clipboardTypes.h> @@ -31,7 +31,7 @@ using namespace rfb; -static LogWriter vlog("SMsgHandler"); +static core::LogWriter vlog("SMsgHandler"); SMsgHandler::SMsgHandler() { diff --git a/common/rfb/SMsgReader.cxx b/common/rfb/SMsgReader.cxx index 0fa10f36..3584727e 100644 --- a/common/rfb/SMsgReader.cxx +++ b/common/rfb/SMsgReader.cxx @@ -26,6 +26,7 @@ #include <vector> #include <core/Configuration.h> +#include <core/LogWriter.h> #include <core/util.h> #include <rdr/InStream.h> @@ -39,11 +40,10 @@ #include <rfb/ScreenSet.h> #include <rfb/SMsgHandler.h> #include <rfb/SMsgReader.h> -#include <rfb/LogWriter.h> using namespace rfb; -static LogWriter vlog("SMsgReader"); +static core::LogWriter vlog("SMsgReader"); static core::IntParameter maxCutText("MaxCutText", "Maximum permitted length of an incoming clipboard update", 256*1024); diff --git a/common/rfb/SMsgWriter.cxx b/common/rfb/SMsgWriter.cxx index 26ee7f6a..32a3a184 100644 --- a/common/rfb/SMsgWriter.cxx +++ b/common/rfb/SMsgWriter.cxx @@ -24,6 +24,7 @@ #include <stdio.h> +#include <core/LogWriter.h> #include <core/util.h> #include <rdr/OutStream.h> @@ -39,13 +40,12 @@ #include <rfb/Encoder.h> #include <rfb/ScreenSet.h> #include <rfb/SMsgWriter.h> -#include <rfb/LogWriter.h> #include <rfb/encodings.h> #include <rfb/ledStates.h> using namespace rfb; -static LogWriter vlog("SMsgWriter"); +static core::LogWriter vlog("SMsgWriter"); SMsgWriter::SMsgWriter(ClientParams* client_, rdr::OutStream* os_) : client(client_), os(os_), diff --git a/common/rfb/SSecurityRSAAES.cxx b/common/rfb/SSecurityRSAAES.cxx index d9945866..6afb52dd 100644 --- a/common/rfb/SSecurityRSAAES.cxx +++ b/common/rfb/SSecurityRSAAES.cxx @@ -38,6 +38,7 @@ #include <nettle/asn1.h> #include <core/Exception.h> +#include <core/LogWriter.h> #include <rdr/AESInStream.h> #include <rdr/AESOutStream.h> @@ -45,7 +46,6 @@ #include <rfb/SSecurityRSAAES.h> #include <rfb/SConnection.h> -#include <rfb/LogWriter.h> #include <rfb/Exception.h> #if !defined(WIN32) && !defined(__APPLE__) #include <rfb/UnixPasswordValidator.h> @@ -76,7 +76,7 @@ core::BoolParameter SSecurityRSAAES::requireUsername ("RequireUsername", "Require username for the RSA-AES security types", false); -static LogWriter vlog("SSecurityRSAAES"); +static core::LogWriter vlog("SSecurityRSAAES"); SSecurityRSAAES::SSecurityRSAAES(SConnection* sc_, uint32_t _secType, int _keySize, bool _isAllEncrypted) diff --git a/common/rfb/SSecurityTLS.cxx b/common/rfb/SSecurityTLS.cxx index 56d678b0..2e173771 100644 --- a/common/rfb/SSecurityTLS.cxx +++ b/common/rfb/SSecurityTLS.cxx @@ -30,13 +30,16 @@ #include <stdlib.h> +#include <core/LogWriter.h> + #include <rfb/SSecurityTLS.h> #include <rfb/SConnection.h> -#include <rfb/LogWriter.h> #include <rfb/Exception.h> + #include <rdr/TLSException.h> #include <rdr/TLSInStream.h> #include <rdr/TLSOutStream.h> + #include <gnutls/x509.h> #if defined (SSECURITYTLS__USE_DEPRECATED_DH) @@ -65,7 +68,7 @@ core::StringParameter SSecurityTLS::X509_CertFile core::StringParameter SSecurityTLS::X509_KeyFile ("X509Key", "Path to the key of the X509 certificate in PEM format", ""); -static LogWriter vlog("TLS"); +static core::LogWriter vlog("TLS"); SSecurityTLS::SSecurityTLS(SConnection* sc_, bool _anon) : SSecurity(sc_), session(nullptr), anon_cred(nullptr), diff --git a/common/rfb/SSecurityVeNCrypt.cxx b/common/rfb/SSecurityVeNCrypt.cxx index 47a7f489..757acc06 100644 --- a/common/rfb/SSecurityVeNCrypt.cxx +++ b/common/rfb/SSecurityVeNCrypt.cxx @@ -26,11 +26,12 @@ #include <config.h> #endif +#include <core/LogWriter.h> + #include <rfb/SConnection.h> #include <rfb/SecurityServer.h> #include <rfb/SSecurityVeNCrypt.h> #include <rfb/Exception.h> -#include <rfb/LogWriter.h> #include <rfb/Security.h> #include <rdr/InStream.h> @@ -38,7 +39,7 @@ using namespace rfb; -static LogWriter vlog("SVeNCrypt"); +static core::LogWriter vlog("SVeNCrypt"); SSecurityVeNCrypt::SSecurityVeNCrypt(SConnection* sc_, SecurityServer *sec) diff --git a/common/rfb/SSecurityVncAuth.cxx b/common/rfb/SSecurityVncAuth.cxx index 67e30ff3..b267d5a0 100644 --- a/common/rfb/SSecurityVncAuth.cxx +++ b/common/rfb/SSecurityVncAuth.cxx @@ -26,13 +26,13 @@ #endif #include <core/Configuration.h> +#include <core/LogWriter.h> #include <rdr/OutStream.h> #include <rfb/SSecurityVncAuth.h> #include <rdr/RandomStream.h> #include <rfb/SConnection.h> -#include <rfb/LogWriter.h> #include <rfb/Exception.h> #include <rfb/obfuscate.h> @@ -46,7 +46,7 @@ extern "C" { using namespace rfb; -static LogWriter vlog("SVncAuth"); +static core::LogWriter vlog("SVncAuth"); core::StringParameter SSecurityVncAuth::vncAuthPasswdFile ("PasswordFile", "Password file for VNC authentication", ""); diff --git a/common/rfb/Security.cxx b/common/rfb/Security.cxx index f812b58e..a7697eb8 100644 --- a/common/rfb/Security.cxx +++ b/common/rfb/Security.cxx @@ -25,14 +25,14 @@ #include <algorithm> +#include <core/LogWriter.h> #include <core/util.h> -#include <rfb/LogWriter.h> #include <rfb/Security.h> using namespace rfb; -static LogWriter vlog("Security"); +static core::LogWriter vlog("Security"); #ifdef HAVE_GNUTLS core::StringParameter Security::GnuTLSPriority("GnuTLSPriority", diff --git a/common/rfb/Timer.cxx b/common/rfb/Timer.cxx index 75551c8b..483be87c 100644 --- a/common/rfb/Timer.cxx +++ b/common/rfb/Timer.cxx @@ -28,10 +28,10 @@ #include <algorithm> +#include <core/LogWriter.h> #include <core/util.h> #include <rfb/Timer.h> -#include <rfb/LogWriter.h> // Temporary during transition to new structure: using namespace core; diff --git a/common/rfb/UpdateTracker.cxx b/common/rfb/UpdateTracker.cxx index b7a86e5f..1aedf491 100644 --- a/common/rfb/UpdateTracker.cxx +++ b/common/rfb/UpdateTracker.cxx @@ -25,12 +25,13 @@ #include <config.h> #endif +#include <core/LogWriter.h> + #include <rfb/UpdateTracker.h> -#include <rfb/LogWriter.h> using namespace rfb; -static LogWriter vlog("UpdateTracker"); +static core::LogWriter vlog("UpdateTracker"); // -=- ClippingUpdateTracker diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx index ce3c6afc..8b47284d 100644 --- a/common/rfb/VNCSConnectionST.cxx +++ b/common/rfb/VNCSConnectionST.cxx @@ -22,6 +22,7 @@ #include <config.h> #endif +#include <core/LogWriter.h> #include <core/util.h> #include <rdr/FdInStream.h> @@ -34,7 +35,6 @@ #include <rfb/Exception.h> #include <rfb/KeyRemapper.h> #include <rfb/KeysymStr.h> -#include <rfb/LogWriter.h> #include <rfb/Security.h> #include <rfb/ServerCore.h> #include <rfb/SMsgWriter.h> @@ -51,7 +51,7 @@ using namespace rfb; -static LogWriter vlog("VNCSConnST"); +static core::LogWriter vlog("VNCSConnST"); static Cursor emptyCursor(0, 0, {0, 0}, nullptr); diff --git a/common/rfb/VNCServerST.cxx b/common/rfb/VNCServerST.cxx index 6aeff212..b0581513 100644 --- a/common/rfb/VNCServerST.cxx +++ b/common/rfb/VNCServerST.cxx @@ -55,6 +55,7 @@ #include <assert.h> #include <stdlib.h> +#include <core/LogWriter.h> #include <core/util.h> #include <rdr/FdOutStream.h> @@ -64,7 +65,6 @@ #include <rfb/ComparingUpdateTracker.h> #include <rfb/KeyRemapper.h> #include <rfb/KeysymStr.h> -#include <rfb/LogWriter.h> #include <rfb/SDesktop.h> #include <rfb/Security.h> #include <rfb/ServerCore.h> @@ -75,8 +75,8 @@ using namespace rfb; -static LogWriter slog("VNCServerST"); -static LogWriter connectionsLog("Connections"); +static core::LogWriter slog("VNCServerST"); +static core::LogWriter connectionsLog("Connections"); // // -=- VNCServerST Implementation diff --git a/common/rfb/ZRLEEncoder.cxx b/common/rfb/ZRLEEncoder.cxx index 6d0d53a8..39450ff0 100644 --- a/common/rfb/ZRLEEncoder.cxx +++ b/common/rfb/ZRLEEncoder.cxx @@ -22,6 +22,7 @@ #endif #include <core/Configuration.h> +#include <core/LogWriter.h> #include <rdr/OutStream.h> #include <rfb/encodings.h> @@ -29,11 +30,10 @@ #include <rfb/PixelBuffer.h> #include <rfb/SConnection.h> #include <rfb/ZRLEEncoder.h> -#include <rfb/LogWriter.h> using namespace rfb; -static LogWriter vlog("ZRLEEncoder"); +static core::LogWriter vlog("ZRLEEncoder"); core::IntParameter zlibLevel("ZlibLevel","[DEPRECATED] Zlib compression level",-1); |