UniMRCP  1.3.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
mrcp_engine_plugin.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2014 Arsen Chaloyan
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * $Id: mrcp_engine_plugin.h 2271 2015-02-03 03:27:46Z achaloyan@gmail.com $
17  */
18 
19 #ifndef MRCP_ENGINE_PLUGIN_H
20 #define MRCP_ENGINE_PLUGIN_H
21 
22 /**
23  * @file mrcp_engine_plugin.h
24  * @brief MRCP Engine Plugin
25  */
26 
27 #include "apr_version.h"
28 #include "apt_log.h"
29 #include "mrcp_engine_types.h"
30 
32 
33 /** Let the plugin symbols be always exported as C functions */
34 #ifdef __cplusplus
35 #define MRCP_PLUGIN_EXTERN_C extern "C"
36 #else
37 #define MRCP_PLUGIN_EXTERN_C extern
38 #endif
39 
40 /** Plugin export defines */
41 #ifdef WIN32
42 #define MRCP_PLUGIN_DECLARE(type) MRCP_PLUGIN_EXTERN_C __declspec(dllexport) type
43 #else
44 #define MRCP_PLUGIN_DECLARE(type) MRCP_PLUGIN_EXTERN_C type
45 #endif
46 
47 /** [REQUIRED] Symbol name of the main entry point in plugin DSO */
48 #define MRCP_PLUGIN_ENGINE_SYM_NAME "mrcp_plugin_create"
49 /** [REQUIRED] Symbol name of the vesrion number entry point in plugin DSO */
50 #define MRCP_PLUGIN_VERSION_SYM_NAME "mrcp_plugin_version"
51 /** [IMPLIED] Symbol name of the log accessor entry point in plugin DSO */
52 #define MRCP_PLUGIN_LOGGER_SYM_NAME "mrcp_plugin_logger_set"
53 
54 /** Prototype of engine creator (entry point of plugin DSO) */
55 typedef mrcp_engine_t* (*mrcp_plugin_creator_f)(apr_pool_t *pool);
56 
57 /** Prototype of log accessor (entry point of plugin DSO) */
59 
60 /** Declare this macro in plugins to use log routine of the server */
61 #define MRCP_PLUGIN_LOGGER_IMPLEMENT \
62  MRCP_PLUGIN_DECLARE(apt_bool_t) mrcp_plugin_logger_set(apt_logger_t *logger) \
63  { return apt_log_instance_set(logger); }
64 
65 /** Declare this macro in plugins to set plugin version */
66 #define MRCP_PLUGIN_VERSION_DECLARE \
67  MRCP_PLUGIN_DECLARE(mrcp_plugin_version_t) mrcp_plugin_version; \
68  mrcp_plugin_version_t mrcp_plugin_version = \
69  {PLUGIN_MAJOR_VERSION, PLUGIN_MINOR_VERSION, PLUGIN_PATCH_VERSION};
70 
71 
72 /** major version
73  * Major API changes that could cause compatibility problems for older
74  * plugins such as structure size changes. No binary compatibility is
75  * possible across a change in the major version.
76  */
77 #define PLUGIN_MAJOR_VERSION 1
78 
79 /** minor version
80  * Minor API changes that do not cause binary compatibility problems.
81  * Reset to 0 when upgrading PLUGIN_MAJOR_VERSION
82  */
83 #define PLUGIN_MINOR_VERSION 3
84 
85 /** patch level
86  * The Patch Level never includes API changes, simply bug fixes.
87  * Reset to 0 when upgrading PLUGIN_MINOR_VERSION
88  */
89 #define PLUGIN_PATCH_VERSION 0
90 
91 
92 /**
93  * Check at compile time if the plugin version is at least a certain
94  * level.
95  */
96 #define PLUGIN_VERSION_AT_LEAST(major,minor,patch) \
97 (((major) < PLUGIN_MAJOR_VERSION) \
98  || ((major) == PLUGIN_MAJOR_VERSION && (minor) < PLUGIN_MINOR_VERSION) \
99  || ((major) == PLUGIN_MAJOR_VERSION && (minor) == PLUGIN_MINOR_VERSION && (patch) <= PLUGIN_PATCH_VERSION))
100 
101 /** The formatted string of plugin's version */
102 #define PLUGIN_VERSION_STRING \
103  APR_STRINGIFY(PLUGIN_MAJOR_VERSION) "." \
104  APR_STRINGIFY(PLUGIN_MINOR_VERSION) "." \
105  APR_STRINGIFY(PLUGIN_PATCH_VERSION)
106 
107 /** Plugin version */
108 typedef apr_version_t mrcp_plugin_version_t;
109 
110 /** Get plugin version */
111 static APR_INLINE void mrcp_plugin_version_get(mrcp_plugin_version_t *version)
112 {
113  version->major = PLUGIN_MAJOR_VERSION;
114  version->minor = PLUGIN_MINOR_VERSION;
115  version->patch = PLUGIN_PATCH_VERSION;
116 }
117 
118 /** Check plugin version */
119 static APR_INLINE int mrcp_plugin_version_check(mrcp_plugin_version_t *version)
120 {
121  return PLUGIN_VERSION_AT_LEAST(version->major,version->minor,version->patch);
122 }
123 
125 
126 #endif /* MRCP_ENGINE_PLUGIN_H */