Browse code

misc/tools/kemi: lua - fixed typos in readme

Daniel-Constantin Mierla authored on 23/11/2020 20:17:59 • GitHub committed on 23/11/2020 20:17:59
Showing 1 changed files
... ...
@@ -71,9 +71,9 @@ Other external tools useful to check the Lua scripts.
71 71
 ### luac ###
72 72
 
73 73
 The `luac` (the Lua compiler) can be used with parameter `-p` to check for
74
-syntax errors (e.g., missing closing quote or parenthesis).:w
74
+syntax errors (e.g., missing closing quote or parenthesis).
75 75
 
76
-Example - when there is a missing closing quite, like:
76
+Example - when there is a missing closing quote, like:
77 77
 
78 78
 ```
79 79
 KSR.hdr.remove("Route);
Browse code

misc/tools/kemi: lua - full file name for kemiluacheck tool

Daniel-Constantin Mierla authored on 23/11/2020 18:44:08 • GitHub committed on 23/11/2020 18:44:08
Showing 1 changed files
... ...
@@ -2,7 +2,7 @@
2 2
 
3 3
 Tools useful for using Kamailio with KEMI Lua scripts.
4 4
 
5
-## kemiksrlib ##
5
+## kemiksrlib.py ##
6 6
 
7 7
 Generates the file `KSR.lua` with skeleton functions in the `KSR` object. The
8 8
 function parameters are prefixed with `p_` and the functions return:
... ...
@@ -85,4 +85,4 @@ the check results in:
85 85
 luac -p kamailio-basic-kemi-lua.lua
86 86
 
87 87
 luac: kamailio-basic-kemi-lua.lua:100: unfinished string near '"Route);'
88
-```
89 88
\ No newline at end of file
89
+```
Browse code

misc/tools/kemi: lua - tools useful for using Kamailio with KEMI Lua scripts

Daniel-Constantin Mierla authored on 23/11/2020 13:21:12
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,88 @@
1
+# Tools For KEMI Lua #
2
+
3
+Tools useful for using Kamailio with KEMI Lua scripts.
4
+
5
+## kemiksrlib ##
6
+
7
+Generates the file `KSR.lua` with skeleton functions in the `KSR` object. The
8
+function parameters are prefixed with `p_` and the functions return:
9
+
10
+  * empty string - in case of functions returning `xval`
11
+  * `1` - in case of functions returning `int`
12
+  * `true` - in case of functions returning `int`
13
+  * nothing - in case of void functions
14
+  * `nil` - in the other cases
15
+
16
+Useful to use for syntax checking and functions prototypes.
17
+
18
+Usage:
19
+
20
+```
21
+python3 kemiksrlib.py /path/to/src/kamailio
22
+```
23
+
24
+## kemiluacheck.py ##
25
+
26
+Generates the file `KSR.luacheckrc` that can be used with `luacheck` to verify
27
+if the KEMI Lua script uses undefined symbols (e.g., functions that are not
28
+in the `KSR` library due to typos).
29
+
30
+Usage:
31
+
32
+```
33
+python3 kemiluacheck.py /path/to/src/kamailio
34
+
35
+luacheck --config KSR.luacheckrc kamailio-basic-kemi-lua.lua -d
36
+```
37
+
38
+Example output with `KSR` correct functions:
39
+
40
+```
41
+Checking kamailio-basic-kemi-lua.lua              5 warnings
42
+
43
+    kamailio-basic-kemi-lua.lua:67:10: unused global variable ksr_request_route
44
+    kamailio-basic-kemi-lua.lua:389:10: unused global variable ksr_branch_manage
45
+    kamailio-basic-kemi-lua.lua:398:10: unused global variable ksr_onreply_manage
46
+    kamailio-basic-kemi-lua.lua:409:10: unused global variable ksr_failure_manage
47
+    kamailio-basic-kemi-lua.lua:420:10: unused global variable ksr_reply_route
48
+
49
+Total: 5 warnings / 0 errors in 1 file
50
+```
51
+
52
+Example output with `KSR.is_CANCLE()` typo:
53
+
54
+```
55
+Checking kamailio-basic-kemi-lua.lua              6 warnings
56
+
57
+    kamailio-basic-kemi-lua.lua:67:10: unused global variable ksr_request_route
58
+    kamailio-basic-kemi-lua.lua:76:5: accessing undefined field is_CANCLE of global KSR
59
+    kamailio-basic-kemi-lua.lua:389:10: unused global variable ksr_branch_manage
60
+    kamailio-basic-kemi-lua.lua:398:10: unused global variable ksr_onreply_manage
61
+    kamailio-basic-kemi-lua.lua:409:10: unused global variable ksr_failure_manage
62
+    kamailio-basic-kemi-lua.lua:420:10: unused global variable ksr_reply_route
63
+
64
+Total: 6 warnings / 0 errors in 1 file
65
+```
66
+
67
+## Other Tools ##
68
+
69
+Other external tools useful to check the Lua scripts.
70
+
71
+### luac ###
72
+
73
+The `luac` (the Lua compiler) can be used with parameter `-p` to check for
74
+syntax errors (e.g., missing closing quote or parenthesis).:w
75
+
76
+Example - when there is a missing closing quite, like:
77
+
78
+```
79
+KSR.hdr.remove("Route);
80
+```
81
+
82
+the check results in:
83
+
84
+```
85
+luac -p kamailio-basic-kemi-lua.lua
86
+
87
+luac: kamailio-basic-kemi-lua.lua:100: unfinished string near '"Route);'
88
+```
0 89
\ No newline at end of file