Skip to content

Commit

Permalink
Merge branch 'corelib' of https://github.com/CendioOssman/tigervnc
Browse files Browse the repository at this point in the history
  • Loading branch information
CendioOssman committed Feb 25, 2025
2 parents 6d10241 + 0024c2a commit 62c606d
Show file tree
Hide file tree
Showing 292 changed files with 3,462 additions and 2,919 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ if(ENABLE_TSAN AND NOT WIN32 AND NOT APPLE AND CMAKE_SIZEOF_VOID_P MATCHES 8)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
endif()

if(MSVC)
# undef min and max macro
target_compile_definitions(rfb PRIVATE NOMINMAX)
endif()

if(NOT DEFINED BUILD_WINVNC)
set(BUILD_WINVNC 1)
endif()
Expand Down
4 changes: 2 additions & 2 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_subdirectory(os)
add_subdirectory(core)
add_subdirectory(rdr)
add_subdirectory(network)
add_subdirectory(rfb)
Expand All @@ -9,6 +9,6 @@ add_subdirectory(rfb)
# is passed (additionally, libvnc is not used on Windows.)

if(NOT WIN32)
set_target_properties(os rdr network rfb
set_target_properties(core rdr network rfb
PROPERTIES COMPILE_FLAGS -fPIC)
endif()
36 changes: 36 additions & 0 deletions common/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
add_library(core STATIC
Configuration.cxx
Exception.cxx
Logger.cxx
Logger_file.cxx
Logger_stdio.cxx
LogWriter.cxx
Mutex.cxx
Region.cxx
Timer.cxx
Thread.cxx
string.cxx
time.cxx
xdgdirs.cxx)

target_include_directories(core PUBLIC ${CMAKE_SOURCE_DIR}/common)
target_include_directories(core SYSTEM PUBLIC ${PIXMAN_INCLUDE_DIRS})
target_link_libraries(core ${PIXMAN_LIBRARIES})
target_link_directories(core PUBLIC ${PIXMAN_LIBRARY_DIRS})

if(UNIX)
target_sources(core PRIVATE Logger_syslog.cxx)
target_link_libraries(core pthread)
endif()

if(WIN32)
target_link_libraries(core ws2_32)
endif()

if(UNIX)
target_sources(core PRIVATE Logger_syslog.cxx)
endif()

if(UNIX)
libtool_create_control_file(core)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
#include <algorithm>
#include <stdexcept>

#include <rfb/util.h>
#include <rfb/Configuration.h>
#include <rfb/LogWriter.h>
#include <core/Configuration.h>
#include <core/LogWriter.h>
#include <core/string.h>

#include <rdr/HexOutStream.h>
#include <rdr/HexInStream.h>

using namespace rfb;
using namespace core;

static LogWriter vlog("Config");

Expand Down
9 changes: 5 additions & 4 deletions common/rfb/Configuration.h → common/core/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
// NB: NO LOCKING is performed when linking Configurations to groups
// or when adding Parameters to Configurations.

#ifndef __RFB_CONFIGURATION_H__
#define __RFB_CONFIGURATION_H__
#ifndef __CORE_CONFIGURATION_H__
#define __CORE_CONFIGURATION_H__

#include <limits.h>
#include <stdint.h>
Expand All @@ -51,7 +51,8 @@
#include <string>
#include <vector>

namespace rfb {
namespace core {

class VoidParameter;

// -=- Configuration
Expand Down Expand Up @@ -221,4 +222,4 @@ namespace rfb {

};

#endif // __RFB_CONFIGURATION_H__
#endif // __CORE_CONFIGURATION_H__
31 changes: 15 additions & 16 deletions common/rdr/Exception.cxx → common/core/Exception.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
#include <stdio.h>
#include <stdarg.h>

#include <rdr/Exception.h>
#include <rdr/TLSException.h>
#include <rfb/util.h>
#include <core/Exception.h>
#include <core/string.h>

#ifdef _WIN32
#include <winsock2.h>
Expand All @@ -40,20 +39,20 @@

#include <string.h>

using namespace rdr;
using namespace core;


getaddrinfo_error::getaddrinfo_error(const char* s, int err_) noexcept
: std::runtime_error(rfb::format("%s: %s (%d)", s,
strerror(err_).c_str(), err_)),
: std::runtime_error(core::format("%s: %s (%d)", s,
strerror(err_).c_str(), err_)),
err(err_)
{
}

getaddrinfo_error::getaddrinfo_error(const std::string& s,
int err_) noexcept
: std::runtime_error(rfb::format("%s: %s (%d)", s.c_str(),
strerror(err_).c_str(), err_)),
: std::runtime_error(core::format("%s: %s (%d)", s.c_str(),
strerror(err_).c_str(), err_)),
err(err_)
{
}
Expand All @@ -73,15 +72,15 @@ std::string getaddrinfo_error::strerror(int err_) const noexcept
}

posix_error::posix_error(const char* what_arg, int err_) noexcept
: std::runtime_error(rfb::format("%s: %s (%d)", what_arg,
strerror(err_).c_str(), err_)),
: std::runtime_error(core::format("%s: %s (%d)", what_arg,
strerror(err_).c_str(), err_)),
err(err_)
{
}

posix_error::posix_error(const std::string& what_arg, int err_) noexcept
: std::runtime_error(rfb::format("%s: %s (%d)", what_arg.c_str(),
strerror(err_).c_str(), err_)),
: std::runtime_error(core::format("%s: %s (%d)", what_arg.c_str(),
strerror(err_).c_str(), err_)),
err(err_)
{
}
Expand All @@ -102,16 +101,16 @@ std::string posix_error::strerror(int err_) const noexcept

#ifdef WIN32
win32_error::win32_error(const char* what_arg, unsigned err_) noexcept
: std::runtime_error(rfb::format("%s: %s (%d)", what_arg,
strerror(err_).c_str(), err_)),
: std::runtime_error(core::format("%s: %s (%d)", what_arg,
strerror(err_).c_str(), err_)),
err(err_)
{
}

win32_error::win32_error(const std::string& what_arg,
unsigned err_) noexcept
: std::runtime_error(rfb::format("%s: %s (%d)", what_arg.c_str(),
strerror(err_).c_str(), err_)),
: std::runtime_error(core::format("%s: %s (%d)", what_arg.c_str(),
strerror(err_).c_str(), err_)),
err(err_)
{
}
Expand Down
11 changes: 3 additions & 8 deletions common/rdr/Exception.h → common/core/Exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
* USA.
*/

#ifndef __RDR_EXCEPTION_H__
#define __RDR_EXCEPTION_H__
#ifndef __CORE_EXCEPTION_H__
#define __CORE_EXCEPTION_H__

#include <stdexcept>
#include <string>

namespace rdr {
namespace core {

class posix_error : public std::runtime_error {
public:
Expand Down Expand Up @@ -70,11 +70,6 @@ namespace rdr {
std::string strerror(int err_) const noexcept;
};

class end_of_stream : public std::runtime_error {
public:
end_of_stream() noexcept : std::runtime_error("End of stream") {}
};

}

#endif
13 changes: 6 additions & 7 deletions common/rfb/LogWriter.cxx → common/core/LogWriter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@
#include <config.h>
#endif

#include <string.h>

#include <rfb/LogWriter.h>
#include <rfb/Configuration.h>
#include <rfb/util.h>
#include <stdlib.h>
#include <string.h>

rfb::LogParameter rfb::logParams;
#include <core/Configuration.h>
#include <core/LogWriter.h>
#include <core/string.h>

using namespace rfb;
using namespace core;

LogParameter core::logParams;

LogWriter::LogWriter(const char* name)
: m_name(name), m_level(0), m_log(nullptr), m_next(log_writers) {
Expand Down
15 changes: 7 additions & 8 deletions common/rfb/LogWriter.h → common/core/LogWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@

// -=- LogWriter.h - The Log writer class.

#ifndef __RFB_LOG_WRITER_H__
#define __RFB_LOG_WRITER_H__
#ifndef __CORE_LOG_WRITER_H__
#define __CORE_LOG_WRITER_H__

#include <stdarg.h>
#include <rfb/Logger.h>
#include <rfb/Configuration.h>

#include <core/Configuration.h>
#include <core/Logger.h>

// Each log writer instance has a unique textual name,
// and is attached to a particular Log instance and
Expand All @@ -46,9 +47,7 @@
} \
}

namespace rfb {

class LogWriter;
namespace core {

class LogWriter {
public:
Expand Down Expand Up @@ -110,4 +109,4 @@ namespace rfb {

};

#endif // __RFB_LOG_WRITER_H__
#endif // __CORE_LOG_WRITER_H__
6 changes: 3 additions & 3 deletions common/rfb/Logger.cxx → common/core/Logger.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
#include <stdio.h>
#include <string.h>

#include <rfb/Logger.h>
#include <rfb/LogWriter.h>
#include <core/Logger.h>
#include <core/LogWriter.h>

using namespace rfb;
using namespace core;

Logger* Logger::loggers = nullptr;

Expand Down
8 changes: 4 additions & 4 deletions common/rfb/Logger.h → common/core/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

// -=- Logger.h - The Logger class.

#ifndef __RFB_LOGGER_H__
#define __RFB_LOGGER_H__
#ifndef __CORE_LOGGER_H__
#define __CORE_LOGGER_H__

#include <stdarg.h>
#include <stdio.h>
Expand All @@ -28,7 +28,7 @@
// and is attached to a particular Logger instance and
// is assigned a particular log level.

namespace rfb {
namespace core {

class Logger {
public:
Expand Down Expand Up @@ -68,4 +68,4 @@ namespace rfb {

};

#endif // __RFB_LOGGER_H__
#endif // __CORE_LOGGER_H__
7 changes: 4 additions & 3 deletions common/rfb/Logger_file.cxx → common/core/Logger_file.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#include <stdlib.h>
#include <string.h>

#include <rfb/Logger_file.h>
#include <core/Logger_file.h>

using namespace rfb;
using namespace core;

Logger_File::Logger_File(const char* loggerName)
: Logger(loggerName), indent(13), width(79), m_file(nullptr),
Expand Down Expand Up @@ -115,7 +115,8 @@ void Logger_File::closeFile()

static Logger_File logger("file");

bool rfb::initFileLogger(const char* filename) {
bool core::initFileLogger(const char* filename)
{
logger.setFilename(filename);
logger.registerLogger();
return true;
Expand Down
8 changes: 4 additions & 4 deletions common/rfb/Logger_file.h → common/core/Logger_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@

// -=- Logger_file - log to a file

#ifndef __RFB_LOGGER_FILE_H__
#define __RFB_LOGGER_FILE_H__
#ifndef __CORE_LOGGER_FILE_H__
#define __CORE_LOGGER_FILE_H__

#include <time.h>
#include <limits.h>

#include <rfb/Logger.h>
#include <core/Logger.h>

namespace rfb {
namespace core {

class Logger_File : public Logger {
public:
Expand Down
7 changes: 4 additions & 3 deletions common/rfb/Logger_stdio.cxx → common/core/Logger_stdio.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
#include <config.h>
#endif

#include <rfb/Logger_stdio.h>
#include <core/Logger_stdio.h>

using namespace rfb;
using namespace core;

static Logger_StdIO logStdErr("stderr", stderr);
static Logger_StdIO logStdOut("stdout", stdout);

bool rfb::initStdIOLoggers() {
bool core::initStdIOLoggers()
{
logStdErr.registerLogger();
logStdOut.registerLogger();
return true;
Expand Down
8 changes: 4 additions & 4 deletions common/rfb/Logger_stdio.h → common/core/Logger_stdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

// -=- Logger_stdio - standard output logger instances

#ifndef __RFB_LOGGER_STDIO_H__
#define __RFB_LOGGER_STDIO_H__
#ifndef __CORE_LOGGER_STDIO_H__
#define __CORE_LOGGER_STDIO_H__

#include <rfb/Logger_file.h>
#include <core/Logger_file.h>

namespace rfb {
namespace core {

class Logger_StdIO : public Logger_File {
public:
Expand Down
Loading

0 comments on commit 62c606d

Please sign in to comment.