-
Notifications
You must be signed in to change notification settings - Fork 0
/
CSMP_PIN_SERVICE.go
67 lines (65 loc) · 1.44 KB
/
CSMP_PIN_SERVICE.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package nesbconvertpin
import (
"bufio"
"os"
"path"
"strings"
)
func CSMP_PIN_SERVICE() (services map[string]map[string][]PinElem) {
services = make(map[string]map[string][]PinElem)
fileName := path.Join(getRootDir(), "etc/enum/CSMP_PIN_SERVICE.txt")
file, err := os.Open(fileName)
if err != nil {
panic(err)
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if len(line) == 0 || strings.HasPrefix(line, "#") || strings.HasPrefix(line, "enumData1") {
continue
}
kv := strings.SplitN(line, "\t", 2)
if len(kv) < 2 {
continue
}
ks := strings.Split(kv[0], ".")
if len(ks) < 3 {
panic(line)
}
dtaname := ks[0]
if !strings.Contains(dtaname, "_SVR") && !strings.Contains(dtaname, "_SGET") && !strings.Contains(dtaname, "_PAY") && !strings.Contains(dtaname, "_CLS") {
continue
}
procode := ks[2]
vs := strings.Split(kv[1], "$")
if len(vs) < 2 {
panic(line)
}
var pes []PinElem
couples := strings.Split(vs[1], "|")
for _, couple := range couples {
pa := strings.Split(couple, ",")
if len(pa) < 2 {
panic(line)
}
var pe PinElem
pe.Pin = pa[0]
pe.Acc = pa[1]
pes = append(pes, pe)
}
if len(pes) == 0 {
panic(line)
}
dta, ok := services[dtaname]
if !ok {
dta = make(map[string][]PinElem)
}
dta[procode] = pes
services[dtaname] = dta
}
if err := scanner.Err(); err != nil {
panic(err)
}
return
}