Rename description packages to replace "scpd" with "srvdesc".

This commit is contained in:
John Beisley 2022-05-27 07:00:09 +01:00
parent 2145a9306f
commit b2bea13720
3 changed files with 14 additions and 13 deletions

View File

@ -9,8 +9,8 @@ import (
"strings"
"github.com/huin/goupnp/v2alpha/cmd/goupnp2dcpgen/zipread"
"github.com/huin/goupnp/v2alpha/description/scpd"
"github.com/huin/goupnp/v2alpha/description/xmlscpd"
"github.com/huin/goupnp/v2alpha/description/srvdesc"
"github.com/huin/goupnp/v2alpha/description/xmlsrvdesc"
)
var (
@ -89,7 +89,7 @@ func processService(
d := xml.NewDecoder(f)
xmlSCPD := &xmlscpd.SCPD{}
xmlSCPD := &xmlsrvdesc.SCPD{}
if err := d.Decode(xmlSCPD); err != nil {
return err
}
@ -108,7 +108,7 @@ func processService(
}
}
_, err = scpd.FromXML(xmlSCPD)
_, err = srvdesc.FromXML(xmlSCPD)
if err != nil {
return err
}

View File

@ -1,12 +1,12 @@
// Package scpd contains data structures that represent an SCPD at a higher level than XML.
package scpd
// Package srvdesc contains data structures that represent an SCPD at a higher level than XML.
package srvdesc
import (
"errors"
"fmt"
"sort"
"github.com/huin/goupnp/v2alpha/description/xmlscpd"
"github.com/huin/goupnp/v2alpha/description/xmlsrvdesc"
)
var (
@ -23,7 +23,7 @@ type SCPD struct {
// FromXML creates an SCPD from XML data.
//
// It assumes that xmlDesc.Clean() has been called.
func FromXML(xmlDesc *xmlscpd.SCPD) (*SCPD, error) {
func FromXML(xmlDesc *xmlsrvdesc.SCPD) (*SCPD, error) {
stateVariables := make(map[string]*StateVariable, len(xmlDesc.StateVariables))
for _, xmlSV := range xmlDesc.StateVariables {
sv, err := stateVariableFromXML(xmlSV)
@ -82,7 +82,7 @@ type Action struct {
}
// actionFromXML creates an Action from the given XML description.
func actionFromXML(xmlAction *xmlscpd.Action) (*Action, error) {
func actionFromXML(xmlAction *xmlsrvdesc.Action) (*Action, error) {
if xmlAction.Name == "" {
return nil, fmt.Errorf("%w: empty action name", BadDescriptionError)
}
@ -117,7 +117,7 @@ type Argument struct {
}
// argumentFromXML creates an Argument from the XML description.
func argumentFromXML(xmlArg *xmlscpd.Argument) (*Argument, error) {
func argumentFromXML(xmlArg *xmlsrvdesc.Argument) (*Argument, error) {
if xmlArg.Name == "" {
return nil, fmt.Errorf("%w: empty argument name", BadDescriptionError)
}
@ -144,7 +144,7 @@ type StateVariable struct {
dataType string
}
func stateVariableFromXML(xmlSV *xmlscpd.StateVariable) (*StateVariable, error) {
func stateVariableFromXML(xmlSV *xmlsrvdesc.StateVariable) (*StateVariable, error) {
if xmlSV.Name == "" {
return nil, fmt.Errorf("%w: empty state variable name", BadDescriptionError)
}

View File

@ -1,8 +1,9 @@
// Package xmlscpd contains the XML data structures used in SCPD (Service Control Protocol Description).
// Package xmlsrvdesc contains the XML data structures used in SCPD (Service Control Protocol
// Description).
//
// Described in section 2.5 of
// https://openconnectivity.org/upnp-specs/UPnP-arch-DeviceArchitecture-v2.0-20200417.pdf.
package xmlscpd
package xmlsrvdesc
import (
"bytes"