File: list_dialogs.sh

package info (click to toggle)
librnd 4.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,812 kB
  • sloc: ansic: 126,990; sh: 2,602; makefile: 2,145; awk: 7
file content (105 lines) | stat: -rw-r--r-- 1,860 bytes parent folder | download | duplicates (2)
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# shell lib

# assumes running from the source tree

# Print table header (but no html header)
print_hdr()
{
echo '
<table border=1 cellspacing=0>
<tr>
	<th> ID
	<th> dialog box name
	<th> action
	<th> source
	<th> comments
'
}

# list all dialogs from the source files provided on the arg list
list_dlgs()
{
grep RND_DAD_NEW "$@" | awk '
	($1 ~ "TEMPLATE") { next }
	{
		file=$1
		name=$0
		sub(":$", "", file)
		sub(".*src/", "src/", file)
		sub(".*src_plugins/", "src_plugins/", file)
		sub(".*RND_DAD_NEW[^(]*[(]", "", name)
		title=name
		if (name ~ "^\"") {
			sub("\"", "", name)
			sub("\".*", "", name)
		}
		else
			name = "<dyn>"

		sub("[^,]*,[^,]*, *", "", title)
		if (title ~ "^\"") {
			sub("\"", "", title)
			sub("\".*", "", title)
		}
		else
			title = "<dyn>"

		print name "\t" title "\t" file
	}
'
}

# read dialog list and emit a html
gen_html()
{
awk -F "[\t]" '
function orna(s)
{
	if ((s == "") || (s == "<dyn>")) return "n/a"
	return s
}

'"$dlgtbl"'
'"$dlgextra"'

function out(id, name, src, action, comment     ,acturl1,acturl2,fn,tmp) {
	if (action == "") {
		if (id in ACTION) action = ACTION[id]
		else if (src in ACTION) action = ACTION[src]
	}

	if (action != "") {
		acturl1 = action
		sub("[(].*", "", acturl1)
		fn = "../action_src/" acturl1 ".html"
		if ((getline tmp < fn) == 1) {
			acturl1 = "<a href=\"action_details.html#" tolower(acturl1) "\">"
			acturl2 = "</a>"
		}
		else {
			acturl1 = ""
			acturl2 = ""
		}
		close(fn)
	}

	if (comment == "") {
		if (id in COMMENT) comment = COMMENT[id]
		else if (src in COMMENT) comment = COMMENT[src]
		else comment = "&nbsp;"
	}

	print "<tr><td>" orna(id) "<td>" orna(name) "<td>" acturl1 orna(action) acturl2 "<td>" src "<td>" comment
}

{
	id=$1
	name=$2
	src=$3
	if ((src in IGNORE) && ((name ~ IGNORE[src]) || (id ~ IGNORE[src])))
		next
	out(id, name, src)
}
'
}