46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package ctl
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/xml"
|
|
"fmt"
|
|
)
|
|
|
|
func escape(s string) string {
|
|
var b bytes.Buffer
|
|
xml.EscapeText(&b, []byte(s))
|
|
return b.String()
|
|
}
|
|
|
|
func AddSchedOutbound(name, on, timeStr, repeat string) Outbound {
|
|
inner := fmt.Sprintf(`<sched name="%s" on="%s" time="%s" repeat="%s"><ctl td="Clean"><clean type="auto"/></ctl></sched>`,
|
|
escape(name), escape(on), escape(timeStr), escape(repeat))
|
|
return Outbound{
|
|
TD: "AddSched",
|
|
Inner: []byte(inner),
|
|
}
|
|
}
|
|
|
|
func ModSchedOutbound(name, on, timeStr, repeat string) Outbound {
|
|
inner := fmt.Sprintf(`<ModSched name="%s"><sched name="%s" on="%s" time="%s" repeat="%s"><ctl td="Clean"><clean type="auto"/></ctl></sched></ModSched>`,
|
|
escape(name), escape(name), escape(on), escape(timeStr), escape(repeat))
|
|
return Outbound{
|
|
TD: "ModSched",
|
|
Inner: []byte(inner),
|
|
}
|
|
}
|
|
|
|
func DelSchedOutbound(name string) Outbound {
|
|
inner := fmt.Sprintf(`<DelSched name="%s"/>`, escape(name))
|
|
return Outbound{
|
|
TD: "DelSched",
|
|
Inner: []byte(inner),
|
|
}
|
|
}
|
|
|
|
func GetSchedOutbound() Outbound {
|
|
return Outbound{
|
|
TD: "GetSched",
|
|
}
|
|
}
|