Debian Codegraph @

src/vendor/azure-uamqp-c/deps/azure-c-shared-utility/inc/azure_c_shared_utility/optionhandler.h

raw
1 // Copyright (c) Microsoft. All rights reserved.
2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4 #ifndef OPTIONHANDLER_H
5 #define OPTIONHANDLER_H
6
7 #include "azure_macro_utils/macro_utils.h"
8 #include "umock_c/umock_c_prod.h"
9
10 #ifdef __cplusplus
11 extern "C" {
12 #endif /* __cplusplus */
13
14 #define OPTIONHANDLER_RESULT_VALUES \
15 OPTIONHANDLER_OK, \
16 OPTIONHANDLER_ERROR, \
17 OPTIONHANDLER_INVALIDARG
18
19 MU_DEFINE_ENUM_WITHOUT_INVALID(OPTIONHANDLER_RESULT, OPTIONHANDLER_RESULT_VALUES)
20
21 typedef struct OPTIONHANDLER_HANDLE_DATA_TAG* OPTIONHANDLER_HANDLE;
22
23 /*the following function pointer points to a function that produces a clone of the option specified by name and value (that is, a clone of void* value)*/
24 /*returns NULL if it failed to produce a clone, otherwise returns a non-NULL value*/
25 /*to be implemented by every module*/
26 typedef void* (*pfCloneOption)(const char* name, const void* value);
27
28 /*the following function pointer points to a function that frees resources allocated for an option*/
29 /*to be implemented by every module*/
30 typedef void (*pfDestroyOption)(const char* name, const void* value);
31
32 /*the following function pointer points to a function that sets an option for a module*/
33 /*to be implemented by every module*/
34 /*returns 0 if _SetOption succeeded, any other value is error, if the option is not intended for that module, returns 0*/
35 typedef int (*pfSetOption)(void* handle, const char* name, const void* value);
36
37 MOCKABLE_FUNCTION(, OPTIONHANDLER_HANDLE, OptionHandler_Create, pfCloneOption, cloneOption, pfDestroyOption, destroyOption, pfSetOption, setOption);
38 MOCKABLE_FUNCTION(, OPTIONHANDLER_HANDLE, OptionHandler_Clone, OPTIONHANDLER_HANDLE, handler);
39 MOCKABLE_FUNCTION(, OPTIONHANDLER_RESULT, OptionHandler_AddOption, OPTIONHANDLER_HANDLE, handle, const char*, name, const void*, value);
40 MOCKABLE_FUNCTION(, OPTIONHANDLER_RESULT, OptionHandler_FeedOptions, OPTIONHANDLER_HANDLE, handle, void*, destinationHandle);
41 MOCKABLE_FUNCTION(, void, OptionHandler_Destroy, OPTIONHANDLER_HANDLE, handle);
42
43 #ifdef __cplusplus
44 }
45 #endif /* __cplusplus */
46
47 #endif /*OPTIONHANDLER*/