From 030902d745079c0b6dec8b27d47fef0bfcfb92d1 Mon Sep 17 00:00:00 2001 From: R3ABM Artem Date: Sat, 16 Feb 2019 21:00:21 +0000 Subject: [PATCH] Revert "Added support of iconv" This reverts commit 0c0990a9c56cd8d46b982856e3fe181aba8abe5a --- SVXLink/ModuleEchoLink.conf | 5 +- SVXLink/echolink/BrandMeisterBridge.cpp | 95 ++++++++----------------- SVXLink/echolink/BrandMeisterBridge.h | 6 -- SVXLink/echolink/ModuleEchoLink.cpp | 4 -- 4 files changed, 32 insertions(+), 78 deletions(-) diff --git a/SVXLink/ModuleEchoLink.conf b/SVXLink/ModuleEchoLink.conf index d0245dc..a1ded6e 100644 --- a/SVXLink/ModuleEchoLink.conf +++ b/SVXLink/ModuleEchoLink.conf @@ -9,8 +9,8 @@ TIMEOUT=0 #REJECT_OUTGOING=^()$ #ACCEPT_OUTGOING=^(.*)$ SERVERS=servers.echolink.org -CALLSIGN=R3ABM-L -PASSWORD=rqY69MWd +CALLSIGN=callsign +PASSWORD=password SYSOPNAME=*DSTAR.SU DMR Bridge* LOCATION=Moscow, Russia MAX_QSOS=10 @@ -22,4 +22,3 @@ AUTOCON_TIME=30 BRIDGE_DEFAULT=9504 BRIDGE_PROXY=2501:10 -BRIDGE_ENCODING=cp1251 diff --git a/SVXLink/echolink/BrandMeisterBridge.cpp b/SVXLink/echolink/BrandMeisterBridge.cpp index a843789..f4cc102 100644 --- a/SVXLink/echolink/BrandMeisterBridge.cpp +++ b/SVXLink/echolink/BrandMeisterBridge.cpp @@ -16,25 +16,18 @@ BrandMeisterBridge::BrandMeisterBridge() { proxy = NULL; - handle = NULL; talker = NULL; unknown = ECHOLINK_DEFAULT_USER_NUMBER; } BrandMeisterBridge::~BrandMeisterBridge() { - iconv_close(handle); DELETE(proxy); free(talker); } // Interface methods for ModuleEchoLink -void BrandMeisterBridge::setEncodingConfiguration(const char* configuration) -{ - handle = iconv_open("UTF-8", configuration); -} - void BrandMeisterBridge::setDefaultConfiguration(const char* configuration) { unknown = strtol(configuration, NULL, 10); @@ -83,16 +76,39 @@ void BrandMeisterBridge::setTalker(const char* call, const char* name) if (*call == '*') { - // Do not handle conference call-sign + // Do not process conference call-sign return; } - size_t length = strlen(call) + strlen(name); - char* buffer = (char*)alloca(length + sizeof(uint32_t)); + const char* delimiter1 = strpbrk(call, " -\n"); + const char* delimiter2 = strpbrk(name, "\n"); - sprintf(buffer, "%s %s", call, name); + if (delimiter1 != NULL) + { + // Remove characters after call-sign + size_t length = delimiter1 - call; + char* buffer = (char*)alloca(length + sizeof(uint32_t)); + strncpy(buffer, call, length); + buffer[length] = '\0'; + call = buffer; + } + if (delimiter2 != NULL) + { + // Remove characters after talker name + size_t length = delimiter2 - name; + char* buffer = (char*)alloca(length + sizeof(uint32_t)); + strncpy(buffer, name, length); + buffer[length] = '\0'; + name = buffer; + } - setTalkerData(call, buffer); + uint32_t number = proxy->getPrivateIDForCall(call); + if (number == 0) + number = unknown; + + syslog(LOG_INFO, "Set talker ID to %d for call-sign %s (%s)", number, call, name); + proxy->setTalkerID(number); + proxy->setTalkerAlias(name); } void BrandMeisterBridge::handleChatMessage(const char* text) @@ -114,65 +130,14 @@ void BrandMeisterBridge::handleChatMessage(const char* text) if (delimiter != NULL) { const char* call = delimiter + 3; - setTalkerData(call, call); + setTalker(call, call); } else { - syslog(LOG_INFO, "Set talker ID to %d (call-sign is not present in chat message)", unknown); + syslog(LOG_INFO, "Set talker ID to %d (call-sign was not fit into chat message)", unknown); proxy->setTalkerID(unknown); proxy->setTalkerAlias(""); } } } -void BrandMeisterBridge::setTalkerData(const char* call, const char* name) -{ - const char* delimiter1 = strpbrk(call, " -\n"); - const char* delimiter2 = strchr(name, '\n'); - - if (delimiter1 != NULL) - { - // Remove characters after call-sign - size_t length = delimiter1 - call; - char* buffer = (char*)alloca(length + sizeof(uint32_t)); - strncpy(buffer, call, length); - buffer[length] = '\0'; - call = buffer; - } - - if (delimiter2 != NULL) - { - // Remove characters after talker name - size_t length = delimiter2 - name; - char* buffer = (char*)alloca(length + sizeof(uint32_t)); - strncpy(buffer, name, length); - buffer[length] = '\0'; - name = buffer; - } - - if (handle != NULL) - { - // Convert name to UTF8 - size_t length1 = strlen(name); - size_t length2 = length1 * 3; - char* buffer = (char*)alloca(length2); - char* pointer1 = const_cast(name); - char* pointer2 = buffer; - iconv(handle, &pointer1, &length1, &pointer2, &length2); - *pointer2 = '\0'; - name = buffer; - } - - uint32_t number = proxy->getPrivateIDForCall(call); - - if (number == 0) - { - // Use default value instead if ID not found - number = unknown; - } - - proxy->setTalkerID(number); - proxy->setTalkerAlias(name); - - syslog(LOG_INFO, "Set talker ID to %d for call-sign %s (%s)", number, call, name); -} diff --git a/SVXLink/echolink/BrandMeisterBridge.h b/SVXLink/echolink/BrandMeisterBridge.h index 9f9c0a4..465104a 100644 --- a/SVXLink/echolink/BrandMeisterBridge.h +++ b/SVXLink/echolink/BrandMeisterBridge.h @@ -3,8 +3,6 @@ #ifndef BRANDMEISTERBRIDGE_H #define BRANDMEISTERBRIDGE_H -#include - #include "PatchCord.h" class BrandMeisterBridge @@ -14,7 +12,6 @@ class BrandMeisterBridge BrandMeisterBridge(); ~BrandMeisterBridge(); - void setEncodingConfiguration(const char* configuration); void setDefaultConfiguration(const char* configuration); void setProxyConfiguration(const char* configuration); @@ -25,12 +22,9 @@ class BrandMeisterBridge private: PatchCord* proxy; - iconv_t handle; char* talker; int unknown; - void setTalkerData(const char* call, const char* name); - }; #endif \ No newline at end of file diff --git a/SVXLink/echolink/ModuleEchoLink.cpp b/SVXLink/echolink/ModuleEchoLink.cpp index 79c7ac1..e82128b 100644 --- a/SVXLink/echolink/ModuleEchoLink.cpp +++ b/SVXLink/echolink/ModuleEchoLink.cpp @@ -420,10 +420,6 @@ bool ModuleEchoLink::initialize(void) { bridge.setDefaultConfiguration(value.c_str()); } - if (cfg().getValue(cfgName(), "BRIDGE_ENCODING", value)) - { - bridge.setEncodingConfiguration(value.c_str()); - } if (cfg().getValue(cfgName(), "BRIDGE_PROXY", value)) { bridge.setProxyConfiguration(value.c_str());