- Remove ALPR_OD Tracker and voting system.

- Disable debugview
This commit is contained in:
2026-04-19 23:15:50 +10:00
parent 51fe507dfd
commit 3418090042
13 changed files with 1266 additions and 129 deletions

View File

@@ -3,21 +3,11 @@
#include "ANSUtilities.h"
#include <cstdint>
#include <cstdio>
#include <cstdarg>
#include <unordered_map>
#include <condition_variable>
#include <mutex>
// ── DebugView logger (filter on "[ANSAWS]") ──
static void AWSDbg(const char* fmt, ...) {
char buf[512];
va_list ap;
va_start(ap, fmt);
int n = vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
if (n < 0) return;
OutputDebugStringA(buf);
}
// DebugView: filter on "[ANSAWS]" or "[ANSUTIL]" — gated by ANSCORE_DEBUGVIEW in ANSLicense.h.
// ── ANSUtilities handle registry ──
// destructionStarted: set by the first Unregister caller; blocks new Acquires
@@ -40,14 +30,30 @@ static std::condition_variable& UtilHandleRegistryCV() {
static void RegisterUtilHandle(ANSCENTER::ANSUtilities* h) {
std::lock_guard<std::mutex> lk(UtilHandleRegistryMutex());
UtilHandleRegistry()[h] = { 1, false };
ANS_DBG("ANSUTIL","Register: handle=%p (uint=%llu) registrySize=%zu",
(void*)h, (unsigned long long)(uintptr_t)h, UtilHandleRegistry().size());
}
static ANSCENTER::ANSUtilities* AcquireUtilHandle(ANSCENTER::ANSUtilities* h) {
std::lock_guard<std::mutex> lk(UtilHandleRegistryMutex());
auto it = UtilHandleRegistry().find(h);
if (it == UtilHandleRegistry().end()) return nullptr;
if (it->second.destructionStarted) return nullptr;
if (it == UtilHandleRegistry().end()) {
ANS_DBG("ANSUTIL","Acquire FAIL: handle=%p (uint=%llu) NOT in registry. registrySize=%zu",
(void*)h, (unsigned long long)(uintptr_t)h, UtilHandleRegistry().size());
size_t i = 0;
for (auto& kv : UtilHandleRegistry()) {
ANS_DBG("ANSUTIL"," registry[%zu] = %p (uint=%llu) refcount=%d destructionStarted=%d",
i++, (void*)kv.first, (unsigned long long)(uintptr_t)kv.first,
kv.second.refcount, kv.second.destructionStarted ? 1 : 0);
}
return nullptr;
}
if (it->second.destructionStarted) {
ANS_DBG("ANSUTIL","Acquire FAIL: handle=%p is being destroyed (destructionStarted=true)", (void*)h);
return nullptr;
}
it->second.refcount++;
ANS_DBG("ANSUTIL","Acquire OK: handle=%p refcount=%d", (void*)h, it->second.refcount);
return h;
}
@@ -65,11 +71,16 @@ static bool ReleaseUtilHandleRef(ANSCENTER::ANSUtilities* h) {
static bool UnregisterUtilHandle(ANSCENTER::ANSUtilities* h) {
std::unique_lock<std::mutex> lk(UtilHandleRegistryMutex());
auto it = UtilHandleRegistry().find(h);
if (it == UtilHandleRegistry().end()) return false;
if (it->second.destructionStarted) {
// Another thread is already tearing this handle down; let it own the delete.
if (it == UtilHandleRegistry().end()) {
ANS_DBG("ANSUTIL","Unregister: handle=%p NOT in registry (already gone)", (void*)h);
return false;
}
if (it->second.destructionStarted) {
// Another thread is already tearing this handle down; let it own the delete.
ANS_DBG("ANSUTIL","Unregister: handle=%p already being destroyed by another thread, returning false", (void*)h);
return false;
}
ANS_DBG("ANSUTIL","Unregister: handle=%p starting (refcount before=%d)", (void*)h, it->second.refcount);
it->second.destructionStarted = true;
it->second.refcount--;
bool ok = UtilHandleRegistryCV().wait_for(lk, std::chrono::seconds(30), [&]() {
@@ -77,6 +88,7 @@ static bool UnregisterUtilHandle(ANSCENTER::ANSUtilities* h) {
return it2 == UtilHandleRegistry().end() || it2->second.refcount <= 0;
});
if (!ok) {
ANS_DBG("ANSUTIL","WARNING: Unregister timed out waiting for in-flight operations on handle=%p", (void*)h);
OutputDebugStringA("WARNING: UnregisterUtilHandle timed out waiting for in-flight operations\n");
}
UtilHandleRegistry().erase(h);
@@ -116,7 +128,7 @@ static std::condition_variable& AWSHandleRegistryCV() {
static void RegisterAWSHandle(ANSCENTER::ANSAWSS3* h) {
std::lock_guard<std::mutex> lk(AWSHandleRegistryMutex());
AWSHandleRegistry()[h] = { 1, false };
AWSDbg("[ANSAWS] Register: handle=%p (uint=%llu) registrySize=%zu\n",
ANS_DBG("ANSAWS", "Register: handle=%p (uint=%llu) registrySize=%zu",
(void*)h, (unsigned long long)(uintptr_t)h, AWSHandleRegistry().size());
}
@@ -130,22 +142,22 @@ static ANSCENTER::ANSAWSS3* AcquireAWSHandle(ANSCENTER::ANSAWSS3* h) {
std::lock_guard<std::mutex> lk(AWSHandleRegistryMutex());
auto it = AWSHandleRegistry().find(h);
if (it == AWSHandleRegistry().end()) {
AWSDbg("[ANSAWS] Acquire FAIL: handle=%p (uint=%llu) NOT in registry. registrySize=%zu\n",
ANS_DBG("ANSAWS", "Acquire FAIL: handle=%p (uint=%llu) NOT in registry. registrySize=%zu",
(void*)h, (unsigned long long)(uintptr_t)h, AWSHandleRegistry().size());
size_t i = 0;
for (auto& kv : AWSHandleRegistry()) {
AWSDbg("[ANSAWS] registry[%zu] = %p (uint=%llu) refcount=%d destructionStarted=%d\n",
ANS_DBG("ANSAWS", " registry[%zu] = %p (uint=%llu) refcount=%d destructionStarted=%d",
i++, (void*)kv.first, (unsigned long long)(uintptr_t)kv.first,
kv.second.refcount, kv.second.destructionStarted ? 1 : 0);
}
return nullptr;
}
if (it->second.destructionStarted) {
AWSDbg("[ANSAWS] Acquire FAIL: handle=%p is being destroyed (destructionStarted=true)\n", (void*)h);
ANS_DBG("ANSAWS", "Acquire FAIL: handle=%p is being destroyed (destructionStarted=true)", (void*)h);
return nullptr;
}
it->second.refcount++;
AWSDbg("[ANSAWS] Acquire OK: handle=%p refcount=%d\n", (void*)h, it->second.refcount);
ANS_DBG("ANSAWS", "Acquire OK: handle=%p refcount=%d", (void*)h, it->second.refcount);
return h;
}
@@ -164,14 +176,14 @@ static bool UnregisterAWSHandle(ANSCENTER::ANSAWSS3* h) {
std::unique_lock<std::mutex> lk(AWSHandleRegistryMutex());
auto it = AWSHandleRegistry().find(h);
if (it == AWSHandleRegistry().end()) {
AWSDbg("[ANSAWS] Unregister: handle=%p NOT in registry (already gone)\n", (void*)h);
ANS_DBG("ANSAWS", "Unregister: handle=%p NOT in registry (already gone)", (void*)h);
return false;
}
if (it->second.destructionStarted) {
AWSDbg("[ANSAWS] Unregister: handle=%p already being destroyed by another thread, returning false\n", (void*)h);
ANS_DBG("ANSAWS", "Unregister: handle=%p already being destroyed by another thread, returning false", (void*)h);
return false;
}
AWSDbg("[ANSAWS] Unregister: handle=%p starting (refcount before=%d)\n", (void*)h, it->second.refcount);
ANS_DBG("ANSAWS", "Unregister: handle=%p starting (refcount before=%d)", (void*)h, it->second.refcount);
it->second.destructionStarted = true;
it->second.refcount--;
bool ok = AWSHandleRegistryCV().wait_for(lk, std::chrono::seconds(120), [&]() {
@@ -225,22 +237,36 @@ BOOL APIENTRY DllMain( HMODULE hModule,
// (releasing live objects we "see" in the input) destroys legitimate parallel
// instances and is far worse. (Same reasoning as CreateANSAWSHandle.)
extern "C" ANSULT_API int CreateANSUtilityHandle(ANSCENTER::ANSUtilities** Handle, const char* licenseKey) {
if (Handle == nullptr || licenseKey == nullptr) return 0;
ANS_DBG("ANSUTIL","Create called: HandlePtr=%p, *Handle(in)=%p (input ignored, always allocates new)",
(void*)Handle, Handle ? (void*)*Handle : nullptr);
if (Handle == nullptr || licenseKey == nullptr) {
ANS_DBG("ANSUTIL","Create FAIL: Handle or licenseKey is null");
return 0;
}
*Handle = nullptr;
try {
*Handle = new ANSCENTER::ANSUtilities();
if (*Handle == nullptr) return 0;
if (*Handle == nullptr) {
ANS_DBG("ANSUTIL","Create FAIL: new returned null");
return 0;
}
ANS_DBG("ANSUTIL","Create: allocated handle=%p (uint=%llu), calling Initialize...",
(void*)*Handle, (unsigned long long)(uintptr_t)*Handle);
if ((*Handle)->Initialize(licenseKey)) {
RegisterUtilHandle(*Handle);
ANS_DBG("ANSUTIL","Create OK: handle=%p (uint=%llu)",
(void*)*Handle, (unsigned long long)(uintptr_t)*Handle);
return 1;
}
// Initialize failed - clean up to prevent memory leak
ANS_DBG("ANSUTIL","Create FAIL: Initialize returned false, deleting handle=%p", (void*)*Handle);
delete *Handle;
*Handle = nullptr;
return 0;
}
catch (std::exception& e) {
// Clean up on exception to prevent memory leak
ANS_DBG("ANSUTIL","Create EXCEPTION (std::exception): %s", e.what());
if (*Handle != nullptr) {
delete *Handle;
*Handle = nullptr;
@@ -248,6 +274,7 @@ extern "C" ANSULT_API int CreateANSUtilityHandle(ANSCENTER::ANSUtilities** Hand
return 0;
}
catch (...) {
ANS_DBG("ANSUTIL","Create EXCEPTION (unknown)");
if (*Handle != nullptr) {
delete *Handle;
*Handle = nullptr;
@@ -258,16 +285,25 @@ extern "C" ANSULT_API int CreateANSUtilityHandle(ANSCENTER::ANSUtilities** Hand
}
static int ReleaseANSUtilityHandle_Impl(ANSCENTER::ANSUtilities** Handle) {
try {
if (!Handle || !*Handle) return 1;
if (!UnregisterUtilHandle(*Handle)) {
if (!Handle || !*Handle) {
ANS_DBG("ANSUTIL","Release: HandlePtr or *Handle is null, no-op");
return 1;
}
ANSCENTER::ANSUtilities* h = *Handle;
ANS_DBG("ANSUTIL","Release called: handle=%p (uint=%llu)", (void*)h, (unsigned long long)(uintptr_t)h);
if (!UnregisterUtilHandle(h)) {
ANS_DBG("ANSUTIL","Release: Unregister returned false (already gone or being destroyed by another thread), handle=%p", (void*)h);
*Handle = nullptr;
return 1;
}
delete *Handle;
delete h;
*Handle = nullptr;
ANS_DBG("ANSUTIL","Release OK: handle=%p deleted, registry now has %zu entries",
(void*)h, UtilHandleRegistry().size());
return 1;
}
catch (...) {
ANS_DBG("ANSUTIL","Release EXCEPTION (unknown)");
if (Handle) *Handle = nullptr;
return 0;
}
@@ -278,11 +314,13 @@ extern "C" ANSULT_API int ReleaseANSUtilityHandle(ANSCENTER::ANSUtilities** Han
return ReleaseANSUtilityHandle_Impl(Handle);
}
__except (EXCEPTION_EXECUTE_HANDLER) {
ANS_DBG("ANSUTIL","ReleaseANSUtilityHandle: SEH exception caught");
if (Handle) *Handle = nullptr;
return 0;
}
}
extern "C" ANSULT_API int GetFCMAccessToken(ANSCENTER::ANSUtilities** Handle,const char* privateKey, LStrHandle accessToken) {
ANS_DBG("ANSUTIL","GetFCMAccessToken: *Handle=%p", (void*)(Handle ? *Handle : nullptr));
if (Handle == nullptr || *Handle == nullptr || privateKey == nullptr || accessToken == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(*Handle));
if (!guard) return 0;
@@ -308,6 +346,8 @@ extern "C" ANSULT_API int GetFCMAccessToken(ANSCENTER::ANSUtilities** Handle,co
}
}
extern "C" ANSULT_API int CreateAWSSNSTopic(ANSCENTER::ANSUtilities** Handle, const char* snsTopicName, LStrHandle arnTopic) {
ANS_DBG("ANSUTIL","CreateAWSSNSTopic: *Handle=%p, snsTopicName=%s",
(void*)(Handle ? *Handle : nullptr), snsTopicName ? snsTopicName : "(null)");
if (Handle == nullptr || *Handle == nullptr || snsTopicName == nullptr || arnTopic == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(*Handle));
if (!guard) return 0;
@@ -333,6 +373,7 @@ extern "C" ANSULT_API int CreateAWSSNSTopic(ANSCENTER::ANSUtilities** Handle, c
}
}
extern "C" ANSULT_API int GetFCMAccessTokenCpp(ANSCENTER::ANSUtilities** Handle, const char* privateKey, std::string& accessToken) {
ANS_DBG("ANSUTIL","GetFCMAccessTokenCpp: *Handle=%p", (void*)(Handle ? *Handle : nullptr));
if (Handle == nullptr || *Handle == nullptr || privateKey == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(*Handle));
if (!guard) return 0;
@@ -354,6 +395,8 @@ extern "C" ANSULT_API int GetFCMAccessTokenCpp(ANSCENTER::ANSUtilities** Handle
}
}
extern "C" ANSULT_API int CreateAWSSNSTopicCpp(ANSCENTER::ANSUtilities** Handle, const char* snsTopicName, std::string& arnTopic) {
ANS_DBG("ANSUTIL","CreateAWSSNSTopicCpp: *Handle=%p, snsTopicName=%s",
(void*)(Handle ? *Handle : nullptr), snsTopicName ? snsTopicName : "(null)");
if (Handle == nullptr || *Handle == nullptr || snsTopicName == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(*Handle));
if (!guard) return 0;
@@ -374,6 +417,8 @@ extern "C" ANSULT_API int CreateAWSSNSTopicCpp(ANSCENTER::ANSUtilities** Handle
}
}
extern "C" ANSULT_API int DeleteAWSSNSTopic(ANSCENTER::ANSUtilities** Handle, const char* arnTopic) {
ANS_DBG("ANSUTIL","DeleteAWSSNSTopic: *Handle=%p, arnTopic=%s",
(void*)(Handle ? *Handle : nullptr), arnTopic ? arnTopic : "(null)");
if (Handle == nullptr || *Handle == nullptr || arnTopic == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(*Handle));
if (!guard) return 0;
@@ -389,6 +434,10 @@ extern "C" ANSULT_API int DeleteAWSSNSTopic(ANSCENTER::ANSUtilities** Handle, c
}
}
extern "C" ANSULT_API int SubcribeSMSPhoneNumberAWSSNSTopic(ANSCENTER::ANSUtilities** Handle, const char* snsTopicName, const char* phoneNumber, LStrHandle subscribedARN) {
ANS_DBG("ANSUTIL","SubcribeSMSPhoneNumberAWSSNSTopic: *Handle=%p, snsTopicName=%s, phoneNumber=%s",
(void*)(Handle ? *Handle : nullptr),
snsTopicName ? snsTopicName : "(null)",
phoneNumber ? phoneNumber : "(null)");
if (Handle == nullptr || *Handle == nullptr || snsTopicName == nullptr || phoneNumber == nullptr || subscribedARN == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(*Handle));
if (!guard) return 0;
@@ -415,6 +464,10 @@ extern "C" ANSULT_API int SubcribeSMSPhoneNumberAWSSNSTopic(ANSCENTER::ANSUtili
}
extern "C" ANSULT_API int SubcribeEmailAddressAWSSNSTopic(ANSCENTER::ANSUtilities** Handle, const char* snsTopicName, const char* emailAddress, LStrHandle subscribedARN) {
ANS_DBG("ANSUTIL","SubcribeEmailAddressAWSSNSTopic: *Handle=%p, snsTopicName=%s, emailAddress=%s",
(void*)(Handle ? *Handle : nullptr),
snsTopicName ? snsTopicName : "(null)",
emailAddress ? emailAddress : "(null)");
if (Handle == nullptr || *Handle == nullptr || snsTopicName == nullptr || emailAddress == nullptr || subscribedARN == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(*Handle));
if (!guard) return 0;
@@ -440,6 +493,10 @@ extern "C" ANSULT_API int SubcribeEmailAddressAWSSNSTopic(ANSCENTER::ANSUtiliti
}
}
extern "C" ANSULT_API int SendMessageToAWSSNSTopic(ANSCENTER::ANSUtilities** Handle, const char* snsTopicName, const char* subjectContent, const char* messageContent, LStrHandle messageId) {
ANS_DBG("ANSUTIL","SendMessageToAWSSNSTopic: *Handle=%p, snsTopicName=%s, subject=%s",
(void*)(Handle ? *Handle : nullptr),
snsTopicName ? snsTopicName : "(null)",
subjectContent ? subjectContent : "(null)");
if (Handle == nullptr || *Handle == nullptr || snsTopicName == nullptr || subjectContent == nullptr || messageContent == nullptr || messageId == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(*Handle));
if (!guard) return 0;
@@ -465,6 +522,9 @@ extern "C" ANSULT_API int SendMessageToAWSSNSTopic(ANSCENTER::ANSUtilities** Ha
}
}
extern "C" ANSULT_API int SendMessageToPhoneNumber(ANSCENTER::ANSUtilities** Handle, const char* phoneNumber, const char* messageContent, LStrHandle messageId) {
ANS_DBG("ANSUTIL","SendMessageToPhoneNumber: *Handle=%p, phoneNumber=%s",
(void*)(Handle ? *Handle : nullptr),
phoneNumber ? phoneNumber : "(null)");
if (Handle == nullptr || *Handle == nullptr || phoneNumber == nullptr || messageContent == nullptr || messageId == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(*Handle));
if (!guard) return 0;
@@ -490,6 +550,10 @@ extern "C" ANSULT_API int SendMessageToPhoneNumber(ANSCENTER::ANSUtilities** Ha
}
}
extern "C" ANSULT_API int SubcribeSMSPhoneNumberAWSSNSTopicCpp(ANSCENTER::ANSUtilities** Handle, const char* snsTopicName, const char* phoneNumber, std::string& subscribedARN) {
ANS_DBG("ANSUTIL","SubcribeSMSPhoneNumberAWSSNSTopicCpp: *Handle=%p, snsTopicName=%s, phoneNumber=%s",
(void*)(Handle ? *Handle : nullptr),
snsTopicName ? snsTopicName : "(null)",
phoneNumber ? phoneNumber : "(null)");
if (Handle == nullptr || *Handle == nullptr || snsTopicName == nullptr || phoneNumber == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(*Handle));
if (!guard) return 0;
@@ -510,6 +574,10 @@ extern "C" ANSULT_API int SubcribeSMSPhoneNumberAWSSNSTopicCpp(ANSCENTER::ANSUt
}
}
extern "C" ANSULT_API int SubcribeEmailAddressAWSSNSTopicCpp(ANSCENTER::ANSUtilities** Handle, const char* snsTopicName, const char* emailAddress, std::string& subscribedARN) {
ANS_DBG("ANSUTIL","SubcribeEmailAddressAWSSNSTopicCpp: *Handle=%p, snsTopicName=%s, emailAddress=%s",
(void*)(Handle ? *Handle : nullptr),
snsTopicName ? snsTopicName : "(null)",
emailAddress ? emailAddress : "(null)");
if (Handle == nullptr || *Handle == nullptr || snsTopicName == nullptr || emailAddress == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(*Handle));
if (!guard) return 0;
@@ -530,6 +598,10 @@ extern "C" ANSULT_API int SubcribeEmailAddressAWSSNSTopicCpp(ANSCENTER::ANSUtil
}
}
extern "C" ANSULT_API int SendMessageToAWSSNSTopicCpp(ANSCENTER::ANSUtilities** Handle, const char* snsTopicName, const char* subjectContent, const char* messageContent, std::string& messageId) {
ANS_DBG("ANSUTIL","SendMessageToAWSSNSTopicCpp: *Handle=%p, snsTopicName=%s, subject=%s",
(void*)(Handle ? *Handle : nullptr),
snsTopicName ? snsTopicName : "(null)",
subjectContent ? subjectContent : "(null)");
if (Handle == nullptr || *Handle == nullptr || snsTopicName == nullptr || subjectContent == nullptr || messageContent == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(*Handle));
if (!guard) return 0;
@@ -550,6 +622,9 @@ extern "C" ANSULT_API int SendMessageToAWSSNSTopicCpp(ANSCENTER::ANSUtilities**
}
}
extern "C" ANSULT_API int SendMessageToPhoneNumberCpp(ANSCENTER::ANSUtilities** Handle, const char* phoneNumber, const char* messageContent, std::string& messageId) {
ANS_DBG("ANSUTIL","SendMessageToPhoneNumberCpp: *Handle=%p, phoneNumber=%s",
(void*)(Handle ? *Handle : nullptr),
phoneNumber ? phoneNumber : "(null)");
if (Handle == nullptr || *Handle == nullptr || phoneNumber == nullptr || messageContent == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(*Handle));
if (!guard) return 0;
@@ -570,6 +645,7 @@ extern "C" ANSULT_API int SendMessageToPhoneNumberCpp(ANSCENTER::ANSUtilities**
}
}
extern "C" ANSULT_API int ListASWTopics(ANSCENTER::ANSUtilities** Handle, LStrHandle arnTopics) {
ANS_DBG("ANSUTIL","ListASWTopics: *Handle=%p", (void*)(Handle ? *Handle : nullptr));
if (Handle == nullptr || *Handle == nullptr || arnTopics == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(*Handle));
if (!guard) return 0;
@@ -595,6 +671,7 @@ extern "C" ANSULT_API int ListASWTopics(ANSCENTER::ANSUtilities** Handle, LStrH
}
}
extern "C" ANSULT_API int AESEncryption(const char* inputString, const char* inputKey, LStrHandle encryptionMessage) {
ANS_DBG("ANSUTIL","AESEncryption: inputString len=%zu", inputString ? strlen(inputString) : 0);
if (inputString == nullptr || inputKey == nullptr || encryptionMessage == nullptr) return 0;
try {
std::string st = ANSCENTER::ANSUtilities::AESEncryption(inputString, inputKey);
@@ -620,6 +697,7 @@ extern "C" ANSULT_API int AESEncryption(const char* inputString, const char* in
}
extern "C" ANSULT_API int MD5HashFile(const char* filePath, LStrHandle decryptionMessage)
{
ANS_DBG("ANSUTIL","MD5HashFile: filePath=%s", filePath ? filePath : "(null)");
if (filePath == nullptr || decryptionMessage == nullptr) return 0;
try {
std::string st = ANSCENTER::ANSUtilities::MD5HashFile(filePath);
@@ -643,6 +721,7 @@ extern "C" ANSULT_API int MD5HashFile(const char* filePath, LStrHandle decrypti
}
}
extern "C" ANSULT_API int AESDecryption(const char* encryptedString, const char* inputKey, LStrHandle decryptionMessage) {
ANS_DBG("ANSUTIL","AESDecryption: encryptedString len=%zu", encryptedString ? strlen(encryptedString) : 0);
if (encryptedString == nullptr || inputKey == nullptr || decryptionMessage == nullptr) return 0;
try {
std::string st = ANSCENTER::ANSUtilities::AESDecryption(encryptedString, inputKey);
@@ -667,6 +746,7 @@ extern "C" ANSULT_API int AESDecryption(const char* encryptedString, const char
}
extern "C" ANSULT_API int ListASWTopicsCpp(ANSCENTER::ANSUtilities** Handle, std::string& arnTopics) {
ANS_DBG("ANSUTIL","ListASWTopicsCpp: *Handle=%p", (void*)(Handle ? *Handle : nullptr));
if (Handle == nullptr || *Handle == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(*Handle));
if (!guard) return 0;
@@ -687,6 +767,7 @@ extern "C" ANSULT_API int ListASWTopicsCpp(ANSCENTER::ANSUtilities** Handle, st
}
}
extern "C" ANSULT_API int AESEncryptionCpp(const char* inputString, const char* inputKey, std::string& encryptedString) {
ANS_DBG("ANSUTIL","AESEncryptionCpp: inputString len=%zu", inputString ? strlen(inputString) : 0);
if (inputString == nullptr || inputKey == nullptr) return 0;
try {
encryptedString = ANSCENTER::ANSUtilities::AESEncryption(inputString, inputKey);
@@ -705,6 +786,7 @@ extern "C" ANSULT_API int AESEncryptionCpp(const char* inputString, const char*
}
}
extern "C" ANSULT_API int AESDecryptionCpp(const char* encryptedString, const char* inputKey, std::string& decryptionMessage) {
ANS_DBG("ANSUTIL","AESDecryptionCpp: encryptedString len=%zu", encryptedString ? strlen(encryptedString) : 0);
if (encryptedString == nullptr || inputKey == nullptr) return 0;
try {
decryptionMessage = ANSCENTER::ANSUtilities::AESDecryption(encryptedString, inputKey);
@@ -723,6 +805,8 @@ extern "C" ANSULT_API int AESDecryptionCpp(const char* encryptedString, const c
}
}
extern "C" ANSULT_API int AuthenticateGCS(ANSCENTER::ANSUtilities** Handle, const char* jsonKeyString) {
ANS_DBG("ANSUTIL","AuthenticateGCS: *Handle=%p, jsonKey len=%zu",
(void*)(Handle ? *Handle : nullptr), jsonKeyString ? strlen(jsonKeyString) : 0);
if (Handle == nullptr || *Handle == nullptr || jsonKeyString == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(*Handle));
if (!guard) return 0;
@@ -738,6 +822,11 @@ extern "C" ANSULT_API int AuthenticateGCS(ANSCENTER::ANSUtilities** Handle, con
}
}
extern "C" ANSULT_API int UploadMatToGCS(ANSCENTER::ANSUtilities** Handle, const char* bucketName, const char* objectName, unsigned char* jpeg_string, int32 bufferLength) {
ANS_DBG("ANSUTIL","UploadMatToGCS: *Handle=%p, bucket=%s, object=%s, len=%d",
(void*)(Handle ? *Handle : nullptr),
bucketName ? bucketName : "(null)",
objectName ? objectName : "(null)",
bufferLength);
if (Handle == nullptr || *Handle == nullptr || bucketName == nullptr || objectName == nullptr || jpeg_string == nullptr || bufferLength <= 0) return 0;
UtilHandleGuard guard(AcquireUtilHandle(*Handle));
if (!guard) return 0;
@@ -757,6 +846,10 @@ extern "C" ANSULT_API int UploadMatToGCS(ANSCENTER::ANSUtilities** Handle, cons
}
}
extern "C" ANSULT_API int UploadImageToGCS(ANSCENTER::ANSUtilities** Handle, const char* bucketName, const char* objectName, cv::Mat image) {
ANS_DBG("ANSUTIL","UploadImageToGCS: *Handle=%p, bucket=%s, object=%s",
(void*)(Handle ? *Handle : nullptr),
bucketName ? bucketName : "(null)",
objectName ? objectName : "(null)");
if (Handle == nullptr || *Handle == nullptr || bucketName == nullptr || objectName == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(*Handle));
if (!guard) return 0;
@@ -773,6 +866,11 @@ extern "C" ANSULT_API int UploadImageToGCS(ANSCENTER::ANSUtilities** Handle, co
}
}
extern "C" ANSULT_API int SetupServerProxy(ANSCENTER::ANSUtilities** Handle, const char* hostName, int port, const char* userName, const char* passWord) {
ANS_DBG("ANSUTIL","SetupServerProxy: *Handle=%p, hostName=%s, port=%d, userName=%s",
(void*)(Handle ? *Handle : nullptr),
hostName ? hostName : "(null)",
port,
userName ? userName : "(null)");
if (Handle == nullptr || *Handle == nullptr || hostName == nullptr || userName == nullptr || passWord == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(*Handle));
if (!guard) return 0;
@@ -797,6 +895,11 @@ extern "C" ANSULT_API int SendEmail(const char* smtpServer, int port,
const char* ccEmails,
const char* bccEmails)
{
ANS_DBG("ANSUTIL","SendEmail: smtpServer=%s, port=%d, userName=%s, fromEmailSender=%s, toEmails=%s",
smtpServer ? smtpServer : "(null)", port,
userName ? userName : "(null)",
fromEmailSender ? fromEmailSender : "(null)",
toEmails ? toEmails : "(null)");
if (smtpServer == nullptr || userName == nullptr || password == nullptr ||
title == nullptr || fromEmailSender == nullptr) return 0;
try {
@@ -852,6 +955,7 @@ extern "C" ANSULT_API int SendEmail(const char* smtpServer, int port,
}
extern "C" ANSULT_API int RebootSystem() {
ANS_DBG("ANSUTIL","RebootSystem called");
try {
if (ANSCENTER::ANSUtilities::RestartPC()) return 1;
else return 0;
@@ -862,6 +966,8 @@ extern "C" ANSULT_API int RebootSystem() {
}
extern "C" ANSULT_API int ANSConvertUTF8ToUTF16LE(const char* utf8Str, LStrHandle result, int includeBOM) {
ANS_DBG("ANSUTIL","ANSConvertUTF8ToUTF16LE: utf8Str len=%zu, includeBOM=%d",
utf8Str ? strlen(utf8Str) : 0, includeBOM);
try {
if (!utf8Str || !result) return -1;
int len = (int)strlen(utf8Str);
@@ -931,6 +1037,7 @@ extern "C" ANSULT_API int ANSConvertUTF8ToUTF16LE(const char* utf8Str, LStrHandl
}
extern "C" ANSULT_API int ANSConvertUTF16LEToUTF8(const unsigned char* utf16leBytes, int byteLen, LStrHandle result) {
ANS_DBG("ANSUTIL","ANSConvertUTF16LEToUTF8: byteLen=%d", byteLen);
try {
if (!utf16leBytes || byteLen <= 0 || !result) return -1;
const unsigned char* data = utf16leBytes;
@@ -970,6 +1077,7 @@ extern "C" ANSULT_API int ANSConvertUTF16LEToUTF8(const unsigned char* utf16leBy
}
extern "C" ANSULT_API int ANSDecodeJsonUnicodeToUTF16LE(const char* escapedStr, LStrHandle result) {
ANS_DBG("ANSUTIL","ANSDecodeJsonUnicodeToUTF16LE: escapedStr len=%zu", escapedStr ? strlen(escapedStr) : 0);
try {
if (!escapedStr || !result) return -1;
std::string decoded = ANSCENTER::ANSUtilities::DecodeJsonUnicodeToUTF16LE(escapedStr);
@@ -985,6 +1093,7 @@ extern "C" ANSULT_API int ANSDecodeJsonUnicodeToUTF16LE(const char* escapedStr,
}
extern "C" ANSULT_API int ANSConvertUTF16LEToUnicodeEscapes(const unsigned char* utf16leBytes, int byteLen, LStrHandle result) {
ANS_DBG("ANSUTIL","ANSConvertUTF16LEToUnicodeEscapes: byteLen=%d", byteLen);
try {
if (!utf16leBytes || byteLen <= 0 || !result) return -1;
std::string escaped = ANSCENTER::ANSUtilities::ConvertUTF16LEToUnicodeEscapes(
@@ -1042,6 +1151,7 @@ static const unsigned char* StripBOM(const unsigned char* data, int& len) {
// 2. Contains UTF-16LE (BOM or 0x00 bytes) → RepairLabVIEWUTF16LE (normalizes
// mixed UTF-8/UTF-16LE + lone spaces to clean UTF-16LE) → convert to UTF-8
extern "C" ANSULT_API int ANSConvertUTF16LEToUTF8_LV(LStrHandle input, LStrHandle result) {
ANS_DBG("ANSUTIL","ANSConvertUTF16LEToUTF8_LV: input=%p, result=%p", (void*)input, (void*)result);
try {
if (!input || !result) return -1;
int byteLen = (*input)->cnt;
@@ -1097,6 +1207,7 @@ extern "C" ANSULT_API int ANSConvertUTF16LEToUTF8_LV(LStrHandle input, LStrHandl
// 1. Pure UTF-8 → convert UTF-8 to Unicode escapes (\uXXXX)
// 2. Contains UTF-16LE → RepairLabVIEWUTF16LE → convert to Unicode escapes
extern "C" ANSULT_API int ANSConvertUTF16LEToUnicodeEscapes_LV(LStrHandle input, LStrHandle result) {
ANS_DBG("ANSUTIL","ANSConvertUTF16LEToUnicodeEscapes_LV: input=%p, result=%p", (void*)input, (void*)result);
try {
if (!input || !result) return -1;
int byteLen = (*input)->cnt;
@@ -1163,6 +1274,7 @@ extern "C" ANSULT_API int ANSConvertUTF16LEToUnicodeEscapes_LV(LStrHandle input,
}
extern "C" ANSULT_API int ANSConvertUnicodeEscapesToUTF8(const char* escapedStr, LStrHandle result) {
ANS_DBG("ANSUTIL","ANSConvertUnicodeEscapesToUTF8: escapedStr len=%zu", escapedStr ? strlen(escapedStr) : 0);
try {
if (!escapedStr || !result) return -1;
int len = (int)strlen(escapedStr);
@@ -1180,6 +1292,7 @@ extern "C" ANSULT_API int ANSConvertUnicodeEscapesToUTF8(const char* escapedStr,
}
extern "C" ANSULT_API int ANSConvertUTF8ToUnicodeEscapes(const char* utf8Str, LStrHandle result) {
ANS_DBG("ANSUTIL","ANSConvertUTF8ToUnicodeEscapes: utf8Str len=%zu", utf8Str ? strlen(utf8Str) : 0);
try {
if (!utf8Str || !result) return -1;
int len = (int)strlen(utf8Str);
@@ -1197,6 +1310,7 @@ extern "C" ANSULT_API int ANSConvertUTF8ToUnicodeEscapes(const char* utf8Str, LS
}
extern "C" ANSULT_API int ANSDoubleEscapeUnicode(const char* str, LStrHandle result) {
ANS_DBG("ANSUTIL","ANSDoubleEscapeUnicode: str len=%zu", str ? strlen(str) : 0);
try {
if (!str || !result) return -1;
int len = (int)strlen(str);
@@ -1214,6 +1328,7 @@ extern "C" ANSULT_API int ANSDoubleEscapeUnicode(const char* str, LStrHandle res
}
extern "C" ANSULT_API int ANSConvertUTF8ToDoubleEscapedUnicode(const char* utf8Str, LStrHandle result) {
ANS_DBG("ANSUTIL","ANSConvertUTF8ToDoubleEscapedUnicode: utf8Str len=%zu", utf8Str ? strlen(utf8Str) : 0);
try {
if (!utf8Str || !result) return -1;
int len = (int)strlen(utf8Str);
@@ -1231,6 +1346,7 @@ extern "C" ANSULT_API int ANSConvertUTF8ToDoubleEscapedUnicode(const char* utf8S
}
extern "C" ANSULT_API int ANSUnescapeDoubleEscapedUnicode(const char* str, LStrHandle result) {
ANS_DBG("ANSUTIL","ANSUnescapeDoubleEscapedUnicode: str len=%zu", str ? strlen(str) : 0);
try {
if (!str || !result) return -1;
int len = (int)strlen(str);
@@ -1266,7 +1382,7 @@ extern "C" ANSULT_API int ANSUnescapeDoubleEscapedUnicode(const char* str, LStrH
// 1 : success, *Handle now points to a new registered instance
// 0 : invalid arg, alloc failure, or Initialize() failed
extern "C" ANSULT_API int CreateANSAWSHandle(ANSCENTER::ANSAWSS3** Handle, const char* licenseKey) {
AWSDbg("[ANSAWS] Create called: HandlePtr=%p, *Handle(in)=%p (input ignored, always allocates new)\n",
ANS_DBG("ANSAWS", "Create called: HandlePtr=%p, *Handle(in)=%p (input ignored, always allocates new)",
(void*)Handle, Handle ? (void*)*Handle : nullptr);
if (Handle == nullptr || licenseKey == nullptr) return 0;
*Handle = nullptr;
@@ -1276,7 +1392,7 @@ extern "C" ANSULT_API int CreateANSAWSHandle(ANSCENTER::ANSAWSS3** Handle, cons
if (*Handle == nullptr) return 0;
if ((*Handle)->Initialize(licenseKey)) {
RegisterAWSHandle(*Handle);
AWSDbg("[ANSAWS] Create OK: *Handle(out)=%p (uint=%llu) -- LabVIEW will see this number\n",
ANS_DBG("ANSAWS", "Create OK: *Handle(out)=%p (uint=%llu) -- LabVIEW will see this number",
(void*)*Handle, (unsigned long long)(uintptr_t)*Handle);
return 1;
}
@@ -1304,25 +1420,25 @@ extern "C" ANSULT_API int CreateANSAWSHandle(ANSCENTER::ANSAWSS3** Handle, cons
static int ReleaseANSAWSHandle_Impl(ANSCENTER::ANSAWSS3** Handle) {
try {
if (!Handle || !*Handle) {
AWSDbg("[ANSAWS] Release: noop (Handle or *Handle was null)\n");
ANS_DBG("ANSAWS", "Release: noop (Handle or *Handle was null)");
return 1;
}
ANSCENTER::ANSAWSS3* h = *Handle;
AWSDbg("[ANSAWS] Release called: handle=%p (uint=%llu)\n",
ANS_DBG("ANSAWS", "Release called: handle=%p (uint=%llu)",
(void*)h, (unsigned long long)(uintptr_t)h);
if (!UnregisterAWSHandle(h)) {
AWSDbg("[ANSAWS] Release: handle %p not in registry, clearing wire only\n", (void*)h);
ANS_DBG("ANSAWS", "Release: handle %p not in registry, clearing wire only", (void*)h);
*Handle = nullptr;
return 1;
}
delete h;
*Handle = nullptr;
AWSDbg("[ANSAWS] Release OK: handle %p deleted, registry now has %zu entries\n",
ANS_DBG("ANSAWS", "Release OK: handle %p deleted, registry now has %zu entries",
(void*)h, AWSHandleRegistry().size());
return 1;
}
catch (...) {
AWSDbg("[ANSAWS] Release EXCEPTION: clearing wire and returning 0\n");
ANS_DBG("ANSAWS", "Release EXCEPTION: clearing wire and returning 0");
if (Handle) *Handle = nullptr;
return 0;
}
@@ -1333,25 +1449,25 @@ extern "C" ANSULT_API int ReleaseANSAWSHandle(ANSCENTER::ANSAWSS3** Handle) {
return ReleaseANSAWSHandle_Impl(Handle);
}
__except (EXCEPTION_EXECUTE_HANDLER) {
AWSDbg("[ANSAWS] Release SEH EXCEPTION: clearing wire and returning 0\n");
ANS_DBG("ANSAWS", "Release SEH EXCEPTION: clearing wire and returning 0");
if (Handle) *Handle = nullptr;
return 0;
}
}
extern "C" ANSULT_API int ConnectANSAWSHandle(ANSCENTER::ANSAWSS3** Handle, const char* baseDomain, const char* bucketRegion, const char* serviceName, int port, int bTls, int autoReconnect, int* awsPath) {
AWSDbg("[ANSAWS] Connect called: *Handle=%p, baseDomain=%s, region=%s, service=%s, port=%d, tls=%d, autoReconnect=%d\n",
ANS_DBG("ANSAWS", "Connect called: *Handle=%p, baseDomain=%s, region=%s, service=%s, port=%d, tls=%d, autoReconnect=%d",
Handle ? (void*)*Handle : nullptr,
baseDomain ? baseDomain : "(null)",
bucketRegion ? bucketRegion : "(null)",
serviceName ? serviceName : "(null)",
port, bTls, autoReconnect);
if (Handle == nullptr || *Handle == nullptr || awsPath == nullptr) {
AWSDbg("[ANSAWS] Connect: returning 0 (null arg)\n");
ANS_DBG("ANSAWS", "Connect: returning 0 (null arg)");
return 0;
}
AWSHandleGuard guard(AcquireAWSHandle(*Handle));
if (!guard) {
AWSDbg("[ANSAWS] Connect: returning 0 (handle %p not in registry)\n", (void*)*Handle);
ANS_DBG("ANSAWS", "Connect: returning 0 (handle %p not in registry)", (void*)*Handle);
return 0;
}
try {
@@ -1360,73 +1476,73 @@ extern "C" ANSULT_API int ConnectANSAWSHandle(ANSCENTER::ANSAWSS3** Handle, con
bool awsPathBool = true;
int result = guard.get()->Connect(baseDomain, bucketRegion, serviceName, port, bTlsBool, autoReconnectBool, awsPathBool);
*awsPath = awsPathBool ? 1 : 0;
AWSDbg("[ANSAWS] Connect result: %d (1=connected, 0=failed, 2=no internet) awsPath=%d\n", result, *awsPath);
ANS_DBG("ANSAWS", "Connect result: %d (1=connected, 0=failed, 2=no internet) awsPath=%d", result, *awsPath);
return result; // 1 = connected, 0 = failed, 2 = no internet (retrying)
}
catch (std::exception& e) {
AWSDbg("[ANSAWS] Connect EXCEPTION: %s\n", e.what());
ANS_DBG("ANSAWS", "Connect EXCEPTION: %s", e.what());
return 0;
}
catch (...) {
AWSDbg("[ANSAWS] Connect EXCEPTION: unknown\n");
ANS_DBG("ANSAWS", "Connect EXCEPTION: unknown");
return 0;
}
}
extern "C" ANSULT_API int SetProxyANSAWSHandle(ANSCENTER::ANSAWSS3** Handle, const char* proxyHost, int proxyPort, const char* proxyUsername, const char* proxyPassword) {
AWSDbg("[ANSAWS] SetProxy called: *Handle=%p, host=%s, port=%d, user=%s\n",
ANS_DBG("ANSAWS", "SetProxy called: *Handle=%p, host=%s, port=%d, user=%s",
Handle ? (void*)*Handle : nullptr,
proxyHost ? proxyHost : "(null)",
proxyPort,
proxyUsername ? proxyUsername : "(null)");
if (Handle == nullptr || *Handle == nullptr) {
AWSDbg("[ANSAWS] SetProxy: returning 0 (null arg)\n");
ANS_DBG("ANSAWS", "SetProxy: returning 0 (null arg)");
return 0;
}
AWSHandleGuard guard(AcquireAWSHandle(*Handle));
if (!guard) {
AWSDbg("[ANSAWS] SetProxy: returning 0 (handle %p not in registry)\n", (void*)*Handle);
ANS_DBG("ANSAWS", "SetProxy: returning 0 (handle %p not in registry)", (void*)*Handle);
return 0;
}
try {
if (guard.get()->SetServerProxy(proxyHost, proxyPort, proxyUsername, proxyPassword)) {
AWSDbg("[ANSAWS] SetProxy OK\n");
ANS_DBG("ANSAWS", "SetProxy OK");
return 1;
}
else {
AWSDbg("[ANSAWS] SetProxy FAILED (SetServerProxy returned false)\n");
ANS_DBG("ANSAWS", "SetProxy FAILED (SetServerProxy returned false)");
return 0;
}
}
catch (std::exception& e) {
AWSDbg("[ANSAWS] SetProxy EXCEPTION: %s\n", e.what());
ANS_DBG("ANSAWS", "SetProxy EXCEPTION: %s", e.what());
return 0;
}
catch (...) {
AWSDbg("[ANSAWS] SetProxy EXCEPTION: unknown\n");
ANS_DBG("ANSAWS", "SetProxy EXCEPTION: unknown");
return 0;
}
}
extern "C" ANSULT_API int SetAuthenticationANSAWSHandle(ANSCENTER::ANSAWSS3** Handle, const char* accessKey, const char* secretKey) {
AWSDbg("[ANSAWS] SetAuth called: *Handle=%p, accessKey=%.6s... (length-only secretKey=%zu)\n",
ANS_DBG("ANSAWS", "SetAuth called: *Handle=%p, accessKey=%.6s... (length-only secretKey=%zu)",
Handle ? (void*)*Handle : nullptr,
accessKey ? accessKey : "(null)",
secretKey ? strlen(secretKey) : 0);
if (Handle == nullptr || *Handle == nullptr ) {
AWSDbg("[ANSAWS] SetAuth: returning 0 (null arg)\n");
ANS_DBG("ANSAWS", "SetAuth: returning 0 (null arg)");
return 0;
}
AWSHandleGuard guard(AcquireAWSHandle(*Handle));
if (!guard) {
AWSDbg("[ANSAWS] SetAuth: returning 0 (handle %p not in registry)\n", (void*)*Handle);
ANS_DBG("ANSAWS", "SetAuth: returning 0 (handle %p not in registry)", (void*)*Handle);
return 0;
}
try {
if (guard.get()->SetAuthentication(accessKey, secretKey)) {
AWSDbg("[ANSAWS] SetAuth OK\n");
ANS_DBG("ANSAWS", "SetAuth OK");
return 1;
}
else {
AWSDbg("[ANSAWS] SetAuth FAILED (SetAuthentication returned false)\n");
ANS_DBG("ANSAWS", "SetAuth FAILED (SetAuthentication returned false)");
return 0;
}
}
@@ -1936,7 +2052,7 @@ extern "C" ANSULT_API int UploadJpegImageANSAWSHandle(ANSCENTER::ANSAWSS3** Han
}
}
extern "C" ANSULT_API int UploadPrefixJpegImageANSAWSHandle(ANSCENTER::ANSAWSS3** Handle, const char* bucketName, const char* prefix, unsigned char* jpeg_string, int32 bufferLength, const char* fileName, LStrHandle uploadedFilePath) {
AWSDbg("[ANSAWS] Upload called: HandlePtr=%p, *Handle=%p (uint=%llu), bucket=%s, prefix=%s, file=%s, len=%d\n",
ANS_DBG("ANSAWS", "Upload called: HandlePtr=%p, *Handle=%p (uint=%llu), bucket=%s, prefix=%s, file=%s, len=%d",
(void*)Handle,
Handle ? (void*)*Handle : nullptr,
Handle && *Handle ? (unsigned long long)(uintptr_t)*Handle : 0ULL,
@@ -1949,12 +2065,12 @@ extern "C" ANSULT_API int UploadPrefixJpegImageANSAWSHandle(ANSCENTER::ANSAWSS3
jpeg_string == nullptr || bufferLength <= 0 ||
fileName == nullptr)
{
AWSDbg("[ANSAWS] Upload: returning 0 (null/invalid arg)\n");
ANS_DBG("ANSAWS", "Upload: returning 0 (null/invalid arg)");
return 0;
}
AWSHandleGuard guard(AcquireAWSHandle(*Handle));
if (!guard) {
AWSDbg("[ANSAWS] Upload: returning -1 (handle %p not in registry)\n", (void*)*Handle);
ANS_DBG("ANSAWS", "Upload: returning -1 (handle %p not in registry)", (void*)*Handle);
return -1;
}
try {
@@ -1966,23 +2082,23 @@ extern "C" ANSULT_API int UploadPrefixJpegImageANSAWSHandle(ANSCENTER::ANSAWSS3
(*uploadedFilePath)->cnt = size;
memcpy((*uploadedFilePath)->str, outPath.c_str(), size);
}
AWSDbg("[ANSAWS] Upload OK (1): file=%s -> %s\n",
ANS_DBG("ANSAWS", "Upload OK (1): file=%s -> %s",
fileName ? fileName : "(null)", outPath.c_str());
return 1;
}
else {
AWSDbg("[ANSAWS] Upload FAILED (-2): file=%s, UploadPrefixJpegImage returned false\n",
ANS_DBG("ANSAWS", "Upload FAILED (-2): file=%s, UploadPrefixJpegImage returned false",
fileName ? fileName : "(null)");
return -2;
}
}
catch (std::exception& e) {
AWSDbg("[ANSAWS] Upload EXCEPTION (-3): file=%s, what=%s\n",
ANS_DBG("ANSAWS", "Upload EXCEPTION (-3): file=%s, what=%s",
fileName ? fileName : "(null)", e.what());
return -3;
}
catch (...) {
AWSDbg("[ANSAWS] Upload EXCEPTION (-4): file=%s, unknown exception\n",
ANS_DBG("ANSAWS", "Upload EXCEPTION (-4): file=%s, unknown exception",
fileName ? fileName : "(null)");
return -4;
}
@@ -2112,6 +2228,7 @@ extern "C" ANSULT_API int UploadPrefixJpegImageANSAWSHandle_CPP(ANSCENTER::ANSAW
// ── ANSUtilities V2 ──
extern "C" ANSULT_API int GetFCMAccessToken_V2(uint64_t handleVal, const char* privateKey, LStrHandle accessToken) {
ANS_DBG("ANSUTIL","GetFCMAccessToken_V2: handleVal=%llu", (unsigned long long)handleVal);
auto* _v2h = reinterpret_cast<ANSCENTER::ANSUtilities*>(handleVal); if (!_v2h) return 0;
if (privateKey == nullptr || accessToken == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(_v2h));
@@ -2134,6 +2251,8 @@ extern "C" ANSULT_API int GetFCMAccessToken_V2(uint64_t handleVal, const char* p
}
extern "C" ANSULT_API int CreateAWSSNSTopic_V2(uint64_t handleVal, const char* snsTopicName, LStrHandle arnTopic) {
ANS_DBG("ANSUTIL","CreateAWSSNSTopic_V2: handleVal=%llu, snsTopicName=%s",
(unsigned long long)handleVal, snsTopicName ? snsTopicName : "(null)");
auto* _v2h = reinterpret_cast<ANSCENTER::ANSUtilities*>(handleVal); if (!_v2h) return 0;
if (snsTopicName == nullptr || arnTopic == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(_v2h));
@@ -2156,6 +2275,8 @@ extern "C" ANSULT_API int CreateAWSSNSTopic_V2(uint64_t handleVal, const char* s
}
extern "C" ANSULT_API int DeleteAWSSNSTopic_V2(uint64_t handleVal, const char* arnTopic) {
ANS_DBG("ANSUTIL","DeleteAWSSNSTopic_V2: handleVal=%llu, arnTopic=%s",
(unsigned long long)handleVal, arnTopic ? arnTopic : "(null)");
auto* _v2h = reinterpret_cast<ANSCENTER::ANSUtilities*>(handleVal); if (!_v2h) return 0;
if (arnTopic == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(_v2h));
@@ -2169,6 +2290,7 @@ extern "C" ANSULT_API int DeleteAWSSNSTopic_V2(uint64_t handleVal, const char* a
}
extern "C" ANSULT_API int ListASWTopics_V2(uint64_t handleVal, LStrHandle arnTopics) {
ANS_DBG("ANSUTIL","ListASWTopics_V2: handleVal=%llu", (unsigned long long)handleVal);
auto* _v2h = reinterpret_cast<ANSCENTER::ANSUtilities*>(handleVal); if (!_v2h) return 0;
if (arnTopics == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(_v2h));
@@ -2191,6 +2313,10 @@ extern "C" ANSULT_API int ListASWTopics_V2(uint64_t handleVal, LStrHandle arnTop
}
extern "C" ANSULT_API int SubcribeSMSPhoneNumberAWSSNSTopic_V2(uint64_t handleVal, const char* snsTopicName, const char* phoneNumber, LStrHandle subscribedARN) {
ANS_DBG("ANSUTIL","SubcribeSMSPhoneNumberAWSSNSTopic_V2: handleVal=%llu, snsTopicName=%s, phoneNumber=%s",
(unsigned long long)handleVal,
snsTopicName ? snsTopicName : "(null)",
phoneNumber ? phoneNumber : "(null)");
auto* _v2h = reinterpret_cast<ANSCENTER::ANSUtilities*>(handleVal); if (!_v2h) return 0;
if (snsTopicName == nullptr || phoneNumber == nullptr || subscribedARN == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(_v2h));
@@ -2213,6 +2339,10 @@ extern "C" ANSULT_API int SubcribeSMSPhoneNumberAWSSNSTopic_V2(uint64_t handleVa
}
extern "C" ANSULT_API int SubcribeEmailAddressAWSSNSTopic_V2(uint64_t handleVal, const char* snsTopicName, const char* emailAddress, LStrHandle subscribedARN) {
ANS_DBG("ANSUTIL","SubcribeEmailAddressAWSSNSTopic_V2: handleVal=%llu, snsTopicName=%s, emailAddress=%s",
(unsigned long long)handleVal,
snsTopicName ? snsTopicName : "(null)",
emailAddress ? emailAddress : "(null)");
auto* _v2h = reinterpret_cast<ANSCENTER::ANSUtilities*>(handleVal); if (!_v2h) return 0;
if (snsTopicName == nullptr || emailAddress == nullptr || subscribedARN == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(_v2h));
@@ -2235,6 +2365,10 @@ extern "C" ANSULT_API int SubcribeEmailAddressAWSSNSTopic_V2(uint64_t handleVal,
}
extern "C" ANSULT_API int SendMessageToAWSSNSTopic_V2(uint64_t handleVal, const char* snsTopicName, const char* subjectContent, const char* messageContent, LStrHandle messageId) {
ANS_DBG("ANSUTIL","SendMessageToAWSSNSTopic_V2: handleVal=%llu, snsTopicName=%s, subject=%s",
(unsigned long long)handleVal,
snsTopicName ? snsTopicName : "(null)",
subjectContent ? subjectContent : "(null)");
auto* _v2h = reinterpret_cast<ANSCENTER::ANSUtilities*>(handleVal); if (!_v2h) return 0;
if (snsTopicName == nullptr || subjectContent == nullptr || messageContent == nullptr || messageId == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(_v2h));
@@ -2257,6 +2391,9 @@ extern "C" ANSULT_API int SendMessageToAWSSNSTopic_V2(uint64_t handleVal, const
}
extern "C" ANSULT_API int SendMessageToPhoneNumber_V2(uint64_t handleVal, const char* phoneNumber, const char* messageContent, LStrHandle messageId) {
ANS_DBG("ANSUTIL","SendMessageToPhoneNumber_V2: handleVal=%llu, phoneNumber=%s",
(unsigned long long)handleVal,
phoneNumber ? phoneNumber : "(null)");
auto* _v2h = reinterpret_cast<ANSCENTER::ANSUtilities*>(handleVal); if (!_v2h) return 0;
if (phoneNumber == nullptr || messageContent == nullptr || messageId == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(_v2h));
@@ -2279,6 +2416,11 @@ extern "C" ANSULT_API int SendMessageToPhoneNumber_V2(uint64_t handleVal, const
}
extern "C" ANSULT_API int SetupServerProxy_V2(uint64_t handleVal, const char* hostName, int port, const char* userName, const char* passWord) {
ANS_DBG("ANSUTIL","SetupServerProxy_V2: handleVal=%llu, hostName=%s, port=%d, userName=%s",
(unsigned long long)handleVal,
hostName ? hostName : "(null)",
port,
userName ? userName : "(null)");
auto* _v2h = reinterpret_cast<ANSCENTER::ANSUtilities*>(handleVal); if (!_v2h) return 0;
if (hostName == nullptr || userName == nullptr || passWord == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(_v2h));
@@ -2292,6 +2434,9 @@ extern "C" ANSULT_API int SetupServerProxy_V2(uint64_t handleVal, const char* ho
}
extern "C" ANSULT_API int AuthenticateGCS_V2(uint64_t handleVal, const char* jsonKeyString) {
ANS_DBG("ANSUTIL","AuthenticateGCS_V2: handleVal=%llu, jsonKey len=%zu",
(unsigned long long)handleVal,
jsonKeyString ? strlen(jsonKeyString) : 0);
auto* _v2h = reinterpret_cast<ANSCENTER::ANSUtilities*>(handleVal); if (!_v2h) return 0;
if (jsonKeyString == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(_v2h));
@@ -2305,6 +2450,11 @@ extern "C" ANSULT_API int AuthenticateGCS_V2(uint64_t handleVal, const char* jso
}
extern "C" ANSULT_API int UploadMatToGCS_V2(uint64_t handleVal, const char* bucketName, const char* objectName, unsigned char* jpeg_string, int32 bufferLength) {
ANS_DBG("ANSUTIL","UploadMatToGCS_V2: handleVal=%llu, bucket=%s, object=%s, len=%d",
(unsigned long long)handleVal,
bucketName ? bucketName : "(null)",
objectName ? objectName : "(null)",
bufferLength);
auto* _v2h = reinterpret_cast<ANSCENTER::ANSUtilities*>(handleVal); if (!_v2h) return 0;
if (bucketName == nullptr || objectName == nullptr || jpeg_string == nullptr || bufferLength <= 0) return 0;
UtilHandleGuard guard(AcquireUtilHandle(_v2h));
@@ -2318,6 +2468,10 @@ extern "C" ANSULT_API int UploadMatToGCS_V2(uint64_t handleVal, const char* buck
}
extern "C" ANSULT_API int UploadImageToGCS_V2(uint64_t handleVal, const char* bucketName, const char* objectName, cv::Mat image) {
ANS_DBG("ANSUTIL","UploadImageToGCS_V2: handleVal=%llu, bucket=%s, object=%s",
(unsigned long long)handleVal,
bucketName ? bucketName : "(null)",
objectName ? objectName : "(null)");
auto* _v2h = reinterpret_cast<ANSCENTER::ANSUtilities*>(handleVal); if (!_v2h) return 0;
if (bucketName == nullptr || objectName == nullptr) return 0;
UtilHandleGuard guard(AcquireUtilHandle(_v2h));