diff --git a/meshcore/agentcore.c b/meshcore/agentcore.c index 557a82d..ad7f15f 100644 --- a/meshcore/agentcore.c +++ b/meshcore/agentcore.c @@ -1815,7 +1815,17 @@ duk_ret_t ILibDuktape_MeshAgent_remoteMouseRender_set(duk_context *ctx) gRemoteMouseRenderDefault = duk_require_int(ctx, 0); return(0); } +duk_ret_t ILibDuktape_MeshAgent_coreHash(duk_context *ctx) +{ + MeshAgentHostContainer *agent; + duk_push_this(ctx); // [MeshAgent] + agent = (MeshAgentHostContainer*)Duktape_GetPointerProperty(ctx, -1, MESH_AGENT_PTR); + char *hashref = ILibSimpleDataStore_GetHash(agent->masterDb, "CoreModule"); // Get the reference to the SHA384 hash for the currently running code + util_tohex(hashref, ILibSimpleDataStore_GetHashSize(), ILibScratchPad); + duk_push_string(ctx, ILibScratchPad); + return(1); +} void ILibDuktape_MeshAgent_PUSH(duk_context *ctx, void *chain) { MeshAgentHostContainer *agent; @@ -1888,6 +1898,7 @@ void ILibDuktape_MeshAgent_PUSH(duk_context *ctx, void *chain) 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); + ILibDuktape_CreateEventWithGetter(ctx, "coreHash", ILibDuktape_MeshAgent_coreHash); #ifdef _LINKVM ILibDuktape_CreateReadonlyProperty_int(ctx, "hasKVM", 1); ILibDuktape_EventEmitter_CreateEventEx(emitter, "kvmConnected"); diff --git a/microstack/ILibSimpleDataStore.c b/microstack/ILibSimpleDataStore.c index 9be9b88..08a4e1e 100644 --- a/microstack/ILibSimpleDataStore.c +++ b/microstack/ILibSimpleDataStore.c @@ -702,7 +702,11 @@ __EXPORT_TYPE char* ILibSimpleDataStore_GetHashEx(ILibSimpleDataStore dataStore, if (entry == NULL) return NULL; // If there is no in-memory entry for this key, return zero now. return entry->valueHash; } - +int ILibSimpleDataStore_GetHashSize() +{ + ILibSimpleDataStore_TableEntry e; + return((int)sizeof(e.valueHash)); +} // Delete a key and value from the data store __EXPORT_TYPE int ILibSimpleDataStore_DeleteEx(ILibSimpleDataStore dataStore, char* key, int keyLen) { diff --git a/microstack/ILibSimpleDataStore.h b/microstack/ILibSimpleDataStore.h index 5aa52e2..294ece1 100644 --- a/microstack/ILibSimpleDataStore.h +++ b/microstack/ILibSimpleDataStore.h @@ -66,9 +66,10 @@ __EXPORT_TYPE int ILibSimpleDataStore_GetEx(ILibSimpleDataStore dataStore, char* #define ILibSimpleDataStore_Get(dataStore, key, buffer, bufferLen) ILibSimpleDataStore_GetEx(dataStore, key, (int)strnlen_s(key, ILibSimpleDataStore_MaxKeyLength), buffer, bufferLen) __EXPORT_TYPE int ILibSimpleDataStore_GetInt(ILibSimpleDataStore dataStore, char* key, int defaultValue); -// Get the SHA256 hash value from the datastore for a given a key. +// Get the SHA384 hash value from the datastore for a given a key. __EXPORT_TYPE char* ILibSimpleDataStore_GetHashEx(ILibSimpleDataStore dataStore, char* key, int keyLen); #define ILibSimpleDataStore_GetHash(dataStore, key) ILibSimpleDataStore_GetHashEx(dataStore, key, (int)strnlen_s(key, ILibSimpleDataStore_MaxKeyLength)) +int ILibSimpleDataStore_GetHashSize(); // Delete a key from the data store __EXPORT_TYPE int ILibSimpleDataStore_DeleteEx(ILibSimpleDataStore dataStore, char* key, int keyLen);