File: get-plugin-field.awk

package info (click to toggle)
roundcube-plugins-extra 0.7-20120110
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,372 kB
  • sloc: php: 10,427; xml: 574; sh: 75; makefile: 53; awk: 51
file content (54 lines) | stat: -rw-r--r-- 716 bytes parent folder | download | duplicates (5)
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
/^Plugin: / {
	if ($2 == plugin) {
		in_plugin = 1
	}
	next
}
/^[A-z-]+:/ {
	if (in_field) {
		# print value in END
		exit 0
	}
	if (in_plugin) {
		if ($1 == field ":") {
			in_field = 1
			value = $2
		}
	}
}
/^ / {
	if (in_field) {
		if (value) {
			value = value "\n"
		}
		if ($1 != ".") {
			value = value substr($0, 2)
		}
	}
}
/^$/ {
	if (in_field) {
		# print value in END
		exit 0
	}
	if (in_plugin) {
		# print value in END
		exit 2
	}
	next
}
END {
	if (in_plugin) {
		if (value) {
			print value
			exit 0
		} else {
			print "Plugin `" plugin "' does not have field `" field "'." > "/dev/stderr"
			exit 2
		}
	}
	if (!in_plugin) {
		print "Plugin `" plugin "' not found." > "/dev/stderr"
		exit 1
	}
}