Browse code

core: relocated some folders from root and utils to misc

- utils keeps only the applications related to kamailio c code
- the other are now in misc/tools
- utils/misc/vim moved to misc/extra/
- obsolete and scripts folders moved to misc/

Daniel-Constantin Mierla authored on 07/12/2016 11:46:38
Showing 1 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,58 @@
1
+#!/bin/sh
2
+#
3
+# $Id$
4
+#
5
+# tool for filtering SIP messages from log by a RegExp
6
+#
7
+# Example of use: ./filter_msg.sh /var/log/sip/sip.1056844800 'CallId: abc'
8
+#
9
+
10
+
11
+#####################
12
+
13
+usage()
14
+{
15
+	echo "Usage: $0 <filename> <RegExp>"
16
+}
17
+
18
+if [ "$#" -ne 2 ] ; then
19
+	usage
20
+	exit
21
+fi
22
+
23
+AWK_PG='
24
+BEGIN {
25
+	IGNORECASE=1;
26
+	line=0;
27
+	msg_match=0;
28
+}
29
+
30
+/^#$/ {
31
+	line=0
32
+	msg_match=0
33
+	next
34
+}
35
+
36
+msg_match==1 {
37
+	print
38
+	next
39
+}
40
+
41
+{ 
42
+	if (match($0, RE)) {
43
+		msg_match=1;
44
+		# dump all accumulated lines here
45
+		for (i=1; i<=line; i++) print buffer[i];
46
+		print
47
+		next
48
+	}
49
+	# there are still chances for a match in following lines;
50
+	# keep buffering this request
51
+	line++
52
+	buffer[line]=$0
53
+}
54
+
55
+'
56
+
57
+
58
+cat $1 | awk "$AWK_PG" RE="$2"