Implemented the cross-platform bits of uiInit().

This commit is contained in:
Pietro Gagliardi 2019-04-19 12:32:13 -04:00
parent 5e45afd0a2
commit 74b1e2780d
5 changed files with 48 additions and 2 deletions

36
common/init.c Normal file
View File

@ -0,0 +1,36 @@
// 19 april 2019
#include <string.h>
#include "ui.h"
#include "uipriv.h"
static int initialized = 0;
int uiprivInitCheckParams(void *options, uiInitError *err)
{
if (err == NULL)
return 0;
if (err->Size != sizeof (uiInitError))
return 0;
if (initialized)
return uiprivInitReturnError(err, "xxxxxxxxx");
if (options != NULL)
return uiprivInitReturnError(err, "xxxxxxxx");
return 1;
}
int uiprivInitReturnError(uiInitError *err, const char *msg)
{
strncpy(err->Message, msg, 256);
if (err->Message[255] != '\0')
// TODO there should be some check to make sure this doesn't happen
err->Message[255] = '\0';
return 0;
}
void uiprivMarkInitialized(void)
{
initialized = 1;
}

5
common/meson.build Normal file
View File

@ -0,0 +1,5 @@
# 23 march 2019
libui_sources += [
'common/init.c',
]

6
common/uipriv.h Normal file
View File

@ -0,0 +1,6 @@
// 19 april 2019
// init.c
extern int uiprivInitCheckParams(void *options, uiInitError *err);
extern int uiprivInitReturnError(uiInitError *err, const char *msg);
extern void uiprivMarkInitialized(void);

View File

View File

@ -140,8 +140,7 @@ libui_sources = []
libui_deps = []
libui_soversion = ''
libui_rpath = ''
#subdir('common')
libui_sources+=['dummy.c']
subdir('common')
if libui_OS == 'windows'
# subdir('windows')
install_headers('ui_windows.h')