1
0
mirror of synced 2024-11-27 15:00:49 +01:00
bananatools/board/config.c

84 lines
2.3 KiB
C
Raw Normal View History

#include <windows.h>
#include <assert.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include "board/config.h"
#include "board/bpreader.h"
#include "util/dprintf.h"
#include "util/hexstr.h"
void bpreader_config_load(struct bpreader_config *cfg, const wchar_t *filename)
{
assert(cfg != NULL);
assert(filename != NULL);
cfg->enable = GetPrivateProfileIntW(L"reader", L"enable", 1, filename);
cfg->port = GetPrivateProfileIntW(L"reader", L"port", 0, filename);
2023-09-25 09:16:26 +02:00
cfg->insert_card = GetPrivateProfileIntW(L"reader", L"insert_card", VK_RETURN, filename);
GetPrivateProfileStringW(
L"reader",
L"access_code",
L"00000000000000000000",
cfg->access_code,
_countof(cfg->access_code),
filename);
HRESULT hr = wstr_to_bytes(cfg->access_code, 20, cfg->access_code_bytes, sizeof(cfg->access_code_bytes));
if (FAILED(hr)) {
dprintf("Reader: wstr_to_bytes 1 failed! 0x%lX", hr);
}
}
void usio_config_load(struct usio_config *cfg, const wchar_t *filename)
{
assert(cfg != NULL);
assert(filename != NULL);
cfg->enable = GetPrivateProfileIntW(L"usio", L"enable", 1, filename);
}
void qr_config_load(struct qr_config *cfg, const wchar_t *filename)
{
assert(cfg != NULL);
assert(filename != NULL);
cfg->enable = GetPrivateProfileIntW(L"qr", L"enable", 1, filename);
cfg->port = GetPrivateProfileIntW(L"qr", L"port", 0, filename);
2023-09-18 10:00:09 +02:00
}
static void aime_dll_config_load(struct aime_dll_config *cfg, const wchar_t *filename)
{
assert(cfg != NULL);
assert(filename != NULL);
GetPrivateProfileStringW(
L"aimeio",
L"path",
L"",
cfg->path,
_countof(cfg->path),
filename);
}
void aime_config_load(struct aime_config *cfg, const wchar_t *filename)
{
assert(cfg != NULL);
assert(filename != NULL);
aime_dll_config_load(&cfg->dll, filename);
cfg->enable = GetPrivateProfileIntW(L"aime", L"enable", 1, filename);
}
2024-10-06 20:37:20 +02:00
void vfd_config_load(struct vfd_config *cfg, const wchar_t *filename)
{
assert(cfg != NULL);
assert(filename != NULL);
cfg->enable = GetPrivateProfileIntW(L"vfd", L"enable", 1, filename);
cfg->port = GetPrivateProfileIntW(L"vfd", L"portNo", 0, filename);
cfg->utf_conversion = GetPrivateProfileIntW(L"vfd", L"utfConversion", 0, filename);
}