stcp: ed25519 pubkey exchange in handshake, fix instance destroy segfault, fix chat_tcp_test
- u_async.c: process immediate_queue BEFORE epoll_wait in uasync_poll - stcp_link.c: defensive NULL etcp_conn/etcp_link in stcp_link_close - utun_instance.c: move stcp_server_list_destroy_all to Phase J (before ETCP), add deferred drain in both Phase J and L - stcp.h/c: STCP_HS_ENC_CLIENT 6→38, STCP_HS_ENC_SERVER 7→39, exchange ed25519_pubkey in both handshake directions - etcp_connections.c: copy peer_ed25519 from STCP to ETCP_CONN in etcp_link_enter_ready_tcp; guard link->etcp in tcp_link_close_cb - chat_sync.c: fix lk->conn NULL dereference for TCP links - test_stcp.c: update stcp_server_create/stcp_client_connect callsites - tools/chat_tcp_test: change transport udp→tcp
This commit is contained in:
1 parent
a3783b5f55
commit
38c9f229bc
1272 files changed
+968388
-1
No files matched your search
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright 2022 Axel Waggershauser
|
||||
*/
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#include "ECI.h"
|
||||
|
||||
#include "ZXAlgorithms.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace ZXing {
|
||||
|
||||
static const std::map<ECI, CharacterSet> ECI_TO_CHARSET = {
|
||||
{ECI(0), CharacterSet::Cp437}, // Obsolete
|
||||
{ECI(1), CharacterSet::ISO8859_1}, // Obsolete
|
||||
{ECI::Cp437, CharacterSet::Cp437}, // Obsolete but still used by PDF417 Macro fields (ISO/IEC 15438:2015 Annex H.2.3)
|
||||
{ECI::ISO8859_1, CharacterSet::ISO8859_1},
|
||||
{ECI::ISO8859_2, CharacterSet::ISO8859_2},
|
||||
{ECI::ISO8859_3, CharacterSet::ISO8859_3},
|
||||
{ECI::ISO8859_4, CharacterSet::ISO8859_4},
|
||||
{ECI::ISO8859_5, CharacterSet::ISO8859_5},
|
||||
{ECI::ISO8859_6, CharacterSet::ISO8859_6},
|
||||
{ECI::ISO8859_7, CharacterSet::ISO8859_7},
|
||||
{ECI::ISO8859_8, CharacterSet::ISO8859_8},
|
||||
{ECI::ISO8859_9, CharacterSet::ISO8859_9},
|
||||
{ECI::ISO8859_10, CharacterSet::ISO8859_10},
|
||||
{ECI::ISO8859_11, CharacterSet::ISO8859_11},
|
||||
{ECI::ISO8859_13, CharacterSet::ISO8859_13},
|
||||
{ECI::ISO8859_14, CharacterSet::ISO8859_14},
|
||||
{ECI::ISO8859_15, CharacterSet::ISO8859_15},
|
||||
{ECI::ISO8859_16, CharacterSet::ISO8859_16},
|
||||
{ECI::Shift_JIS, CharacterSet::Shift_JIS},
|
||||
{ECI::Cp1250, CharacterSet::Cp1250},
|
||||
{ECI::Cp1251, CharacterSet::Cp1251},
|
||||
{ECI::Cp1252, CharacterSet::Cp1252},
|
||||
{ECI::Cp1256, CharacterSet::Cp1256},
|
||||
{ECI::UTF8, CharacterSet::UTF8},
|
||||
{ECI::UTF16BE, CharacterSet::UTF16BE},
|
||||
{ECI::UTF16LE, CharacterSet::UTF16LE},
|
||||
{ECI::UTF32BE, CharacterSet::UTF32BE},
|
||||
{ECI::UTF32LE, CharacterSet::UTF32LE},
|
||||
{ECI::ASCII, CharacterSet::ASCII},
|
||||
{ECI::Big5, CharacterSet::Big5},
|
||||
{ECI::GB18030, CharacterSet::GB18030},
|
||||
{ECI::GB2312, CharacterSet::GB2312},
|
||||
{ECI::EUC_KR, CharacterSet::EUC_KR},
|
||||
{ECI::ISO646_Inv, CharacterSet::ASCII},
|
||||
{ECI::Binary, CharacterSet::BINARY},
|
||||
};
|
||||
|
||||
std::string ToString(ECI eci)
|
||||
{
|
||||
return '\\' + ToString(ToInt(eci), 6);
|
||||
}
|
||||
|
||||
CharacterSet ToCharacterSet(ECI eci)
|
||||
{
|
||||
if (auto it = ECI_TO_CHARSET.find(eci); it != ECI_TO_CHARSET.end())
|
||||
return it->second;
|
||||
|
||||
return CharacterSet::Unknown;
|
||||
}
|
||||
|
||||
ECI ToECI(CharacterSet cs)
|
||||
{
|
||||
// Special case ISO8859_1 to avoid obsolete ECI 1
|
||||
if (cs == CharacterSet::ISO8859_1)
|
||||
return ECI::ISO8859_1;
|
||||
// Special case Cp437 to avoid obsolete ECI 0 for slightly less obsolete ECI 2
|
||||
if (cs == CharacterSet::Cp437)
|
||||
return ECI::Cp437;
|
||||
|
||||
for (auto& [key, value] : ECI_TO_CHARSET)
|
||||
if (value == cs)
|
||||
return key;
|
||||
|
||||
return ECI::Unknown;
|
||||
}
|
||||
|
||||
} // namespace ZXing
|
||||
Reference in new issue
Block a user