From 35d488e972a9dd75ce3867c000405f128b79c615 Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Sun, 15 Jan 2023 12:14:05 +0000 Subject: reorganise things a bit to align further with the actual names/structure --- .../Src/Internal/CWSecretPluginCallbacks.cpp | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 command_line/PluginLib/Src/Internal/CWSecretPluginCallbacks.cpp (limited to 'command_line/PluginLib/Src/Internal/CWSecretPluginCallbacks.cpp') diff --git a/command_line/PluginLib/Src/Internal/CWSecretPluginCallbacks.cpp b/command_line/PluginLib/Src/Internal/CWSecretPluginCallbacks.cpp new file mode 100644 index 0000000..b33ca81 --- /dev/null +++ b/command_line/PluginLib/Src/Internal/CWSecretPluginCallbacks.cpp @@ -0,0 +1,39 @@ +#include "plugin_internal.h" + +static Boolean ValidateContext(CWPluginContext context) { + return context && (context->shellSignature == CWFOURCHAR('C','W','I','E')); +} + +typedef CWResult (*cbSecretAttachHandleType)(CWPluginContext, Handle, CWMemHandle *); +typedef CWResult (*cbSecretDetachHandleType)(CWPluginContext, CWMemHandle, Handle *); +typedef CWResult (*cbSecretPeekHandleType)(CWPluginContext, CWMemHandle, Handle *); +typedef CWResult (*cbSecretGetNamedPreferencesType)(CWPluginContext, const char *, Handle *); + +CW_CALLBACK CWSecretAttachHandle(CWPluginContext context, Handle handle, CWMemHandle *memHandle) { + if (!ValidateContext(context)) + return cwErrInvalidParameter; + return ((cbSecretAttachHandleType) context->callbacks->cbInternal[0])(context, handle, memHandle); +} + +CW_CALLBACK CWSecretDetachHandle(CWPluginContext context, CWMemHandle memHandle, Handle *handle) { + if (!ValidateContext(context)) + return cwErrInvalidParameter; + return ((cbSecretDetachHandleType) context->callbacks->cbInternal[1])(context, memHandle, handle); +} + +CW_CALLBACK CWSecretPeekHandle(CWPluginContext context, CWMemHandle memHandle, Handle *handle) { + if (!ValidateContext(context)) + return cwErrInvalidParameter; + return ((cbSecretPeekHandleType) context->callbacks->cbInternal[2])(context, memHandle, handle); +} + +CW_CALLBACK CWSecretGetNamedPreferences(CWPluginContext context, const char *prefsname, Handle *prefsdata) { + if (!prefsdata) + return cwErrInvalidParameter; + + CWMemHandle memHandle; + CWResult res = CWGetNamedPreferences(context, prefsname, &memHandle); + if (!res) + res = CWSecretDetachHandle(context, memHandle, prefsdata); + return res; +} -- cgit v1.2.3