1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-06 00:13:33 +00:00

Added workaround for macOS LaunchD placing all parameters within quotes

This commit is contained in:
Bryan Roe
2020-02-26 13:59:21 -08:00
parent 908698fb68
commit cd111f0f6e
2 changed files with 24 additions and 0 deletions

View File

@@ -1774,6 +1774,20 @@ duk_ret_t ILibDuktape_MeshAgent_getIdleTimeout(duk_context *ctx)
return(1);
}
duk_ret_t ILibDuktape_MeshAgent_getStartupOptions(duk_context *ctx)
{
MeshAgentHostContainer *agent;
duk_push_this(ctx); // [MeshAgent]
agent = (MeshAgentHostContainer*)Duktape_GetPointerProperty(ctx, -1, MESH_AGENT_PTR);
int varLen = ILibSimpleDataStore_Cached_GetJSON(agent->masterDb, NULL, 0);
char *buffer = duk_push_fixed_buffer(ctx, varLen);
ILibSimpleDataStore_Cached_GetJSON(agent->masterDb, buffer, varLen);
duk_push_string(ctx, buffer);
duk_json_decode(ctx, -1);
return(1);
}
void ILibDuktape_MeshAgent_PUSH(duk_context *ctx, void *chain)
{
MeshAgentHostContainer *agent;
@@ -1845,6 +1859,7 @@ void ILibDuktape_MeshAgent_PUSH(duk_context *ctx, void *chain)
ILibDuktape_CreateFinalizer(ctx, ILibDuktape_MeshAgent_Finalizer);
ILibDuktape_CreateReadonlyProperty_int(ctx, "activeMicroLMS", (agent->microLMS != NULL ? 1 : 0));
ILibDuktape_CreateInstanceMethod(ctx, "restartCore", ILibDuktape_MeshAgent_dumpCoreModule, 0);
ILibDuktape_CreateInstanceMethod(ctx, "getStartupOptions", ILibDuktape_MeshAgent_getStartupOptions, 0);
#ifdef _LINKVM
ILibDuktape_CreateReadonlyProperty_int(ctx, "hasKVM", 1);
ILibDuktape_EventEmitter_CreateEventEx(emitter, "kvmConnected");

View File

@@ -114,6 +114,15 @@ void ILibSimpleDataStore_SHA384(char *data, int datalen, char* result) { util_sh
void ILibSimpleDataStore_Cached(ILibSimpleDataStore dataStore, char* key, int keyLen, char* value, int valueLen)
{
if (valueLen > 2)
{
if (value[0] == '"' && value[valueLen - 1] == '"')
{
value = value + 1;
valueLen -= 2;
}
}
ILibSimpleDataStore_Root *root = (ILibSimpleDataStore_Root*)dataStore;
if (root->cacheTable == NULL) { root->cacheTable = ILibHashtable_Create(); }
ILibSimpleDataStore_CacheEntry *entry = (ILibSimpleDataStore_CacheEntry*)ILibMemory_Allocate(sizeof(ILibSimpleDataStore_CacheEntry) + valueLen, 0, NULL, NULL);