-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathplugin.c
89 lines (67 loc) · 2.36 KB
/
plugin.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "MumblePlugin_v_1_0_x.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct MumbleAPI_v_1_0_x mumbleAPI;
mumble_plugin_id_t ownID;
mumble_error_t mumble_init(mumble_plugin_id_t pluginID) {
ownID = pluginID;
if (mumbleAPI.log(ownID, "Hello Mumble") != MUMBLE_STATUS_OK) {
// Logging failed -> usually you'd probably want to log things like this in your plugin's
// logging system (if there is any)
}
return MUMBLE_STATUS_OK;
}
void mumble_shutdown() {
if (mumbleAPI.log(ownID, "Goodbye Mumble") != MUMBLE_STATUS_OK) {
// Logging failed -> usually you'd probably want to log things like this in your plugin's
// logging system (if there is any)
}
}
struct MumbleStringWrapper mumble_getName() {
static const char *name = "HelloMumble";
struct MumbleStringWrapper wrapper;
wrapper.data = name;
wrapper.size = strlen(name);
wrapper.needsReleasing = false;
return wrapper;
}
mumble_version_t mumble_getAPIVersion() {
// This constant will always hold the API version that fits the included header files
return MUMBLE_PLUGIN_API_VERSION;
}
void mumble_registerAPIFunctions(void *apiStruct) {
// Provided mumble_getAPIVersion returns MUMBLE_PLUGIN_API_VERSION, this cast will make sure
// that the passed pointer will be cast to the proper type
mumbleAPI = MUMBLE_API_CAST(apiStruct);
}
void mumble_releaseResource(const void *pointer) {
// As we never pass a resource to Mumble that needs releasing, this function should never
// get called
printf("Called mumble_releaseResource but expected that this never gets called -> Aborting");
abort();
}
// Below functions are not strictly necessary but every halfway serious plugin should implement them nonetheless
mumble_version_t mumble_getVersion() {
mumble_version_t version;
version.major = 1;
version.minor = 0;
version.patch = 0;
return version;
}
struct MumbleStringWrapper mumble_getAuthor() {
static const char *author = "Mumble Developers";
struct MumbleStringWrapper wrapper;
wrapper.data = author;
wrapper.size = strlen(author);
wrapper.needsReleasing = false;
return wrapper;
}
struct MumbleStringWrapper mumble_getDescription() {
static const char *description = "A simple plugin template that can say hello and goodbye";
struct MumbleStringWrapper wrapper;
wrapper.data = description;
wrapper.size = strlen(description);
wrapper.needsReleasing = false;
return wrapper;
}