Move DCP spec manifests out to a TOML file.
This commit is contained in:
parent
3db7296aeb
commit
9d4879e3c6
@ -13,6 +13,7 @@ import (
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/huin/goupnp/v2alpha/cmd/goupnp2srvgen/tmplfuncs"
|
||||
"github.com/huin/goupnp/v2alpha/cmd/goupnp2srvgen/zipread"
|
||||
"github.com/huin/goupnp/v2alpha/description/srvdesc"
|
||||
@ -23,6 +24,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
srvManifests = flag.String("srv_manifests", "", "Path to srvmanifests.toml")
|
||||
srvTemplate = flag.String("srv_template", "", "Path to srv.gotemplate.")
|
||||
upnpresourcesZip = flag.String("upnpresources_zip", "", "Path to upnpresources.zip.")
|
||||
)
|
||||
@ -41,6 +43,16 @@ func run() error {
|
||||
if len(flag.Args()) > 0 {
|
||||
return fmt.Errorf("unused arguments: %s", strings.Join(flag.Args(), " "))
|
||||
}
|
||||
|
||||
if *srvManifests == "" {
|
||||
return errors.New("-srv_manifests is a required flag.")
|
||||
}
|
||||
var manifests DCPSpecManifests
|
||||
_, err := toml.DecodeFile(*srvManifests, &manifests)
|
||||
if err != nil {
|
||||
return fmt.Errorf("loading srv_manifests %q: %w", *srvManifests, err)
|
||||
}
|
||||
|
||||
if *srvTemplate == "" {
|
||||
return errors.New("-srv_template is a required flag.")
|
||||
}
|
||||
@ -72,7 +84,7 @@ func run() error {
|
||||
GoType: reflect.TypeOf((*soap.SOAPAction)(nil)).Elem(),
|
||||
}
|
||||
|
||||
for _, m := range manifests {
|
||||
for _, m := range manifests.DCPS {
|
||||
if err := processDCP(upnpresources, m, typeMap, tmpl); err != nil {
|
||||
return fmt.Errorf("processing DCP %s: %w", m.Path, err)
|
||||
}
|
||||
@ -80,24 +92,6 @@ func run() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
var manifests = []*DCPSpecManifest{
|
||||
{
|
||||
Path: "standardizeddcps/Internet Gateway_2/UPnP-gw-IGD-TestFiles-20101210.zip",
|
||||
Services: []*ServiceManifest{
|
||||
{
|
||||
Package: "lanhostconfigmanagement1",
|
||||
ServiceType: "urn:schemas-upnp-org:service:LANHostConfigManagement:1",
|
||||
Path: "xml data files/service/LANHostConfigManagement1.xml",
|
||||
},
|
||||
{
|
||||
Package: "wanpppconnection1",
|
||||
ServiceType: "urn:schemas-upnp-org:service:WANPPPConnection:1",
|
||||
Path: "xml data files/service/WANPPPConnection1.xml",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func processDCP(
|
||||
upnpresources *zipread.ZipRead,
|
||||
manifest *DCPSpecManifest,
|
||||
@ -158,6 +152,10 @@ func processService(
|
||||
return nil
|
||||
}
|
||||
|
||||
type DCPSpecManifests struct {
|
||||
DCPS []*DCPSpecManifest
|
||||
}
|
||||
|
||||
type DCPSpecManifest struct {
|
||||
// Path is the file path within upnpresources.zip to the DCP spec ZIP file.
|
||||
Path string
|
||||
|
@ -3,3 +3,5 @@ module github.com/huin/goupnp/v2alpha
|
||||
go 1.18
|
||||
|
||||
require github.com/google/go-cmp v0.5.7
|
||||
|
||||
require github.com/BurntSushi/toml v1.1.0 // indirect
|
||||
|
@ -1,3 +1,5 @@
|
||||
github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I=
|
||||
github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
|
||||
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
|
10
v2alpha/srv/srvmanifests.toml
Normal file
10
v2alpha/srv/srvmanifests.toml
Normal file
@ -0,0 +1,10 @@
|
||||
[[DCPS]]
|
||||
Path = "standardizeddcps/Internet Gateway_2/UPnP-gw-IGD-TestFiles-20101210.zip"
|
||||
[[DCPS.Services]]
|
||||
Package = "lanhostconfigmanagement1"
|
||||
ServiceType = "urn:schemas-upnp-org:service:LANHostConfigManagement:1"
|
||||
Path = "xml data files/service/LANHostConfigManagement1.xml"
|
||||
[[DCPS.Services]]
|
||||
Package = "wanpppconnection1"
|
||||
ServiceType = "urn:schemas-upnp-org:service:WANPPPConnection:1"
|
||||
Path = "xml data files/service/WANPPPConnection1.xml"
|
Loading…
Reference in New Issue
Block a user