Skip to content

Commit

Permalink
Backup
Browse files Browse the repository at this point in the history
  • Loading branch information
g41797 committed Oct 20, 2023
1 parent 40fcfb2 commit f9c4785
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion parts.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (p *parts) pos() int {

// Sets the position to 0.
// The internal array will stay the same.
func (p *parts) clear() {
func (p *parts) rewind() {
p.position = 0
}

Expand Down
33 changes: 26 additions & 7 deletions syslogmsgparts.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,34 @@ func (mp *syslogmsgparts) extractBadMessage(extr func(name, value string) error)
return extr(FormerMessage, value)
}

// func (mp *syslogmsgparts) extractRFC5424Message(extr func(name, value string) error) error {
// return nil
// }
func (mp *syslogmsgparts) extractRFCMessage(names []string, extr func(name, value string) error) error {
mp.rewind()

// func (mp *syslogmsgparts) extractRFC3164Message(extr func(name, value string) error) error {
// return nil
// }
count, _ := mp.runeAt(1)
mp.skip(int(count + 1))

vlen, _ := mp.runeAt(2)
value, err := mp.part(int(vlen))
if err != nil {
return err
}
err = extr(RFCFormatKey, value)
if err != nil {
return err
}

for i, name := range names {
vlen, _ := mp.runeAt(2 + i)
value, err := mp.part(int(vlen))
if err != nil {
return err
}
err = extr(name, value)
if err != nil {
return err
}
}

func (mp *syslogmsgparts) extractRFCMessage(names []string, extr func(name, value string) error) error {
return nil
}

Expand Down

0 comments on commit f9c4785

Please sign in to comment.