summaryrefslogtreecommitdiff
path: root/exports
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-11-22 16:14:06 +0100
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-11-23 16:16:09 +0100
commit4a4b3f0a1c008e35a4492b7fd05176d1822c7232 (patch)
tree287ac69b6f89524282d4e2cbc85c6d8030285c88 /exports
parentea07a6d7b2df9b09d8e4c796b2416a60ba90144a (diff)
FSM: Check unhandled transitions
Diffstat (limited to 'exports')
-rw-r--r--exports/exports.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/exports/exports.go b/exports/exports.go
index 05f2462..8e418d4 100644
--- a/exports/exports.go
+++ b/exports/exports.go
@@ -4,11 +4,11 @@ package main
#include <stdlib.h>
#include "error.h"
-typedef void (*PythonCB)(const char* name, int oldstate, int newstate, void* data);
+typedef int (*PythonCB)(const char* name, int oldstate, int newstate, void* data);
-static void call_callback(PythonCB callback, const char *name, int oldstate, int newstate, void* data)
+static int call_callback(PythonCB callback, const char *name, int oldstate, int newstate, void* data)
{
- callback(name, oldstate, newstate, data);
+ return callback(name, oldstate, newstate, data);
}
*/
import "C"
@@ -61,18 +61,19 @@ func StateCallback(
old_state client.FSMStateID,
new_state client.FSMStateID,
data interface{},
-) {
+) bool {
P_StateCallback, exists := P_StateCallbacks[name]
if !exists || P_StateCallback == nil {
- return
+ return false
}
name_c := C.CString(name)
oldState_c := C.int(old_state)
newState_c := C.int(new_state)
data_c := GetStateData(state, new_state, data)
- C.call_callback(P_StateCallback, name_c, oldState_c, newState_c, data_c)
+ handled := C.call_callback(P_StateCallback, name_c, oldState_c, newState_c, data_c)
C.free(unsafe.Pointer(name_c))
// data_c gets freed by the wrapper
+ return handled == C.int(1)
}
func GetVPNState(name string) (*client.Client, error) {
@@ -110,8 +111,8 @@ func Register(
nameStr,
C.GoString(config_directory),
C.GoString(language),
- func(old client.FSMStateID, new client.FSMStateID, data interface{}) {
- StateCallback(state, nameStr, old, new, data)
+ func(old client.FSMStateID, new client.FSMStateID, data interface{}) bool {
+ return StateCallback(state, nameStr, old, new, data)
},
debug != 0,
)