-
Notifications
You must be signed in to change notification settings - Fork 7
/
linktable.go
50 lines (40 loc) · 920 Bytes
/
linktable.go
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
package ciqdb
import (
"encoding/binary"
"strings"
)
type LinkTable struct {
PRGSection
links []Link
}
func (l *LinkTable) String() string {
var buf strings.Builder
buf.WriteString(l.PRGSection.String() + "\n")
for _, link := range l.links {
buf.WriteString(" " + link.String() + "\n")
}
return buf.String()
}
type Link struct {
module int
class int
}
func (l Link) String() string {
return "module: " + apidb(l.module) + ", class: " + apidb(l.class)
}
func parseDataTable(p *PRG, t SecType, length int, data []byte) *LinkTable {
table := LinkTable{
PRGSection: PRGSection{
Type: t,
length: length,
},
}
nLinks := int(binary.BigEndian.Uint16(data[0:2]))
for i := 0; i < nLinks; i++ {
table.links = append(table.links, Link{
module: int(binary.BigEndian.Uint32(data[i*8+2 : i*8+6])),
class: int(binary.BigEndian.Uint32(data[i*8+6 : i*8+10])),
})
}
return &table
}