// Minimal ATL string-conversion shim for the WinTesla engine port.
// The engine only uses USES_CONVERSION + W2A/A2W (wide<->ANSI) from ATL; we provide them
// without the full ATL component. Rotating static buffers cover multiple conversions per statement.
#pragma once
#include <windows.h>

#define USES_CONVERSION ((void)0)

static inline char* _shim_w2a(const wchar_t* w) {
    static char bufs[16][1024];
    static int idx = 0;
    char* b = bufs[idx++ & 15];
    if (!w) { b[0] = 0; return b; }
    WideCharToMultiByte(CP_ACP, 0, w, -1, b, 1024, NULL, NULL);
    return b;
}
static inline wchar_t* _shim_a2w(const char* a) {
    static wchar_t bufs[16][1024];
    static int idx = 0;
    wchar_t* b = bufs[idx++ & 15];
    if (!a) { b[0] = 0; return b; }
    MultiByteToWideChar(CP_ACP, 0, a, -1, b, 1024);
    return b;
}

#define W2A(x)  _shim_w2a(x)
#define A2W(x)  _shim_a2w(x)
#define W2CA(x) ((const char*)_shim_w2a(x))
#define A2CW(x) ((const wchar_t*)_shim_a2w(x))
#define OLE2A(x)  _shim_w2a(x)
#define OLE2CA(x) ((const char*)_shim_w2a(x))
