mirror of
https://github.com/djhackersdev/bemanitools.git
synced 2025-02-21 04:48:42 +01:00
launcher: make app_config.xml optional
This commit is contained in:
parent
8ae06f6f4b
commit
3b8f6ac1d9
@ -17,6 +17,7 @@
|
||||
|
||||
#include "util/codepage.h"
|
||||
#include "util/defs.h"
|
||||
#include "util/fs.h"
|
||||
#include "util/log.h"
|
||||
#include "util/mem.h"
|
||||
#include "util/str.h"
|
||||
@ -243,7 +244,13 @@ int main(int argc, const char **argv)
|
||||
|
||||
/* Invoke dll_entry_init */
|
||||
|
||||
app_config = boot_property_load(options.app_config_path);
|
||||
if (path_exists(options.app_config_path)) {
|
||||
app_config = boot_property_load(options.app_config_path);
|
||||
} else {
|
||||
log_warning("%s: app config file missing, using empty", options.app_config_path);
|
||||
app_config = boot_property_load_cstring("<param>dummy</param>");
|
||||
}
|
||||
|
||||
app_config_root = property_search(app_config, 0, "/param");
|
||||
|
||||
if (app_config_root == NULL) {
|
||||
|
@ -20,6 +20,25 @@ static int boot_property_fread(uint32_t context, void *bytes, size_t nbytes)
|
||||
return fread(bytes, 1, nbytes, f);
|
||||
}
|
||||
|
||||
struct cstring_read_handle {
|
||||
const char * buffer;
|
||||
size_t buffer_len;
|
||||
size_t offset;
|
||||
};
|
||||
|
||||
static int boot_property_cstring_read(uint32_t context, void *bytes, size_t nbytes)
|
||||
{
|
||||
int result = 0;
|
||||
struct cstring_read_handle* h = TlsGetValue(context);
|
||||
|
||||
if (h->offset < h->buffer_len){
|
||||
result = min(nbytes, h->buffer_len - h->offset);
|
||||
memcpy(bytes, (const void *)(h->buffer + h->offset), result);
|
||||
h->offset += result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
struct property *boot_property_load(const char *filename)
|
||||
{
|
||||
struct property *prop;
|
||||
@ -65,6 +84,44 @@ struct property *boot_property_load(const char *filename)
|
||||
|
||||
return prop;
|
||||
}
|
||||
struct property *boot_property_load_cstring(const char *cstring)
|
||||
{
|
||||
struct property *prop;
|
||||
void *buffer;
|
||||
int nbytes;
|
||||
uint32_t s_keyhole;
|
||||
|
||||
// see above
|
||||
struct cstring_read_handle read_handle;
|
||||
read_handle.buffer = cstring;
|
||||
read_handle.buffer_len = strlen(cstring);
|
||||
read_handle.offset = 0;
|
||||
|
||||
s_keyhole = TlsAlloc();
|
||||
TlsSetValue(s_keyhole, &read_handle);
|
||||
|
||||
nbytes = property_read_query_memsize(boot_property_cstring_read, s_keyhole, 0, 0);
|
||||
|
||||
if (nbytes < 0) {
|
||||
log_fatal("Error querying configuration string");
|
||||
}
|
||||
|
||||
buffer = xmalloc(nbytes);
|
||||
prop = property_create(
|
||||
PROPERTY_FLAG_READ | PROPERTY_FLAG_WRITE | PROPERTY_FLAG_CREATE | PROPERTY_FLAG_APPEND,
|
||||
buffer,
|
||||
nbytes
|
||||
);
|
||||
|
||||
read_handle.offset = 0;
|
||||
if (!property_insert_read(prop, 0, boot_property_cstring_read, s_keyhole)) {
|
||||
log_fatal("Error inserting configuration string");
|
||||
}
|
||||
|
||||
TlsFree(s_keyhole);
|
||||
|
||||
return prop;
|
||||
}
|
||||
|
||||
void boot_property_free(struct property *prop)
|
||||
{
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "imports/avs.h"
|
||||
|
||||
struct property *boot_property_load(const char *filename);
|
||||
struct property *boot_property_load_cstring(const char *cstring);
|
||||
void boot_property_free(struct property *prop);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user