OceanBase Plugin Development Kit
OceanBase Plugin Development Kit
载入中...
搜索中...
未找到
src
lib
ob_plugin_libmain.c
浏览该文件的文档.
1
/*
2
* Copyright (c) 2025 OceanBase.
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
#include <unistd.h>
17
#include <stdio.h>
18
#include "
oceanbase/ob_plugin.h
"
19
20
#ifdef __linux__
21
#include <sys/utsname.h>
22
#endif
23
24
#ifdef __cplusplus
25
extern
"C"
{
26
#endif
27
28
#ifdef LD_LIBRARY_PATH
29
const
char
__plugin_service_interp[] __attribute__((section(
".interp"
))) = LD_LIBRARY_PATH;
30
#endif
31
32
void
__print_version
(
ObPluginVersion
version)
33
{
34
printf(
"%ld.%ld.%ld"
,
35
version /
OBP_VERSION_FIELD_NUMBER
/
OBP_VERSION_FIELD_NUMBER
,
36
version /
OBP_VERSION_FIELD_NUMBER
%
OBP_VERSION_FIELD_NUMBER
,
37
version %
OBP_VERSION_FIELD_NUMBER
);
38
}
39
40
void
__print_compiler_info
()
41
{
42
const
char
*compiled_by =
"COMPILED BY: "
;
43
44
#ifdef __clang__
45
printf(
"%sclang %s\n"
, compiled_by, __clang__version__);
46
#elif defined(__GNUC__)
47
printf(
"%sGCC %s\n"
, compiled_by, __VERSION__);
48
#else
49
printf(
"Unknown compiler\n"
);
50
#endif
51
}
52
53
void
__print_os_info
()
54
{
55
#ifdef __linux__
56
struct
utsname uname_info;
57
if
(0 == uname(&uname_info)) {
58
printf(
"COMPILED ON: %s %s %s %s\n"
,
59
uname_info.sysname, uname_info.release, uname_info.version, uname_info.machine);
60
}
61
#endif
62
}
63
64
void
_ob_plugin_lib_main
()
65
{
66
extern
const
char
*
OBP_DYNAMIC_PLUGIN_NAME_VAR
;
67
extern
const
char
*
OBP_DYNAMIC_PLUGIN_BUILD_REVISION_VAR
;
68
extern
const
char
*
OBP_DYNAMIC_PLUGIN_BUILD_BRANCH_VAR
;
69
extern
const
char
*
OBP_DYNAMIC_PLUGIN_BUILD_DATE_VAR
;
70
extern
const
char
*
OBP_DYNAMIC_PLUGIN_BUILD_TIME_VAR
;
71
extern
ObPlugin
OBP_DYNAMIC_PLUGIN_PLUGIN_VAR
;
72
73
ObPlugin
*plugin = &
OBP_DYNAMIC_PLUGIN_PLUGIN_VAR
;
74
75
printf(
"OceanBase Plugin Library: %s\n"
,
OBP_DYNAMIC_PLUGIN_NAME_VAR
);
76
__print_compiler_info
();
77
__print_os_info
();
78
printf(
"\n"
);
79
printf(
"AUTHOR: %s\n"
, plugin->
author
);
80
printf(
"LIBRARY VERSION: "
);
81
__print_version
(plugin->
version
);
82
printf(
"\n"
);
83
printf(
"PLUGIN API VERSION: "
);
84
__print_version
(
OBP_PLUGIN_API_VERSION_CURRENT
);
85
printf(
"\n"
);
86
printf(
"LICENSE: %s\n"
, plugin->
license
);
87
printf(
"REVISION: %s\n"
,
OBP_DYNAMIC_PLUGIN_BUILD_REVISION_VAR
);
88
printf(
"BUILD_BRANCH: %s\n"
,
OBP_DYNAMIC_PLUGIN_BUILD_BRANCH_VAR
);
89
printf(
"BUILD_TIME: %s %s\n"
,
OBP_DYNAMIC_PLUGIN_BUILD_DATE_VAR
,
OBP_DYNAMIC_PLUGIN_BUILD_TIME_VAR
);
90
printf(
"\n"
);
91
92
_exit(0);
93
}
94
95
#ifdef __cplusplus
96
}
// extern "C"
97
#endif
ob_plugin.h
OBP_PLUGIN_API_VERSION_CURRENT
#define OBP_PLUGIN_API_VERSION_CURRENT
current API version
定义
ob_plugin.h:37
ObPluginVersion
uint64_t ObPluginVersion
The version type
定义
ob_plugin.h:124
OBP_DYNAMIC_PLUGIN_PLUGIN_VAR
#define OBP_DYNAMIC_PLUGIN_PLUGIN_VAR
定义
ob_plugin_base.h:32
OBP_DYNAMIC_PLUGIN_BUILD_DATE_VAR
#define OBP_DYNAMIC_PLUGIN_BUILD_DATE_VAR
定义
ob_plugin_base.h:35
OBP_DYNAMIC_PLUGIN_BUILD_REVISION_VAR
#define OBP_DYNAMIC_PLUGIN_BUILD_REVISION_VAR
定义
ob_plugin_base.h:33
OBP_DYNAMIC_PLUGIN_BUILD_BRANCH_VAR
#define OBP_DYNAMIC_PLUGIN_BUILD_BRANCH_VAR
定义
ob_plugin_base.h:34
OBP_DYNAMIC_PLUGIN_NAME_VAR
#define OBP_DYNAMIC_PLUGIN_NAME_VAR
定义
ob_plugin_base.h:29
OBP_VERSION_FIELD_NUMBER
#define OBP_VERSION_FIELD_NUMBER
The maximum number of each field of version
定义
ob_plugin_base.h:69
OBP_DYNAMIC_PLUGIN_BUILD_TIME_VAR
#define OBP_DYNAMIC_PLUGIN_BUILD_TIME_VAR
定义
ob_plugin_base.h:36
_ob_plugin_lib_main
void _ob_plugin_lib_main()
定义
ob_plugin_libmain.c:64
__print_version
void __print_version(ObPluginVersion version)
定义
ob_plugin_libmain.c:32
__print_os_info
void __print_os_info()
定义
ob_plugin_libmain.c:53
__print_compiler_info
void __print_compiler_info()
定义
ob_plugin_libmain.c:40
_ObPlugin
ob plugin description structure
定义
ob_plugin.h:136
_ObPlugin::license
const char * license
The license of the plugin.
定义
ob_plugin.h:139
_ObPlugin::version
ObPluginVersion version
library version for the plugin
定义
ob_plugin.h:138
_ObPlugin::author
const char * author
定义
ob_plugin.h:137
制作者
1.12.0