Add wrappers for StringCbXXXX functions and default RegLoadXXXX.

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2019-08-26 10:27:38 +01:00
parent ed82f9d9d6
commit 907474c489
5 changed files with 42 additions and 0 deletions

View file

@ -27,6 +27,8 @@ add_library(appleii SHARED
linux/benchmark.cpp
linux/paddle.cpp
linux/version.cpp
linux/stringcb.cpp
linux/registry.cpp
Z80VICE/z80.cpp
Z80VICE/z80mem.cpp

18
source/linux/registry.cpp Normal file
View file

@ -0,0 +1,18 @@
#include "linux/wincompat.h"
#include "linux/stringcb.h"
#include "linux/interface.h"
BOOL RegLoadString (LPCTSTR section, LPCTSTR key, BOOL peruser, LPTSTR buffer, DWORD chars, LPCTSTR defaultValue)
{
BOOL success = RegLoadString(section, key, peruser, buffer, chars);
if (!success)
StringCbCopy(buffer, chars, defaultValue);
return success;
}
BOOL RegLoadValue (LPCTSTR section, LPCTSTR key, BOOL peruser, DWORD* value, DWORD defaultValue) {
BOOL success = RegLoadValue(section, key, peruser, value);
if (!success)
*value = defaultValue;
return success;
}

16
source/linux/stringcb.cpp Normal file
View file

@ -0,0 +1,16 @@
#include "linux/stringcb.h"
#include <cstring>
HRESULT StringCbCopy(char * pszDest, const size_t cbDest, const char * pszSrc)
{
strncpy(pszDest, pszSrc, cbDest - 1);
pszDest[cbDest - 1] = '\0';
return 0;
}
HRESULT StringCbCat(char * pszDest, const size_t cbDest, const char * pszSrc)
{
strncat(pszDest, pszSrc, cbDest - strlen(pszDest) - 1);
pszDest[cbDest - 1] = '\0';
return 0;
}

5
source/linux/stringcb.h Normal file
View file

@ -0,0 +1,5 @@
#include "linux/wincompat.h"
HRESULT StringCbCopy(char * pszDest, const size_t cbDest, const char * pszSrc);
HRESULT StringCbCat(char * pszDest,const size_t cbDest, const char * pszSrc);
#define StringCbPrintf snprintf

View file

@ -5,6 +5,7 @@
#include "linux/wincompat.h"
#include "linux/dummies.h"
#include "linux/stringcb.h"
#include "minizip/unzip.h"
#define FILE_BEGIN SEEK_SET