diff --git a/.gitignore b/.gitignore
index 73fc2516..4a135268 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,7 @@
*.so
# Directories
+.*
/bin/*
/lib/
/obj/
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 00000000..974229c9
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,48 @@
+cmake_minimum_required(VERSION 3.0.2)
+project(SqMod)
+
+# Tell CMake where to find our scripts
+set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
+
+# Several plugin options
+option(BUILTIN_RUNTIMES "Include the MinGW runtime into the binary itself." ON)
+option(FORCE_32BIT_BIN "Create a 32-bit executable binary if the compiler defaults to 64-bit." OFF)
+option(ENABLE_MYSQL "Enable the MySQL library." OFF)
+
+# Default to c++14 standard
+if(CMAKE_VERSION VERSION_LESS "3.1")
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
+ endif()
+else()
+ # Apparently the above does not work with cmake from on debian 8
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+ # Try the standard method as well
+ set(CMAKE_CXX_STANDARD 14)
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
+endif()
+
+# Default to release mode
+set(CMAKE_BUILD_TYPE "Release")
+
+# Include mingw runntime into the binary
+if (GCC OR MINGW)
+ if(BUILTIN_RUNTIMES)
+ set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
+ endif()
+endif()
+
+# Enable position independent code
+if (UNIX)
+ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+endif()
+# Include VCMP library
+add_subdirectory(vcmp)
+# Include Squirrel library
+add_subdirectory(squirrel)
+# Include Squat library
+add_subdirectory(sqrat)
+# Include SDK library
+add_subdirectory(sdk)
+# Include Module library
+add_subdirectory(module)
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 56d74c13..00000000
--- a/Makefile
+++ /dev/null
@@ -1,222 +0,0 @@
-export SQ_BASEDIR=$(CURDIR)
-export SQ_MAKE = make
-export SQ_C_COMPILER = gcc
-export SQ_PP_COMPILER = g++
-export SQ_C_LINKER_STATIC = ar
-export SQ_PP_LINKER_STATIC = ar
-export SQ_C_LINKER_DYNAMIC = gcc
-export SQ_PP_LINKER_DYNAMIC = g++
-export SQ_TARGET_NAME_PREFIX
-export SQ_C_OPTIONS = -Wall -Wextra -Wno-error -Wno-implicit-fallthrough
-export SQ_PP_OPTIONS = -std=c++14
-export SQ_STATIC_LINKER_OPTIONS = -rc -s
-export SQ_DYNAMIC_LINKER_OPTIONS = -shared
-export SQ_DYNAMIC_LINKER_OPTIONS_
-export SQ_DEFINES
-export SQ_INCLUDES
-export SQ_LIBRARIES
-export SQ_MAKE_THREADS = 1
-export SQ_DEBUG_POSTFIX
-
-SQ_MAKE += -j$(SQ_MAKE_THREADS)
-
-ifndef SQ_TARGET_NAME_PREFIX
- SQ_TARGET_NAME_PREFIX = mod_
-endif
-
-export SQ_PLAT
-export SQ_ARCH
-export SQ_COMP
-export SQ_BEXT
-export SQ_OEXT = o
-export SQ_LEXT = a
-
-ifeq ($(OS),Windows_NT)
- SQ_PLAT = win
- SQ_COMP = mingw
- SQ_BEXT = dll
-
- ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
- SQ_ARCH = 64
- else
- SQ_ARCH = 32
- endif
-else
- SQ_PLAT = linux
- SQ_COMP = gcc
- SQ_BEXT = so
-
- UNAME_P := $(shell uname -p)
- ifeq ($(UNAME_P),x86_64)
- SQ_ARCH = 64
- else
- SQ_ARCH = 32
- endif
- UNAME_M := $(shell uname -m)
- ifeq ($(UNAME_M),x86_64)
- SQ_ARCH = 64
- else
- SQ_ARCH = 32
- endif
-endif
-
-ifdef ARCH
- SQ_ARCH = $(ARCH)
-endif
-
-ifdef DEBUG
- SQ_DEBUG_POSTFIX = -d
-endif
-
-export SQ_INCDIR=$(SQ_BASEDIR)/include
-export SQ_SHRDIR=$(SQ_BASEDIR)/shared
-export SQ_MODDIR=$(SQ_BASEDIR)/modules
-export SQ_EXTDIR=$(SQ_BASEDIR)/external
-export SQ_BASE_CFGDIR=$(SQ_BASEDIR)/config
-export SQ_BASE_LIBDIR=$(SQ_BASEDIR)/lib
-export SQ_BASE_OBJDIR=$(SQ_BASEDIR)/obj
-export SQ_BASE_BINDIR=$(SQ_BASEDIR)/bin
-export SQ_CFGDIR=$(SQ_BASE_CFGDIR)/$(SQ_COMP)$(SQ_ARCH)
-export SQ_LIBDIR=$(SQ_BASE_LIBDIR)/$(SQ_COMP)$(SQ_ARCH)
-export SQ_OBJDIR=$(SQ_BASE_OBJDIR)/$(SQ_COMP)$(SQ_ARCH)
-export SQ_BINDIR=$(SQ_BASE_BINDIR)/$(SQ_PLAT)$(SQ_ARCH)$(SQ_DEBUG_POSTFIX)
-export SQ_OUTDIR=
-
-ifdef STANDALONE
- SQ_OUTDIR = $(SQ_BINDIR)/standalone
- SQ_C_OPTIONS += -static-libgcc -static-libstdc++ -enable-static
-else
- SQ_OUTDIR = $(SQ_BINDIR)
-endif
-
-SQ_INCLUDES += -I"$(SQ_INCDIR)" -I"$(SQ_EXTDIR)/Common" -I"$(SQ_SHRDIR)" -I"$(SQ_BASE_CFGDIR)/common" -I"$(SQ_CFGDIR)"
-
-ifndef DEBUG
- SQ_DEFINES += -DNDEBUG
- SQ_C_OPTIONS += -O3
- SQ_DYNAMIC_LINKER_OPTIONS_ += -s
-else
- SQ_DEFINES += -D_DEBUG
- SQ_C_OPTIONS += -g
-endif
-
-ifeq ($(SQ_PLAT),win)
- SQ_DYNAMIC_LINKER_OPTIONS += -Wl,--dll
-else
- SQ_DEFINES += -DLINUX
- SQ_C_OPTIONS += -fPIC
- SQ_DYNAMIC_LINKER_OPTIONS += -Wl,-Bsymbolic
-endif
-
-ifeq ($(SQ_ARCH),64)
- SQ_DEFINES += -D_SQ64
- SQ_C_OPTIONS += -m64
- SQ_DYNAMIC_LINKER_OPTIONS_ += -m64
-else
- SQ_C_OPTIONS += -m32
- SQ_DYNAMIC_LINKER_OPTIONS_ += -m32
-endif
-
-ifdef STANDALONE
- ifeq ($(SQ_PLAT),win)
- SQ_DYNAMIC_LINKER_OPTIONS_ += -static
- else
- SQ_DYNAMIC_LINKER_OPTIONS_ += -Bstatic
- endif
-endif
-
-SQ_DEFINES += -DSCRAT_USE_EXCEPTION -DSCRAT_USE_CXX11_OPTIMIZATIONS
-
-.PHONY := all
-
-export SQ_TARGET
-
-ifdef BUILD
- SQ_TARGET += build
-endif
-ifdef LINK
- SQ_TARGET += link
-endif
-ifdef DEFAULT
- SQ_TARGET = default
-endif
-ifdef CLEAN
- SQ_TARGET += clean
-endif
-
-all: folders mod_squirrel mod_sqlite mod_xml mod_mmdb mod_irc mod_mysql
-
-mod_squirrel:
- cd $(SQ_BASEDIR)/source; $(SQ_MAKE) $(SQ_TARGET)
-
-mod_sqlite:
- cd $(SQ_MODDIR)/sqlite; $(SQ_MAKE) $(SQ_TARGET)
-
-mod_xml:
- cd $(SQ_MODDIR)/xml; $(SQ_MAKE) $(SQ_TARGET)
-
-mod_mmdb:
- cd $(SQ_MODDIR)/mmdb; $(SQ_MAKE) $(SQ_TARGET)
-
-mod_irc:
- cd $(SQ_MODDIR)/irc; $(SQ_MAKE) $(SQ_TARGET)
-
-mod_mysql:
- cd $(SQ_MODDIR)/mysql; $(SQ_MAKE) $(SQ_TARGET)
-
-mod_sample:
- cd $(SQ_MODDIR)/sample; $(SQ_MAKE) $(SQ_TARGET)
-
-build:
- cd $(SQ_MODDIR)/sqlite; $(SQ_MAKE) build
- cd $(SQ_MODDIR)/xml; $(SQ_MAKE) build
- cd $(SQ_MODDIR)/mmdb; $(SQ_MAKE) build
- cd $(SQ_MODDIR)/irc; $(SQ_MAKE) build
- cd $(SQ_MODDIR)/mysql; $(SQ_MAKE) build
- cd source; $(SQ_MAKE) build
-
-link:
- cd $(SQ_MODDIR)/sqlite; $(SQ_MAKE) link
- cd $(SQ_MODDIR)/xml; $(SQ_MAKE) link
- cd $(SQ_MODDIR)/mmdb; $(SQ_MAKE) link
- cd $(SQ_MODDIR)/irc; $(SQ_MAKE) link
- cd $(SQ_MODDIR)/mysql; $(SQ_MAKE) link
- cd source; $(SQ_MAKE) link
-
-clean:
- cd $(SQ_MODDIR)/sqlite; $(SQ_MAKE) clean
- cd $(SQ_MODDIR)/xml; $(SQ_MAKE) clean
- cd $(SQ_MODDIR)/mmdb; $(SQ_MAKE) clean
- cd $(SQ_MODDIR)/irc; $(SQ_MAKE) clean
- cd $(SQ_MODDIR)/mysql; $(SQ_MAKE) clean
- cd source; $(SQ_MAKE) clean
-
-folders:
- mkdir -p $(SQ_LIBDIR)
- mkdir -p $(SQ_OUTDIR)
- mkdir -p $(SQ_OBJDIR)
- mkdir -p $(SQ_OBJDIR)/source/Base
- mkdir -p $(SQ_OBJDIR)/source/Entity
- mkdir -p $(SQ_OBJDIR)/source/Misc
- mkdir -p $(SQ_OBJDIR)/source/Library/Chrono
- mkdir -p $(SQ_OBJDIR)/source/Library/Crypt
- mkdir -p $(SQ_OBJDIR)/source/Library/IO
- mkdir -p $(SQ_OBJDIR)/source/Library/Numeric
- mkdir -p $(SQ_OBJDIR)/source/Library/System
- mkdir -p $(SQ_OBJDIR)/source/Library/Utils
- mkdir -p $(SQ_OBJDIR)/shared/Base
- mkdir -p $(SQ_OBJDIR)/external/Common
- mkdir -p $(SQ_OBJDIR)/external/B64
- mkdir -p $(SQ_OBJDIR)/external/Hash
- mkdir -p $(SQ_OBJDIR)/external/LibIRC
- mkdir -p $(SQ_OBJDIR)/external/MaxmindDB
- mkdir -p $(SQ_OBJDIR)/external/PUGIXML
- mkdir -p $(SQ_OBJDIR)/external/SQLite
- mkdir -p $(SQ_OBJDIR)/external/Squirrel/Lib
- mkdir -p $(SQ_OBJDIR)/modules/irc
- mkdir -p $(SQ_OBJDIR)/modules/mmdb/Handle
- mkdir -p $(SQ_OBJDIR)/modules/mysql/Handle
- mkdir -p $(SQ_OBJDIR)/modules/mysql/Wrapper
- mkdir -p $(SQ_OBJDIR)/modules/sqlite/Handle
- mkdir -p $(SQ_OBJDIR)/modules/xml/Handle
- mkdir -p $(SQ_OBJDIR)/modules/xml/Wrapper
diff --git a/bin/demo/boot.nut b/bin/demo/boot.nut
deleted file mode 100644
index 874151b0..00000000
--- a/bin/demo/boot.nut
+++ /dev/null
@@ -1,17 +0,0 @@
-// Compute the path to the scripts folder (use the `ScriptFolder` option from `sqmod.ini`)
-ScriptsPath <- SqSysPath.Working().Append(SqCore.GetOption("ScriptFolder"));
-// Log it for debug purposes
-SqLog.Inf("Booting script from: %s", ScriptsPath.String);
-// Load the command manager
-SqCore.LoadScript(true, SqSysPath(ScriptsPath.String).Append("cmd.nut"));
-// Load event scripts (delay them `true` since we don't need them executed right away)
-SqCore.LoadScript(true, SqSysPath(ScriptsPath.String).Append("events").Append("blip.nut"));
-SqCore.LoadScript(true, SqSysPath(ScriptsPath.String).Append("events").Append("checkpoint.nut"));
-SqCore.LoadScript(true, SqSysPath(ScriptsPath.String).Append("events").Append("custom.nut"));
-SqCore.LoadScript(true, SqSysPath(ScriptsPath.String).Append("events").Append("keybind.nut"));
-SqCore.LoadScript(true, SqSysPath(ScriptsPath.String).Append("events").Append("object.nut"));
-SqCore.LoadScript(true, SqSysPath(ScriptsPath.String).Append("events").Append("pickup.nut"));
-SqCore.LoadScript(true, SqSysPath(ScriptsPath.String).Append("events").Append("player.nut"));
-SqCore.LoadScript(true, SqSysPath(ScriptsPath.String).Append("events").Append("server.nut"));
-SqCore.LoadScript(true, SqSysPath(ScriptsPath.String).Append("events").Append("vehicle.nut"));
-// Load command scripts (delay them `true` since we don't need them executed right away)
diff --git a/bin/demo/cmd.nut b/bin/demo/cmd.nut
deleted file mode 100644
index 11cbd004..00000000
--- a/bin/demo/cmd.nut
+++ /dev/null
@@ -1,103 +0,0 @@
-/* --------------------------------------------------------------------------------------------------------------------
- * We need a command manager to be able to create and manage commands.
- * We also store it in the root table to make it accessible in other scripts.
-*/
-g_Cmd <- SqCmd.Manager();
-/* --------------------------------------------------------------------------------------------------------------------
- * This is our global function we give to the command manager to tell whether someone is allowed
- * or not to execute a certain function. If this function returns false, the command is ignored
-*/
-g_Cmd.BindAuth(this, function(player, command) {
- // I guess we can use the default authority level to make the decision :/
- return (player.Authority >= command.Authority);
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * General purpose error handler for a command manager.
- * Otherwise the player doesn't know why a command failed.
-*/
-g_Cmd.BindFail(this, function(type, msg, payload) {
- // Retrieve the player that executed the command
- local player = g_Cmd.Invoker;
- // See if the invoker even exists
- if (!player || typeof(player) != "SqPlayer") {
- return; // No one to report!
- }
- // Let players know how to get in contact with the owner
- local contact = SqCore.GetOptionOr("OwnerContact", "no.email@to.me");
- // Identify the error type
- switch (type) {
- // The command failed for unknown reasons
- case SqCmdErr.Unknown: {
- player.Message("Unable to execute the command for reasons unknown");
- player.Message("=> Please contact the owner: %s", contact);
- } break;
- // The command failed to execute because there was nothing to execute
- case SqCmdErr.EmptyCommand: {
- player.Message("Cannot execute an empty command");
- } break;
- // The command failed to execute because the command name was invalid after processing
- case SqCmdErr.InvalidCommand: {
- player.Message("The specified command name is invalid");
- } break;
- // The command failed to execute because there was a syntax error in the arguments
- case SqCmdErr.SyntaxError: {
- player.Message("There was a syntax error in argument: %d", payload);
- } break;
- // The command failed to execute because there was no such command
- case SqCmdErr.UnknownCommand: {
- player.Message("The specified command does no exist");
- } break;
- // The command failed to execute because the it's currently suspended
- case SqCmdErr.ListenerSuspended: {
- player.Message("The requested command is currently suspended");
- } break;
- // The command failed to execute because the invoker does not have the proper authority
- case SqCmdErr.InsufficientAuth: {
- player.Message("You don't have the proper authority to execute this command");
- } break;
- // The command failed to execute because there was no callback to handle the execution
- case SqCmdErr.MissingExecuter: {
- player.Message("The specified command is not being processed");
- } break;
- // The command was unable to execute because the argument limit was not reached
- case SqCmdErr.IncompleteArgs: {
- player.Message("The specified command requires at least %d arguments", payload);
- } break;
- // The command was unable to execute because the argument limit was exceeded
- case SqCmdErr.ExtraneousArgs: {
- player.Message("The specified command requires no more than %d arguments", payload);
- } break;
- // Command was unable to execute due to argument type mismatch
- case SqCmdErr.UnsupportedArg: {
- player.Message("Argument %d requires a different type than the one you specified", payload);
- } break;
- // The command arguments contained more data than the internal buffer can handle
- case SqCmdErr.BufferOverflow: {
- player.Message("An internal error occurred and the execution was aborted");
- player.Message("=> Please contact the owner: %s", contact);
- } break;
- // The command failed to complete execution due to a runtime exception
- case SqCmdErr.ExecutionFailed: {
- player.Message("The command failed to complete the execution properly");
- player.Message("=> Please contact the owner: %s", contact);
- } break;
- // The command completed the execution but returned a negative result
- case SqCmdErr.ExecutionAborted: {
- player.Message("The command execution was aborted and therefore had no effect");
- } break;
- // The post execution callback failed to execute due to a runtime exception
- case SqCmdErr.PostProcessingFailed: {
- player.Message("The command post-processing stage failed to complete properly");
- player.Message("=> Please contact the owner: %s", contact);
- } break;
- // The callback that was supposed to deal with the failure also failed due to a runtime exception
- case SqCmdErr.UnresolvedFailure: {
- player.Message("Unable to resolve the failures during command execution");
- player.Message("=> Please contact the owner: %s", contact);
- } break;
- // Something bad happened and no one knows what
- default: {
- SqLog.Inf("Command failed to execute because [%s][%s]", msg, ""+payload);
- }
- }
-});
diff --git a/bin/demo/events/blip.nut b/bin/demo/events/blip.nut
deleted file mode 100644
index 05f7dd92..00000000
--- a/bin/demo/events/blip.nut
+++ /dev/null
@@ -1,19 +0,0 @@
-
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: BlipCreated
-*/
-SqCore.On().BlipCreated.Connect(function(/*SqBlip*/ blip, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: BlipDestroyed
-*/
-SqCore.On().BlipDestroyed.Connect(function(/*SqBlip*/ blip, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: BlipCustom
-*/
-SqCore.On().BlipCustom.Connect(function(/*SqBlip*/ blip, /*int*/ header, /*object*/ payload) {
-
-});
\ No newline at end of file
diff --git a/bin/demo/events/checkpoint.nut b/bin/demo/events/checkpoint.nut
deleted file mode 100644
index 80440d04..00000000
--- a/bin/demo/events/checkpoint.nut
+++ /dev/null
@@ -1,49 +0,0 @@
-
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: CheckpointCreated
-*/
-SqCore.On().CheckpointCreated.Connect(function(/*SqCheckpoint*/ checkpoint, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: CheckpointDestroyed
-*/
-SqCore.On().CheckpointDestroyed.Connect(function(/*SqCheckpoint*/ checkpoint, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: CheckpointCustom
-*/
-SqCore.On().CheckpointCustom.Connect(function(/*SqCheckpoint*/ checkpoint, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: CheckpointStream
-*/
-SqCore.On().CheckpointStream.Connect(function(/*SqPlayer*/ client, /*SqCheckpoint*/ checkpoint, /*bool*/ is_deleted) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: CheckpointEntered
-*/
-SqCore.On().CheckpointEntered.Connect(function(/*SqCheckpoint*/ checkpoint, /*SqPlayer*/ player) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: CheckpointExited
-*/
-SqCore.On().CheckpointExited.Connect(function(/*SqCheckpoint*/ checkpoint, /*SqPlayer*/ player) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: CheckpointWorld
-*/
-SqCore.On().CheckpointWorld.Connect(function(/*SqCheckpoint*/ checkpoint, /*int*/ old_world, /*int*/ new_world) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: CheckpointRadius
-*/
-SqCore.On().CheckpointRadius.Connect(function(/*SqCheckpoint*/ checkpoint, /*float*/ old_radius, /*float*/ new_radius) {
-
-});
\ No newline at end of file
diff --git a/bin/demo/events/custom.nut b/bin/demo/events/custom.nut
deleted file mode 100644
index 7539c5a1..00000000
--- a/bin/demo/events/custom.nut
+++ /dev/null
@@ -1,6 +0,0 @@
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: CustomEvent
-*/
-SqCore.On().CustomEvent.Connect(function(/*int*/ group, /*int*/ header, /*object*/ payload) {
-
-});
\ No newline at end of file
diff --git a/bin/demo/events/keybind.nut b/bin/demo/events/keybind.nut
deleted file mode 100644
index 95907c9b..00000000
--- a/bin/demo/events/keybind.nut
+++ /dev/null
@@ -1,19 +0,0 @@
-
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: KeybindCreated
-*/
-SqCore.On().KeybindCreated.Connect(function(/*SqKeybind*/ keybind, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: KeybindDestroyed
-*/
-SqCore.On().KeybindDestroyed.Connect(function(/*SqKeybind*/ keybind, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: KeybindCustom
-*/
-SqCore.On().KeybindCustom.Connect(function(/*SqKeybind*/ keybind, /*int*/ header, /*object*/ payload) {
-
-});
\ No newline at end of file
diff --git a/bin/demo/events/object.nut b/bin/demo/events/object.nut
deleted file mode 100644
index 2b142088..00000000
--- a/bin/demo/events/object.nut
+++ /dev/null
@@ -1,55 +0,0 @@
-
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ObjectCreated
-*/
-SqCore.On().ObjectCreated.Connect(function(/*SqObject*/ object, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ObjectDestroyed
-*/
-SqCore.On().ObjectDestroyed.Connect(function(/*SqObject*/ object, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ObjectCustom
-*/
-SqCore.On().ObjectCustom.Connect(function(/*SqObject*/ object, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ObjectStream
-*/
-SqCore.On().ObjectStream.Connect(function(/*SqPlayer*/ client, /*SqObject*/ object, /*bool*/ is_deleted) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ObjectShot
-*/
-SqCore.On().ObjectShot.Connect(function(/*SqObject*/ object, /*SqPlayer*/ player, /*int*/ weapon_id) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ObjectTouched
-*/
-SqCore.On().ObjectTouched.Connect(function(/*SqObject*/ object, /*SqPlayer*/ player) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ObjectWorld
-*/
-SqCore.On().ObjectWorld.Connect(function(/*SqObject*/ object, /*int*/ old_world, /*int*/ new_world) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ObjectAlpha
-*/
-SqCore.On().ObjectAlpha.Connect(function(/*SqObject*/ object, /*int*/ old_alpha, /*int*/ new_alpha, /*int*/ time) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ObjectReport
-*/
-SqCore.On().ObjectReport.Connect(function(/*SqObject*/ object, /*bool*/ old_status, /*bool*/ new_status, /*bool*/ touched) {
-
-});
\ No newline at end of file
diff --git a/bin/demo/events/pickup.nut b/bin/demo/events/pickup.nut
deleted file mode 100644
index 5c13b6e9..00000000
--- a/bin/demo/events/pickup.nut
+++ /dev/null
@@ -1,73 +0,0 @@
-
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PickupCreated
-*/
-SqCore.On().PickupCreated.Connect(function(/*SqPickup*/ pickup, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PickupDestroyed
-*/
-SqCore.On().PickupDestroyed.Connect(function(/*SqPickup*/ pickup, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PickupCustom
-*/
-SqCore.On().PickupCustom.Connect(function(/*SqPickup*/ pickup, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PickupStream
-*/
-SqCore.On().PickupStream.Connect(function(/*SqPlayer*/ client, /*SqPickup*/ pickup, /*bool*/ is_deleted) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PickupClaimed
-*/
-SqCore.On().PickupClaimed.Connect(function(/*SqPickup*/ pickup, /*SqPlayer*/ player) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PickupCollected
-*/
-SqCore.On().PickupCollected.Connect(function(/*SqPickup*/ pickup, /*SqPlayer*/ player) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PickupRespawn
-*/
-SqCore.On().PickupRespawn.Connect(function(/*SqPickup*/ pickup) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PickupWorld
-*/
-SqCore.On().PickupWorld.Connect(function(/*SqPickup*/ pickup, /*int*/ old_world, /*int*/ new_world) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PickupAlpha
-*/
-SqCore.On().PickupAlpha.Connect(function(/*SqPickup*/ pickup, /*int*/ old_alpha, /*int*/ new_alpha) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PickupAutomatic
-*/
-SqCore.On().PickupAutomatic.Connect(function(/*SqPickup*/ pickup, /*bool*/ old_status, /*bool*/ new_status) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PickupAutoTimer
-*/
-SqCore.On().PickupAutoTimer.Connect(function(/*SqPickup*/ pickup, /*int*/ old_timer, /*int*/ new_timer) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PickupOption
-*/
-SqCore.On().PickupOption.Connect(function(/*SqPickup*/ pickup, /*int*/ option_id, /*bool*/ value, /*int*/ header, /*object*/ payload) {
-
-});
\ No newline at end of file
diff --git a/bin/demo/events/player.nut b/bin/demo/events/player.nut
deleted file mode 100644
index dd604e2d..00000000
--- a/bin/demo/events/player.nut
+++ /dev/null
@@ -1,427 +0,0 @@
-
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerCreated
-*/
-SqCore.On().PlayerCreated.Connect(function(/*SqPlayer*/ player, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerDestroyed
-*/
-SqCore.On().PlayerDestroyed.Connect(function(/*SqPlayer*/ player, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerCustom
-*/
-SqCore.On().PlayerCustom.Connect(function(/*SqPlayer*/ player, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerStream
-*/
-SqCore.On().PlayerStream.Connect(function(/*SqPlayer*/ client, /*SqPlayer*/ player, /*bool*/ is_deleted) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerRequestClass
-*/
-SqCore.On().PlayerRequestClass.Connect(function(/*SqPlayer*/ player, offset) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerRequestSpawn
-*/
-SqCore.On().PlayerRequestSpawn.Connect(function(/*SqPlayer*/ player) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerSpawn
-*/
-SqCore.On().PlayerSpawn.Connect(function(/*SqPlayer*/ player) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerWasted
-*/
-SqCore.On().PlayerWasted.Connect(function(/*SqPlayer*/ player, /*int*/ reason) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerKilled
-*/
-SqCore.On().PlayerKilled.Connect(function(/*SqPlayer*/ player, /*SqPlayer*/ killer, /*int*/ reason, /*int*/ body_part, /*bool*/ team_kill) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerEmbarking
-*/
-SqCore.On().PlayerEmbarking.Connect(function(/*SqPlayer*/ player, /*SqVehicle*/ vehicle, /*int*/ slot) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerEmbarked
-*/
-SqCore.On().PlayerEmbarked.Connect(function(/*SqPlayer*/ player, /*SqVehicle*/ vehicle, /*int*/ slot) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerDisembark
-*/
-SqCore.On().PlayerDisembark.Connect(function(/*SqPlayer*/ player, /*SqVehicle*/ vehicle) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerRename
-*/
-SqCore.On().PlayerRename.Connect(function(/*SqPlayer*/ player, /*string*/ old_name, /*string*/ new_name) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerState
-*/
-SqCore.On().PlayerState.Connect(function(/*SqPlayer*/ player, /*int*/ old_state, /*int*/ new_state) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: StateNone
-*/
-SqCore.On().StateNone.Connect(function(/*SqPlayer*/ player, /*int*/ old_state) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: StateNormal
-*/
-SqCore.On().StateNormal.Connect(function(/*SqPlayer*/ player, /*int*/ old_state) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: StateAim
-*/
-SqCore.On().StateAim.Connect(function(/*SqPlayer*/ player, /*int*/ old_state) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: StateDriver
-*/
-SqCore.On().StateDriver.Connect(function(/*SqPlayer*/ player, /*int*/ old_state) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: StatePassenger
-*/
-SqCore.On().StatePassenger.Connect(function(/*SqPlayer*/ player, /*int*/ old_state) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: StateEnterDriver
-*/
-SqCore.On().StateEnterDriver.Connect(function(/*SqPlayer*/ player, /*int*/ old_state) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: StateEnterPassenger
-*/
-SqCore.On().StateEnterPassenger.Connect(function(/*SqPlayer*/ player, /*int*/ old_state) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: StateExit
-*/
-SqCore.On().StateExit.Connect(function(/*SqPlayer*/ player, /*int*/ old_state) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: StateUnspawned
-*/
-SqCore.On().StateUnspawned.Connect(function(/*SqPlayer*/ player, /*int*/ old_state) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerAction
-*/
-SqCore.On().PlayerAction.Connect(function(/*SqPlayer*/ player, /*int*/ old_action, /*int*/ new_action) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ActionNone
-*/
-SqCore.On().ActionNone.Connect(function(/*SqPlayer*/ player, /*int*/ old_action) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ActionNormal
-*/
-SqCore.On().ActionNormal.Connect(function(/*SqPlayer*/ player, /*int*/ old_action) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ActionAiming
-*/
-SqCore.On().ActionAiming.Connect(function(/*SqPlayer*/ player, /*int*/ old_action) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ActionShooting
-*/
-SqCore.On().ActionShooting.Connect(function(/*SqPlayer*/ player, /*int*/ old_action) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ActionJumping
-*/
-SqCore.On().ActionJumping.Connect(function(/*SqPlayer*/ player, /*int*/ old_action) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ActionLieDown
-*/
-SqCore.On().ActionLieDown.Connect(function(/*SqPlayer*/ player, /*int*/ old_action) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ActionGettingUp
-*/
-SqCore.On().ActionGettingUp.Connect(function(/*SqPlayer*/ player, /*int*/ old_action) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ActionJumpVehicle
-*/
-SqCore.On().ActionJumpVehicle.Connect(function(/*SqPlayer*/ player, /*int*/ old_action) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ActionDriving
-*/
-SqCore.On().ActionDriving.Connect(function(/*SqPlayer*/ player, /*int*/ old_action) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ActionDying
-*/
-SqCore.On().ActionDying.Connect(function(/*SqPlayer*/ player, /*int*/ old_action) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ActionWasted
-*/
-SqCore.On().ActionWasted.Connect(function(/*SqPlayer*/ player, /*int*/ old_action) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ActionEmbarking
-*/
-SqCore.On().ActionEmbarking.Connect(function(/*SqPlayer*/ player, /*int*/ old_action) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ActionDisembarking
-*/
-SqCore.On().ActionDisembarking.Connect(function(/*SqPlayer*/ player, /*int*/ old_action) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerBurning
-*/
-SqCore.On().PlayerBurning.Connect(function(/*SqPlayer*/ player, /*bool*/ is_on_fire) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerCrouching
-*/
-SqCore.On().PlayerCrouching.Connect(function(/*SqPlayer*/ player, /*bool*/ is_crouching) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerGameKeys
-*/
-SqCore.On().PlayerGameKeys.Connect(function(/*SqPlayer*/ player, /*int*/ old_keys, /*int*/ new_keys) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerStartTyping
-*/
-SqCore.On().PlayerStartTyping.Connect(function(/*SqPlayer*/ player) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerStopTyping
-*/
-SqCore.On().PlayerStopTyping.Connect(function(/*SqPlayer*/ player) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerAway
-*/
-SqCore.On().PlayerAway.Connect(function(/*SqPlayer*/ player, /*bool*/ is_away) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerMessage
-*/
-SqCore.On().PlayerMessage.Connect(function(/*SqPlayer*/ player, /*string*/ message) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerCommand
-*/
-SqCore.On().PlayerCommand.Connect(function(/*SqPlayer*/ player, /*string*/ message) {
- g_Cmd.Run(player, command); // Forward this command to the command manager
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerPrivateMessage
-*/
-SqCore.On().PlayerPrivateMessage.Connect(function(/*SqPlayer*/ player, /*SqPlayer*/ target_player, /*string*/ message) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerKeyPress
-*/
-SqCore.On().PlayerKeyPress.Connect(function(/*SqPlayer*/ player, /*SqKeybind*/ bind) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerKeyRelease
-*/
-SqCore.On().PlayerKeyRelease.Connect(function(/*SqPlayer*/ player, /*SqKeybind*/ bind) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerSpectate
-*/
-SqCore.On().PlayerSpectate.Connect(function(/*SqPlayer*/ player, /*SqPlayer*/ target_player) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerUnspectate
-*/
-SqCore.On().PlayerUnspectate.Connect(function(/*SqPlayer*/ player) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerCrashreport
-*/
-SqCore.On().PlayerCrashreport.Connect(function(/*SqPlayer*/ player, /*string*/ report) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerModuleList
-*/
-SqCore.On().PlayerModuleList.Connect(function(/*SqPlayer*/ player, /*string*/ list) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ClientScriptData
-*/
-SqCore.On().ClientScriptData.Connect(function(/*SqPlayer*/ player, /*SqBuffer*/ data, /*int*/ size) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerUpdate
-*/
-SqCore.On().PlayerUpdate.Connect(function(/*SqPlayer*/ player, /*int*/ update_type) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerHealth
-*/
-SqCore.On().PlayerHealth.Connect(function(/*SqPlayer*/ player, /*float*/ old_health, /*float*/ new_health) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerArmour
-*/
-SqCore.On().PlayerArmour.Connect(function(/*SqPlayer*/ player, /*float*/ old_armour, /*float*/ new_armour) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerWeapon
-*/
-SqCore.On().PlayerWeapon.Connect(function(/*SqPlayer*/ player, /*int*/ old_weapon, /*int*/ new_weapon) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerHeading
-*/
-SqCore.On().PlayerHeading.Connect(function(/*SqPlayer*/ player, /*float*/ old_heading, /*float*/ new_heading) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerPosition
-*/
-SqCore.On().PlayerPosition.Connect(function(/*SqPlayer*/ player, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerOption
-*/
-SqCore.On().PlayerOption.Connect(function(/*SqPlayer*/ player, /*int*/ option_id, /*bool*/ value, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerAdmin
-*/
-SqCore.On().PlayerAdmin.Connect(function(/*SqPlayer*/ player, /*bool*/ old_status, /*bool*/ new_status) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerWorld
-*/
-SqCore.On().PlayerWorld.Connect(function(/*SqPlayer*/ player, /*int*/ old_world, /*int*/ new_world, /*bool*/ secondary) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerTeam
-*/
-SqCore.On().PlayerTeam.Connect(function(/*SqPlayer*/ player, /*int*/ old_team, /*int*/ new_team) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerSkin
-*/
-SqCore.On().PlayerSkin.Connect(function(/*SqPlayer*/ player, /*int*/ old_skin, /*int*/ new_skin) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerMoney
-*/
-SqCore.On().PlayerMoney.Connect(function(/*SqPlayer*/ player, /*int*/ old_money, /*int*/ new_money) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerScore
-*/
-SqCore.On().PlayerScore.Connect(function(/*SqPlayer*/ player, /*int*/ old_score, /*int*/ new_score) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerWantedLevel
-*/
-SqCore.On().PlayerWantedLevel.Connect(function(/*SqPlayer*/ player, /*int*/ old_level, /*int*/ new_level) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerImmunity
-*/
-SqCore.On().PlayerImmunity.Connect(function(/*SqPlayer*/ player, /*int*/ old_immunity, /*int*/ new_immunity) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerAlpha
-*/
-SqCore.On().PlayerAlpha.Connect(function(/*SqPlayer*/ player, /*int*/ old_alpha, /*int*/ new_alpha, /*int*/ fade) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerEnterArea
-*/
-SqCore.On().PlayerEnterArea.Connect(function(/*SqPlayer*/ player, /*SqArea*/ area) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: PlayerLeaveArea
-*/
-SqCore.On().PlayerLeaveArea.Connect(function(/*SqPlayer*/ player, /*SqArea*/ area) {
-
-});
\ No newline at end of file
diff --git a/bin/demo/events/server.nut b/bin/demo/events/server.nut
deleted file mode 100644
index fe335f4a..00000000
--- a/bin/demo/events/server.nut
+++ /dev/null
@@ -1,55 +0,0 @@
-
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ServerStartup
-*/
-SqCore.On().ServerStartup.Connect(function(/*...*/) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ServerShutdown
-*/
-SqCore.On().ServerShutdown.Connect(function(/*...*/) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ServerFrame
-*/
-SqCore.On().ServerFrame.Connect(function(/*float*/ elapsed_time) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: IncomingConnection
-*/
-SqCore.On().IncomingConnection.Connect(function(/*string*/ player_name, /*int*/ name_buffer_size, /*string*/ user_password, /*string*/ ip_address) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: EntityPool
-*/
-SqCore.On().EntityPool.Connect(function(/*int*/ entity_type, /*Sq[Entity]*/ entity, /*bool*/ is_deleted) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: EntityStream
-*/
-SqCore.On().EntityStream.Connect(function(/*SqPlayer*/ player, /*Sq[Entity]*/ entity, /*int*/ entity_type, /*bool*/ is_deleted) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ServerOption
-*/
-SqCore.On().ServerOption.Connect(function(/*int*/ option, /*bool*/ value, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ScriptReload
-*/
-SqCore.On().ScriptReload.Connect(function(/*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: ScriptLoaded
-*/
-SqCore.On().ScriptLoaded.Connect(function(/*...*/) {
-
-});
diff --git a/bin/demo/events/vehicle.nut b/bin/demo/events/vehicle.nut
deleted file mode 100644
index 0ef950c2..00000000
--- a/bin/demo/events/vehicle.nut
+++ /dev/null
@@ -1,127 +0,0 @@
-
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: VehicleCreated
-*/
-SqCore.On().VehicleCreated.Connect(function(/*SqVehicle*/ vehicle, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: VehicleDestroyed
-*/
-SqCore.On().VehicleDestroyed.Connect(function(/*SqVehicle*/ vehicle, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: VehicleCustom
-*/
-SqCore.On().VehicleCustom.Connect(function(/*SqVehicle*/ vehicle, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: VehicleStream
-*/
-SqCore.On().VehicleStream.Connect(function(/*SqPlayer*/ client, /*SqVehicle*/ vehicle, /*bool*/ is_deleted) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: VehicleExplode
-*/
-SqCore.On().VehicleExplode.Connect(function(/*SqVehicle*/ vehicle) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: VehicleRespawn
-*/
-SqCore.On().VehicleRespawn.Connect(function(/*SqVehicle*/ vehicle) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: VehicleUpdate
-*/
-SqCore.On().VehicleUpdate.Connect(function(/*SqVehicle*/ vehicle, /*int*/ update_type) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: VehicleColor
-*/
-SqCore.On().VehicleColor.Connect(function(/*SqVehicle*/ vehicle, /*int*/ changed) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: VehicleHealth
-*/
-SqCore.On().VehicleHealth.Connect(function(/*SqVehicle*/ vehicle, /*float*/ old_health, /*float*/ new_health) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: VehiclePosition
-*/
-SqCore.On().VehiclePosition.Connect(function(/*SqVehicle*/ vehicle) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: VehicleRotation
-*/
-SqCore.On().VehicleRotation.Connect(function(/*SqVehicle*/ vehicle) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: VehicleOption
-*/
-SqCore.On().VehicleOption.Connect(function(/*SqVehicle*/ vehicle, /*int*/ option_id, /*bool*/ value, /*int*/ header, /*object*/ payload) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: VehicleWorld
-*/
-SqCore.On().VehicleWorld.Connect(function(/*SqVehicle*/ vehicle, /*int*/ old_world, /*int*/ new_world) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: VehicleImmunity
-*/
-SqCore.On().VehicleImmunity.Connect(function(/*SqVehicle*/ vehicle, /*int*/ old_immunity, /*int*/ new_immunity) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: VehiclePartStatus
-*/
-SqCore.On().VehiclePartStatus.Connect(function(/*SqVehicle*/ vehicle, /*int*/ part, /*int*/ old_status, /*int*/ new_status) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: VehicleTyreStatus
-*/
-SqCore.On().VehicleTyreStatus.Connect(function(/*SqVehicle*/ vehicle, /*int*/ tyre, /*int*/ old_status, /*int*/ new_status) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: VehicleDamageData
-*/
-SqCore.On().VehicleDamageData.Connect(function(/*SqVehicle*/ vehicle, /*int*/ old_data, /*int*/ new_data) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: VehicleRadio
-*/
-SqCore.On().VehicleRadio.Connect(function(/*SqVehicle*/ vehicle, /*int*/ old_radio, /*int*/ new_radio) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: VehicleHandlingRule
-*/
-SqCore.On().VehicleHandlingRule.Connect(function(/*SqVehicle*/ vehicle, /*int*/ rule, /*float*/ old_data, /*float*/ new_data) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: VehicleEnterArea
-*/
-SqCore.On().VehicleEnterArea.Connect(function(/*SqVehicle*/ vehicle, /*SqArea*/ area) {
-
-});
-/* --------------------------------------------------------------------------------------------------------------------
- * Bind to global event: VehicleLeaveArea
-*/
-SqCore.On().VehicleLeaveArea.Connect(function(/*SqVehicle*/ vehicle, /*SqArea*/ area) {
-
-});
\ No newline at end of file
diff --git a/cbp/ModIRC.cbp b/cbp/ModIRC.cbp
deleted file mode 100644
index 58ee279d..00000000
--- a/cbp/ModIRC.cbp
+++ /dev/null
@@ -1,453 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/cbp/ModJSON.cbp b/cbp/ModJSON.cbp
deleted file mode 100644
index 8f062ae4..00000000
--- a/cbp/ModJSON.cbp
+++ /dev/null
@@ -1,440 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/cbp/ModMMDB.cbp b/cbp/ModMMDB.cbp
deleted file mode 100644
index 127c5ea0..00000000
--- a/cbp/ModMMDB.cbp
+++ /dev/null
@@ -1,466 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/cbp/ModMongoose.cbp b/cbp/ModMongoose.cbp
deleted file mode 100644
index 31935498..00000000
--- a/cbp/ModMongoose.cbp
+++ /dev/null
@@ -1,462 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/cbp/ModMySQL.cbp b/cbp/ModMySQL.cbp
deleted file mode 100644
index 9728941e..00000000
--- a/cbp/ModMySQL.cbp
+++ /dev/null
@@ -1,495 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/cbp/ModSQLite.cbp b/cbp/ModSQLite.cbp
deleted file mode 100644
index 018b39b1..00000000
--- a/cbp/ModSQLite.cbp
+++ /dev/null
@@ -1,454 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/cbp/ModSample.cbp b/cbp/ModSample.cbp
deleted file mode 100644
index 5bf5095c..00000000
--- a/cbp/ModSample.cbp
+++ /dev/null
@@ -1,429 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/cbp/ModXML.cbp b/cbp/ModXML.cbp
deleted file mode 100644
index 2cde12d4..00000000
--- a/cbp/ModXML.cbp
+++ /dev/null
@@ -1,442 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/cbp/Module.cbp b/cbp/Module.cbp
deleted file mode 100644
index b6d1bed5..00000000
--- a/cbp/Module.cbp
+++ /dev/null
@@ -1,591 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/cbp/Sandbox.cbp b/cbp/Sandbox.cbp
deleted file mode 100644
index b4652521..00000000
--- a/cbp/Sandbox.cbp
+++ /dev/null
@@ -1,181 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/cbp/Squirrel.cbp b/cbp/Squirrel.cbp
deleted file mode 100644
index cfac1017..00000000
--- a/cbp/Squirrel.cbp
+++ /dev/null
@@ -1,228 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/cbp/default.workspace b/cbp/default.workspace
deleted file mode 100644
index fac8d50d..00000000
--- a/cbp/default.workspace
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/cmake/FindMySQL.cmake b/cmake/FindMySQL.cmake
new file mode 100644
index 00000000..f30a73e7
--- /dev/null
+++ b/cmake/FindMySQL.cmake
@@ -0,0 +1,220 @@
+#
+# This module is designed to find/handle mysql(client) library
+#
+# Requirements:
+# - CMake >= 2.8.3 (for new version of find_package_handle_standard_args)
+#
+# The following variables will be defined for your use:
+# - MYSQL_INCLUDE_DIRS : mysql(client) include directory
+# - MYSQL_LIBRARIES : mysql(client) libraries
+# - MYSQL_VERSION : complete version of mysql(client) (x.y.z)
+# - MYSQL_VERSION_MAJOR : major version of mysql(client)
+# - MYSQL_VERSION_MINOR : minor version of mysql(client)
+# - MYSQL_VERSION_PATCH : patch version of mysql(client)
+#
+# How to use:
+# 1) Copy this file in the root of your project source directory
+# 2) Then, tell CMake to search this non-standard module in your project directory by adding to your CMakeLists.txt:
+# set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
+# 3) Finally call find_package(MySQL) once
+#
+# Here is a complete sample to build an executable:
+#
+# set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
+#
+# find_package(MySQL REQUIRED) # Note: name is case sensitive
+#
+# add_executable(myapp myapp.c)
+# include_directories(${MYSQL_INCLUDE_DIRS})
+# target_link_libraries(myapp ${MYSQL_LIBRARIES})
+# # with CMake >= 3.0.0, the last two lines can be replaced by the following
+# target_link_libraries(myapp MySQL::MySQL) # Note: case also matters here
+#
+
+
+#=============================================================================
+# Copyright (c) 2013-2016, julp
+#
+# Distributed under the OSI-approved BSD License
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#=============================================================================
+
+cmake_minimum_required(VERSION 2.8.3)
+
+# "As of MySQL 5.7.9, MySQL distributions contain a mysqlclient.pc file that provides information about MySQL configuration for use by the pkg-config command."
+find_package(PkgConfig QUIET)
+
+########## Private ##########
+if(NOT DEFINED MYSQL_PUBLIC_VAR_NS)
+ set(MYSQL_PUBLIC_VAR_NS "MYSQL")
+endif(NOT DEFINED MYSQL_PUBLIC_VAR_NS)
+if(NOT DEFINED MYSQL_PRIVATE_VAR_NS)
+ set(MYSQL_PRIVATE_VAR_NS "_${MYSQL_PUBLIC_VAR_NS}")
+endif(NOT DEFINED MYSQL_PRIVATE_VAR_NS)
+if(NOT DEFINED PC_MYSQL_PRIVATE_VAR_NS)
+ set(PC_MYSQL_PRIVATE_VAR_NS "_PC${PC_MYSQL_PRIVATE_VAR_NS}")
+endif(NOT DEFINED PC_MYSQL_PRIVATE_VAR_NS)
+
+# Alias all MySQL_FIND_X variables to MYSQL_FIND_X
+# Workaround for find_package: no way to force case of variable's names it creates (I don't want to change MY coding standard)
+set(${MYSQL_PRIVATE_VAR_NS}_FIND_PKG_PREFIX "MySQL")
+get_directory_property(${MYSQL_PRIVATE_VAR_NS}_CURRENT_VARIABLES VARIABLES)
+foreach(${MYSQL_PRIVATE_VAR_NS}_VARNAME ${${MYSQL_PRIVATE_VAR_NS}_CURRENT_VARIABLES})
+ if(${MYSQL_PRIVATE_VAR_NS}_VARNAME MATCHES "^${${MYSQL_PRIVATE_VAR_NS}_FIND_PKG_PREFIX}")
+ string(REGEX REPLACE "^${${MYSQL_PRIVATE_VAR_NS}_FIND_PKG_PREFIX}" "${MYSQL_PUBLIC_VAR_NS}" ${MYSQL_PRIVATE_VAR_NS}_NORMALIZED_VARNAME ${${MYSQL_PRIVATE_VAR_NS}_VARNAME})
+ set(${${MYSQL_PRIVATE_VAR_NS}_NORMALIZED_VARNAME} ${${${MYSQL_PRIVATE_VAR_NS}_VARNAME}})
+ endif(${MYSQL_PRIVATE_VAR_NS}_VARNAME MATCHES "^${${MYSQL_PRIVATE_VAR_NS}_FIND_PKG_PREFIX}")
+endforeach(${MYSQL_PRIVATE_VAR_NS}_VARNAME)
+
+macro(_mysql_set_dotted_version VERSION_STRING)
+ set(${MYSQL_PUBLIC_VAR_NS}_VERSION "${VERSION_STRING}")
+ string(REGEX MATCHALL "[0-9]+" ${MYSQL_PRIVATE_VAR_NS}_VERSION_PARTS ${VERSION_STRING})
+ list(GET ${MYSQL_PRIVATE_VAR_NS}_VERSION_PARTS 0 ${MYSQL_PUBLIC_VAR_NS}_VERSION_MAJOR)
+ list(GET ${MYSQL_PRIVATE_VAR_NS}_VERSION_PARTS 1 ${MYSQL_PUBLIC_VAR_NS}_VERSION_MINOR)
+ list(GET ${MYSQL_PRIVATE_VAR_NS}_VERSION_PARTS 2 ${MYSQL_PUBLIC_VAR_NS}_VERSION_PATCH)
+endmacro(_mysql_set_dotted_version)
+
+########## Public ##########
+if(PKG_CONFIG_FOUND)
+ pkg_check_modules(${PC_MYSQL_PRIVATE_VAR_NS} "mysqlclient" QUIET)
+ if(${PC_MYSQL_PRIVATE_VAR_NS}_FOUND)
+ if(${PC_MYSQL_PRIVATE_VAR_NS}_VERSION)
+ _mysql_set_dotted_version("${${PC_MYSQL_PRIVATE_VAR_NS}_VERSION}")
+ endif(${PC_MYSQL_PRIVATE_VAR_NS}_VERSION)
+ endif(${PC_MYSQL_PRIVATE_VAR_NS}_FOUND)
+endif(PKG_CONFIG_FOUND)
+
+find_program(${MYSQL_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE mysql_config)
+if(${MYSQL_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE)
+ execute_process(OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND ${${MYSQL_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --cflags OUTPUT_VARIABLE ${MYSQL_PUBLIC_VAR_NS}_MYSQL_CONFIG_C_FLAGS)
+ execute_process(OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND ${${MYSQL_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --version OUTPUT_VARIABLE ${MYSQL_PUBLIC_VAR_NS}_MYSQL_CONFIG_VERSION)
+ execute_process(OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND ${${MYSQL_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --variable=pkglibdir OUTPUT_VARIABLE ${MYSQL_PUBLIC_VAR_NS}_MYSQL_CONFIG_LIBRARY_DIR)
+ execute_process(OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND ${${MYSQL_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --variable=pkgincludedir OUTPUT_VARIABLE ${MYSQL_PUBLIC_VAR_NS}_MYSQL_CONFIG_INCLUDE_DIR)
+# execute_process(OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND ${${MYSQL_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --plugindir OUTPUT_VARIABLE ${MYSQL_PUBLIC_VAR_NS}_MYSQL_CONFIG_PLUGIN_DIR)
+# execute_process(OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND ${${MYSQL_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --socket OUTPUT_VARIABLE ${MYSQL_PUBLIC_VAR_NS}_MYSQL_CONFIG_SOCKET)
+# execute_process(OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND ${${MYSQL_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --port OUTPUT_VARIABLE ${MYSQL_PUBLIC_VAR_NS}_MYSQL_CONFIG_PORT)
+# execute_process(OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND ${${MYSQL_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --libmysqld-libs OUTPUT_VARIABLE ${MYSQL_PUBLIC_VAR_NS}_MYSQL_CONFIG_LIBRARY_EMBEDDED)
+
+ _mysql_set_dotted_version("${${MYSQL_PUBLIC_VAR_NS}_MYSQL_CONFIG_VERSION}")
+endif(${MYSQL_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE)
+
+find_path(
+ ${MYSQL_PUBLIC_VAR_NS}_INCLUDE_DIR
+ NAMES mysql_version.h
+ PATH_SUFFIXES include mysql
+ PATHS ${${PC_MYSQL_PRIVATE_VAR_NS}_INCLUDE_DIRS} ${${MYSQL_PUBLIC_VAR_NS}_MYSQL_CONFIG_INCLUDE_DIR}
+)
+
+if(MSVC)
+ include(SelectLibraryConfigurations)
+ # "On Windows, the static library is mysqlclient.lib and the dynamic library is libmysql.dll. Windows distributions also include libmysql.lib, a static import library needed for using the dynamic library."
+ set(${MYSQL_PRIVATE_VAR_NS}_POSSIBLE_DEBUG_NAMES "mysqld mysqlclientd")
+ set(${MYSQL_PRIVATE_VAR_NS}_POSSIBLE_RELEASE_NAMES "mysql mysqlclient")
+
+ find_library(
+ ${MYSQL_PUBLIC_VAR_NS}_LIBRARY_RELEASE
+ NAMES ${${MYSQL_PRIVATE_VAR_NS}_POSSIBLE_RELEASE_NAMES}
+ DOC "Release library for mysqlclient"
+ )
+ find_library(
+ ${MYSQL_PUBLIC_VAR_NS}_LIBRARY_DEBUG
+ NAMES ${${MYSQL_PRIVATE_VAR_NS}_POSSIBLE_DEBUG_NAMES}
+ DOC "Debug library for mysqlclient"
+ )
+
+ select_library_configurations("${MYSQL_PUBLIC_VAR_NS}")
+else(MSVC)
+ # "On Unix (and Unix-like) sytems, the static library is libmysqlclient.a. The dynamic library is libmysqlclient.so on most Unix systems and libmysqlclient.dylib on OS X."
+ find_library(
+ ${MYSQL_PUBLIC_VAR_NS}_LIBRARY
+ NAMES mysqlclient
+ PATHS ${${PC_MYSQL_PRIVATE_VAR_NS}_LIBRARY_DIRS} ${${MYSQL_PUBLIC_VAR_NS}_MYSQL_CONFIG_LIBRARY_DIR}
+ )
+endif(MSVC)
+
+if(${MYSQL_PUBLIC_VAR_NS}_INCLUDE_DIR AND NOT ${MYSQL_PUBLIC_VAR_NS}_VERSION)
+ file(STRINGS "${${MYSQL_PUBLIC_VAR_NS}_INCLUDE_DIR}/mysql_version.h" ${MYSQL_PRIVATE_VAR_NS}_VERSION_NUMBER_DEFINITION LIMIT_COUNT 1 REGEX ".*#[ \t]*define[ \t]*MYSQL_VERSION_ID[ \t]*[0-9]+.*")
+ string(REGEX REPLACE ".*# *define +MYSQL_VERSION_ID +([0-9]+).*" "\\1" ${MYSQL_PRIVATE_VAR_NS}_VERSION_NUMBER ${${MYSQL_PRIVATE_VAR_NS}_VERSION_NUMBER_DEFINITION})
+
+ math(EXPR ${MYSQL_PUBLIC_VAR_NS}_VERSION_MAJOR "${${MYSQL_PRIVATE_VAR_NS}_VERSION_NUMBER} / 10000")
+ math(EXPR ${MYSQL_PUBLIC_VAR_NS}_VERSION_MINOR "(${${MYSQL_PRIVATE_VAR_NS}_VERSION_NUMBER} - ${${MYSQL_PUBLIC_VAR_NS}_VERSION_MAJOR} * 10000) / 100")
+ math(EXPR ${MYSQL_PUBLIC_VAR_NS}_VERSION_PATCH "${${MYSQL_PRIVATE_VAR_NS}_VERSION_NUMBER} - ${${MYSQL_PUBLIC_VAR_NS}_VERSION_MAJOR} * 10000 - ${${MYSQL_PUBLIC_VAR_NS}_VERSION_MINOR} * 100")
+ set(${MYSQL_PUBLIC_VAR_NS}_VERSION "${${MYSQL_PUBLIC_VAR_NS}_VERSION_MAJOR}.${${MYSQL_PUBLIC_VAR_NS}_VERSION_MINOR}.${${MYSQL_PUBLIC_VAR_NS}_VERSION_PATCH}")
+endif(${MYSQL_PUBLIC_VAR_NS}_INCLUDE_DIR AND NOT ${MYSQL_PUBLIC_VAR_NS}_VERSION)
+
+# Check find_package arguments
+include(FindPackageHandleStandardArgs)
+if(${MYSQL_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${MYSQL_PUBLIC_VAR_NS}_FIND_QUIETLY)
+ find_package_handle_standard_args(
+ ${MYSQL_PUBLIC_VAR_NS}
+ REQUIRED_VARS ${MYSQL_PUBLIC_VAR_NS}_LIBRARY ${MYSQL_PUBLIC_VAR_NS}_INCLUDE_DIR
+ VERSION_VAR ${MYSQL_PUBLIC_VAR_NS}_VERSION
+ )
+else(${MYSQL_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${MYSQL_PUBLIC_VAR_NS}_FIND_QUIETLY)
+ find_package_handle_standard_args(${MYSQL_PUBLIC_VAR_NS} "Could NOT find mysql(client)" ${MYSQL_PUBLIC_VAR_NS}_LIBRARY ${MYSQL_PUBLIC_VAR_NS}_INCLUDE_DIR)
+endif(${MYSQL_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${MYSQL_PUBLIC_VAR_NS}_FIND_QUIETLY)
+
+if(${MYSQL_PUBLIC_VAR_NS}_FOUND)
+ #
+ # for compatibility with previous versions, alias old MYSQL_(MAJOR|MINOR|PATCH)_VERSION to MYSQL_VERSION_$1
+ set(${MYSQL_PUBLIC_VAR_NS}_MAJOR_VERSION ${${MYSQL_PUBLIC_VAR_NS}_VERSION_MAJOR})
+ set(${MYSQL_PUBLIC_VAR_NS}_MINOR_VERSION ${${MYSQL_PUBLIC_VAR_NS}_VERSION_MINOR})
+ set(${MYSQL_PUBLIC_VAR_NS}_PATCH_VERSION ${${MYSQL_PUBLIC_VAR_NS}_VERSION_PATCH})
+ #
+ set(${MYSQL_PUBLIC_VAR_NS}_LIBRARIES ${${MYSQL_PUBLIC_VAR_NS}_LIBRARY})
+ set(${MYSQL_PUBLIC_VAR_NS}_INCLUDE_DIRS ${${MYSQL_PUBLIC_VAR_NS}_INCLUDE_DIR})
+ if(CMAKE_VERSION VERSION_GREATER "3.0.0")
+ if(NOT TARGET MySQL::MySQL)
+ add_library(MySQL::MySQL UNKNOWN IMPORTED)
+ endif(NOT TARGET MySQL::MySQL)
+ if(${MYSQL_PUBLIC_VAR_NS}_LIBRARY_RELEASE)
+ set_property(TARGET MySQL::MySQL APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+ set_target_properties(MySQL::MySQL PROPERTIES IMPORTED_LOCATION_RELEASE "${${MYSQL_PUBLIC_VAR_NS}_LIBRARY_RELEASE}")
+ endif(${MYSQL_PUBLIC_VAR_NS}_LIBRARY_RELEASE)
+ if(${MYSQL_PUBLIC_VAR_NS}_LIBRARY_DEBUG)
+ set_property(TARGET MySQL::MySQL APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
+ set_target_properties(MySQL::MySQL PROPERTIES IMPORTED_LOCATION_DEBUG "${${MYSQL_PUBLIC_VAR_NS}_LIBRARY_DEBUG}")
+ endif(${MYSQL_PUBLIC_VAR_NS}_LIBRARY_DEBUG)
+ if(${MYSQL_PUBLIC_VAR_NS}_LIBRARY)
+ set_target_properties(MySQL::MySQL PROPERTIES IMPORTED_LOCATION "${${MYSQL_PUBLIC_VAR_NS}_LIBRARY}")
+ endif(${MYSQL_PUBLIC_VAR_NS}_LIBRARY)
+ set_target_properties(MySQL::MySQL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${${MYSQL_PUBLIC_VAR_NS}_INCLUDE_DIR}")
+ endif(CMAKE_VERSION VERSION_GREATER "3.0.0")
+endif(${MYSQL_PUBLIC_VAR_NS}_FOUND)
+
+mark_as_advanced(
+ ${MYSQL_PUBLIC_VAR_NS}_INCLUDE_DIR
+ ${MYSQL_PUBLIC_VAR_NS}_LIBRARY
+)
+
+########## ##########
+
+if(${MYSQL_PUBLIC_VAR_NS}_DEBUG)
+
+ function(mysql_debug _VARNAME)
+ if(DEFINED ${MYSQL_PUBLIC_VAR_NS}_${_VARNAME})
+ message("${MYSQL_PUBLIC_VAR_NS}_${_VARNAME} = ${${MYSQL_PUBLIC_VAR_NS}_${_VARNAME}}")
+ else(DEFINED ${MYSQL_PUBLIC_VAR_NS}_${_VARNAME})
+ message("${MYSQL_PUBLIC_VAR_NS}_${_VARNAME} = ")
+ endif(DEFINED ${MYSQL_PUBLIC_VAR_NS}_${_VARNAME})
+ endfunction(mysql_debug)
+
+ # IN (args)
+ mysql_debug("FIND_REQUIRED")
+ mysql_debug("FIND_QUIETLY")
+ mysql_debug("FIND_VERSION")
+ # OUT
+ # Linking
+ mysql_debug("INCLUDE_DIRS")
+ mysql_debug("LIBRARIES")
+ # Version
+ mysql_debug("VERSION_MAJOR")
+ mysql_debug("VERSION_MINOR")
+ mysql_debug("VERSION_PATCH")
+ mysql_debug("VERSION")
+
+endif(${MYSQL_PUBLIC_VAR_NS}_DEBUG)
+
+########## ##########
diff --git a/config/common/maxminddb_config.h b/config/common/maxminddb_config.h
deleted file mode 100644
index 70d5dfde..00000000
--- a/config/common/maxminddb_config.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef MAXMINDDB_CONFIG_H
-#define MAXMINDDB_CONFIG_H
-
-#ifndef MMDB_UINT128_USING_MODE
-/* Define as 1 if we we use unsigned int __atribute__ ((__mode__(TI))) for uint128 values */
-#if __x86_64__
- #define MMDB_UINT128_USING_MODE 1
-#else
- #define MMDB_UINT128_USING_MODE 0
-#endif
-
-#endif
-
-#ifndef MMDB_UINT128_IS_BYTE_ARRAY
-/* Define as 1 if we don't have an unsigned __int128 type */\
-#if __x86_64__
- #undef MMDB_UINT128_IS_BYTE_ARRAY
-#else
- #define MMDB_UINT128_IS_BYTE_ARRAY 1
-#endif
-
-#endif
-
-/* Name of package */
-#define PACKAGE "libmaxminddb"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "support@maxmind.com"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "libmaxminddb"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "libmaxminddb 1.4.2"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "libmaxminddb"
-
-/* Define to the home page for this package. */
-#define PACKAGE_URL ""
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.4.2"
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Version number of package */
-#define VERSION "1.4.2"
-
-#endif /* MAXMINDDB_CONFIG_H */
diff --git a/config/gcc32/ircconfig.h b/config/gcc32/ircconfig.h
deleted file mode 100644
index 67b56b6c..00000000
--- a/config/gcc32/ircconfig.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* src/config.h. Generated from config.h.in by configure. */
-/* include/config.h.in. Generated from configure.in by autoheader. */
-
-/* Define to 1 if you have the `getaddrinfo' function. */
-/* #undef HAVE_GETADDRINFO */
-
-/* Define to 1 if you have the `gethostbyname_r' function. */
-#define HAVE_GETHOSTBYNAME_R 1
-
-/* Define to 1 if you have the `inet_ntoa' function. */
-#define HAVE_INET_NTOA 1
-
-/* Define to 1 if you have the `inet_pton' function. */
-/* #undef HAVE_INET_PTON */
-
-/* Define to 1 if you have the header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the `localtime_r' function. */
-#define HAVE_LOCALTIME_R 1
-
-/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
- to 0 otherwise. */
-#define HAVE_MALLOC 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have the `socket' function. */
-#define HAVE_SOCKET 1
-
-/* Define to 1 if `stat' has the bug that it succeeds when given the
- zero-length file name argument. */
-/* #undef HAVE_STAT_EMPTY_STRING_BUG */
-
-/* Define to 1 if stdbool.h conforms to C99. */
-#define HAVE_STDBOOL_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_SELECT_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_SOCKET_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define to 1 if the system has the type `_Bool'. */
-#define HAVE__BOOL 1
-
-/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
- slash. */
-#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "gyunaev@ulduzsoft.com"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "libircclient"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "libircclient 1.3"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "libircclient"
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.3"
-
-/* Define to the type of arg 1 for `select'. */
-#define SELECT_TYPE_ARG1 int
-
-/* Define to the type of args 2, 3 and 4 for `select'. */
-#define SELECT_TYPE_ARG234 (fd_set *)
-
-/* Define to the type of arg 5 for `select'. */
-#define SELECT_TYPE_ARG5 (struct timeval *)
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define to 1 if you can safely include both and . */
-#define TIME_WITH_SYS_TIME 1
-
-/* Define to empty if `const' does not conform to ANSI C. */
-/* #undef const */
-
-/* Define to rpl_malloc if the replacement function should be used. */
-/* #undef malloc */
-
-/* Define to `unsigned int' if does not define. */
-/* #undef size_t */
diff --git a/config/gcc32/maxminddb_config.h b/config/gcc32/maxminddb_config.h
deleted file mode 100644
index f8505b72..00000000
--- a/config/gcc32/maxminddb_config.h
+++ /dev/null
@@ -1,195 +0,0 @@
-/* include/maxminddb_config.h. Generated from maxminddb_config.h.in by configure. */
-#ifndef MAXMINDDB_CONFIG_H
-#define MAXMINDDB_CONFIG_H
-/* config.h. Generated from config.h.in by configure. */
-/* config.h.in. Generated from configure.ac by autoheader. */
-
-/* Define to 1 if you have the header file. */
-#define HAVE_ARPA_INET_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_ASSERT_H 1
-
-/* Define to 1 if the system has the type `boolean'. */
-/* #undef HAVE_BOOLEAN */
-
-/* Define to 1 if you have the header file. */
-#define HAVE_DLFCN_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_FCNTL_H 1
-
-/* Define to 1 if you have the `getpagesize' function. */
-#define HAVE_GETPAGESIZE 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_LIBGEN_H 1
-
-/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
- to 0 otherwise. */
-#define HAVE_MALLOC 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_MATH_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have a working `mmap' system call. */
-#define HAVE_MMAP 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_NETDB_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_NETINET_IN_H 1
-
-/* Has an open_memstream() function */
-#define HAVE_OPEN_MEMSTREAM 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDARG_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDBOOL_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDIO_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_MMAN_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_PARAM_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_SOCKET_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_TIME_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
- */
-#define LT_OBJDIR ".libs/"
-
-/* Missing the unsigned __int128 type */
-#define MMDB_UINT128_IS_BYTE_ARRAY 1
-
-/* int128 types are available with __attribute__((mode(TI))) */
-/* #undef MMDB_UINT128_USING_MODE */
-
-/* Name of package */
-#define PACKAGE "libmaxminddb"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "support@maxmind.com"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "libmaxminddb"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "libmaxminddb 1.4.2"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "libmaxminddb"
-
-/* Define to the home page for this package. */
-#define PACKAGE_URL ""
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.4.2"
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Version number of package */
-#define VERSION "1.4.2"
-
-/* Define for Solaris 2.5.1 so the uint32_t typedef from ,
- , or is not used. If the typedef were allowed, the
- #define below would cause a syntax error. */
-/* #undef _UINT32_T */
-
-/* Define for Solaris 2.5.1 so the uint64_t typedef from ,
- , or is not used. If the typedef were allowed, the
- #define below would cause a syntax error. */
-/* #undef _UINT64_T */
-
-/* Define for Solaris 2.5.1 so the uint8_t typedef from ,
- , or is not used. If the typedef were allowed, the
- #define below would cause a syntax error. */
-/* #undef _UINT8_T */
-
-/* Define to rpl_malloc if the replacement function should be used. */
-/* #undef malloc */
-
-/* Define to `long int' if does not define. */
-/* #undef off_t */
-
-/* Define to the equivalent of the C99 'restrict' keyword, or to
- nothing if this is not supported. Do not define if restrict is
- supported directly. */
-#define restrict __restrict
-/* Work around a bug in Sun C++: it does not support _Restrict or
- __restrict__, even though the corresponding Sun C compiler ends up with
- "#define restrict _Restrict" or "#define restrict __restrict__" in the
- previous line. Perhaps some future version of Sun C++ will work with
- restrict; if so, hopefully it defines __RESTRICT like Sun C does. */
-#if defined __SUNPRO_CC && !defined __RESTRICT
-# define _Restrict
-# define __restrict__
-#endif
-
-/* Define to `unsigned int' if does not define. */
-/* #undef size_t */
-
-/* Define to `int' if does not define. */
-/* #undef ssize_t */
-
-/* Define to the type of an unsigned integer type of width exactly 32 bits if
- such a type exists and the standard includes do not define it. */
-/* #undef uint32_t */
-
-/* Define to the type of an unsigned integer type of width exactly 64 bits if
- such a type exists and the standard includes do not define it. */
-/* #undef uint64_t */
-
-/* Define to the type of an unsigned integer type of width exactly 8 bits if
- such a type exists and the standard includes do not define it. */
-/* #undef uint8_t */
-
-#ifndef MMDB_UINT128_USING_MODE
-/* Define as 1 if we we use unsigned int __atribute__ ((__mode__(TI))) for uint128 values */
-#define MMDB_UINT128_USING_MODE 0
-#endif
-
-#ifndef MMDB_UINT128_IS_BYTE_ARRAY
-/* Define as 1 if we don't have an unsigned __int128 type */
-#define MMDB_UINT128_IS_BYTE_ARRAY 0
-#endif
-
-#endif /* MAXMINDDB_CONFIG_H */
diff --git a/config/gcc64/ircconfig.h b/config/gcc64/ircconfig.h
deleted file mode 100644
index 67b56b6c..00000000
--- a/config/gcc64/ircconfig.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* src/config.h. Generated from config.h.in by configure. */
-/* include/config.h.in. Generated from configure.in by autoheader. */
-
-/* Define to 1 if you have the `getaddrinfo' function. */
-/* #undef HAVE_GETADDRINFO */
-
-/* Define to 1 if you have the `gethostbyname_r' function. */
-#define HAVE_GETHOSTBYNAME_R 1
-
-/* Define to 1 if you have the `inet_ntoa' function. */
-#define HAVE_INET_NTOA 1
-
-/* Define to 1 if you have the `inet_pton' function. */
-/* #undef HAVE_INET_PTON */
-
-/* Define to 1 if you have the header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the `localtime_r' function. */
-#define HAVE_LOCALTIME_R 1
-
-/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
- to 0 otherwise. */
-#define HAVE_MALLOC 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have the `socket' function. */
-#define HAVE_SOCKET 1
-
-/* Define to 1 if `stat' has the bug that it succeeds when given the
- zero-length file name argument. */
-/* #undef HAVE_STAT_EMPTY_STRING_BUG */
-
-/* Define to 1 if stdbool.h conforms to C99. */
-#define HAVE_STDBOOL_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_SELECT_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_SOCKET_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define to 1 if the system has the type `_Bool'. */
-#define HAVE__BOOL 1
-
-/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
- slash. */
-#define LSTAT_FOLLOWS_SLASHED_SYMLINK 1
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "gyunaev@ulduzsoft.com"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "libircclient"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "libircclient 1.3"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "libircclient"
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.3"
-
-/* Define to the type of arg 1 for `select'. */
-#define SELECT_TYPE_ARG1 int
-
-/* Define to the type of args 2, 3 and 4 for `select'. */
-#define SELECT_TYPE_ARG234 (fd_set *)
-
-/* Define to the type of arg 5 for `select'. */
-#define SELECT_TYPE_ARG5 (struct timeval *)
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define to 1 if you can safely include both and . */
-#define TIME_WITH_SYS_TIME 1
-
-/* Define to empty if `const' does not conform to ANSI C. */
-/* #undef const */
-
-/* Define to rpl_malloc if the replacement function should be used. */
-/* #undef malloc */
-
-/* Define to `unsigned int' if does not define. */
-/* #undef size_t */
diff --git a/config/gcc64/maxminddb_config.h b/config/gcc64/maxminddb_config.h
deleted file mode 100644
index b5498aba..00000000
--- a/config/gcc64/maxminddb_config.h
+++ /dev/null
@@ -1,195 +0,0 @@
-/* include/maxminddb_config.h. Generated from maxminddb_config.h.in by configure. */
-#ifndef MAXMINDDB_CONFIG_H
-#define MAXMINDDB_CONFIG_H
-/* config.h. Generated from config.h.in by configure. */
-/* config.h.in. Generated from configure.ac by autoheader. */
-
-/* Define to 1 if you have the header file. */
-#define HAVE_ARPA_INET_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_ASSERT_H 1
-
-/* Define to 1 if the system has the type `boolean'. */
-/* #undef HAVE_BOOLEAN */
-
-/* Define to 1 if you have the header file. */
-#define HAVE_DLFCN_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_FCNTL_H 1
-
-/* Define to 1 if you have the `getpagesize' function. */
-#define HAVE_GETPAGESIZE 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_LIBGEN_H 1
-
-/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
- to 0 otherwise. */
-#define HAVE_MALLOC 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_MATH_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have a working `mmap' system call. */
-#define HAVE_MMAP 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_NETDB_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_NETINET_IN_H 1
-
-/* Has an open_memstream() function */
-#define HAVE_OPEN_MEMSTREAM 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDARG_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDBOOL_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDIO_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_MMAN_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_PARAM_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_SOCKET_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_TIME_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
- */
-#define LT_OBJDIR ".libs/"
-
-/* Missing the unsigned __int128 type */
-#define MMDB_UINT128_IS_BYTE_ARRAY 0
-
-/* int128 types are available with __attribute__((mode(TI))) */
-/* #undef MMDB_UINT128_USING_MODE */
-
-/* Name of package */
-#define PACKAGE "libmaxminddb"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "support@maxmind.com"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "libmaxminddb"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "libmaxminddb 1.4.2"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "libmaxminddb"
-
-/* Define to the home page for this package. */
-#define PACKAGE_URL ""
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.4.2"
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Version number of package */
-#define VERSION "1.4.2"
-
-/* Define for Solaris 2.5.1 so the uint32_t typedef from ,
- , or is not used. If the typedef were allowed, the
- #define below would cause a syntax error. */
-/* #undef _UINT32_T */
-
-/* Define for Solaris 2.5.1 so the uint64_t typedef from ,
- , or is not used. If the typedef were allowed, the
- #define below would cause a syntax error. */
-/* #undef _UINT64_T */
-
-/* Define for Solaris 2.5.1 so the uint8_t typedef from ,
- , or is not used. If the typedef were allowed, the
- #define below would cause a syntax error. */
-/* #undef _UINT8_T */
-
-/* Define to rpl_malloc if the replacement function should be used. */
-/* #undef malloc */
-
-/* Define to `long int' if does not define. */
-/* #undef off_t */
-
-/* Define to the equivalent of the C99 'restrict' keyword, or to
- nothing if this is not supported. Do not define if restrict is
- supported directly. */
-#define restrict __restrict
-/* Work around a bug in Sun C++: it does not support _Restrict or
- __restrict__, even though the corresponding Sun C compiler ends up with
- "#define restrict _Restrict" or "#define restrict __restrict__" in the
- previous line. Perhaps some future version of Sun C++ will work with
- restrict; if so, hopefully it defines __RESTRICT like Sun C does. */
-#if defined __SUNPRO_CC && !defined __RESTRICT
-# define _Restrict
-# define __restrict__
-#endif
-
-/* Define to `unsigned int' if does not define. */
-/* #undef size_t */
-
-/* Define to `int' if does not define. */
-/* #undef ssize_t */
-
-/* Define to the type of an unsigned integer type of width exactly 32 bits if
- such a type exists and the standard includes do not define it. */
-/* #undef uint32_t */
-
-/* Define to the type of an unsigned integer type of width exactly 64 bits if
- such a type exists and the standard includes do not define it. */
-/* #undef uint64_t */
-
-/* Define to the type of an unsigned integer type of width exactly 8 bits if
- such a type exists and the standard includes do not define it. */
-/* #undef uint8_t */
-
-#ifndef MMDB_UINT128_USING_MODE
-/* Define as 1 if we we use unsigned int __atribute__ ((__mode__(TI))) for uint128 values */
-#define MMDB_UINT128_USING_MODE 0
-#endif
-
-#ifndef MMDB_UINT128_IS_BYTE_ARRAY
-/* Define as 1 if we don't have an unsigned __int128 type */
-#define MMDB_UINT128_IS_BYTE_ARRAY 0
-#endif
-
-#endif /* MAXMINDDB_CONFIG_H */
diff --git a/config/mingw32/ircconfig.h b/config/mingw32/ircconfig.h
deleted file mode 100644
index d1910322..00000000
--- a/config/mingw32/ircconfig.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* src/config.h. Generated from config.h.in by configure. */
-/* include/config.h.in. Generated from configure.in by autoheader. */
-
-/* Define to 1 if you have the `getaddrinfo' function. */
-/* #undef HAVE_GETADDRINFO */
-
-/* Define to 1 if you have the `gethostbyname_r' function. */
-/* #undef HAVE_GETHOSTBYNAME_R */
-
-/* Define to 1 if you have the `inet_ntoa' function. */
-/* #undef HAVE_INET_NTOA */
-
-/* Define to 1 if you have the `inet_pton' function. */
-/* #undef HAVE_INET_PTON */
-
-/* Define to 1 if you have the header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the `localtime_r' function. */
-/* #undef HAVE_LOCALTIME_R */
-
-/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
- to 0 otherwise. */
-#define HAVE_MALLOC 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have the `socket' function. */
-/* #undef HAVE_SOCKET */
-
-/* Define to 1 if `stat' has the bug that it succeeds when given the
- zero-length file name argument. */
-/* #undef HAVE_STAT_EMPTY_STRING_BUG */
-
-/* Define to 1 if stdbool.h conforms to C99. */
-#define HAVE_STDBOOL_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the header file. */
-/* #undef HAVE_SYS_SELECT_H */
-
-/* Define to 1 if you have the header file. */
-/* #undef HAVE_SYS_SOCKET_H */
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define to 1 if the system has the type `_Bool'. */
-#define HAVE__BOOL 1
-
-/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
- slash. */
-/* #undef LSTAT_FOLLOWS_SLASHED_SYMLINK */
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "gyunaev@ulduzsoft.com"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "libircclient"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "libircclient 1.3"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "libircclient"
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.3"
-
-/* Define to the type of arg 1 for `select'. */
-#define SELECT_TYPE_ARG1 int
-
-/* Define to the type of args 2, 3 and 4 for `select'. */
-#define SELECT_TYPE_ARG234 (int *)
-
-/* Define to the type of arg 5 for `select'. */
-#define SELECT_TYPE_ARG5 (struct timeval *)
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define to 1 if you can safely include both and . */
-#define TIME_WITH_SYS_TIME 1
-
-/* Define to empty if `const' does not conform to ANSI C. */
-/* #undef const */
-
-/* Define to rpl_malloc if the replacement function should be used. */
-/* #undef malloc */
-
-/* Define to `unsigned int' if does not define. */
-/* #undef size_t */
diff --git a/config/mingw64/endian.h b/config/mingw64/endian.h
deleted file mode 100644
index 120371d0..00000000
--- a/config/mingw64/endian.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef _ENDIAN_H_
-#define _ENDIAN_H_
-
-#if defined(__MINGW32__) || defined(__MINGW64__)
- // Workaround for MinGW and it's lack of file
- #define __BYTE_ORDER __BYTE_ORDER__
- #define __LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
- #define __BIG_ENDIAN __ORDER_BIG_ENDIAN__
-#elif !defined(_MSC_VER)
- // Just include the system file
- #include
-#endif
-
-#endif // _ENDIAN_H_
\ No newline at end of file
diff --git a/config/mingw64/ircconfig.h b/config/mingw64/ircconfig.h
deleted file mode 100644
index d1910322..00000000
--- a/config/mingw64/ircconfig.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* src/config.h. Generated from config.h.in by configure. */
-/* include/config.h.in. Generated from configure.in by autoheader. */
-
-/* Define to 1 if you have the `getaddrinfo' function. */
-/* #undef HAVE_GETADDRINFO */
-
-/* Define to 1 if you have the `gethostbyname_r' function. */
-/* #undef HAVE_GETHOSTBYNAME_R */
-
-/* Define to 1 if you have the `inet_ntoa' function. */
-/* #undef HAVE_INET_NTOA */
-
-/* Define to 1 if you have the `inet_pton' function. */
-/* #undef HAVE_INET_PTON */
-
-/* Define to 1 if you have the header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the `localtime_r' function. */
-/* #undef HAVE_LOCALTIME_R */
-
-/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
- to 0 otherwise. */
-#define HAVE_MALLOC 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have the `socket' function. */
-/* #undef HAVE_SOCKET */
-
-/* Define to 1 if `stat' has the bug that it succeeds when given the
- zero-length file name argument. */
-/* #undef HAVE_STAT_EMPTY_STRING_BUG */
-
-/* Define to 1 if stdbool.h conforms to C99. */
-#define HAVE_STDBOOL_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the header file. */
-/* #undef HAVE_SYS_SELECT_H */
-
-/* Define to 1 if you have the header file. */
-/* #undef HAVE_SYS_SOCKET_H */
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define to 1 if the system has the type `_Bool'. */
-#define HAVE__BOOL 1
-
-/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
- slash. */
-/* #undef LSTAT_FOLLOWS_SLASHED_SYMLINK */
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "gyunaev@ulduzsoft.com"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "libircclient"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "libircclient 1.3"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "libircclient"
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.3"
-
-/* Define to the type of arg 1 for `select'. */
-#define SELECT_TYPE_ARG1 int
-
-/* Define to the type of args 2, 3 and 4 for `select'. */
-#define SELECT_TYPE_ARG234 (int *)
-
-/* Define to the type of arg 5 for `select'. */
-#define SELECT_TYPE_ARG5 (struct timeval *)
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define to 1 if you can safely include both and . */
-#define TIME_WITH_SYS_TIME 1
-
-/* Define to empty if `const' does not conform to ANSI C. */
-/* #undef const */
-
-/* Define to rpl_malloc if the replacement function should be used. */
-/* #undef malloc */
-
-/* Define to `unsigned int' if does not define. */
-/* #undef size_t */
diff --git a/external/Jansson/dump.c b/external/Jansson/dump.c
deleted file mode 100644
index 912f955f..00000000
--- a/external/Jansson/dump.c
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
- * Copyright (c) 2009-2014 Petri Lehtinen
- *
- * Jansson is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See LICENSE for details.
- */
-
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
-#include
-#include
-#include
-#include
-
-#include "jansson.h"
-#include "jansson_private.h"
-#include "strbuffer.h"
-#include "utf.h"
-
-#define MAX_INTEGER_STR_LENGTH 100
-#define MAX_REAL_STR_LENGTH 100
-
-#define FLAGS_TO_INDENT(f) ((f) & 0x1F)
-#define FLAGS_TO_PRECISION(f) (((f) >> 11) & 0x1F)
-
-struct object_key {
- size_t serial;
- const char *key;
-};
-
-static int dump_to_strbuffer(const char *buffer, size_t size, void *data)
-{
- return strbuffer_append_bytes((strbuffer_t *)data, buffer, size);
-}
-
-static int dump_to_file(const char *buffer, size_t size, void *data)
-{
- FILE *dest = (FILE *)data;
- if(fwrite(buffer, size, 1, dest) != 1)
- return -1;
- return 0;
-}
-
-/* 32 spaces (the maximum indentation size) */
-static const char whitespace[] = " ";
-
-static int dump_indent(size_t flags, int depth, int space, json_dump_callback_t dump, void *data)
-{
- if(FLAGS_TO_INDENT(flags) > 0)
- {
- unsigned int ws_count = FLAGS_TO_INDENT(flags), n_spaces = depth * ws_count;
-
- if(dump("\n", 1, data))
- return -1;
-
- while(n_spaces > 0)
- {
- int cur_n = n_spaces < sizeof whitespace - 1 ? n_spaces : sizeof whitespace - 1;
-
- if(dump(whitespace, cur_n, data))
- return -1;
-
- n_spaces -= cur_n;
- }
- }
- else if(space && !(flags & JSON_COMPACT))
- {
- return dump(" ", 1, data);
- }
- return 0;
-}
-
-static int dump_string(const char *str, size_t len, json_dump_callback_t dump, void *data, size_t flags)
-{
- const char *pos, *end, *lim;
- int32_t codepoint;
-
- if(dump("\"", 1, data))
- return -1;
-
- end = pos = str;
- lim = str + len;
- while(1)
- {
- const char *text;
- char seq[13];
- int length;
-
- while(end < lim)
- {
- end = utf8_iterate(pos, lim - pos, &codepoint);
- if(!end)
- return -1;
-
- /* mandatory escape or control char */
- if(codepoint == '\\' || codepoint == '"' || codepoint < 0x20)
- break;
-
- /* slash */
- if((flags & JSON_ESCAPE_SLASH) && codepoint == '/')
- break;
-
- /* non-ASCII */
- if((flags & JSON_ENSURE_ASCII) && codepoint > 0x7F)
- break;
-
- pos = end;
- }
-
- if(pos != str) {
- if(dump(str, pos - str, data))
- return -1;
- }
-
- if(end == pos)
- break;
-
- /* handle \, /, ", and control codes */
- length = 2;
- switch(codepoint)
- {
- case '\\': text = "\\\\"; break;
- case '\"': text = "\\\""; break;
- case '\b': text = "\\b"; break;
- case '\f': text = "\\f"; break;
- case '\n': text = "\\n"; break;
- case '\r': text = "\\r"; break;
- case '\t': text = "\\t"; break;
- case '/': text = "\\/"; break;
- default:
- {
- /* codepoint is in BMP */
- if(codepoint < 0x10000)
- {
- snprintf(seq, sizeof(seq), "\\u%04X", (unsigned int)codepoint);
- length = 6;
- }
-
- /* not in BMP -> construct a UTF-16 surrogate pair */
- else
- {
- int32_t first, last;
-
- codepoint -= 0x10000;
- first = 0xD800 | ((codepoint & 0xffc00) >> 10);
- last = 0xDC00 | (codepoint & 0x003ff);
-
- snprintf(seq, sizeof(seq), "\\u%04X\\u%04X", (unsigned int)first, (unsigned int)last);
- length = 12;
- }
-
- text = seq;
- break;
- }
- }
-
- if(dump(text, length, data))
- return -1;
-
- str = pos = end;
- }
-
- return dump("\"", 1, data);
-}
-
-static int object_key_compare_keys(const void *key1, const void *key2)
-{
- return strcmp(((const struct object_key *)key1)->key,
- ((const struct object_key *)key2)->key);
-}
-
-static int object_key_compare_serials(const void *key1, const void *key2)
-{
- size_t a = ((const struct object_key *)key1)->serial;
- size_t b = ((const struct object_key *)key2)->serial;
-
- return a < b ? -1 : a == b ? 0 : 1;
-}
-
-static int do_dump(const json_t *json, size_t flags, int depth,
- json_dump_callback_t dump, void *data)
-{
- if(!json)
- return -1;
-
- switch(json_typeof(json)) {
- case JSON_NULL:
- return dump("null", 4, data);
-
- case JSON_TRUE:
- return dump("true", 4, data);
-
- case JSON_FALSE:
- return dump("false", 5, data);
-
- case JSON_INTEGER:
- {
- char buffer[MAX_INTEGER_STR_LENGTH];
- int size;
-
- size = snprintf(buffer, MAX_INTEGER_STR_LENGTH,
- "%" JSON_INTEGER_FORMAT,
- json_integer_value(json));
- if(size < 0 || size >= MAX_INTEGER_STR_LENGTH)
- return -1;
-
- return dump(buffer, size, data);
- }
-
- case JSON_REAL:
- {
- char buffer[MAX_REAL_STR_LENGTH];
- int size;
- double value = json_real_value(json);
-
- size = jsonp_dtostr(buffer, MAX_REAL_STR_LENGTH, value,
- FLAGS_TO_PRECISION(flags));
- if(size < 0)
- return -1;
-
- return dump(buffer, size, data);
- }
-
- case JSON_STRING:
- return dump_string(json_string_value(json), json_string_length(json), dump, data, flags);
-
- case JSON_ARRAY:
- {
- size_t n;
- size_t i;
-
- json_array_t *array;
-
- /* detect circular references */
- array = json_to_array(json);
- if(array->visited)
- goto array_error;
- array->visited = 1;
-
- n = json_array_size(json);
-
- if(dump("[", 1, data))
- goto array_error;
- if(n == 0) {
- array->visited = 0;
- return dump("]", 1, data);
- }
- if(dump_indent(flags, depth + 1, 0, dump, data))
- goto array_error;
-
- for(i = 0; i < n; ++i) {
- if(do_dump(json_array_get(json, i), flags, depth + 1,
- dump, data))
- goto array_error;
-
- if(i < n - 1)
- {
- if(dump(",", 1, data) ||
- dump_indent(flags, depth + 1, 1, dump, data))
- goto array_error;
- }
- else
- {
- if(dump_indent(flags, depth, 0, dump, data))
- goto array_error;
- }
- }
-
- array->visited = 0;
- return dump("]", 1, data);
-
- array_error:
- array->visited = 0;
- return -1;
- }
-
- case JSON_OBJECT:
- {
- json_object_t *object;
- void *iter;
- const char *separator;
- int separator_length;
-
- if(flags & JSON_COMPACT) {
- separator = ":";
- separator_length = 1;
- }
- else {
- separator = ": ";
- separator_length = 2;
- }
-
- /* detect circular references */
- object = json_to_object(json);
- if(object->visited)
- goto object_error;
- object->visited = 1;
-
- iter = json_object_iter((json_t *)json);
-
- if(dump("{", 1, data))
- goto object_error;
- if(!iter) {
- object->visited = 0;
- return dump("}", 1, data);
- }
- if(dump_indent(flags, depth + 1, 0, dump, data))
- goto object_error;
-
- if(flags & JSON_SORT_KEYS || flags & JSON_PRESERVE_ORDER)
- {
- struct object_key *keys;
- size_t size, i;
- int (*cmp_func)(const void *, const void *);
-
- size = json_object_size(json);
- keys = jsonp_malloc(size * sizeof(struct object_key));
- if(!keys)
- goto object_error;
-
- i = 0;
- while(iter)
- {
- keys[i].serial = hashtable_iter_serial(iter);
- keys[i].key = json_object_iter_key(iter);
- iter = json_object_iter_next((json_t *)json, iter);
- i++;
- }
- assert(i == size);
-
- if(flags & JSON_SORT_KEYS)
- cmp_func = object_key_compare_keys;
- else
- cmp_func = object_key_compare_serials;
-
- qsort(keys, size, sizeof(struct object_key), cmp_func);
-
- for(i = 0; i < size; i++)
- {
- const char *key;
- json_t *value;
-
- key = keys[i].key;
- value = json_object_get(json, key);
- assert(value);
-
- dump_string(key, strlen(key), dump, data, flags);
- if(dump(separator, separator_length, data) ||
- do_dump(value, flags, depth + 1, dump, data))
- {
- jsonp_free(keys);
- goto object_error;
- }
-
- if(i < size - 1)
- {
- if(dump(",", 1, data) ||
- dump_indent(flags, depth + 1, 1, dump, data))
- {
- jsonp_free(keys);
- goto object_error;
- }
- }
- else
- {
- if(dump_indent(flags, depth, 0, dump, data))
- {
- jsonp_free(keys);
- goto object_error;
- }
- }
- }
-
- jsonp_free(keys);
- }
- else
- {
- /* Don't sort keys */
-
- while(iter)
- {
- void *next = json_object_iter_next((json_t *)json, iter);
- const char *key = json_object_iter_key(iter);
-
- dump_string(key, strlen(key), dump, data, flags);
- if(dump(separator, separator_length, data) ||
- do_dump(json_object_iter_value(iter), flags, depth + 1,
- dump, data))
- goto object_error;
-
- if(next)
- {
- if(dump(",", 1, data) ||
- dump_indent(flags, depth + 1, 1, dump, data))
- goto object_error;
- }
- else
- {
- if(dump_indent(flags, depth, 0, dump, data))
- goto object_error;
- }
-
- iter = next;
- }
- }
-
- object->visited = 0;
- return dump("}", 1, data);
-
- object_error:
- object->visited = 0;
- return -1;
- }
-
- default:
- /* not reached */
- return -1;
- }
-}
-
-char *json_dumps(const json_t *json, size_t flags)
-{
- strbuffer_t strbuff;
- char *result;
-
- if(strbuffer_init(&strbuff))
- return NULL;
-
- if(json_dump_callback(json, dump_to_strbuffer, (void *)&strbuff, flags))
- result = NULL;
- else
- result = jsonp_strdup(strbuffer_value(&strbuff));
-
- strbuffer_close(&strbuff);
- return result;
-}
-
-int json_dumpf(const json_t *json, FILE *output, size_t flags)
-{
- return json_dump_callback(json, dump_to_file, (void *)output, flags);
-}
-
-int json_dump_file(const json_t *json, const char *path, size_t flags)
-{
- int result;
-
- FILE *output = fopen(path, "w");
- if(!output)
- return -1;
-
- result = json_dumpf(json, output, flags);
-
- fclose(output);
- return result;
-}
-
-int json_dump_callback(const json_t *json, json_dump_callback_t callback, void *data, size_t flags)
-{
- if(!(flags & JSON_ENCODE_ANY)) {
- if(!json_is_array(json) && !json_is_object(json))
- return -1;
- }
-
- return do_dump(json, flags, 0, callback, data);
-}
diff --git a/external/Jansson/error.c b/external/Jansson/error.c
deleted file mode 100644
index 58c83790..00000000
--- a/external/Jansson/error.c
+++ /dev/null
@@ -1,63 +0,0 @@
-#include
-#include "jansson_private.h"
-
-void jsonp_error_init(json_error_t *error, const char *source)
-{
- if(error)
- {
- error->text[0] = '\0';
- error->line = -1;
- error->column = -1;
- error->position = 0;
- if(source)
- jsonp_error_set_source(error, source);
- else
- error->source[0] = '\0';
- }
-}
-
-void jsonp_error_set_source(json_error_t *error, const char *source)
-{
- size_t length;
-
- if(!error || !source)
- return;
-
- length = strlen(source);
- if(length < JSON_ERROR_SOURCE_LENGTH)
- strncpy(error->source, source, length + 1);
- else {
- size_t extra = length - JSON_ERROR_SOURCE_LENGTH + 4;
- strncpy(error->source, "...", 3);
- strncpy(error->source + 3, source + extra, length - extra + 1);
- }
-}
-
-void jsonp_error_set(json_error_t *error, int line, int column,
- size_t position, const char *msg, ...)
-{
- va_list ap;
-
- va_start(ap, msg);
- jsonp_error_vset(error, line, column, position, msg, ap);
- va_end(ap);
-}
-
-void jsonp_error_vset(json_error_t *error, int line, int column,
- size_t position, const char *msg, va_list ap)
-{
- if(!error)
- return;
-
- if(error->text[0] != '\0') {
- /* error already set */
- return;
- }
-
- error->line = line;
- error->column = column;
- error->position = (int)position;
-
- vsnprintf(error->text, JSON_ERROR_TEXT_LENGTH, msg, ap);
- error->text[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
-}
diff --git a/external/Jansson/hashtable.c b/external/Jansson/hashtable.c
deleted file mode 100644
index a453b00f..00000000
--- a/external/Jansson/hashtable.c
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
- * Copyright (c) 2009-2014 Petri Lehtinen
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See LICENSE for details.
- */
-
-#if HAVE_CONFIG_H
-#include
-#endif
-
-#include
-#include
-
-#if HAVE_STDINT_H
-#include
-#endif
-
-#include /* for JSON_INLINE */
-#include "jansson_private.h" /* for container_of() */
-#include "hashtable.h"
-
-#ifndef INITIAL_HASHTABLE_ORDER
-#define INITIAL_HASHTABLE_ORDER 3
-#endif
-
-typedef struct hashtable_list list_t;
-typedef struct hashtable_pair pair_t;
-typedef struct hashtable_bucket bucket_t;
-
-extern volatile uint32_t hashtable_seed;
-
-/* Implementation of the hash function */
-#include "lookup3.h"
-
-#define list_to_pair(list_) container_of(list_, pair_t, list)
-#define hash_str(key) ((size_t)hashlittle((key), strlen(key), hashtable_seed))
-
-static JSON_INLINE void list_init(list_t *list)
-{
- list->next = list;
- list->prev = list;
-}
-
-static JSON_INLINE void list_insert(list_t *list, list_t *node)
-{
- node->next = list;
- node->prev = list->prev;
- list->prev->next = node;
- list->prev = node;
-}
-
-static JSON_INLINE void list_remove(list_t *list)
-{
- list->prev->next = list->next;
- list->next->prev = list->prev;
-}
-
-static JSON_INLINE int bucket_is_empty(hashtable_t *hashtable, bucket_t *bucket)
-{
- return bucket->first == &hashtable->list && bucket->first == bucket->last;
-}
-
-static void insert_to_bucket(hashtable_t *hashtable, bucket_t *bucket,
- list_t *list)
-{
- if(bucket_is_empty(hashtable, bucket))
- {
- list_insert(&hashtable->list, list);
- bucket->first = bucket->last = list;
- }
- else
- {
- list_insert(bucket->first, list);
- bucket->first = list;
- }
-}
-
-static pair_t *hashtable_find_pair(hashtable_t *hashtable, bucket_t *bucket,
- const char *key, size_t hash)
-{
- list_t *list;
- pair_t *pair;
-
- if(bucket_is_empty(hashtable, bucket))
- return NULL;
-
- list = bucket->first;
- while(1)
- {
- pair = list_to_pair(list);
- if(pair->hash == hash && strcmp(pair->key, key) == 0)
- return pair;
-
- if(list == bucket->last)
- break;
-
- list = list->next;
- }
-
- return NULL;
-}
-
-/* returns 0 on success, -1 if key was not found */
-static int hashtable_do_del(hashtable_t *hashtable,
- const char *key, size_t hash)
-{
- pair_t *pair;
- bucket_t *bucket;
- size_t index;
-
- index = hash & hashmask(hashtable->order);
- bucket = &hashtable->buckets[index];
-
- pair = hashtable_find_pair(hashtable, bucket, key, hash);
- if(!pair)
- return -1;
-
- if(&pair->list == bucket->first && &pair->list == bucket->last)
- bucket->first = bucket->last = &hashtable->list;
-
- else if(&pair->list == bucket->first)
- bucket->first = pair->list.next;
-
- else if(&pair->list == bucket->last)
- bucket->last = pair->list.prev;
-
- list_remove(&pair->list);
- json_decref(pair->value);
-
- jsonp_free(pair);
- hashtable->size--;
-
- return 0;
-}
-
-static void hashtable_do_clear(hashtable_t *hashtable)
-{
- list_t *list, *next;
- pair_t *pair;
-
- for(list = hashtable->list.next; list != &hashtable->list; list = next)
- {
- next = list->next;
- pair = list_to_pair(list);
- json_decref(pair->value);
- jsonp_free(pair);
- }
-}
-
-static int hashtable_do_rehash(hashtable_t *hashtable)
-{
- list_t *list, *next;
- pair_t *pair;
- size_t i, index, new_size;
-
- jsonp_free(hashtable->buckets);
-
- hashtable->order++;
- new_size = hashsize(hashtable->order);
-
- hashtable->buckets = jsonp_malloc(new_size * sizeof(bucket_t));
- if(!hashtable->buckets)
- return -1;
-
- for(i = 0; i < hashsize(hashtable->order); i++)
- {
- hashtable->buckets[i].first = hashtable->buckets[i].last =
- &hashtable->list;
- }
-
- list = hashtable->list.next;
- list_init(&hashtable->list);
-
- for(; list != &hashtable->list; list = next) {
- next = list->next;
- pair = list_to_pair(list);
- index = pair->hash % new_size;
- insert_to_bucket(hashtable, &hashtable->buckets[index], &pair->list);
- }
-
- return 0;
-}
-
-
-int hashtable_init(hashtable_t *hashtable)
-{
- size_t i;
-
- hashtable->size = 0;
- hashtable->order = INITIAL_HASHTABLE_ORDER;
- hashtable->buckets = jsonp_malloc(hashsize(hashtable->order) * sizeof(bucket_t));
- if(!hashtable->buckets)
- return -1;
-
- list_init(&hashtable->list);
-
- for(i = 0; i < hashsize(hashtable->order); i++)
- {
- hashtable->buckets[i].first = hashtable->buckets[i].last =
- &hashtable->list;
- }
-
- return 0;
-}
-
-void hashtable_close(hashtable_t *hashtable)
-{
- hashtable_do_clear(hashtable);
- jsonp_free(hashtable->buckets);
-}
-
-int hashtable_set(hashtable_t *hashtable,
- const char *key, size_t serial,
- json_t *value)
-{
- pair_t *pair;
- bucket_t *bucket;
- size_t hash, index;
-
- /* rehash if the load ratio exceeds 1 */
- if(hashtable->size >= hashsize(hashtable->order))
- if(hashtable_do_rehash(hashtable))
- return -1;
-
- hash = hash_str(key);
- index = hash & hashmask(hashtable->order);
- bucket = &hashtable->buckets[index];
- pair = hashtable_find_pair(hashtable, bucket, key, hash);
-
- if(pair)
- {
- json_decref(pair->value);
- pair->value = value;
- }
- else
- {
- /* offsetof(...) returns the size of pair_t without the last,
- flexible member. This way, the correct amount is
- allocated. */
-
- size_t len = strlen(key);
- if(len >= (size_t)-1 - offsetof(pair_t, key)) {
- /* Avoid an overflow if the key is very long */
- return -1;
- }
-
- pair = jsonp_malloc(offsetof(pair_t, key) + len + 1);
- if(!pair)
- return -1;
-
- pair->hash = hash;
- pair->serial = serial;
- strncpy(pair->key, key, len + 1);
- pair->value = value;
- list_init(&pair->list);
-
- insert_to_bucket(hashtable, bucket, &pair->list);
-
- hashtable->size++;
- }
- return 0;
-}
-
-void *hashtable_get(hashtable_t *hashtable, const char *key)
-{
- pair_t *pair;
- size_t hash;
- bucket_t *bucket;
-
- hash = hash_str(key);
- bucket = &hashtable->buckets[hash & hashmask(hashtable->order)];
-
- pair = hashtable_find_pair(hashtable, bucket, key, hash);
- if(!pair)
- return NULL;
-
- return pair->value;
-}
-
-int hashtable_del(hashtable_t *hashtable, const char *key)
-{
- size_t hash = hash_str(key);
- return hashtable_do_del(hashtable, key, hash);
-}
-
-void hashtable_clear(hashtable_t *hashtable)
-{
- size_t i;
-
- hashtable_do_clear(hashtable);
-
- for(i = 0; i < hashsize(hashtable->order); i++)
- {
- hashtable->buckets[i].first = hashtable->buckets[i].last =
- &hashtable->list;
- }
-
- list_init(&hashtable->list);
- hashtable->size = 0;
-}
-
-void *hashtable_iter(hashtable_t *hashtable)
-{
- return hashtable_iter_next(hashtable, &hashtable->list);
-}
-
-void *hashtable_iter_at(hashtable_t *hashtable, const char *key)
-{
- pair_t *pair;
- size_t hash;
- bucket_t *bucket;
-
- hash = hash_str(key);
- bucket = &hashtable->buckets[hash & hashmask(hashtable->order)];
-
- pair = hashtable_find_pair(hashtable, bucket, key, hash);
- if(!pair)
- return NULL;
-
- return &pair->list;
-}
-
-void *hashtable_iter_next(hashtable_t *hashtable, void *iter)
-{
- list_t *list = (list_t *)iter;
- if(list->next == &hashtable->list)
- return NULL;
- return list->next;
-}
-
-void *hashtable_iter_key(void *iter)
-{
- pair_t *pair = list_to_pair((list_t *)iter);
- return pair->key;
-}
-
-size_t hashtable_iter_serial(void *iter)
-{
- pair_t *pair = list_to_pair((list_t *)iter);
- return pair->serial;
-}
-
-void *hashtable_iter_value(void *iter)
-{
- pair_t *pair = list_to_pair((list_t *)iter);
- return pair->value;
-}
-
-void hashtable_iter_set(void *iter, json_t *value)
-{
- pair_t *pair = list_to_pair((list_t *)iter);
-
- json_decref(pair->value);
- pair->value = value;
-}
diff --git a/external/Jansson/hashtable.h b/external/Jansson/hashtable.h
deleted file mode 100644
index fab6443a..00000000
--- a/external/Jansson/hashtable.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (c) 2009-2014 Petri Lehtinen
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See LICENSE for details.
- */
-
-#ifndef HASHTABLE_H
-#define HASHTABLE_H
-
-#include
-#include "jansson.h"
-
-struct hashtable_list {
- struct hashtable_list *prev;
- struct hashtable_list *next;
-};
-
-/* "pair" may be a bit confusing a name, but think of it as a
- key-value pair. In this case, it just encodes some extra data,
- too */
-struct hashtable_pair {
- struct hashtable_list list;
- size_t hash;
- json_t *value;
- size_t serial;
- char key[1];
-};
-
-struct hashtable_bucket {
- struct hashtable_list *first;
- struct hashtable_list *last;
-};
-
-typedef struct hashtable {
- size_t size;
- struct hashtable_bucket *buckets;
- size_t order; /* hashtable has pow(2, order) buckets */
- struct hashtable_list list;
-} hashtable_t;
-
-
-#define hashtable_key_to_iter(key_) \
- (&(container_of(key_, struct hashtable_pair, key)->list))
-
-
-/**
- * hashtable_init - Initialize a hashtable object
- *
- * @hashtable: The (statically allocated) hashtable object
- *
- * Initializes a statically allocated hashtable object. The object
- * should be cleared with hashtable_close when it's no longer used.
- *
- * Returns 0 on success, -1 on error (out of memory).
- */
-int hashtable_init(hashtable_t *hashtable);
-
-/**
- * hashtable_close - Release all resources used by a hashtable object
- *
- * @hashtable: The hashtable
- *
- * Destroys a statically allocated hashtable object.
- */
-void hashtable_close(hashtable_t *hashtable);
-
-/**
- * hashtable_set - Add/modify value in hashtable
- *
- * @hashtable: The hashtable object
- * @key: The key
- * @serial: For addition order of keys
- * @value: The value
- *
- * If a value with the given key already exists, its value is replaced
- * with the new value. Value is "stealed" in the sense that hashtable
- * doesn't increment its refcount but decreases the refcount when the
- * value is no longer needed.
- *
- * Returns 0 on success, -1 on failure (out of memory).
- */
-int hashtable_set(hashtable_t *hashtable,
- const char *key, size_t serial,
- json_t *value);
-
-/**
- * hashtable_get - Get a value associated with a key
- *
- * @hashtable: The hashtable object
- * @key: The key
- *
- * Returns value if it is found, or NULL otherwise.
- */
-void *hashtable_get(hashtable_t *hashtable, const char *key);
-
-/**
- * hashtable_del - Remove a value from the hashtable
- *
- * @hashtable: The hashtable object
- * @key: The key
- *
- * Returns 0 on success, or -1 if the key was not found.
- */
-int hashtable_del(hashtable_t *hashtable, const char *key);
-
-/**
- * hashtable_clear - Clear hashtable
- *
- * @hashtable: The hashtable object
- *
- * Removes all items from the hashtable.
- */
-void hashtable_clear(hashtable_t *hashtable);
-
-/**
- * hashtable_iter - Iterate over hashtable
- *
- * @hashtable: The hashtable object
- *
- * Returns an opaque iterator to the first element in the hashtable.
- * The iterator should be passed to hashtable_iter_* functions.
- * The hashtable items are not iterated over in any particular order.
- *
- * There's no need to free the iterator in any way. The iterator is
- * valid as long as the item that is referenced by the iterator is not
- * deleted. Other values may be added or deleted. In particular,
- * hashtable_iter_next() may be called on an iterator, and after that
- * the key/value pair pointed by the old iterator may be deleted.
- */
-void *hashtable_iter(hashtable_t *hashtable);
-
-/**
- * hashtable_iter_at - Return an iterator at a specific key
- *
- * @hashtable: The hashtable object
- * @key: The key that the iterator should point to
- *
- * Like hashtable_iter() but returns an iterator pointing to a
- * specific key.
- */
-void *hashtable_iter_at(hashtable_t *hashtable, const char *key);
-
-/**
- * hashtable_iter_next - Advance an iterator
- *
- * @hashtable: The hashtable object
- * @iter: The iterator
- *
- * Returns a new iterator pointing to the next element in the
- * hashtable or NULL if the whole hastable has been iterated over.
- */
-void *hashtable_iter_next(hashtable_t *hashtable, void *iter);
-
-/**
- * hashtable_iter_key - Retrieve the key pointed by an iterator
- *
- * @iter: The iterator
- */
-void *hashtable_iter_key(void *iter);
-
-/**
- * hashtable_iter_serial - Retrieve the serial number pointed to by an iterator
- *
- * @iter: The iterator
- */
-size_t hashtable_iter_serial(void *iter);
-
-/**
- * hashtable_iter_value - Retrieve the value pointed by an iterator
- *
- * @iter: The iterator
- */
-void *hashtable_iter_value(void *iter);
-
-/**
- * hashtable_iter_set - Set the value pointed by an iterator
- *
- * @iter: The iterator
- * @value: The value to set
- */
-void hashtable_iter_set(void *iter, json_t *value);
-
-#endif
diff --git a/external/Jansson/hashtable_seed.c b/external/Jansson/hashtable_seed.c
deleted file mode 100644
index 751e0e32..00000000
--- a/external/Jansson/hashtable_seed.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/* Generate sizeof(uint32_t) bytes of as random data as possible to seed
- the hash function.
-*/
-
-#ifdef HAVE_CONFIG_H
-#include
-#endif
-
-#include
-#include
-
-#ifdef HAVE_STDINT_H
-#include
-#endif
-
-#ifdef HAVE_FCNTL_H
-#include
-#endif
-
-#ifdef HAVE_SCHED_H
-#include
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include
-#endif
-
-#ifdef HAVE_SYS_STAT_H
-#include
-#endif
-
-#ifdef HAVE_SYS_TIME_H
-#include
-#endif
-
-#ifdef HAVE_SYS_TYPES_H
-#include
-#endif
-
-#if defined(_WIN32)
-/* For GetModuleHandle(), GetProcAddress() and GetCurrentProcessId() */
-#include
-#endif
-
-#include "jansson.h"
-
-
-static uint32_t buf_to_uint32(char *data) {
- size_t i;
- uint32_t result = 0;
-
- for (i = 0; i < sizeof(uint32_t); i++)
- result = (result << 8) | (unsigned char)data[i];
-
- return result;
-}
-
-
-
-/* /dev/urandom */
-#if !defined(_WIN32) && defined(USE_URANDOM)
-static int seed_from_urandom(uint32_t *seed) {
- /* Use unbuffered I/O if we have open(), close() and read(). Otherwise
- fall back to fopen() */
-
- char data[sizeof(uint32_t)];
- int ok;
-
-#if defined(HAVE_OPEN) && defined(HAVE_CLOSE) && defined(HAVE_READ)
- int urandom;
- urandom = open("/dev/urandom", O_RDONLY);
- if (urandom == -1)
- return 1;
-
- ok = read(urandom, data, sizeof(uint32_t)) == sizeof(uint32_t);
- close(urandom);
-#else
- FILE *urandom;
-
- urandom = fopen("/dev/urandom", "rb");
- if (!urandom)
- return 1;
-
- ok = fread(data, 1, sizeof(uint32_t), urandom) == sizeof(uint32_t);
- fclose(urandom);
-#endif
-
- if (!ok)
- return 1;
-
- *seed = buf_to_uint32(data);
- return 0;
-}
-#endif
-
-/* Windows Crypto API */
-#if defined(_WIN32) && defined(USE_WINDOWS_CRYPTOAPI)
-#include
-
-typedef BOOL (WINAPI *CRYPTACQUIRECONTEXTA)(HCRYPTPROV *phProv, LPCSTR pszContainer, LPCSTR pszProvider, DWORD dwProvType, DWORD dwFlags);
-typedef BOOL (WINAPI *CRYPTGENRANDOM)(HCRYPTPROV hProv, DWORD dwLen, BYTE *pbBuffer);
-typedef BOOL (WINAPI *CRYPTRELEASECONTEXT)(HCRYPTPROV hProv, DWORD dwFlags);
-
-static int seed_from_windows_cryptoapi(uint32_t *seed)
-{
- HINSTANCE hAdvAPI32 = NULL;
- CRYPTACQUIRECONTEXTA pCryptAcquireContext = NULL;
- CRYPTGENRANDOM pCryptGenRandom = NULL;
- CRYPTRELEASECONTEXT pCryptReleaseContext = NULL;
- HCRYPTPROV hCryptProv = 0;
- BYTE data[sizeof(uint32_t)];
- int ok;
-
- hAdvAPI32 = GetModuleHandle(TEXT("advapi32.dll"));
- if(hAdvAPI32 == NULL)
- return 1;
-
- pCryptAcquireContext = (CRYPTACQUIRECONTEXTA)GetProcAddress(hAdvAPI32, "CryptAcquireContextA");
- if (!pCryptAcquireContext)
- return 1;
-
- pCryptGenRandom = (CRYPTGENRANDOM)GetProcAddress(hAdvAPI32, "CryptGenRandom");
- if (!pCryptGenRandom)
- return 1;
-
- pCryptReleaseContext = (CRYPTRELEASECONTEXT)GetProcAddress(hAdvAPI32, "CryptReleaseContext");
- if (!pCryptReleaseContext)
- return 1;
-
- if (!pCryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
- return 1;
-
- ok = pCryptGenRandom(hCryptProv, sizeof(uint32_t), data);
- pCryptReleaseContext(hCryptProv, 0);
-
- if (!ok)
- return 1;
-
- *seed = buf_to_uint32((char *)data);
- return 0;
-}
-#endif
-
-/* gettimeofday() and getpid() */
-static int seed_from_timestamp_and_pid(uint32_t *seed) {
-#ifdef HAVE_GETTIMEOFDAY
- /* XOR of seconds and microseconds */
- struct timeval tv;
- gettimeofday(&tv, NULL);
- *seed = (uint32_t)tv.tv_sec ^ (uint32_t)tv.tv_usec;
-#else
- /* Seconds only */
- *seed = (uint32_t)time(NULL);
-#endif
-
- /* XOR with PID for more randomness */
-#if defined(_WIN32)
- *seed ^= (uint32_t)GetCurrentProcessId();
-#elif defined(HAVE_GETPID)
- *seed ^= (uint32_t)getpid();
-#endif
-
- return 0;
-}
-
-static uint32_t generate_seed() {
- uint32_t seed;
- int done = 0;
-
-#if !defined(_WIN32) && defined(USE_URANDOM)
- if (!done && seed_from_urandom(&seed) == 0)
- done = 1;
-#endif
-
-#if defined(_WIN32) && defined(USE_WINDOWS_CRYPTOAPI)
- if (!done && seed_from_windows_cryptoapi(&seed) == 0)
- done = 1;
-#endif
-
- if (!done) {
- /* Fall back to timestamp and PID if no better randomness is
- available */
- seed_from_timestamp_and_pid(&seed);
- }
-
- /* Make sure the seed is never zero */
- if (seed == 0)
- seed = 1;
-
- return seed;
-}
-
-
-volatile uint32_t hashtable_seed = 0;
-
-#if defined(HAVE_ATOMIC_BUILTINS) && (defined(HAVE_SCHED_YIELD) || !defined(_WIN32))
-static volatile char seed_initialized = 0;
-
-void json_object_seed(size_t seed) {
- uint32_t new_seed = (uint32_t)seed;
-
- if (hashtable_seed == 0) {
- if (__atomic_test_and_set(&seed_initialized, __ATOMIC_RELAXED) == 0) {
- /* Do the seeding ourselves */
- if (new_seed == 0)
- new_seed = generate_seed();
-
- __atomic_store_n(&hashtable_seed, new_seed, __ATOMIC_RELEASE);
- } else {
- /* Wait for another thread to do the seeding */
- do {
-#ifdef HAVE_SCHED_YIELD
- sched_yield();
-#endif
- } while(__atomic_load_n(&hashtable_seed, __ATOMIC_ACQUIRE) == 0);
- }
- }
-}
-#elif defined(HAVE_SYNC_BUILTINS) && (defined(HAVE_SCHED_YIELD) || !defined(_WIN32))
-void json_object_seed(size_t seed) {
- uint32_t new_seed = (uint32_t)seed;
-
- if (hashtable_seed == 0) {
- if (new_seed == 0) {
- /* Explicit synchronization fences are not supported by the
- __sync builtins, so every thread getting here has to
- generate the seed value.
- */
- new_seed = generate_seed();
- }
-
- do {
- if (__sync_bool_compare_and_swap(&hashtable_seed, 0, new_seed)) {
- /* We were the first to seed */
- break;
- } else {
- /* Wait for another thread to do the seeding */
-#ifdef HAVE_SCHED_YIELD
- sched_yield();
-#endif
- }
- } while(hashtable_seed == 0);
- }
-}
-#elif defined(_WIN32)
-static long seed_initialized = 0;
-void json_object_seed(size_t seed) {
- uint32_t new_seed = (uint32_t)seed;
-
- if (hashtable_seed == 0) {
- if (InterlockedIncrement(&seed_initialized) == 1) {
- /* Do the seeding ourselves */
- if (new_seed == 0)
- new_seed = generate_seed();
-
- hashtable_seed = new_seed;
- } else {
- /* Wait for another thread to do the seeding */
- do {
- SwitchToThread();
- } while (hashtable_seed == 0);
- }
- }
-}
-#else
-/* Fall back to a thread-unsafe version */
-void json_object_seed(size_t seed) {
- uint32_t new_seed = (uint32_t)seed;
-
- if (hashtable_seed == 0) {
- if (new_seed == 0)
- new_seed = generate_seed();
-
- hashtable_seed = new_seed;
- }
-}
-#endif
diff --git a/external/Jansson/jansson.def b/external/Jansson/jansson.def
deleted file mode 100644
index c43eb07e..00000000
--- a/external/Jansson/jansson.def
+++ /dev/null
@@ -1,70 +0,0 @@
-EXPORTS
- json_delete
- json_true
- json_false
- json_null
- json_string
- json_stringn
- json_string_nocheck
- json_stringn_nocheck
- json_string_value
- json_string_length
- json_string_set
- json_string_setn
- json_string_set_nocheck
- json_string_setn_nocheck
- json_integer
- json_integer_value
- json_integer_set
- json_real
- json_real_value
- json_real_set
- json_number_value
- json_array
- json_array_size
- json_array_get
- json_array_set_new
- json_array_append_new
- json_array_insert_new
- json_array_remove
- json_array_clear
- json_array_extend
- json_object
- json_object_size
- json_object_get
- json_object_set_new
- json_object_set_new_nocheck
- json_object_del
- json_object_clear
- json_object_update
- json_object_update_existing
- json_object_update_missing
- json_object_iter
- json_object_iter_at
- json_object_iter_next
- json_object_iter_key
- json_object_iter_value
- json_object_iter_set_new
- json_object_key_to_iter
- json_object_seed
- json_dumps
- json_dumpf
- json_dump_file
- json_dump_callback
- json_loads
- json_loadb
- json_loadf
- json_load_file
- json_load_callback
- json_equal
- json_copy
- json_deep_copy
- json_pack
- json_pack_ex
- json_vpack_ex
- json_unpack
- json_unpack_ex
- json_vunpack_ex
- json_set_alloc_funcs
- json_get_alloc_funcs
-
diff --git a/external/Jansson/jansson.h b/external/Jansson/jansson.h
deleted file mode 100644
index ee607946..00000000
--- a/external/Jansson/jansson.h
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * Copyright (c) 2009-2014 Petri Lehtinen
- *
- * Jansson is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See LICENSE for details.
- */
-
-#ifndef JANSSON_H
-#define JANSSON_H
-
-#include
-#include /* for size_t */
-#include
-
-#include "jansson_config.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* version */
-
-#define JANSSON_MAJOR_VERSION 2
-#define JANSSON_MINOR_VERSION 7
-#define JANSSON_MICRO_VERSION 0
-
-/* Micro version is omitted if it's 0 */
-#define JANSSON_VERSION "2.7"
-
-/* Version as a 3-byte hex number, e.g. 0x010201 == 1.2.1. Use this
- for numeric comparisons, e.g. #if JANSSON_VERSION_HEX >= ... */
-#define JANSSON_VERSION_HEX ((JANSSON_MAJOR_VERSION << 16) | \
- (JANSSON_MINOR_VERSION << 8) | \
- (JANSSON_MICRO_VERSION << 0))
-
-
-/* types */
-
-typedef enum {
- JSON_OBJECT,
- JSON_ARRAY,
- JSON_STRING,
- JSON_INTEGER,
- JSON_REAL,
- JSON_TRUE,
- JSON_FALSE,
- JSON_NULL
-} json_type;
-
-typedef struct json_t {
- json_type type;
- size_t refcount;
-} json_t;
-
-#ifndef JANSSON_USING_CMAKE /* disabled if using cmake */
-#if JSON_INTEGER_IS_LONG_LONG
-#ifdef _WIN32
-#define JSON_INTEGER_FORMAT "I64d"
-#else
-#define JSON_INTEGER_FORMAT "lld"
-#endif
-typedef long long json_int_t;
-#else
-#define JSON_INTEGER_FORMAT "ld"
-typedef long json_int_t;
-#endif /* JSON_INTEGER_IS_LONG_LONG */
-#endif
-
-#define json_typeof(json) ((json)->type)
-#define json_is_object(json) ((json) && json_typeof(json) == JSON_OBJECT)
-#define json_is_array(json) ((json) && json_typeof(json) == JSON_ARRAY)
-#define json_is_string(json) ((json) && json_typeof(json) == JSON_STRING)
-#define json_is_integer(json) ((json) && json_typeof(json) == JSON_INTEGER)
-#define json_is_real(json) ((json) && json_typeof(json) == JSON_REAL)
-#define json_is_number(json) (json_is_integer(json) || json_is_real(json))
-#define json_is_true(json) ((json) && json_typeof(json) == JSON_TRUE)
-#define json_is_false(json) ((json) && json_typeof(json) == JSON_FALSE)
-#define json_boolean_value json_is_true
-#define json_is_boolean(json) (json_is_true(json) || json_is_false(json))
-#define json_is_null(json) ((json) && json_typeof(json) == JSON_NULL)
-
-/* construction, destruction, reference counting */
-
-json_t *json_object(void);
-json_t *json_array(void);
-json_t *json_string(const char *value);
-json_t *json_stringn(const char *value, size_t len);
-json_t *json_string_nocheck(const char *value);
-json_t *json_stringn_nocheck(const char *value, size_t len);
-json_t *json_integer(json_int_t value);
-json_t *json_real(double value);
-json_t *json_true(void);
-json_t *json_false(void);
-#define json_boolean(val) ((val) ? json_true() : json_false())
-json_t *json_null(void);
-
-static JSON_INLINE
-json_t *json_incref(json_t *json)
-{
- if(json && json->refcount != (size_t)-1)
- ++json->refcount;
- return json;
-}
-
-/* do not call json_delete directly */
-void json_delete(json_t *json);
-
-static JSON_INLINE
-void json_decref(json_t *json)
-{
- if(json && json->refcount != (size_t)-1 && --json->refcount == 0)
- json_delete(json);
-}
-
-
-/* error reporting */
-
-#define JSON_ERROR_TEXT_LENGTH 160
-#define JSON_ERROR_SOURCE_LENGTH 80
-
-typedef struct {
- int line;
- int column;
- int position;
- char source[JSON_ERROR_SOURCE_LENGTH];
- char text[JSON_ERROR_TEXT_LENGTH];
-} json_error_t;
-
-
-/* getters, setters, manipulation */
-
-void json_object_seed(size_t seed);
-size_t json_object_size(const json_t *object);
-json_t *json_object_get(const json_t *object, const char *key);
-int json_object_set_new(json_t *object, const char *key, json_t *value);
-int json_object_set_new_nocheck(json_t *object, const char *key, json_t *value);
-int json_object_del(json_t *object, const char *key);
-int json_object_clear(json_t *object);
-int json_object_update(json_t *object, json_t *other);
-int json_object_update_existing(json_t *object, json_t *other);
-int json_object_update_missing(json_t *object, json_t *other);
-void *json_object_iter(json_t *object);
-void *json_object_iter_at(json_t *object, const char *key);
-void *json_object_key_to_iter(const char *key);
-void *json_object_iter_next(json_t *object, void *iter);
-const char *json_object_iter_key(void *iter);
-json_t *json_object_iter_value(void *iter);
-int json_object_iter_set_new(json_t *object, void *iter, json_t *value);
-
-#define json_object_foreach(object, key, value) \
- for(key = json_object_iter_key(json_object_iter(object)); \
- key && (value = json_object_iter_value(json_object_key_to_iter(key))); \
- key = json_object_iter_key(json_object_iter_next(object, json_object_key_to_iter(key))))
-
-#define json_object_foreach_safe(object, n, key, value) \
- for(key = json_object_iter_key(json_object_iter(object)), \
- n = json_object_iter_next(object, json_object_key_to_iter(key)); \
- key && (value = json_object_iter_value(json_object_key_to_iter(key))); \
- key = json_object_iter_key(n), \
- n = json_object_iter_next(object, json_object_key_to_iter(key)))
-
-#define json_array_foreach(array, index, value) \
- for(index = 0; \
- index < json_array_size(array) && (value = json_array_get(array, index)); \
- index++)
-
-static JSON_INLINE
-int json_object_set(json_t *object, const char *key, json_t *value)
-{
- return json_object_set_new(object, key, json_incref(value));
-}
-
-static JSON_INLINE
-int json_object_set_nocheck(json_t *object, const char *key, json_t *value)
-{
- return json_object_set_new_nocheck(object, key, json_incref(value));
-}
-
-static JSON_INLINE
-int json_object_iter_set(json_t *object, void *iter, json_t *value)
-{
- return json_object_iter_set_new(object, iter, json_incref(value));
-}
-
-size_t json_array_size(const json_t *array);
-json_t *json_array_get(const json_t *array, size_t index);
-int json_array_set_new(json_t *array, size_t index, json_t *value);
-int json_array_append_new(json_t *array, json_t *value);
-int json_array_insert_new(json_t *array, size_t index, json_t *value);
-int json_array_remove(json_t *array, size_t index);
-int json_array_clear(json_t *array);
-int json_array_extend(json_t *array, json_t *other);
-
-static JSON_INLINE
-int json_array_set(json_t *array, size_t ind, json_t *value)
-{
- return json_array_set_new(array, ind, json_incref(value));
-}
-
-static JSON_INLINE
-int json_array_append(json_t *array, json_t *value)
-{
- return json_array_append_new(array, json_incref(value));
-}
-
-static JSON_INLINE
-int json_array_insert(json_t *array, size_t ind, json_t *value)
-{
- return json_array_insert_new(array, ind, json_incref(value));
-}
-
-const char *json_string_value(const json_t *string);
-size_t json_string_length(const json_t *string);
-json_int_t json_integer_value(const json_t *integer);
-double json_real_value(const json_t *real);
-double json_number_value(const json_t *json);
-
-int json_string_set(json_t *string, const char *value);
-int json_string_setn(json_t *string, const char *value, size_t len);
-int json_string_set_nocheck(json_t *string, const char *value);
-int json_string_setn_nocheck(json_t *string, const char *value, size_t len);
-int json_integer_set(json_t *integer, json_int_t value);
-int json_real_set(json_t *real, double value);
-
-/* pack, unpack */
-
-json_t *json_pack(const char *fmt, ...);
-json_t *json_pack_ex(json_error_t *error, size_t flags, const char *fmt, ...);
-json_t *json_vpack_ex(json_error_t *error, size_t flags, const char *fmt, va_list ap);
-
-#define JSON_VALIDATE_ONLY 0x1
-#define JSON_STRICT 0x2
-
-int json_unpack(json_t *root, const char *fmt, ...);
-int json_unpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt, ...);
-int json_vunpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt, va_list ap);
-
-
-/* equality */
-
-int json_equal(json_t *value1, json_t *value2);
-
-
-/* copying */
-
-json_t *json_copy(json_t *value);
-json_t *json_deep_copy(const json_t *value);
-
-
-/* decoding */
-
-#define JSON_REJECT_DUPLICATES 0x1
-#define JSON_DISABLE_EOF_CHECK 0x2
-#define JSON_DECODE_ANY 0x4
-#define JSON_DECODE_INT_AS_REAL 0x8
-#define JSON_ALLOW_NUL 0x10
-
-typedef size_t (*json_load_callback_t)(void *buffer, size_t buflen, void *data);
-
-json_t *json_loads(const char *input, size_t flags, json_error_t *error);
-json_t *json_loadb(const char *buffer, size_t buflen, size_t flags, json_error_t *error);
-json_t *json_loadf(FILE *input, size_t flags, json_error_t *error);
-json_t *json_load_file(const char *path, size_t flags, json_error_t *error);
-json_t *json_load_callback(json_load_callback_t callback, void *data, size_t flags, json_error_t *error);
-
-
-/* encoding */
-
-#define JSON_MAX_INDENT 0x1F
-#define JSON_INDENT(n) ((n) & JSON_MAX_INDENT)
-#define JSON_COMPACT 0x20
-#define JSON_ENSURE_ASCII 0x40
-#define JSON_SORT_KEYS 0x80
-#define JSON_PRESERVE_ORDER 0x100
-#define JSON_ENCODE_ANY 0x200
-#define JSON_ESCAPE_SLASH 0x400
-#define JSON_REAL_PRECISION(n) (((n) & 0x1F) << 11)
-
-typedef int (*json_dump_callback_t)(const char *buffer, size_t size, void *data);
-
-char *json_dumps(const json_t *json, size_t flags);
-int json_dumpf(const json_t *json, FILE *output, size_t flags);
-int json_dump_file(const json_t *json, const char *path, size_t flags);
-int json_dump_callback(const json_t *json, json_dump_callback_t callback, void *data, size_t flags);
-
-/* custom memory allocation */
-
-typedef void *(*json_malloc_t)(size_t);
-typedef void (*json_free_t)(void *);
-
-void json_set_alloc_funcs(json_malloc_t malloc_fn, json_free_t free_fn);
-void json_get_alloc_funcs(json_malloc_t *malloc_fn, json_free_t *free_fn);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/external/Jansson/jansson_private.h b/external/Jansson/jansson_private.h
deleted file mode 100644
index ccb3a574..00000000
--- a/external/Jansson/jansson_private.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2009-2014 Petri Lehtinen
- *
- * Jansson is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See LICENSE for details.
- */
-
-#ifndef JANSSON_PRIVATE_H
-#define JANSSON_PRIVATE_H
-
-#include
-#include "jansson.h"
-#include "hashtable.h"
-#include "strbuffer.h"
-
-#define container_of(ptr_, type_, member_) \
- ((type_ *)((char *)ptr_ - offsetof(type_, member_)))
-
-/* On some platforms, max() may already be defined */
-#ifndef max
-#define max(a, b) ((a) > (b) ? (a) : (b))
-#endif
-
-/* va_copy is a C99 feature. In C89 implementations, it's sometimes
- available as __va_copy. If not, memcpy() should do the trick. */
-#ifndef va_copy
-#ifdef __va_copy
-#define va_copy __va_copy
-#else
-#define va_copy(a, b) memcpy(&(a), &(b), sizeof(va_list))
-#endif
-#endif
-
-typedef struct {
- json_t json;
- hashtable_t hashtable;
- size_t serial;
- int visited;
-} json_object_t;
-
-typedef struct {
- json_t json;
- size_t size;
- size_t entries;
- json_t **table;
- int visited;
-} json_array_t;
-
-typedef struct {
- json_t json;
- char *value;
- size_t length;
-} json_string_t;
-
-typedef struct {
- json_t json;
- double value;
-} json_real_t;
-
-typedef struct {
- json_t json;
- json_int_t value;
-} json_integer_t;
-
-#define json_to_object(json_) container_of(json_, json_object_t, json)
-#define json_to_array(json_) container_of(json_, json_array_t, json)
-#define json_to_string(json_) container_of(json_, json_string_t, json)
-#define json_to_real(json_) container_of(json_, json_real_t, json)
-#define json_to_integer(json_) container_of(json_, json_integer_t, json)
-
-/* Create a string by taking ownership of an existing buffer */
-json_t *jsonp_stringn_nocheck_own(const char *value, size_t len);
-
-/* Error message formatting */
-void jsonp_error_init(json_error_t *error, const char *source);
-void jsonp_error_set_source(json_error_t *error, const char *source);
-void jsonp_error_set(json_error_t *error, int line, int column,
- size_t position, const char *msg, ...);
-void jsonp_error_vset(json_error_t *error, int line, int column,
- size_t position, const char *msg, va_list ap);
-
-/* Locale independent string<->double conversions */
-int jsonp_strtod(strbuffer_t *strbuffer, double *out);
-int jsonp_dtostr(char *buffer, size_t size, double value, int prec);
-
-/* Wrappers for custom memory functions */
-void* jsonp_malloc(size_t size);
-void jsonp_free(void *ptr);
-char *jsonp_strndup(const char *str, size_t length);
-char *jsonp_strdup(const char *str);
-char *jsonp_strndup(const char *str, size_t len);
-
-
-/* Windows compatibility */
-#if defined(_WIN32) || defined(WIN32)
-# if defined(_MSC_VER) /* MS compiller */
-# if (_MSC_VER < 1900) && !defined(snprintf) /* snprintf not defined yet & not introduced */
-# define snprintf _snprintf
-# endif
-# if (_MSC_VER < 1500) && !defined(vsnprintf) /* vsnprintf not defined yet & not introduced */
-# define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
-# endif
-# else /* Other Windows compiller, old definition */
-# define snprintf _snprintf
-# define vsnprintf _vsnprintf
-# endif
-#endif
-
-#endif
diff --git a/external/Jansson/load.c b/external/Jansson/load.c
deleted file mode 100644
index 33a260a8..00000000
--- a/external/Jansson/load.c
+++ /dev/null
@@ -1,1110 +0,0 @@
-/*
- * Copyright (c) 2009-2014 Petri Lehtinen
- *
- * Jansson is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See LICENSE for details.
- */
-
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "jansson.h"
-#include "jansson_private.h"
-#include "strbuffer.h"
-#include "utf.h"
-
-#define STREAM_STATE_OK 0
-#define STREAM_STATE_EOF -1
-#define STREAM_STATE_ERROR -2
-
-#define TOKEN_INVALID -1
-#define TOKEN_EOF 0
-#define TOKEN_STRING 256
-#define TOKEN_INTEGER 257
-#define TOKEN_REAL 258
-#define TOKEN_TRUE 259
-#define TOKEN_FALSE 260
-#define TOKEN_NULL 261
-
-/* Locale independent versions of isxxx() functions */
-#define l_isupper(c) ('A' <= (c) && (c) <= 'Z')
-#define l_islower(c) ('a' <= (c) && (c) <= 'z')
-#define l_isalpha(c) (l_isupper(c) || l_islower(c))
-#define l_isdigit(c) ('0' <= (c) && (c) <= '9')
-#define l_isxdigit(c) \
- (l_isdigit(c) || ('A' <= (c) && (c) <= 'F') || ('a' <= (c) && (c) <= 'f'))
-
-/* Read one byte from stream, convert to unsigned char, then int, and
- return. return EOF on end of file. This corresponds to the
- behaviour of fgetc(). */
-typedef int (*get_func)(void *data);
-
-typedef struct {
- get_func get;
- void *data;
- char buffer[5];
- size_t buffer_pos;
- int state;
- int line;
- int column, last_column;
- size_t position;
-} stream_t;
-
-typedef struct {
- stream_t stream;
- strbuffer_t saved_text;
- size_t flags;
- size_t depth;
- int token;
- union {
- struct {
- char *val;
- size_t len;
- } string;
- json_int_t integer;
- double real;
- } value;
-} lex_t;
-
-#define stream_to_lex(stream) container_of(stream, lex_t, stream)
-
-
-/*** error reporting ***/
-
-static void error_set(json_error_t *error, const lex_t *lex,
- const char *msg, ...)
-{
- va_list ap;
- char msg_text[JSON_ERROR_TEXT_LENGTH];
- char msg_with_context[JSON_ERROR_TEXT_LENGTH];
-
- int line = -1, col = -1;
- size_t pos = 0;
- const char *result = msg_text;
-
- if(!error)
- return;
-
- va_start(ap, msg);
- vsnprintf(msg_text, JSON_ERROR_TEXT_LENGTH, msg, ap);
- msg_text[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
- va_end(ap);
-
- if(lex)
- {
- const char *saved_text = strbuffer_value(&lex->saved_text);
-
- line = lex->stream.line;
- col = lex->stream.column;
- pos = lex->stream.position;
-
- if(saved_text && saved_text[0])
- {
- if(lex->saved_text.length <= 20) {
- snprintf(msg_with_context, JSON_ERROR_TEXT_LENGTH,
- "%s near '%s'", msg_text, saved_text);
- msg_with_context[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
- result = msg_with_context;
- }
- }
- else
- {
- if(lex->stream.state == STREAM_STATE_ERROR) {
- /* No context for UTF-8 decoding errors */
- result = msg_text;
- }
- else {
- snprintf(msg_with_context, JSON_ERROR_TEXT_LENGTH,
- "%s near end of file", msg_text);
- msg_with_context[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
- result = msg_with_context;
- }
- }
- }
-
- jsonp_error_set(error, line, col, pos, "%s", result);
-}
-
-
-/*** lexical analyzer ***/
-
-static void
-stream_init(stream_t *stream, get_func get, void *data)
-{
- stream->get = get;
- stream->data = data;
- stream->buffer[0] = '\0';
- stream->buffer_pos = 0;
-
- stream->state = STREAM_STATE_OK;
- stream->line = 1;
- stream->column = 0;
- stream->position = 0;
-}
-
-static int stream_get(stream_t *stream, json_error_t *error)
-{
- int c;
-
- if(stream->state != STREAM_STATE_OK)
- return stream->state;
-
- if(!stream->buffer[stream->buffer_pos])
- {
- c = stream->get(stream->data);
- if(c == EOF) {
- stream->state = STREAM_STATE_EOF;
- return STREAM_STATE_EOF;
- }
-
- stream->buffer[0] = c;
- stream->buffer_pos = 0;
-
- if(0x80 <= c && c <= 0xFF)
- {
- /* multi-byte UTF-8 sequence */
- size_t i, count;
-
- count = utf8_check_first(c);
- if(!count)
- goto out;
-
- assert(count >= 2);
-
- for(i = 1; i < count; i++)
- stream->buffer[i] = stream->get(stream->data);
-
- if(!utf8_check_full(stream->buffer, count, NULL))
- goto out;
-
- stream->buffer[count] = '\0';
- }
- else
- stream->buffer[1] = '\0';
- }
-
- c = stream->buffer[stream->buffer_pos++];
-
- stream->position++;
- if(c == '\n') {
- stream->line++;
- stream->last_column = stream->column;
- stream->column = 0;
- }
- else if(utf8_check_first(c)) {
- /* track the Unicode character column, so increment only if
- this is the first character of a UTF-8 sequence */
- stream->column++;
- }
-
- return c;
-
-out:
- stream->state = STREAM_STATE_ERROR;
- error_set(error, stream_to_lex(stream), "unable to decode byte 0x%x", c);
- return STREAM_STATE_ERROR;
-}
-
-static void stream_unget(stream_t *stream, int c)
-{
- if(c == STREAM_STATE_EOF || c == STREAM_STATE_ERROR)
- return;
-
- stream->position--;
- if(c == '\n') {
- stream->line--;
- stream->column = stream->last_column;
- }
- else if(utf8_check_first(c))
- stream->column--;
-
- assert(stream->buffer_pos > 0);
- stream->buffer_pos--;
- assert(stream->buffer[stream->buffer_pos] == c);
-}
-
-
-static int lex_get(lex_t *lex, json_error_t *error)
-{
- return stream_get(&lex->stream, error);
-}
-
-static void lex_save(lex_t *lex, int c)
-{
- strbuffer_append_byte(&lex->saved_text, c);
-}
-
-static int lex_get_save(lex_t *lex, json_error_t *error)
-{
- int c = stream_get(&lex->stream, error);
- if(c != STREAM_STATE_EOF && c != STREAM_STATE_ERROR)
- lex_save(lex, c);
- return c;
-}
-
-static void lex_unget(lex_t *lex, int c)
-{
- stream_unget(&lex->stream, c);
-}
-
-static void lex_unget_unsave(lex_t *lex, int c)
-{
- if(c != STREAM_STATE_EOF && c != STREAM_STATE_ERROR) {
- /* Since we treat warnings as errors, when assertions are turned
- * off the "d" variable would be set but never used. Which is
- * treated as an error by GCC.
- */
- #ifndef NDEBUG
- char d;
- #endif
- stream_unget(&lex->stream, c);
- #ifndef NDEBUG
- d =
- #endif
- strbuffer_pop(&lex->saved_text);
- assert(c == d);
- }
-}
-
-static void lex_save_cached(lex_t *lex)
-{
- while(lex->stream.buffer[lex->stream.buffer_pos] != '\0')
- {
- lex_save(lex, lex->stream.buffer[lex->stream.buffer_pos]);
- lex->stream.buffer_pos++;
- lex->stream.position++;
- }
-}
-
-static void lex_free_string(lex_t *lex)
-{
- jsonp_free(lex->value.string.val);
- lex->value.string.val = NULL;
- lex->value.string.len = 0;
-}
-
-/* assumes that str points to 'u' plus at least 4 valid hex digits */
-static int32_t decode_unicode_escape(const char *str)
-{
- int i;
- int32_t value = 0;
-
- assert(str[0] == 'u');
-
- for(i = 1; i <= 4; i++) {
- char c = str[i];
- value <<= 4;
- if(l_isdigit(c))
- value += c - '0';
- else if(l_islower(c))
- value += c - 'a' + 10;
- else if(l_isupper(c))
- value += c - 'A' + 10;
- else
- return -1;
- }
-
- return value;
-}
-
-static void lex_scan_string(lex_t *lex, json_error_t *error)
-{
- int c;
- const char *p;
- char *t;
- int i;
-
- lex->value.string.val = NULL;
- lex->token = TOKEN_INVALID;
-
- c = lex_get_save(lex, error);
-
- while(c != '"') {
- if(c == STREAM_STATE_ERROR)
- goto out;
-
- else if(c == STREAM_STATE_EOF) {
- error_set(error, lex, "premature end of input");
- goto out;
- }
-
- else if(0 <= c && c <= 0x1F) {
- /* control character */
- lex_unget_unsave(lex, c);
- if(c == '\n')
- error_set(error, lex, "unexpected newline", c);
- else
- error_set(error, lex, "control character 0x%x", c);
- goto out;
- }
-
- else if(c == '\\') {
- c = lex_get_save(lex, error);
- if(c == 'u') {
- c = lex_get_save(lex, error);
- for(i = 0; i < 4; i++) {
- if(!l_isxdigit(c)) {
- error_set(error, lex, "invalid escape");
- goto out;
- }
- c = lex_get_save(lex, error);
- }
- }
- else if(c == '"' || c == '\\' || c == '/' || c == 'b' ||
- c == 'f' || c == 'n' || c == 'r' || c == 't')
- c = lex_get_save(lex, error);
- else {
- error_set(error, lex, "invalid escape");
- goto out;
- }
- }
- else
- c = lex_get_save(lex, error);
- }
-
- /* the actual value is at most of the same length as the source
- string, because:
- - shortcut escapes (e.g. "\t") (length 2) are converted to 1 byte
- - a single \uXXXX escape (length 6) is converted to at most 3 bytes
- - two \uXXXX escapes (length 12) forming an UTF-16 surrogate pair
- are converted to 4 bytes
- */
- t = jsonp_malloc(lex->saved_text.length + 1);
- if(!t) {
- /* this is not very nice, since TOKEN_INVALID is returned */
- goto out;
- }
- lex->value.string.val = t;
-
- /* + 1 to skip the " */
- p = strbuffer_value(&lex->saved_text) + 1;
-
- while(*p != '"') {
- if(*p == '\\') {
- p++;
- if(*p == 'u') {
- size_t length;
- int32_t value;
-
- value = decode_unicode_escape(p);
- if(value < 0) {
- error_set(error, lex, "invalid Unicode escape '%.6s'", p - 1);
- goto out;
- }
- p += 5;
-
- if(0xD800 <= value && value <= 0xDBFF) {
- /* surrogate pair */
- if(*p == '\\' && *(p + 1) == 'u') {
- int32_t value2 = decode_unicode_escape(++p);
- if(value2 < 0) {
- error_set(error, lex, "invalid Unicode escape '%.6s'", p - 1);
- goto out;
- }
- p += 5;
-
- if(0xDC00 <= value2 && value2 <= 0xDFFF) {
- /* valid second surrogate */
- value =
- ((value - 0xD800) << 10) +
- (value2 - 0xDC00) +
- 0x10000;
- }
- else {
- /* invalid second surrogate */
- error_set(error, lex,
- "invalid Unicode '\\u%04X\\u%04X'",
- value, value2);
- goto out;
- }
- }
- else {
- /* no second surrogate */
- error_set(error, lex, "invalid Unicode '\\u%04X'",
- value);
- goto out;
- }
- }
- else if(0xDC00 <= value && value <= 0xDFFF) {
- error_set(error, lex, "invalid Unicode '\\u%04X'", value);
- goto out;
- }
-
- if(utf8_encode(value, t, &length))
- assert(0);
- t += length;
- }
- else {
- switch(*p) {
- case '"': case '\\': case '/':
- *t = *p; break;
- case 'b': *t = '\b'; break;
- case 'f': *t = '\f'; break;
- case 'n': *t = '\n'; break;
- case 'r': *t = '\r'; break;
- case 't': *t = '\t'; break;
- default: assert(0);
- }
- t++;
- p++;
- }
- }
- else
- *(t++) = *(p++);
- }
- *t = '\0';
- lex->value.string.len = t - lex->value.string.val;
- lex->token = TOKEN_STRING;
- return;
-
-out:
- lex_free_string(lex);
-}
-
-#ifndef JANSSON_USING_CMAKE /* disabled if using cmake */
-#if JSON_INTEGER_IS_LONG_LONG
-#ifdef _MSC_VER /* Microsoft Visual Studio */
-#define json_strtoint _strtoi64
-#else
-#define json_strtoint strtoll
-#endif
-#else
-#define json_strtoint strtol
-#endif
-#endif
-
-static int lex_scan_number(lex_t *lex, int c, json_error_t *error)
-{
- const char *saved_text;
- char *end;
- double doubleval;
-
- lex->token = TOKEN_INVALID;
-
- if(c == '-')
- c = lex_get_save(lex, error);
-
- if(c == '0') {
- c = lex_get_save(lex, error);
- if(l_isdigit(c)) {
- lex_unget_unsave(lex, c);
- goto out;
- }
- }
- else if(l_isdigit(c)) {
- do
- c = lex_get_save(lex, error);
- while(l_isdigit(c));
- }
- else {
- lex_unget_unsave(lex, c);
- goto out;
- }
-
- if(!(lex->flags & JSON_DECODE_INT_AS_REAL) &&
- c != '.' && c != 'E' && c != 'e')
- {
- json_int_t intval;
-
- lex_unget_unsave(lex, c);
-
- saved_text = strbuffer_value(&lex->saved_text);
-
- errno = 0;
- intval = json_strtoint(saved_text, &end, 10);
- if(errno == ERANGE) {
- if(intval < 0)
- error_set(error, lex, "too big negative integer");
- else
- error_set(error, lex, "too big integer");
- goto out;
- }
-
- assert(end == saved_text + lex->saved_text.length);
-
- lex->token = TOKEN_INTEGER;
- lex->value.integer = intval;
- return 0;
- }
-
- if(c == '.') {
- c = lex_get(lex, error);
- if(!l_isdigit(c)) {
- lex_unget(lex, c);
- goto out;
- }
- lex_save(lex, c);
-
- do
- c = lex_get_save(lex, error);
- while(l_isdigit(c));
- }
-
- if(c == 'E' || c == 'e') {
- c = lex_get_save(lex, error);
- if(c == '+' || c == '-')
- c = lex_get_save(lex, error);
-
- if(!l_isdigit(c)) {
- lex_unget_unsave(lex, c);
- goto out;
- }
-
- do
- c = lex_get_save(lex, error);
- while(l_isdigit(c));
- }
-
- lex_unget_unsave(lex, c);
-
- if(jsonp_strtod(&lex->saved_text, &doubleval)) {
- error_set(error, lex, "real number overflow");
- goto out;
- }
-
- lex->token = TOKEN_REAL;
- lex->value.real = doubleval;
- return 0;
-
-out:
- return -1;
-}
-
-static int lex_scan(lex_t *lex, json_error_t *error)
-{
- int c;
-
- strbuffer_clear(&lex->saved_text);
-
- if(lex->token == TOKEN_STRING)
- lex_free_string(lex);
-
- do
- c = lex_get(lex, error);
- while(c == ' ' || c == '\t' || c == '\n' || c == '\r');
-
- if(c == STREAM_STATE_EOF) {
- lex->token = TOKEN_EOF;
- goto out;
- }
-
- if(c == STREAM_STATE_ERROR) {
- lex->token = TOKEN_INVALID;
- goto out;
- }
-
- lex_save(lex, c);
-
- if(c == '{' || c == '}' || c == '[' || c == ']' || c == ':' || c == ',')
- lex->token = c;
-
- else if(c == '"')
- lex_scan_string(lex, error);
-
- else if(l_isdigit(c) || c == '-') {
- if(lex_scan_number(lex, c, error))
- goto out;
- }
-
- else if(l_isalpha(c)) {
- /* eat up the whole identifier for clearer error messages */
- const char *saved_text;
-
- do
- c = lex_get_save(lex, error);
- while(l_isalpha(c));
- lex_unget_unsave(lex, c);
-
- saved_text = strbuffer_value(&lex->saved_text);
-
- if(strcmp(saved_text, "true") == 0)
- lex->token = TOKEN_TRUE;
- else if(strcmp(saved_text, "false") == 0)
- lex->token = TOKEN_FALSE;
- else if(strcmp(saved_text, "null") == 0)
- lex->token = TOKEN_NULL;
- else
- lex->token = TOKEN_INVALID;
- }
-
- else {
- /* save the rest of the input UTF-8 sequence to get an error
- message of valid UTF-8 */
- lex_save_cached(lex);
- lex->token = TOKEN_INVALID;
- }
-
-out:
- return lex->token;
-}
-
-static char *lex_steal_string(lex_t *lex, size_t *out_len)
-{
- char *result = NULL;
- if(lex->token == TOKEN_STRING) {
- result = lex->value.string.val;
- *out_len = lex->value.string.len;
- lex->value.string.val = NULL;
- lex->value.string.len = 0;
- }
- return result;
-}
-
-static int lex_init(lex_t *lex, get_func get, size_t flags, void *data)
-{
- stream_init(&lex->stream, get, data);
- if(strbuffer_init(&lex->saved_text))
- return -1;
-
- lex->flags = flags;
- lex->token = TOKEN_INVALID;
- return 0;
-}
-
-static void lex_close(lex_t *lex)
-{
- if(lex->token == TOKEN_STRING)
- lex_free_string(lex);
- strbuffer_close(&lex->saved_text);
-}
-
-
-/*** parser ***/
-
-static json_t *parse_value(lex_t *lex, size_t flags, json_error_t *error);
-
-static json_t *parse_object(lex_t *lex, size_t flags, json_error_t *error)
-{
- json_t *object = json_object();
- if(!object)
- return NULL;
-
- lex_scan(lex, error);
- if(lex->token == '}')
- return object;
-
- while(1) {
- char *key;
- size_t len;
- json_t *value;
-
- if(lex->token != TOKEN_STRING) {
- error_set(error, lex, "string or '}' expected");
- goto error;
- }
-
- key = lex_steal_string(lex, &len);
- if(!key)
- return NULL;
- if (memchr(key, '\0', len)) {
- jsonp_free(key);
- error_set(error, lex, "NUL byte in object key not supported");
- goto error;
- }
-
- if(flags & JSON_REJECT_DUPLICATES) {
- if(json_object_get(object, key)) {
- jsonp_free(key);
- error_set(error, lex, "duplicate object key");
- goto error;
- }
- }
-
- lex_scan(lex, error);
- if(lex->token != ':') {
- jsonp_free(key);
- error_set(error, lex, "':' expected");
- goto error;
- }
-
- lex_scan(lex, error);
- value = parse_value(lex, flags, error);
- if(!value) {
- jsonp_free(key);
- goto error;
- }
-
- if(json_object_set_nocheck(object, key, value)) {
- jsonp_free(key);
- json_decref(value);
- goto error;
- }
-
- json_decref(value);
- jsonp_free(key);
-
- lex_scan(lex, error);
- if(lex->token != ',')
- break;
-
- lex_scan(lex, error);
- }
-
- if(lex->token != '}') {
- error_set(error, lex, "'}' expected");
- goto error;
- }
-
- return object;
-
-error:
- json_decref(object);
- return NULL;
-}
-
-static json_t *parse_array(lex_t *lex, size_t flags, json_error_t *error)
-{
- json_t *array = json_array();
- if(!array)
- return NULL;
-
- lex_scan(lex, error);
- if(lex->token == ']')
- return array;
-
- while(lex->token) {
- json_t *elem = parse_value(lex, flags, error);
- if(!elem)
- goto error;
-
- if(json_array_append(array, elem)) {
- json_decref(elem);
- goto error;
- }
- json_decref(elem);
-
- lex_scan(lex, error);
- if(lex->token != ',')
- break;
-
- lex_scan(lex, error);
- }
-
- if(lex->token != ']') {
- error_set(error, lex, "']' expected");
- goto error;
- }
-
- return array;
-
-error:
- json_decref(array);
- return NULL;
-}
-
-static json_t *parse_value(lex_t *lex, size_t flags, json_error_t *error)
-{
- json_t *json;
-
- lex->depth++;
- if(lex->depth > JSON_PARSER_MAX_DEPTH) {
- error_set(error, lex, "maximum parsing depth reached");
- return NULL;
- }
-
- switch(lex->token) {
- case TOKEN_STRING: {
- const char *value = lex->value.string.val;
- size_t len = lex->value.string.len;
-
- if(!(flags & JSON_ALLOW_NUL)) {
- if(memchr(value, '\0', len)) {
- error_set(error, lex, "\\u0000 is not allowed without JSON_ALLOW_NUL");
- return NULL;
- }
- }
-
- json = jsonp_stringn_nocheck_own(value, len);
- if(json) {
- lex->value.string.val = NULL;
- lex->value.string.len = 0;
- }
- break;
- }
-
- case TOKEN_INTEGER: {
- json = json_integer(lex->value.integer);
- break;
- }
-
- case TOKEN_REAL: {
- json = json_real(lex->value.real);
- break;
- }
-
- case TOKEN_TRUE:
- json = json_true();
- break;
-
- case TOKEN_FALSE:
- json = json_false();
- break;
-
- case TOKEN_NULL:
- json = json_null();
- break;
-
- case '{':
- json = parse_object(lex, flags, error);
- break;
-
- case '[':
- json = parse_array(lex, flags, error);
- break;
-
- case TOKEN_INVALID:
- error_set(error, lex, "invalid token");
- return NULL;
-
- default:
- error_set(error, lex, "unexpected token");
- return NULL;
- }
-
- if(!json)
- return NULL;
-
- lex->depth--;
- return json;
-}
-
-static json_t *parse_json(lex_t *lex, size_t flags, json_error_t *error)
-{
- json_t *result;
-
- lex->depth = 0;
-
- lex_scan(lex, error);
- if(!(flags & JSON_DECODE_ANY)) {
- if(lex->token != '[' && lex->token != '{') {
- error_set(error, lex, "'[' or '{' expected");
- return NULL;
- }
- }
-
- result = parse_value(lex, flags, error);
- if(!result)
- return NULL;
-
- if(!(flags & JSON_DISABLE_EOF_CHECK)) {
- lex_scan(lex, error);
- if(lex->token != TOKEN_EOF) {
- error_set(error, lex, "end of file expected");
- json_decref(result);
- return NULL;
- }
- }
-
- if(error) {
- /* Save the position even though there was no error */
- error->position = (int)lex->stream.position;
- }
-
- return result;
-}
-
-typedef struct
-{
- const char *data;
- int pos;
-} string_data_t;
-
-static int string_get(void *data)
-{
- char c;
- string_data_t *stream = (string_data_t *)data;
- c = stream->data[stream->pos];
- if(c == '\0')
- return EOF;
- else
- {
- stream->pos++;
- return (unsigned char)c;
- }
-}
-
-json_t *json_loads(const char *string, size_t flags, json_error_t *error)
-{
- lex_t lex;
- json_t *result;
- string_data_t stream_data;
-
- jsonp_error_init(error, "");
-
- if (string == NULL) {
- error_set(error, NULL, "wrong arguments");
- return NULL;
- }
-
- stream_data.data = string;
- stream_data.pos = 0;
-
- if(lex_init(&lex, string_get, flags, (void *)&stream_data))
- return NULL;
-
- result = parse_json(&lex, flags, error);
-
- lex_close(&lex);
- return result;
-}
-
-typedef struct
-{
- const char *data;
- size_t len;
- size_t pos;
-} buffer_data_t;
-
-static int buffer_get(void *data)
-{
- char c;
- buffer_data_t *stream = data;
- if(stream->pos >= stream->len)
- return EOF;
-
- c = stream->data[stream->pos];
- stream->pos++;
- return (unsigned char)c;
-}
-
-json_t *json_loadb(const char *buffer, size_t buflen, size_t flags, json_error_t *error)
-{
- lex_t lex;
- json_t *result;
- buffer_data_t stream_data;
-
- jsonp_error_init(error, "");
-
- if (buffer == NULL) {
- error_set(error, NULL, "wrong arguments");
- return NULL;
- }
-
- stream_data.data = buffer;
- stream_data.pos = 0;
- stream_data.len = buflen;
-
- if(lex_init(&lex, buffer_get, flags, (void *)&stream_data))
- return NULL;
-
- result = parse_json(&lex, flags, error);
-
- lex_close(&lex);
- return result;
-}
-
-json_t *json_loadf(FILE *input, size_t flags, json_error_t *error)
-{
- lex_t lex;
- const char *source;
- json_t *result;
-
- if(input == stdin)
- source = "";
- else
- source = "";
-
- jsonp_error_init(error, source);
-
- if (input == NULL) {
- error_set(error, NULL, "wrong arguments");
- return NULL;
- }
-
- if(lex_init(&lex, (get_func)fgetc, flags, input))
- return NULL;
-
- result = parse_json(&lex, flags, error);
-
- lex_close(&lex);
- return result;
-}
-
-json_t *json_load_file(const char *path, size_t flags, json_error_t *error)
-{
- json_t *result;
- FILE *fp;
-
- jsonp_error_init(error, path);
-
- if (path == NULL) {
- error_set(error, NULL, "wrong arguments");
- return NULL;
- }
-
- fp = fopen(path, "rb");
- if(!fp)
- {
- error_set(error, NULL, "unable to open %s: %s",
- path, strerror(errno));
- return NULL;
- }
-
- result = json_loadf(fp, flags, error);
-
- fclose(fp);
- return result;
-}
-
-#define MAX_BUF_LEN 1024
-
-typedef struct
-{
- char data[MAX_BUF_LEN];
- size_t len;
- size_t pos;
- json_load_callback_t callback;
- void *arg;
-} callback_data_t;
-
-static int callback_get(void *data)
-{
- char c;
- callback_data_t *stream = data;
-
- if(stream->pos >= stream->len) {
- stream->pos = 0;
- stream->len = stream->callback(stream->data, MAX_BUF_LEN, stream->arg);
- if(stream->len == 0 || stream->len == (size_t)-1)
- return EOF;
- }
-
- c = stream->data[stream->pos];
- stream->pos++;
- return (unsigned char)c;
-}
-
-json_t *json_load_callback(json_load_callback_t callback, void *arg, size_t flags, json_error_t *error)
-{
- lex_t lex;
- json_t *result;
-
- callback_data_t stream_data;
-
- memset(&stream_data, 0, sizeof(stream_data));
- stream_data.callback = callback;
- stream_data.arg = arg;
-
- jsonp_error_init(error, "");
-
- if (callback == NULL) {
- error_set(error, NULL, "wrong arguments");
- return NULL;
- }
-
- if(lex_init(&lex, (get_func)callback_get, flags, &stream_data))
- return NULL;
-
- result = parse_json(&lex, flags, error);
-
- lex_close(&lex);
- return result;
-}
diff --git a/external/Jansson/lookup3.h b/external/Jansson/lookup3.h
deleted file mode 100644
index 522a41ae..00000000
--- a/external/Jansson/lookup3.h
+++ /dev/null
@@ -1,381 +0,0 @@
-/*
--------------------------------------------------------------------------------
-lookup3.c, by Bob Jenkins, May 2006, Public Domain.
-
-These are functions for producing 32-bit hashes for hash table lookup.
-hashword(), hashlittle(), hashlittle2(), hashbig(), mix(), and final()
-are externally useful functions. Routines to test the hash are included
-if SELF_TEST is defined. You can use this free for any purpose. It's in
-the public domain. It has no warranty.
-
-You probably want to use hashlittle(). hashlittle() and hashbig()
-hash byte arrays. hashlittle() is is faster than hashbig() on
-little-endian machines. Intel and AMD are little-endian machines.
-On second thought, you probably want hashlittle2(), which is identical to
-hashlittle() except it returns two 32-bit hashes for the price of one.
-You could implement hashbig2() if you wanted but I haven't bothered here.
-
-If you want to find a hash of, say, exactly 7 integers, do
- a = i1; b = i2; c = i3;
- mix(a,b,c);
- a += i4; b += i5; c += i6;
- mix(a,b,c);
- a += i7;
- final(a,b,c);
-then use c as the hash value. If you have a variable length array of
-4-byte integers to hash, use hashword(). If you have a byte array (like
-a character string), use hashlittle(). If you have several byte arrays, or
-a mix of things, see the comments above hashlittle().
-
-Why is this so big? I read 12 bytes at a time into 3 4-byte integers,
-then mix those integers. This is fast (you can do a lot more thorough
-mixing with 12*3 instructions on 3 integers than you can with 3 instructions
-on 1 byte), but shoehorning those bytes into integers efficiently is messy.
--------------------------------------------------------------------------------
-*/
-
-#include
-
-#ifdef HAVE_CONFIG_H
-#include
-#endif
-
-#ifdef HAVE_STDINT_H
-#include /* defines uint32_t etc */
-#endif
-
-#ifdef HAVE_SYS_PARAM_H
-#include /* attempt to define endianness */
-#endif
-
-#ifdef HAVE_ENDIAN_H
-# include /* attempt to define endianness */
-#endif
-
-/*
- * My best guess at if you are big-endian or little-endian. This may
- * need adjustment.
- */
-#if (defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && \
- __BYTE_ORDER == __LITTLE_ENDIAN) || \
- (defined(i386) || defined(__i386__) || defined(__i486__) || \
- defined(__i586__) || defined(__i686__) || defined(vax) || defined(MIPSEL))
-# define HASH_LITTLE_ENDIAN 1
-# define HASH_BIG_ENDIAN 0
-#elif (defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && \
- __BYTE_ORDER == __BIG_ENDIAN) || \
- (defined(sparc) || defined(POWERPC) || defined(mc68000) || defined(sel))
-# define HASH_LITTLE_ENDIAN 0
-# define HASH_BIG_ENDIAN 1
-#else
-# define HASH_LITTLE_ENDIAN 0
-# define HASH_BIG_ENDIAN 0
-#endif
-
-#define hashsize(n) ((uint32_t)1<<(n))
-#define hashmask(n) (hashsize(n)-1)
-#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
-
-/*
--------------------------------------------------------------------------------
-mix -- mix 3 32-bit values reversibly.
-
-This is reversible, so any information in (a,b,c) before mix() is
-still in (a,b,c) after mix().
-
-If four pairs of (a,b,c) inputs are run through mix(), or through
-mix() in reverse, there are at least 32 bits of the output that
-are sometimes the same for one pair and different for another pair.
-This was tested for:
-* pairs that differed by one bit, by two bits, in any combination
- of top bits of (a,b,c), or in any combination of bottom bits of
- (a,b,c).
-* "differ" is defined as +, -, ^, or ~^. For + and -, I transformed
- the output delta to a Gray code (a^(a>>1)) so a string of 1's (as
- is commonly produced by subtraction) look like a single 1-bit
- difference.
-* the base values were pseudorandom, all zero but one bit set, or
- all zero plus a counter that starts at zero.
-
-Some k values for my "a-=c; a^=rot(c,k); c+=b;" arrangement that
-satisfy this are
- 4 6 8 16 19 4
- 9 15 3 18 27 15
- 14 9 3 7 17 3
-Well, "9 15 3 18 27 15" didn't quite get 32 bits diffing
-for "differ" defined as + with a one-bit base and a two-bit delta. I
-used http://burtleburtle.net/bob/hash/avalanche.html to choose
-the operations, constants, and arrangements of the variables.
-
-This does not achieve avalanche. There are input bits of (a,b,c)
-that fail to affect some output bits of (a,b,c), especially of a. The
-most thoroughly mixed value is c, but it doesn't really even achieve
-avalanche in c.
-
-This allows some parallelism. Read-after-writes are good at doubling
-the number of bits affected, so the goal of mixing pulls in the opposite
-direction as the goal of parallelism. I did what I could. Rotates
-seem to cost as much as shifts on every machine I could lay my hands
-on, and rotates are much kinder to the top and bottom bits, so I used
-rotates.
--------------------------------------------------------------------------------
-*/
-#define mix(a,b,c) \
-{ \
- a -= c; a ^= rot(c, 4); c += b; \
- b -= a; b ^= rot(a, 6); a += c; \
- c -= b; c ^= rot(b, 8); b += a; \
- a -= c; a ^= rot(c,16); c += b; \
- b -= a; b ^= rot(a,19); a += c; \
- c -= b; c ^= rot(b, 4); b += a; \
-}
-
-/*
--------------------------------------------------------------------------------
-final -- final mixing of 3 32-bit values (a,b,c) into c
-
-Pairs of (a,b,c) values differing in only a few bits will usually
-produce values of c that look totally different. This was tested for
-* pairs that differed by one bit, by two bits, in any combination
- of top bits of (a,b,c), or in any combination of bottom bits of
- (a,b,c).
-* "differ" is defined as +, -, ^, or ~^. For + and -, I transformed
- the output delta to a Gray code (a^(a>>1)) so a string of 1's (as
- is commonly produced by subtraction) look like a single 1-bit
- difference.
-* the base values were pseudorandom, all zero but one bit set, or
- all zero plus a counter that starts at zero.
-
-These constants passed:
- 14 11 25 16 4 14 24
- 12 14 25 16 4 14 24
-and these came close:
- 4 8 15 26 3 22 24
- 10 8 15 26 3 22 24
- 11 8 15 26 3 22 24
--------------------------------------------------------------------------------
-*/
-#define final(a,b,c) \
-{ \
- c ^= b; c -= rot(b,14); \
- a ^= c; a -= rot(c,11); \
- b ^= a; b -= rot(a,25); \
- c ^= b; c -= rot(b,16); \
- a ^= c; a -= rot(c,4); \
- b ^= a; b -= rot(a,14); \
- c ^= b; c -= rot(b,24); \
-}
-
-/*
--------------------------------------------------------------------------------
-hashlittle() -- hash a variable-length key into a 32-bit value
- k : the key (the unaligned variable-length array of bytes)
- length : the length of the key, counting by bytes
- initval : can be any 4-byte value
-Returns a 32-bit value. Every bit of the key affects every bit of
-the return value. Two keys differing by one or two bits will have
-totally different hash values.
-
-The best hash table sizes are powers of 2. There is no need to do
-mod a prime (mod is sooo slow!). If you need less than 32 bits,
-use a bitmask. For example, if you need only 10 bits, do
- h = (h & hashmask(10));
-In which case, the hash table should have hashsize(10) elements.
-
-If you are hashing n strings (uint8_t **)k, do it like this:
- for (i=0, h=0; i 12)
- {
- a += k[0];
- b += k[1];
- c += k[2];
- mix(a,b,c);
- length -= 12;
- k += 3;
- }
-
- /*----------------------------- handle the last (probably partial) block */
- /*
- * "k[2]&0xffffff" actually reads beyond the end of the string, but
- * then masks off the part it's not allowed to read. Because the
- * string is aligned, the masked-off tail is in the same word as the
- * rest of the string. Every machine with memory protection I've seen
- * does it on word boundaries, so is OK with this. But VALGRIND will
- * still catch it and complain. The masking trick does make the hash
- * noticably faster for short strings (like English words).
- */
-#ifndef NO_MASKING_TRICK
-
- switch(length)
- {
- case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
- case 11: c+=k[2]&0xffffff; b+=k[1]; a+=k[0]; break;
- case 10: c+=k[2]&0xffff; b+=k[1]; a+=k[0]; break;
- case 9 : c+=k[2]&0xff; b+=k[1]; a+=k[0]; break;
- case 8 : b+=k[1]; a+=k[0]; break;
- case 7 : b+=k[1]&0xffffff; a+=k[0]; break;
- case 6 : b+=k[1]&0xffff; a+=k[0]; break;
- case 5 : b+=k[1]&0xff; a+=k[0]; break;
- case 4 : a+=k[0]; break;
- case 3 : a+=k[0]&0xffffff; break;
- case 2 : a+=k[0]&0xffff; break;
- case 1 : a+=k[0]&0xff; break;
- case 0 : return c; /* zero length strings require no mixing */
- }
-
-#else /* make valgrind happy */
-
- k8 = (const uint8_t *)k;
- switch(length)
- {
- case 12: c+=k[2]; b+=k[1]; a+=k[0]; break;
- case 11: c+=((uint32_t)k8[10])<<16; /* fall through */
- case 10: c+=((uint32_t)k8[9])<<8; /* fall through */
- case 9 : c+=k8[8]; /* fall through */
- case 8 : b+=k[1]; a+=k[0]; break;
- case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */
- case 6 : b+=((uint32_t)k8[5])<<8; /* fall through */
- case 5 : b+=k8[4]; /* fall through */
- case 4 : a+=k[0]; break;
- case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */
- case 2 : a+=((uint32_t)k8[1])<<8; /* fall through */
- case 1 : a+=k8[0]; break;
- case 0 : return c;
- }
-
-#endif /* !valgrind */
-
- } else if (HASH_LITTLE_ENDIAN && ((u.i & 0x1) == 0)) {
- const uint16_t *k = (const uint16_t *)key; /* read 16-bit chunks */
- const uint8_t *k8;
-
- /*--------------- all but last block: aligned reads and different mixing */
- while (length > 12)
- {
- a += k[0] + (((uint32_t)k[1])<<16);
- b += k[2] + (((uint32_t)k[3])<<16);
- c += k[4] + (((uint32_t)k[5])<<16);
- mix(a,b,c);
- length -= 12;
- k += 6;
- }
-
- /*----------------------------- handle the last (probably partial) block */
- k8 = (const uint8_t *)k;
- switch(length)
- {
- case 12: c+=k[4]+(((uint32_t)k[5])<<16);
- b+=k[2]+(((uint32_t)k[3])<<16);
- a+=k[0]+(((uint32_t)k[1])<<16);
- break;
- case 11: c+=((uint32_t)k8[10])<<16; /* fall through */
- case 10: c+=k[4];
- b+=k[2]+(((uint32_t)k[3])<<16);
- a+=k[0]+(((uint32_t)k[1])<<16);
- break;
- case 9 : c+=k8[8]; /* fall through */
- case 8 : b+=k[2]+(((uint32_t)k[3])<<16);
- a+=k[0]+(((uint32_t)k[1])<<16);
- break;
- case 7 : b+=((uint32_t)k8[6])<<16; /* fall through */
- case 6 : b+=k[2];
- a+=k[0]+(((uint32_t)k[1])<<16);
- break;
- case 5 : b+=k8[4]; /* fall through */
- case 4 : a+=k[0]+(((uint32_t)k[1])<<16);
- break;
- case 3 : a+=((uint32_t)k8[2])<<16; /* fall through */
- case 2 : a+=k[0];
- break;
- case 1 : a+=k8[0];
- break;
- case 0 : return c; /* zero length requires no mixing */
- }
-
- } else { /* need to read the key one byte at a time */
- const uint8_t *k = (const uint8_t *)key;
-
- /*--------------- all but the last block: affect some 32 bits of (a,b,c) */
- while (length > 12)
- {
- a += k[0];
- a += ((uint32_t)k[1])<<8;
- a += ((uint32_t)k[2])<<16;
- a += ((uint32_t)k[3])<<24;
- b += k[4];
- b += ((uint32_t)k[5])<<8;
- b += ((uint32_t)k[6])<<16;
- b += ((uint32_t)k[7])<<24;
- c += k[8];
- c += ((uint32_t)k[9])<<8;
- c += ((uint32_t)k[10])<<16;
- c += ((uint32_t)k[11])<<24;
- mix(a,b,c);
- length -= 12;
- k += 12;
- }
-
- /*-------------------------------- last block: affect all 32 bits of (c) */
- switch(length) /* all the case statements fall through */
- {
- case 12: c+=((uint32_t)k[11])<<24;
- case 11: c+=((uint32_t)k[10])<<16;
- case 10: c+=((uint32_t)k[9])<<8;
- case 9 : c+=k[8];
- case 8 : b+=((uint32_t)k[7])<<24;
- case 7 : b+=((uint32_t)k[6])<<16;
- case 6 : b+=((uint32_t)k[5])<<8;
- case 5 : b+=k[4];
- case 4 : a+=((uint32_t)k[3])<<24;
- case 3 : a+=((uint32_t)k[2])<<16;
- case 2 : a+=((uint32_t)k[1])<<8;
- case 1 : a+=k[0];
- break;
- case 0 : return c;
- }
- }
-
- final(a,b,c);
- return c;
-}
diff --git a/external/Jansson/memory.c b/external/Jansson/memory.c
deleted file mode 100644
index e2368cf2..00000000
--- a/external/Jansson/memory.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2009-2014 Petri Lehtinen
- * Copyright (c) 2011-2012 Basile Starynkevitch
- *
- * Jansson is free software; you can redistribute it and/or modify it
- * under the terms of the MIT license. See LICENSE for details.
- */
-
-#include
-#include
-
-#include "jansson.h"
-#include "jansson_private.h"
-
-/* C89 allows these to be macros */
-#undef malloc
-#undef free
-
-/* memory function pointers */
-static json_malloc_t do_malloc = malloc;
-static json_free_t do_free = free;
-
-void *jsonp_malloc(size_t size)
-{
- if(!size)
- return NULL;
-
- return (*do_malloc)(size);
-}
-
-void jsonp_free(void *ptr)
-{
- if(!ptr)
- return;
-
- (*do_free)(ptr);
-}
-
-char *jsonp_strdup(const char *str)
-{
- return jsonp_strndup(str, strlen(str));
-}
-
-char *jsonp_strndup(const char *str, size_t len)
-{
- char *new_str;
-
- new_str = jsonp_malloc(len + 1);
- if(!new_str)
- return NULL;
-
- memcpy(new_str, str, len);
- new_str[len] = '\0';
- return new_str;
-}
-
-void json_set_alloc_funcs(json_malloc_t malloc_fn, json_free_t free_fn)
-{
- do_malloc = malloc_fn;
- do_free = free_fn;
-}
-
-void json_get_alloc_funcs(json_malloc_t *malloc_fn, json_free_t *free_fn)
-{
- if (malloc_fn)
- *malloc_fn = do_malloc;
- if (free_fn)
- *free_fn = do_free;
-}
diff --git a/external/Jansson/pack_unpack.c b/external/Jansson/pack_unpack.c
deleted file mode 100644
index f6c700c6..00000000
--- a/external/Jansson/pack_unpack.c
+++ /dev/null
@@ -1,871 +0,0 @@
-/*
- * Copyright (c) 2009-2014 Petri Lehtinen
- * Copyright (c) 2011-2012 Graeme Smecher
- *
- * Jansson is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See LICENSE for details.
- */
-
-#include
-#include "jansson.h"
-#include "jansson_private.h"
-#include "utf.h"
-
-typedef struct {
- int line;
- int column;
- size_t pos;
- char token;
-} token_t;
-
-typedef struct {
- const char *start;
- const char *fmt;
- token_t prev_token;
- token_t token;
- token_t next_token;
- json_error_t *error;
- size_t flags;
- int line;
- int column;
- size_t pos;
-} scanner_t;
-
-#define token(scanner) ((scanner)->token.token)
-
-static const char * const type_names[] = {
- "object",
- "array",
- "string",
- "integer",
- "real",
- "true",
- "false",
- "null"
-};
-
-#define type_name(x) type_names[json_typeof(x)]
-
-static const char unpack_value_starters[] = "{[siIbfFOon";
-
-static void scanner_init(scanner_t *s, json_error_t *error,
- size_t flags, const char *fmt)
-{
- s->error = error;
- s->flags = flags;
- s->fmt = s->start = fmt;
- memset(&s->prev_token, 0, sizeof(token_t));
- memset(&s->token, 0, sizeof(token_t));
- memset(&s->next_token, 0, sizeof(token_t));
- s->line = 1;
- s->column = 0;
- s->pos = 0;
-}
-
-static void next_token(scanner_t *s)
-{
- const char *t;
- s->prev_token = s->token;
-
- if(s->next_token.line) {
- s->token = s->next_token;
- s->next_token.line = 0;
- return;
- }
-
- t = s->fmt;
- s->column++;
- s->pos++;
-
- /* skip space and ignored chars */
- while(*t == ' ' || *t == '\t' || *t == '\n' || *t == ',' || *t == ':') {
- if(*t == '\n') {
- s->line++;
- s->column = 1;
- }
- else
- s->column++;
-
- s->pos++;
- t++;
- }
-
- s->token.token = *t;
- s->token.line = s->line;
- s->token.column = s->column;
- s->token.pos = s->pos;
-
- t++;
- s->fmt = t;
-}
-
-static void prev_token(scanner_t *s)
-{
- s->next_token = s->token;
- s->token = s->prev_token;
-}
-
-static void set_error(scanner_t *s, const char *source, const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
-
- jsonp_error_vset(s->error, s->token.line, s->token.column, s->token.pos,
- fmt, ap);
-
- jsonp_error_set_source(s->error, source);
-
- va_end(ap);
-}
-
-static json_t *pack(scanner_t *s, va_list *ap);
-
-
-/* ours will be set to 1 if jsonp_free() must be called for the result
- afterwards */
-static char *read_string(scanner_t *s, va_list *ap,
- const char *purpose, size_t *out_len, int *ours)
-{
- char t;
- strbuffer_t strbuff;
- const char *str;
- size_t length;
-
- next_token(s);
- t = token(s);
- prev_token(s);
-
- if(t != '#' && t != '%' && t != '+') {
- /* Optimize the simple case */
- str = va_arg(*ap, const char *);
-
- if(!str) {
- set_error(s, "", "NULL string argument");
- return NULL;
- }
-
- length = strlen(str);
-
- if(!utf8_check_string(str, length)) {
- set_error(s, "", "Invalid UTF-8 %s", purpose);
- return NULL;
- }
-
- *out_len = length;
- *ours = 0;
- return (char *)str;
- }
-
- strbuffer_init(&strbuff);
-
- while(1) {
- str = va_arg(*ap, const char *);
- if(!str) {
- set_error(s, "", "NULL string argument");
- strbuffer_close(&strbuff);
- return NULL;
- }
-
- next_token(s);
-
- if(token(s) == '#') {
- length = va_arg(*ap, int);
- }
- else if(token(s) == '%') {
- length = va_arg(*ap, size_t);
- }
- else {
- prev_token(s);
- length = strlen(str);
- }
-
- if(strbuffer_append_bytes(&strbuff, str, length) == -1) {
- set_error(s, "", "Out of memory");
- strbuffer_close(&strbuff);
- return NULL;
- }
-
- next_token(s);
- if(token(s) != '+') {
- prev_token(s);
- break;
- }
- }
-
- if(!utf8_check_string(strbuff.value, strbuff.length)) {
- set_error(s, "", "Invalid UTF-8 %s", purpose);
- strbuffer_close(&strbuff);
- return NULL;
- }
-
- *out_len = strbuff.length;
- *ours = 1;
- return strbuffer_steal_value(&strbuff);
-}
-
-static json_t *pack_object(scanner_t *s, va_list *ap)
-{
- json_t *object = json_object();
- next_token(s);
-
- while(token(s) != '}') {
- char *key;
- size_t len;
- int ours;
- json_t *value;
-
- if(!token(s)) {
- set_error(s, "", "Unexpected end of format string");
- goto error;
- }
-
- if(token(s) != 's') {
- set_error(s, "", "Expected format 's', got '%c'", token(s));
- goto error;
- }
-
- key = read_string(s, ap, "object key", &len, &ours);
- if(!key)
- goto error;
-
- next_token(s);
-
- value = pack(s, ap);
- if(!value) {
- if(ours)
- jsonp_free(key);
-
- goto error;
- }
-
- if(json_object_set_new_nocheck(object, key, value)) {
- set_error(s, "", "Unable to add key \"%s\"", key);
- if(ours)
- jsonp_free(key);
-
- goto error;
- }
-
- if(ours)
- jsonp_free(key);
-
- next_token(s);
- }
-
- return object;
-
-error:
- json_decref(object);
- return NULL;
-}
-
-static json_t *pack_array(scanner_t *s, va_list *ap)
-{
- json_t *array = json_array();
- next_token(s);
-
- while(token(s) != ']') {
- json_t *value;
-
- if(!token(s)) {
- set_error(s, "", "Unexpected end of format string");
- goto error;
- }
-
- value = pack(s, ap);
- if(!value)
- goto error;
-
- if(json_array_append_new(array, value)) {
- set_error(s, "", "Unable to append to array");
- goto error;
- }
-
- next_token(s);
- }
- return array;
-
-error:
- json_decref(array);
- return NULL;
-}
-
-static json_t *pack_string(scanner_t *s, va_list *ap)
-{
- char *str;
- size_t len;
- int ours;
- int nullable;
-
- next_token(s);
- nullable = token(s) == '?';
- if (!nullable)
- prev_token(s);
-
- str = read_string(s, ap, "string", &len, &ours);
- if (!str) {
- return nullable ? json_null() : NULL;
- } else if (ours) {
- return jsonp_stringn_nocheck_own(str, len);
- } else {
- return json_stringn_nocheck(str, len);
- }
-}
-
-static json_t *pack(scanner_t *s, va_list *ap)
-{
- switch(token(s)) {
- case '{':
- return pack_object(s, ap);
-
- case '[':
- return pack_array(s, ap);
-
- case 's': /* string */
- return pack_string(s, ap);
-
- case 'n': /* null */
- return json_null();
-
- case 'b': /* boolean */
- return va_arg(*ap, int) ? json_true() : json_false();
-
- case 'i': /* integer from int */
- return json_integer(va_arg(*ap, int));
-
- case 'I': /* integer from json_int_t */
- return json_integer(va_arg(*ap, json_int_t));
-
- case 'f': /* real */
- return json_real(va_arg(*ap, double));
-
- case 'O': /* a json_t object; increments refcount */
- {
- int nullable;
- json_t *json;
-
- next_token(s);
- nullable = token(s) == '?';
- if (!nullable)
- prev_token(s);
-
- json = va_arg(*ap, json_t *);
- if (!json && nullable) {
- return json_null();
- } else {
- return json_incref(json);
- }
- }
-
- case 'o': /* a json_t object; doesn't increment refcount */
- {
- int nullable;
- json_t *json;
-
- next_token(s);
- nullable = token(s) == '?';
- if (!nullable)
- prev_token(s);
-
- json = va_arg(*ap, json_t *);
- if (!json && nullable) {
- return json_null();
- } else {
- return json;
- }
- }
-
- default:
- set_error(s, "", "Unexpected format character '%c'",
- token(s));
- return NULL;
- }
-}
-
-static int unpack(scanner_t *s, json_t *root, va_list *ap);
-
-static int unpack_object(scanner_t *s, json_t *root, va_list *ap)
-{
- int ret = -1;
- int strict = 0;
- int gotopt = 0;
-
- /* Use a set (emulated by a hashtable) to check that all object
- keys are accessed. Checking that the correct number of keys
- were accessed is not enough, as the same key can be unpacked
- multiple times.
- */
- hashtable_t key_set;
-
- if(hashtable_init(&key_set)) {
- set_error(s, "", "Out of memory");
- return -1;
- }
-
- if(root && !json_is_object(root)) {
- set_error(s, "", "Expected object, got %s",
- type_name(root));
- goto out;
- }
- next_token(s);
-
- while(token(s) != '}') {
- const char *key;
- json_t *value;
- int opt = 0;
-
- if(strict != 0) {
- set_error(s, "", "Expected '}' after '%c', got '%c'",
- (strict == 1 ? '!' : '*'), token(s));
- goto out;
- }
-
- if(!token(s)) {
- set_error(s, "", "Unexpected end of format string");
- goto out;
- }
-
- if(token(s) == '!' || token(s) == '*') {
- strict = (token(s) == '!' ? 1 : -1);
- next_token(s);
- continue;
- }
-
- if(token(s) != 's') {
- set_error(s, "", "Expected format 's', got '%c'", token(s));
- goto out;
- }
-
- key = va_arg(*ap, const char *);
- if(!key) {
- set_error(s, "", "NULL object key");
- goto out;
- }
-
- next_token(s);
-
- if(token(s) == '?') {
- opt = gotopt = 1;
- next_token(s);
- }
-
- if(!root) {
- /* skipping */
- value = NULL;
- }
- else {
- value = json_object_get(root, key);
- if(!value && !opt) {
- set_error(s, "", "Object item not found: %s", key);
- goto out;
- }
- }
-
- if(unpack(s, value, ap))
- goto out;
-
- hashtable_set(&key_set, key, 0, json_null());
- next_token(s);
- }
-
- if(strict == 0 && (s->flags & JSON_STRICT))
- strict = 1;
-
- if(root && strict == 1) {
- /* We need to check that all non optional items have been parsed */
- const char *key;
- int have_unrecognized_keys = 0;
- strbuffer_t unrecognized_keys;
- json_t *value;
- long unpacked = 0;
- if (gotopt) {
- /* We have optional keys, we need to iter on each key */
- json_object_foreach(root, key, value) {
- if(!hashtable_get(&key_set, key)) {
- unpacked++;
-
- /* Save unrecognized keys for the error message */
- if (!have_unrecognized_keys) {
- strbuffer_init(&unrecognized_keys);
- have_unrecognized_keys = 1;
- } else {
- strbuffer_append_bytes(&unrecognized_keys, ", ", 2);
- }
- strbuffer_append_bytes(&unrecognized_keys, key, strlen(key));
- }
- }
- } else {
- /* No optional keys, we can just compare the number of items */
- unpacked = (long)json_object_size(root) - (long)key_set.size;
- }
- if (unpacked) {
- if (!gotopt) {
- /* Save unrecognized keys for the error message */
- json_object_foreach(root, key, value) {
- if(!hashtable_get(&key_set, key)) {
- if (!have_unrecognized_keys) {
- strbuffer_init(&unrecognized_keys);
- have_unrecognized_keys = 1;
- } else {
- strbuffer_append_bytes(&unrecognized_keys, ", ", 2);
- }
- strbuffer_append_bytes(&unrecognized_keys, key, strlen(key));
- }
- }
- }
- set_error(s, "",
- "%li object item(s) left unpacked: %s",
- unpacked, strbuffer_value(&unrecognized_keys));
- strbuffer_close(&unrecognized_keys);
- goto out;
- }
- }
-
- ret = 0;
-
-out:
- hashtable_close(&key_set);
- return ret;
-}
-
-static int unpack_array(scanner_t *s, json_t *root, va_list *ap)
-{
- size_t i = 0;
- int strict = 0;
-
- if(root && !json_is_array(root)) {
- set_error(s, "", "Expected array, got %s", type_name(root));
- return -1;
- }
- next_token(s);
-
- while(token(s) != ']') {
- json_t *value;
-
- if(strict != 0) {
- set_error(s, "", "Expected ']' after '%c', got '%c'",
- (strict == 1 ? '!' : '*'),
- token(s));
- return -1;
- }
-
- if(!token(s)) {
- set_error(s, "", "Unexpected end of format string");
- return -1;
- }
-
- if(token(s) == '!' || token(s) == '*') {
- strict = (token(s) == '!' ? 1 : -1);
- next_token(s);
- continue;
- }
-
- if(!strchr(unpack_value_starters, token(s))) {
- set_error(s, "", "Unexpected format character '%c'",
- token(s));
- return -1;
- }
-
- if(!root) {
- /* skipping */
- value = NULL;
- }
- else {
- value = json_array_get(root, i);
- if(!value) {
- set_error(s, "", "Array index %lu out of range",
- (unsigned long)i);
- return -1;
- }
- }
-
- if(unpack(s, value, ap))
- return -1;
-
- next_token(s);
- i++;
- }
-
- if(strict == 0 && (s->flags & JSON_STRICT))
- strict = 1;
-
- if(root && strict == 1 && i != json_array_size(root)) {
- long diff = (long)json_array_size(root) - (long)i;
- set_error(s, "", "%li array item(s) left unpacked", diff);
- return -1;
- }
-
- return 0;
-}
-
-static int unpack(scanner_t *s, json_t *root, va_list *ap)
-{
- switch(token(s))
- {
- case '{':
- return unpack_object(s, root, ap);
-
- case '[':
- return unpack_array(s, root, ap);
-
- case 's':
- if(root && !json_is_string(root)) {
- set_error(s, "", "Expected string, got %s",
- type_name(root));
- return -1;
- }
-
- if(!(s->flags & JSON_VALIDATE_ONLY)) {
- const char **str_target;
- size_t *len_target = NULL;
-
- str_target = va_arg(*ap, const char **);
- if(!str_target) {
- set_error(s, "", "NULL string argument");
- return -1;
- }
-
- next_token(s);
-
- if(token(s) == '%') {
- len_target = va_arg(*ap, size_t *);
- if(!len_target) {
- set_error(s, "", "NULL string length argument");
- return -1;
- }
- }
- else
- prev_token(s);
-
- if(root) {
- *str_target = json_string_value(root);
- if(len_target)
- *len_target = json_string_length(root);
- }
- }
- return 0;
-
- case 'i':
- if(root && !json_is_integer(root)) {
- set_error(s, "", "Expected integer, got %s",
- type_name(root));
- return -1;
- }
-
- if(!(s->flags & JSON_VALIDATE_ONLY)) {
- int *target = va_arg(*ap, int*);
- if(root)
- *target = (int)json_integer_value(root);
- }
-
- return 0;
-
- case 'I':
- if(root && !json_is_integer(root)) {
- set_error(s, "", "Expected integer, got %s",
- type_name(root));
- return -1;
- }
-
- if(!(s->flags & JSON_VALIDATE_ONLY)) {
- json_int_t *target = va_arg(*ap, json_int_t*);
- if(root)
- *target = json_integer_value(root);
- }
-
- return 0;
-
- case 'b':
- if(root && !json_is_boolean(root)) {
- set_error(s, "", "Expected true or false, got %s",
- type_name(root));
- return -1;
- }
-
- if(!(s->flags & JSON_VALIDATE_ONLY)) {
- int *target = va_arg(*ap, int*);
- if(root)
- *target = json_is_true(root);
- }
-
- return 0;
-
- case 'f':
- if(root && !json_is_real(root)) {
- set_error(s, "", "Expected real, got %s",
- type_name(root));
- return -1;
- }
-
- if(!(s->flags & JSON_VALIDATE_ONLY)) {
- double *target = va_arg(*ap, double*);
- if(root)
- *target = json_real_value(root);
- }
-
- return 0;
-
- case 'F':
- if(root && !json_is_number(root)) {
- set_error(s, "", "Expected real or integer, got %s",
- type_name(root));
- return -1;
- }
-
- if(!(s->flags & JSON_VALIDATE_ONLY)) {
- double *target = va_arg(*ap, double*);
- if(root)
- *target = json_number_value(root);
- }
-
- return 0;
-
- case 'O':
- if(root && !(s->flags & JSON_VALIDATE_ONLY))
- json_incref(root);
- /* Fall through */
-
- case 'o':
- if(!(s->flags & JSON_VALIDATE_ONLY)) {
- json_t **target = va_arg(*ap, json_t**);
- if(root)
- *target = root;
- }
-
- return 0;
-
- case 'n':
- /* Never assign, just validate */
- if(root && !json_is_null(root)) {
- set_error(s, "", "Expected null, got %s",
- type_name(root));
- return -1;
- }
- return 0;
-
- default:
- set_error(s, "", "Unexpected format character '%c'",
- token(s));
- return -1;
- }
-}
-
-json_t *json_vpack_ex(json_error_t *error, size_t flags,
- const char *fmt, va_list ap)
-{
- scanner_t s;
- va_list ap_copy;
- json_t *value;
-
- if(!fmt || !*fmt) {
- jsonp_error_init(error, "");
- jsonp_error_set(error, -1, -1, 0, "NULL or empty format string");
- return NULL;
- }
- jsonp_error_init(error, NULL);
-
- scanner_init(&s, error, flags, fmt);
- next_token(&s);
-
- va_copy(ap_copy, ap);
- value = pack(&s, &ap_copy);
- va_end(ap_copy);
-
- if(!value)
- return NULL;
-
- next_token(&s);
- if(token(&s)) {
- json_decref(value);
- set_error(&s, "", "Garbage after format string");
- return NULL;
- }
-
- return value;
-}
-
-json_t *json_pack_ex(json_error_t *error, size_t flags, const char *fmt, ...)
-{
- json_t *value;
- va_list ap;
-
- va_start(ap, fmt);
- value = json_vpack_ex(error, flags, fmt, ap);
- va_end(ap);
-
- return value;
-}
-
-json_t *json_pack(const char *fmt, ...)
-{
- json_t *value;
- va_list ap;
-
- va_start(ap, fmt);
- value = json_vpack_ex(NULL, 0, fmt, ap);
- va_end(ap);
-
- return value;
-}
-
-int json_vunpack_ex(json_t *root, json_error_t *error, size_t flags,
- const char *fmt, va_list ap)
-{
- scanner_t s;
- va_list ap_copy;
-
- if(!root) {
- jsonp_error_init(error, "");
- jsonp_error_set(error, -1, -1, 0, "NULL root value");
- return -1;
- }
-
- if(!fmt || !*fmt) {
- jsonp_error_init(error, "");
- jsonp_error_set(error, -1, -1, 0, "NULL or empty format string");
- return -1;
- }
- jsonp_error_init(error, NULL);
-
- scanner_init(&s, error, flags, fmt);
- next_token(&s);
-
- va_copy(ap_copy, ap);
- if(unpack(&s, root, &ap_copy)) {
- va_end(ap_copy);
- return -1;
- }
- va_end(ap_copy);
-
- next_token(&s);
- if(token(&s)) {
- set_error(&s, "", "Garbage after format string");
- return -1;
- }
-
- return 0;
-}
-
-int json_unpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt, ...)
-{
- int ret;
- va_list ap;
-
- va_start(ap, fmt);
- ret = json_vunpack_ex(root, error, flags, fmt, ap);
- va_end(ap);
-
- return ret;
-}
-
-int json_unpack(json_t *root, const char *fmt, ...)
-{
- int ret;
- va_list ap;
-
- va_start(ap, fmt);
- ret = json_vunpack_ex(root, NULL, 0, fmt, ap);
- va_end(ap);
-
- return ret;
-}
diff --git a/external/Jansson/strbuffer.c b/external/Jansson/strbuffer.c
deleted file mode 100644
index 51292051..00000000
--- a/external/Jansson/strbuffer.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2009-2014 Petri Lehtinen
- *
- * Jansson is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See LICENSE for details.
- */
-
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
-#include
-#include
-#include "jansson_private.h"
-#include "strbuffer.h"
-
-#define STRBUFFER_MIN_SIZE 16
-#define STRBUFFER_FACTOR 2
-#define STRBUFFER_SIZE_MAX ((size_t)-1)
-
-int strbuffer_init(strbuffer_t *strbuff)
-{
- strbuff->size = STRBUFFER_MIN_SIZE;
- strbuff->length = 0;
-
- strbuff->value = jsonp_malloc(strbuff->size);
- if(!strbuff->value)
- return -1;
-
- /* initialize to empty */
- strbuff->value[0] = '\0';
- return 0;
-}
-
-void strbuffer_close(strbuffer_t *strbuff)
-{
- if(strbuff->value)
- jsonp_free(strbuff->value);
-
- strbuff->size = 0;
- strbuff->length = 0;
- strbuff->value = NULL;
-}
-
-void strbuffer_clear(strbuffer_t *strbuff)
-{
- strbuff->length = 0;
- strbuff->value[0] = '\0';
-}
-
-const char *strbuffer_value(const strbuffer_t *strbuff)
-{
- return strbuff->value;
-}
-
-char *strbuffer_steal_value(strbuffer_t *strbuff)
-{
- char *result = strbuff->value;
- strbuff->value = NULL;
- return result;
-}
-
-int strbuffer_append_byte(strbuffer_t *strbuff, char byte)
-{
- return strbuffer_append_bytes(strbuff, &byte, 1);
-}
-
-int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size)
-{
- if(size >= strbuff->size - strbuff->length)
- {
- size_t new_size;
- char *new_value;
-
- /* avoid integer overflow */
- if (strbuff->size > STRBUFFER_SIZE_MAX / STRBUFFER_FACTOR
- || size > STRBUFFER_SIZE_MAX - 1
- || strbuff->length > STRBUFFER_SIZE_MAX - 1 - size)
- return -1;
-
- new_size = max(strbuff->size * STRBUFFER_FACTOR,
- strbuff->length + size + 1);
-
- new_value = jsonp_malloc(new_size);
- if(!new_value)
- return -1;
-
- memcpy(new_value, strbuff->value, strbuff->length);
-
- jsonp_free(strbuff->value);
- strbuff->value = new_value;
- strbuff->size = new_size;
- }
-
- memcpy(strbuff->value + strbuff->length, data, size);
- strbuff->length += size;
- strbuff->value[strbuff->length] = '\0';
-
- return 0;
-}
-
-char strbuffer_pop(strbuffer_t *strbuff)
-{
- if(strbuff->length > 0) {
- char c = strbuff->value[--strbuff->length];
- strbuff->value[strbuff->length] = '\0';
- return c;
- }
- else
- return '\0';
-}
diff --git a/external/Jansson/strbuffer.h b/external/Jansson/strbuffer.h
deleted file mode 100644
index 88b7e053..00000000
--- a/external/Jansson/strbuffer.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2009-2014 Petri Lehtinen
- *
- * Jansson is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See LICENSE for details.
- */
-
-#ifndef STRBUFFER_H
-#define STRBUFFER_H
-
-#include
-
-typedef struct {
- char *value;
- size_t length; /* bytes used */
- size_t size; /* bytes allocated */
-} strbuffer_t;
-
-int strbuffer_init(strbuffer_t *strbuff);
-void strbuffer_close(strbuffer_t *strbuff);
-
-void strbuffer_clear(strbuffer_t *strbuff);
-
-const char *strbuffer_value(const strbuffer_t *strbuff);
-
-/* Steal the value and close the strbuffer */
-char *strbuffer_steal_value(strbuffer_t *strbuff);
-
-int strbuffer_append_byte(strbuffer_t *strbuff, char byte);
-int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size);
-
-char strbuffer_pop(strbuffer_t *strbuff);
-
-#endif
diff --git a/external/Jansson/strconv.c b/external/Jansson/strconv.c
deleted file mode 100644
index 8075481e..00000000
--- a/external/Jansson/strconv.c
+++ /dev/null
@@ -1,145 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-#ifdef __MINGW32__
-#undef __NO_ISOCEXT /* ensure stdlib.h will declare prototypes for mingw own 'strtod' replacement, called '__strtod' */
-#endif
-#include "jansson_private.h"
-#include "strbuffer.h"
-
-/* need jansson_private_config.h to get the correct snprintf */
-#ifdef HAVE_CONFIG_H
-#include
-#endif
-
-#ifdef __MINGW32__
-#define strtod __strtod
-#endif
-
-#if JSON_HAVE_LOCALECONV
-#include
-
-/*
- - This code assumes that the decimal separator is exactly one
- character.
-
- - If setlocale() is called by another thread between the call to
- localeconv() and the call to sprintf() or strtod(), the result may
- be wrong. setlocale() is not thread-safe and should not be used
- this way. Multi-threaded programs should use uselocale() instead.
-*/
-
-static void to_locale(strbuffer_t *strbuffer)
-{
- const char *point;
- char *pos;
-
- point = localeconv()->decimal_point;
- if(*point == '.') {
- /* No conversion needed */
- return;
- }
-
- pos = strchr(strbuffer->value, '.');
- if(pos)
- *pos = *point;
-}
-
-static void from_locale(char *buffer)
-{
- const char *point;
- char *pos;
-
- point = localeconv()->decimal_point;
- if(*point == '.') {
- /* No conversion needed */
- return;
- }
-
- pos = strchr(buffer, *point);
- if(pos)
- *pos = '.';
-}
-#endif
-
-int jsonp_strtod(strbuffer_t *strbuffer, double *out)
-{
- double value;
- char *end;
-
-#if JSON_HAVE_LOCALECONV
- to_locale(strbuffer);
-#endif
-
- errno = 0;
- value = strtod(strbuffer->value, &end);
- assert(end == strbuffer->value + strbuffer->length);
-
- if((value == HUGE_VAL || value == -HUGE_VAL) && errno == ERANGE) {
- /* Overflow */
- return -1;
- }
-
- *out = value;
- return 0;
-}
-
-int jsonp_dtostr(char *buffer, size_t size, double value, int precision)
-{
- int ret;
- char *start, *end;
- size_t length;
-
- if (precision == 0)
- precision = 17;
-
- ret = snprintf(buffer, size, "%.*g", precision, value);
- if(ret < 0)
- return -1;
-
- length = (size_t)ret;
- if(length >= size)
- return -1;
-
-#if JSON_HAVE_LOCALECONV
- from_locale(buffer);
-#endif
-
- /* Make sure there's a dot or 'e' in the output. Otherwise
- a real is converted to an integer when decoding */
- if(strchr(buffer, '.') == NULL &&
- strchr(buffer, 'e') == NULL)
- {
- if(length + 3 >= size) {
- /* No space to append ".0" */
- return -1;
- }
- buffer[length] = '.';
- buffer[length + 1] = '0';
- buffer[length + 2] = '\0';
- length += 2;
- }
-
- /* Remove leading '+' from positive exponent. Also remove leading
- zeros from exponents (added by some printf() implementations) */
- start = strchr(buffer, 'e');
- if(start) {
- start++;
- end = start + 1;
-
- if(*start == '-')
- start++;
-
- while(*end == '0')
- end++;
-
- if(end != start) {
- memmove(start, end, length - (size_t)(end - buffer));
- length -= (size_t)(end - start);
- }
- }
-
- return (int)length;
-}
diff --git a/external/Jansson/utf.c b/external/Jansson/utf.c
deleted file mode 100644
index b56e1250..00000000
--- a/external/Jansson/utf.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright (c) 2009-2014 Petri Lehtinen
- *
- * Jansson is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See LICENSE for details.
- */
-
-#include
-#include "utf.h"
-
-int utf8_encode(int32_t codepoint, char *buffer, size_t *size)
-{
- if(codepoint < 0)
- return -1;
- else if(codepoint < 0x80)
- {
- buffer[0] = (char)codepoint;
- *size = 1;
- }
- else if(codepoint < 0x800)
- {
- buffer[0] = 0xC0 + ((codepoint & 0x7C0) >> 6);
- buffer[1] = 0x80 + ((codepoint & 0x03F));
- *size = 2;
- }
- else if(codepoint < 0x10000)
- {
- buffer[0] = 0xE0 + ((codepoint & 0xF000) >> 12);
- buffer[1] = 0x80 + ((codepoint & 0x0FC0) >> 6);
- buffer[2] = 0x80 + ((codepoint & 0x003F));
- *size = 3;
- }
- else if(codepoint <= 0x10FFFF)
- {
- buffer[0] = 0xF0 + ((codepoint & 0x1C0000) >> 18);
- buffer[1] = 0x80 + ((codepoint & 0x03F000) >> 12);
- buffer[2] = 0x80 + ((codepoint & 0x000FC0) >> 6);
- buffer[3] = 0x80 + ((codepoint & 0x00003F));
- *size = 4;
- }
- else
- return -1;
-
- return 0;
-}
-
-size_t utf8_check_first(char byte)
-{
- unsigned char u = (unsigned char)byte;
-
- if(u < 0x80)
- return 1;
-
- if(0x80 <= u && u <= 0xBF) {
- /* second, third or fourth byte of a multi-byte
- sequence, i.e. a "continuation byte" */
- return 0;
- }
- else if(u == 0xC0 || u == 0xC1) {
- /* overlong encoding of an ASCII byte */
- return 0;
- }
- else if(0xC2 <= u && u <= 0xDF) {
- /* 2-byte sequence */
- return 2;
- }
-
- else if(0xE0 <= u && u <= 0xEF) {
- /* 3-byte sequence */
- return 3;
- }
- else if(0xF0 <= u && u <= 0xF4) {
- /* 4-byte sequence */
- return 4;
- }
- else { /* u >= 0xF5 */
- /* Restricted (start of 4-, 5- or 6-byte sequence) or invalid
- UTF-8 */
- return 0;
- }
-}
-
-size_t utf8_check_full(const char *buffer, size_t size, int32_t *codepoint)
-{
- size_t i;
- int32_t value = 0;
- unsigned char u = (unsigned char)buffer[0];
-
- if(size == 2)
- {
- value = u & 0x1F;
- }
- else if(size == 3)
- {
- value = u & 0xF;
- }
- else if(size == 4)
- {
- value = u & 0x7;
- }
- else
- return 0;
-
- for(i = 1; i < size; i++)
- {
- u = (unsigned char)buffer[i];
-
- if(u < 0x80 || u > 0xBF) {
- /* not a continuation byte */
- return 0;
- }
-
- value = (value << 6) + (u & 0x3F);
- }
-
- if(value > 0x10FFFF) {
- /* not in Unicode range */
- return 0;
- }
-
- else if(0xD800 <= value && value <= 0xDFFF) {
- /* invalid code point (UTF-16 surrogate halves) */
- return 0;
- }
-
- else if((size == 2 && value < 0x80) ||
- (size == 3 && value < 0x800) ||
- (size == 4 && value < 0x10000)) {
- /* overlong encoding */
- return 0;
- }
-
- if(codepoint)
- *codepoint = value;
-
- return 1;
-}
-
-const char *utf8_iterate(const char *buffer, size_t bufsize, int32_t *codepoint)
-{
- size_t count;
- int32_t value;
-
- if(!bufsize)
- return buffer;
-
- count = utf8_check_first(buffer[0]);
- if(count <= 0)
- return NULL;
-
- if(count == 1)
- value = (unsigned char)buffer[0];
- else
- {
- if(count > bufsize || !utf8_check_full(buffer, count, &value))
- return NULL;
- }
-
- if(codepoint)
- *codepoint = value;
-
- return buffer + count;
-}
-
-int utf8_check_string(const char *string, size_t length)
-{
- size_t i;
-
- for(i = 0; i < length; i++)
- {
- size_t count = utf8_check_first(string[i]);
- if(count == 0)
- return 0;
- else if(count > 1)
- {
- if(count > length - i)
- return 0;
-
- if(!utf8_check_full(&string[i], count, NULL))
- return 0;
-
- i += count - 1;
- }
- }
-
- return 1;
-}
diff --git a/external/Jansson/utf.h b/external/Jansson/utf.h
deleted file mode 100644
index 2cebea01..00000000
--- a/external/Jansson/utf.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2009-2014 Petri Lehtinen
- *
- * Jansson is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See LICENSE for details.
- */
-
-#ifndef UTF_H
-#define UTF_H
-
-#ifdef HAVE_CONFIG_H
-#include
-#endif
-
-#ifdef HAVE_STDINT_H
-#include
-#endif
-
-int utf8_encode(int32_t codepoint, char *buffer, size_t *size);
-
-size_t utf8_check_first(char byte);
-size_t utf8_check_full(const char *buffer, size_t size, int32_t *codepoint);
-const char *utf8_iterate(const char *buffer, size_t size, int32_t *codepoint);
-
-int utf8_check_string(const char *string, size_t length);
-
-#endif
diff --git a/external/Jansson/value.c b/external/Jansson/value.c
deleted file mode 100644
index 20106051..00000000
--- a/external/Jansson/value.c
+++ /dev/null
@@ -1,1048 +0,0 @@
-/*
- * Copyright (c) 2009-2014 Petri Lehtinen
- *
- * Jansson is free software; you can redistribute it and/or modify
- * it under the terms of the MIT license. See LICENSE for details.
- */
-
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include
-#endif
-
-#include
-#include
-#include
-#include
-
-#ifdef HAVE_STDINT_H
-#include
-#endif
-
-#include "jansson.h"
-#include "hashtable.h"
-#include "jansson_private.h"
-#include "utf.h"
-
-/* Work around nonstandard isnan() and isinf() implementations */
-#ifndef isnan
-#ifndef __sun
-static JSON_INLINE int isnan(double x) { return x != x; }
-#endif
-#endif
-#ifndef isinf
-static JSON_INLINE int isinf(double x) { return !isnan(x) && isnan(x - x); }
-#endif
-
-static JSON_INLINE void json_init(json_t *json, json_type type)
-{
- json->type = type;
- json->refcount = 1;
-}
-
-
-/*** object ***/
-
-extern volatile uint32_t hashtable_seed;
-
-json_t *json_object(void)
-{
- json_object_t *object = jsonp_malloc(sizeof(json_object_t));
- if(!object)
- return NULL;
-
- if (!hashtable_seed) {
- /* Autoseed */
- json_object_seed(0);
- }
-
- json_init(&object->json, JSON_OBJECT);
-
- if(hashtable_init(&object->hashtable))
- {
- jsonp_free(object);
- return NULL;
- }
-
- object->serial = 0;
- object->visited = 0;
-
- return &object->json;
-}
-
-static void json_delete_object(json_object_t *object)
-{
- hashtable_close(&object->hashtable);
- jsonp_free(object);
-}
-
-size_t json_object_size(const json_t *json)
-{
- json_object_t *object;
-
- if(!json_is_object(json))
- return 0;
-
- object = json_to_object(json);
- return object->hashtable.size;
-}
-
-json_t *json_object_get(const json_t *json, const char *key)
-{
- json_object_t *object;
-
- if(!key || !json_is_object(json))
- return NULL;
-
- object = json_to_object(json);
- return hashtable_get(&object->hashtable, key);
-}
-
-int json_object_set_new_nocheck(json_t *json, const char *key, json_t *value)
-{
- json_object_t *object;
-
- if(!value)
- return -1;
-
- if(!key || !json_is_object(json) || json == value)
- {
- json_decref(value);
- return -1;
- }
- object = json_to_object(json);
-
- if(hashtable_set(&object->hashtable, key, object->serial++, value))
- {
- json_decref(value);
- return -1;
- }
-
- return 0;
-}
-
-int json_object_set_new(json_t *json, const char *key, json_t *value)
-{
- if(!key || !utf8_check_string(key, strlen(key)))
- {
- json_decref(value);
- return -1;
- }
-
- return json_object_set_new_nocheck(json, key, value);
-}
-
-int json_object_del(json_t *json, const char *key)
-{
- json_object_t *object;
-
- if(!key || !json_is_object(json))
- return -1;
-
- object = json_to_object(json);
- return hashtable_del(&object->hashtable, key);
-}
-
-int json_object_clear(json_t *json)
-{
- json_object_t *object;
-
- if(!json_is_object(json))
- return -1;
-
- object = json_to_object(json);
-
- hashtable_clear(&object->hashtable);
- object->serial = 0;
-
- return 0;
-}
-
-int json_object_update(json_t *object, json_t *other)
-{
- const char *key;
- json_t *value;
-
- if(!json_is_object(object) || !json_is_object(other))
- return -1;
-
- json_object_foreach(other, key, value) {
- if(json_object_set_nocheck(object, key, value))
- return -1;
- }
-
- return 0;
-}
-
-int json_object_update_existing(json_t *object, json_t *other)
-{
- const char *key;
- json_t *value;
-
- if(!json_is_object(object) || !json_is_object(other))
- return -1;
-
- json_object_foreach(other, key, value) {
- if(json_object_get(object, key))
- json_object_set_nocheck(object, key, value);
- }
-
- return 0;
-}
-
-int json_object_update_missing(json_t *object, json_t *other)
-{
- const char *key;
- json_t *value;
-
- if(!json_is_object(object) || !json_is_object(other))
- return -1;
-
- json_object_foreach(other, key, value) {
- if(!json_object_get(object, key))
- json_object_set_nocheck(object, key, value);
- }
-
- return 0;
-}
-
-void *json_object_iter(json_t *json)
-{
- json_object_t *object;
-
- if(!json_is_object(json))
- return NULL;
-
- object = json_to_object(json);
- return hashtable_iter(&object->hashtable);
-}
-
-void *json_object_iter_at(json_t *json, const char *key)
-{
- json_object_t *object;
-
- if(!key || !json_is_object(json))
- return NULL;
-
- object = json_to_object(json);
- return hashtable_iter_at(&object->hashtable, key);
-}
-
-void *json_object_iter_next(json_t *json, void *iter)
-{
- json_object_t *object;
-
- if(!json_is_object(json) || iter == NULL)
- return NULL;
-
- object = json_to_object(json);
- return hashtable_iter_next(&object->hashtable, iter);
-}
-
-const char *json_object_iter_key(void *iter)
-{
- if(!iter)
- return NULL;
-
- return hashtable_iter_key(iter);
-}
-
-json_t *json_object_iter_value(void *iter)
-{
- if(!iter)
- return NULL;
-
- return (json_t *)hashtable_iter_value(iter);
-}
-
-int json_object_iter_set_new(json_t *json, void *iter, json_t *value)
-{
- if(!json_is_object(json) || !iter || !value)
- return -1;
-
- hashtable_iter_set(iter, value);
- return 0;
-}
-
-void *json_object_key_to_iter(const char *key)
-{
- if(!key)
- return NULL;
-
- return hashtable_key_to_iter(key);
-}
-
-static int json_object_equal(json_t *object1, json_t *object2)
-{
- const char *key;
- json_t *value1, *value2;
-
- if(json_object_size(object1) != json_object_size(object2))
- return 0;
-
- json_object_foreach(object1, key, value1) {
- value2 = json_object_get(object2, key);
-
- if(!json_equal(value1, value2))
- return 0;
- }
-
- return 1;
-}
-
-static json_t *json_object_copy(json_t *object)
-{
- json_t *result;
-
- const char *key;
- json_t *value;
-
- result = json_object();
- if(!result)
- return NULL;
-
- json_object_foreach(object, key, value)
- json_object_set_nocheck(result, key, value);
-
- return result;
-}
-
-static json_t *json_object_deep_copy(const json_t *object)
-{
- json_t *result;
- void *iter;
-
- result = json_object();
- if(!result)
- return NULL;
-
- /* Cannot use json_object_foreach because object has to be cast
- non-const */
- iter = json_object_iter((json_t *)object);
- while(iter) {
- const char *key;
- const json_t *value;
- key = json_object_iter_key(iter);
- value = json_object_iter_value(iter);
-
- json_object_set_new_nocheck(result, key, json_deep_copy(value));
- iter = json_object_iter_next((json_t *)object, iter);
- }
-
- return result;
-}
-
-
-/*** array ***/
-
-json_t *json_array(void)
-{
- json_array_t *array = jsonp_malloc(sizeof(json_array_t));
- if(!array)
- return NULL;
- json_init(&array->json, JSON_ARRAY);
-
- array->entries = 0;
- array->size = 8;
-
- array->table = jsonp_malloc(array->size * sizeof(json_t *));
- if(!array->table) {
- jsonp_free(array);
- return NULL;
- }
-
- array->visited = 0;
-
- return &array->json;
-}
-
-static void json_delete_array(json_array_t *array)
-{
- size_t i;
-
- for(i = 0; i < array->entries; i++)
- json_decref(array->table[i]);
-
- jsonp_free(array->table);
- jsonp_free(array);
-}
-
-size_t json_array_size(const json_t *json)
-{
- if(!json_is_array(json))
- return 0;
-
- return json_to_array(json)->entries;
-}
-
-json_t *json_array_get(const json_t *json, size_t index)
-{
- json_array_t *array;
- if(!json_is_array(json))
- return NULL;
- array = json_to_array(json);
-
- if(index >= array->entries)
- return NULL;
-
- return array->table[index];
-}
-
-int json_array_set_new(json_t *json, size_t index, json_t *value)
-{
- json_array_t *array;
-
- if(!value)
- return -1;
-
- if(!json_is_array(json) || json == value)
- {
- json_decref(value);
- return -1;
- }
- array = json_to_array(json);
-
- if(index >= array->entries)
- {
- json_decref(value);
- return -1;
- }
-
- json_decref(array->table[index]);
- array->table[index] = value;
-
- return 0;
-}
-
-static void array_move(json_array_t *array, size_t dest,
- size_t src, size_t count)
-{
- memmove(&array->table[dest], &array->table[src], count * sizeof(json_t *));
-}
-
-static void array_copy(json_t **dest, size_t dpos,
- json_t **src, size_t spos,
- size_t count)
-{
- memcpy(&dest[dpos], &src[spos], count * sizeof(json_t *));
-}
-
-static json_t **json_array_grow(json_array_t *array,
- size_t amount,
- int copy)
-{
- size_t new_size;
- json_t **old_table, **new_table;
-
- if(array->entries + amount <= array->size)
- return array->table;
-
- old_table = array->table;
-
- new_size = max(array->size + amount, array->size * 2);
- new_table = jsonp_malloc(new_size * sizeof(json_t *));
- if(!new_table)
- return NULL;
-
- array->size = new_size;
- array->table = new_table;
-
- if(copy) {
- array_copy(array->table, 0, old_table, 0, array->entries);
- jsonp_free(old_table);
- return array->table;
- }
-
- return old_table;
-}
-
-int json_array_append_new(json_t *json, json_t *value)
-{
- json_array_t *array;
-
- if(!value)
- return -1;
-
- if(!json_is_array(json) || json == value)
- {
- json_decref(value);
- return -1;
- }
- array = json_to_array(json);
-
- if(!json_array_grow(array, 1, 1)) {
- json_decref(value);
- return -1;
- }
-
- array->table[array->entries] = value;
- array->entries++;
-
- return 0;
-}
-
-int json_array_insert_new(json_t *json, size_t index, json_t *value)
-{
- json_array_t *array;
- json_t **old_table;
-
- if(!value)
- return -1;
-
- if(!json_is_array(json) || json == value) {
- json_decref(value);
- return -1;
- }
- array = json_to_array(json);
-
- if(index > array->entries) {
- json_decref(value);
- return -1;
- }
-
- old_table = json_array_grow(array, 1, 0);
- if(!old_table) {
- json_decref(value);
- return -1;
- }
-
- if(old_table != array->table) {
- array_copy(array->table, 0, old_table, 0, index);
- array_copy(array->table, index + 1, old_table, index,
- array->entries - index);
- jsonp_free(old_table);
- }
- else
- array_move(array, index + 1, index, array->entries - index);
-
- array->table[index] = value;
- array->entries++;
-
- return 0;
-}
-
-int json_array_remove(json_t *json, size_t index)
-{
- json_array_t *array;
-
- if(!json_is_array(json))
- return -1;
- array = json_to_array(json);
-
- if(index >= array->entries)
- return -1;
-
- json_decref(array->table[index]);
-
- /* If we're removing the last element, nothing has to be moved */
- if(index < array->entries - 1)
- array_move(array, index, index + 1, array->entries - index - 1);
-
- array->entries--;
-
- return 0;
-}
-
-int json_array_clear(json_t *json)
-{
- json_array_t *array;
- size_t i;
-
- if(!json_is_array(json))
- return -1;
- array = json_to_array(json);
-
- for(i = 0; i < array->entries; i++)
- json_decref(array->table[i]);
-
- array->entries = 0;
- return 0;
-}
-
-int json_array_extend(json_t *json, json_t *other_json)
-{
- json_array_t *array, *other;
- size_t i;
-
- if(!json_is_array(json) || !json_is_array(other_json))
- return -1;
- array = json_to_array(json);
- other = json_to_array(other_json);
-
- if(!json_array_grow(array, other->entries, 1))
- return -1;
-
- for(i = 0; i < other->entries; i++)
- json_incref(other->table[i]);
-
- array_copy(array->table, array->entries, other->table, 0, other->entries);
-
- array->entries += other->entries;
- return 0;
-}
-
-static int json_array_equal(json_t *array1, json_t *array2)
-{
- size_t i, size;
-
- size = json_array_size(array1);
- if(size != json_array_size(array2))
- return 0;
-
- for(i = 0; i < size; i++)
- {
- json_t *value1, *value2;
-
- value1 = json_array_get(array1, i);
- value2 = json_array_get(array2, i);
-
- if(!json_equal(value1, value2))
- return 0;
- }
-
- return 1;
-}
-
-static json_t *json_array_copy(json_t *array)
-{
- json_t *result;
- size_t i;
-
- result = json_array();
- if(!result)
- return NULL;
-
- for(i = 0; i < json_array_size(array); i++)
- json_array_append(result, json_array_get(array, i));
-
- return result;
-}
-
-static json_t *json_array_deep_copy(const json_t *array)
-{
- json_t *result;
- size_t i;
-
- result = json_array();
- if(!result)
- return NULL;
-
- for(i = 0; i < json_array_size(array); i++)
- json_array_append_new(result, json_deep_copy(json_array_get(array, i)));
-
- return result;
-}
-
-/*** string ***/
-
-static json_t *string_create(const char *value, size_t len, int own)
-{
- char *v;
- json_string_t *string;
-
- if(!value)
- return NULL;
-
- if(own)
- v = (char *)value;
- else {
- v = jsonp_strndup(value, len);
- if(!v)
- return NULL;
- }
-
- string = jsonp_malloc(sizeof(json_string_t));
- if(!string) {
- if(!own)
- jsonp_free(v);
- return NULL;
- }
- json_init(&string->json, JSON_STRING);
- string->value = v;
- string->length = len;
-
- return &string->json;
-}
-
-json_t *json_string_nocheck(const char *value)
-{
- if(!value)
- return NULL;
-
- return string_create(value, strlen(value), 0);
-}
-
-json_t *json_stringn_nocheck(const char *value, size_t len)
-{
- return string_create(value, len, 0);
-}
-
-/* this is private; "steal" is not a public API concept */
-json_t *jsonp_stringn_nocheck_own(const char *value, size_t len)
-{
- return string_create(value, len, 1);
-}
-
-json_t *json_string(const char *value)
-{
- if(!value)
- return NULL;
-
- return json_stringn(value, strlen(value));
-}
-
-json_t *json_stringn(const char *value, size_t len)
-{
- if(!value || !utf8_check_string(value, len))
- return NULL;
-
- return json_stringn_nocheck(value, len);
-}
-
-const char *json_string_value(const json_t *json)
-{
- if(!json_is_string(json))
- return NULL;
-
- return json_to_string(json)->value;
-}
-
-size_t json_string_length(const json_t *json)
-{
- if(!json_is_string(json))
- return 0;
-
- return json_to_string(json)->length;
-}
-
-int json_string_set_nocheck(json_t *json, const char *value)
-{
- if(!value)
- return -1;
-
- return json_string_setn_nocheck(json, value, strlen(value));
-}
-
-int json_string_setn_nocheck(json_t *json, const char *value, size_t len)
-{
- char *dup;
- json_string_t *string;
-
- if(!json_is_string(json) || !value)
- return -1;
-
- dup = jsonp_strndup(value, len);
- if(!dup)
- return -1;
-
- string = json_to_string(json);
- jsonp_free(string->value);
- string->value = dup;
- string->length = len;
-
- return 0;
-}
-
-int json_string_set(json_t *json, const char *value)
-{
- if(!value)
- return -1;
-
- return json_string_setn(json, value, strlen(value));
-}
-
-int json_string_setn(json_t *json, const char *value, size_t len)
-{
- if(!value || !utf8_check_string(value, len))
- return -1;
-
- return json_string_setn_nocheck(json, value, len);
-}
-
-static void json_delete_string(json_string_t *string)
-{
- jsonp_free(string->value);
- jsonp_free(string);
-}
-
-static int json_string_equal(json_t *string1, json_t *string2)
-{
- json_string_t *s1, *s2;
-
- if(!json_is_string(string1) || !json_is_string(string2))
- return 0;
-
- s1 = json_to_string(string1);
- s2 = json_to_string(string2);
- return s1->length == s2->length && !memcmp(s1->value, s2->value, s1->length);
-}
-
-static json_t *json_string_copy(const json_t *string)
-{
- json_string_t *s;
-
- if(!json_is_string(string))
- return NULL;
-
- s = json_to_string(string);
- return json_stringn_nocheck(s->value, s->length);
-}
-
-
-/*** integer ***/
-
-json_t *json_integer(json_int_t value)
-{
- json_integer_t *integer = jsonp_malloc(sizeof(json_integer_t));
- if(!integer)
- return NULL;
- json_init(&integer->json, JSON_INTEGER);
-
- integer->value = value;
- return &integer->json;
-}
-
-json_int_t json_integer_value(const json_t *json)
-{
- if(!json_is_integer(json))
- return 0;
-
- return json_to_integer(json)->value;
-}
-
-int json_integer_set(json_t *json, json_int_t value)
-{
- if(!json_is_integer(json))
- return -1;
-
- json_to_integer(json)->value = value;
-
- return 0;
-}
-
-static void json_delete_integer(json_integer_t *integer)
-{
- jsonp_free(integer);
-}
-
-static int json_integer_equal(json_t *integer1, json_t *integer2)
-{
- return json_integer_value(integer1) == json_integer_value(integer2);
-}
-
-static json_t *json_integer_copy(const json_t *integer)
-{
- return json_integer(json_integer_value(integer));
-}
-
-
-/*** real ***/
-
-json_t *json_real(double value)
-{
- json_real_t *real;
-
- if(isnan(value) || isinf(value))
- return NULL;
-
- real = jsonp_malloc(sizeof(json_real_t));
- if(!real)
- return NULL;
- json_init(&real->json, JSON_REAL);
-
- real->value = value;
- return &real->json;
-}
-
-double json_real_value(const json_t *json)
-{
- if(!json_is_real(json))
- return 0;
-
- return json_to_real(json)->value;
-}
-
-int json_real_set(json_t *json, double value)
-{
- if(!json_is_real(json) || isnan(value) || isinf(value))
- return -1;
-
- json_to_real(json)->value = value;
-
- return 0;
-}
-
-static void json_delete_real(json_real_t *real)
-{
- jsonp_free(real);
-}
-
-static int json_real_equal(json_t *real1, json_t *real2)
-{
- return json_real_value(real1) == json_real_value(real2);
-}
-
-static json_t *json_real_copy(const json_t *real)
-{
- return json_real(json_real_value(real));
-}
-
-
-/*** number ***/
-
-double json_number_value(const json_t *json)
-{
- if(json_is_integer(json))
- return (double)json_integer_value(json);
- else if(json_is_real(json))
- return json_real_value(json);
- else
- return 0.0;
-}
-
-
-/*** simple values ***/
-
-json_t *json_true(void)
-{
- static json_t the_true = {JSON_TRUE, (size_t)-1};
- return &the_true;
-}
-
-
-json_t *json_false(void)
-{
- static json_t the_false = {JSON_FALSE, (size_t)-1};
- return &the_false;
-}
-
-
-json_t *json_null(void)
-{
- static json_t the_null = {JSON_NULL, (size_t)-1};
- return &the_null;
-}
-
-
-/*** deletion ***/
-
-void json_delete(json_t *json)
-{
- if (!json)
- return;
-
- switch(json_typeof(json)) {
- case JSON_OBJECT:
- json_delete_object(json_to_object(json));
- break;
- case JSON_ARRAY:
- json_delete_array(json_to_array(json));
- break;
- case JSON_STRING:
- json_delete_string(json_to_string(json));
- break;
- case JSON_INTEGER:
- json_delete_integer(json_to_integer(json));
- break;
- case JSON_REAL:
- json_delete_real(json_to_real(json));
- break;
- default:
- return;
- }
-
- /* json_delete is not called for true, false or null */
-}
-
-
-/*** equality ***/
-
-int json_equal(json_t *json1, json_t *json2)
-{
- if(!json1 || !json2)
- return 0;
-
- if(json_typeof(json1) != json_typeof(json2))
- return 0;
-
- /* this covers true, false and null as they are singletons */
- if(json1 == json2)
- return 1;
-
- switch(json_typeof(json1)) {
- case JSON_OBJECT:
- return json_object_equal(json1, json2);
- case JSON_ARRAY:
- return json_array_equal(json1, json2);
- case JSON_STRING:
- return json_string_equal(json1, json2);
- case JSON_INTEGER:
- return json_integer_equal(json1, json2);
- case JSON_REAL:
- return json_real_equal(json1, json2);
- default:
- return 0;
- }
-}
-
-
-/*** copying ***/
-
-json_t *json_copy(json_t *json)
-{
- if(!json)
- return NULL;
-
- switch(json_typeof(json)) {
- case JSON_OBJECT:
- return json_object_copy(json);
- case JSON_ARRAY:
- return json_array_copy(json);
- case JSON_STRING:
- return json_string_copy(json);
- case JSON_INTEGER:
- return json_integer_copy(json);
- case JSON_REAL:
- return json_real_copy(json);
- case JSON_TRUE:
- case JSON_FALSE:
- case JSON_NULL:
- return json;
- default:
- return NULL;
- }
-
- return NULL;
-}
-
-json_t *json_deep_copy(const json_t *json)
-{
- if(!json)
- return NULL;
-
- switch(json_typeof(json)) {
- case JSON_OBJECT:
- return json_object_deep_copy(json);
- case JSON_ARRAY:
- return json_array_deep_copy(json);
- /* for the rest of the types, deep copying doesn't differ from
- shallow copying */
- case JSON_STRING:
- return json_string_copy(json);
- case JSON_INTEGER:
- return json_integer_copy(json);
- case JSON_REAL:
- return json_real_copy(json);
- case JSON_TRUE:
- case JSON_FALSE:
- case JSON_NULL:
- return (json_t *)json;
- default:
- return NULL;
- }
-
- return NULL;
-}
diff --git a/external/LibIRC/colors.c b/external/LibIRC/colors.c
deleted file mode 100644
index 247cb10c..00000000
--- a/external/LibIRC/colors.c
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
- * Copyright (C) 2004-2012 George Yunaev gyunaev@ulduzsoft.com
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at your
- * option) any later version.
- *
- * This library 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 Lesser General Public
- * License for more details.
- */
-
-#include
-
-#define LIBIRC_COLORPARSER_BOLD (1<<1)
-#define LIBIRC_COLORPARSER_UNDERLINE (1<<2)
-#define LIBIRC_COLORPARSER_REVERSE (1<<3)
-#define LIBIRC_COLORPARSER_COLOR (1<<4)
-
-#define LIBIRC_COLORPARSER_MAXCOLORS 15
-
-
-static const char * color_replacement_table[] =
-{
- "WHITE",
- "BLACK",
- "DARKBLUE",
- "DARKGREEN",
- "RED",
- "BROWN",
- "PURPLE",
- "OLIVE",
- "YELLOW",
- "GREEN",
- "TEAL",
- "CYAN",
- "BLUE",
- "MAGENTA",
- "DARKGRAY",
- "LIGHTGRAY",
- 0
-};
-
-
-static inline void libirc_colorparser_addorcat (char ** destline, unsigned int * destlen, const char * str)
-{
- unsigned int len = strlen(str);
-
- if ( *destline )
- {
- strcpy (*destline, str);
- *destline += len;
- }
- else
- *destlen += len;
-}
-
-
-static void libirc_colorparser_applymask (unsigned int * mask,
- char ** destline, unsigned int * destlen,
- unsigned int bitmask, const char * start, const char * end)
-{
- if ( (*mask & bitmask) != 0 )
- {
- *mask &= ~bitmask;
- libirc_colorparser_addorcat (destline, destlen, end);
- }
- else
- {
- *mask |= bitmask;
- libirc_colorparser_addorcat (destline, destlen, start);
- }
-}
-
-
-static void libirc_colorparser_applycolor (unsigned int * mask,
- char ** destline, unsigned int * destlen,
- unsigned int colorid, unsigned int bgcolorid)
-{
- const char * end = "[/COLOR]";
- char startbuf[64];
-
- if ( bgcolorid != 0 )
- sprintf (startbuf, "[COLOR=%s/%s]", color_replacement_table[colorid], color_replacement_table[bgcolorid]);
- else
- sprintf (startbuf, "[COLOR=%s]", color_replacement_table[colorid]);
-
- if ( (*mask & LIBIRC_COLORPARSER_COLOR) != 0 )
- libirc_colorparser_addorcat (destline, destlen, end);
-
- *mask |= LIBIRC_COLORPARSER_COLOR;
- libirc_colorparser_addorcat (destline, destlen, startbuf);
-}
-
-
-static void libirc_colorparser_closetags (unsigned int * mask,
- char ** destline, unsigned int * destlen)
-{
- if ( *mask & LIBIRC_COLORPARSER_BOLD )
- libirc_colorparser_applymask (mask, destline, destlen, LIBIRC_COLORPARSER_BOLD, 0, "[/B]");
-
- if ( *mask & LIBIRC_COLORPARSER_UNDERLINE )
- libirc_colorparser_applymask (mask, destline, destlen, LIBIRC_COLORPARSER_UNDERLINE, 0, "[/U]");
-
- if ( *mask & LIBIRC_COLORPARSER_REVERSE )
- libirc_colorparser_applymask (mask, destline, destlen, LIBIRC_COLORPARSER_REVERSE, 0, "[/I]");
-
- if ( *mask & LIBIRC_COLORPARSER_COLOR )
- libirc_colorparser_applymask (mask, destline, destlen, LIBIRC_COLORPARSER_COLOR, 0, "[/COLOR]");
-}
-
-
-
-/*
- * IRC to [code] color conversion. Or strip.
- */
-static char * libirc_colorparser_irc2code (const char * source, int strip)
-{
- unsigned int mask = 0, destlen = 0;
- char * destline = 0, *d = 0;
- const char *p;
- int current_bg = 0;
-
- /*
- * There will be two passes. First pass calculates the total length of
- * the destination string. The second pass allocates memory for the string,
- * and fills it.
- */
- while ( destline == 0 ) // destline will be set after the 2nd pass
- {
- if ( destlen > 0 )
- {
- // This is the 2nd pass; allocate memory.
- if ( (destline = malloc (destlen)) == 0 )
- return 0;
-
- d = destline;
- }
-
- for ( p = source; *p; p++ )
- {
- switch (*p)
- {
- case 0x02: // bold
- if ( strip )
- continue;
-
- libirc_colorparser_applymask (&mask, &d, &destlen, LIBIRC_COLORPARSER_BOLD, "[B]", "[/B]");
- break;
-
- case 0x1F: // underline
- if ( strip )
- continue;
-
- libirc_colorparser_applymask (&mask, &d, &destlen, LIBIRC_COLORPARSER_UNDERLINE, "[U]", "[/U]");
- break;
-
- case 0x16: // reverse
- if ( strip )
- continue;
-
- libirc_colorparser_applymask (&mask, &d, &destlen, LIBIRC_COLORPARSER_REVERSE, "[I]", "[/I]");
- break;
-
- case 0x0F: // reset colors
- if ( strip )
- continue;
-
- libirc_colorparser_closetags (&mask, &d, &destlen);
- break;
-
- case 0x03: // set color
- if ( isdigit (p[1]) )
- {
- // Parse
- int bgcolor = -1, color = p[1] - 0x30;
- p++;
-
- if ( isdigit (p[1]) )
- {
- color = color * 10 + (p[1] - 0x30);
- p++;
- }
-
- // If there is a comma, search for the following
- // background color
- if ( p[1] == ',' && isdigit (p[2]) )
- {
- bgcolor = p[2] - 0x30;
- p += 2;
-
- if ( isdigit (p[1]) )
- {
- bgcolor = bgcolor * 10 + (p[1] - 0x30);
- p++;
- }
- }
-
- // Check for range
- if ( color <= LIBIRC_COLORPARSER_MAXCOLORS
- && bgcolor <= LIBIRC_COLORPARSER_MAXCOLORS )
- {
- if ( strip )
- continue;
-
- if ( bgcolor != -1 )
- current_bg = bgcolor;
-
- libirc_colorparser_applycolor (&mask, &d, &destlen, color, current_bg);
- }
- }
- break;
-
- default:
- if ( destline )
- *d++ = *p;
- else
- destlen++;
- break;
- }
- }
-
- // Close all the opened tags
- libirc_colorparser_closetags (&mask, &d, &destlen);
- destlen++; // for 0-terminator
- }
-
- *d = '\0';
- return destline;
-}
-
-
-static int libirc_colorparser_colorlookup (const char * color)
-{
- int i;
- for ( i = 0; color_replacement_table[i]; i++ )
- if ( !strcmp (color, color_replacement_table[i]) )
- return i;
-
- return -1;
-}
-
-
-/*
- * [code] to IRC color conversion.
- */
-char * irc_color_convert_to_mirc (const char * source, void * (*memory_allocator)(size_t))
-{
- unsigned int destlen = 0;
- char * destline = 0, *d = 0;
- const char *p1, *p2, *cur;
-
- /*
- * There will be two passes. First pass calculates the total length of
- * the destination string. The second pass allocates memory for the string,
- * and fills it.
- */
- while ( destline == 0 ) // destline will be set after the 2nd pass
- {
- if ( destlen > 0 )
- {
- // This is the 2nd pass; allocate memory.
- if ( (destline = memory_allocator (destlen)) == 0 )
- return 0;
-
- d = destline;
- }
-
- cur = source;
- while ( (p1 = strchr (cur, '[')) != 0 )
- {
- const char * replacedval = 0;
- p2 = 0;
-
- // Check if the closing bracket is available after p1
- // and the tag length is suitable
- if ( p1[1] != '\0'
- && (p2 = strchr (p1, ']')) != 0
- && (p2 - p1) > 1
- && (p2 - p1) < 31 )
- {
- // Get the tag
- char tagbuf[32];
- int taglen = p2 - p1 - 1;
-
- memcpy (tagbuf, p1 + 1, taglen);
- tagbuf[taglen] = '\0';
-
- if ( !strcmp (tagbuf, "/COLOR") )
- replacedval = "\x0F";
- else if ( strstr (tagbuf, "COLOR=") == tagbuf )
- {
- int color, bgcolor = -2;
- char * bcol;
-
- bcol = strchr (tagbuf + 6, '/');
-
- if ( bcol )
- {
- *bcol++ = '\0';
- bgcolor = libirc_colorparser_colorlookup (bcol);
- }
-
- color = libirc_colorparser_colorlookup (tagbuf + 6);
-
- if ( color != -1 && bgcolor == -2 )
- {
- sprintf (tagbuf, "\x03%02d", color);
- replacedval = tagbuf;
- }
- else if ( color != -1 && bgcolor >= 0 )
- {
- sprintf (tagbuf, "\x03%02d,%02d", color, bgcolor);
- replacedval = tagbuf;
- }
- }
- else if ( !strcmp (tagbuf, "B") || !strcmp (tagbuf, "/B") )
- replacedval = "\x02";
- else if ( !strcmp (tagbuf, "U") || !strcmp (tagbuf, "/U") )
- replacedval = "\x1F";
- else if ( !strcmp (tagbuf, "I") || !strcmp (tagbuf, "/I") )
- replacedval = "\x16";
- }
-
- if ( replacedval )
- {
- // add a part before the tag
- int partlen = p1 - cur;
-
- if ( destline )
- {
- memcpy (d, cur, partlen);
- d += partlen;
- }
- else
- destlen += partlen;
-
- // Add the replacement
- libirc_colorparser_addorcat (&d, &destlen, replacedval);
-
- // And move the pointer
- cur = p2 + 1;
- }
- else
- {
- // add a whole part before the end tag
- int partlen;
-
- if ( !p2 )
- p2 = cur + strlen(cur);
-
- partlen = p2 - cur + 1;
-
- if ( destline )
- {
- memcpy (d, cur, partlen);
- d += partlen;
- }
- else
- destlen += partlen;
-
- // And move the pointer
- cur = p2 + 1;
- }
- }
-
- // Add the rest of string
- libirc_colorparser_addorcat (&d, &destlen, cur);
- destlen++; // for 0-terminator
- }
-
- *d = '\0';
- return destline;
-}
-
-
-char * irc_color_strip_from_mirc (const char * message)
-{
- return libirc_colorparser_irc2code (message, 1);
-}
-
-
-char * irc_color_convert_from_mirc (const char * message)
-{
- return libirc_colorparser_irc2code (message, 0);
-}
diff --git a/external/LibIRC/dcc.c b/external/LibIRC/dcc.c
deleted file mode 100644
index 00ccb5f6..00000000
--- a/external/LibIRC/dcc.c
+++ /dev/null
@@ -1,892 +0,0 @@
-/*
- * Copyright (C) 2004-2012 George Yunaev gyunaev@ulduzsoft.com
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at your
- * option) any later version.
- *
- * This library 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 Lesser General Public
- * License for more details.
- */
-
-#define LIBIRC_DCC_CHAT 1
-#define LIBIRC_DCC_SENDFILE 2
-#define LIBIRC_DCC_RECVFILE 3
-
-
-static irc_dcc_session_t * libirc_find_dcc_session (irc_session_t * session, irc_dcc_t dccid, int lock_list)
-{
- irc_dcc_session_t * s, *found = 0;
-
- if ( lock_list )
- libirc_mutex_lock (&session->mutex_dcc);
-
- for ( s = session->dcc_sessions; s; s = s->next )
- {
- if ( s->id == dccid )
- {
- found = s;
- break;
- }
- }
-
- if ( found == 0 && lock_list )
- libirc_mutex_unlock (&session->mutex_dcc);
-
- return found;
-}
-
-
-static void libirc_dcc_destroy_nolock (irc_session_t * session, irc_dcc_t dccid)
-{
- irc_dcc_session_t * dcc = libirc_find_dcc_session (session, dccid, 0);
-
- if ( dcc )
- {
- if ( dcc->sock >= 0 )
- socket_close (&dcc->sock);
-
- dcc->state = LIBIRC_STATE_REMOVED;
- }
-}
-
-
-static void libirc_remove_dcc_session (irc_session_t * session, irc_dcc_session_t * dcc, int lock_list)
-{
- if ( dcc->sock >= 0 )
- socket_close (&dcc->sock);
-
- if ( dcc->dccsend_file_fp )
- fclose (dcc->dccsend_file_fp);
-
- dcc->dccsend_file_fp = 0;
-
- libirc_mutex_destroy (&dcc->mutex_outbuf);
-
- if ( lock_list )
- libirc_mutex_lock (&session->mutex_dcc);
-
- if ( session->dcc_sessions != dcc )
- {
- irc_dcc_session_t * s;
- for ( s = session->dcc_sessions; s; s = s->next )
- {
- if ( s->next == dcc )
- {
- s->next = dcc->next;
- break;
- }
- }
- }
- else
- session->dcc_sessions = dcc->next;
-
- if ( lock_list )
- libirc_mutex_unlock (&session->mutex_dcc);
-
- free (dcc);
-}
-
-
-static void libirc_dcc_add_descriptors (irc_session_t * ircsession, fd_set *in_set, fd_set *out_set, int * maxfd)
-{
- irc_dcc_session_t * dcc, *dcc_next;
- time_t now = time (0);
-
- libirc_mutex_lock (&ircsession->mutex_dcc);
-
- // Preprocessing DCC list:
- // - ask DCC send callbacks for data;
- // - remove unused DCC structures
- for ( dcc = ircsession->dcc_sessions; dcc; dcc = dcc_next )
- {
- dcc_next = dcc->next;
-
- // Remove timed-out sessions
- if ( (dcc->state == LIBIRC_STATE_CONNECTING
- || dcc->state == LIBIRC_STATE_INIT
- || dcc->state == LIBIRC_STATE_LISTENING)
- && now - dcc->timeout > ircsession->dcc_timeout )
- {
- // Inform the caller about DCC timeout.
- // Do not inform when state is LIBIRC_STATE_INIT - session
- // was initiated from someone else, and callbacks aren't set yet.
- if ( dcc->state != LIBIRC_STATE_INIT )
- {
- libirc_mutex_unlock (&ircsession->mutex_dcc);
-
- if ( dcc->cb )
- (*dcc->cb)(ircsession, dcc->id, LIBIRC_ERR_TIMEOUT, dcc->ctx, 0, 0);
-
- libirc_mutex_lock (&ircsession->mutex_dcc);
- }
-
- libirc_remove_dcc_session (ircsession, dcc, 0);
- }
-
- /*
- * If we're sending file, and the output buffer is empty, we need
- * to provide some data.
- */
- if ( dcc->state == LIBIRC_STATE_CONNECTED
- && dcc->dccmode == LIBIRC_DCC_SENDFILE
- && dcc->dccsend_file_fp
- && dcc->outgoing_offset == 0 )
- {
- int len = fread (dcc->outgoing_buf, 1, sizeof (dcc->outgoing_buf), dcc->dccsend_file_fp);
-
- if ( len <= 0 )
- {
- int err = (len < 0 ? LIBIRC_ERR_READ : 0);
-
- libirc_mutex_unlock (&ircsession->mutex_dcc);
-
- (*dcc->cb)(ircsession, dcc->id, err, dcc->ctx, 0, 0);
- libirc_mutex_lock (&ircsession->mutex_dcc);
- libirc_dcc_destroy_nolock (ircsession, dcc->id);
- }
- else
- dcc->outgoing_offset = len;
- }
-
- // Clean up unused sessions
- if ( dcc->state == LIBIRC_STATE_REMOVED )
- libirc_remove_dcc_session (ircsession, dcc, 0);
- }
-
- for ( dcc = ircsession->dcc_sessions; dcc; dcc = dcc->next )
- {
- switch (dcc->state)
- {
- case LIBIRC_STATE_LISTENING:
- // While listening, only in_set descriptor should be set
- libirc_add_to_set (dcc->sock, in_set, maxfd);
- break;
-
- case LIBIRC_STATE_CONNECTING:
- // While connection, only out_set descriptor should be set
- libirc_add_to_set (dcc->sock, out_set, maxfd);
- break;
-
- case LIBIRC_STATE_CONNECTED:
- // Add input descriptor if there is space in input buffer
- // and it is DCC chat (during DCC send, there is nothing to recv)
- if ( dcc->incoming_offset < sizeof(dcc->incoming_buf) - 1 )
- libirc_add_to_set (dcc->sock, in_set, maxfd);
-
- // Add output descriptor if there is something in output buffer
- libirc_mutex_lock (&dcc->mutex_outbuf);
-
- if ( dcc->outgoing_offset > 0 )
- libirc_add_to_set (dcc->sock, out_set, maxfd);
-
- libirc_mutex_unlock (&dcc->mutex_outbuf);
- break;
-
- case LIBIRC_STATE_CONFIRM_SIZE:
- /*
- * If we're receiving file, then WE should confirm the transferred
- * part (so we have to sent data). But if we're sending the file,
- * then RECEIVER should confirm the packet, so we have to receive
- * data.
- *
- * We don't need to LOCK_DCC_OUTBUF - during file transfer, buffers
- * can't change asynchronously.
- */
- if ( dcc->dccmode == LIBIRC_DCC_RECVFILE && dcc->outgoing_offset > 0 )
- libirc_add_to_set (dcc->sock, out_set, maxfd);
-
- if ( dcc->dccmode == LIBIRC_DCC_SENDFILE && dcc->incoming_offset < 4 )
- libirc_add_to_set (dcc->sock, in_set, maxfd);
- }
- }
-
- libirc_mutex_unlock (&ircsession->mutex_dcc);
-}
-
-
-static void libirc_dcc_process_descriptors (irc_session_t * ircsession, fd_set *in_set, fd_set *out_set)
-{
- irc_dcc_session_t * dcc;
-
- /*
- * We need to use such a complex scheme here, because on every callback
- * a number of DCC sessions could be destroyed.
- */
- libirc_mutex_lock (&ircsession->mutex_dcc);
-
- for ( dcc = ircsession->dcc_sessions; dcc; dcc = dcc->next )
- {
- if ( dcc->state == LIBIRC_STATE_LISTENING
- && FD_ISSET (dcc->sock, in_set) )
- {
- socklen_t len = sizeof(dcc->remote_addr);
- int nsock, err = 0;
-
- // New connection is available; accept it.
- if ( socket_accept (&dcc->sock, (socket_t*)&nsock, (struct sockaddr *) &dcc->remote_addr, &len) )
- err = LIBIRC_ERR_ACCEPT;
-
- // On success, change the active socket and change the state
- if ( err == 0 )
- {
- // close the listen socket, and replace it by a newly
- // accepted
- socket_close (&dcc->sock);
- dcc->sock = nsock;
- dcc->state = LIBIRC_STATE_CONNECTED;
- }
-
- // If this is DCC chat, inform the caller about accept()
- // success or failure.
- // Otherwise (DCC send) there is no reason.
- if ( dcc->dccmode == LIBIRC_DCC_CHAT )
- {
- libirc_mutex_unlock (&ircsession->mutex_dcc);
- (*dcc->cb)(ircsession, dcc->id, err, dcc->ctx, 0, 0);
- libirc_mutex_lock (&ircsession->mutex_dcc);
- }
-
- if ( err )
- libirc_dcc_destroy_nolock (ircsession, dcc->id);
- }
-
- if ( dcc->state == LIBIRC_STATE_CONNECTING
- && FD_ISSET (dcc->sock, out_set) )
- {
- // Now we have to determine whether the socket is connected
- // or the connect is failed
- struct sockaddr_in saddr;
- socklen_t slen = sizeof(saddr);
- int err = 0;
-
- if ( getpeername (dcc->sock, (struct sockaddr*)&saddr, &slen) < 0 )
- err = LIBIRC_ERR_CONNECT;
-
- // On success, change the state
- if ( err == 0 )
- dcc->state = LIBIRC_STATE_CONNECTED;
-
- // If this is DCC chat, inform the caller about connect()
- // success or failure.
- // Otherwise (DCC send) there is no reason.
- if ( dcc->dccmode == LIBIRC_DCC_CHAT )
- {
- libirc_mutex_unlock (&ircsession->mutex_dcc);
- (*dcc->cb)(ircsession, dcc->id, err, dcc->ctx, 0, 0);
- libirc_mutex_lock (&ircsession->mutex_dcc);
- }
-
- if ( err )
- libirc_dcc_destroy_nolock (ircsession, dcc->id);
- }
-
- if ( dcc->state == LIBIRC_STATE_CONNECTED
- || dcc->state == LIBIRC_STATE_CONFIRM_SIZE )
- {
- if ( FD_ISSET (dcc->sock, in_set) )
- {
- int length, offset = 0, err = 0;
-
- unsigned int amount = sizeof (dcc->incoming_buf) - dcc->incoming_offset;
-
- length = socket_recv (&dcc->sock, dcc->incoming_buf + dcc->incoming_offset, amount);
-
- if ( length < 0 )
- {
- err = LIBIRC_ERR_READ;
- }
- else if ( length == 0 )
- {
- err = LIBIRC_ERR_CLOSED;
-
- if ( dcc->dccsend_file_fp )
- {
- fclose (dcc->dccsend_file_fp);
- dcc->dccsend_file_fp = 0;
- }
- }
- else
- {
- dcc->incoming_offset += length;
-
- if ( dcc->dccmode != LIBIRC_DCC_CHAT )
- offset = dcc->incoming_offset;
- else
- offset = libirc_findcrorlf (dcc->incoming_buf, dcc->incoming_offset);
-
- /*
- * In LIBIRC_STATE_CONFIRM_SIZE state we don't call any
- * callbacks (except there is an error). We just receive
- * the data, and compare it with the amount sent.
- */
- if ( dcc->state == LIBIRC_STATE_CONFIRM_SIZE )
- {
- if ( dcc->dccmode != LIBIRC_DCC_SENDFILE )
- abort();
-
- if ( dcc->incoming_offset == 4 )
- {
- // The order is big-endian
- const unsigned char * bptr = (const unsigned char *) dcc->incoming_buf;
- unsigned int received_size = (bptr[0] << 24) | (bptr[1] << 16) | (bptr[2] << 8) | bptr[3];
-
- // Sent size confirmed
- if ( dcc->file_confirm_offset == received_size )
- {
- dcc->state = LIBIRC_STATE_CONNECTED;
- dcc->incoming_offset = 0;
- }
- else
- err = LIBIRC_ERR_WRITE;
- }
- }
- else
- {
- /*
- * If it is DCC_CHAT, we send a 0-terminated string
- * (which is smaller than offset). Otherwise we send
- * a full buffer.
- */
- libirc_mutex_unlock (&ircsession->mutex_dcc);
-
- if ( dcc->dccmode != LIBIRC_DCC_CHAT )
- {
- if ( dcc->dccmode != LIBIRC_DCC_RECVFILE )
- abort();
-
- (*dcc->cb)(ircsession, dcc->id, err, dcc->ctx, dcc->incoming_buf, offset);
-
- /*
- * If the session is not terminated in callback,
- * put the sent amount into the sent_packet_size_net_byteorder
- */
- if ( dcc->state != LIBIRC_STATE_REMOVED )
- {
- dcc->state = LIBIRC_STATE_CONFIRM_SIZE;
- dcc->file_confirm_offset += offset;
-
- // Store as big endian
- dcc->outgoing_buf[0] = (char) dcc->file_confirm_offset >> 24;
- dcc->outgoing_buf[1] = (char) dcc->file_confirm_offset >> 16;
- dcc->outgoing_buf[2] = (char) dcc->file_confirm_offset >> 8;
- dcc->outgoing_buf[3] = (char) dcc->file_confirm_offset;
- dcc->outgoing_offset = 4;
- }
- }
- else
- (*dcc->cb)(ircsession, dcc->id, err, dcc->ctx, dcc->incoming_buf, strlen(dcc->incoming_buf));
-
- libirc_mutex_lock (&ircsession->mutex_dcc);
-
- if ( dcc->incoming_offset - offset > 0 )
- memmove (dcc->incoming_buf, dcc->incoming_buf + offset, dcc->incoming_offset - offset);
-
- dcc->incoming_offset -= offset;
- }
- }
-
- /*
- * If error arises somewhere above, we inform the caller
- * of failure, and destroy this session.
- */
- if ( err )
- {
- libirc_mutex_unlock (&ircsession->mutex_dcc);
- (*dcc->cb)(ircsession, dcc->id, err, dcc->ctx, 0, 0);
- libirc_mutex_lock (&ircsession->mutex_dcc);
- libirc_dcc_destroy_nolock (ircsession, dcc->id);
- }
- }
-
- /*
- * Session might be closed (with sock = -1) after the in_set
- * processing, so before out_set processing we should check
- * for this case
- */
- if ( dcc->state == LIBIRC_STATE_REMOVED )
- continue;
-
- /*
- * Write bit set - we can send() something, and it won't block.
- */
- if ( FD_ISSET (dcc->sock, out_set) )
- {
- int length, offset, err = 0;
-
- /*
- * Because in some cases outgoing_buf could be changed
- * asynchronously (by another thread), we should lock
- * it.
- */
- libirc_mutex_lock (&dcc->mutex_outbuf);
-
- offset = dcc->outgoing_offset;
-
- if ( offset > 0 )
- {
- length = socket_send (&dcc->sock, dcc->outgoing_buf, offset);
-
- if ( length < 0 )
- err = LIBIRC_ERR_WRITE;
- else if ( length == 0 )
- err = LIBIRC_ERR_CLOSED;
- else
- {
- /*
- * If this was DCC_SENDFILE, and we just sent a packet,
- * change the state to wait for confirmation (and store
- * sent packet size)
- */
- if ( dcc->state == LIBIRC_STATE_CONNECTED
- && dcc->dccmode == LIBIRC_DCC_SENDFILE )
- {
- dcc->file_confirm_offset += offset;
- dcc->state = LIBIRC_STATE_CONFIRM_SIZE;
-
- libirc_mutex_unlock (&ircsession->mutex_dcc);
- libirc_mutex_unlock (&dcc->mutex_outbuf);
- (*dcc->cb)(ircsession, dcc->id, err, dcc->ctx, 0, offset);
- libirc_mutex_lock (&ircsession->mutex_dcc);
- libirc_mutex_lock (&dcc->mutex_outbuf);
- }
-
- if ( dcc->outgoing_offset - length > 0 )
- memmove (dcc->outgoing_buf, dcc->outgoing_buf + length, dcc->outgoing_offset - length);
-
- dcc->outgoing_offset -= length;
-
- /*
- * If we just sent the confirmation data, change state
- * back.
- */
- if ( dcc->state == LIBIRC_STATE_CONFIRM_SIZE
- && dcc->dccmode == LIBIRC_DCC_RECVFILE
- && dcc->outgoing_offset == 0 )
- {
- /*
- * If the file is already received, we should inform
- * the caller, and close the session.
- */
- if ( dcc->received_file_size == dcc->file_confirm_offset )
- {
- libirc_mutex_unlock (&ircsession->mutex_dcc);
- libirc_mutex_unlock (&dcc->mutex_outbuf);
- (*dcc->cb)(ircsession, dcc->id, 0, dcc->ctx, 0, 0);
- libirc_dcc_destroy_nolock (ircsession, dcc->id);
- }
- else
- {
- /* Continue to receive the file */
- dcc->state = LIBIRC_STATE_CONNECTED;
- }
- }
- }
- }
-
- libirc_mutex_unlock (&dcc->mutex_outbuf);
-
- /*
- * If error arises somewhere above, we inform the caller
- * of failure, and destroy this session.
- */
- if ( err )
- {
- libirc_mutex_unlock (&ircsession->mutex_dcc);
- (*dcc->cb)(ircsession, dcc->id, err, dcc->ctx, 0, 0);
- libirc_mutex_lock (&ircsession->mutex_dcc);
-
- libirc_dcc_destroy_nolock (ircsession, dcc->id);
- }
- }
- }
- }
-
- libirc_mutex_unlock (&ircsession->mutex_dcc);
-}
-
-
-static int libirc_new_dcc_session (irc_session_t * session, unsigned long ip, unsigned short port, int dccmode, void * ctx, irc_dcc_session_t ** pdcc)
-{
- irc_dcc_session_t * dcc = malloc (sizeof(irc_dcc_session_t));
-
- if ( !dcc )
- return LIBIRC_ERR_NOMEM;
-
- // setup
- memset (dcc, 0, sizeof(irc_dcc_session_t));
-
- dcc->dccsend_file_fp = 0;
-
- if ( libirc_mutex_init (&dcc->mutex_outbuf) )
- goto cleanup_exit_error;
-
- if ( socket_create (PF_INET, SOCK_STREAM, &dcc->sock) )
- goto cleanup_exit_error;
-
- if ( !ip )
- {
- unsigned long arg = 1;
-
- setsockopt (dcc->sock, SOL_SOCKET, SO_REUSEADDR, (char*)&arg, sizeof(arg));
-
-#if defined (ENABLE_IPV6)
- if ( session->flags & SESSIONFL_USES_IPV6 )
- {
- struct sockaddr_in6 saddr6;
-
- memset (&saddr6, 0, sizeof(saddr6));
- saddr6.sin6_family = AF_INET6;
- memcpy (&saddr6.sin6_addr, &session->local_addr6, sizeof(session->local_addr6));
- saddr6.sin6_port = htons (0);
-
- if ( bind (dcc->sock, (struct sockaddr *) &saddr6, sizeof(saddr6)) < 0 )
- goto cleanup_exit_error;
- }
- else
-#endif
- {
- struct sockaddr_in saddr;
- memset (&saddr, 0, sizeof(saddr));
- saddr.sin_family = AF_INET;
- memcpy (&saddr.sin_addr, &session->local_addr, sizeof(session->local_addr));
- saddr.sin_port = htons (0);
-
- if ( bind (dcc->sock, (struct sockaddr *) &saddr, sizeof(saddr)) < 0 )
- goto cleanup_exit_error;
- }
-
- if ( listen (dcc->sock, 5) < 0 )
- goto cleanup_exit_error;
-
- dcc->state = LIBIRC_STATE_LISTENING;
- }
- else
- {
- // make socket non-blocking, so connect() call won't block
- if ( socket_make_nonblocking (&dcc->sock) )
- goto cleanup_exit_error;
-
- memset (&dcc->remote_addr, 0, sizeof(dcc->remote_addr));
- dcc->remote_addr.sin_family = AF_INET;
- dcc->remote_addr.sin_addr.s_addr = htonl (ip); // what idiot came up with idea to send IP address in host-byteorder?
- dcc->remote_addr.sin_port = htons(port);
-
- dcc->state = LIBIRC_STATE_INIT;
- }
-
- dcc->dccmode = dccmode;
- dcc->ctx = ctx;
- time (&dcc->timeout);
-
- // and store it
- libirc_mutex_lock (&session->mutex_dcc);
-
- dcc->id = session->dcc_last_id++;
- dcc->next = session->dcc_sessions;
- session->dcc_sessions = dcc;
-
- libirc_mutex_unlock (&session->mutex_dcc);
-
- *pdcc = dcc;
- return 0;
-
-cleanup_exit_error:
- if ( dcc->sock >= 0 )
- socket_close (&dcc->sock);
-
- free (dcc);
- return LIBIRC_ERR_SOCKET;
-}
-
-
-int irc_dcc_destroy (irc_session_t * session, irc_dcc_t dccid)
-{
- // This function doesn't actually destroy the session; it just changes
- // its state to "removed" and closes the socket. The memory is actually
- // freed after the processing loop.
- irc_dcc_session_t * dcc = libirc_find_dcc_session (session, dccid, 1);
-
- if ( !dcc )
- return 1;
-
- if ( dcc->sock >= 0 )
- socket_close (&dcc->sock);
-
- dcc->state = LIBIRC_STATE_REMOVED;
-
- libirc_mutex_unlock (&session->mutex_dcc);
- return 0;
-}
-
-
-int irc_dcc_chat (irc_session_t * session, void * ctx, const char * nick, irc_dcc_callback_t callback, irc_dcc_t * dccid)
-{
- struct sockaddr_in saddr;
- socklen_t len = sizeof(saddr);
- char cmdbuf[128], notbuf[128];
- irc_dcc_session_t * dcc;
- int err;
-
- if ( session->state != LIBIRC_STATE_CONNECTED )
- {
- session->lasterror = LIBIRC_ERR_STATE;
- return 1;
- }
-
- err = libirc_new_dcc_session (session, 0, 0, LIBIRC_DCC_CHAT, ctx, &dcc);
-
- if ( err )
- {
- session->lasterror = err;
- return 1;
- }
-
- if ( getsockname (dcc->sock, (struct sockaddr*) &saddr, &len) < 0 )
- {
- session->lasterror = LIBIRC_ERR_SOCKET;
- libirc_remove_dcc_session (session, dcc, 1);
- return 1;
- }
-
- sprintf (notbuf, "DCC Chat (%s)", inet_ntoa (saddr.sin_addr));
- sprintf (cmdbuf, "DCC CHAT chat %lu %u", (unsigned long) ntohl (saddr.sin_addr.s_addr), ntohs (saddr.sin_port));
-
- if ( irc_cmd_notice (session, nick, notbuf)
- || irc_cmd_ctcp_request (session, nick, cmdbuf) )
- {
- libirc_remove_dcc_session (session, dcc, 1);
- return 1;
- }
-
- *dccid = dcc->id;
- dcc->cb = callback;
- dcc->dccmode = LIBIRC_DCC_CHAT;
-
- return 0;
-}
-
-
-int irc_dcc_msg (irc_session_t * session, irc_dcc_t dccid, const char * text)
-{
- irc_dcc_session_t * dcc = libirc_find_dcc_session (session, dccid, 1);
-
- if ( !dcc )
- return 1;
-
- if ( dcc->dccmode != LIBIRC_DCC_CHAT )
- {
- session->lasterror = LIBIRC_ERR_INVAL;
- libirc_mutex_unlock (&session->mutex_dcc);
- return 1;
- }
-
- if ( (strlen(text) + 2) >= (sizeof(dcc->outgoing_buf) - dcc->outgoing_offset) )
- {
- session->lasterror = LIBIRC_ERR_NOMEM;
- libirc_mutex_unlock (&session->mutex_dcc);
- return 1;
- }
-
- libirc_mutex_lock (&dcc->mutex_outbuf);
-
- strcpy (dcc->outgoing_buf + dcc->outgoing_offset, text);
- dcc->outgoing_offset += strlen (text);
- dcc->outgoing_buf[dcc->outgoing_offset++] = 0x0D;
- dcc->outgoing_buf[dcc->outgoing_offset++] = 0x0A;
-
- libirc_mutex_unlock (&dcc->mutex_outbuf);
- libirc_mutex_unlock (&session->mutex_dcc);
-
- return 0;
-}
-
-
-static void libirc_dcc_request (irc_session_t * session, const char * nick, const char * req)
-{
- char filenamebuf[256];
- unsigned long ip, size;
- unsigned short port;
-
- if ( sscanf (req, "DCC CHAT chat %lu %hu", &ip, &port) == 2 )
- {
- if ( session->callbacks.event_dcc_chat_req )
- {
- irc_dcc_session_t * dcc;
-
- int err = libirc_new_dcc_session (session, ip, port, LIBIRC_DCC_CHAT, 0, &dcc);
- if ( err )
- {
- session->lasterror = err;
- return;
- }
-
- (*session->callbacks.event_dcc_chat_req) (session,
- nick,
- inet_ntoa (dcc->remote_addr.sin_addr),
- dcc->id);
- }
-
- return;
- }
- else if ( sscanf (req, "DCC SEND %s %lu %hu %lu", filenamebuf, &ip, &port, &size) == 4 )
- {
- if ( session->callbacks.event_dcc_send_req )
- {
- irc_dcc_session_t * dcc;
-
- int err = libirc_new_dcc_session (session, ip, port, LIBIRC_DCC_RECVFILE, 0, &dcc);
- if ( err )
- {
- session->lasterror = err;
- return;
- }
-
- (*session->callbacks.event_dcc_send_req) (session,
- nick,
- inet_ntoa (dcc->remote_addr.sin_addr),
- filenamebuf,
- size,
- dcc->id);
-
- dcc->received_file_size = size;
- }
-
- return;
- }
-#if defined (ENABLE_DEBUG)
- fprintf (stderr, "BUG: Unhandled DCC message: %s\n", req);
- abort();
-#endif
-}
-
-
-int irc_dcc_accept (irc_session_t * session, irc_dcc_t dccid, void * ctx, irc_dcc_callback_t callback)
-{
- irc_dcc_session_t * dcc = libirc_find_dcc_session (session, dccid, 1);
-
- if ( !dcc )
- return 1;
-
- if ( dcc->state != LIBIRC_STATE_INIT )
- {
- session->lasterror = LIBIRC_ERR_STATE;
- libirc_mutex_unlock (&session->mutex_dcc);
- return 1;
- }
-
- dcc->cb = callback;
- dcc->ctx = ctx;
-
- // Initiate the connect
- if ( socket_connect (&dcc->sock, (struct sockaddr *) &dcc->remote_addr, sizeof(dcc->remote_addr)) )
- {
- libirc_dcc_destroy_nolock (session, dccid);
- libirc_mutex_unlock (&session->mutex_dcc);
- session->lasterror = LIBIRC_ERR_CONNECT;
- return 1;
- }
-
- dcc->state = LIBIRC_STATE_CONNECTING;
- libirc_mutex_unlock (&session->mutex_dcc);
- return 0;
-}
-
-
-int irc_dcc_decline (irc_session_t * session, irc_dcc_t dccid)
-{
- irc_dcc_session_t * dcc = libirc_find_dcc_session (session, dccid, 1);
-
- if ( !dcc )
- return 1;
-
- if ( dcc->state != LIBIRC_STATE_INIT )
- {
- session->lasterror = LIBIRC_ERR_STATE;
- libirc_mutex_unlock (&session->mutex_dcc);
- return 1;
- }
-
- libirc_dcc_destroy_nolock (session, dccid);
- libirc_mutex_unlock (&session->mutex_dcc);
- return 0;
-}
-
-
-int irc_dcc_sendfile (irc_session_t * session, void * ctx, const char * nick, const char * filename, irc_dcc_callback_t callback, irc_dcc_t * dccid)
-{
- struct sockaddr_in saddr;
- socklen_t len = sizeof(saddr);
- char cmdbuf[128], notbuf[128];
- irc_dcc_session_t * dcc;
- const char * p;
- int err;
- long filesize;
-
- if ( !session || !dccid || !filename || !callback )
- {
- session->lasterror = LIBIRC_ERR_INVAL;
- return 1;
- }
-
- if ( session->state != LIBIRC_STATE_CONNECTED )
- {
- session->lasterror = LIBIRC_ERR_STATE;
- return 1;
- }
-
- if ( (err = libirc_new_dcc_session (session, 0, 0, LIBIRC_DCC_SENDFILE, ctx, &dcc)) != 0 )
- {
- session->lasterror = err;
- return 1;
- }
-
- if ( (dcc->dccsend_file_fp = fopen (filename, "rb")) == 0 )
- {
- libirc_remove_dcc_session (session, dcc, 1);
- session->lasterror = LIBIRC_ERR_OPENFILE;
- return 1;
- }
-
- /* Get file length */
- if ( fseek (dcc->dccsend_file_fp, 0, SEEK_END)
- || (filesize = ftell (dcc->dccsend_file_fp)) == -1
- || fseek (dcc->dccsend_file_fp, 0, SEEK_SET) )
- {
- libirc_remove_dcc_session (session, dcc, 1);
- session->lasterror = LIBIRC_ERR_NODCCSEND;
- return 1;
- }
-
- if ( getsockname (dcc->sock, (struct sockaddr*) &saddr, &len) < 0 )
- {
- libirc_remove_dcc_session (session, dcc, 1);
- session->lasterror = LIBIRC_ERR_SOCKET;
- return 1;
- }
-
- // Remove path from the filename
- if ( (p = strrchr (filename, '\\')) == 0
- && (p = strrchr (filename, '/')) == 0 )
- p = filename;
- else
- p++; // skip directory slash
-
- sprintf (notbuf, "DCC Send %s (%s)", p, inet_ntoa (saddr.sin_addr));
- sprintf (cmdbuf, "DCC SEND %s %lu %u %ld", p, (unsigned long) ntohl (saddr.sin_addr.s_addr), ntohs (saddr.sin_port), filesize);
-
- if ( irc_cmd_notice (session, nick, notbuf)
- || irc_cmd_ctcp_request (session, nick, cmdbuf) )
- {
- libirc_remove_dcc_session (session, dcc, 1);
- return 1;
- }
-
- *dccid = dcc->id;
- dcc->cb = callback;
-
- return 0;
-}
diff --git a/external/LibIRC/dcc.h b/external/LibIRC/dcc.h
deleted file mode 100644
index deb3355f..00000000
--- a/external/LibIRC/dcc.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2004-2012 George Yunaev gyunaev@ulduzsoft.com
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at your
- * option) any later version.
- *
- * This library 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 Lesser General Public
- * License for more details.
- */
-
-#ifndef INCLUDE_IRC_DCC_H
-#define INCLUDE_IRC_DCC_H
-
-
-/*
- * This structure keeps the state of a single DCC connection.
- */
-struct irc_dcc_session_s
-{
- irc_dcc_session_t * next;
-
- irc_dcc_t id;
- void * ctx;
- socket_t sock; /*!< DCC socket */
- int dccmode; /*!< Boolean value to differ chat vs send
- requests. Changes the cb behavior - when
- it is chat, data is sent by lines with
- stripped CRLFs. In file mode, the data
- is sent as-is */
- int state;
- time_t timeout;
-
- FILE * dccsend_file_fp;
- unsigned int received_file_size;
- unsigned int file_confirm_offset;
-
- struct sockaddr_in remote_addr;
-
- char incoming_buf[LIBIRC_DCC_BUFFER_SIZE];
- unsigned int incoming_offset;
-
- char outgoing_buf[LIBIRC_DCC_BUFFER_SIZE];
- unsigned int outgoing_offset;
- port_mutex_t mutex_outbuf;
-
- irc_dcc_callback_t cb;
-};
-
-
-#endif /* INCLUDE_IRC_DCC_H */
diff --git a/external/LibIRC/errors.c b/external/LibIRC/errors.c
deleted file mode 100644
index 6533b898..00000000
--- a/external/LibIRC/errors.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2004-2012 George Yunaev gyunaev@ulduzsoft.com
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at your
- * option) any later version.
- *
- * This library 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 Lesser General Public
- * License for more details.
- */
-
-static const char * libirc_strerror[LIBIRC_ERR_MAX] =
-{
- "No error",
- "Invalid argument",
- "Host not resolved",
- "Socket error",
- "Could not connect",
- "Remote connection closed",
- "Out of memory",
- "Could not accept new connection",
- "Object not found",
- "Could not DCC send this object",
- "Read error",
- "Write error",
- "Illegal operation for this state",
- "Timeout error",
- "Could not open file",
- "IRC session terminated",
- "IPv6 not supported",
- "SSL not supported",
- "SSL initialization failed",
- "SSL connection failed",
- "SSL certificate verify failed",
-};
-
-
-int irc_errno (irc_session_t * session)
-{
- return session->lasterror;
-}
-
-
-const char * irc_strerror (int ircerrno)
-{
- if ( ircerrno >= 0 && ircerrno < LIBIRC_ERR_MAX )
- return libirc_strerror[ircerrno];
- else
- return "Invalid irc_errno value";
-}
-
diff --git a/external/LibIRC/libircclient.c b/external/LibIRC/libircclient.c
deleted file mode 100644
index caf16b1f..00000000
--- a/external/LibIRC/libircclient.c
+++ /dev/null
@@ -1,1258 +0,0 @@
-/*
- * Copyright (C) 2004-2012 George Yunaev gyunaev@ulduzsoft.com
- *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or (at your
- * option) any later version.
- *
- * This library 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 Lesser General Public
- * License for more details.
- */
-
-#define IS_DEBUG_ENABLED(s) ((s)->options & LIBIRC_OPTION_DEBUG)
-
-#include "portable.c"
-#include "sockets.c"
-
-#include "libircclient.h"
-#include "session.h"
-
-#include "utils.c"
-#include "errors.c"
-#include "colors.c"
-#include "dcc.c"
-#include "ssl.c"
-
-
-#ifdef _MSC_VER
- /*
- * The debugger of MSVC 2005 does not like strdup.
- * It complains about heap corruption when free is called.
- * Use _strdup instead.
- */
- #undef strdup
- #define strdup _strdup
-#endif
-
-
-irc_session_t * irc_create_session (irc_callbacks_t * callbacks)
-{
- irc_session_t * session = malloc (sizeof(irc_session_t));
-
- if ( !session )
- return 0;
-
- memset (session, 0, sizeof(irc_session_t));
- session->sock = -1;
-
- if ( libirc_mutex_init (&session->mutex_session)
- || libirc_mutex_init (&session->mutex_dcc) )
- {
- free (session);
- return 0;
- }
-
- session->dcc_last_id = 1;
- session->dcc_timeout = 60;
-
- memcpy (&session->callbacks, callbacks, sizeof(irc_callbacks_t));
-
- if ( !session->callbacks.event_ctcp_req )
- session->callbacks.event_ctcp_req = libirc_event_ctcp_internal;
-
- return session;
-}
-
-static void free_ircsession_strings (irc_session_t * session)
-{
- if ( session->realname )
- free (session->realname);
-
- if ( session->username )
- free (session->username);
-
- if ( session->nick )
- free (session->nick);
-
- if ( session->server )
- free (session->server);
-
- if ( session->server_password )
- free (session->server_password);
-
- session->realname = 0;
- session->username = 0;
- session->nick = 0;
- session->server = 0;
- session->server_password = 0;
-}
-
-void irc_destroy_session (irc_session_t * session)
-{
- free_ircsession_strings( session );
-
- // The CTCP VERSION must be freed only now
- if ( session->ctcp_version )
- free (session->ctcp_version);
-
- if ( session->sock >= 0 )
- socket_close (&session->sock);
-
-#if defined (ENABLE_THREADS)
- libirc_mutex_destroy (&session->mutex_session);
-#endif
-
-#if defined (ENABLE_SSL)
- if ( session->ssl )
- SSL_free( session->ssl );
-#endif
-
- /*
- * delete DCC data
- * libirc_remove_dcc_session removes the DCC session from the list.
- */
- while ( session->dcc_sessions )
- libirc_remove_dcc_session (session, session->dcc_sessions, 0);
-
- libirc_mutex_destroy (&session->mutex_dcc);
-
- free (session);
-}
-
-
-int irc_connect (irc_session_t * session,
- const char * server,
- unsigned short port,
- const char * server_password,
- const char * nick,
- const char * username,
- const char * realname)
-{
- struct sockaddr_in saddr;
- char * p;
-
- // Check and copy all the specified fields
- if ( !server || !nick )
- {
- session->lasterror = LIBIRC_ERR_INVAL;
- return 1;
- }
-
- if ( session->state != LIBIRC_STATE_INIT )
- {
- session->lasterror = LIBIRC_ERR_STATE;
- return 1;
- }
-
- // Free the strings if defined; may be the case when the session is reused after the connection fails
- free_ircsession_strings( session );
-
- // Handle the server # prefix (SSL)
- if ( server[0] == SSL_PREFIX )
- {
-#if defined (ENABLE_SSL)
- server++;
- session->flags |= SESSIONFL_SSL_CONNECTION;
-#else
- session->lasterror = LIBIRC_ERR_SSL_NOT_SUPPORTED;
- return 1;
-#endif
- }
-
- if ( username )
- session->username = strdup (username);
-
- if ( server_password )
- session->server_password = strdup (server_password);
-
- if ( realname )
- session->realname = strdup (realname);
-
- session->nick = strdup (nick);
- session->server = strdup (server);
-
- // If port number is zero and server contains the port, parse it
- if ( port == 0 && (p = strchr( session->server, ':' )) != 0 )
- {
- // Terminate the string and parse the port number
- *p++ = '\0';
- port = atoi( p );
- }
-
- // IPv4 address resolving
- memset( &saddr, 0, sizeof(saddr) );
- saddr.sin_family = AF_INET;
- saddr.sin_port = htons (port);
- saddr.sin_addr.s_addr = inet_addr( session->server );
-
- if ( saddr.sin_addr.s_addr == INADDR_NONE )
- {
- struct hostent *hp;
-#if defined HAVE_GETHOSTBYNAME_R
- int tmp_errno;
- struct hostent tmp_hostent;
- char buf[2048];
-
- if ( gethostbyname_r (session->server, &tmp_hostent, buf, sizeof(buf), &hp, &tmp_errno) )
- hp = 0;
-#else
- hp = gethostbyname (session->server);
-#endif // HAVE_GETHOSTBYNAME_R
- if ( !hp )
- {
- session->lasterror = LIBIRC_ERR_RESOLV;
- return 1;
- }
-
- memcpy (&saddr.sin_addr, hp->h_addr, (size_t) hp->h_length);
- }
-
- // create the IRC server socket
- if ( socket_create( PF_INET, SOCK_STREAM, &session->sock)
- || socket_make_nonblocking (&session->sock) )
- {
- session->lasterror = LIBIRC_ERR_SOCKET;
- return 1;
- }
-
-#if defined (ENABLE_SSL)
- // Init the SSL stuff
- if ( session->flags & SESSIONFL_SSL_CONNECTION )
- {
- int rc = ssl_init( session );
-
- if ( rc != 0 )
- {
- session->lasterror = rc;
- return 1;
- }
- }
-#endif
-
- // and connect to the IRC server
- if ( socket_connect (&session->sock, (struct sockaddr *) &saddr, sizeof(saddr)) )
- {
- session->lasterror = LIBIRC_ERR_CONNECT;
- return 1;
- }
-
- session->state = LIBIRC_STATE_CONNECTING;
- session->flags = SESSIONFL_USES_IPV6; // reset in case of reconnect
- return 0;
-}
-
-
-int irc_connect6 (irc_session_t * session,
- const char * server,
- unsigned short port,
- const char * server_password,
- const char * nick,
- const char * username,
- const char * realname)
-{
-#if defined (ENABLE_IPV6)
- struct sockaddr_in6 saddr;
- struct addrinfo ainfo, *res = NULL;
- char portStr[32], *p;
-#if defined (_WIN32)
- int addrlen = sizeof(saddr);
- HMODULE hWsock;
- getaddrinfo_ptr_t getaddrinfo_ptr;
- freeaddrinfo_ptr_t freeaddrinfo_ptr;
- int resolvesuccess = 0;
-#endif
-
- // Check and copy all the specified fields
- if ( !server || !nick )
- {
- session->lasterror = LIBIRC_ERR_INVAL;
- return 1;
- }
-
- if ( session->state != LIBIRC_STATE_INIT )
- {
- session->lasterror = LIBIRC_ERR_STATE;
- return 1;
- }
-
- // Free the strings if defined; may be the case when the session is reused after the connection fails
- free_ircsession_strings( session );
-
- // Handle the server # prefix (SSL)
- if ( server[0] == SSL_PREFIX )
- {
-#if defined (ENABLE_SSL)
- server++;
- session->flags |= SESSIONFL_SSL_CONNECTION;
-#else
- session->lasterror = LIBIRC_ERR_SSL_NOT_SUPPORTED;
- return 1;
-#endif
- }
-
- if ( username )
- session->username = strdup (username);
-
- if ( server_password )
- session->server_password = strdup (server_password);
-
- if ( realname )
- session->realname = strdup (realname);
-
- session->nick = strdup (nick);
- session->server = strdup (server);
-
- // If port number is zero and server contains the port, parse it
- if ( port == 0 && (p = strchr( session->server, ':' )) != 0 )
- {
- // Terminate the string and parse the port number
- *p++ = '\0';
- port = atoi( p );
- }
-
- memset( &saddr, 0, sizeof(saddr) );
- saddr.sin6_family = AF_INET6;
- saddr.sin6_port = htons (port);
-
- sprintf( portStr, "%u", (unsigned)port );
-
-#if defined (_WIN32)
- if ( WSAStringToAddressA( (LPSTR)session->server, AF_INET6, NULL, (struct sockaddr *)&saddr, &addrlen ) == SOCKET_ERROR )
- {
- hWsock = LoadLibraryA("ws2_32");
-
- if (hWsock)
- {
- /* Determine functions at runtime, because windows systems < XP do not
- * support getaddrinfo. */
- getaddrinfo_ptr = (getaddrinfo_ptr_t)GetProcAddress(hWsock, "getaddrinfo");
- freeaddrinfo_ptr = (freeaddrinfo_ptr_t)GetProcAddress(hWsock, "freeaddrinfo");
-
- if (getaddrinfo_ptr && freeaddrinfo_ptr)
- {
- memset(&ainfo, 0, sizeof(ainfo));
- ainfo.ai_family = AF_INET6;
- ainfo.ai_socktype = SOCK_STREAM;
- ainfo.ai_protocol = 0;
-
- if ( getaddrinfo_ptr(session->server, portStr, &ainfo, &res) == 0 && res )
- {
- resolvesuccess = 1;
- memcpy( &saddr, res->ai_addr, res->ai_addrlen );
- freeaddrinfo_ptr( res );
- }
- }
- FreeLibrary(hWsock);
- }
- if (!resolvesuccess)
- {
- session->lasterror = LIBIRC_ERR_RESOLV;
- return 1;
- }
- }
-#else
- if ( inet_pton( AF_INET6, session->server, (void*) &saddr.sin6_addr ) <= 0 )
- {
- memset( &ainfo, 0, sizeof(ainfo) );
- ainfo.ai_family = AF_INET6;
- ainfo.ai_socktype = SOCK_STREAM;
- ainfo.ai_protocol = 0;
-
- if ( getaddrinfo( session->server, portStr, &ainfo, &res ) || !res )
- {
- session->lasterror = LIBIRC_ERR_RESOLV;
- return 1;
- }
-
- memcpy( &saddr, res->ai_addr, res->ai_addrlen );
- freeaddrinfo( res );
- }
-#endif
-
- // create the IRC server socket
- if ( socket_create( PF_INET6, SOCK_STREAM, &session->sock)
- || socket_make_nonblocking (&session->sock) )
- {
- session->lasterror = LIBIRC_ERR_SOCKET;
- return 1;
- }
-
-#if defined (ENABLE_SSL)
- // Init the SSL stuff
- if ( session->flags & SESSIONFL_SSL_CONNECTION )
- {
- int rc = ssl_init( session );
-
- if ( rc != 0 )
- return rc;
- }
-#endif
-
- // and connect to the IRC server
- if ( socket_connect (&session->sock, (struct sockaddr *) &saddr, sizeof(saddr)) )
- {
- session->lasterror = LIBIRC_ERR_CONNECT;
- return 1;
- }
-
- session->state = LIBIRC_STATE_CONNECTING;
- session->flags = 0; // reset in case of reconnect
- return 0;
-#else
- session->lasterror = LIBIRC_ERR_NOIPV6;
- return 1;
-#endif
-}
-
-
-int irc_is_connected (irc_session_t * session)
-{
- return (session->state == LIBIRC_STATE_CONNECTED
- || session->state == LIBIRC_STATE_CONNECTING) ? 1 : 0;
-}
-
-
-int irc_run (irc_session_t * session)
-{
- if ( session->state != LIBIRC_STATE_CONNECTING )
- {
- session->lasterror = LIBIRC_ERR_STATE;
- return 1;
- }
-
- while ( irc_is_connected(session) )
- {
- struct timeval tv;
- fd_set in_set, out_set;
- int maxfd = 0;
-
- tv.tv_usec = 250000;
- tv.tv_sec = 0;
-
- // Init sets
- FD_ZERO (&in_set);
- FD_ZERO (&out_set);
-
- irc_add_select_descriptors (session, &in_set, &out_set, &maxfd);
-
- if ( select (maxfd + 1, &in_set, &out_set, 0, &tv) < 0 )
- {
- if ( socket_error() == EINTR )
- continue;
-
- session->lasterror = LIBIRC_ERR_TERMINATED;
- return 1;
- }
-
- if ( irc_process_select_descriptors (session, &in_set, &out_set) )
- return 1;
- }
-
- return 0;
-}
-
-
-int irc_add_select_descriptors (irc_session_t * session, fd_set *in_set, fd_set *out_set, int * maxfd)
-{
- if ( session->sock < 0
- || session->state == LIBIRC_STATE_INIT
- || session->state == LIBIRC_STATE_DISCONNECTED )
- {
- session->lasterror = LIBIRC_ERR_STATE;
- return 1;
- }
-
- libirc_mutex_lock (&session->mutex_session);
-
- switch (session->state)
- {
- case LIBIRC_STATE_CONNECTING:
- // While connection, only out_set descriptor should be set
- libirc_add_to_set (session->sock, out_set, maxfd);
- break;
-
- case LIBIRC_STATE_CONNECTED:
- // Add input descriptor if there is space in input buffer
- if ( session->incoming_offset < (sizeof (session->incoming_buf) - 1)
- || (session->flags & SESSIONFL_SSL_WRITE_WANTS_READ) != 0 )
- libirc_add_to_set (session->sock, in_set, maxfd);
-
- // Add output descriptor if there is something in output buffer
- if ( libirc_findcrlf (session->outgoing_buf, session->outgoing_offset) > 0
- || (session->flags & SESSIONFL_SSL_READ_WANTS_WRITE) != 0 )
- libirc_add_to_set (session->sock, out_set, maxfd);
-
- break;
- }
-
- libirc_mutex_unlock (&session->mutex_session);
-
- libirc_dcc_add_descriptors (session, in_set, out_set, maxfd);
- return 0;
-}
-
-
-static void libirc_process_incoming_data (irc_session_t * session, size_t process_length)
-{
- #define MAX_PARAMS_ALLOWED 10
- char buf[2*512], *p, *s;
- const char * command = 0, *prefix = 0, *params[MAX_PARAMS_ALLOWED+1];
- int code = 0, paramindex = 0;
- char *buf_end = buf + process_length;
-
- if ( process_length > sizeof(buf) )
- abort(); // should be impossible
-
- memcpy (buf, session->incoming_buf, process_length);
- buf[process_length] = '\0';
-
- memset ((char *)params, 0, sizeof(params));
- p = buf;
-
- /*
- * From RFC 1459:
- * ::= [':'