[388] | 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_c_shared_utility/macro_utils.h"
|
---|
| 8 |
|
---|
| 9 | #define OPTIONHANDLER_RESULT_VALUES \
|
---|
| 10 | OPTIONHANDLER_OK, \
|
---|
| 11 | OPTIONHANDLER_ERROR, \
|
---|
| 12 | OPTIONHANDLER_INVALIDARG
|
---|
| 13 |
|
---|
| 14 | MU_DEFINE_ENUM(OPTIONHANDLER_RESULT, OPTIONHANDLER_RESULT_VALUES)
|
---|
| 15 |
|
---|
| 16 | #ifdef __cplusplus
|
---|
| 17 | extern "C" {
|
---|
| 18 | #endif /* __cplusplus */
|
---|
| 19 |
|
---|
| 20 | #include "azure_c_shared_utility/umock_c_prod.h"
|
---|
| 21 |
|
---|
| 22 | typedef struct OPTIONHANDLER_HANDLE_DATA_TAG* OPTIONHANDLER_HANDLE;
|
---|
| 23 |
|
---|
| 24 | /*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)*/
|
---|
| 25 | /*returns NULL if it failed to produce a clone, otherwise returns a non-NULL value*/
|
---|
| 26 | /*to be implemented by every module*/
|
---|
| 27 | typedef void* (*pfCloneOption)(const char* name, const void* value);
|
---|
| 28 |
|
---|
| 29 | /*the following function pointer points to a function that frees resources allocated for an option*/
|
---|
| 30 | /*to be implemented by every module*/
|
---|
| 31 | typedef void (*pfDestroyOption)(const char* name, const void* value);
|
---|
| 32 |
|
---|
| 33 | /*the following function pointer points to a function that sets an option for a module*/
|
---|
| 34 | /*to be implemented by every module*/
|
---|
| 35 | /*returns 0 if _SetOption succeeded, any other value is error, if the option is not intended for that module, returns 0*/
|
---|
| 36 | typedef int (*pfSetOption)(void* handle, const char* name, const void* value);
|
---|
| 37 |
|
---|
| 38 | MOCKABLE_FUNCTION(, OPTIONHANDLER_HANDLE, OptionHandler_Create, pfCloneOption, cloneOption, pfDestroyOption, destroyOption, pfSetOption, setOption);
|
---|
| 39 | MOCKABLE_FUNCTION(, OPTIONHANDLER_HANDLE, OptionHandler_Clone, OPTIONHANDLER_HANDLE, handler);
|
---|
| 40 | MOCKABLE_FUNCTION(, OPTIONHANDLER_RESULT, OptionHandler_AddOption, OPTIONHANDLER_HANDLE, handle, const char*, name, const void*, value);
|
---|
| 41 | MOCKABLE_FUNCTION(, OPTIONHANDLER_RESULT, OptionHandler_FeedOptions, OPTIONHANDLER_HANDLE, handle, void*, destinationHandle);
|
---|
| 42 | MOCKABLE_FUNCTION(, void, OptionHandler_Destroy, OPTIONHANDLER_HANDLE, handle);
|
---|
| 43 |
|
---|
| 44 | #ifdef __cplusplus
|
---|
| 45 | }
|
---|
| 46 | #endif /* __cplusplus */
|
---|
| 47 |
|
---|
| 48 | #endif /*OPTIONHANDLER*/
|
---|