Skip to content

Commit

Permalink
Trying to add TextfileContentState
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan authored and jonathan committed Jul 28, 2022
1 parent ee46356 commit 69464ca
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
13 changes: 12 additions & 1 deletion oval/states.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

func (s *States) init() {
var wg sync.WaitGroup
wg.Add(4)
wg.Add(5)

go func() {
defer wg.Done()
Expand Down Expand Up @@ -41,6 +41,14 @@ func (s *States) init() {
}
}()

go func() {
defer wg.Done()
s.textfileContent54Memo = make(map[string]int, len(s.TextfileContent54States))
for i, v := range s.TextfileContent54States {
s.textfileContent54Memo[v.ID] = i
}
}()

wg.Wait()
}

Expand All @@ -61,6 +69,9 @@ func (s *States) Lookup(ref string) (kind string, index int, err error) {
if i, ok := s.dpkginfoMemo[ref]; ok {
return s.DpkgInfoStates[i].XMLName.Local, i, nil
}
if i, ok := s.textfileContent54Memo[ref]; ok {
return s.TextfileContent54States[i].XMLName.Local, i, nil
}

// We didn't find it, maybe we can say why.
id, err := ParseID(ref)
Expand Down
22 changes: 12 additions & 10 deletions oval/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,16 +278,18 @@ type Objects struct {

// States : >states
type States struct {
once sync.Once
XMLName xml.Name `xml:"states"`
LineStates []LineState `xml:"line_state"`
Version55States []Version55State `xml:"version55_state"`
RPMInfoStates []RPMInfoState `xml:"rpminfo_state"`
DpkgInfoStates []DpkgInfoState `xml:"dpkginfo_state"`
lineMemo map[string]int
version55Memo map[string]int
rpminfoMemo map[string]int
dpkginfoMemo map[string]int
once sync.Once
XMLName xml.Name `xml:"states"`
LineStates []LineState `xml:"line_state"`
Version55States []Version55State `xml:"version55_state"`
RPMInfoStates []RPMInfoState `xml:"rpminfo_state"`
DpkgInfoStates []DpkgInfoState `xml:"dpkginfo_state"`
TextfileContent54States []TextfileContent54State `xml:"textfilecontent54_state"`
lineMemo map[string]int
version55Memo map[string]int
rpminfoMemo map[string]int
dpkginfoMemo map[string]int
textfileContent54Memo map[string]int
}

// Value
Expand Down

0 comments on commit 69464ca

Please sign in to comment.