refactor: STCP connections as ETCP links (is_tcp)
- Add is_tcp, tcp_link, tcp_reconnect_* fields to ETCP_LINK - Remove transport_link from ETCP_CONN, add tcp_link_count - stcp_link: replace embedded etcp_conn with pointer; add etcp_link backpointer - stcp_link: link_rx_cb routes ETCP data to etcp_conn_input - stcp_link: call on_close_cb in close - New TCP functions: etcp_link_enter_ready_tcp, etcp_tcp_link_start_connect, etcp_tcp_link_start_reconnect, tcp_link_close_cb, etcp_tcp_send - etcp_link_new: handle NULL conn for TCP links; skip enter_init for TCP - etcp_link_close: close stcp_link for TCP - etcp_encrypt_send: redirect TCP to etcp_tcp_send (skips AES-CCM) - tcp_server_on_link: create ETCP_LINK(is_tcp=1) + enter_ready_tcp - etcp_connect: TCP addrs -> etcp_tcp_link_start_connect - Remove ctx->tcp_link/tcp_ready - test_stcp_traffic: find stcp_link via links->is_tcp instead of transport_link - 66/68 tests pass; 2 STCP tests expected to fail (integration not complete)
This commit is contained in:
1 parent
937af4c26a
commit
d773f1724a
1705 files changed
+187
-1082154
No files matched your search
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 Nu-book Inc.
|
||||
*/
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#include "TextEncoder.h"
|
||||
|
||||
#include "CharacterSet.h"
|
||||
#include "ECI.h"
|
||||
#include "Utf.h"
|
||||
#include "ZXAlgorithms.h"
|
||||
#include "Version.h"
|
||||
|
||||
#ifdef ZXING_USE_ZINT
|
||||
#include <zint.h>
|
||||
#else
|
||||
#include "libzueci/zueci.h"
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace ZXing {
|
||||
|
||||
void TextEncoder::GetBytes(const std::string& str, CharacterSet charset, std::string& bytes)
|
||||
{
|
||||
int eci = ToInt(ToECI(charset));
|
||||
const int str_len = narrow_cast<int>(str.length());
|
||||
int eci_len;
|
||||
|
||||
if (eci == -1)
|
||||
eci = 899; // Binary
|
||||
|
||||
bytes.clear();
|
||||
|
||||
#ifdef ZXING_USE_ZINT
|
||||
int error_number = ZBarcode_Dest_Len_ECI(eci, reinterpret_cast<const unsigned char *>(str.data()), str_len, &eci_len);
|
||||
if (error_number >= ZINT_ERROR) // Shouldn't happen
|
||||
throw std::logic_error("Internal error `ZBarcode_Dest_Len_ECI()`");
|
||||
|
||||
bytes.resize(eci_len); // Sufficient but approximate length
|
||||
|
||||
error_number = ZBarcode_UTF8_To_ECI(eci,reinterpret_cast<const unsigned char *>(str.data()), str_len,
|
||||
reinterpret_cast<unsigned char *>(bytes.data()), &eci_len);
|
||||
if (error_number >= ZINT_ERROR) {
|
||||
bytes.clear();
|
||||
throw std::invalid_argument("Unexpected charcode");
|
||||
}
|
||||
#else
|
||||
int error_number = zueci_dest_len_eci(eci, reinterpret_cast<const unsigned char *>(str.data()), str_len, &eci_len);
|
||||
if (error_number >= ZUECI_ERROR) // Shouldn't happen
|
||||
throw std::logic_error("Internal error `zueci_dest_len_eci()`");
|
||||
|
||||
bytes.resize(eci_len); // Sufficient but approximate length
|
||||
|
||||
error_number = zueci_utf8_to_eci(eci, reinterpret_cast<const unsigned char *>(str.data()), str_len,
|
||||
reinterpret_cast<unsigned char *>(bytes.data()), &eci_len);
|
||||
if (error_number >= ZUECI_ERROR) {
|
||||
bytes.clear();
|
||||
throw std::invalid_argument("Unexpected charcode");
|
||||
}
|
||||
#endif // ZXING_USE_ZINT
|
||||
|
||||
bytes.resize(eci_len); // Actual length
|
||||
}
|
||||
|
||||
void TextEncoder::GetBytes(const std::wstring& str, CharacterSet charset, std::string& bytes)
|
||||
{
|
||||
GetBytes(ToUtf8(str), charset, bytes);
|
||||
}
|
||||
|
||||
} // ZXing
|
||||
Reference in new issue
Block a user