aboutsummaryrefslogtreecommitdiffstats
path: root/Godeps
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2015-11-03 18:47:07 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-11-03 18:47:07 +0800
commite5532154a50114d5ffb1ffd850b746cab00cb899 (patch)
tree0042cc997ccf4166b9b52464339d52d37d7a8ad6 /Godeps
parent9666db2a442887ccf8ec2d81f5e2fedc1a3a3d3e (diff)
parentf75becc264f8bde0f58391fc226243d03e78aa7b (diff)
downloadgo-tangerine-e5532154a50114d5ffb1ffd850b746cab00cb899.tar
go-tangerine-e5532154a50114d5ffb1ffd850b746cab00cb899.tar.gz
go-tangerine-e5532154a50114d5ffb1ffd850b746cab00cb899.tar.bz2
go-tangerine-e5532154a50114d5ffb1ffd850b746cab00cb899.tar.lz
go-tangerine-e5532154a50114d5ffb1ffd850b746cab00cb899.tar.xz
go-tangerine-e5532154a50114d5ffb1ffd850b746cab00cb899.tar.zst
go-tangerine-e5532154a50114d5ffb1ffd850b746cab00cb899.zip
Merge branch 'release/1.3.0'
Conflicts: VERSION cmd/geth/main.go
Diffstat (limited to 'Godeps')
-rw-r--r--Godeps/Godeps.json10
-rw-r--r--Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/cl.go26
-rw-r--r--Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/cl_test.go254
-rw-r--r--Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/context.go161
-rw-r--r--Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/device.go510
-rw-r--r--Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/device12.go51
-rw-r--r--Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/cl.h1210
-rw-r--r--Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/cl_ext.h315
-rw-r--r--Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/cl_gl.h158
-rw-r--r--Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/cl_gl_ext.h65
-rw-r--r--Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/cl_platform.h1278
-rw-r--r--Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/opencl.h43
-rw-r--r--Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/image.go83
-rw-r--r--Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/kernel.go127
-rw-r--r--Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/kernel10.go7
-rw-r--r--Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/kernel12.go20
-rw-r--r--Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/platform.go83
-rw-r--r--Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/program.go105
-rw-r--r--Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/queue.go193
-rw-r--r--Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/types.go487
-rw-r--r--Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/types12.go71
-rw-r--r--Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/types_darwin.go45
-rw-r--r--Godeps/_workspace/src/github.com/codegangsta/cli/.travis.yml9
-rw-r--r--Godeps/_workspace/src/github.com/codegangsta/cli/README.md33
-rw-r--r--Godeps/_workspace/src/github.com/codegangsta/cli/app.go90
-rw-r--r--Godeps/_workspace/src/github.com/codegangsta/cli/app_test.go622
-rw-r--r--Godeps/_workspace/src/github.com/codegangsta/cli/autocomplete/bash_autocomplete2
-rw-r--r--Godeps/_workspace/src/github.com/codegangsta/cli/cli.go21
-rw-r--r--Godeps/_workspace/src/github.com/codegangsta/cli/cli_test.go100
-rw-r--r--Godeps/_workspace/src/github.com/codegangsta/cli/command.go43
-rw-r--r--Godeps/_workspace/src/github.com/codegangsta/cli/command_test.go49
-rw-r--r--Godeps/_workspace/src/github.com/codegangsta/cli/context.go72
-rw-r--r--Godeps/_workspace/src/github.com/codegangsta/cli/context_test.go111
-rw-r--r--Godeps/_workspace/src/github.com/codegangsta/cli/flag.go45
-rw-r--r--Godeps/_workspace/src/github.com/codegangsta/cli/flag_test.go742
-rw-r--r--Godeps/_workspace/src/github.com/codegangsta/cli/help.go111
-rw-r--r--Godeps/_workspace/src/github.com/codegangsta/cli/helpers_test.go19
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go42
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/ethash_opencl.go629
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/ethash_opencl_kernel_go_str.go600
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/ethash_test.go23
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/ethashc.go16
-rw-r--r--Godeps/_workspace/src/github.com/huin/goupnp/.gitignore1
-rw-r--r--Godeps/_workspace/src/github.com/huin/goupnp/README.md34
-rw-r--r--Godeps/_workspace/src/github.com/huin/goupnp/cmd/example_ssdp_registry/example_ssdp_registry.go27
-rw-r--r--Godeps/_workspace/src/github.com/huin/goupnp/dcps/av1/av1.go8452
-rw-r--r--Godeps/_workspace/src/github.com/huin/goupnp/dcps/internetgateway1/internetgateway1.go938
-rw-r--r--Godeps/_workspace/src/github.com/huin/goupnp/dcps/internetgateway2/internetgateway2.go1733
-rw-r--r--Godeps/_workspace/src/github.com/huin/goupnp/example/example_test.go62
-rw-r--r--Godeps/_workspace/src/github.com/huin/goupnp/gotasks/specgen_task.go378
-rw-r--r--Godeps/_workspace/src/github.com/huin/goupnp/goupnp.go52
-rw-r--r--Godeps/_workspace/src/github.com/huin/goupnp/service_client.go62
-rw-r--r--Godeps/_workspace/src/github.com/huin/goupnp/soap/soap_test.go85
-rw-r--r--Godeps/_workspace/src/github.com/huin/goupnp/soap/types.go11
-rw-r--r--Godeps/_workspace/src/github.com/huin/goupnp/soap/types_test.go481
-rw-r--r--Godeps/_workspace/src/github.com/huin/goupnp/ssdp/registry.go132
56 files changed, 17127 insertions, 4002 deletions
diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json
index e4b37a12e..cf23ad6a6 100644
--- a/Godeps/Godeps.json
+++ b/Godeps/Godeps.json
@@ -7,8 +7,8 @@
"Deps": [
{
"ImportPath": "github.com/codegangsta/cli",
- "Comment": "1.2.0-95-g9b2bd2b",
- "Rev": "9b2bd2b3489748d4d0a204fa4eb2ee9e89e0ebc6"
+ "Comment": "1.2.0-161-gf445c89",
+ "Rev": "f445c894402839580d30de47551cedc152dad814"
},
{
"ImportPath": "github.com/davecgh/go-spew/spew",
@@ -16,8 +16,8 @@
},
{
"ImportPath": "github.com/ethereum/ethash",
- "Comment": "v23.1-234-g062e40a",
- "Rev": "062e40a1a1671f5a5102862b56e4c56f68a732f5"
+ "Comment": "v23.1-238-g9401881",
+ "Rev": "9401881ab040d1a3b0ae9e4780a115bc284a8a1a"
},
{
"ImportPath": "github.com/fatih/color",
@@ -34,7 +34,7 @@
},
{
"ImportPath": "github.com/huin/goupnp",
- "Rev": "5cff77a69fb22f5f1774c4451ea2aab63d4d2f20"
+ "Rev": "90f71cb5dd6d4606388666d2cda4ce2f563d2185"
},
{
"ImportPath": "github.com/jackpal/go-nat-pmp",
diff --git a/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/cl.go b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/cl.go
new file mode 100644
index 000000000..3d577b2b6
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/cl.go
@@ -0,0 +1,26 @@
+/*
+Package cl provides a binding to the OpenCL api. It's mostly a low-level
+wrapper that avoids adding functionality while still making the interface
+a little more friendly and easy to use.
+
+Resource life-cycle management:
+
+For any CL object that gets created (buffer, queue, kernel, etc..) you should
+call object.Release() when finished with it to free the CL resources. This
+explicitely calls the related clXXXRelease method for the type. However,
+as a fallback there is a finalizer set for every resource item that takes
+care of it (eventually) if Release isn't called. In this way you can have
+better control over the life cycle of resources while having a fall back
+to avoid leaks. This is similar to how file handles and such are handled
+in the Go standard packages.
+*/
+package cl
+
+// #include "headers/1.2/opencl.h"
+// #cgo CFLAGS: -Iheaders/1.2
+// #cgo darwin LDFLAGS: -framework OpenCL
+// #cgo linux LDFLAGS: -lOpenCL
+import "C"
+import "errors"
+
+var ErrUnsupported = errors.New("cl: unsupported")
diff --git a/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/cl_test.go b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/cl_test.go
new file mode 100644
index 000000000..7659ce14f
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/cl_test.go
@@ -0,0 +1,254 @@
+package cl
+
+import (
+ "math/rand"
+ "reflect"
+ "strings"
+ "testing"
+)
+
+var kernelSource = `
+__kernel void square(
+ __global float* input,
+ __global float* output,
+ const unsigned int count)
+{
+ int i = get_global_id(0);
+ if(i < count)
+ output[i] = input[i] * input[i];
+}
+`
+
+func getObjectStrings(object interface{}) map[string]string {
+ v := reflect.ValueOf(object)
+ t := reflect.TypeOf(object)
+
+ strs := make(map[string]string)
+
+ numMethods := t.NumMethod()
+ for i := 0; i < numMethods; i++ {
+ method := t.Method(i)
+ if method.Type.NumIn() == 1 && method.Type.NumOut() == 1 && method.Type.Out(0).Kind() == reflect.String {
+ // this is a string-returning method with (presumably) only a pointer receiver parameter
+ // call it
+ outs := v.Method(i).Call([]reflect.Value{})
+ // put the result in our map
+ strs[method.Name] = (outs[0].Interface()).(string)
+ }
+ }
+
+ return strs
+}
+
+func TestPlatformStringsContainNoNULs(t *testing.T) {
+ platforms, err := GetPlatforms()
+ if err != nil {
+ t.Fatalf("Failed to get platforms: %+v", err)
+ }
+
+ for _, p := range platforms {
+ for key, value := range getObjectStrings(p) {
+ if strings.Contains(value, "\x00") {
+ t.Fatalf("platform string %q = %+q contains NUL", key, value)
+ }
+ }
+ }
+}
+
+func TestDeviceStringsContainNoNULs(t *testing.T) {
+ platforms, err := GetPlatforms()
+ if err != nil {
+ t.Fatalf("Failed to get platforms: %+v", err)
+ }
+
+ for _, p := range platforms {
+ devs, err := p.GetDevices(DeviceTypeAll)
+ if err != nil {
+ t.Fatalf("Failed to get devices for platform %q: %+v", p.Name(), err)
+ }
+
+ for _, d := range devs {
+ for key, value := range getObjectStrings(d) {
+ if strings.Contains(value, "\x00") {
+ t.Fatalf("device string %q = %+q contains NUL", key, value)
+ }
+ }
+ }
+ }
+}
+
+func TestHello(t *testing.T) {
+ var data [1024]float32
+ for i := 0; i < len(data); i++ {
+ data[i] = rand.Float32()
+ }
+
+ platforms, err := GetPlatforms()
+ if err != nil {
+ t.Fatalf("Failed to get platforms: %+v", err)
+ }
+ for i, p := range platforms {
+ t.Logf("Platform %d:", i)
+ t.Logf(" Name: %s", p.Name())
+ t.Logf(" Vendor: %s", p.Vendor())
+ t.Logf(" Profile: %s", p.Profile())
+ t.Logf(" Version: %s", p.Version())
+ t.Logf(" Extensions: %s", p.Extensions())
+ }
+ platform := platforms[0]
+
+ devices, err := platform.GetDevices(DeviceTypeAll)
+ if err != nil {
+ t.Fatalf("Failed to get devices: %+v", err)
+ }
+ if len(devices) == 0 {
+ t.Fatalf("GetDevices returned no devices")
+ }
+ deviceIndex := -1
+ for i, d := range devices {
+ if deviceIndex < 0 && d.Type() == DeviceTypeGPU {
+ deviceIndex = i
+ }
+ t.Logf("Device %d (%s): %s", i, d.Type(), d.Name())
+ t.Logf(" Address Bits: %d", d.AddressBits())
+ t.Logf(" Available: %+v", d.Available())
+ // t.Logf(" Built-In Kernels: %s", d.BuiltInKernels())
+ t.Logf(" Compiler Available: %+v", d.CompilerAvailable())
+ t.Logf(" Double FP Config: %s", d.DoubleFPConfig())
+ t.Logf(" Driver Version: %s", d.DriverVersion())
+ t.Logf(" Error Correction Supported: %+v", d.ErrorCorrectionSupport())
+ t.Logf(" Execution Capabilities: %s", d.ExecutionCapabilities())
+ t.Logf(" Extensions: %s", d.Extensions())
+ t.Logf(" Global Memory Cache Type: %s", d.GlobalMemCacheType())
+ t.Logf(" Global Memory Cacheline Size: %d KB", d.GlobalMemCachelineSize()/1024)
+ t.Logf(" Global Memory Size: %d MB", d.GlobalMemSize()/(1024*1024))
+ t.Logf(" Half FP Config: %s", d.HalfFPConfig())
+ t.Logf(" Host Unified Memory: %+v", d.HostUnifiedMemory())
+ t.Logf(" Image Support: %+v", d.ImageSupport())
+ t.Logf(" Image2D Max Dimensions: %d x %d", d.Image2DMaxWidth(), d.Image2DMaxHeight())
+ t.Logf(" Image3D Max Dimenionns: %d x %d x %d", d.Image3DMaxWidth(), d.Image3DMaxHeight(), d.Image3DMaxDepth())
+ // t.Logf(" Image Max Buffer Size: %d", d.ImageMaxBufferSize())
+ // t.Logf(" Image Max Array Size: %d", d.ImageMaxArraySize())
+ // t.Logf(" Linker Available: %+v", d.LinkerAvailable())
+ t.Logf(" Little Endian: %+v", d.EndianLittle())
+ t.Logf(" Local Mem Size Size: %d KB", d.LocalMemSize()/1024)
+ t.Logf(" Local Mem Type: %s", d.LocalMemType())
+ t.Logf(" Max Clock Frequency: %d", d.MaxClockFrequency())
+ t.Logf(" Max Compute Units: %d", d.MaxComputeUnits())
+ t.Logf(" Max Constant Args: %d", d.MaxConstantArgs())
+ t.Logf(" Max Constant Buffer Size: %d KB", d.MaxConstantBufferSize()/1024)
+ t.Logf(" Max Mem Alloc Size: %d KB", d.MaxMemAllocSize()/1024)
+ t.Logf(" Max Parameter Size: %d", d.MaxParameterSize())
+ t.Logf(" Max Read-Image Args: %d", d.MaxReadImageArgs())
+ t.Logf(" Max Samplers: %d", d.MaxSamplers())
+ t.Logf(" Max Work Group Size: %d", d.MaxWorkGroupSize())
+ t.Logf(" Max Work Item Dimensions: %d", d.MaxWorkItemDimensions())
+ t.Logf(" Max Work Item Sizes: %d", d.MaxWorkItemSizes())
+ t.Logf(" Max Write-Image Args: %d", d.MaxWriteImageArgs())
+ t.Logf(" Memory Base Address Alignment: %d", d.MemBaseAddrAlign())
+ t.Logf(" Native Vector Width Char: %d", d.NativeVectorWidthChar())
+ t.Logf(" Native Vector Width Short: %d", d.NativeVectorWidthShort())
+ t.Logf(" Native Vector Width Int: %d", d.NativeVectorWidthInt())
+ t.Logf(" Native Vector Width Long: %d", d.NativeVectorWidthLong())
+ t.Logf(" Native Vector Width Float: %d", d.NativeVectorWidthFloat())
+ t.Logf(" Native Vector Width Double: %d", d.NativeVectorWidthDouble())
+ t.Logf(" Native Vector Width Half: %d", d.NativeVectorWidthHalf())
+ t.Logf(" OpenCL C Version: %s", d.OpenCLCVersion())
+ // t.Logf(" Parent Device: %+v", d.ParentDevice())
+ t.Logf(" Profile: %s", d.Profile())
+ t.Logf(" Profiling Timer Resolution: %d", d.ProfilingTimerResolution())
+ t.Logf(" Vendor: %s", d.Vendor())
+ t.Logf(" Version: %s", d.Version())
+ }
+ if deviceIndex < 0 {
+ deviceIndex = 0
+ }
+ device := devices[deviceIndex]
+ t.Logf("Using device %d", deviceIndex)
+ context, err := CreateContext([]*Device{device})
+ if err != nil {
+ t.Fatalf("CreateContext failed: %+v", err)
+ }
+ // imageFormats, err := context.GetSupportedImageFormats(0, MemObjectTypeImage2D)
+ // if err != nil {
+ // t.Fatalf("GetSupportedImageFormats failed: %+v", err)
+ // }
+ // t.Logf("Supported image formats: %+v", imageFormats)
+ queue, err := context.CreateCommandQueue(device, 0)
+ if err != nil {
+ t.Fatalf("CreateCommandQueue failed: %+v", err)
+ }
+ program, err := context.CreateProgramWithSource([]string{kernelSource})
+ if err != nil {
+ t.Fatalf("CreateProgramWithSource failed: %+v", err)
+ }
+ if err := program.BuildProgram(nil, ""); err != nil {
+ t.Fatalf("BuildProgram failed: %+v", err)
+ }
+ kernel, err := program.CreateKernel("square")
+ if err != nil {
+ t.Fatalf("CreateKernel failed: %+v", err)
+ }
+ for i := 0; i < 3; i++ {
+ name, err := kernel.ArgName(i)
+ if err == ErrUnsupported {
+ break
+ } else if err != nil {
+ t.Errorf("GetKernelArgInfo for name failed: %+v", err)
+ break
+ } else {
+ t.Logf("Kernel arg %d: %s", i, name)
+ }
+ }
+ input, err := context.CreateEmptyBuffer(MemReadOnly, 4*len(data))
+ if err != nil {
+ t.Fatalf("CreateBuffer failed for input: %+v", err)
+ }
+ output, err := context.CreateEmptyBuffer(MemReadOnly, 4*len(data))
+ if err != nil {
+ t.Fatalf("CreateBuffer failed for output: %+v", err)
+ }
+ if _, err := queue.EnqueueWriteBufferFloat32(input, true, 0, data[:], nil); err != nil {
+ t.Fatalf("EnqueueWriteBufferFloat32 failed: %+v", err)
+ }
+ if err := kernel.SetArgs(input, output, uint32(len(data))); err != nil {
+ t.Fatalf("SetKernelArgs failed: %+v", err)
+ }
+
+ local, err := kernel.WorkGroupSize(device)
+ if err != nil {
+ t.Fatalf("WorkGroupSize failed: %+v", err)
+ }
+ t.Logf("Work group size: %d", local)
+ size, _ := kernel.PreferredWorkGroupSizeMultiple(nil)
+ t.Logf("Preferred Work Group Size Multiple: %d", size)
+
+ global := len(data)
+ d := len(data) % local
+ if d != 0 {
+ global += local - d
+ }
+ if _, err := queue.EnqueueNDRangeKernel(kernel, nil, []int{global}, []int{local}, nil); err != nil {
+ t.Fatalf("EnqueueNDRangeKernel failed: %+v", err)
+ }
+
+ if err := queue.Finish(); err != nil {
+ t.Fatalf("Finish failed: %+v", err)
+ }
+
+ results := make([]float32, len(data))
+ if _, err := queue.EnqueueReadBufferFloat32(output, true, 0, results, nil); err != nil {
+ t.Fatalf("EnqueueReadBufferFloat32 failed: %+v", err)
+ }
+
+ correct := 0
+ for i, v := range data {
+ if results[i] == v*v {
+ correct++
+ }
+ }
+
+ if correct != len(data) {
+ t.Fatalf("%d/%d correct values", correct, len(data))
+ }
+}
diff --git a/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/context.go b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/context.go
new file mode 100644
index 000000000..67441bb5f
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/context.go
@@ -0,0 +1,161 @@
+package cl
+
+// #include <stdlib.h>
+// #ifdef __APPLE__
+// #include "OpenCL/opencl.h"
+// #else
+// #include "cl.h"
+// #endif
+import "C"
+
+import (
+ "runtime"
+ "unsafe"
+)
+
+const maxImageFormats = 256
+
+type Context struct {
+ clContext C.cl_context
+ devices []*Device
+}
+
+type MemObject struct {
+ clMem C.cl_mem
+ size int
+}
+
+func releaseContext(c *Context) {
+ if c.clContext != nil {
+ C.clReleaseContext(c.clContext)
+ c.clContext = nil
+ }
+}
+
+func releaseMemObject(b *MemObject) {
+ if b.clMem != nil {
+ C.clReleaseMemObject(b.clMem)
+ b.clMem = nil
+ }
+}
+
+func newMemObject(mo C.cl_mem, size int) *MemObject {
+ memObject := &MemObject{clMem: mo, size: size}
+ runtime.SetFinalizer(memObject, releaseMemObject)
+ return memObject
+}
+
+func (b *MemObject) Release() {
+ releaseMemObject(b)
+}
+
+// TODO: properties
+func CreateContext(devices []*Device) (*Context, error) {
+ deviceIds := buildDeviceIdList(devices)
+ var err C.cl_int
+ clContext := C.clCreateContext(nil, C.cl_uint(len(devices)), &deviceIds[0], nil, nil, &err)
+ if err != C.CL_SUCCESS {
+ return nil, toError(err)
+ }
+ if clContext == nil {
+ return nil, ErrUnknown
+ }
+ context := &Context{clContext: clContext, devices: devices}
+ runtime.SetFinalizer(context, releaseContext)
+ return context, nil
+}
+
+func (ctx *Context) GetSupportedImageFormats(flags MemFlag, imageType MemObjectType) ([]ImageFormat, error) {
+ var formats [maxImageFormats]C.cl_image_format
+ var nFormats C.cl_uint
+ if err := C.clGetSupportedImageFormats(ctx.clContext, C.cl_mem_flags(flags), C.cl_mem_object_type(imageType), maxImageFormats, &formats[0], &nFormats); err != C.CL_SUCCESS {
+ return nil, toError(err)
+ }
+ fmts := make([]ImageFormat, nFormats)
+ for i, f := range formats[:nFormats] {
+ fmts[i] = ImageFormat{
+ ChannelOrder: ChannelOrder(f.image_channel_order),
+ ChannelDataType: ChannelDataType(f.image_channel_data_type),
+ }
+ }
+ return fmts, nil
+}
+
+func (ctx *Context) CreateCommandQueue(device *Device, properties CommandQueueProperty) (*CommandQueue, error) {
+ var err C.cl_int
+ clQueue := C.clCreateCommandQueue(ctx.clContext, device.id, C.cl_command_queue_properties(properties), &err)
+ if err != C.CL_SUCCESS {
+ return nil, toError(err)
+ }
+ if clQueue == nil {
+ return nil, ErrUnknown
+ }
+ commandQueue := &CommandQueue{clQueue: clQueue, device: device}
+ runtime.SetFinalizer(commandQueue, releaseCommandQueue)
+ return commandQueue, nil
+}
+
+func (ctx *Context) CreateProgramWithSource(sources []string) (*Program, error) {
+ cSources := make([]*C.char, len(sources))
+ for i, s := range sources {
+ cs := C.CString(s)
+ cSources[i] = cs
+ defer C.free(unsafe.Pointer(cs))
+ }
+ var err C.cl_int
+ clProgram := C.clCreateProgramWithSource(ctx.clContext, C.cl_uint(len(sources)), &cSources[0], nil, &err)
+ if err != C.CL_SUCCESS {
+ return nil, toError(err)
+ }
+ if clProgram == nil {
+ return nil, ErrUnknown
+ }
+ program := &Program{clProgram: clProgram, devices: ctx.devices}
+ runtime.SetFinalizer(program, releaseProgram)
+ return program, nil
+}
+
+func (ctx *Context) CreateBufferUnsafe(flags MemFlag, size int, dataPtr unsafe.Pointer) (*MemObject, error) {
+ var err C.cl_int
+ clBuffer := C.clCreateBuffer(ctx.clContext, C.cl_mem_flags(flags), C.size_t(size), dataPtr, &err)
+ if err != C.CL_SUCCESS {
+ return nil, toError(err)
+ }
+ if clBuffer == nil {
+ return nil, ErrUnknown
+ }
+ return newMemObject(clBuffer, size), nil
+}
+
+func (ctx *Context) CreateEmptyBuffer(flags MemFlag, size int) (*MemObject, error) {
+ return ctx.CreateBufferUnsafe(flags, size, nil)
+}
+
+func (ctx *Context) CreateEmptyBufferFloat32(flags MemFlag, size int) (*MemObject, error) {
+ return ctx.CreateBufferUnsafe(flags, 4*size, nil)
+}
+
+func (ctx *Context) CreateBuffer(flags MemFlag, data []byte) (*MemObject, error) {
+ return ctx.CreateBufferUnsafe(flags, len(data), unsafe.Pointer(&data[0]))
+}
+
+//float64
+func (ctx *Context) CreateBufferFloat32(flags MemFlag, data []float32) (*MemObject, error) {
+ return ctx.CreateBufferUnsafe(flags, 4*len(data), unsafe.Pointer(&data[0]))
+}
+
+func (ctx *Context) CreateUserEvent() (*Event, error) {
+ var err C.cl_int
+ clEvent := C.clCreateUserEvent(ctx.clContext, &err)
+ if err != C.CL_SUCCESS {
+ return nil, toError(err)
+ }
+ return newEvent(clEvent), nil
+}
+
+func (ctx *Context) Release() {
+ releaseContext(ctx)
+}
+
+// http://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clCreateSubBuffer.html
+// func (memObject *MemObject) CreateSubBuffer(flags MemFlag, bufferCreateType BufferCreateType, )
diff --git a/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/device.go b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/device.go
new file mode 100644
index 000000000..d62a6fb71
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/device.go
@@ -0,0 +1,510 @@
+package cl
+
+// #ifdef __APPLE__
+// #include "OpenCL/opencl.h"
+// #else
+// #include "cl.h"
+// #include "cl_ext.h"
+// #endif
+import "C"
+
+import (
+ "strings"
+ "unsafe"
+)
+
+const maxDeviceCount = 64
+
+type DeviceType uint
+
+const (
+ DeviceTypeCPU DeviceType = C.CL_DEVICE_TYPE_CPU
+ DeviceTypeGPU DeviceType = C.CL_DEVICE_TYPE_GPU
+ DeviceTypeAccelerator DeviceType = C.CL_DEVICE_TYPE_ACCELERATOR
+ DeviceTypeDefault DeviceType = C.CL_DEVICE_TYPE_DEFAULT
+ DeviceTypeAll DeviceType = C.CL_DEVICE_TYPE_ALL
+)
+
+type FPConfig int
+
+const (
+ FPConfigDenorm FPConfig = C.CL_FP_DENORM // denorms are supported
+ FPConfigInfNaN FPConfig = C.CL_FP_INF_NAN // INF and NaNs are supported
+ FPConfigRoundToNearest FPConfig = C.CL_FP_ROUND_TO_NEAREST // round to nearest even rounding mode supported
+ FPConfigRoundToZero FPConfig = C.CL_FP_ROUND_TO_ZERO // round to zero rounding mode supported
+ FPConfigRoundToInf FPConfig = C.CL_FP_ROUND_TO_INF // round to positive and negative infinity rounding modes supported
+ FPConfigFMA FPConfig = C.CL_FP_FMA // IEEE754-2008 fused multiply-add is supported
+ FPConfigSoftFloat FPConfig = C.CL_FP_SOFT_FLOAT // Basic floating-point operations (such as addition, subtraction, multiplication) are implemented in software
+)
+
+var fpConfigNameMap = map[FPConfig]string{
+ FPConfigDenorm: "Denorm",
+ FPConfigInfNaN: "InfNaN",
+ FPConfigRoundToNearest: "RoundToNearest",
+ FPConfigRoundToZero: "RoundToZero",
+ FPConfigRoundToInf: "RoundToInf",
+ FPConfigFMA: "FMA",
+ FPConfigSoftFloat: "SoftFloat",
+}
+
+func (c FPConfig) String() string {
+ var parts []string
+ for bit, name := range fpConfigNameMap {
+ if c&bit != 0 {
+ parts = append(parts, name)
+ }
+ }
+ if parts == nil {
+ return ""
+ }
+ return strings.Join(parts, "|")
+}
+
+func (dt DeviceType) String() string {
+ var parts []string
+ if dt&DeviceTypeCPU != 0 {
+ parts = append(parts, "CPU")
+ }
+ if dt&DeviceTypeGPU != 0 {
+ parts = append(parts, "GPU")
+ }
+ if dt&DeviceTypeAccelerator != 0 {
+ parts = append(parts, "Accelerator")
+ }
+ if dt&DeviceTypeDefault != 0 {
+ parts = append(parts, "Default")
+ }
+ if parts == nil {
+ parts = append(parts, "None")
+ }
+ return strings.Join(parts, "|")
+}
+
+type Device struct {
+ id C.cl_device_id
+}
+
+func buildDeviceIdList(devices []*Device) []C.cl_device_id {
+ deviceIds := make([]C.cl_device_id, len(devices))
+ for i, d := range devices {
+ deviceIds[i] = d.id
+ }
+ return deviceIds
+}
+
+// Obtain the list of devices available on a platform. 'platform' refers
+// to the platform returned by GetPlatforms or can be nil. If platform
+// is nil, the behavior is implementation-defined.
+func GetDevices(platform *Platform, deviceType DeviceType) ([]*Device, error) {
+ var deviceIds [maxDeviceCount]C.cl_device_id
+ var numDevices C.cl_uint
+ var platformId C.cl_platform_id
+ if platform != nil {
+ platformId = platform.id
+ }
+ if err := C.clGetDeviceIDs(platformId, C.cl_device_type(deviceType), C.cl_uint(maxDeviceCount), &deviceIds[0], &numDevices); err != C.CL_SUCCESS {
+ return nil, toError(err)
+ }
+ if numDevices > maxDeviceCount {
+ numDevices = maxDeviceCount
+ }
+ devices := make([]*Device, numDevices)
+ for i := 0; i < int(numDevices); i++ {
+ devices[i] = &Device{id: deviceIds[i]}
+ }
+ return devices, nil
+}
+
+func (d *Device) nullableId() C.cl_device_id {
+ if d == nil {
+ return nil
+ }
+ return d.id
+}
+
+func (d *Device) GetInfoString(param C.cl_device_info, panicOnError bool) (string, error) {
+ var strC [1024]C.char
+ var strN C.size_t
+ if err := C.clGetDeviceInfo(d.id, param, 1024, unsafe.Pointer(&strC), &strN); err != C.CL_SUCCESS {
+ if panicOnError {
+ panic("Should never fail")
+ }
+ return "", toError(err)
+ }
+
+ // OpenCL strings are NUL-terminated, and the terminator is included in strN
+ // Go strings aren't NUL-terminated, so subtract 1 from the length
+ return C.GoStringN((*C.char)(unsafe.Pointer(&strC)), C.int(strN-1)), nil
+}
+
+func (d *Device) getInfoUint(param C.cl_device_info, panicOnError bool) (uint, error) {
+ var val C.cl_uint
+ if err := C.clGetDeviceInfo(d.id, param, C.size_t(unsafe.Sizeof(val)), unsafe.Pointer(&val), nil); err != C.CL_SUCCESS {
+ if panicOnError {
+ panic("Should never fail")
+ }
+ return 0, toError(err)
+ }
+ return uint(val), nil
+}
+
+func (d *Device) getInfoSize(param C.cl_device_info, panicOnError bool) (int, error) {
+ var val C.size_t
+ if err := C.clGetDeviceInfo(d.id, param, C.size_t(unsafe.Sizeof(val)), unsafe.Pointer(&val), nil); err != C.CL_SUCCESS {
+ if panicOnError {
+ panic("Should never fail")
+ }
+ return 0, toError(err)
+ }
+ return int(val), nil
+}
+
+func (d *Device) getInfoUlong(param C.cl_device_info, panicOnError bool) (int64, error) {
+ var val C.cl_ulong
+ if err := C.clGetDeviceInfo(d.id, param, C.size_t(unsafe.Sizeof(val)), unsafe.Pointer(&val), nil); err != C.CL_SUCCESS {
+ if panicOnError {
+ panic("Should never fail")
+ }
+ return 0, toError(err)
+ }
+ return int64(val), nil
+}
+
+func (d *Device) getInfoBool(param C.cl_device_info, panicOnError bool) (bool, error) {
+ var val C.cl_bool
+ if err := C.clGetDeviceInfo(d.id, param, C.size_t(unsafe.Sizeof(val)), unsafe.Pointer(&val), nil); err != C.CL_SUCCESS {
+ if panicOnError {
+ panic("Should never fail")
+ }
+ return false, toError(err)
+ }
+ return val == C.CL_TRUE, nil
+}
+
+func (d *Device) Name() string {
+ str, _ := d.GetInfoString(C.CL_DEVICE_NAME, true)
+ return str
+}
+
+func (d *Device) Vendor() string {
+ str, _ := d.GetInfoString(C.CL_DEVICE_VENDOR, true)
+ return str
+}
+
+func (d *Device) Extensions() string {
+ str, _ := d.GetInfoString(C.CL_DEVICE_EXTENSIONS, true)
+ return str
+}
+
+func (d *Device) OpenCLCVersion() string {
+ str, _ := d.GetInfoString(C.CL_DEVICE_OPENCL_C_VERSION, true)
+ return str
+}
+
+func (d *Device) Profile() string {
+ str, _ := d.GetInfoString(C.CL_DEVICE_PROFILE, true)
+ return str
+}
+
+func (d *Device) Version() string {
+ str, _ := d.GetInfoString(C.CL_DEVICE_VERSION, true)
+ return str
+}
+
+func (d *Device) DriverVersion() string {
+ str, _ := d.GetInfoString(C.CL_DRIVER_VERSION, true)
+ return str
+}
+
+// The default compute device address space size specified as an
+// unsigned integer value in bits. Currently supported values are 32 or 64 bits.
+func (d *Device) AddressBits() int {
+ val, _ := d.getInfoUint(C.CL_DEVICE_ADDRESS_BITS, true)
+ return int(val)
+}
+
+// Size of global memory cache line in bytes.
+func (d *Device) GlobalMemCachelineSize() int {
+ val, _ := d.getInfoUint(C.CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, true)
+ return int(val)
+}
+
+// Maximum configured clock frequency of the device in MHz.
+func (d *Device) MaxClockFrequency() int {
+ val, _ := d.getInfoUint(C.CL_DEVICE_MAX_CLOCK_FREQUENCY, true)
+ return int(val)
+}
+
+// The number of parallel compute units on the OpenCL device.
+// A work-group executes on a single compute unit. The minimum value is 1.
+func (d *Device) MaxComputeUnits() int {
+ val, _ := d.getInfoUint(C.CL_DEVICE_MAX_COMPUTE_UNITS, true)
+ return int(val)
+}
+
+// Max number of arguments declared with the __constant qualifier in a kernel.
+// The minimum value is 8 for devices that are not of type CL_DEVICE_TYPE_CUSTOM.
+func (d *Device) MaxConstantArgs() int {
+ val, _ := d.getInfoUint(C.CL_DEVICE_MAX_CONSTANT_ARGS, true)
+ return int(val)
+}
+
+// Max number of simultaneous image objects that can be read by a kernel.
+// The minimum value is 128 if CL_DEVICE_IMAGE_SUPPORT is CL_TRUE.
+func (d *Device) MaxReadImageArgs() int {
+ val, _ := d.getInfoUint(C.CL_DEVICE_MAX_READ_IMAGE_ARGS, true)
+ return int(val)
+}
+
+// Maximum number of samplers that can be used in a kernel. The minimum
+// value is 16 if CL_DEVICE_IMAGE_SUPPORT is CL_TRUE. (Also see sampler_t.)
+func (d *Device) MaxSamplers() int {
+ val, _ := d.getInfoUint(C.CL_DEVICE_MAX_SAMPLERS, true)
+ return int(val)
+}
+
+// Maximum dimensions that specify the global and local work-item IDs used
+// by the data parallel execution model. (Refer to clEnqueueNDRangeKernel).
+// The minimum value is 3 for devices that are not of type CL_DEVICE_TYPE_CUSTOM.
+func (d *Device) MaxWorkItemDimensions() int {
+ val, _ := d.getInfoUint(C.CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, true)
+ return int(val)
+}
+
+// Max number of simultaneous image objects that can be written to by a
+// kernel. The minimum value is 8 if CL_DEVICE_IMAGE_SUPPORT is CL_TRUE.
+func (d *Device) MaxWriteImageArgs() int {
+ val, _ := d.getInfoUint(C.CL_DEVICE_MAX_WRITE_IMAGE_ARGS, true)
+ return int(val)
+}
+
+// The minimum value is the size (in bits) of the largest OpenCL built-in
+// data type supported by the device (long16 in FULL profile, long16 or
+// int16 in EMBEDDED profile) for devices that are not of type CL_DEVICE_TYPE_CUSTOM.
+func (d *Device) MemBaseAddrAlign() int {
+ val, _ := d.getInfoUint(C.CL_DEVICE_MEM_BASE_ADDR_ALIGN, true)
+ return int(val)
+}
+
+func (d *Device) NativeVectorWidthChar() int {
+ val, _ := d.getInfoUint(C.CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, true)
+ return int(val)
+}
+
+func (d *Device) NativeVectorWidthShort() int {
+ val, _ := d.getInfoUint(C.CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, true)
+ return int(val)
+}
+
+func (d *Device) NativeVectorWidthInt() int {
+ val, _ := d.getInfoUint(C.CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, true)
+ return int(val)
+}
+
+func (d *Device) NativeVectorWidthLong() int {
+ val, _ := d.getInfoUint(C.CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, true)
+ return int(val)
+}
+
+func (d *Device) NativeVectorWidthFloat() int {
+ val, _ := d.getInfoUint(C.CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, true)
+ return int(val)
+}
+
+func (d *Device) NativeVectorWidthDouble() int {
+ val, _ := d.getInfoUint(C.CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, true)
+ return int(val)
+}
+
+func (d *Device) NativeVectorWidthHalf() int {
+ val, _ := d.getInfoUint(C.CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, true)
+ return int(val)
+}
+
+// Max height of 2D image in pixels. The minimum value is 8192
+// if CL_DEVICE_IMAGE_SUPPORT is CL_TRUE.
+func (d *Device) Image2DMaxHeight() int {
+ val, _ := d.getInfoSize(C.CL_DEVICE_IMAGE2D_MAX_HEIGHT, true)
+ return int(val)
+}
+
+// Max width of 2D image or 1D image not created from a buffer object in
+// pixels. The minimum value is 8192 if CL_DEVICE_IMAGE_SUPPORT is CL_TRUE.
+func (d *Device) Image2DMaxWidth() int {
+ val, _ := d.getInfoSize(C.CL_DEVICE_IMAGE2D_MAX_WIDTH, true)
+ return int(val)
+}
+
+// Max depth of 3D image in pixels. The minimum value is 2048 if CL_DEVICE_IMAGE_SUPPORT is CL_TRUE.
+func (d *Device) Image3DMaxDepth() int {
+ val, _ := d.getInfoSize(C.CL_DEVICE_IMAGE3D_MAX_DEPTH, true)
+ return int(val)
+}
+
+// Max height of 3D image in pixels. The minimum value is 2048 if CL_DEVICE_IMAGE_SUPPORT is CL_TRUE.
+func (d *Device) Image3DMaxHeight() int {
+ val, _ := d.getInfoSize(C.CL_DEVICE_IMAGE3D_MAX_HEIGHT, true)
+ return int(val)
+}
+
+// Max width of 3D image in pixels. The minimum value is 2048 if CL_DEVICE_IMAGE_SUPPORT is CL_TRUE.
+func (d *Device) Image3DMaxWidth() int {
+ val, _ := d.getInfoSize(C.CL_DEVICE_IMAGE3D_MAX_WIDTH, true)
+ return int(val)
+}
+
+// Max size in bytes of the arguments that can be passed to a kernel. The
+// minimum value is 1024 for devices that are not of type CL_DEVICE_TYPE_CUSTOM.
+// For this minimum value, only a maximum of 128 arguments can be passed to a kernel.
+func (d *Device) MaxParameterSize() int {
+ val, _ := d.getInfoSize(C.CL_DEVICE_MAX_PARAMETER_SIZE, true)
+ return int(val)
+}
+
+// Maximum number of work-items in a work-group executing a kernel on a
+// single compute unit, using the data parallel execution model. (Refer
+// to clEnqueueNDRangeKernel). The minimum value is 1.
+func (d *Device) MaxWorkGroupSize() int {
+ val, _ := d.getInfoSize(C.CL_DEVICE_MAX_WORK_GROUP_SIZE, true)
+ return int(val)
+}
+
+// Describes the resolution of device timer. This is measured in nanoseconds.
+func (d *Device) ProfilingTimerResolution() int {
+ val, _ := d.getInfoSize(C.CL_DEVICE_PROFILING_TIMER_RESOLUTION, true)
+ return int(val)
+}
+
+// Size of local memory arena in bytes. The minimum value is 32 KB for
+// devices that are not of type CL_DEVICE_TYPE_CUSTOM.
+func (d *Device) LocalMemSize() int64 {
+ val, _ := d.getInfoUlong(C.CL_DEVICE_LOCAL_MEM_SIZE, true)
+ return val
+}
+
+// Max size in bytes of a constant buffer allocation. The minimum value is
+// 64 KB for devices that are not of type CL_DEVICE_TYPE_CUSTOM.
+func (d *Device) MaxConstantBufferSize() int64 {
+ val, _ := d.getInfoUlong(C.CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, true)
+ return val
+}
+
+// Max size of memory object allocation in bytes. The minimum value is max
+// (1/4th of CL_DEVICE_GLOBAL_MEM_SIZE, 128*1024*1024) for devices that are
+// not of type CL_DEVICE_TYPE_CUSTOM.
+func (d *Device) MaxMemAllocSize() int64 {
+ val, _ := d.getInfoUlong(C.CL_DEVICE_MAX_MEM_ALLOC_SIZE, true)
+ return val
+}
+
+// Size of global device memory in bytes.
+func (d *Device) GlobalMemSize() int64 {
+ val, _ := d.getInfoUlong(C.CL_DEVICE_GLOBAL_MEM_SIZE, true)
+ return val
+}
+
+func (d *Device) Available() bool {
+ val, _ := d.getInfoBool(C.CL_DEVICE_AVAILABLE, true)
+ return val
+}
+
+func (d *Device) CompilerAvailable() bool {
+ val, _ := d.getInfoBool(C.CL_DEVICE_COMPILER_AVAILABLE, true)
+ return val
+}
+
+func (d *Device) EndianLittle() bool {
+ val, _ := d.getInfoBool(C.CL_DEVICE_ENDIAN_LITTLE, true)
+ return val
+}
+
+// Is CL_TRUE if the device implements error correction for all
+// accesses to compute device memory (global and constant). Is
+// CL_FALSE if the device does not implement such error correction.
+func (d *Device) ErrorCorrectionSupport() bool {
+ val, _ := d.getInfoBool(C.CL_DEVICE_ERROR_CORRECTION_SUPPORT, true)
+ return val
+}
+
+func (d *Device) HostUnifiedMemory() bool {
+ val, _ := d.getInfoBool(C.CL_DEVICE_HOST_UNIFIED_MEMORY, true)
+ return val
+}
+
+func (d *Device) ImageSupport() bool {
+ val, _ := d.getInfoBool(C.CL_DEVICE_IMAGE_SUPPORT, true)
+ return val
+}
+
+func (d *Device) Type() DeviceType {
+ var deviceType C.cl_device_type
+ if err := C.clGetDeviceInfo(d.id, C.CL_DEVICE_TYPE, C.size_t(unsafe.Sizeof(deviceType)), unsafe.Pointer(&deviceType), nil); err != C.CL_SUCCESS {
+ panic("Failed to get device type")
+ }
+ return DeviceType(deviceType)
+}
+
+// Describes double precision floating-point capability of the OpenCL device
+func (d *Device) DoubleFPConfig() FPConfig {
+ var fpConfig C.cl_device_fp_config
+ if err := C.clGetDeviceInfo(d.id, C.CL_DEVICE_DOUBLE_FP_CONFIG, C.size_t(unsafe.Sizeof(fpConfig)), unsafe.Pointer(&fpConfig), nil); err != C.CL_SUCCESS {
+ panic("Failed to get double FP config")
+ }
+ return FPConfig(fpConfig)
+}
+
+// Describes the OPTIONAL half precision floating-point capability of the OpenCL device
+func (d *Device) HalfFPConfig() FPConfig {
+ var fpConfig C.cl_device_fp_config
+ err := C.clGetDeviceInfo(d.id, C.CL_DEVICE_HALF_FP_CONFIG, C.size_t(unsafe.Sizeof(fpConfig)), unsafe.Pointer(&fpConfig), nil)
+ if err != C.CL_SUCCESS {
+ return FPConfig(0)
+ }
+ return FPConfig(fpConfig)
+}
+
+// Type of local memory supported. This can be set to CL_LOCAL implying dedicated
+// local memory storage such as SRAM, or CL_GLOBAL. For custom devices, CL_NONE
+// can also be returned indicating no local memory support.
+func (d *Device) LocalMemType() LocalMemType {
+ var memType C.cl_device_local_mem_type
+ if err := C.clGetDeviceInfo(d.id, C.CL_DEVICE_LOCAL_MEM_TYPE, C.size_t(unsafe.Sizeof(memType)), unsafe.Pointer(&memType), nil); err != C.CL_SUCCESS {
+ return LocalMemType(C.CL_NONE)
+ }
+ return LocalMemType(memType)
+}
+
+// Describes the execution capabilities of the device. The mandated minimum capability is CL_EXEC_KERNEL.
+func (d *Device) ExecutionCapabilities() ExecCapability {
+ var execCap C.cl_device_exec_capabilities
+ if err := C.clGetDeviceInfo(d.id, C.CL_DEVICE_EXECUTION_CAPABILITIES, C.size_t(unsafe.Sizeof(execCap)), unsafe.Pointer(&execCap), nil); err != C.CL_SUCCESS {
+ panic("Failed to get execution capabilities")
+ }
+ return ExecCapability(execCap)
+}
+
+func (d *Device) GlobalMemCacheType() MemCacheType {
+ var memType C.cl_device_mem_cache_type
+ if err := C.clGetDeviceInfo(d.id, C.CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, C.size_t(unsafe.Sizeof(memType)), unsafe.Pointer(&memType), nil); err != C.CL_SUCCESS {
+ return MemCacheType(C.CL_NONE)
+ }
+ return MemCacheType(memType)
+}
+
+// Maximum number of work-items that can be specified in each dimension of the work-group to clEnqueueNDRangeKernel.
+//
+// Returns n size_t entries, where n is the value returned by the query for CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS.
+//
+// The minimum value is (1, 1, 1) for devices that are not of type CL_DEVICE_TYPE_CUSTOM.
+func (d *Device) MaxWorkItemSizes() []int {
+ dims := d.MaxWorkItemDimensions()
+ sizes := make([]C.size_t, dims)
+ if err := C.clGetDeviceInfo(d.id, C.CL_DEVICE_MAX_WORK_ITEM_SIZES, C.size_t(int(unsafe.Sizeof(sizes[0]))*dims), unsafe.Pointer(&sizes[0]), nil); err != C.CL_SUCCESS {
+ panic("Failed to get max work item sizes")
+ }
+ intSizes := make([]int, dims)
+ for i, s := range sizes {
+ intSizes[i] = int(s)
+ }
+ return intSizes
+}
diff --git a/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/device12.go b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/device12.go
new file mode 100644
index 000000000..b4b559a6a
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/device12.go
@@ -0,0 +1,51 @@
+// +build cl12
+
+package cl
+
+// #ifdef __APPLE__
+// #include "OpenCL/opencl.h"
+// #else
+// #include "cl.h"
+// #endif
+import "C"
+import "unsafe"
+
+const FPConfigCorrectlyRoundedDivideSqrt FPConfig = C.CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT
+
+func init() {
+ fpConfigNameMap[FPConfigCorrectlyRoundedDivideSqrt] = "CorrectlyRoundedDivideSqrt"
+}
+
+func (d *Device) BuiltInKernels() string {
+ str, _ := d.getInfoString(C.CL_DEVICE_BUILT_IN_KERNELS, true)
+ return str
+}
+
+// Is CL_FALSE if the implementation does not have a linker available. Is CL_TRUE if the linker is available. This can be CL_FALSE for the embedded platform profile only. This must be CL_TRUE if CL_DEVICE_COMPILER_AVAILABLE is CL_TRUE
+func (d *Device) LinkerAvailable() bool {
+ val, _ := d.getInfoBool(C.CL_DEVICE_LINKER_AVAILABLE, true)
+ return val
+}
+
+func (d *Device) ParentDevice() *Device {
+ var deviceId C.cl_device_id
+ if err := C.clGetDeviceInfo(d.id, C.CL_DEVICE_PARENT_DEVICE, C.size_t(unsafe.Sizeof(deviceId)), unsafe.Pointer(&deviceId), nil); err != C.CL_SUCCESS {
+ panic("ParentDevice failed")
+ }
+ if deviceId == nil {
+ return nil
+ }
+ return &Device{id: deviceId}
+}
+
+// Max number of pixels for a 1D image created from a buffer object. The minimum value is 65536 if CL_DEVICE_IMAGE_SUPPORT is CL_TRUE.
+func (d *Device) ImageMaxBufferSize() int {
+ val, _ := d.getInfoSize(C.CL_DEVICE_IMAGE_MAX_BUFFER_SIZE, true)
+ return int(val)
+}
+
+// Max number of images in a 1D or 2D image array. The minimum value is 2048 if CL_DEVICE_IMAGE_SUPPORT is CL_TRUE
+func (d *Device) ImageMaxArraySize() int {
+ val, _ := d.getInfoSize(C.CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, true)
+ return int(val)
+}
diff --git a/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/cl.h b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/cl.h
new file mode 100644
index 000000000..c38aa1eda
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/cl.h
@@ -0,0 +1,1210 @@
+/*******************************************************************************
+ * Copyright (c) 2008 - 2012 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ ******************************************************************************/
+
+#ifndef __OPENCL_CL_H
+#define __OPENCL_CL_H
+
+#include <cl_platform.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/******************************************************************************/
+
+typedef struct _cl_platform_id * cl_platform_id;
+typedef struct _cl_device_id * cl_device_id;
+typedef struct _cl_context * cl_context;
+typedef struct _cl_command_queue * cl_command_queue;
+typedef struct _cl_mem * cl_mem;
+typedef struct _cl_program * cl_program;
+typedef struct _cl_kernel * cl_kernel;
+typedef struct _cl_event * cl_event;
+typedef struct _cl_sampler * cl_sampler;
+
+typedef cl_uint cl_bool; /* WARNING! Unlike cl_ types in cl_platform.h, cl_bool is not guaranteed to be the same size as the bool in kernels. */
+typedef cl_ulong cl_bitfield;
+typedef cl_bitfield cl_device_type;
+typedef cl_uint cl_platform_info;
+typedef cl_uint cl_device_info;
+typedef cl_bitfield cl_device_fp_config;
+typedef cl_uint cl_device_mem_cache_type;
+typedef cl_uint cl_device_local_mem_type;
+typedef cl_bitfield cl_device_exec_capabilities;
+typedef cl_bitfield cl_command_queue_properties;
+typedef intptr_t cl_device_partition_property;
+typedef cl_bitfield cl_device_affinity_domain;
+
+typedef intptr_t cl_context_properties;
+typedef cl_uint cl_context_info;
+typedef cl_uint cl_command_queue_info;
+typedef cl_uint cl_channel_order;
+typedef cl_uint cl_channel_type;
+typedef cl_bitfield cl_mem_flags;
+typedef cl_uint cl_mem_object_type;
+typedef cl_uint cl_mem_info;
+typedef cl_bitfield cl_mem_migration_flags;
+typedef cl_uint cl_image_info;
+typedef cl_uint cl_buffer_create_type;
+typedef cl_uint cl_addressing_mode;
+typedef cl_uint cl_filter_mode;
+typedef cl_uint cl_sampler_info;
+typedef cl_bitfield cl_map_flags;
+typedef cl_uint cl_program_info;
+typedef cl_uint cl_program_build_info;
+typedef cl_uint cl_program_binary_type;
+typedef cl_int cl_build_status;
+typedef cl_uint cl_kernel_info;
+typedef cl_uint cl_kernel_arg_info;
+typedef cl_uint cl_kernel_arg_address_qualifier;
+typedef cl_uint cl_kernel_arg_access_qualifier;
+typedef cl_bitfield cl_kernel_arg_type_qualifier;
+typedef cl_uint cl_kernel_work_group_info;
+typedef cl_uint cl_event_info;
+typedef cl_uint cl_command_type;
+typedef cl_uint cl_profiling_info;
+
+
+typedef struct _cl_image_format {
+ cl_channel_order image_channel_order;
+ cl_channel_type image_channel_data_type;
+} cl_image_format;
+
+typedef struct _cl_image_desc {
+ cl_mem_object_type image_type;
+ size_t image_width;
+ size_t image_height;
+ size_t image_depth;
+ size_t image_array_size;
+ size_t image_row_pitch;
+ size_t image_slice_pitch;
+ cl_uint num_mip_levels;
+ cl_uint num_samples;
+ cl_mem buffer;
+} cl_image_desc;
+
+typedef struct _cl_buffer_region {
+ size_t origin;
+ size_t size;
+} cl_buffer_region;
+
+
+/******************************************************************************/
+
+/* Error Codes */
+#define CL_SUCCESS 0
+#define CL_DEVICE_NOT_FOUND -1
+#define CL_DEVICE_NOT_AVAILABLE -2
+#define CL_COMPILER_NOT_AVAILABLE -3
+#define CL_MEM_OBJECT_ALLOCATION_FAILURE -4
+#define CL_OUT_OF_RESOURCES -5
+#define CL_OUT_OF_HOST_MEMORY -6
+#define CL_PROFILING_INFO_NOT_AVAILABLE -7
+#define CL_MEM_COPY_OVERLAP -8
+#define CL_IMAGE_FORMAT_MISMATCH -9
+#define CL_IMAGE_FORMAT_NOT_SUPPORTED -10
+#define CL_BUILD_PROGRAM_FAILURE -11
+#define CL_MAP_FAILURE -12
+#define CL_MISALIGNED_SUB_BUFFER_OFFSET -13
+#define CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST -14
+#define CL_COMPILE_PROGRAM_FAILURE -15
+#define CL_LINKER_NOT_AVAILABLE -16
+#define CL_LINK_PROGRAM_FAILURE -17
+#define CL_DEVICE_PARTITION_FAILED -18
+#define CL_KERNEL_ARG_INFO_NOT_AVAILABLE -19
+
+#define CL_INVALID_VALUE -30
+#define CL_INVALID_DEVICE_TYPE -31
+#define CL_INVALID_PLATFORM -32
+#define CL_INVALID_DEVICE -33
+#define CL_INVALID_CONTEXT -34
+#define CL_INVALID_QUEUE_PROPERTIES -35
+#define CL_INVALID_COMMAND_QUEUE -36
+#define CL_INVALID_HOST_PTR -37
+#define CL_INVALID_MEM_OBJECT -38
+#define CL_INVALID_IMAGE_FORMAT_DESCRIPTOR -39
+#define CL_INVALID_IMAGE_SIZE -40
+#define CL_INVALID_SAMPLER -41
+#define CL_INVALID_BINARY -42
+#define CL_INVALID_BUILD_OPTIONS -43
+#define CL_INVALID_PROGRAM -44
+#define CL_INVALID_PROGRAM_EXECUTABLE -45
+#define CL_INVALID_KERNEL_NAME -46
+#define CL_INVALID_KERNEL_DEFINITION -47
+#define CL_INVALID_KERNEL -48
+#define CL_INVALID_ARG_INDEX -49
+#define CL_INVALID_ARG_VALUE -50
+#define CL_INVALID_ARG_SIZE -51
+#define CL_INVALID_KERNEL_ARGS -52
+#define CL_INVALID_WORK_DIMENSION -53
+#define CL_INVALID_WORK_GROUP_SIZE -54
+#define CL_INVALID_WORK_ITEM_SIZE -55
+#define CL_INVALID_GLOBAL_OFFSET -56
+#define CL_INVALID_EVENT_WAIT_LIST -57
+#define CL_INVALID_EVENT -58
+#define CL_INVALID_OPERATION -59
+#define CL_INVALID_GL_OBJECT -60
+#define CL_INVALID_BUFFER_SIZE -61
+#define CL_INVALID_MIP_LEVEL -62
+#define CL_INVALID_GLOBAL_WORK_SIZE -63
+#define CL_INVALID_PROPERTY -64
+#define CL_INVALID_IMAGE_DESCRIPTOR -65
+#define CL_INVALID_COMPILER_OPTIONS -66
+#define CL_INVALID_LINKER_OPTIONS -67
+#define CL_INVALID_DEVICE_PARTITION_COUNT -68
+
+/* OpenCL Version */
+#define CL_VERSION_1_0 1
+#define CL_VERSION_1_1 1
+#define CL_VERSION_1_2 1
+
+/* cl_bool */
+#define CL_FALSE 0
+#define CL_TRUE 1
+#define CL_BLOCKING CL_TRUE
+#define CL_NON_BLOCKING CL_FALSE
+
+/* cl_platform_info */
+#define CL_PLATFORM_PROFILE 0x0900
+#define CL_PLATFORM_VERSION 0x0901
+#define CL_PLATFORM_NAME 0x0902
+#define CL_PLATFORM_VENDOR 0x0903
+#define CL_PLATFORM_EXTENSIONS 0x0904
+
+/* cl_device_type - bitfield */
+#define CL_DEVICE_TYPE_DEFAULT (1 << 0)
+#define CL_DEVICE_TYPE_CPU (1 << 1)
+#define CL_DEVICE_TYPE_GPU (1 << 2)
+#define CL_DEVICE_TYPE_ACCELERATOR (1 << 3)
+#define CL_DEVICE_TYPE_CUSTOM (1 << 4)
+#define CL_DEVICE_TYPE_ALL 0xFFFFFFFF
+
+/* cl_device_info */
+#define CL_DEVICE_TYPE 0x1000
+#define CL_DEVICE_VENDOR_ID 0x1001
+#define CL_DEVICE_MAX_COMPUTE_UNITS 0x1002
+#define CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS 0x1003
+#define CL_DEVICE_MAX_WORK_GROUP_SIZE 0x1004
+#define CL_DEVICE_MAX_WORK_ITEM_SIZES 0x1005
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR 0x1006
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT 0x1007
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT 0x1008
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG 0x1009
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT 0x100A
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE 0x100B
+#define CL_DEVICE_MAX_CLOCK_FREQUENCY 0x100C
+#define CL_DEVICE_ADDRESS_BITS 0x100D
+#define CL_DEVICE_MAX_READ_IMAGE_ARGS 0x100E
+#define CL_DEVICE_MAX_WRITE_IMAGE_ARGS 0x100F
+#define CL_DEVICE_MAX_MEM_ALLOC_SIZE 0x1010
+#define CL_DEVICE_IMAGE2D_MAX_WIDTH 0x1011
+#define CL_DEVICE_IMAGE2D_MAX_HEIGHT 0x1012
+#define CL_DEVICE_IMAGE3D_MAX_WIDTH 0x1013
+#define CL_DEVICE_IMAGE3D_MAX_HEIGHT 0x1014
+#define CL_DEVICE_IMAGE3D_MAX_DEPTH 0x1015
+#define CL_DEVICE_IMAGE_SUPPORT 0x1016
+#define CL_DEVICE_MAX_PARAMETER_SIZE 0x1017
+#define CL_DEVICE_MAX_SAMPLERS 0x1018
+#define CL_DEVICE_MEM_BASE_ADDR_ALIGN 0x1019
+#define CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE 0x101A
+#define CL_DEVICE_SINGLE_FP_CONFIG 0x101B
+#define CL_DEVICE_GLOBAL_MEM_CACHE_TYPE 0x101C
+#define CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE 0x101D
+#define CL_DEVICE_GLOBAL_MEM_CACHE_SIZE 0x101E
+#define CL_DEVICE_GLOBAL_MEM_SIZE 0x101F
+#define CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE 0x1020
+#define CL_DEVICE_MAX_CONSTANT_ARGS 0x1021
+#define CL_DEVICE_LOCAL_MEM_TYPE 0x1022
+#define CL_DEVICE_LOCAL_MEM_SIZE 0x1023
+#define CL_DEVICE_ERROR_CORRECTION_SUPPORT 0x1024
+#define CL_DEVICE_PROFILING_TIMER_RESOLUTION 0x1025
+#define CL_DEVICE_ENDIAN_LITTLE 0x1026
+#define CL_DEVICE_AVAILABLE 0x1027
+#define CL_DEVICE_COMPILER_AVAILABLE 0x1028
+#define CL_DEVICE_EXECUTION_CAPABILITIES 0x1029
+#define CL_DEVICE_QUEUE_PROPERTIES 0x102A
+#define CL_DEVICE_NAME 0x102B
+#define CL_DEVICE_VENDOR 0x102C
+#define CL_DRIVER_VERSION 0x102D
+#define CL_DEVICE_PROFILE 0x102E
+#define CL_DEVICE_VERSION 0x102F
+#define CL_DEVICE_EXTENSIONS 0x1030
+#define CL_DEVICE_PLATFORM 0x1031
+#define CL_DEVICE_DOUBLE_FP_CONFIG 0x1032
+/* 0x1033 reserved for CL_DEVICE_HALF_FP_CONFIG */
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF 0x1034
+#define CL_DEVICE_HOST_UNIFIED_MEMORY 0x1035
+#define CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR 0x1036
+#define CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT 0x1037
+#define CL_DEVICE_NATIVE_VECTOR_WIDTH_INT 0x1038
+#define CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG 0x1039
+#define CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT 0x103A
+#define CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE 0x103B
+#define CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF 0x103C
+#define CL_DEVICE_OPENCL_C_VERSION 0x103D
+#define CL_DEVICE_LINKER_AVAILABLE 0x103E
+#define CL_DEVICE_BUILT_IN_KERNELS 0x103F
+#define CL_DEVICE_IMAGE_MAX_BUFFER_SIZE 0x1040
+#define CL_DEVICE_IMAGE_MAX_ARRAY_SIZE 0x1041
+#define CL_DEVICE_PARENT_DEVICE 0x1042
+#define CL_DEVICE_PARTITION_MAX_SUB_DEVICES 0x1043
+#define CL_DEVICE_PARTITION_PROPERTIES 0x1044
+#define CL_DEVICE_PARTITION_AFFINITY_DOMAIN 0x1045
+#define CL_DEVICE_PARTITION_TYPE 0x1046
+#define CL_DEVICE_REFERENCE_COUNT 0x1047
+#define CL_DEVICE_PREFERRED_INTEROP_USER_SYNC 0x1048
+#define CL_DEVICE_PRINTF_BUFFER_SIZE 0x1049
+#define CL_DEVICE_IMAGE_PITCH_ALIGNMENT 0x104A
+#define CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT 0x104B
+
+/* cl_device_fp_config - bitfield */
+#define CL_FP_DENORM (1 << 0)
+#define CL_FP_INF_NAN (1 << 1)
+#define CL_FP_ROUND_TO_NEAREST (1 << 2)
+#define CL_FP_ROUND_TO_ZERO (1 << 3)
+#define CL_FP_ROUND_TO_INF (1 << 4)
+#define CL_FP_FMA (1 << 5)
+#define CL_FP_SOFT_FLOAT (1 << 6)
+#define CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT (1 << 7)
+
+/* cl_device_mem_cache_type */
+#define CL_NONE 0x0
+#define CL_READ_ONLY_CACHE 0x1
+#define CL_READ_WRITE_CACHE 0x2
+
+/* cl_device_local_mem_type */
+#define CL_LOCAL 0x1
+#define CL_GLOBAL 0x2
+
+/* cl_device_exec_capabilities - bitfield */
+#define CL_EXEC_KERNEL (1 << 0)
+#define CL_EXEC_NATIVE_KERNEL (1 << 1)
+
+/* cl_command_queue_properties - bitfield */
+#define CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE (1 << 0)
+#define CL_QUEUE_PROFILING_ENABLE (1 << 1)
+
+/* cl_context_info */
+#define CL_CONTEXT_REFERENCE_COUNT 0x1080
+#define CL_CONTEXT_DEVICES 0x1081
+#define CL_CONTEXT_PROPERTIES 0x1082
+#define CL_CONTEXT_NUM_DEVICES 0x1083
+
+/* cl_context_properties */
+#define CL_CONTEXT_PLATFORM 0x1084
+#define CL_CONTEXT_INTEROP_USER_SYNC 0x1085
+
+/* cl_device_partition_property */
+#define CL_DEVICE_PARTITION_EQUALLY 0x1086
+#define CL_DEVICE_PARTITION_BY_COUNTS 0x1087
+#define CL_DEVICE_PARTITION_BY_COUNTS_LIST_END 0x0
+#define CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN 0x1088
+
+/* cl_device_affinity_domain */
+#define CL_DEVICE_AFFINITY_DOMAIN_NUMA (1 << 0)
+#define CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE (1 << 1)
+#define CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE (1 << 2)
+#define CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE (1 << 3)
+#define CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE (1 << 4)
+#define CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE (1 << 5)
+
+/* cl_command_queue_info */
+#define CL_QUEUE_CONTEXT 0x1090
+#define CL_QUEUE_DEVICE 0x1091
+#define CL_QUEUE_REFERENCE_COUNT 0x1092
+#define CL_QUEUE_PROPERTIES 0x1093
+
+/* cl_mem_flags - bitfield */
+#define CL_MEM_READ_WRITE (1 << 0)
+#define CL_MEM_WRITE_ONLY (1 << 1)
+#define CL_MEM_READ_ONLY (1 << 2)
+#define CL_MEM_USE_HOST_PTR (1 << 3)
+#define CL_MEM_ALLOC_HOST_PTR (1 << 4)
+#define CL_MEM_COPY_HOST_PTR (1 << 5)
+/* reserved (1 << 6) */
+#define CL_MEM_HOST_WRITE_ONLY (1 << 7)
+#define CL_MEM_HOST_READ_ONLY (1 << 8)
+#define CL_MEM_HOST_NO_ACCESS (1 << 9)
+
+/* cl_mem_migration_flags - bitfield */
+#define CL_MIGRATE_MEM_OBJECT_HOST (1 << 0)
+#define CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED (1 << 1)
+
+/* cl_channel_order */
+#define CL_R 0x10B0
+#define CL_A 0x10B1
+#define CL_RG 0x10B2
+#define CL_RA 0x10B3
+#define CL_RGB 0x10B4
+#define CL_RGBA 0x10B5
+#define CL_BGRA 0x10B6
+#define CL_ARGB 0x10B7
+#define CL_INTENSITY 0x10B8
+#define CL_LUMINANCE 0x10B9
+#define CL_Rx 0x10BA
+#define CL_RGx 0x10BB
+#define CL_RGBx 0x10BC
+#define CL_DEPTH 0x10BD
+#define CL_DEPTH_STENCIL 0x10BE
+
+/* cl_channel_type */
+#define CL_SNORM_INT8 0x10D0
+#define CL_SNORM_INT16 0x10D1
+#define CL_UNORM_INT8 0x10D2
+#define CL_UNORM_INT16 0x10D3
+#define CL_UNORM_SHORT_565 0x10D4
+#define CL_UNORM_SHORT_555 0x10D5
+#define CL_UNORM_INT_101010 0x10D6
+#define CL_SIGNED_INT8 0x10D7
+#define CL_SIGNED_INT16 0x10D8
+#define CL_SIGNED_INT32 0x10D9
+#define CL_UNSIGNED_INT8 0x10DA
+#define CL_UNSIGNED_INT16 0x10DB
+#define CL_UNSIGNED_INT32 0x10DC
+#define CL_HALF_FLOAT 0x10DD
+#define CL_FLOAT 0x10DE
+#define CL_UNORM_INT24 0x10DF
+
+/* cl_mem_object_type */
+#define CL_MEM_OBJECT_BUFFER 0x10F0
+#define CL_MEM_OBJECT_IMAGE2D 0x10F1
+#define CL_MEM_OBJECT_IMAGE3D 0x10F2
+#define CL_MEM_OBJECT_IMAGE2D_ARRAY 0x10F3
+#define CL_MEM_OBJECT_IMAGE1D 0x10F4
+#define CL_MEM_OBJECT_IMAGE1D_ARRAY 0x10F5
+#define CL_MEM_OBJECT_IMAGE1D_BUFFER 0x10F6
+
+/* cl_mem_info */
+#define CL_MEM_TYPE 0x1100
+#define CL_MEM_FLAGS 0x1101
+#define CL_MEM_SIZE 0x1102
+#define CL_MEM_HOST_PTR 0x1103
+#define CL_MEM_MAP_COUNT 0x1104
+#define CL_MEM_REFERENCE_COUNT 0x1105
+#define CL_MEM_CONTEXT 0x1106
+#define CL_MEM_ASSOCIATED_MEMOBJECT 0x1107
+#define CL_MEM_OFFSET 0x1108
+
+/* cl_image_info */
+#define CL_IMAGE_FORMAT 0x1110
+#define CL_IMAGE_ELEMENT_SIZE 0x1111
+#define CL_IMAGE_ROW_PITCH 0x1112
+#define CL_IMAGE_SLICE_PITCH 0x1113
+#define CL_IMAGE_WIDTH 0x1114
+#define CL_IMAGE_HEIGHT 0x1115
+#define CL_IMAGE_DEPTH 0x1116
+#define CL_IMAGE_ARRAY_SIZE 0x1117
+#define CL_IMAGE_BUFFER 0x1118
+#define CL_IMAGE_NUM_MIP_LEVELS 0x1119
+#define CL_IMAGE_NUM_SAMPLES 0x111A
+
+/* cl_addressing_mode */
+#define CL_ADDRESS_NONE 0x1130
+#define CL_ADDRESS_CLAMP_TO_EDGE 0x1131
+#define CL_ADDRESS_CLAMP 0x1132
+#define CL_ADDRESS_REPEAT 0x1133
+#define CL_ADDRESS_MIRRORED_REPEAT 0x1134
+
+/* cl_filter_mode */
+#define CL_FILTER_NEAREST 0x1140
+#define CL_FILTER_LINEAR 0x1141
+
+/* cl_sampler_info */
+#define CL_SAMPLER_REFERENCE_COUNT 0x1150
+#define CL_SAMPLER_CONTEXT 0x1151
+#define CL_SAMPLER_NORMALIZED_COORDS 0x1152
+#define CL_SAMPLER_ADDRESSING_MODE 0x1153
+#define CL_SAMPLER_FILTER_MODE 0x1154
+
+/* cl_map_flags - bitfield */
+#define CL_MAP_READ (1 << 0)
+#define CL_MAP_WRITE (1 << 1)
+#define CL_MAP_WRITE_INVALIDATE_REGION (1 << 2)
+
+/* cl_program_info */
+#define CL_PROGRAM_REFERENCE_COUNT 0x1160
+#define CL_PROGRAM_CONTEXT 0x1161
+#define CL_PROGRAM_NUM_DEVICES 0x1162
+#define CL_PROGRAM_DEVICES 0x1163
+#define CL_PROGRAM_SOURCE 0x1164
+#define CL_PROGRAM_BINARY_SIZES 0x1165
+#define CL_PROGRAM_BINARIES 0x1166
+#define CL_PROGRAM_NUM_KERNELS 0x1167
+#define CL_PROGRAM_KERNEL_NAMES 0x1168
+
+/* cl_program_build_info */
+#define CL_PROGRAM_BUILD_STATUS 0x1181
+#define CL_PROGRAM_BUILD_OPTIONS 0x1182
+#define CL_PROGRAM_BUILD_LOG 0x1183
+#define CL_PROGRAM_BINARY_TYPE 0x1184
+
+/* cl_program_binary_type */
+#define CL_PROGRAM_BINARY_TYPE_NONE 0x0
+#define CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT 0x1
+#define CL_PROGRAM_BINARY_TYPE_LIBRARY 0x2
+#define CL_PROGRAM_BINARY_TYPE_EXECUTABLE 0x4
+
+/* cl_build_status */
+#define CL_BUILD_SUCCESS 0
+#define CL_BUILD_NONE -1
+#define CL_BUILD_ERROR -2
+#define CL_BUILD_IN_PROGRESS -3
+
+/* cl_kernel_info */
+#define CL_KERNEL_FUNCTION_NAME 0x1190
+#define CL_KERNEL_NUM_ARGS 0x1191
+#define CL_KERNEL_REFERENCE_COUNT 0x1192
+#define CL_KERNEL_CONTEXT 0x1193
+#define CL_KERNEL_PROGRAM 0x1194
+#define CL_KERNEL_ATTRIBUTES 0x1195
+
+/* cl_kernel_arg_info */
+#define CL_KERNEL_ARG_ADDRESS_QUALIFIER 0x1196
+#define CL_KERNEL_ARG_ACCESS_QUALIFIER 0x1197
+#define CL_KERNEL_ARG_TYPE_NAME 0x1198
+#define CL_KERNEL_ARG_TYPE_QUALIFIER 0x1199
+#define CL_KERNEL_ARG_NAME 0x119A
+
+/* cl_kernel_arg_address_qualifier */
+#define CL_KERNEL_ARG_ADDRESS_GLOBAL 0x119B
+#define CL_KERNEL_ARG_ADDRESS_LOCAL 0x119C
+#define CL_KERNEL_ARG_ADDRESS_CONSTANT 0x119D
+#define CL_KERNEL_ARG_ADDRESS_PRIVATE 0x119E
+
+/* cl_kernel_arg_access_qualifier */
+#define CL_KERNEL_ARG_ACCESS_READ_ONLY 0x11A0
+#define CL_KERNEL_ARG_ACCESS_WRITE_ONLY 0x11A1
+#define CL_KERNEL_ARG_ACCESS_READ_WRITE 0x11A2
+#define CL_KERNEL_ARG_ACCESS_NONE 0x11A3
+
+/* cl_kernel_arg_type_qualifer */
+#define CL_KERNEL_ARG_TYPE_NONE 0
+#define CL_KERNEL_ARG_TYPE_CONST (1 << 0)
+#define CL_KERNEL_ARG_TYPE_RESTRICT (1 << 1)
+#define CL_KERNEL_ARG_TYPE_VOLATILE (1 << 2)
+
+/* cl_kernel_work_group_info */
+#define CL_KERNEL_WORK_GROUP_SIZE 0x11B0
+#define CL_KERNEL_COMPILE_WORK_GROUP_SIZE 0x11B1
+#define CL_KERNEL_LOCAL_MEM_SIZE 0x11B2
+#define CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE 0x11B3
+#define CL_KERNEL_PRIVATE_MEM_SIZE 0x11B4
+#define CL_KERNEL_GLOBAL_WORK_SIZE 0x11B5
+
+/* cl_event_info */
+#define CL_EVENT_COMMAND_QUEUE 0x11D0
+#define CL_EVENT_COMMAND_TYPE 0x11D1
+#define CL_EVENT_REFERENCE_COUNT 0x11D2
+#define CL_EVENT_COMMAND_EXECUTION_STATUS 0x11D3
+#define CL_EVENT_CONTEXT 0x11D4
+
+/* cl_command_type */
+#define CL_COMMAND_NDRANGE_KERNEL 0x11F0
+#define CL_COMMAND_TASK 0x11F1
+#define CL_COMMAND_NATIVE_KERNEL 0x11F2
+#define CL_COMMAND_READ_BUFFER 0x11F3
+#define CL_COMMAND_WRITE_BUFFER 0x11F4
+#define CL_COMMAND_COPY_BUFFER 0x11F5
+#define CL_COMMAND_READ_IMAGE 0x11F6
+#define CL_COMMAND_WRITE_IMAGE 0x11F7
+#define CL_COMMAND_COPY_IMAGE 0x11F8
+#define CL_COMMAND_COPY_IMAGE_TO_BUFFER 0x11F9
+#define CL_COMMAND_COPY_BUFFER_TO_IMAGE 0x11FA
+#define CL_COMMAND_MAP_BUFFER 0x11FB
+#define CL_COMMAND_MAP_IMAGE 0x11FC
+#define CL_COMMAND_UNMAP_MEM_OBJECT 0x11FD
+#define CL_COMMAND_MARKER 0x11FE
+#define CL_COMMAND_ACQUIRE_GL_OBJECTS 0x11FF
+#define CL_COMMAND_RELEASE_GL_OBJECTS 0x1200
+#define CL_COMMAND_READ_BUFFER_RECT 0x1201
+#define CL_COMMAND_WRITE_BUFFER_RECT 0x1202
+#define CL_COMMAND_COPY_BUFFER_RECT 0x1203
+#define CL_COMMAND_USER 0x1204
+#define CL_COMMAND_BARRIER 0x1205
+#define CL_COMMAND_MIGRATE_MEM_OBJECTS 0x1206
+#define CL_COMMAND_FILL_BUFFER 0x1207
+#define CL_COMMAND_FILL_IMAGE 0x1208
+
+/* command execution status */
+#define CL_COMPLETE 0x0
+#define CL_RUNNING 0x1
+#define CL_SUBMITTED 0x2
+#define CL_QUEUED 0x3
+
+/* cl_buffer_create_type */
+#define CL_BUFFER_CREATE_TYPE_REGION 0x1220
+
+/* cl_profiling_info */
+#define CL_PROFILING_COMMAND_QUEUED 0x1280
+#define CL_PROFILING_COMMAND_SUBMIT 0x1281
+#define CL_PROFILING_COMMAND_START 0x1282
+#define CL_PROFILING_COMMAND_END 0x1283
+
+/********************************************************************************************************/
+
+/* Platform API */
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetPlatformIDs(cl_uint /* num_entries */,
+ cl_platform_id * /* platforms */,
+ cl_uint * /* num_platforms */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetPlatformInfo(cl_platform_id /* platform */,
+ cl_platform_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+/* Device APIs */
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetDeviceIDs(cl_platform_id /* platform */,
+ cl_device_type /* device_type */,
+ cl_uint /* num_entries */,
+ cl_device_id * /* devices */,
+ cl_uint * /* num_devices */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetDeviceInfo(cl_device_id /* device */,
+ cl_device_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clCreateSubDevices(cl_device_id /* in_device */,
+ const cl_device_partition_property * /* properties */,
+ cl_uint /* num_devices */,
+ cl_device_id * /* out_devices */,
+ cl_uint * /* num_devices_ret */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainDevice(cl_device_id /* device */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseDevice(cl_device_id /* device */) CL_API_SUFFIX__VERSION_1_2;
+
+/* Context APIs */
+extern CL_API_ENTRY cl_context CL_API_CALL
+clCreateContext(const cl_context_properties * /* properties */,
+ cl_uint /* num_devices */,
+ const cl_device_id * /* devices */,
+ void (CL_CALLBACK * /* pfn_notify */)(const char *, const void *, size_t, void *),
+ void * /* user_data */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_context CL_API_CALL
+clCreateContextFromType(const cl_context_properties * /* properties */,
+ cl_device_type /* device_type */,
+ void (CL_CALLBACK * /* pfn_notify*/ )(const char *, const void *, size_t, void *),
+ void * /* user_data */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainContext(cl_context /* context */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseContext(cl_context /* context */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetContextInfo(cl_context /* context */,
+ cl_context_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+/* Command Queue APIs */
+extern CL_API_ENTRY cl_command_queue CL_API_CALL
+clCreateCommandQueue(cl_context /* context */,
+ cl_device_id /* device */,
+ cl_command_queue_properties /* properties */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainCommandQueue(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseCommandQueue(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetCommandQueueInfo(cl_command_queue /* command_queue */,
+ cl_command_queue_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+/* Memory Object APIs */
+extern CL_API_ENTRY cl_mem CL_API_CALL
+clCreateBuffer(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ size_t /* size */,
+ void * /* host_ptr */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_mem CL_API_CALL
+clCreateSubBuffer(cl_mem /* buffer */,
+ cl_mem_flags /* flags */,
+ cl_buffer_create_type /* buffer_create_type */,
+ const void * /* buffer_create_info */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1;
+
+extern CL_API_ENTRY cl_mem CL_API_CALL
+clCreateImage(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ const cl_image_format * /* image_format */,
+ const cl_image_desc * /* image_desc */,
+ void * /* host_ptr */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainMemObject(cl_mem /* memobj */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseMemObject(cl_mem /* memobj */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetSupportedImageFormats(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ cl_mem_object_type /* image_type */,
+ cl_uint /* num_entries */,
+ cl_image_format * /* image_formats */,
+ cl_uint * /* num_image_formats */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetMemObjectInfo(cl_mem /* memobj */,
+ cl_mem_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetImageInfo(cl_mem /* image */,
+ cl_image_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clSetMemObjectDestructorCallback( cl_mem /* memobj */,
+ void (CL_CALLBACK * /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/),
+ void * /*user_data */ ) CL_API_SUFFIX__VERSION_1_1;
+
+/* Sampler APIs */
+extern CL_API_ENTRY cl_sampler CL_API_CALL
+clCreateSampler(cl_context /* context */,
+ cl_bool /* normalized_coords */,
+ cl_addressing_mode /* addressing_mode */,
+ cl_filter_mode /* filter_mode */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainSampler(cl_sampler /* sampler */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseSampler(cl_sampler /* sampler */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetSamplerInfo(cl_sampler /* sampler */,
+ cl_sampler_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+/* Program Object APIs */
+extern CL_API_ENTRY cl_program CL_API_CALL
+clCreateProgramWithSource(cl_context /* context */,
+ cl_uint /* count */,
+ const char ** /* strings */,
+ const size_t * /* lengths */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_program CL_API_CALL
+clCreateProgramWithBinary(cl_context /* context */,
+ cl_uint /* num_devices */,
+ const cl_device_id * /* device_list */,
+ const size_t * /* lengths */,
+ const unsigned char ** /* binaries */,
+ cl_int * /* binary_status */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_program CL_API_CALL
+clCreateProgramWithBuiltInKernels(cl_context /* context */,
+ cl_uint /* num_devices */,
+ const cl_device_id * /* device_list */,
+ const char * /* kernel_names */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainProgram(cl_program /* program */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseProgram(cl_program /* program */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clBuildProgram(cl_program /* program */,
+ cl_uint /* num_devices */,
+ const cl_device_id * /* device_list */,
+ const char * /* options */,
+ void (CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, void * /* user_data */),
+ void * /* user_data */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clCompileProgram(cl_program /* program */,
+ cl_uint /* num_devices */,
+ const cl_device_id * /* device_list */,
+ const char * /* options */,
+ cl_uint /* num_input_headers */,
+ const cl_program * /* input_headers */,
+ const char ** /* header_include_names */,
+ void (CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, void * /* user_data */),
+ void * /* user_data */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_program CL_API_CALL
+clLinkProgram(cl_context /* context */,
+ cl_uint /* num_devices */,
+ const cl_device_id * /* device_list */,
+ const char * /* options */,
+ cl_uint /* num_input_programs */,
+ const cl_program * /* input_programs */,
+ void (CL_CALLBACK * /* pfn_notify */)(cl_program /* program */, void * /* user_data */),
+ void * /* user_data */,
+ cl_int * /* errcode_ret */ ) CL_API_SUFFIX__VERSION_1_2;
+
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clUnloadPlatformCompiler(cl_platform_id /* platform */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetProgramInfo(cl_program /* program */,
+ cl_program_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetProgramBuildInfo(cl_program /* program */,
+ cl_device_id /* device */,
+ cl_program_build_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+/* Kernel Object APIs */
+extern CL_API_ENTRY cl_kernel CL_API_CALL
+clCreateKernel(cl_program /* program */,
+ const char * /* kernel_name */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clCreateKernelsInProgram(cl_program /* program */,
+ cl_uint /* num_kernels */,
+ cl_kernel * /* kernels */,
+ cl_uint * /* num_kernels_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainKernel(cl_kernel /* kernel */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseKernel(cl_kernel /* kernel */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clSetKernelArg(cl_kernel /* kernel */,
+ cl_uint /* arg_index */,
+ size_t /* arg_size */,
+ const void * /* arg_value */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetKernelInfo(cl_kernel /* kernel */,
+ cl_kernel_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetKernelArgInfo(cl_kernel /* kernel */,
+ cl_uint /* arg_indx */,
+ cl_kernel_arg_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetKernelWorkGroupInfo(cl_kernel /* kernel */,
+ cl_device_id /* device */,
+ cl_kernel_work_group_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+/* Event Object APIs */
+extern CL_API_ENTRY cl_int CL_API_CALL
+clWaitForEvents(cl_uint /* num_events */,
+ const cl_event * /* event_list */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetEventInfo(cl_event /* event */,
+ cl_event_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_event CL_API_CALL
+clCreateUserEvent(cl_context /* context */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_1;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clRetainEvent(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clReleaseEvent(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clSetUserEventStatus(cl_event /* event */,
+ cl_int /* execution_status */) CL_API_SUFFIX__VERSION_1_1;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clSetEventCallback( cl_event /* event */,
+ cl_int /* command_exec_callback_type */,
+ void (CL_CALLBACK * /* pfn_notify */)(cl_event, cl_int, void *),
+ void * /* user_data */) CL_API_SUFFIX__VERSION_1_1;
+
+/* Profiling APIs */
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetEventProfilingInfo(cl_event /* event */,
+ cl_profiling_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+/* Flush and Finish APIs */
+extern CL_API_ENTRY cl_int CL_API_CALL
+clFlush(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clFinish(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
+
+/* Enqueued Commands APIs */
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueReadBuffer(cl_command_queue /* command_queue */,
+ cl_mem /* buffer */,
+ cl_bool /* blocking_read */,
+ size_t /* offset */,
+ size_t /* size */,
+ void * /* ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueReadBufferRect(cl_command_queue /* command_queue */,
+ cl_mem /* buffer */,
+ cl_bool /* blocking_read */,
+ const size_t * /* buffer_offset */,
+ const size_t * /* host_offset */,
+ const size_t * /* region */,
+ size_t /* buffer_row_pitch */,
+ size_t /* buffer_slice_pitch */,
+ size_t /* host_row_pitch */,
+ size_t /* host_slice_pitch */,
+ void * /* ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueWriteBuffer(cl_command_queue /* command_queue */,
+ cl_mem /* buffer */,
+ cl_bool /* blocking_write */,
+ size_t /* offset */,
+ size_t /* size */,
+ const void * /* ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueWriteBufferRect(cl_command_queue /* command_queue */,
+ cl_mem /* buffer */,
+ cl_bool /* blocking_write */,
+ const size_t * /* buffer_offset */,
+ const size_t * /* host_offset */,
+ const size_t * /* region */,
+ size_t /* buffer_row_pitch */,
+ size_t /* buffer_slice_pitch */,
+ size_t /* host_row_pitch */,
+ size_t /* host_slice_pitch */,
+ const void * /* ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueFillBuffer(cl_command_queue /* command_queue */,
+ cl_mem /* buffer */,
+ const void * /* pattern */,
+ size_t /* pattern_size */,
+ size_t /* offset */,
+ size_t /* size */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueCopyBuffer(cl_command_queue /* command_queue */,
+ cl_mem /* src_buffer */,
+ cl_mem /* dst_buffer */,
+ size_t /* src_offset */,
+ size_t /* dst_offset */,
+ size_t /* size */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueCopyBufferRect(cl_command_queue /* command_queue */,
+ cl_mem /* src_buffer */,
+ cl_mem /* dst_buffer */,
+ const size_t * /* src_origin */,
+ const size_t * /* dst_origin */,
+ const size_t * /* region */,
+ size_t /* src_row_pitch */,
+ size_t /* src_slice_pitch */,
+ size_t /* dst_row_pitch */,
+ size_t /* dst_slice_pitch */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_1;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueReadImage(cl_command_queue /* command_queue */,
+ cl_mem /* image */,
+ cl_bool /* blocking_read */,
+ const size_t * /* origin[3] */,
+ const size_t * /* region[3] */,
+ size_t /* row_pitch */,
+ size_t /* slice_pitch */,
+ void * /* ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueWriteImage(cl_command_queue /* command_queue */,
+ cl_mem /* image */,
+ cl_bool /* blocking_write */,
+ const size_t * /* origin[3] */,
+ const size_t * /* region[3] */,
+ size_t /* input_row_pitch */,
+ size_t /* input_slice_pitch */,
+ const void * /* ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueFillImage(cl_command_queue /* command_queue */,
+ cl_mem /* image */,
+ const void * /* fill_color */,
+ const size_t * /* origin[3] */,
+ const size_t * /* region[3] */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueCopyImage(cl_command_queue /* command_queue */,
+ cl_mem /* src_image */,
+ cl_mem /* dst_image */,
+ const size_t * /* src_origin[3] */,
+ const size_t * /* dst_origin[3] */,
+ const size_t * /* region[3] */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueCopyImageToBuffer(cl_command_queue /* command_queue */,
+ cl_mem /* src_image */,
+ cl_mem /* dst_buffer */,
+ const size_t * /* src_origin[3] */,
+ const size_t * /* region[3] */,
+ size_t /* dst_offset */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueCopyBufferToImage(cl_command_queue /* command_queue */,
+ cl_mem /* src_buffer */,
+ cl_mem /* dst_image */,
+ size_t /* src_offset */,
+ const size_t * /* dst_origin[3] */,
+ const size_t * /* region[3] */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY void * CL_API_CALL
+clEnqueueMapBuffer(cl_command_queue /* command_queue */,
+ cl_mem /* buffer */,
+ cl_bool /* blocking_map */,
+ cl_map_flags /* map_flags */,
+ size_t /* offset */,
+ size_t /* size */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY void * CL_API_CALL
+clEnqueueMapImage(cl_command_queue /* command_queue */,
+ cl_mem /* image */,
+ cl_bool /* blocking_map */,
+ cl_map_flags /* map_flags */,
+ const size_t * /* origin[3] */,
+ const size_t * /* region[3] */,
+ size_t * /* image_row_pitch */,
+ size_t * /* image_slice_pitch */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueUnmapMemObject(cl_command_queue /* command_queue */,
+ cl_mem /* memobj */,
+ void * /* mapped_ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueMigrateMemObjects(cl_command_queue /* command_queue */,
+ cl_uint /* num_mem_objects */,
+ const cl_mem * /* mem_objects */,
+ cl_mem_migration_flags /* flags */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueNDRangeKernel(cl_command_queue /* command_queue */,
+ cl_kernel /* kernel */,
+ cl_uint /* work_dim */,
+ const size_t * /* global_work_offset */,
+ const size_t * /* global_work_size */,
+ const size_t * /* local_work_size */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueTask(cl_command_queue /* command_queue */,
+ cl_kernel /* kernel */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueNativeKernel(cl_command_queue /* command_queue */,
+ void (CL_CALLBACK * /*user_func*/)(void *),
+ void * /* args */,
+ size_t /* cb_args */,
+ cl_uint /* num_mem_objects */,
+ const cl_mem * /* mem_list */,
+ const void ** /* args_mem_loc */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueMarkerWithWaitList(cl_command_queue /* command_queue */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueBarrierWithWaitList(cl_command_queue /* command_queue */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_2;
+
+
+/* Extension function access
+ *
+ * Returns the extension function address for the given function name,
+ * or NULL if a valid function can not be found. The client must
+ * check to make sure the address is not NULL, before using or
+ * calling the returned function address.
+ */
+extern CL_API_ENTRY void * CL_API_CALL
+clGetExtensionFunctionAddressForPlatform(cl_platform_id /* platform */,
+ const char * /* func_name */) CL_API_SUFFIX__VERSION_1_2;
+
+
+/* Deprecated OpenCL 1.1 APIs */
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL
+clCreateImage2D(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ const cl_image_format * /* image_format */,
+ size_t /* image_width */,
+ size_t /* image_height */,
+ size_t /* image_row_pitch */,
+ void * /* host_ptr */,
+ cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
+
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL
+clCreateImage3D(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ const cl_image_format * /* image_format */,
+ size_t /* image_width */,
+ size_t /* image_height */,
+ size_t /* image_depth */,
+ size_t /* image_row_pitch */,
+ size_t /* image_slice_pitch */,
+ void * /* host_ptr */,
+ cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
+
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL
+clEnqueueMarker(cl_command_queue /* command_queue */,
+ cl_event * /* event */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
+
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL
+clEnqueueWaitForEvents(cl_command_queue /* command_queue */,
+ cl_uint /* num_events */,
+ const cl_event * /* event_list */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
+
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL
+clEnqueueBarrier(cl_command_queue /* command_queue */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
+
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int CL_API_CALL
+clUnloadCompiler(void) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
+
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED void * CL_API_CALL
+clGetExtensionFunctionAddress(const char * /* func_name */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OPENCL_CL_H */
+
diff --git a/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/cl_ext.h b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/cl_ext.h
new file mode 100644
index 000000000..a998c9c51
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/cl_ext.h
@@ -0,0 +1,315 @@
+/*******************************************************************************
+ * Copyright (c) 2008-2013 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ ******************************************************************************/
+
+/* $Revision: 11928 $ on $Date: 2010-07-13 09:04:56 -0700 (Tue, 13 Jul 2010) $ */
+
+/* cl_ext.h contains OpenCL extensions which don't have external */
+/* (OpenGL, D3D) dependencies. */
+
+#ifndef __CL_EXT_H
+#define __CL_EXT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __APPLE__
+#include <AvailabilityMacros.h>
+#endif
+
+#include <cl.h>
+
+/* cl_khr_fp16 extension - no extension #define since it has no functions */
+#define CL_DEVICE_HALF_FP_CONFIG 0x1033
+
+/* Memory object destruction
+ *
+ * Apple extension for use to manage externally allocated buffers used with cl_mem objects with CL_MEM_USE_HOST_PTR
+ *
+ * Registers a user callback function that will be called when the memory object is deleted and its resources
+ * freed. Each call to clSetMemObjectCallbackFn registers the specified user callback function on a callback
+ * stack associated with memobj. The registered user callback functions are called in the reverse order in
+ * which they were registered. The user callback functions are called and then the memory object is deleted
+ * and its resources freed. This provides a mechanism for the application (and libraries) using memobj to be
+ * notified when the memory referenced by host_ptr, specified when the memory object is created and used as
+ * the storage bits for the memory object, can be reused or freed.
+ *
+ * The application may not call CL api's with the cl_mem object passed to the pfn_notify.
+ *
+ * Please check for the "cl_APPLE_SetMemObjectDestructor" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS)
+ * before using.
+ */
+#define cl_APPLE_SetMemObjectDestructor 1
+cl_int CL_API_ENTRY clSetMemObjectDestructorAPPLE( cl_mem /* memobj */,
+ void (* /*pfn_notify*/)( cl_mem /* memobj */, void* /*user_data*/),
+ void * /*user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
+
+
+/* Context Logging Functions
+ *
+ * The next three convenience functions are intended to be used as the pfn_notify parameter to clCreateContext().
+ * Please check for the "cl_APPLE_ContextLoggingFunctions" extension using clGetDeviceInfo(CL_DEVICE_EXTENSIONS)
+ * before using.
+ *
+ * clLogMessagesToSystemLog fowards on all log messages to the Apple System Logger
+ */
+#define cl_APPLE_ContextLoggingFunctions 1
+extern void CL_API_ENTRY clLogMessagesToSystemLogAPPLE( const char * /* errstr */,
+ const void * /* private_info */,
+ size_t /* cb */,
+ void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
+
+/* clLogMessagesToStdout sends all log messages to the file descriptor stdout */
+extern void CL_API_ENTRY clLogMessagesToStdoutAPPLE( const char * /* errstr */,
+ const void * /* private_info */,
+ size_t /* cb */,
+ void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
+
+/* clLogMessagesToStderr sends all log messages to the file descriptor stderr */
+extern void CL_API_ENTRY clLogMessagesToStderrAPPLE( const char * /* errstr */,
+ const void * /* private_info */,
+ size_t /* cb */,
+ void * /* user_data */ ) CL_EXT_SUFFIX__VERSION_1_0;
+
+
+/************************
+* cl_khr_icd extension *
+************************/
+#define cl_khr_icd 1
+
+/* cl_platform_info */
+#define CL_PLATFORM_ICD_SUFFIX_KHR 0x0920
+
+/* Additional Error Codes */
+#define CL_PLATFORM_NOT_FOUND_KHR -1001
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clIcdGetPlatformIDsKHR(cl_uint /* num_entries */,
+ cl_platform_id * /* platforms */,
+ cl_uint * /* num_platforms */);
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *clIcdGetPlatformIDsKHR_fn)(
+ cl_uint /* num_entries */,
+ cl_platform_id * /* platforms */,
+ cl_uint * /* num_platforms */);
+
+
+/* Extension: cl_khr_image2D_buffer
+ *
+ * This extension allows a 2D image to be created from a cl_mem buffer without a copy.
+ * The type associated with a 2D image created from a buffer in an OpenCL program is image2d_t.
+ * Both the sampler and sampler-less read_image built-in functions are supported for 2D images
+ * and 2D images created from a buffer. Similarly, the write_image built-ins are also supported
+ * for 2D images created from a buffer.
+ *
+ * When the 2D image from buffer is created, the client must specify the width,
+ * height, image format (i.e. channel order and channel data type) and optionally the row pitch
+ *
+ * The pitch specified must be a multiple of CL_DEVICE_IMAGE_PITCH_ALIGNMENT pixels.
+ * The base address of the buffer must be aligned to CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT pixels.
+ */
+
+/*************************************
+ * cl_khr_initalize_memory extension *
+ *************************************/
+
+#define CL_CONTEXT_MEMORY_INITIALIZE_KHR 0x200E
+
+
+/**************************************
+ * cl_khr_terminate_context extension *
+ **************************************/
+
+#define CL_DEVICE_TERMINATE_CAPABILITY_KHR 0x200F
+#define CL_CONTEXT_TERMINATE_KHR 0x2010
+
+#define cl_khr_terminate_context 1
+extern CL_API_ENTRY cl_int CL_API_CALL clTerminateContextKHR(cl_context /* context */) CL_EXT_SUFFIX__VERSION_1_2;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *clTerminateContextKHR_fn)(cl_context /* context */) CL_EXT_SUFFIX__VERSION_1_2;
+
+
+/*
+ * Extension: cl_khr_spir
+ *
+ * This extension adds support to create an OpenCL program object from a
+ * Standard Portable Intermediate Representation (SPIR) instance
+ */
+
+#define CL_DEVICE_SPIR_VERSIONS 0x40E0
+#define CL_PROGRAM_BINARY_TYPE_INTERMEDIATE 0x40E1
+
+
+/******************************************
+* cl_nv_device_attribute_query extension *
+******************************************/
+/* cl_nv_device_attribute_query extension - no extension #define since it has no functions */
+#define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000
+#define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001
+#define CL_DEVICE_REGISTERS_PER_BLOCK_NV 0x4002
+#define CL_DEVICE_WARP_SIZE_NV 0x4003
+#define CL_DEVICE_GPU_OVERLAP_NV 0x4004
+#define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005
+#define CL_DEVICE_INTEGRATED_MEMORY_NV 0x4006
+
+/*********************************
+* cl_amd_device_attribute_query *
+*********************************/
+#define CL_DEVICE_PROFILING_TIMER_OFFSET_AMD 0x4036
+
+/*********************************
+* cl_arm_printf extension
+*********************************/
+#define CL_PRINTF_CALLBACK_ARM 0x40B0
+#define CL_PRINTF_BUFFERSIZE_ARM 0x40B1
+
+#ifdef CL_VERSION_1_1
+ /***********************************
+ * cl_ext_device_fission extension *
+ ***********************************/
+ #define cl_ext_device_fission 1
+
+ extern CL_API_ENTRY cl_int CL_API_CALL
+ clReleaseDeviceEXT( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
+
+ typedef CL_API_ENTRY cl_int
+ (CL_API_CALL *clReleaseDeviceEXT_fn)( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
+
+ extern CL_API_ENTRY cl_int CL_API_CALL
+ clRetainDeviceEXT( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
+
+ typedef CL_API_ENTRY cl_int
+ (CL_API_CALL *clRetainDeviceEXT_fn)( cl_device_id /*device*/ ) CL_EXT_SUFFIX__VERSION_1_1;
+
+ typedef cl_ulong cl_device_partition_property_ext;
+ extern CL_API_ENTRY cl_int CL_API_CALL
+ clCreateSubDevicesEXT( cl_device_id /*in_device*/,
+ const cl_device_partition_property_ext * /* properties */,
+ cl_uint /*num_entries*/,
+ cl_device_id * /*out_devices*/,
+ cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
+
+ typedef CL_API_ENTRY cl_int
+ ( CL_API_CALL * clCreateSubDevicesEXT_fn)( cl_device_id /*in_device*/,
+ const cl_device_partition_property_ext * /* properties */,
+ cl_uint /*num_entries*/,
+ cl_device_id * /*out_devices*/,
+ cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1;
+
+ /* cl_device_partition_property_ext */
+ #define CL_DEVICE_PARTITION_EQUALLY_EXT 0x4050
+ #define CL_DEVICE_PARTITION_BY_COUNTS_EXT 0x4051
+ #define CL_DEVICE_PARTITION_BY_NAMES_EXT 0x4052
+ #define CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN_EXT 0x4053
+
+ /* clDeviceGetInfo selectors */
+ #define CL_DEVICE_PARENT_DEVICE_EXT 0x4054
+ #define CL_DEVICE_PARTITION_TYPES_EXT 0x4055
+ #define CL_DEVICE_AFFINITY_DOMAINS_EXT 0x4056
+ #define CL_DEVICE_REFERENCE_COUNT_EXT 0x4057
+ #define CL_DEVICE_PARTITION_STYLE_EXT 0x4058
+
+ /* error codes */
+ #define CL_DEVICE_PARTITION_FAILED_EXT -1057
+ #define CL_INVALID_PARTITION_COUNT_EXT -1058
+ #define CL_INVALID_PARTITION_NAME_EXT -1059
+
+ /* CL_AFFINITY_DOMAINs */
+ #define CL_AFFINITY_DOMAIN_L1_CACHE_EXT 0x1
+ #define CL_AFFINITY_DOMAIN_L2_CACHE_EXT 0x2
+ #define CL_AFFINITY_DOMAIN_L3_CACHE_EXT 0x3
+ #define CL_AFFINITY_DOMAIN_L4_CACHE_EXT 0x4
+ #define CL_AFFINITY_DOMAIN_NUMA_EXT 0x10
+ #define CL_AFFINITY_DOMAIN_NEXT_FISSIONABLE_EXT 0x100
+
+ /* cl_device_partition_property_ext list terminators */
+ #define CL_PROPERTIES_LIST_END_EXT ((cl_device_partition_property_ext) 0)
+ #define CL_PARTITION_BY_COUNTS_LIST_END_EXT ((cl_device_partition_property_ext) 0)
+ #define CL_PARTITION_BY_NAMES_LIST_END_EXT ((cl_device_partition_property_ext) 0 - 1)
+
+/*********************************
+* cl_qcom_ext_host_ptr extension
+*********************************/
+
+#define CL_MEM_EXT_HOST_PTR_QCOM (1 << 29)
+
+#define CL_DEVICE_EXT_MEM_PADDING_IN_BYTES_QCOM 0x40A0
+#define CL_DEVICE_PAGE_SIZE_QCOM 0x40A1
+#define CL_IMAGE_ROW_ALIGNMENT_QCOM 0x40A2
+#define CL_IMAGE_SLICE_ALIGNMENT_QCOM 0x40A3
+#define CL_MEM_HOST_UNCACHED_QCOM 0x40A4
+#define CL_MEM_HOST_WRITEBACK_QCOM 0x40A5
+#define CL_MEM_HOST_WRITETHROUGH_QCOM 0x40A6
+#define CL_MEM_HOST_WRITE_COMBINING_QCOM 0x40A7
+
+typedef cl_uint cl_image_pitch_info_qcom;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetDeviceImageInfoQCOM(cl_device_id device,
+ size_t image_width,
+ size_t image_height,
+ const cl_image_format *image_format,
+ cl_image_pitch_info_qcom param_name,
+ size_t param_value_size,
+ void *param_value,
+ size_t *param_value_size_ret);
+
+typedef struct _cl_mem_ext_host_ptr
+{
+ /* Type of external memory allocation. */
+ /* Legal values will be defined in layered extensions. */
+ cl_uint allocation_type;
+
+ /* Host cache policy for this external memory allocation. */
+ cl_uint host_cache_policy;
+
+} cl_mem_ext_host_ptr;
+
+/*********************************
+* cl_qcom_ion_host_ptr extension
+*********************************/
+
+#define CL_MEM_ION_HOST_PTR_QCOM 0x40A8
+
+typedef struct _cl_mem_ion_host_ptr
+{
+ /* Type of external memory allocation. */
+ /* Must be CL_MEM_ION_HOST_PTR_QCOM for ION allocations. */
+ cl_mem_ext_host_ptr ext_host_ptr;
+
+ /* ION file descriptor */
+ int ion_filedesc;
+
+ /* Host pointer to the ION allocated memory */
+ void* ion_hostptr;
+
+} cl_mem_ion_host_ptr;
+
+#endif /* CL_VERSION_1_1 */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __CL_EXT_H */
diff --git a/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/cl_gl.h b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/cl_gl.h
new file mode 100644
index 000000000..ad914cbd4
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/cl_gl.h
@@ -0,0 +1,158 @@
+/**********************************************************************************
+ * Copyright (c) 2008 - 2012 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ **********************************************************************************/
+
+#ifndef __OPENCL_CL_GL_H
+#define __OPENCL_CL_GL_H
+
+#include <cl.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef cl_uint cl_gl_object_type;
+typedef cl_uint cl_gl_texture_info;
+typedef cl_uint cl_gl_platform_info;
+typedef struct __GLsync *cl_GLsync;
+
+/* cl_gl_object_type = 0x2000 - 0x200F enum values are currently taken */
+#define CL_GL_OBJECT_BUFFER 0x2000
+#define CL_GL_OBJECT_TEXTURE2D 0x2001
+#define CL_GL_OBJECT_TEXTURE3D 0x2002
+#define CL_GL_OBJECT_RENDERBUFFER 0x2003
+#define CL_GL_OBJECT_TEXTURE2D_ARRAY 0x200E
+#define CL_GL_OBJECT_TEXTURE1D 0x200F
+#define CL_GL_OBJECT_TEXTURE1D_ARRAY 0x2010
+#define CL_GL_OBJECT_TEXTURE_BUFFER 0x2011
+
+/* cl_gl_texture_info */
+#define CL_GL_TEXTURE_TARGET 0x2004
+#define CL_GL_MIPMAP_LEVEL 0x2005
+#define CL_GL_NUM_SAMPLES 0x2012
+
+
+extern CL_API_ENTRY cl_mem CL_API_CALL
+clCreateFromGLBuffer(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ cl_GLuint /* bufobj */,
+ int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_mem CL_API_CALL
+clCreateFromGLTexture(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ cl_GLenum /* target */,
+ cl_GLint /* miplevel */,
+ cl_GLuint /* texture */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_2;
+
+extern CL_API_ENTRY cl_mem CL_API_CALL
+clCreateFromGLRenderbuffer(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ cl_GLuint /* renderbuffer */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetGLObjectInfo(cl_mem /* memobj */,
+ cl_gl_object_type * /* gl_object_type */,
+ cl_GLuint * /* gl_object_name */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetGLTextureInfo(cl_mem /* memobj */,
+ cl_gl_texture_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueAcquireGLObjects(cl_command_queue /* command_queue */,
+ cl_uint /* num_objects */,
+ const cl_mem * /* mem_objects */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clEnqueueReleaseGLObjects(cl_command_queue /* command_queue */,
+ cl_uint /* num_objects */,
+ const cl_mem * /* mem_objects */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+
+/* Deprecated OpenCL 1.1 APIs */
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL
+clCreateFromGLTexture2D(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ cl_GLenum /* target */,
+ cl_GLint /* miplevel */,
+ cl_GLuint /* texture */,
+ cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
+
+extern CL_API_ENTRY CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_mem CL_API_CALL
+clCreateFromGLTexture3D(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ cl_GLenum /* target */,
+ cl_GLint /* miplevel */,
+ cl_GLuint /* texture */,
+ cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED;
+
+/* cl_khr_gl_sharing extension */
+
+#define cl_khr_gl_sharing 1
+
+typedef cl_uint cl_gl_context_info;
+
+/* Additional Error Codes */
+#define CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR -1000
+
+/* cl_gl_context_info */
+#define CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR 0x2006
+#define CL_DEVICES_FOR_GL_CONTEXT_KHR 0x2007
+
+/* Additional cl_context_properties */
+#define CL_GL_CONTEXT_KHR 0x2008
+#define CL_EGL_DISPLAY_KHR 0x2009
+#define CL_GLX_DISPLAY_KHR 0x200A
+#define CL_WGL_HDC_KHR 0x200B
+#define CL_CGL_SHAREGROUP_KHR 0x200C
+
+extern CL_API_ENTRY cl_int CL_API_CALL
+clGetGLContextInfoKHR(const cl_context_properties * /* properties */,
+ cl_gl_context_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetGLContextInfoKHR_fn)(
+ const cl_context_properties * properties,
+ cl_gl_context_info param_name,
+ size_t param_value_size,
+ void * param_value,
+ size_t * param_value_size_ret);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OPENCL_CL_GL_H */
diff --git a/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/cl_gl_ext.h b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/cl_gl_ext.h
new file mode 100644
index 000000000..0c10fedfa
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/cl_gl_ext.h
@@ -0,0 +1,65 @@
+/**********************************************************************************
+ * Copyright (c) 2008-2012 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ **********************************************************************************/
+
+/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */
+
+/* cl_gl_ext.h contains vendor (non-KHR) OpenCL extensions which have */
+/* OpenGL dependencies. */
+
+#ifndef __OPENCL_CL_GL_EXT_H
+#define __OPENCL_CL_GL_EXT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <cl_gl.h>
+
+/*
+ * For each extension, follow this template
+ * cl_VEN_extname extension */
+/* #define cl_VEN_extname 1
+ * ... define new types, if any
+ * ... define new tokens, if any
+ * ... define new APIs, if any
+ *
+ * If you need GLtypes here, mirror them with a cl_GLtype, rather than including a GL header
+ * This allows us to avoid having to decide whether to include GL headers or GLES here.
+ */
+
+/*
+ * cl_khr_gl_event extension
+ * See section 9.9 in the OpenCL 1.1 spec for more information
+ */
+#define CL_COMMAND_GL_FENCE_SYNC_OBJECT_KHR 0x200D
+
+extern CL_API_ENTRY cl_event CL_API_CALL
+clCreateEventFromGLsyncKHR(cl_context /* context */,
+ cl_GLsync /* cl_GLsync */,
+ cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OPENCL_CL_GL_EXT_H */
diff --git a/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/cl_platform.h b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/cl_platform.h
new file mode 100644
index 000000000..7f6f5e8a7
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/cl_platform.h
@@ -0,0 +1,1278 @@
+/**********************************************************************************
+ * Copyright (c) 2008-2012 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ **********************************************************************************/
+
+/* $Revision: 11803 $ on $Date: 2010-06-25 10:02:12 -0700 (Fri, 25 Jun 2010) $ */
+
+#ifndef __CL_PLATFORM_H
+#define __CL_PLATFORM_H
+
+#ifdef __APPLE__
+ /* Contains #defines for AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER below */
+ #include <AvailabilityMacros.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(_WIN32)
+ #define CL_API_ENTRY
+ #define CL_API_CALL __stdcall
+ #define CL_CALLBACK __stdcall
+#else
+ #define CL_API_ENTRY
+ #define CL_API_CALL
+ #define CL_CALLBACK
+#endif
+
+#ifdef __APPLE__
+ #define CL_EXTENSION_WEAK_LINK __attribute__((weak_import))
+ #define CL_API_SUFFIX__VERSION_1_0 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
+ #define CL_EXT_SUFFIX__VERSION_1_0 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
+ #define CL_API_SUFFIX__VERSION_1_1 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
+ #define GCL_API_SUFFIX__VERSION_1_1 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
+ #define CL_EXT_SUFFIX__VERSION_1_1 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
+ #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7
+
+ #ifdef AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
+ #define CL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
+ #define GCL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
+ #define CL_EXT_SUFFIX__VERSION_1_2 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
+ #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
+ #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8
+ #else
+ #warning This path should never happen outside of internal operating system development. AvailabilityMacros do not function correctly here!
+ #define CL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
+ #define GCL_API_SUFFIX__VERSION_1_2 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
+ #define CL_EXT_SUFFIX__VERSION_1_2 CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
+ #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
+ #endif
+#else
+ #define CL_EXTENSION_WEAK_LINK
+ #define CL_API_SUFFIX__VERSION_1_0
+ #define CL_EXT_SUFFIX__VERSION_1_0
+ #define CL_API_SUFFIX__VERSION_1_1
+ #define CL_EXT_SUFFIX__VERSION_1_1
+ #define CL_API_SUFFIX__VERSION_1_2
+ #define CL_EXT_SUFFIX__VERSION_1_2
+
+ #ifdef __GNUC__
+ #ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS
+ #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
+ #else
+ #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED __attribute__((deprecated))
+ #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
+ #endif
+
+ #ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS
+ #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
+ #else
+ #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED __attribute__((deprecated))
+ #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
+ #endif
+ #elif _WIN32
+ #ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS
+ #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
+ #else
+ #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED __declspec(deprecated)
+ #endif
+
+ #ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS
+ #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
+ #else
+ #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED __declspec(deprecated)
+ #endif
+ #else
+ #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
+
+ #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
+ #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
+ #endif
+#endif
+
+#if (defined (_WIN32) && defined(_MSC_VER))
+
+/* scalar types */
+typedef signed __int8 cl_char;
+typedef unsigned __int8 cl_uchar;
+typedef signed __int16 cl_short;
+typedef unsigned __int16 cl_ushort;
+typedef signed __int32 cl_int;
+typedef unsigned __int32 cl_uint;
+typedef signed __int64 cl_long;
+typedef unsigned __int64 cl_ulong;
+
+typedef unsigned __int16 cl_half;
+typedef float cl_float;
+typedef double cl_double;
+
+/* Macro names and corresponding values defined by OpenCL */
+#define CL_CHAR_BIT 8
+#define CL_SCHAR_MAX 127
+#define CL_SCHAR_MIN (-127-1)
+#define CL_CHAR_MAX CL_SCHAR_MAX
+#define CL_CHAR_MIN CL_SCHAR_MIN
+#define CL_UCHAR_MAX 255
+#define CL_SHRT_MAX 32767
+#define CL_SHRT_MIN (-32767-1)
+#define CL_USHRT_MAX 65535
+#define CL_INT_MAX 2147483647
+#define CL_INT_MIN (-2147483647-1)
+#define CL_UINT_MAX 0xffffffffU
+#define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL)
+#define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL)
+#define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL)
+
+#define CL_FLT_DIG 6
+#define CL_FLT_MANT_DIG 24
+#define CL_FLT_MAX_10_EXP +38
+#define CL_FLT_MAX_EXP +128
+#define CL_FLT_MIN_10_EXP -37
+#define CL_FLT_MIN_EXP -125
+#define CL_FLT_RADIX 2
+#define CL_FLT_MAX 340282346638528859811704183484516925440.0f
+#define CL_FLT_MIN 1.175494350822287507969e-38f
+#define CL_FLT_EPSILON 0x1.0p-23f
+
+#define CL_DBL_DIG 15
+#define CL_DBL_MANT_DIG 53
+#define CL_DBL_MAX_10_EXP +308
+#define CL_DBL_MAX_EXP +1024
+#define CL_DBL_MIN_10_EXP -307
+#define CL_DBL_MIN_EXP -1021
+#define CL_DBL_RADIX 2
+#define CL_DBL_MAX 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0
+#define CL_DBL_MIN 2.225073858507201383090e-308
+#define CL_DBL_EPSILON 2.220446049250313080847e-16
+
+#define CL_M_E 2.718281828459045090796
+#define CL_M_LOG2E 1.442695040888963387005
+#define CL_M_LOG10E 0.434294481903251816668
+#define CL_M_LN2 0.693147180559945286227
+#define CL_M_LN10 2.302585092994045901094
+#define CL_M_PI 3.141592653589793115998
+#define CL_M_PI_2 1.570796326794896557999
+#define CL_M_PI_4 0.785398163397448278999
+#define CL_M_1_PI 0.318309886183790691216
+#define CL_M_2_PI 0.636619772367581382433
+#define CL_M_2_SQRTPI 1.128379167095512558561
+#define CL_M_SQRT2 1.414213562373095145475
+#define CL_M_SQRT1_2 0.707106781186547572737
+
+#define CL_M_E_F 2.71828174591064f
+#define CL_M_LOG2E_F 1.44269502162933f
+#define CL_M_LOG10E_F 0.43429449200630f
+#define CL_M_LN2_F 0.69314718246460f
+#define CL_M_LN10_F 2.30258512496948f
+#define CL_M_PI_F 3.14159274101257f
+#define CL_M_PI_2_F 1.57079637050629f
+#define CL_M_PI_4_F 0.78539818525314f
+#define CL_M_1_PI_F 0.31830987334251f
+#define CL_M_2_PI_F 0.63661974668503f
+#define CL_M_2_SQRTPI_F 1.12837922573090f
+#define CL_M_SQRT2_F 1.41421353816986f
+#define CL_M_SQRT1_2_F 0.70710676908493f
+
+#define CL_NAN (CL_INFINITY - CL_INFINITY)
+#define CL_HUGE_VALF ((cl_float) 1e50)
+#define CL_HUGE_VAL ((cl_double) 1e500)
+#define CL_MAXFLOAT CL_FLT_MAX
+#define CL_INFINITY CL_HUGE_VALF
+
+#else
+
+#include <stdint.h>
+
+/* scalar types */
+typedef int8_t cl_char;
+typedef uint8_t cl_uchar;
+typedef int16_t cl_short __attribute__((aligned(2)));
+typedef uint16_t cl_ushort __attribute__((aligned(2)));
+typedef int32_t cl_int __attribute__((aligned(4)));
+typedef uint32_t cl_uint __attribute__((aligned(4)));
+typedef int64_t cl_long __attribute__((aligned(8)));
+typedef uint64_t cl_ulong __attribute__((aligned(8)));
+
+typedef uint16_t cl_half __attribute__((aligned(2)));
+typedef float cl_float __attribute__((aligned(4)));
+typedef double cl_double __attribute__((aligned(8)));
+
+/* Macro names and corresponding values defined by OpenCL */
+#define CL_CHAR_BIT 8
+#define CL_SCHAR_MAX 127
+#define CL_SCHAR_MIN (-127-1)
+#define CL_CHAR_MAX CL_SCHAR_MAX
+#define CL_CHAR_MIN CL_SCHAR_MIN
+#define CL_UCHAR_MAX 255
+#define CL_SHRT_MAX 32767
+#define CL_SHRT_MIN (-32767-1)
+#define CL_USHRT_MAX 65535
+#define CL_INT_MAX 2147483647
+#define CL_INT_MIN (-2147483647-1)
+#define CL_UINT_MAX 0xffffffffU
+#define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL)
+#define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL)
+#define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL)
+
+#define CL_FLT_DIG 6
+#define CL_FLT_MANT_DIG 24
+#define CL_FLT_MAX_10_EXP +38
+#define CL_FLT_MAX_EXP +128
+#define CL_FLT_MIN_10_EXP -37
+#define CL_FLT_MIN_EXP -125
+#define CL_FLT_RADIX 2
+#define CL_FLT_MAX 0x1.fffffep127f
+#define CL_FLT_MIN 0x1.0p-126f
+#define CL_FLT_EPSILON 0x1.0p-23f
+
+#define CL_DBL_DIG 15
+#define CL_DBL_MANT_DIG 53
+#define CL_DBL_MAX_10_EXP +308
+#define CL_DBL_MAX_EXP +1024
+#define CL_DBL_MIN_10_EXP -307
+#define CL_DBL_MIN_EXP -1021
+#define CL_DBL_RADIX 2
+#define CL_DBL_MAX 0x1.fffffffffffffp1023
+#define CL_DBL_MIN 0x1.0p-1022
+#define CL_DBL_EPSILON 0x1.0p-52
+
+#define CL_M_E 2.718281828459045090796
+#define CL_M_LOG2E 1.442695040888963387005
+#define CL_M_LOG10E 0.434294481903251816668
+#define CL_M_LN2 0.693147180559945286227
+#define CL_M_LN10 2.302585092994045901094
+#define CL_M_PI 3.141592653589793115998
+#define CL_M_PI_2 1.570796326794896557999
+#define CL_M_PI_4 0.785398163397448278999
+#define CL_M_1_PI 0.318309886183790691216
+#define CL_M_2_PI 0.636619772367581382433
+#define CL_M_2_SQRTPI 1.128379167095512558561
+#define CL_M_SQRT2 1.414213562373095145475
+#define CL_M_SQRT1_2 0.707106781186547572737
+
+#define CL_M_E_F 2.71828174591064f
+#define CL_M_LOG2E_F 1.44269502162933f
+#define CL_M_LOG10E_F 0.43429449200630f
+#define CL_M_LN2_F 0.69314718246460f
+#define CL_M_LN10_F 2.30258512496948f
+#define CL_M_PI_F 3.14159274101257f
+#define CL_M_PI_2_F 1.57079637050629f
+#define CL_M_PI_4_F 0.78539818525314f
+#define CL_M_1_PI_F 0.31830987334251f
+#define CL_M_2_PI_F 0.63661974668503f
+#define CL_M_2_SQRTPI_F 1.12837922573090f
+#define CL_M_SQRT2_F 1.41421353816986f
+#define CL_M_SQRT1_2_F 0.70710676908493f
+
+#if defined( __GNUC__ )
+ #define CL_HUGE_VALF __builtin_huge_valf()
+ #define CL_HUGE_VAL __builtin_huge_val()
+ #define CL_NAN __builtin_nanf( "" )
+#else
+ #define CL_HUGE_VALF ((cl_float) 1e50)
+ #define CL_HUGE_VAL ((cl_double) 1e500)
+ float nanf( const char * );
+ #define CL_NAN nanf( "" )
+#endif
+#define CL_MAXFLOAT CL_FLT_MAX
+#define CL_INFINITY CL_HUGE_VALF
+
+#endif
+
+#include <stddef.h>
+
+/* Mirror types to GL types. Mirror types allow us to avoid deciding which 87s to load based on whether we are using GL or GLES here. */
+typedef unsigned int cl_GLuint;
+typedef int cl_GLint;
+typedef unsigned int cl_GLenum;
+
+/*
+ * Vector types
+ *
+ * Note: OpenCL requires that all types be naturally aligned.
+ * This means that vector types must be naturally aligned.
+ * For example, a vector of four floats must be aligned to
+ * a 16 byte boundary (calculated as 4 * the natural 4-byte
+ * alignment of the float). The alignment qualifiers here
+ * will only function properly if your compiler supports them
+ * and if you don't actively work to defeat them. For example,
+ * in order for a cl_float4 to be 16 byte aligned in a struct,
+ * the start of the struct must itself be 16-byte aligned.
+ *
+ * Maintaining proper alignment is the user's responsibility.
+ */
+
+/* Define basic vector types */
+#if defined( __VEC__ )
+ #include <altivec.h> /* may be omitted depending on compiler. AltiVec spec provides no way to detect whether the header is required. */
+ typedef vector unsigned char __cl_uchar16;
+ typedef vector signed char __cl_char16;
+ typedef vector unsigned short __cl_ushort8;
+ typedef vector signed short __cl_short8;
+ typedef vector unsigned int __cl_uint4;
+ typedef vector signed int __cl_int4;
+ typedef vector float __cl_float4;
+ #define __CL_UCHAR16__ 1
+ #define __CL_CHAR16__ 1
+ #define __CL_USHORT8__ 1
+ #define __CL_SHORT8__ 1
+ #define __CL_UINT4__ 1
+ #define __CL_INT4__ 1
+ #define __CL_FLOAT4__ 1
+#endif
+
+#if defined( __SSE__ )
+ #if defined( __MINGW64__ )
+ #include <intrin.h>
+ #else
+ #include <xmmintrin.h>
+ #endif
+ #if defined( __GNUC__ )
+ typedef float __cl_float4 __attribute__((vector_size(16)));
+ #else
+ typedef __m128 __cl_float4;
+ #endif
+ #define __CL_FLOAT4__ 1
+#endif
+
+#if defined( __SSE2__ )
+ #if defined( __MINGW64__ )
+ #include <intrin.h>
+ #else
+ #include <emmintrin.h>
+ #endif
+ #if defined( __GNUC__ )
+ typedef cl_uchar __cl_uchar16 __attribute__((vector_size(16)));
+ typedef cl_char __cl_char16 __attribute__((vector_size(16)));
+ typedef cl_ushort __cl_ushort8 __attribute__((vector_size(16)));
+ typedef cl_short __cl_short8 __attribute__((vector_size(16)));
+ typedef cl_uint __cl_uint4 __attribute__((vector_size(16)));
+ typedef cl_int __cl_int4 __attribute__((vector_size(16)));
+ typedef cl_ulong __cl_ulong2 __attribute__((vector_size(16)));
+ typedef cl_long __cl_long2 __attribute__((vector_size(16)));
+ typedef cl_double __cl_double2 __attribute__((vector_size(16)));
+ #else
+ typedef __m128i __cl_uchar16;
+ typedef __m128i __cl_char16;
+ typedef __m128i __cl_ushort8;
+ typedef __m128i __cl_short8;
+ typedef __m128i __cl_uint4;
+ typedef __m128i __cl_int4;
+ typedef __m128i __cl_ulong2;
+ typedef __m128i __cl_long2;
+ typedef __m128d __cl_double2;
+ #endif
+ #define __CL_UCHAR16__ 1
+ #define __CL_CHAR16__ 1
+ #define __CL_USHORT8__ 1
+ #define __CL_SHORT8__ 1
+ #define __CL_INT4__ 1
+ #define __CL_UINT4__ 1
+ #define __CL_ULONG2__ 1
+ #define __CL_LONG2__ 1
+ #define __CL_DOUBLE2__ 1
+#endif
+
+#if defined( __MMX__ )
+ #include <mmintrin.h>
+ #if defined( __GNUC__ )
+ typedef cl_uchar __cl_uchar8 __attribute__((vector_size(8)));
+ typedef cl_char __cl_char8 __attribute__((vector_size(8)));
+ typedef cl_ushort __cl_ushort4 __attribute__((vector_size(8)));
+ typedef cl_short __cl_short4 __attribute__((vector_size(8)));
+ typedef cl_uint __cl_uint2 __attribute__((vector_size(8)));
+ typedef cl_int __cl_int2 __attribute__((vector_size(8)));
+ typedef cl_ulong __cl_ulong1 __attribute__((vector_size(8)));
+ typedef cl_long __cl_long1 __attribute__((vector_size(8)));
+ typedef cl_float __cl_float2 __attribute__((vector_size(8)));
+ #else
+ typedef __m64 __cl_uchar8;
+ typedef __m64 __cl_char8;
+ typedef __m64 __cl_ushort4;
+ typedef __m64 __cl_short4;
+ typedef __m64 __cl_uint2;
+ typedef __m64 __cl_int2;
+ typedef __m64 __cl_ulong1;
+ typedef __m64 __cl_long1;
+ typedef __m64 __cl_float2;
+ #endif
+ #define __CL_UCHAR8__ 1
+ #define __CL_CHAR8__ 1
+ #define __CL_USHORT4__ 1
+ #define __CL_SHORT4__ 1
+ #define __CL_INT2__ 1
+ #define __CL_UINT2__ 1
+ #define __CL_ULONG1__ 1
+ #define __CL_LONG1__ 1
+ #define __CL_FLOAT2__ 1
+#endif
+
+#if defined( __AVX__ )
+ #if defined( __MINGW64__ )
+ #include <intrin.h>
+ #else
+ #include <immintrin.h>
+ #endif
+ #if defined( __GNUC__ )
+ typedef cl_float __cl_float8 __attribute__((vector_size(32)));
+ typedef cl_double __cl_double4 __attribute__((vector_size(32)));
+ #else
+ typedef __m256 __cl_float8;
+ typedef __m256d __cl_double4;
+ #endif
+ #define __CL_FLOAT8__ 1
+ #define __CL_DOUBLE4__ 1
+#endif
+
+/* Define capabilities for anonymous struct members. */
+#if defined( __GNUC__) && ! defined( __STRICT_ANSI__ )
+#define __CL_HAS_ANON_STRUCT__ 1
+#define __CL_ANON_STRUCT__ __extension__
+#elif defined( _WIN32) && (_MSC_VER >= 1500)
+ /* Microsoft Developer Studio 2008 supports anonymous structs, but
+ * complains by default. */
+#define __CL_HAS_ANON_STRUCT__ 1
+#define __CL_ANON_STRUCT__
+ /* Disable warning C4201: nonstandard extension used : nameless
+ * struct/union */
+#pragma warning( push )
+#pragma warning( disable : 4201 )
+#else
+#define __CL_HAS_ANON_STRUCT__ 0
+#define __CL_ANON_STRUCT__
+#endif
+
+/* Define alignment keys */
+#if defined( __GNUC__ )
+ #define CL_ALIGNED(_x) __attribute__ ((aligned(_x)))
+#elif defined( _WIN32) && (_MSC_VER)
+ /* Alignment keys neutered on windows because MSVC can't swallow function arguments with alignment requirements */
+ /* http://msdn.microsoft.com/en-us/library/373ak2y1%28VS.71%29.aspx */
+ /* #include <crtdefs.h> */
+ /* #define CL_ALIGNED(_x) _CRT_ALIGN(_x) */
+ #define CL_ALIGNED(_x)
+#else
+ #warning Need to implement some method to align data here
+ #define CL_ALIGNED(_x)
+#endif
+
+/* Indicate whether .xyzw, .s0123 and .hi.lo are supported */
+#if __CL_HAS_ANON_STRUCT__
+ /* .xyzw and .s0123...{f|F} are supported */
+ #define CL_HAS_NAMED_VECTOR_FIELDS 1
+ /* .hi and .lo are supported */
+ #define CL_HAS_HI_LO_VECTOR_FIELDS 1
+#endif
+
+/* Define cl_vector types */
+
+/* ---- cl_charn ---- */
+typedef union
+{
+ cl_char CL_ALIGNED(2) s[2];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_char x, y; };
+ __CL_ANON_STRUCT__ struct{ cl_char s0, s1; };
+ __CL_ANON_STRUCT__ struct{ cl_char lo, hi; };
+#endif
+#if defined( __CL_CHAR2__)
+ __cl_char2 v2;
+#endif
+}cl_char2;
+
+typedef union
+{
+ cl_char CL_ALIGNED(4) s[4];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_char x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_char s0, s1, s2, s3; };
+ __CL_ANON_STRUCT__ struct{ cl_char2 lo, hi; };
+#endif
+#if defined( __CL_CHAR2__)
+ __cl_char2 v2[2];
+#endif
+#if defined( __CL_CHAR4__)
+ __cl_char4 v4;
+#endif
+}cl_char4;
+
+/* cl_char3 is identical in size, alignment and behavior to cl_char4. See section 6.1.5. */
+typedef cl_char4 cl_char3;
+
+typedef union
+{
+ cl_char CL_ALIGNED(8) s[8];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_char x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7; };
+ __CL_ANON_STRUCT__ struct{ cl_char4 lo, hi; };
+#endif
+#if defined( __CL_CHAR2__)
+ __cl_char2 v2[4];
+#endif
+#if defined( __CL_CHAR4__)
+ __cl_char4 v4[2];
+#endif
+#if defined( __CL_CHAR8__ )
+ __cl_char8 v8;
+#endif
+}cl_char8;
+
+typedef union
+{
+ cl_char CL_ALIGNED(16) s[16];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_char x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
+ __CL_ANON_STRUCT__ struct{ cl_char s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
+ __CL_ANON_STRUCT__ struct{ cl_char8 lo, hi; };
+#endif
+#if defined( __CL_CHAR2__)
+ __cl_char2 v2[8];
+#endif
+#if defined( __CL_CHAR4__)
+ __cl_char4 v4[4];
+#endif
+#if defined( __CL_CHAR8__ )
+ __cl_char8 v8[2];
+#endif
+#if defined( __CL_CHAR16__ )
+ __cl_char16 v16;
+#endif
+}cl_char16;
+
+
+/* ---- cl_ucharn ---- */
+typedef union
+{
+ cl_uchar CL_ALIGNED(2) s[2];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_uchar x, y; };
+ __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1; };
+ __CL_ANON_STRUCT__ struct{ cl_uchar lo, hi; };
+#endif
+#if defined( __cl_uchar2__)
+ __cl_uchar2 v2;
+#endif
+}cl_uchar2;
+
+typedef union
+{
+ cl_uchar CL_ALIGNED(4) s[4];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_uchar x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1, s2, s3; };
+ __CL_ANON_STRUCT__ struct{ cl_uchar2 lo, hi; };
+#endif
+#if defined( __CL_UCHAR2__)
+ __cl_uchar2 v2[2];
+#endif
+#if defined( __CL_UCHAR4__)
+ __cl_uchar4 v4;
+#endif
+}cl_uchar4;
+
+/* cl_uchar3 is identical in size, alignment and behavior to cl_uchar4. See section 6.1.5. */
+typedef cl_uchar4 cl_uchar3;
+
+typedef union
+{
+ cl_uchar CL_ALIGNED(8) s[8];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_uchar x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7; };
+ __CL_ANON_STRUCT__ struct{ cl_uchar4 lo, hi; };
+#endif
+#if defined( __CL_UCHAR2__)
+ __cl_uchar2 v2[4];
+#endif
+#if defined( __CL_UCHAR4__)
+ __cl_uchar4 v4[2];
+#endif
+#if defined( __CL_UCHAR8__ )
+ __cl_uchar8 v8;
+#endif
+}cl_uchar8;
+
+typedef union
+{
+ cl_uchar CL_ALIGNED(16) s[16];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_uchar x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
+ __CL_ANON_STRUCT__ struct{ cl_uchar s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
+ __CL_ANON_STRUCT__ struct{ cl_uchar8 lo, hi; };
+#endif
+#if defined( __CL_UCHAR2__)
+ __cl_uchar2 v2[8];
+#endif
+#if defined( __CL_UCHAR4__)
+ __cl_uchar4 v4[4];
+#endif
+#if defined( __CL_UCHAR8__ )
+ __cl_uchar8 v8[2];
+#endif
+#if defined( __CL_UCHAR16__ )
+ __cl_uchar16 v16;
+#endif
+}cl_uchar16;
+
+
+/* ---- cl_shortn ---- */
+typedef union
+{
+ cl_short CL_ALIGNED(4) s[2];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_short x, y; };
+ __CL_ANON_STRUCT__ struct{ cl_short s0, s1; };
+ __CL_ANON_STRUCT__ struct{ cl_short lo, hi; };
+#endif
+#if defined( __CL_SHORT2__)
+ __cl_short2 v2;
+#endif
+}cl_short2;
+
+typedef union
+{
+ cl_short CL_ALIGNED(8) s[4];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_short x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_short s0, s1, s2, s3; };
+ __CL_ANON_STRUCT__ struct{ cl_short2 lo, hi; };
+#endif
+#if defined( __CL_SHORT2__)
+ __cl_short2 v2[2];
+#endif
+#if defined( __CL_SHORT4__)
+ __cl_short4 v4;
+#endif
+}cl_short4;
+
+/* cl_short3 is identical in size, alignment and behavior to cl_short4. See section 6.1.5. */
+typedef cl_short4 cl_short3;
+
+typedef union
+{
+ cl_short CL_ALIGNED(16) s[8];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_short x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7; };
+ __CL_ANON_STRUCT__ struct{ cl_short4 lo, hi; };
+#endif
+#if defined( __CL_SHORT2__)
+ __cl_short2 v2[4];
+#endif
+#if defined( __CL_SHORT4__)
+ __cl_short4 v4[2];
+#endif
+#if defined( __CL_SHORT8__ )
+ __cl_short8 v8;
+#endif
+}cl_short8;
+
+typedef union
+{
+ cl_short CL_ALIGNED(32) s[16];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_short x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
+ __CL_ANON_STRUCT__ struct{ cl_short s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
+ __CL_ANON_STRUCT__ struct{ cl_short8 lo, hi; };
+#endif
+#if defined( __CL_SHORT2__)
+ __cl_short2 v2[8];
+#endif
+#if defined( __CL_SHORT4__)
+ __cl_short4 v4[4];
+#endif
+#if defined( __CL_SHORT8__ )
+ __cl_short8 v8[2];
+#endif
+#if defined( __CL_SHORT16__ )
+ __cl_short16 v16;
+#endif
+}cl_short16;
+
+
+/* ---- cl_ushortn ---- */
+typedef union
+{
+ cl_ushort CL_ALIGNED(4) s[2];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_ushort x, y; };
+ __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1; };
+ __CL_ANON_STRUCT__ struct{ cl_ushort lo, hi; };
+#endif
+#if defined( __CL_USHORT2__)
+ __cl_ushort2 v2;
+#endif
+}cl_ushort2;
+
+typedef union
+{
+ cl_ushort CL_ALIGNED(8) s[4];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_ushort x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1, s2, s3; };
+ __CL_ANON_STRUCT__ struct{ cl_ushort2 lo, hi; };
+#endif
+#if defined( __CL_USHORT2__)
+ __cl_ushort2 v2[2];
+#endif
+#if defined( __CL_USHORT4__)
+ __cl_ushort4 v4;
+#endif
+}cl_ushort4;
+
+/* cl_ushort3 is identical in size, alignment and behavior to cl_ushort4. See section 6.1.5. */
+typedef cl_ushort4 cl_ushort3;
+
+typedef union
+{
+ cl_ushort CL_ALIGNED(16) s[8];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_ushort x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7; };
+ __CL_ANON_STRUCT__ struct{ cl_ushort4 lo, hi; };
+#endif
+#if defined( __CL_USHORT2__)
+ __cl_ushort2 v2[4];
+#endif
+#if defined( __CL_USHORT4__)
+ __cl_ushort4 v4[2];
+#endif
+#if defined( __CL_USHORT8__ )
+ __cl_ushort8 v8;
+#endif
+}cl_ushort8;
+
+typedef union
+{
+ cl_ushort CL_ALIGNED(32) s[16];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_ushort x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
+ __CL_ANON_STRUCT__ struct{ cl_ushort s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
+ __CL_ANON_STRUCT__ struct{ cl_ushort8 lo, hi; };
+#endif
+#if defined( __CL_USHORT2__)
+ __cl_ushort2 v2[8];
+#endif
+#if defined( __CL_USHORT4__)
+ __cl_ushort4 v4[4];
+#endif
+#if defined( __CL_USHORT8__ )
+ __cl_ushort8 v8[2];
+#endif
+#if defined( __CL_USHORT16__ )
+ __cl_ushort16 v16;
+#endif
+}cl_ushort16;
+
+/* ---- cl_intn ---- */
+typedef union
+{
+ cl_int CL_ALIGNED(8) s[2];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_int x, y; };
+ __CL_ANON_STRUCT__ struct{ cl_int s0, s1; };
+ __CL_ANON_STRUCT__ struct{ cl_int lo, hi; };
+#endif
+#if defined( __CL_INT2__)
+ __cl_int2 v2;
+#endif
+}cl_int2;
+
+typedef union
+{
+ cl_int CL_ALIGNED(16) s[4];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_int x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_int s0, s1, s2, s3; };
+ __CL_ANON_STRUCT__ struct{ cl_int2 lo, hi; };
+#endif
+#if defined( __CL_INT2__)
+ __cl_int2 v2[2];
+#endif
+#if defined( __CL_INT4__)
+ __cl_int4 v4;
+#endif
+}cl_int4;
+
+/* cl_int3 is identical in size, alignment and behavior to cl_int4. See section 6.1.5. */
+typedef cl_int4 cl_int3;
+
+typedef union
+{
+ cl_int CL_ALIGNED(32) s[8];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_int x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7; };
+ __CL_ANON_STRUCT__ struct{ cl_int4 lo, hi; };
+#endif
+#if defined( __CL_INT2__)
+ __cl_int2 v2[4];
+#endif
+#if defined( __CL_INT4__)
+ __cl_int4 v4[2];
+#endif
+#if defined( __CL_INT8__ )
+ __cl_int8 v8;
+#endif
+}cl_int8;
+
+typedef union
+{
+ cl_int CL_ALIGNED(64) s[16];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_int x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
+ __CL_ANON_STRUCT__ struct{ cl_int s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
+ __CL_ANON_STRUCT__ struct{ cl_int8 lo, hi; };
+#endif
+#if defined( __CL_INT2__)
+ __cl_int2 v2[8];
+#endif
+#if defined( __CL_INT4__)
+ __cl_int4 v4[4];
+#endif
+#if defined( __CL_INT8__ )
+ __cl_int8 v8[2];
+#endif
+#if defined( __CL_INT16__ )
+ __cl_int16 v16;
+#endif
+}cl_int16;
+
+
+/* ---- cl_uintn ---- */
+typedef union
+{
+ cl_uint CL_ALIGNED(8) s[2];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_uint x, y; };
+ __CL_ANON_STRUCT__ struct{ cl_uint s0, s1; };
+ __CL_ANON_STRUCT__ struct{ cl_uint lo, hi; };
+#endif
+#if defined( __CL_UINT2__)
+ __cl_uint2 v2;
+#endif
+}cl_uint2;
+
+typedef union
+{
+ cl_uint CL_ALIGNED(16) s[4];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_uint x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_uint s0, s1, s2, s3; };
+ __CL_ANON_STRUCT__ struct{ cl_uint2 lo, hi; };
+#endif
+#if defined( __CL_UINT2__)
+ __cl_uint2 v2[2];
+#endif
+#if defined( __CL_UINT4__)
+ __cl_uint4 v4;
+#endif
+}cl_uint4;
+
+/* cl_uint3 is identical in size, alignment and behavior to cl_uint4. See section 6.1.5. */
+typedef cl_uint4 cl_uint3;
+
+typedef union
+{
+ cl_uint CL_ALIGNED(32) s[8];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_uint x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7; };
+ __CL_ANON_STRUCT__ struct{ cl_uint4 lo, hi; };
+#endif
+#if defined( __CL_UINT2__)
+ __cl_uint2 v2[4];
+#endif
+#if defined( __CL_UINT4__)
+ __cl_uint4 v4[2];
+#endif
+#if defined( __CL_UINT8__ )
+ __cl_uint8 v8;
+#endif
+}cl_uint8;
+
+typedef union
+{
+ cl_uint CL_ALIGNED(64) s[16];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_uint x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
+ __CL_ANON_STRUCT__ struct{ cl_uint s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
+ __CL_ANON_STRUCT__ struct{ cl_uint8 lo, hi; };
+#endif
+#if defined( __CL_UINT2__)
+ __cl_uint2 v2[8];
+#endif
+#if defined( __CL_UINT4__)
+ __cl_uint4 v4[4];
+#endif
+#if defined( __CL_UINT8__ )
+ __cl_uint8 v8[2];
+#endif
+#if defined( __CL_UINT16__ )
+ __cl_uint16 v16;
+#endif
+}cl_uint16;
+
+/* ---- cl_longn ---- */
+typedef union
+{
+ cl_long CL_ALIGNED(16) s[2];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_long x, y; };
+ __CL_ANON_STRUCT__ struct{ cl_long s0, s1; };
+ __CL_ANON_STRUCT__ struct{ cl_long lo, hi; };
+#endif
+#if defined( __CL_LONG2__)
+ __cl_long2 v2;
+#endif
+}cl_long2;
+
+typedef union
+{
+ cl_long CL_ALIGNED(32) s[4];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_long x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_long s0, s1, s2, s3; };
+ __CL_ANON_STRUCT__ struct{ cl_long2 lo, hi; };
+#endif
+#if defined( __CL_LONG2__)
+ __cl_long2 v2[2];
+#endif
+#if defined( __CL_LONG4__)
+ __cl_long4 v4;
+#endif
+}cl_long4;
+
+/* cl_long3 is identical in size, alignment and behavior to cl_long4. See section 6.1.5. */
+typedef cl_long4 cl_long3;
+
+typedef union
+{
+ cl_long CL_ALIGNED(64) s[8];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_long x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7; };
+ __CL_ANON_STRUCT__ struct{ cl_long4 lo, hi; };
+#endif
+#if defined( __CL_LONG2__)
+ __cl_long2 v2[4];
+#endif
+#if defined( __CL_LONG4__)
+ __cl_long4 v4[2];
+#endif
+#if defined( __CL_LONG8__ )
+ __cl_long8 v8;
+#endif
+}cl_long8;
+
+typedef union
+{
+ cl_long CL_ALIGNED(128) s[16];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_long x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
+ __CL_ANON_STRUCT__ struct{ cl_long s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
+ __CL_ANON_STRUCT__ struct{ cl_long8 lo, hi; };
+#endif
+#if defined( __CL_LONG2__)
+ __cl_long2 v2[8];
+#endif
+#if defined( __CL_LONG4__)
+ __cl_long4 v4[4];
+#endif
+#if defined( __CL_LONG8__ )
+ __cl_long8 v8[2];
+#endif
+#if defined( __CL_LONG16__ )
+ __cl_long16 v16;
+#endif
+}cl_long16;
+
+
+/* ---- cl_ulongn ---- */
+typedef union
+{
+ cl_ulong CL_ALIGNED(16) s[2];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_ulong x, y; };
+ __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1; };
+ __CL_ANON_STRUCT__ struct{ cl_ulong lo, hi; };
+#endif
+#if defined( __CL_ULONG2__)
+ __cl_ulong2 v2;
+#endif
+}cl_ulong2;
+
+typedef union
+{
+ cl_ulong CL_ALIGNED(32) s[4];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_ulong x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1, s2, s3; };
+ __CL_ANON_STRUCT__ struct{ cl_ulong2 lo, hi; };
+#endif
+#if defined( __CL_ULONG2__)
+ __cl_ulong2 v2[2];
+#endif
+#if defined( __CL_ULONG4__)
+ __cl_ulong4 v4;
+#endif
+}cl_ulong4;
+
+/* cl_ulong3 is identical in size, alignment and behavior to cl_ulong4. See section 6.1.5. */
+typedef cl_ulong4 cl_ulong3;
+
+typedef union
+{
+ cl_ulong CL_ALIGNED(64) s[8];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_ulong x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7; };
+ __CL_ANON_STRUCT__ struct{ cl_ulong4 lo, hi; };
+#endif
+#if defined( __CL_ULONG2__)
+ __cl_ulong2 v2[4];
+#endif
+#if defined( __CL_ULONG4__)
+ __cl_ulong4 v4[2];
+#endif
+#if defined( __CL_ULONG8__ )
+ __cl_ulong8 v8;
+#endif
+}cl_ulong8;
+
+typedef union
+{
+ cl_ulong CL_ALIGNED(128) s[16];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_ulong x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
+ __CL_ANON_STRUCT__ struct{ cl_ulong s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
+ __CL_ANON_STRUCT__ struct{ cl_ulong8 lo, hi; };
+#endif
+#if defined( __CL_ULONG2__)
+ __cl_ulong2 v2[8];
+#endif
+#if defined( __CL_ULONG4__)
+ __cl_ulong4 v4[4];
+#endif
+#if defined( __CL_ULONG8__ )
+ __cl_ulong8 v8[2];
+#endif
+#if defined( __CL_ULONG16__ )
+ __cl_ulong16 v16;
+#endif
+}cl_ulong16;
+
+
+/* --- cl_floatn ---- */
+
+typedef union
+{
+ cl_float CL_ALIGNED(8) s[2];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_float x, y; };
+ __CL_ANON_STRUCT__ struct{ cl_float s0, s1; };
+ __CL_ANON_STRUCT__ struct{ cl_float lo, hi; };
+#endif
+#if defined( __CL_FLOAT2__)
+ __cl_float2 v2;
+#endif
+}cl_float2;
+
+typedef union
+{
+ cl_float CL_ALIGNED(16) s[4];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_float x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_float s0, s1, s2, s3; };
+ __CL_ANON_STRUCT__ struct{ cl_float2 lo, hi; };
+#endif
+#if defined( __CL_FLOAT2__)
+ __cl_float2 v2[2];
+#endif
+#if defined( __CL_FLOAT4__)
+ __cl_float4 v4;
+#endif
+}cl_float4;
+
+/* cl_float3 is identical in size, alignment and behavior to cl_float4. See section 6.1.5. */
+typedef cl_float4 cl_float3;
+
+typedef union
+{
+ cl_float CL_ALIGNED(32) s[8];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_float x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7; };
+ __CL_ANON_STRUCT__ struct{ cl_float4 lo, hi; };
+#endif
+#if defined( __CL_FLOAT2__)
+ __cl_float2 v2[4];
+#endif
+#if defined( __CL_FLOAT4__)
+ __cl_float4 v4[2];
+#endif
+#if defined( __CL_FLOAT8__ )
+ __cl_float8 v8;
+#endif
+}cl_float8;
+
+typedef union
+{
+ cl_float CL_ALIGNED(64) s[16];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_float x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
+ __CL_ANON_STRUCT__ struct{ cl_float s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
+ __CL_ANON_STRUCT__ struct{ cl_float8 lo, hi; };
+#endif
+#if defined( __CL_FLOAT2__)
+ __cl_float2 v2[8];
+#endif
+#if defined( __CL_FLOAT4__)
+ __cl_float4 v4[4];
+#endif
+#if defined( __CL_FLOAT8__ )
+ __cl_float8 v8[2];
+#endif
+#if defined( __CL_FLOAT16__ )
+ __cl_float16 v16;
+#endif
+}cl_float16;
+
+/* --- cl_doublen ---- */
+
+typedef union
+{
+ cl_double CL_ALIGNED(16) s[2];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_double x, y; };
+ __CL_ANON_STRUCT__ struct{ cl_double s0, s1; };
+ __CL_ANON_STRUCT__ struct{ cl_double lo, hi; };
+#endif
+#if defined( __CL_DOUBLE2__)
+ __cl_double2 v2;
+#endif
+}cl_double2;
+
+typedef union
+{
+ cl_double CL_ALIGNED(32) s[4];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_double x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_double s0, s1, s2, s3; };
+ __CL_ANON_STRUCT__ struct{ cl_double2 lo, hi; };
+#endif
+#if defined( __CL_DOUBLE2__)
+ __cl_double2 v2[2];
+#endif
+#if defined( __CL_DOUBLE4__)
+ __cl_double4 v4;
+#endif
+}cl_double4;
+
+/* cl_double3 is identical in size, alignment and behavior to cl_double4. See section 6.1.5. */
+typedef cl_double4 cl_double3;
+
+typedef union
+{
+ cl_double CL_ALIGNED(64) s[8];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_double x, y, z, w; };
+ __CL_ANON_STRUCT__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7; };
+ __CL_ANON_STRUCT__ struct{ cl_double4 lo, hi; };
+#endif
+#if defined( __CL_DOUBLE2__)
+ __cl_double2 v2[4];
+#endif
+#if defined( __CL_DOUBLE4__)
+ __cl_double4 v4[2];
+#endif
+#if defined( __CL_DOUBLE8__ )
+ __cl_double8 v8;
+#endif
+}cl_double8;
+
+typedef union
+{
+ cl_double CL_ALIGNED(128) s[16];
+#if __CL_HAS_ANON_STRUCT__
+ __CL_ANON_STRUCT__ struct{ cl_double x, y, z, w, __spacer4, __spacer5, __spacer6, __spacer7, __spacer8, __spacer9, sa, sb, sc, sd, se, sf; };
+ __CL_ANON_STRUCT__ struct{ cl_double s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, sA, sB, sC, sD, sE, sF; };
+ __CL_ANON_STRUCT__ struct{ cl_double8 lo, hi; };
+#endif
+#if defined( __CL_DOUBLE2__)
+ __cl_double2 v2[8];
+#endif
+#if defined( __CL_DOUBLE4__)
+ __cl_double4 v4[4];
+#endif
+#if defined( __CL_DOUBLE8__ )
+ __cl_double8 v8[2];
+#endif
+#if defined( __CL_DOUBLE16__ )
+ __cl_double16 v16;
+#endif
+}cl_double16;
+
+/* Macro to facilitate debugging
+ * Usage:
+ * Place CL_PROGRAM_STRING_DEBUG_INFO on the line before the first line of your source.
+ * The first line ends with: CL_PROGRAM_STRING_DEBUG_INFO \"
+ * Each line thereafter of OpenCL C source must end with: \n\
+ * The last line ends in ";
+ *
+ * Example:
+ *
+ * const char *my_program = CL_PROGRAM_STRING_DEBUG_INFO "\
+ * kernel void foo( int a, float * b ) \n\
+ * { \n\
+ * // my comment \n\
+ * *b[ get_global_id(0)] = a; \n\
+ * } \n\
+ * ";
+ *
+ * This should correctly set up the line, (column) and file information for your source
+ * string so you can do source level debugging.
+ */
+#define __CL_STRINGIFY( _x ) # _x
+#define _CL_STRINGIFY( _x ) __CL_STRINGIFY( _x )
+#define CL_PROGRAM_STRING_DEBUG_INFO "#line " _CL_STRINGIFY(__LINE__) " \"" __FILE__ "\" \n\n"
+
+#ifdef __cplusplus
+}
+#endif
+
+#undef __CL_HAS_ANON_STRUCT__
+#undef __CL_ANON_STRUCT__
+#if defined( _WIN32) && (_MSC_VER >= 1500)
+#pragma warning( pop )
+#endif
+
+#endif /* __CL_PLATFORM_H */
diff --git a/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/opencl.h b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/opencl.h
new file mode 100644
index 000000000..fccacd168
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/headers/1.2/opencl.h
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2008-2012 The Khronos Group Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Materials.
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ ******************************************************************************/
+
+/* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */
+
+#ifndef __OPENCL_H
+#define __OPENCL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <cl.h>
+#include <cl_gl.h>
+#include <cl_gl_ext.h>
+#include <cl_ext.h>
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OPENCL_H */
+
diff --git a/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/image.go b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/image.go
new file mode 100644
index 000000000..d6a996377
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/image.go
@@ -0,0 +1,83 @@
+// +build cl12
+
+package cl
+
+// #ifdef __APPLE__
+// #include "OpenCL/opencl.h"
+// #else
+// #include "cl.h"
+// #endif
+import "C"
+import (
+ "image"
+ "unsafe"
+)
+
+func (ctx *Context) CreateImage(flags MemFlag, imageFormat ImageFormat, imageDesc ImageDescription, data []byte) (*MemObject, error) {
+ format := imageFormat.toCl()
+ desc := imageDesc.toCl()
+ var dataPtr unsafe.Pointer
+ if data != nil {
+ dataPtr = unsafe.Pointer(&data[0])
+ }
+ var err C.cl_int
+ clBuffer := C.clCreateImage(ctx.clContext, C.cl_mem_flags(flags), &format, &desc, dataPtr, &err)
+ if err != C.CL_SUCCESS {
+ return nil, toError(err)
+ }
+ if clBuffer == nil {
+ return nil, ErrUnknown
+ }
+ return newMemObject(clBuffer, len(data)), nil
+}
+
+func (ctx *Context) CreateImageSimple(flags MemFlag, width, height int, channelOrder ChannelOrder, channelDataType ChannelDataType, data []byte) (*MemObject, error) {
+ format := ImageFormat{channelOrder, channelDataType}
+ desc := ImageDescription{
+ Type: MemObjectTypeImage2D,
+ Width: width,
+ Height: height,
+ }
+ return ctx.CreateImage(flags, format, desc, data)
+}
+
+func (ctx *Context) CreateImageFromImage(flags MemFlag, img image.Image) (*MemObject, error) {
+ switch m := img.(type) {
+ case *image.Gray:
+ format := ImageFormat{ChannelOrderIntensity, ChannelDataTypeUNormInt8}
+ desc := ImageDescription{
+ Type: MemObjectTypeImage2D,
+ Width: m.Bounds().Dx(),
+ Height: m.Bounds().Dy(),
+ RowPitch: m.Stride,
+ }
+ return ctx.CreateImage(flags, format, desc, m.Pix)
+ case *image.RGBA:
+ format := ImageFormat{ChannelOrderRGBA, ChannelDataTypeUNormInt8}
+ desc := ImageDescription{
+ Type: MemObjectTypeImage2D,
+ Width: m.Bounds().Dx(),
+ Height: m.Bounds().Dy(),
+ RowPitch: m.Stride,
+ }
+ return ctx.CreateImage(flags, format, desc, m.Pix)
+ }
+
+ b := img.Bounds()
+ w := b.Dx()
+ h := b.Dy()
+ data := make([]byte, w*h*4)
+ dataOffset := 0
+ for y := 0; y < h; y++ {
+ for x := 0; x < w; x++ {
+ c := img.At(x+b.Min.X, y+b.Min.Y)
+ r, g, b, a := c.RGBA()
+ data[dataOffset] = uint8(r >> 8)
+ data[dataOffset+1] = uint8(g >> 8)
+ data[dataOffset+2] = uint8(b >> 8)
+ data[dataOffset+3] = uint8(a >> 8)
+ dataOffset += 4
+ }
+ }
+ return ctx.CreateImageSimple(flags, w, h, ChannelOrderRGBA, ChannelDataTypeUNormInt8, data)
+}
diff --git a/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/kernel.go b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/kernel.go
new file mode 100644
index 000000000..894a775e8
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/kernel.go
@@ -0,0 +1,127 @@
+package cl
+
+// #ifdef __APPLE__
+// #include "OpenCL/opencl.h"
+// #else
+// #include "cl.h"
+// #endif
+import "C"
+
+import (
+ "fmt"
+ "unsafe"
+)
+
+type ErrUnsupportedArgumentType struct {
+ Index int
+ Value interface{}
+}
+
+func (e ErrUnsupportedArgumentType) Error() string {
+ return fmt.Sprintf("cl: unsupported argument type for index %d: %+v", e.Index, e.Value)
+}
+
+type Kernel struct {
+ clKernel C.cl_kernel
+ name string
+}
+
+type LocalBuffer int
+
+func releaseKernel(k *Kernel) {
+ if k.clKernel != nil {
+ C.clReleaseKernel(k.clKernel)
+ k.clKernel = nil
+ }
+}
+
+func (k *Kernel) Release() {
+ releaseKernel(k)
+}
+
+func (k *Kernel) SetArgs(args ...interface{}) error {
+ for index, arg := range args {
+ if err := k.SetArg(index, arg); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+func (k *Kernel) SetArg(index int, arg interface{}) error {
+ switch val := arg.(type) {
+ case uint8:
+ return k.SetArgUint8(index, val)
+ case int8:
+ return k.SetArgInt8(index, val)
+ case uint32:
+ return k.SetArgUint32(index, val)
+ case uint64:
+ return k.SetArgUint64(index, val)
+ case int32:
+ return k.SetArgInt32(index, val)
+ case float32:
+ return k.SetArgFloat32(index, val)
+ case *MemObject:
+ return k.SetArgBuffer(index, val)
+ case LocalBuffer:
+ return k.SetArgLocal(index, int(val))
+ default:
+ return ErrUnsupportedArgumentType{Index: index, Value: arg}
+ }
+}
+
+func (k *Kernel) SetArgBuffer(index int, buffer *MemObject) error {
+ return k.SetArgUnsafe(index, int(unsafe.Sizeof(buffer.clMem)), unsafe.Pointer(&buffer.clMem))
+}
+
+func (k *Kernel) SetArgFloat32(index int, val float32) error {
+ return k.SetArgUnsafe(index, int(unsafe.Sizeof(val)), unsafe.Pointer(&val))
+}
+
+func (k *Kernel) SetArgInt8(index int, val int8) error {
+ return k.SetArgUnsafe(index, int(unsafe.Sizeof(val)), unsafe.Pointer(&val))
+}
+
+func (k *Kernel) SetArgUint8(index int, val uint8) error {
+ return k.SetArgUnsafe(index, int(unsafe.Sizeof(val)), unsafe.Pointer(&val))
+}
+
+func (k *Kernel) SetArgInt32(index int, val int32) error {
+ return k.SetArgUnsafe(index, int(unsafe.Sizeof(val)), unsafe.Pointer(&val))
+}
+
+func (k *Kernel) SetArgUint32(index int, val uint32) error {
+ return k.SetArgUnsafe(index, int(unsafe.Sizeof(val)), unsafe.Pointer(&val))
+}
+
+func (k *Kernel) SetArgUint64(index int, val uint64) error {
+ return k.SetArgUnsafe(index, int(unsafe.Sizeof(val)), unsafe.Pointer(&val))
+}
+
+func (k *Kernel) SetArgLocal(index int, size int) error {
+ return k.SetArgUnsafe(index, size, nil)
+}
+
+func (k *Kernel) SetArgUnsafe(index, argSize int, arg unsafe.Pointer) error {
+ //fmt.Println("FUNKY: ", index, argSize)
+ return toError(C.clSetKernelArg(k.clKernel, C.cl_uint(index), C.size_t(argSize), arg))
+}
+
+func (k *Kernel) PreferredWorkGroupSizeMultiple(device *Device) (int, error) {
+ var size C.size_t
+ err := C.clGetKernelWorkGroupInfo(k.clKernel, device.nullableId(), C.CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, C.size_t(unsafe.Sizeof(size)), unsafe.Pointer(&size), nil)
+ return int(size), toError(err)
+}
+
+func (k *Kernel) WorkGroupSize(device *Device) (int, error) {
+ var size C.size_t
+ err := C.clGetKernelWorkGroupInfo(k.clKernel, device.nullableId(), C.CL_KERNEL_WORK_GROUP_SIZE, C.size_t(unsafe.Sizeof(size)), unsafe.Pointer(&size), nil)
+ return int(size), toError(err)
+}
+
+func (k *Kernel) NumArgs() (int, error) {
+ var num C.cl_uint
+ err := C.clGetKernelInfo(k.clKernel, C.CL_KERNEL_NUM_ARGS, C.size_t(unsafe.Sizeof(num)), unsafe.Pointer(&num), nil)
+ return int(num), toError(err)
+}
diff --git a/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/kernel10.go b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/kernel10.go
new file mode 100644
index 000000000..579946068
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/kernel10.go
@@ -0,0 +1,7 @@
+// +build !cl12
+
+package cl
+
+func (k *Kernel) ArgName(index int) (string, error) {
+ return "", ErrUnsupported
+}
diff --git a/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/kernel12.go b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/kernel12.go
new file mode 100644
index 000000000..d9e6f3546
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/kernel12.go
@@ -0,0 +1,20 @@
+// +build cl12
+
+package cl
+
+// #ifdef __APPLE__
+// #include "OpenCL/opencl.h"
+// #else
+// #include "cl.h"
+// #endif
+import "C"
+import "unsafe"
+
+func (k *Kernel) ArgName(index int) (string, error) {
+ var strC [1024]byte
+ var strN C.size_t
+ if err := C.clGetKernelArgInfo(k.clKernel, C.cl_uint(index), C.CL_KERNEL_ARG_NAME, 1024, unsafe.Pointer(&strC[0]), &strN); err != C.CL_SUCCESS {
+ return "", toError(err)
+ }
+ return string(strC[:strN]), nil
+}
diff --git a/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/platform.go b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/platform.go
new file mode 100644
index 000000000..fd1d162cf
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/platform.go
@@ -0,0 +1,83 @@
+package cl
+
+// #ifdef __APPLE__
+// #include "OpenCL/opencl.h"
+// #else
+// #include "cl.h"
+// #endif
+import "C"
+
+import "unsafe"
+
+const maxPlatforms = 32
+
+type Platform struct {
+ id C.cl_platform_id
+}
+
+// Obtain the list of platforms available.
+func GetPlatforms() ([]*Platform, error) {
+ var platformIds [maxPlatforms]C.cl_platform_id
+ var nPlatforms C.cl_uint
+ if err := C.clGetPlatformIDs(C.cl_uint(maxPlatforms), &platformIds[0], &nPlatforms); err != C.CL_SUCCESS {
+ return nil, toError(err)
+ }
+ platforms := make([]*Platform, nPlatforms)
+ for i := 0; i < int(nPlatforms); i++ {
+ platforms[i] = &Platform{id: platformIds[i]}
+ }
+ return platforms, nil
+}
+
+func (p *Platform) GetDevices(deviceType DeviceType) ([]*Device, error) {
+ return GetDevices(p, deviceType)
+}
+
+func (p *Platform) getInfoString(param C.cl_platform_info) (string, error) {
+ var strC [2048]byte
+ var strN C.size_t
+ if err := C.clGetPlatformInfo(p.id, param, 2048, unsafe.Pointer(&strC[0]), &strN); err != C.CL_SUCCESS {
+ return "", toError(err)
+ }
+ return string(strC[:(strN - 1)]), nil
+}
+
+func (p *Platform) Name() string {
+ if str, err := p.getInfoString(C.CL_PLATFORM_NAME); err != nil {
+ panic("Platform.Name() should never fail")
+ } else {
+ return str
+ }
+}
+
+func (p *Platform) Vendor() string {
+ if str, err := p.getInfoString(C.CL_PLATFORM_VENDOR); err != nil {
+ panic("Platform.Vendor() should never fail")
+ } else {
+ return str
+ }
+}
+
+func (p *Platform) Profile() string {
+ if str, err := p.getInfoString(C.CL_PLATFORM_PROFILE); err != nil {
+ panic("Platform.Profile() should never fail")
+ } else {
+ return str
+ }
+}
+
+func (p *Platform) Version() string {
+ if str, err := p.getInfoString(C.CL_PLATFORM_VERSION); err != nil {
+ panic("Platform.Version() should never fail")
+ } else {
+ return str
+ }
+}
+
+func (p *Platform) Extensions() string {
+ if str, err := p.getInfoString(C.CL_PLATFORM_EXTENSIONS); err != nil {
+ panic("Platform.Extensions() should never fail")
+ } else {
+ return str
+ }
+}
diff --git a/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/program.go b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/program.go
new file mode 100644
index 000000000..e75f7ee0e
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/program.go
@@ -0,0 +1,105 @@
+package cl
+
+// #include <stdlib.h>
+// #ifdef __APPLE__
+// #include "OpenCL/opencl.h"
+// #else
+// #include "cl.h"
+// #endif
+import "C"
+
+import (
+ "fmt"
+ "runtime"
+ "unsafe"
+)
+
+type BuildError struct {
+ Message string
+ Device *Device
+}
+
+func (e BuildError) Error() string {
+ if e.Device != nil {
+ return fmt.Sprintf("cl: build error on %q: %s", e.Device.Name(), e.Message)
+ } else {
+ return fmt.Sprintf("cl: build error: %s", e.Message)
+ }
+}
+
+type Program struct {
+ clProgram C.cl_program
+ devices []*Device
+}
+
+func releaseProgram(p *Program) {
+ if p.clProgram != nil {
+ C.clReleaseProgram(p.clProgram)
+ p.clProgram = nil
+ }
+}
+
+func (p *Program) Release() {
+ releaseProgram(p)
+}
+
+func (p *Program) BuildProgram(devices []*Device, options string) error {
+ var cOptions *C.char
+ if options != "" {
+ cOptions = C.CString(options)
+ defer C.free(unsafe.Pointer(cOptions))
+ }
+ var deviceList []C.cl_device_id
+ var deviceListPtr *C.cl_device_id
+ numDevices := C.cl_uint(len(devices))
+ if devices != nil && len(devices) > 0 {
+ deviceList = buildDeviceIdList(devices)
+ deviceListPtr = &deviceList[0]
+ }
+ if err := C.clBuildProgram(p.clProgram, numDevices, deviceListPtr, cOptions, nil, nil); err != C.CL_SUCCESS {
+ buffer := make([]byte, 4096)
+ var bLen C.size_t
+ var err C.cl_int
+
+ for _, dev := range p.devices {
+ for i := 2; i >= 0; i-- {
+ err = C.clGetProgramBuildInfo(p.clProgram, dev.id, C.CL_PROGRAM_BUILD_LOG, C.size_t(len(buffer)), unsafe.Pointer(&buffer[0]), &bLen)
+ if err == C.CL_INVALID_VALUE && i > 0 && bLen < 1024*1024 {
+ // INVALID_VALUE probably means our buffer isn't large enough
+ buffer = make([]byte, bLen)
+ } else {
+ break
+ }
+ }
+ if err != C.CL_SUCCESS {
+ return toError(err)
+ }
+
+ if bLen > 1 {
+ return BuildError{
+ Device: dev,
+ Message: string(buffer[:bLen-1]),
+ }
+ }
+ }
+
+ return BuildError{
+ Device: nil,
+ Message: "build failed and produced no log entries",
+ }
+ }
+ return nil
+}
+
+func (p *Program) CreateKernel(name string) (*Kernel, error) {
+ cName := C.CString(name)
+ defer C.free(unsafe.Pointer(cName))
+ var err C.cl_int
+ clKernel := C.clCreateKernel(p.clProgram, cName, &err)
+ if err != C.CL_SUCCESS {
+ return nil, toError(err)
+ }
+ kernel := &Kernel{clKernel: clKernel, name: name}
+ runtime.SetFinalizer(kernel, releaseKernel)
+ return kernel, nil
+}
diff --git a/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/queue.go b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/queue.go
new file mode 100644
index 000000000..7762746da
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/queue.go
@@ -0,0 +1,193 @@
+package cl
+
+// #ifdef __APPLE__
+// #include "OpenCL/opencl.h"
+// #else
+// #include "cl.h"
+// #endif
+import "C"
+
+import "unsafe"
+
+type CommandQueueProperty int
+
+const (
+ CommandQueueOutOfOrderExecModeEnable CommandQueueProperty = C.CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE
+ CommandQueueProfilingEnable CommandQueueProperty = C.CL_QUEUE_PROFILING_ENABLE
+)
+
+type CommandQueue struct {
+ clQueue C.cl_command_queue
+ device *Device
+}
+
+func releaseCommandQueue(q *CommandQueue) {
+ if q.clQueue != nil {
+ C.clReleaseCommandQueue(q.clQueue)
+ q.clQueue = nil
+ }
+}
+
+// Call clReleaseCommandQueue on the CommandQueue. Using the CommandQueue after Release will cause a panick.
+func (q *CommandQueue) Release() {
+ releaseCommandQueue(q)
+}
+
+// Blocks until all previously queued OpenCL commands in a command-queue are issued to the associated device and have completed.
+func (q *CommandQueue) Finish() error {
+ return toError(C.clFinish(q.clQueue))
+}
+
+// Issues all previously queued OpenCL commands in a command-queue to the device associated with the command-queue.
+func (q *CommandQueue) Flush() error {
+ return toError(C.clFlush(q.clQueue))
+}
+
+// Enqueues a command to map a region of the buffer object given by buffer into the host address space and returns a pointer to this mapped region.
+func (q *CommandQueue) EnqueueMapBuffer(buffer *MemObject, blocking bool, flags MapFlag, offset, size int, eventWaitList []*Event) (*MappedMemObject, *Event, error) {
+ var event C.cl_event
+ var err C.cl_int
+ ptr := C.clEnqueueMapBuffer(q.clQueue, buffer.clMem, clBool(blocking), flags.toCl(), C.size_t(offset), C.size_t(size), C.cl_uint(len(eventWaitList)), eventListPtr(eventWaitList), &event, &err)
+ if err != C.CL_SUCCESS {
+ return nil, nil, toError(err)
+ }
+ ev := newEvent(event)
+ if ptr == nil {
+ return nil, ev, ErrUnknown
+ }
+ return &MappedMemObject{ptr: ptr, size: size}, ev, nil
+}
+
+// Enqueues a command to map a region of an image object into the host address space and returns a pointer to this mapped region.
+func (q *CommandQueue) EnqueueMapImage(buffer *MemObject, blocking bool, flags MapFlag, origin, region [3]int, eventWaitList []*Event) (*MappedMemObject, *Event, error) {
+ cOrigin := sizeT3(origin)
+ cRegion := sizeT3(region)
+ var event C.cl_event
+ var err C.cl_int
+ var rowPitch, slicePitch C.size_t
+ ptr := C.clEnqueueMapImage(q.clQueue, buffer.clMem, clBool(blocking), flags.toCl(), &cOrigin[0], &cRegion[0], &rowPitch, &slicePitch, C.cl_uint(len(eventWaitList)), eventListPtr(eventWaitList), &event, &err)
+ if err != C.CL_SUCCESS {
+ return nil, nil, toError(err)
+ }
+ ev := newEvent(event)
+ if ptr == nil {
+ return nil, ev, ErrUnknown
+ }
+ size := 0 // TODO: could calculate this
+ return &MappedMemObject{ptr: ptr, size: size, rowPitch: int(rowPitch), slicePitch: int(slicePitch)}, ev, nil
+}
+
+// Enqueues a command to unmap a previously mapped region of a memory object.
+func (q *CommandQueue) EnqueueUnmapMemObject(buffer *MemObject, mappedObj *MappedMemObject, eventWaitList []*Event) (*Event, error) {
+ var event C.cl_event
+ if err := C.clEnqueueUnmapMemObject(q.clQueue, buffer.clMem, mappedObj.ptr, C.cl_uint(len(eventWaitList)), eventListPtr(eventWaitList), &event); err != C.CL_SUCCESS {
+ return nil, toError(err)
+ }
+ return newEvent(event), nil
+}
+
+// Enqueues a command to copy a buffer object to another buffer object.
+func (q *CommandQueue) EnqueueCopyBuffer(srcBuffer, dstBuffer *MemObject, srcOffset, dstOffset, byteCount int, eventWaitList []*Event) (*Event, error) {
+ var event C.cl_event
+ err := toError(C.clEnqueueCopyBuffer(q.clQueue, srcBuffer.clMem, dstBuffer.clMem, C.size_t(srcOffset), C.size_t(dstOffset), C.size_t(byteCount), C.cl_uint(len(eventWaitList)), eventListPtr(eventWaitList), &event))
+ return newEvent(event), err
+}
+
+// Enqueue commands to write to a buffer object from host memory.
+func (q *CommandQueue) EnqueueWriteBuffer(buffer *MemObject, blocking bool, offset, dataSize int, dataPtr unsafe.Pointer, eventWaitList []*Event) (*Event, error) {
+ var event C.cl_event
+ err := toError(C.clEnqueueWriteBuffer(q.clQueue, buffer.clMem, clBool(blocking), C.size_t(offset), C.size_t(dataSize), dataPtr, C.cl_uint(len(eventWaitList)), eventListPtr(eventWaitList), &event))
+ return newEvent(event), err
+}
+
+func (q *CommandQueue) EnqueueWriteBufferFloat32(buffer *MemObject, blocking bool, offset int, data []float32, eventWaitList []*Event) (*Event, error) {
+ dataPtr := unsafe.Pointer(&data[0])
+ dataSize := int(unsafe.Sizeof(data[0])) * len(data)
+ return q.EnqueueWriteBuffer(buffer, blocking, offset, dataSize, dataPtr, eventWaitList)
+}
+
+// Enqueue commands to read from a buffer object to host memory.
+func (q *CommandQueue) EnqueueReadBuffer(buffer *MemObject, blocking bool, offset, dataSize int, dataPtr unsafe.Pointer, eventWaitList []*Event) (*Event, error) {
+ var event C.cl_event
+ err := toError(C.clEnqueueReadBuffer(q.clQueue, buffer.clMem, clBool(blocking), C.size_t(offset), C.size_t(dataSize), dataPtr, C.cl_uint(len(eventWaitList)), eventListPtr(eventWaitList), &event))
+ return newEvent(event), err
+}
+
+func (q *CommandQueue) EnqueueReadBufferFloat32(buffer *MemObject, blocking bool, offset int, data []float32, eventWaitList []*Event) (*Event, error) {
+ dataPtr := unsafe.Pointer(&data[0])
+ dataSize := int(unsafe.Sizeof(data[0])) * len(data)
+ return q.EnqueueReadBuffer(buffer, blocking, offset, dataSize, dataPtr, eventWaitList)
+}
+
+// Enqueues a command to execute a kernel on a device.
+func (q *CommandQueue) EnqueueNDRangeKernel(kernel *Kernel, globalWorkOffset, globalWorkSize, localWorkSize []int, eventWaitList []*Event) (*Event, error) {
+ workDim := len(globalWorkSize)
+ var globalWorkOffsetList []C.size_t
+ var globalWorkOffsetPtr *C.size_t
+ if globalWorkOffset != nil {
+ globalWorkOffsetList = make([]C.size_t, len(globalWorkOffset))
+ for i, off := range globalWorkOffset {
+ globalWorkOffsetList[i] = C.size_t(off)
+ }
+ globalWorkOffsetPtr = &globalWorkOffsetList[0]
+ }
+ var globalWorkSizeList []C.size_t
+ var globalWorkSizePtr *C.size_t
+ if globalWorkSize != nil {
+ globalWorkSizeList = make([]C.size_t, len(globalWorkSize))
+ for i, off := range globalWorkSize {
+ globalWorkSizeList[i] = C.size_t(off)
+ }
+ globalWorkSizePtr = &globalWorkSizeList[0]
+ }
+ var localWorkSizeList []C.size_t
+ var localWorkSizePtr *C.size_t
+ if localWorkSize != nil {
+ localWorkSizeList = make([]C.size_t, len(localWorkSize))
+ for i, off := range localWorkSize {
+ localWorkSizeList[i] = C.size_t(off)
+ }
+ localWorkSizePtr = &localWorkSizeList[0]
+ }
+ var event C.cl_event
+ err := toError(C.clEnqueueNDRangeKernel(q.clQueue, kernel.clKernel, C.cl_uint(workDim), globalWorkOffsetPtr, globalWorkSizePtr, localWorkSizePtr, C.cl_uint(len(eventWaitList)), eventListPtr(eventWaitList), &event))
+ return newEvent(event), err
+}
+
+// Enqueues a command to read from a 2D or 3D image object to host memory.
+func (q *CommandQueue) EnqueueReadImage(image *MemObject, blocking bool, origin, region [3]int, rowPitch, slicePitch int, data []byte, eventWaitList []*Event) (*Event, error) {
+ cOrigin := sizeT3(origin)
+ cRegion := sizeT3(region)
+ var event C.cl_event
+ err := toError(C.clEnqueueReadImage(q.clQueue, image.clMem, clBool(blocking), &cOrigin[0], &cRegion[0], C.size_t(rowPitch), C.size_t(slicePitch), unsafe.Pointer(&data[0]), C.cl_uint(len(eventWaitList)), eventListPtr(eventWaitList), &event))
+ return newEvent(event), err
+}
+
+// Enqueues a command to write from a 2D or 3D image object to host memory.
+func (q *CommandQueue) EnqueueWriteImage(image *MemObject, blocking bool, origin, region [3]int, rowPitch, slicePitch int, data []byte, eventWaitList []*Event) (*Event, error) {
+ cOrigin := sizeT3(origin)
+ cRegion := sizeT3(region)
+ var event C.cl_event
+ err := toError(C.clEnqueueWriteImage(q.clQueue, image.clMem, clBool(blocking), &cOrigin[0], &cRegion[0], C.size_t(rowPitch), C.size_t(slicePitch), unsafe.Pointer(&data[0]), C.cl_uint(len(eventWaitList)), eventListPtr(eventWaitList), &event))
+ return newEvent(event), err
+}
+
+func (q *CommandQueue) EnqueueFillBuffer(buffer *MemObject, pattern unsafe.Pointer, patternSize, offset, size int, eventWaitList []*Event) (*Event, error) {
+ var event C.cl_event
+ err := toError(C.clEnqueueFillBuffer(q.clQueue, buffer.clMem, pattern, C.size_t(patternSize), C.size_t(offset), C.size_t(size), C.cl_uint(len(eventWaitList)), eventListPtr(eventWaitList), &event))
+ return newEvent(event), err
+}
+
+// A synchronization point that enqueues a barrier operation.
+func (q *CommandQueue) EnqueueBarrierWithWaitList(eventWaitList []*Event) (*Event, error) {
+ var event C.cl_event
+ err := toError(C.clEnqueueBarrierWithWaitList(q.clQueue, C.cl_uint(len(eventWaitList)), eventListPtr(eventWaitList), &event))
+ return newEvent(event), err
+}
+
+// Enqueues a marker command which waits for either a list of events to complete, or all previously enqueued commands to complete.
+func (q *CommandQueue) EnqueueMarkerWithWaitList(eventWaitList []*Event) (*Event, error) {
+ var event C.cl_event
+ err := toError(C.clEnqueueMarkerWithWaitList(q.clQueue, C.cl_uint(len(eventWaitList)), eventListPtr(eventWaitList), &event))
+ return newEvent(event), err
+}
diff --git a/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/types.go b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/types.go
new file mode 100644
index 000000000..00c846ce7
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/types.go
@@ -0,0 +1,487 @@
+package cl
+
+// #ifdef __APPLE__
+// #include "OpenCL/opencl.h"
+// #else
+// #include "cl.h"
+// #endif
+import "C"
+
+import (
+ "errors"
+ "fmt"
+ "reflect"
+ "runtime"
+ "strings"
+ "unsafe"
+)
+
+var (
+ ErrUnknown = errors.New("cl: unknown error") // Generally an unexpected result from an OpenCL function (e.g. CL_SUCCESS but null pointer)
+)
+
+type ErrOther int
+
+func (e ErrOther) Error() string {
+ return fmt.Sprintf("cl: error %d", int(e))
+}
+
+var (
+ ErrDeviceNotFound = errors.New("cl: Device Not Found")
+ ErrDeviceNotAvailable = errors.New("cl: Device Not Available")
+ ErrCompilerNotAvailable = errors.New("cl: Compiler Not Available")
+ ErrMemObjectAllocationFailure = errors.New("cl: Mem Object Allocation Failure")
+ ErrOutOfResources = errors.New("cl: Out Of Resources")
+ ErrOutOfHostMemory = errors.New("cl: Out Of Host Memory")
+ ErrProfilingInfoNotAvailable = errors.New("cl: Profiling Info Not Available")
+ ErrMemCopyOverlap = errors.New("cl: Mem Copy Overlap")
+ ErrImageFormatMismatch = errors.New("cl: Image Format Mismatch")
+ ErrImageFormatNotSupported = errors.New("cl: Image Format Not Supported")
+ ErrBuildProgramFailure = errors.New("cl: Build Program Failure")
+ ErrMapFailure = errors.New("cl: Map Failure")
+ ErrMisalignedSubBufferOffset = errors.New("cl: Misaligned Sub Buffer Offset")
+ ErrExecStatusErrorForEventsInWaitList = errors.New("cl: Exec Status Error For Events In Wait List")
+ ErrCompileProgramFailure = errors.New("cl: Compile Program Failure")
+ ErrLinkerNotAvailable = errors.New("cl: Linker Not Available")
+ ErrLinkProgramFailure = errors.New("cl: Link Program Failure")
+ ErrDevicePartitionFailed = errors.New("cl: Device Partition Failed")
+ ErrKernelArgInfoNotAvailable = errors.New("cl: Kernel Arg Info Not Available")
+ ErrInvalidValue = errors.New("cl: Invalid Value")
+ ErrInvalidDeviceType = errors.New("cl: Invalid Device Type")
+ ErrInvalidPlatform = errors.New("cl: Invalid Platform")
+ ErrInvalidDevice = errors.New("cl: Invalid Device")
+ ErrInvalidContext = errors.New("cl: Invalid Context")
+ ErrInvalidQueueProperties = errors.New("cl: Invalid Queue Properties")
+ ErrInvalidCommandQueue = errors.New("cl: Invalid Command Queue")
+ ErrInvalidHostPtr = errors.New("cl: Invalid Host Ptr")
+ ErrInvalidMemObject = errors.New("cl: Invalid Mem Object")
+ ErrInvalidImageFormatDescriptor = errors.New("cl: Invalid Image Format Descriptor")
+ ErrInvalidImageSize = errors.New("cl: Invalid Image Size")
+ ErrInvalidSampler = errors.New("cl: Invalid Sampler")
+ ErrInvalidBinary = errors.New("cl: Invalid Binary")
+ ErrInvalidBuildOptions = errors.New("cl: Invalid Build Options")
+ ErrInvalidProgram = errors.New("cl: Invalid Program")
+ ErrInvalidProgramExecutable = errors.New("cl: Invalid Program Executable")
+ ErrInvalidKernelName = errors.New("cl: Invalid Kernel Name")
+ ErrInvalidKernelDefinition = errors.New("cl: Invalid Kernel Definition")
+ ErrInvalidKernel = errors.New("cl: Invalid Kernel")
+ ErrInvalidArgIndex = errors.New("cl: Invalid Arg Index")
+ ErrInvalidArgValue = errors.New("cl: Invalid Arg Value")
+ ErrInvalidArgSize = errors.New("cl: Invalid Arg Size")
+ ErrInvalidKernelArgs = errors.New("cl: Invalid Kernel Args")
+ ErrInvalidWorkDimension = errors.New("cl: Invalid Work Dimension")
+ ErrInvalidWorkGroupSize = errors.New("cl: Invalid Work Group Size")
+ ErrInvalidWorkItemSize = errors.New("cl: Invalid Work Item Size")
+ ErrInvalidGlobalOffset = errors.New("cl: Invalid Global Offset")
+ ErrInvalidEventWaitList = errors.New("cl: Invalid Event Wait List")
+ ErrInvalidEvent = errors.New("cl: Invalid Event")
+ ErrInvalidOperation = errors.New("cl: Invalid Operation")
+ ErrInvalidGlObject = errors.New("cl: Invalid Gl Object")
+ ErrInvalidBufferSize = errors.New("cl: Invalid Buffer Size")
+ ErrInvalidMipLevel = errors.New("cl: Invalid Mip Level")
+ ErrInvalidGlobalWorkSize = errors.New("cl: Invalid Global Work Size")
+ ErrInvalidProperty = errors.New("cl: Invalid Property")
+ ErrInvalidImageDescriptor = errors.New("cl: Invalid Image Descriptor")
+ ErrInvalidCompilerOptions = errors.New("cl: Invalid Compiler Options")
+ ErrInvalidLinkerOptions = errors.New("cl: Invalid Linker Options")
+ ErrInvalidDevicePartitionCount = errors.New("cl: Invalid Device Partition Count")
+)
+var errorMap = map[C.cl_int]error{
+ C.CL_SUCCESS: nil,
+ C.CL_DEVICE_NOT_FOUND: ErrDeviceNotFound,
+ C.CL_DEVICE_NOT_AVAILABLE: ErrDeviceNotAvailable,
+ C.CL_COMPILER_NOT_AVAILABLE: ErrCompilerNotAvailable,
+ C.CL_MEM_OBJECT_ALLOCATION_FAILURE: ErrMemObjectAllocationFailure,
+ C.CL_OUT_OF_RESOURCES: ErrOutOfResources,
+ C.CL_OUT_OF_HOST_MEMORY: ErrOutOfHostMemory,
+ C.CL_PROFILING_INFO_NOT_AVAILABLE: ErrProfilingInfoNotAvailable,
+ C.CL_MEM_COPY_OVERLAP: ErrMemCopyOverlap,
+ C.CL_IMAGE_FORMAT_MISMATCH: ErrImageFormatMismatch,
+ C.CL_IMAGE_FORMAT_NOT_SUPPORTED: ErrImageFormatNotSupported,
+ C.CL_BUILD_PROGRAM_FAILURE: ErrBuildProgramFailure,
+ C.CL_MAP_FAILURE: ErrMapFailure,
+ C.CL_MISALIGNED_SUB_BUFFER_OFFSET: ErrMisalignedSubBufferOffset,
+ C.CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST: ErrExecStatusErrorForEventsInWaitList,
+ C.CL_INVALID_VALUE: ErrInvalidValue,
+ C.CL_INVALID_DEVICE_TYPE: ErrInvalidDeviceType,
+ C.CL_INVALID_PLATFORM: ErrInvalidPlatform,
+ C.CL_INVALID_DEVICE: ErrInvalidDevice,
+ C.CL_INVALID_CONTEXT: ErrInvalidContext,
+ C.CL_INVALID_QUEUE_PROPERTIES: ErrInvalidQueueProperties,
+ C.CL_INVALID_COMMAND_QUEUE: ErrInvalidCommandQueue,
+ C.CL_INVALID_HOST_PTR: ErrInvalidHostPtr,
+ C.CL_INVALID_MEM_OBJECT: ErrInvalidMemObject,
+ C.CL_INVALID_IMAGE_FORMAT_DESCRIPTOR: ErrInvalidImageFormatDescriptor,
+ C.CL_INVALID_IMAGE_SIZE: ErrInvalidImageSize,
+ C.CL_INVALID_SAMPLER: ErrInvalidSampler,
+ C.CL_INVALID_BINARY: ErrInvalidBinary,
+ C.CL_INVALID_BUILD_OPTIONS: ErrInvalidBuildOptions,
+ C.CL_INVALID_PROGRAM: ErrInvalidProgram,
+ C.CL_INVALID_PROGRAM_EXECUTABLE: ErrInvalidProgramExecutable,
+ C.CL_INVALID_KERNEL_NAME: ErrInvalidKernelName,
+ C.CL_INVALID_KERNEL_DEFINITION: ErrInvalidKernelDefinition,
+ C.CL_INVALID_KERNEL: ErrInvalidKernel,
+ C.CL_INVALID_ARG_INDEX: ErrInvalidArgIndex,
+ C.CL_INVALID_ARG_VALUE: ErrInvalidArgValue,
+ C.CL_INVALID_ARG_SIZE: ErrInvalidArgSize,
+ C.CL_INVALID_KERNEL_ARGS: ErrInvalidKernelArgs,
+ C.CL_INVALID_WORK_DIMENSION: ErrInvalidWorkDimension,
+ C.CL_INVALID_WORK_GROUP_SIZE: ErrInvalidWorkGroupSize,
+ C.CL_INVALID_WORK_ITEM_SIZE: ErrInvalidWorkItemSize,
+ C.CL_INVALID_GLOBAL_OFFSET: ErrInvalidGlobalOffset,
+ C.CL_INVALID_EVENT_WAIT_LIST: ErrInvalidEventWaitList,
+ C.CL_INVALID_EVENT: ErrInvalidEvent,
+ C.CL_INVALID_OPERATION: ErrInvalidOperation,
+ C.CL_INVALID_GL_OBJECT: ErrInvalidGlObject,
+ C.CL_INVALID_BUFFER_SIZE: ErrInvalidBufferSize,
+ C.CL_INVALID_MIP_LEVEL: ErrInvalidMipLevel,
+ C.CL_INVALID_GLOBAL_WORK_SIZE: ErrInvalidGlobalWorkSize,
+ C.CL_INVALID_PROPERTY: ErrInvalidProperty,
+}
+
+func toError(code C.cl_int) error {
+ if err, ok := errorMap[code]; ok {
+ return err
+ }
+ return ErrOther(code)
+}
+
+type LocalMemType int
+
+const (
+ LocalMemTypeNone LocalMemType = C.CL_NONE
+ LocalMemTypeGlobal LocalMemType = C.CL_GLOBAL
+ LocalMemTypeLocal LocalMemType = C.CL_LOCAL
+)
+
+var localMemTypeMap = map[LocalMemType]string{
+ LocalMemTypeNone: "None",
+ LocalMemTypeGlobal: "Global",
+ LocalMemTypeLocal: "Local",
+}
+
+func (t LocalMemType) String() string {
+ name := localMemTypeMap[t]
+ if name == "" {
+ name = "Unknown"
+ }
+ return name
+}
+
+type ExecCapability int
+
+const (
+ ExecCapabilityKernel ExecCapability = C.CL_EXEC_KERNEL // The OpenCL device can execute OpenCL kernels.
+ ExecCapabilityNativeKernel ExecCapability = C.CL_EXEC_NATIVE_KERNEL // The OpenCL device can execute native kernels.
+)
+
+func (ec ExecCapability) String() string {
+ var parts []string
+ if ec&ExecCapabilityKernel != 0 {
+ parts = append(parts, "Kernel")
+ }
+ if ec&ExecCapabilityNativeKernel != 0 {
+ parts = append(parts, "NativeKernel")
+ }
+ if parts == nil {
+ return ""
+ }
+ return strings.Join(parts, "|")
+}
+
+type MemCacheType int
+
+const (
+ MemCacheTypeNone MemCacheType = C.CL_NONE
+ MemCacheTypeReadOnlyCache MemCacheType = C.CL_READ_ONLY_CACHE
+ MemCacheTypeReadWriteCache MemCacheType = C.CL_READ_WRITE_CACHE
+)
+
+func (ct MemCacheType) String() string {
+ switch ct {
+ case MemCacheTypeNone:
+ return "None"
+ case MemCacheTypeReadOnlyCache:
+ return "ReadOnly"
+ case MemCacheTypeReadWriteCache:
+ return "ReadWrite"
+ }
+ return fmt.Sprintf("Unknown(%x)", int(ct))
+}
+
+type MemFlag int
+
+const (
+ MemReadWrite MemFlag = C.CL_MEM_READ_WRITE
+ MemWriteOnly MemFlag = C.CL_MEM_WRITE_ONLY
+ MemReadOnly MemFlag = C.CL_MEM_READ_ONLY
+ MemUseHostPtr MemFlag = C.CL_MEM_USE_HOST_PTR
+ MemAllocHostPtr MemFlag = C.CL_MEM_ALLOC_HOST_PTR
+ MemCopyHostPtr MemFlag = C.CL_MEM_COPY_HOST_PTR
+
+ MemWriteOnlyHost MemFlag = C.CL_MEM_HOST_WRITE_ONLY
+ MemReadOnlyHost MemFlag = C.CL_MEM_HOST_READ_ONLY
+ MemNoAccessHost MemFlag = C.CL_MEM_HOST_NO_ACCESS
+)
+
+type MemObjectType int
+
+const (
+ MemObjectTypeBuffer MemObjectType = C.CL_MEM_OBJECT_BUFFER
+ MemObjectTypeImage2D MemObjectType = C.CL_MEM_OBJECT_IMAGE2D
+ MemObjectTypeImage3D MemObjectType = C.CL_MEM_OBJECT_IMAGE3D
+)
+
+type MapFlag int
+
+const (
+ // This flag specifies that the region being mapped in the memory object is being mapped for reading.
+ MapFlagRead MapFlag = C.CL_MAP_READ
+ MapFlagWrite MapFlag = C.CL_MAP_WRITE
+ MapFlagWriteInvalidateRegion MapFlag = C.CL_MAP_WRITE_INVALIDATE_REGION
+)
+
+func (mf MapFlag) toCl() C.cl_map_flags {
+ return C.cl_map_flags(mf)
+}
+
+type ChannelOrder int
+
+const (
+ ChannelOrderR ChannelOrder = C.CL_R
+ ChannelOrderA ChannelOrder = C.CL_A
+ ChannelOrderRG ChannelOrder = C.CL_RG
+ ChannelOrderRA ChannelOrder = C.CL_RA
+ ChannelOrderRGB ChannelOrder = C.CL_RGB
+ ChannelOrderRGBA ChannelOrder = C.CL_RGBA
+ ChannelOrderBGRA ChannelOrder = C.CL_BGRA
+ ChannelOrderARGB ChannelOrder = C.CL_ARGB
+ ChannelOrderIntensity ChannelOrder = C.CL_INTENSITY
+ ChannelOrderLuminance ChannelOrder = C.CL_LUMINANCE
+ ChannelOrderRx ChannelOrder = C.CL_Rx
+ ChannelOrderRGx ChannelOrder = C.CL_RGx
+ ChannelOrderRGBx ChannelOrder = C.CL_RGBx
+)
+
+var channelOrderNameMap = map[ChannelOrder]string{
+ ChannelOrderR: "R",
+ ChannelOrderA: "A",
+ ChannelOrderRG: "RG",
+ ChannelOrderRA: "RA",
+ ChannelOrderRGB: "RGB",
+ ChannelOrderRGBA: "RGBA",
+ ChannelOrderBGRA: "BGRA",
+ ChannelOrderARGB: "ARGB",
+ ChannelOrderIntensity: "Intensity",
+ ChannelOrderLuminance: "Luminance",
+ ChannelOrderRx: "Rx",
+ ChannelOrderRGx: "RGx",
+ ChannelOrderRGBx: "RGBx",
+}
+
+func (co ChannelOrder) String() string {
+ name := channelOrderNameMap[co]
+ if name == "" {
+ name = fmt.Sprintf("Unknown(%x)", int(co))
+ }
+ return name
+}
+
+type ChannelDataType int
+
+const (
+ ChannelDataTypeSNormInt8 ChannelDataType = C.CL_SNORM_INT8
+ ChannelDataTypeSNormInt16 ChannelDataType = C.CL_SNORM_INT16
+ ChannelDataTypeUNormInt8 ChannelDataType = C.CL_UNORM_INT8
+ ChannelDataTypeUNormInt16 ChannelDataType = C.CL_UNORM_INT16
+ ChannelDataTypeUNormShort565 ChannelDataType = C.CL_UNORM_SHORT_565
+ ChannelDataTypeUNormShort555 ChannelDataType = C.CL_UNORM_SHORT_555
+ ChannelDataTypeUNormInt101010 ChannelDataType = C.CL_UNORM_INT_101010
+ ChannelDataTypeSignedInt8 ChannelDataType = C.CL_SIGNED_INT8
+ ChannelDataTypeSignedInt16 ChannelDataType = C.CL_SIGNED_INT16
+ ChannelDataTypeSignedInt32 ChannelDataType = C.CL_SIGNED_INT32
+ ChannelDataTypeUnsignedInt8 ChannelDataType = C.CL_UNSIGNED_INT8
+ ChannelDataTypeUnsignedInt16 ChannelDataType = C.CL_UNSIGNED_INT16
+ ChannelDataTypeUnsignedInt32 ChannelDataType = C.CL_UNSIGNED_INT32
+ ChannelDataTypeHalfFloat ChannelDataType = C.CL_HALF_FLOAT
+ ChannelDataTypeFloat ChannelDataType = C.CL_FLOAT
+)
+
+var channelDataTypeNameMap = map[ChannelDataType]string{
+ ChannelDataTypeSNormInt8: "SNormInt8",
+ ChannelDataTypeSNormInt16: "SNormInt16",
+ ChannelDataTypeUNormInt8: "UNormInt8",
+ ChannelDataTypeUNormInt16: "UNormInt16",
+ ChannelDataTypeUNormShort565: "UNormShort565",
+ ChannelDataTypeUNormShort555: "UNormShort555",
+ ChannelDataTypeUNormInt101010: "UNormInt101010",
+ ChannelDataTypeSignedInt8: "SignedInt8",
+ ChannelDataTypeSignedInt16: "SignedInt16",
+ ChannelDataTypeSignedInt32: "SignedInt32",
+ ChannelDataTypeUnsignedInt8: "UnsignedInt8",
+ ChannelDataTypeUnsignedInt16: "UnsignedInt16",
+ ChannelDataTypeUnsignedInt32: "UnsignedInt32",
+ ChannelDataTypeHalfFloat: "HalfFloat",
+ ChannelDataTypeFloat: "Float",
+}
+
+func (ct ChannelDataType) String() string {
+ name := channelDataTypeNameMap[ct]
+ if name == "" {
+ name = fmt.Sprintf("Unknown(%x)", int(ct))
+ }
+ return name
+}
+
+type ImageFormat struct {
+ ChannelOrder ChannelOrder
+ ChannelDataType ChannelDataType
+}
+
+func (f ImageFormat) toCl() C.cl_image_format {
+ var format C.cl_image_format
+ format.image_channel_order = C.cl_channel_order(f.ChannelOrder)
+ format.image_channel_data_type = C.cl_channel_type(f.ChannelDataType)
+ return format
+}
+
+type ProfilingInfo int
+
+const (
+ // A 64-bit value that describes the current device time counter in
+ // nanoseconds when the command identified by event is enqueued in
+ // a command-queue by the host.
+ ProfilingInfoCommandQueued ProfilingInfo = C.CL_PROFILING_COMMAND_QUEUED
+ // A 64-bit value that describes the current device time counter in
+ // nanoseconds when the command identified by event that has been
+ // enqueued is submitted by the host to the device associated with the command-queue.
+ ProfilingInfoCommandSubmit ProfilingInfo = C.CL_PROFILING_COMMAND_SUBMIT
+ // A 64-bit value that describes the current device time counter in
+ // nanoseconds when the command identified by event starts execution on the device.
+ ProfilingInfoCommandStart ProfilingInfo = C.CL_PROFILING_COMMAND_START
+ // A 64-bit value that describes the current device time counter in
+ // nanoseconds when the command identified by event has finished
+ // execution on the device.
+ ProfilingInfoCommandEnd ProfilingInfo = C.CL_PROFILING_COMMAND_END
+)
+
+type CommmandExecStatus int
+
+const (
+ CommmandExecStatusComplete CommmandExecStatus = C.CL_COMPLETE
+ CommmandExecStatusRunning CommmandExecStatus = C.CL_RUNNING
+ CommmandExecStatusSubmitted CommmandExecStatus = C.CL_SUBMITTED
+ CommmandExecStatusQueued CommmandExecStatus = C.CL_QUEUED
+)
+
+type Event struct {
+ clEvent C.cl_event
+}
+
+func releaseEvent(ev *Event) {
+ if ev.clEvent != nil {
+ C.clReleaseEvent(ev.clEvent)
+ ev.clEvent = nil
+ }
+}
+
+func (e *Event) Release() {
+ releaseEvent(e)
+}
+
+func (e *Event) GetEventProfilingInfo(paramName ProfilingInfo) (int64, error) {
+ var paramValue C.cl_ulong
+ if err := C.clGetEventProfilingInfo(e.clEvent, C.cl_profiling_info(paramName), C.size_t(unsafe.Sizeof(paramValue)), unsafe.Pointer(&paramValue), nil); err != C.CL_SUCCESS {
+ return 0, toError(err)
+ }
+ return int64(paramValue), nil
+}
+
+// Sets the execution status of a user event object.
+//
+// `status` specifies the new execution status to be set and
+// can be CL_COMPLETE or a negative integer value to indicate
+// an error. A negative integer value causes all enqueued commands
+// that wait on this user event to be terminated. clSetUserEventStatus
+// can only be called once to change the execution status of event.
+func (e *Event) SetUserEventStatus(status int) error {
+ return toError(C.clSetUserEventStatus(e.clEvent, C.cl_int(status)))
+}
+
+// Waits on the host thread for commands identified by event objects in
+// events to complete. A command is considered complete if its execution
+// status is CL_COMPLETE or a negative value. The events specified in
+// event_list act as synchronization points.
+//
+// If the cl_khr_gl_event extension is enabled, event objects can also be
+// used to reflect the status of an OpenGL sync object. The sync object
+// in turn refers to a fence command executing in an OpenGL command
+// stream. This provides another method of coordinating sharing of buffers
+// and images between OpenGL and OpenCL.
+func WaitForEvents(events []*Event) error {
+ return toError(C.clWaitForEvents(C.cl_uint(len(events)), eventListPtr(events)))
+}
+
+func newEvent(clEvent C.cl_event) *Event {
+ ev := &Event{clEvent: clEvent}
+ runtime.SetFinalizer(ev, releaseEvent)
+ return ev
+}
+
+func eventListPtr(el []*Event) *C.cl_event {
+ if el == nil {
+ return nil
+ }
+ elist := make([]C.cl_event, len(el))
+ for i, e := range el {
+ elist[i] = e.clEvent
+ }
+ return (*C.cl_event)(&elist[0])
+}
+
+func clBool(b bool) C.cl_bool {
+ if b {
+ return C.CL_TRUE
+ }
+ return C.CL_FALSE
+}
+
+func sizeT3(i3 [3]int) [3]C.size_t {
+ var val [3]C.size_t
+ val[0] = C.size_t(i3[0])
+ val[1] = C.size_t(i3[1])
+ val[2] = C.size_t(i3[2])
+ return val
+}
+
+type MappedMemObject struct {
+ ptr unsafe.Pointer
+ size int
+ rowPitch int
+ slicePitch int
+}
+
+func (mb *MappedMemObject) ByteSlice() []byte {
+ var byteSlice []byte
+ sliceHeader := (*reflect.SliceHeader)(unsafe.Pointer(&byteSlice))
+ sliceHeader.Cap = mb.size
+ sliceHeader.Len = mb.size
+ sliceHeader.Data = uintptr(mb.ptr)
+ return byteSlice
+}
+
+func (mb *MappedMemObject) Ptr() unsafe.Pointer {
+ return mb.ptr
+}
+
+func (mb *MappedMemObject) Size() int {
+ return mb.size
+}
+
+func (mb *MappedMemObject) RowPitch() int {
+ return mb.rowPitch
+}
+
+func (mb *MappedMemObject) SlicePitch() int {
+ return mb.slicePitch
+}
diff --git a/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/types12.go b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/types12.go
new file mode 100644
index 000000000..58023cb60
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/types12.go
@@ -0,0 +1,71 @@
+// +build cl12
+
+package cl
+
+// #ifdef __APPLE__
+// #include "OpenCL/opencl.h"
+// #else
+// #include "cl.h"
+// #endif
+import "C"
+
+const (
+ ChannelDataTypeUNormInt24 ChannelDataType = C.CL_UNORM_INT24
+ ChannelOrderDepth ChannelOrder = C.CL_DEPTH
+ ChannelOrderDepthStencil ChannelOrder = C.CL_DEPTH_STENCIL
+ MemHostNoAccess MemFlag = C.CL_MEM_HOST_NO_ACCESS // OpenCL 1.2
+ MemHostReadOnly MemFlag = C.CL_MEM_HOST_READ_ONLY // OpenCL 1.2
+ MemHostWriteOnly MemFlag = C.CL_MEM_HOST_WRITE_ONLY // OpenCL 1.2
+ MemObjectTypeImage1D MemObjectType = C.CL_MEM_OBJECT_IMAGE1D
+ MemObjectTypeImage1DArray MemObjectType = C.CL_MEM_OBJECT_IMAGE1D_ARRAY
+ MemObjectTypeImage1DBuffer MemObjectType = C.CL_MEM_OBJECT_IMAGE1D_BUFFER
+ MemObjectTypeImage2DArray MemObjectType = C.CL_MEM_OBJECT_IMAGE2D_ARRAY
+ // This flag specifies that the region being mapped in the memory object is being mapped for writing.
+ //
+ // The contents of the region being mapped are to be discarded. This is typically the case when the
+ // region being mapped is overwritten by the host. This flag allows the implementation to no longer
+ // guarantee that the pointer returned by clEnqueueMapBuffer or clEnqueueMapImage contains the
+ // latest bits in the region being mapped which can be a significant performance enhancement.
+ MapFlagWriteInvalidateRegion MapFlag = C.CL_MAP_WRITE_INVALIDATE_REGION
+)
+
+func init() {
+ errorMap[C.CL_COMPILE_PROGRAM_FAILURE] = ErrCompileProgramFailure
+ errorMap[C.CL_DEVICE_PARTITION_FAILED] = ErrDevicePartitionFailed
+ errorMap[C.CL_INVALID_COMPILER_OPTIONS] = ErrInvalidCompilerOptions
+ errorMap[C.CL_INVALID_DEVICE_PARTITION_COUNT] = ErrInvalidDevicePartitionCount
+ errorMap[C.CL_INVALID_IMAGE_DESCRIPTOR] = ErrInvalidImageDescriptor
+ errorMap[C.CL_INVALID_LINKER_OPTIONS] = ErrInvalidLinkerOptions
+ errorMap[C.CL_KERNEL_ARG_INFO_NOT_AVAILABLE] = ErrKernelArgInfoNotAvailable
+ errorMap[C.CL_LINK_PROGRAM_FAILURE] = ErrLinkProgramFailure
+ errorMap[C.CL_LINKER_NOT_AVAILABLE] = ErrLinkerNotAvailable
+ channelOrderNameMap[ChannelOrderDepth] = "Depth"
+ channelOrderNameMap[ChannelOrderDepthStencil] = "DepthStencil"
+ channelDataTypeNameMap[ChannelDataTypeUNormInt24] = "UNormInt24"
+}
+
+type ImageDescription struct {
+ Type MemObjectType
+ Width, Height, Depth int
+ ArraySize, RowPitch, SlicePitch int
+ NumMipLevels, NumSamples int
+ Buffer *MemObject
+}
+
+func (d ImageDescription) toCl() C.cl_image_desc {
+ var desc C.cl_image_desc
+ desc.image_type = C.cl_mem_object_type(d.Type)
+ desc.image_width = C.size_t(d.Width)
+ desc.image_height = C.size_t(d.Height)
+ desc.image_depth = C.size_t(d.Depth)
+ desc.image_array_size = C.size_t(d.ArraySize)
+ desc.image_row_pitch = C.size_t(d.RowPitch)
+ desc.image_slice_pitch = C.size_t(d.SlicePitch)
+ desc.num_mip_levels = C.cl_uint(d.NumMipLevels)
+ desc.num_samples = C.cl_uint(d.NumSamples)
+ desc.buffer = nil
+ if d.Buffer != nil {
+ desc.buffer = d.Buffer.clMem
+ }
+ return desc
+}
diff --git a/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/types_darwin.go b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/types_darwin.go
new file mode 100644
index 000000000..ddcf74906
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/Gustav-Simonsson/go-opencl/cl/types_darwin.go
@@ -0,0 +1,45 @@
+package cl
+
+// #ifdef __APPLE__
+// #include "OpenCL/opencl.h"
+// #else
+// #include "cl.h"
+// #endif
+import "C"
+
+// Extension: cl_APPLE_fixed_alpha_channel_orders
+//
+// These selectors may be passed to clCreateImage2D() in the cl_image_format.image_channel_order field.
+// They are like CL_BGRA and CL_ARGB except that the alpha channel to be ignored. On calls to read_imagef,
+// the alpha will be 0xff (1.0f) if the sample falls in the image and 0 if it does not fall in the image.
+// On calls to write_imagef, the alpha value is ignored and 0xff (1.0f) is written. These formats are
+// currently only available for the CL_UNORM_INT8 cl_channel_type. They are intended to support legacy
+// image formats.
+const (
+ ChannelOrder1RGBApple ChannelOrder = C.CL_1RGB_APPLE // Introduced in MacOS X.7.
+ ChannelOrderBGR1Apple ChannelOrder = C.CL_BGR1_APPLE // Introduced in MacOS X.7.
+)
+
+// Extension: cl_APPLE_biased_fixed_point_image_formats
+//
+// This selector may be passed to clCreateImage2D() in the cl_image_format.image_channel_data_type field.
+// It defines a biased signed 1.14 fixed point storage format, with range [-1, 3). The conversion from
+// float to this fixed point format is defined as follows:
+//
+// ushort float_to_sfixed14( float x ){
+// int i = convert_int_sat_rte( x * 0x1.0p14f ); // scale [-1, 3.0) to [-16384, 3*16384), round to nearest integer
+// i = add_sat( i, 0x4000 ); // apply bias, to convert to [0, 65535) range
+// return convert_ushort_sat(i); // clamp to destination size
+// }
+//
+// The inverse conversion is the reverse process. The formats are currently only available on the CPU with
+// the CL_RGBA channel layout.
+const (
+ ChannelDataTypeSFixed14Apple ChannelDataType = C.CL_SFIXED14_APPLE // Introduced in MacOS X.7.
+)
+
+func init() {
+ channelOrderNameMap[ChannelOrder1RGBApple] = "1RGBApple"
+ channelOrderNameMap[ChannelOrderBGR1Apple] = "RGB1Apple"
+ channelDataTypeNameMap[ChannelDataTypeSFixed14Apple] = "SFixed14Apple"
+}
diff --git a/Godeps/_workspace/src/github.com/codegangsta/cli/.travis.yml b/Godeps/_workspace/src/github.com/codegangsta/cli/.travis.yml
index baf46abc6..34d39c871 100644
--- a/Godeps/_workspace/src/github.com/codegangsta/cli/.travis.yml
+++ b/Godeps/_workspace/src/github.com/codegangsta/cli/.travis.yml
@@ -1,5 +1,12 @@
language: go
-go: 1.1
+sudo: false
+
+go:
+- 1.0.3
+- 1.1.2
+- 1.2.2
+- 1.3.3
+- 1.4.2
script:
- go vet ./...
diff --git a/Godeps/_workspace/src/github.com/codegangsta/cli/README.md b/Godeps/_workspace/src/github.com/codegangsta/cli/README.md
index 4b3ddb0a3..234655710 100644
--- a/Godeps/_workspace/src/github.com/codegangsta/cli/README.md
+++ b/Godeps/_workspace/src/github.com/codegangsta/cli/README.md
@@ -1,18 +1,17 @@
+[![Coverage](http://gocover.io/_badge/github.com/codegangsta/cli?0)](http://gocover.io/github.com/codegangsta/cli)
[![Build Status](https://travis-ci.org/codegangsta/cli.png?branch=master)](https://travis-ci.org/codegangsta/cli)
+[![GoDoc](https://godoc.org/github.com/codegangsta/cli?status.svg)](https://godoc.org/github.com/codegangsta/cli)
# cli.go
-cli.go is simple, fast, and fun package for building command line apps in Go. The goal is to enable developers to write fast and distributable command line applications in an expressive way.
-
-You can view the API docs here:
-http://godoc.org/github.com/codegangsta/cli
+`cli.go` is simple, fast, and fun package for building command line apps in Go. The goal is to enable developers to write fast and distributable command line applications in an expressive way.
## Overview
Command line apps are usually so tiny that there is absolutely no reason why your code should *not* be self-documenting. Things like generating help text and parsing command flags/options should not hinder productivity when writing a command line app.
-**This is where cli.go comes into play.** cli.go makes command line programming fun, organized, and expressive!
+**This is where `cli.go` comes into play.** `cli.go` makes command line programming fun, organized, and expressive!
## Installation
-Make sure you have a working Go environment (go 1.1 is *required*). [See the install instructions](http://golang.org/doc/install.html).
+Make sure you have a working Go environment (go 1.1+ is *required*). [See the install instructions](http://golang.org/doc/install.html).
To install `cli.go`, simply run:
```
@@ -25,7 +24,7 @@ export PATH=$PATH:$GOPATH/bin
```
## Getting Started
-One of the philosophies behind cli.go is that an API should be playful and full of discovery. So a cli.go app can be as little as one line of code in `main()`.
+One of the philosophies behind `cli.go` is that an API should be playful and full of discovery. So a `cli.go` app can be as little as one line of code in `main()`.
``` go
package main
@@ -103,7 +102,8 @@ $ greet
Hello friend!
```
-cli.go also generates some bitchass help text:
+`cli.go` also generates neat help text:
+
```
$ greet help
NAME:
@@ -158,6 +158,8 @@ app.Action = func(c *cli.Context) {
...
```
+See full list of flags at http://godoc.org/github.com/codegangsta/cli
+
#### Alternate Names
You can set alternate (or short) names for flags by providing a comma-delimited list for the `Name`. e.g.
@@ -289,6 +291,21 @@ setting the `PROG` variable to the name of your program:
`PROG=myprogram source /.../cli/autocomplete/bash_autocomplete`
+#### To Distribute
+
+Copy `autocomplete/bash_autocomplete` into `/etc/bash_completion.d/` and rename
+it to the name of the program you wish to add autocomplete support for (or
+automatically install it there if you are distributing a package). Don't forget
+to source the file to make it active in the current shell.
+
+```
+ sudo cp src/bash_autocomplete /etc/bash_completion.d/<myprogram>
+ source /etc/bash_completion.d/<myprogram>
+```
+
+Alternatively, you can just document that users should source the generic
+`autocomplete/bash_autocomplete` in their bash configuration with `$PROG` set
+to the name of their program (as above).
## Contribution Guidelines
Feel free to put up a pull request to fix a bug or maybe add a feature. I will give it a code review and make sure that it does not break backwards compatibility. If I or any other collaborators agree that it is in line with the vision of the project, we will work with you to get the code into a mergeable state and merge it into the master branch.
diff --git a/Godeps/_workspace/src/github.com/codegangsta/cli/app.go b/Godeps/_workspace/src/github.com/codegangsta/cli/app.go
index cd2900519..9a15c0c03 100644
--- a/Godeps/_workspace/src/github.com/codegangsta/cli/app.go
+++ b/Godeps/_workspace/src/github.com/codegangsta/cli/app.go
@@ -5,19 +5,20 @@ import (
"io"
"io/ioutil"
"os"
- "strings"
- "text/tabwriter"
- "text/template"
"time"
)
// App is the main structure of a cli application. It is recomended that
-// and app be created with the cli.NewApp() function
+// an app be created with the cli.NewApp() function
type App struct {
// The name of the program. Defaults to os.Args[0]
Name string
+ // Full name of command for help, defaults to Name
+ HelpName string
// Description of the program.
Usage string
+ // Description of the program argument format.
+ ArgsUsage string
// Version of the program
Version string
// List of commands to execute
@@ -46,6 +47,8 @@ type App struct {
Compiled time.Time
// List of all authors who contributed
Authors []Author
+ // Copyright of the binary if any
+ Copyright string
// Name of Author (Note: Use App.Authors, this is deprecated)
Author string
// Email of Author (Note: Use App.Authors, this is deprecated)
@@ -68,6 +71,7 @@ func compileTime() time.Time {
func NewApp() *App {
return &App{
Name: os.Args[0],
+ HelpName: os.Args[0],
Usage: "A new cli application",
Version: "0.0.0",
BashComplete: DefaultAppComplete,
@@ -83,25 +87,14 @@ func (a *App) Run(arguments []string) (err error) {
a.Authors = append(a.Authors, Author{Name: a.Author, Email: a.Email})
}
- if HelpPrinter == nil {
- defer func() {
- HelpPrinter = nil
- }()
-
- HelpPrinter = func(templ string, data interface{}) {
- funcMap := template.FuncMap{
- "join": strings.Join,
- }
-
- w := tabwriter.NewWriter(a.Writer, 0, 8, 1, '\t', 0)
- t := template.Must(template.New("help").Funcs(funcMap).Parse(templ))
- err := t.Execute(w, data)
- if err != nil {
- panic(err)
- }
- w.Flush()
+ newCmds := []Command{}
+ for _, c := range a.Commands {
+ if c.HelpName == "" {
+ c.HelpName = fmt.Sprintf("%s %s", a.HelpName, c.Name)
}
+ newCmds = append(newCmds, c)
}
+ a.Commands = newCmds
// append help to commands
if a.Command(helpCommand.Name) == nil && !a.HideHelp {
@@ -127,17 +120,16 @@ func (a *App) Run(arguments []string) (err error) {
nerr := normalizeFlags(a.Flags, set)
if nerr != nil {
fmt.Fprintln(a.Writer, nerr)
- context := NewContext(a, set, set)
+ context := NewContext(a, set, nil)
ShowAppHelp(context)
- fmt.Fprintln(a.Writer)
return nerr
}
- context := NewContext(a, set, set)
+ context := NewContext(a, set, nil)
if err != nil {
- fmt.Fprintf(a.Writer, "Incorrect Usage.\n\n")
- ShowAppHelp(context)
+ fmt.Fprintln(a.Writer, "Incorrect Usage.")
fmt.Fprintln(a.Writer)
+ ShowAppHelp(context)
return err
}
@@ -145,20 +137,26 @@ func (a *App) Run(arguments []string) (err error) {
return nil
}
- if checkHelp(context) {
+ if !a.HideHelp && checkHelp(context) {
+ ShowAppHelp(context)
return nil
}
- if checkVersion(context) {
+ if !a.HideVersion && checkVersion(context) {
+ ShowVersion(context)
return nil
}
if a.After != nil {
defer func() {
- // err is always nil here.
- // There is a check to see if it is non-nil
- // just few lines before.
- err = a.After(context)
+ afterErr := a.After(context)
+ if afterErr != nil {
+ if err != nil {
+ err = NewMultiError(err, afterErr)
+ } else {
+ err = afterErr
+ }
+ }
}()
}
@@ -203,6 +201,15 @@ func (a *App) RunAsSubcommand(ctx *Context) (err error) {
}
}
+ newCmds := []Command{}
+ for _, c := range a.Commands {
+ if c.HelpName == "" {
+ c.HelpName = fmt.Sprintf("%s %s", a.HelpName, c.Name)
+ }
+ newCmds = append(newCmds, c)
+ }
+ a.Commands = newCmds
+
// append flags
if a.EnableBashCompletion {
a.appendFlag(BashCompletionFlag)
@@ -213,21 +220,22 @@ func (a *App) RunAsSubcommand(ctx *Context) (err error) {
set.SetOutput(ioutil.Discard)
err = set.Parse(ctx.Args().Tail())
nerr := normalizeFlags(a.Flags, set)
- context := NewContext(a, set, ctx.globalSet)
+ context := NewContext(a, set, ctx)
if nerr != nil {
fmt.Fprintln(a.Writer, nerr)
+ fmt.Fprintln(a.Writer)
if len(a.Commands) > 0 {
ShowSubcommandHelp(context)
} else {
ShowCommandHelp(ctx, context.Args().First())
}
- fmt.Fprintln(a.Writer)
return nerr
}
if err != nil {
- fmt.Fprintf(a.Writer, "Incorrect Usage.\n\n")
+ fmt.Fprintln(a.Writer, "Incorrect Usage.")
+ fmt.Fprintln(a.Writer)
ShowSubcommandHelp(context)
return err
}
@@ -248,10 +256,14 @@ func (a *App) RunAsSubcommand(ctx *Context) (err error) {
if a.After != nil {
defer func() {
- // err is always nil here.
- // There is a check to see if it is non-nil
- // just few lines before.
- err = a.After(context)
+ afterErr := a.After(context)
+ if afterErr != nil {
+ if err != nil {
+ err = NewMultiError(err, afterErr)
+ } else {
+ err = afterErr
+ }
+ }
}()
}
diff --git a/Godeps/_workspace/src/github.com/codegangsta/cli/app_test.go b/Godeps/_workspace/src/github.com/codegangsta/cli/app_test.go
deleted file mode 100644
index 4a40b89cd..000000000
--- a/Godeps/_workspace/src/github.com/codegangsta/cli/app_test.go
+++ /dev/null
@@ -1,622 +0,0 @@
-package cli_test
-
-import (
- "flag"
- "fmt"
- "os"
- "testing"
-
- "github.com/codegangsta/cli"
-)
-
-func ExampleApp() {
- // set args for examples sake
- os.Args = []string{"greet", "--name", "Jeremy"}
-
- app := cli.NewApp()
- app.Name = "greet"
- app.Flags = []cli.Flag{
- cli.StringFlag{Name: "name", Value: "bob", Usage: "a name to say"},
- }
- app.Action = func(c *cli.Context) {
- fmt.Printf("Hello %v\n", c.String("name"))
- }
- app.Author = "Harrison"
- app.Email = "harrison@lolwut.com"
- app.Authors = []cli.Author{cli.Author{Name: "Oliver Allen", Email: "oliver@toyshop.com"}}
- app.Run(os.Args)
- // Output:
- // Hello Jeremy
-}
-
-func ExampleAppSubcommand() {
- // set args for examples sake
- os.Args = []string{"say", "hi", "english", "--name", "Jeremy"}
- app := cli.NewApp()
- app.Name = "say"
- app.Commands = []cli.Command{
- {
- Name: "hello",
- Aliases: []string{"hi"},
- Usage: "use it to see a description",
- Description: "This is how we describe hello the function",
- Subcommands: []cli.Command{
- {
- Name: "english",
- Aliases: []string{"en"},
- Usage: "sends a greeting in english",
- Description: "greets someone in english",
- Flags: []cli.Flag{
- cli.StringFlag{
- Name: "name",
- Value: "Bob",
- Usage: "Name of the person to greet",
- },
- },
- Action: func(c *cli.Context) {
- fmt.Println("Hello,", c.String("name"))
- },
- },
- },
- },
- }
-
- app.Run(os.Args)
- // Output:
- // Hello, Jeremy
-}
-
-func ExampleAppHelp() {
- // set args for examples sake
- os.Args = []string{"greet", "h", "describeit"}
-
- app := cli.NewApp()
- app.Name = "greet"
- app.Flags = []cli.Flag{
- cli.StringFlag{Name: "name", Value: "bob", Usage: "a name to say"},
- }
- app.Commands = []cli.Command{
- {
- Name: "describeit",
- Aliases: []string{"d"},
- Usage: "use it to see a description",
- Description: "This is how we describe describeit the function",
- Action: func(c *cli.Context) {
- fmt.Printf("i like to describe things")
- },
- },
- }
- app.Run(os.Args)
- // Output:
- // NAME:
- // describeit - use it to see a description
- //
- // USAGE:
- // command describeit [arguments...]
- //
- // DESCRIPTION:
- // This is how we describe describeit the function
-}
-
-func ExampleAppBashComplete() {
- // set args for examples sake
- os.Args = []string{"greet", "--generate-bash-completion"}
-
- app := cli.NewApp()
- app.Name = "greet"
- app.EnableBashCompletion = true
- app.Commands = []cli.Command{
- {
- Name: "describeit",
- Aliases: []string{"d"},
- Usage: "use it to see a description",
- Description: "This is how we describe describeit the function",
- Action: func(c *cli.Context) {
- fmt.Printf("i like to describe things")
- },
- }, {
- Name: "next",
- Usage: "next example",
- Description: "more stuff to see when generating bash completion",
- Action: func(c *cli.Context) {
- fmt.Printf("the next example")
- },
- },
- }
-
- app.Run(os.Args)
- // Output:
- // describeit
- // d
- // next
- // help
- // h
-}
-
-func TestApp_Run(t *testing.T) {
- s := ""
-
- app := cli.NewApp()
- app.Action = func(c *cli.Context) {
- s = s + c.Args().First()
- }
-
- err := app.Run([]string{"command", "foo"})
- expect(t, err, nil)
- err = app.Run([]string{"command", "bar"})
- expect(t, err, nil)
- expect(t, s, "foobar")
-}
-
-var commandAppTests = []struct {
- name string
- expected bool
-}{
- {"foobar", true},
- {"batbaz", true},
- {"b", true},
- {"f", true},
- {"bat", false},
- {"nothing", false},
-}
-
-func TestApp_Command(t *testing.T) {
- app := cli.NewApp()
- fooCommand := cli.Command{Name: "foobar", Aliases: []string{"f"}}
- batCommand := cli.Command{Name: "batbaz", Aliases: []string{"b"}}
- app.Commands = []cli.Command{
- fooCommand,
- batCommand,
- }
-
- for _, test := range commandAppTests {
- expect(t, app.Command(test.name) != nil, test.expected)
- }
-}
-
-func TestApp_CommandWithArgBeforeFlags(t *testing.T) {
- var parsedOption, firstArg string
-
- app := cli.NewApp()
- command := cli.Command{
- Name: "cmd",
- Flags: []cli.Flag{
- cli.StringFlag{Name: "option", Value: "", Usage: "some option"},
- },
- Action: func(c *cli.Context) {
- parsedOption = c.String("option")
- firstArg = c.Args().First()
- },
- }
- app.Commands = []cli.Command{command}
-
- app.Run([]string{"", "cmd", "my-arg", "--option", "my-option"})
-
- expect(t, parsedOption, "my-option")
- expect(t, firstArg, "my-arg")
-}
-
-func TestApp_RunAsSubcommandParseFlags(t *testing.T) {
- var context *cli.Context
-
- a := cli.NewApp()
- a.Commands = []cli.Command{
- {
- Name: "foo",
- Action: func(c *cli.Context) {
- context = c
- },
- Flags: []cli.Flag{
- cli.StringFlag{
- Name: "lang",
- Value: "english",
- Usage: "language for the greeting",
- },
- },
- Before: func(_ *cli.Context) error { return nil },
- },
- }
- a.Run([]string{"", "foo", "--lang", "spanish", "abcd"})
-
- expect(t, context.Args().Get(0), "abcd")
- expect(t, context.String("lang"), "spanish")
-}
-
-func TestApp_CommandWithFlagBeforeTerminator(t *testing.T) {
- var parsedOption string
- var args []string
-
- app := cli.NewApp()
- command := cli.Command{
- Name: "cmd",
- Flags: []cli.Flag{
- cli.StringFlag{Name: "option", Value: "", Usage: "some option"},
- },
- Action: func(c *cli.Context) {
- parsedOption = c.String("option")
- args = c.Args()
- },
- }
- app.Commands = []cli.Command{command}
-
- app.Run([]string{"", "cmd", "my-arg", "--option", "my-option", "--", "--notARealFlag"})
-
- expect(t, parsedOption, "my-option")
- expect(t, args[0], "my-arg")
- expect(t, args[1], "--")
- expect(t, args[2], "--notARealFlag")
-}
-
-func TestApp_CommandWithNoFlagBeforeTerminator(t *testing.T) {
- var args []string
-
- app := cli.NewApp()
- command := cli.Command{
- Name: "cmd",
- Action: func(c *cli.Context) {
- args = c.Args()
- },
- }
- app.Commands = []cli.Command{command}
-
- app.Run([]string{"", "cmd", "my-arg", "--", "notAFlagAtAll"})
-
- expect(t, args[0], "my-arg")
- expect(t, args[1], "--")
- expect(t, args[2], "notAFlagAtAll")
-}
-
-func TestApp_Float64Flag(t *testing.T) {
- var meters float64
-
- app := cli.NewApp()
- app.Flags = []cli.Flag{
- cli.Float64Flag{Name: "height", Value: 1.5, Usage: "Set the height, in meters"},
- }
- app.Action = func(c *cli.Context) {
- meters = c.Float64("height")
- }
-
- app.Run([]string{"", "--height", "1.93"})
- expect(t, meters, 1.93)
-}
-
-func TestApp_ParseSliceFlags(t *testing.T) {
- var parsedOption, firstArg string
- var parsedIntSlice []int
- var parsedStringSlice []string
-
- app := cli.NewApp()
- command := cli.Command{
- Name: "cmd",
- Flags: []cli.Flag{
- cli.IntSliceFlag{Name: "p", Value: &cli.IntSlice{}, Usage: "set one or more ip addr"},
- cli.StringSliceFlag{Name: "ip", Value: &cli.StringSlice{}, Usage: "set one or more ports to open"},
- },
- Action: func(c *cli.Context) {
- parsedIntSlice = c.IntSlice("p")
- parsedStringSlice = c.StringSlice("ip")
- parsedOption = c.String("option")
- firstArg = c.Args().First()
- },
- }
- app.Commands = []cli.Command{command}
-
- app.Run([]string{"", "cmd", "my-arg", "-p", "22", "-p", "80", "-ip", "8.8.8.8", "-ip", "8.8.4.4"})
-
- IntsEquals := func(a, b []int) bool {
- if len(a) != len(b) {
- return false
- }
- for i, v := range a {
- if v != b[i] {
- return false
- }
- }
- return true
- }
-
- StrsEquals := func(a, b []string) bool {
- if len(a) != len(b) {
- return false
- }
- for i, v := range a {
- if v != b[i] {
- return false
- }
- }
- return true
- }
- var expectedIntSlice = []int{22, 80}
- var expectedStringSlice = []string{"8.8.8.8", "8.8.4.4"}
-
- if !IntsEquals(parsedIntSlice, expectedIntSlice) {
- t.Errorf("%v does not match %v", parsedIntSlice, expectedIntSlice)
- }
-
- if !StrsEquals(parsedStringSlice, expectedStringSlice) {
- t.Errorf("%v does not match %v", parsedStringSlice, expectedStringSlice)
- }
-}
-
-func TestApp_DefaultStdout(t *testing.T) {
- app := cli.NewApp()
-
- if app.Writer != os.Stdout {
- t.Error("Default output writer not set.")
- }
-}
-
-type mockWriter struct {
- written []byte
-}
-
-func (fw *mockWriter) Write(p []byte) (n int, err error) {
- if fw.written == nil {
- fw.written = p
- } else {
- fw.written = append(fw.written, p...)
- }
-
- return len(p), nil
-}
-
-func (fw *mockWriter) GetWritten() (b []byte) {
- return fw.written
-}
-
-func TestApp_SetStdout(t *testing.T) {
- w := &mockWriter{}
-
- app := cli.NewApp()
- app.Name = "test"
- app.Writer = w
-
- err := app.Run([]string{"help"})
-
- if err != nil {
- t.Fatalf("Run error: %s", err)
- }
-
- if len(w.written) == 0 {
- t.Error("App did not write output to desired writer.")
- }
-}
-
-func TestApp_BeforeFunc(t *testing.T) {
- beforeRun, subcommandRun := false, false
- beforeError := fmt.Errorf("fail")
- var err error
-
- app := cli.NewApp()
-
- app.Before = func(c *cli.Context) error {
- beforeRun = true
- s := c.String("opt")
- if s == "fail" {
- return beforeError
- }
-
- return nil
- }
-
- app.Commands = []cli.Command{
- cli.Command{
- Name: "sub",
- Action: func(c *cli.Context) {
- subcommandRun = true
- },
- },
- }
-
- app.Flags = []cli.Flag{
- cli.StringFlag{Name: "opt"},
- }
-
- // run with the Before() func succeeding
- err = app.Run([]string{"command", "--opt", "succeed", "sub"})
-
- if err != nil {
- t.Fatalf("Run error: %s", err)
- }
-
- if beforeRun == false {
- t.Errorf("Before() not executed when expected")
- }
-
- if subcommandRun == false {
- t.Errorf("Subcommand not executed when expected")
- }
-
- // reset
- beforeRun, subcommandRun = false, false
-
- // run with the Before() func failing
- err = app.Run([]string{"command", "--opt", "fail", "sub"})
-
- // should be the same error produced by the Before func
- if err != beforeError {
- t.Errorf("Run error expected, but not received")
- }
-
- if beforeRun == false {
- t.Errorf("Before() not executed when expected")
- }
-
- if subcommandRun == true {
- t.Errorf("Subcommand executed when NOT expected")
- }
-
-}
-
-func TestApp_AfterFunc(t *testing.T) {
- afterRun, subcommandRun := false, false
- afterError := fmt.Errorf("fail")
- var err error
-
- app := cli.NewApp()
-
- app.After = func(c *cli.Context) error {
- afterRun = true
- s := c.String("opt")
- if s == "fail" {
- return afterError
- }
-
- return nil
- }
-
- app.Commands = []cli.Command{
- cli.Command{
- Name: "sub",
- Action: func(c *cli.Context) {
- subcommandRun = true
- },
- },
- }
-
- app.Flags = []cli.Flag{
- cli.StringFlag{Name: "opt"},
- }
-
- // run with the After() func succeeding
- err = app.Run([]string{"command", "--opt", "succeed", "sub"})
-
- if err != nil {
- t.Fatalf("Run error: %s", err)
- }
-
- if afterRun == false {
- t.Errorf("After() not executed when expected")
- }
-
- if subcommandRun == false {
- t.Errorf("Subcommand not executed when expected")
- }
-
- // reset
- afterRun, subcommandRun = false, false
-
- // run with the Before() func failing
- err = app.Run([]string{"command", "--opt", "fail", "sub"})
-
- // should be the same error produced by the Before func
- if err != afterError {
- t.Errorf("Run error expected, but not received")
- }
-
- if afterRun == false {
- t.Errorf("After() not executed when expected")
- }
-
- if subcommandRun == false {
- t.Errorf("Subcommand not executed when expected")
- }
-}
-
-func TestAppNoHelpFlag(t *testing.T) {
- oldFlag := cli.HelpFlag
- defer func() {
- cli.HelpFlag = oldFlag
- }()
-
- cli.HelpFlag = cli.BoolFlag{}
-
- app := cli.NewApp()
- err := app.Run([]string{"test", "-h"})
-
- if err != flag.ErrHelp {
- t.Errorf("expected error about missing help flag, but got: %s (%T)", err, err)
- }
-}
-
-func TestAppHelpPrinter(t *testing.T) {
- oldPrinter := cli.HelpPrinter
- defer func() {
- cli.HelpPrinter = oldPrinter
- }()
-
- var wasCalled = false
- cli.HelpPrinter = func(template string, data interface{}) {
- wasCalled = true
- }
-
- app := cli.NewApp()
- app.Run([]string{"-h"})
-
- if wasCalled == false {
- t.Errorf("Help printer expected to be called, but was not")
- }
-}
-
-func TestAppVersionPrinter(t *testing.T) {
- oldPrinter := cli.VersionPrinter
- defer func() {
- cli.VersionPrinter = oldPrinter
- }()
-
- var wasCalled = false
- cli.VersionPrinter = func(c *cli.Context) {
- wasCalled = true
- }
-
- app := cli.NewApp()
- ctx := cli.NewContext(app, nil, nil)
- cli.ShowVersion(ctx)
-
- if wasCalled == false {
- t.Errorf("Version printer expected to be called, but was not")
- }
-}
-
-func TestAppCommandNotFound(t *testing.T) {
- beforeRun, subcommandRun := false, false
- app := cli.NewApp()
-
- app.CommandNotFound = func(c *cli.Context, command string) {
- beforeRun = true
- }
-
- app.Commands = []cli.Command{
- cli.Command{
- Name: "bar",
- Action: func(c *cli.Context) {
- subcommandRun = true
- },
- },
- }
-
- app.Run([]string{"command", "foo"})
-
- expect(t, beforeRun, true)
- expect(t, subcommandRun, false)
-}
-
-func TestGlobalFlagsInSubcommands(t *testing.T) {
- subcommandRun := false
- app := cli.NewApp()
-
- app.Flags = []cli.Flag{
- cli.BoolFlag{Name: "debug, d", Usage: "Enable debugging"},
- }
-
- app.Commands = []cli.Command{
- cli.Command{
- Name: "foo",
- Subcommands: []cli.Command{
- {
- Name: "bar",
- Action: func(c *cli.Context) {
- if c.GlobalBool("debug") {
- subcommandRun = true
- }
- },
- },
- },
- },
- }
-
- app.Run([]string{"command", "-d", "foo", "bar"})
-
- expect(t, subcommandRun, true)
-}
diff --git a/Godeps/_workspace/src/github.com/codegangsta/cli/autocomplete/bash_autocomplete b/Godeps/_workspace/src/github.com/codegangsta/cli/autocomplete/bash_autocomplete
index 9b55dd990..d9231f4cf 100644
--- a/Godeps/_workspace/src/github.com/codegangsta/cli/autocomplete/bash_autocomplete
+++ b/Godeps/_workspace/src/github.com/codegangsta/cli/autocomplete/bash_autocomplete
@@ -1,5 +1,7 @@
#! /bin/bash
+: ${PROG:=$(basename ${BASH_SOURCE})}
+
_cli_bash_autocomplete() {
local cur prev opts base
COMPREPLY=()
diff --git a/Godeps/_workspace/src/github.com/codegangsta/cli/cli.go b/Godeps/_workspace/src/github.com/codegangsta/cli/cli.go
index b74254581..31dc9124d 100644
--- a/Godeps/_workspace/src/github.com/codegangsta/cli/cli.go
+++ b/Godeps/_workspace/src/github.com/codegangsta/cli/cli.go
@@ -17,3 +17,24 @@
// app.Run(os.Args)
// }
package cli
+
+import (
+ "strings"
+)
+
+type MultiError struct {
+ Errors []error
+}
+
+func NewMultiError(err ...error) MultiError {
+ return MultiError{Errors: err}
+}
+
+func (m MultiError) Error() string {
+ errs := make([]string, len(m.Errors))
+ for i, err := range m.Errors {
+ errs[i] = err.Error()
+ }
+
+ return strings.Join(errs, "\n")
+}
diff --git a/Godeps/_workspace/src/github.com/codegangsta/cli/cli_test.go b/Godeps/_workspace/src/github.com/codegangsta/cli/cli_test.go
deleted file mode 100644
index 8a8df9736..000000000
--- a/Godeps/_workspace/src/github.com/codegangsta/cli/cli_test.go
+++ /dev/null
@@ -1,100 +0,0 @@
-package cli_test
-
-import (
- "os"
-
- "github.com/codegangsta/cli"
-)
-
-func Example() {
- app := cli.NewApp()
- app.Name = "todo"
- app.Usage = "task list on the command line"
- app.Commands = []cli.Command{
- {
- Name: "add",
- Aliases: []string{"a"},
- Usage: "add a task to the list",
- Action: func(c *cli.Context) {
- println("added task: ", c.Args().First())
- },
- },
- {
- Name: "complete",
- Aliases: []string{"c"},
- Usage: "complete a task on the list",
- Action: func(c *cli.Context) {
- println("completed task: ", c.Args().First())
- },
- },
- }
-
- app.Run(os.Args)
-}
-
-func ExampleSubcommand() {
- app := cli.NewApp()
- app.Name = "say"
- app.Commands = []cli.Command{
- {
- Name: "hello",
- Aliases: []string{"hi"},
- Usage: "use it to see a description",
- Description: "This is how we describe hello the function",
- Subcommands: []cli.Command{
- {
- Name: "english",
- Aliases: []string{"en"},
- Usage: "sends a greeting in english",
- Description: "greets someone in english",
- Flags: []cli.Flag{
- cli.StringFlag{
- Name: "name",
- Value: "Bob",
- Usage: "Name of the person to greet",
- },
- },
- Action: func(c *cli.Context) {
- println("Hello, ", c.String("name"))
- },
- }, {
- Name: "spanish",
- Aliases: []string{"sp"},
- Usage: "sends a greeting in spanish",
- Flags: []cli.Flag{
- cli.StringFlag{
- Name: "surname",
- Value: "Jones",
- Usage: "Surname of the person to greet",
- },
- },
- Action: func(c *cli.Context) {
- println("Hola, ", c.String("surname"))
- },
- }, {
- Name: "french",
- Aliases: []string{"fr"},
- Usage: "sends a greeting in french",
- Flags: []cli.Flag{
- cli.StringFlag{
- Name: "nickname",
- Value: "Stevie",
- Usage: "Nickname of the person to greet",
- },
- },
- Action: func(c *cli.Context) {
- println("Bonjour, ", c.String("nickname"))
- },
- },
- },
- }, {
- Name: "bye",
- Usage: "says goodbye",
- Action: func(c *cli.Context) {
- println("bye")
- },
- },
- }
-
- app.Run(os.Args)
-}
diff --git a/Godeps/_workspace/src/github.com/codegangsta/cli/command.go b/Godeps/_workspace/src/github.com/codegangsta/cli/command.go
index b61691c86..fac754deb 100644
--- a/Godeps/_workspace/src/github.com/codegangsta/cli/command.go
+++ b/Godeps/_workspace/src/github.com/codegangsta/cli/command.go
@@ -18,6 +18,8 @@ type Command struct {
Usage string
// A longer explanation of how the command works
Description string
+ // A short description of the arguments of this command
+ ArgsUsage string
// The function to call when checking for bash command completions
BashComplete func(context *Context)
// An action to execute before any sub-subcommands are run, but after the context is ready
@@ -36,11 +38,23 @@ type Command struct {
SkipFlagParsing bool
// Boolean to hide built-in help command
HideHelp bool
+
+ // Full name of command for help, defaults to full command name, including parent commands.
+ HelpName string
+ commandNamePath []string
+}
+
+// Returns the full name of the command.
+// For subcommands this ensures that parent commands are part of the command path
+func (c Command) FullName() string {
+ if c.commandNamePath == nil {
+ return c.Name
+ }
+ return strings.Join(c.commandNamePath, " ")
}
// Invokes the command given the context, parses ctx.Args() to generate command-specific flags
func (c Command) Run(ctx *Context) error {
-
if len(c.Subcommands) > 0 || c.Before != nil || c.After != nil {
return c.startApp(ctx)
}
@@ -91,9 +105,9 @@ func (c Command) Run(ctx *Context) error {
}
if err != nil {
- fmt.Fprint(ctx.App.Writer, "Incorrect Usage.\n\n")
- ShowCommandHelp(ctx, c.Name)
+ fmt.Fprintln(ctx.App.Writer, "Incorrect Usage.")
fmt.Fprintln(ctx.App.Writer)
+ ShowCommandHelp(ctx, c.Name)
return err
}
@@ -102,10 +116,9 @@ func (c Command) Run(ctx *Context) error {
fmt.Fprintln(ctx.App.Writer, nerr)
fmt.Fprintln(ctx.App.Writer)
ShowCommandHelp(ctx, c.Name)
- fmt.Fprintln(ctx.App.Writer)
return nerr
}
- context := NewContext(ctx.App, set, ctx.globalSet)
+ context := NewContext(ctx.App, set, ctx)
if checkCommandCompletions(context, c.Name) {
return nil
@@ -144,6 +157,12 @@ func (c Command) startApp(ctx *Context) error {
// set the name and usage
app.Name = fmt.Sprintf("%s %s", ctx.App.Name, c.Name)
+ if c.HelpName == "" {
+ app.HelpName = c.HelpName
+ } else {
+ app.HelpName = fmt.Sprintf("%s %s", ctx.App.Name, c.Name)
+ }
+
if c.Description != "" {
app.Usage = c.Description
} else {
@@ -158,6 +177,13 @@ func (c Command) startApp(ctx *Context) error {
app.Flags = c.Flags
app.HideHelp = c.HideHelp
+ app.Version = ctx.App.Version
+ app.HideVersion = ctx.App.HideVersion
+ app.Compiled = ctx.App.Compiled
+ app.Author = ctx.App.Author
+ app.Email = ctx.App.Email
+ app.Writer = ctx.App.Writer
+
// bash completion
app.EnableBashCompletion = ctx.App.EnableBashCompletion
if c.BashComplete != nil {
@@ -173,5 +199,12 @@ func (c Command) startApp(ctx *Context) error {
app.Action = helpSubcommand.Action
}
+ var newCmds []Command
+ for _, cc := range app.Commands {
+ cc.commandNamePath = []string{c.Name, cc.Name}
+ newCmds = append(newCmds, cc)
+ }
+ app.Commands = newCmds
+
return app.RunAsSubcommand(ctx)
}
diff --git a/Godeps/_workspace/src/github.com/codegangsta/cli/command_test.go b/Godeps/_workspace/src/github.com/codegangsta/cli/command_test.go
deleted file mode 100644
index 4125b0c1b..000000000
--- a/Godeps/_workspace/src/github.com/codegangsta/cli/command_test.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package cli_test
-
-import (
- "flag"
- "testing"
-
- "github.com/codegangsta/cli"
-)
-
-func TestCommandDoNotIgnoreFlags(t *testing.T) {
- app := cli.NewApp()
- set := flag.NewFlagSet("test", 0)
- test := []string{"blah", "blah", "-break"}
- set.Parse(test)
-
- c := cli.NewContext(app, set, set)
-
- command := cli.Command{
- Name: "test-cmd",
- Aliases: []string{"tc"},
- Usage: "this is for testing",
- Description: "testing",
- Action: func(_ *cli.Context) {},
- }
- err := command.Run(c)
-
- expect(t, err.Error(), "flag provided but not defined: -break")
-}
-
-func TestCommandIgnoreFlags(t *testing.T) {
- app := cli.NewApp()
- set := flag.NewFlagSet("test", 0)
- test := []string{"blah", "blah"}
- set.Parse(test)
-
- c := cli.NewContext(app, set, set)
-
- command := cli.Command{
- Name: "test-cmd",
- Aliases: []string{"tc"},
- Usage: "this is for testing",
- Description: "testing",
- Action: func(_ *cli.Context) {},
- SkipFlagParsing: true,
- }
- err := command.Run(c)
-
- expect(t, err, nil)
-}
diff --git a/Godeps/_workspace/src/github.com/codegangsta/cli/context.go b/Godeps/_workspace/src/github.com/codegangsta/cli/context.go
index 37221bdc2..f541f41c3 100644
--- a/Godeps/_workspace/src/github.com/codegangsta/cli/context.go
+++ b/Godeps/_workspace/src/github.com/codegangsta/cli/context.go
@@ -16,14 +16,14 @@ type Context struct {
App *App
Command Command
flagSet *flag.FlagSet
- globalSet *flag.FlagSet
setFlags map[string]bool
globalSetFlags map[string]bool
+ parentContext *Context
}
// Creates a new context. For use in when invoking an App or Command action.
-func NewContext(app *App, set *flag.FlagSet, globalSet *flag.FlagSet) *Context {
- return &Context{App: app, flagSet: set, globalSet: globalSet}
+func NewContext(app *App, set *flag.FlagSet, parentCtx *Context) *Context {
+ return &Context{App: app, flagSet: set, parentContext: parentCtx}
}
// Looks up the value of a local int flag, returns 0 if no int flag exists
@@ -73,37 +73,58 @@ func (c *Context) Generic(name string) interface{} {
// Looks up the value of a global int flag, returns 0 if no int flag exists
func (c *Context) GlobalInt(name string) int {
- return lookupInt(name, c.globalSet)
+ if fs := lookupGlobalFlagSet(name, c); fs != nil {
+ return lookupInt(name, fs)
+ }
+ return 0
}
// Looks up the value of a global time.Duration flag, returns 0 if no time.Duration flag exists
func (c *Context) GlobalDuration(name string) time.Duration {
- return lookupDuration(name, c.globalSet)
+ if fs := lookupGlobalFlagSet(name, c); fs != nil {
+ return lookupDuration(name, fs)
+ }
+ return 0
}
// Looks up the value of a global bool flag, returns false if no bool flag exists
func (c *Context) GlobalBool(name string) bool {
- return lookupBool(name, c.globalSet)
+ if fs := lookupGlobalFlagSet(name, c); fs != nil {
+ return lookupBool(name, fs)
+ }
+ return false
}
// Looks up the value of a global string flag, returns "" if no string flag exists
func (c *Context) GlobalString(name string) string {
- return lookupString(name, c.globalSet)
+ if fs := lookupGlobalFlagSet(name, c); fs != nil {
+ return lookupString(name, fs)
+ }
+ return ""
}
// Looks up the value of a global string slice flag, returns nil if no string slice flag exists
func (c *Context) GlobalStringSlice(name string) []string {
- return lookupStringSlice(name, c.globalSet)
+ if fs := lookupGlobalFlagSet(name, c); fs != nil {
+ return lookupStringSlice(name, fs)
+ }
+ return nil
}
// Looks up the value of a global int slice flag, returns nil if no int slice flag exists
func (c *Context) GlobalIntSlice(name string) []int {
- return lookupIntSlice(name, c.globalSet)
+ if fs := lookupGlobalFlagSet(name, c); fs != nil {
+ return lookupIntSlice(name, fs)
+ }
+ return nil
}
// Looks up the value of a global generic flag, returns nil if no generic flag exists
func (c *Context) GlobalGeneric(name string) interface{} {
- return lookupGeneric(name, c.globalSet)
+ if fs := lookupGlobalFlagSet(name, c); fs != nil {
+ return lookupGeneric(name, fs)
+ }
+ return nil
}
// Returns the number of flags set
@@ -126,11 +147,17 @@ func (c *Context) IsSet(name string) bool {
func (c *Context) GlobalIsSet(name string) bool {
if c.globalSetFlags == nil {
c.globalSetFlags = make(map[string]bool)
- c.globalSet.Visit(func(f *flag.Flag) {
- c.globalSetFlags[f.Name] = true
- })
+ ctx := c
+ if ctx.parentContext != nil {
+ ctx = ctx.parentContext
+ }
+ for ; ctx != nil && c.globalSetFlags[name] == false; ctx = ctx.parentContext {
+ ctx.flagSet.Visit(func(f *flag.Flag) {
+ c.globalSetFlags[f.Name] = true
+ })
+ }
}
- return c.globalSetFlags[name] == true
+ return c.globalSetFlags[name]
}
// Returns a slice of flag names used in this context.
@@ -157,6 +184,11 @@ func (c *Context) GlobalFlagNames() (names []string) {
return
}
+// Returns the parent context, if any
+func (c *Context) Parent() *Context {
+ return c.parentContext
+}
+
type Args []string
// Returns the command line arguments associated with the context.
@@ -201,6 +233,18 @@ func (a Args) Swap(from, to int) error {
return nil
}
+func lookupGlobalFlagSet(name string, ctx *Context) *flag.FlagSet {
+ if ctx.parentContext != nil {
+ ctx = ctx.parentContext
+ }
+ for ; ctx != nil; ctx = ctx.parentContext {
+ if f := ctx.flagSet.Lookup(name); f != nil {
+ return ctx.flagSet
+ }
+ }
+ return nil
+}
+
func lookupInt(name string, set *flag.FlagSet) int {
f := set.Lookup(name)
if f != nil {
diff --git a/Godeps/_workspace/src/github.com/codegangsta/cli/context_test.go b/Godeps/_workspace/src/github.com/codegangsta/cli/context_test.go
deleted file mode 100644
index d4a1877f0..000000000
--- a/Godeps/_workspace/src/github.com/codegangsta/cli/context_test.go
+++ /dev/null
@@ -1,111 +0,0 @@
-package cli_test
-
-import (
- "flag"
- "testing"
- "time"
-
- "github.com/codegangsta/cli"
-)
-
-func TestNewContext(t *testing.T) {
- set := flag.NewFlagSet("test", 0)
- set.Int("myflag", 12, "doc")
- globalSet := flag.NewFlagSet("test", 0)
- globalSet.Int("myflag", 42, "doc")
- command := cli.Command{Name: "mycommand"}
- c := cli.NewContext(nil, set, globalSet)
- c.Command = command
- expect(t, c.Int("myflag"), 12)
- expect(t, c.GlobalInt("myflag"), 42)
- expect(t, c.Command.Name, "mycommand")
-}
-
-func TestContext_Int(t *testing.T) {
- set := flag.NewFlagSet("test", 0)
- set.Int("myflag", 12, "doc")
- c := cli.NewContext(nil, set, set)
- expect(t, c.Int("myflag"), 12)
-}
-
-func TestContext_Duration(t *testing.T) {
- set := flag.NewFlagSet("test", 0)
- set.Duration("myflag", time.Duration(12*time.Second), "doc")
- c := cli.NewContext(nil, set, set)
- expect(t, c.Duration("myflag"), time.Duration(12*time.Second))
-}
-
-func TestContext_String(t *testing.T) {
- set := flag.NewFlagSet("test", 0)
- set.String("myflag", "hello world", "doc")
- c := cli.NewContext(nil, set, set)
- expect(t, c.String("myflag"), "hello world")
-}
-
-func TestContext_Bool(t *testing.T) {
- set := flag.NewFlagSet("test", 0)
- set.Bool("myflag", false, "doc")
- c := cli.NewContext(nil, set, set)
- expect(t, c.Bool("myflag"), false)
-}
-
-func TestContext_BoolT(t *testing.T) {
- set := flag.NewFlagSet("test", 0)
- set.Bool("myflag", true, "doc")
- c := cli.NewContext(nil, set, set)
- expect(t, c.BoolT("myflag"), true)
-}
-
-func TestContext_Args(t *testing.T) {
- set := flag.NewFlagSet("test", 0)
- set.Bool("myflag", false, "doc")
- c := cli.NewContext(nil, set, set)
- set.Parse([]string{"--myflag", "bat", "baz"})
- expect(t, len(c.Args()), 2)
- expect(t, c.Bool("myflag"), true)
-}
-
-func TestContext_IsSet(t *testing.T) {
- set := flag.NewFlagSet("test", 0)
- set.Bool("myflag", false, "doc")
- set.String("otherflag", "hello world", "doc")
- globalSet := flag.NewFlagSet("test", 0)
- globalSet.Bool("myflagGlobal", true, "doc")
- c := cli.NewContext(nil, set, globalSet)
- set.Parse([]string{"--myflag", "bat", "baz"})
- globalSet.Parse([]string{"--myflagGlobal", "bat", "baz"})
- expect(t, c.IsSet("myflag"), true)
- expect(t, c.IsSet("otherflag"), false)
- expect(t, c.IsSet("bogusflag"), false)
- expect(t, c.IsSet("myflagGlobal"), false)
-}
-
-func TestContext_GlobalIsSet(t *testing.T) {
- set := flag.NewFlagSet("test", 0)
- set.Bool("myflag", false, "doc")
- set.String("otherflag", "hello world", "doc")
- globalSet := flag.NewFlagSet("test", 0)
- globalSet.Bool("myflagGlobal", true, "doc")
- globalSet.Bool("myflagGlobalUnset", true, "doc")
- c := cli.NewContext(nil, set, globalSet)
- set.Parse([]string{"--myflag", "bat", "baz"})
- globalSet.Parse([]string{"--myflagGlobal", "bat", "baz"})
- expect(t, c.GlobalIsSet("myflag"), false)
- expect(t, c.GlobalIsSet("otherflag"), false)
- expect(t, c.GlobalIsSet("bogusflag"), false)
- expect(t, c.GlobalIsSet("myflagGlobal"), true)
- expect(t, c.GlobalIsSet("myflagGlobalUnset"), false)
- expect(t, c.GlobalIsSet("bogusGlobal"), false)
-}
-
-func TestContext_NumFlags(t *testing.T) {
- set := flag.NewFlagSet("test", 0)
- set.Bool("myflag", false, "doc")
- set.String("otherflag", "hello world", "doc")
- globalSet := flag.NewFlagSet("test", 0)
- globalSet.Bool("myflagGlobal", true, "doc")
- c := cli.NewContext(nil, set, globalSet)
- set.Parse([]string{"--myflag", "--otherflag=foo"})
- globalSet.Parse([]string{"--myflagGlobal"})
- expect(t, c.NumFlags(), 2)
-}
diff --git a/Godeps/_workspace/src/github.com/codegangsta/cli/flag.go b/Godeps/_workspace/src/github.com/codegangsta/cli/flag.go
index 251158667..531b09130 100644
--- a/Godeps/_workspace/src/github.com/codegangsta/cli/flag.go
+++ b/Godeps/_workspace/src/github.com/codegangsta/cli/flag.go
@@ -99,21 +99,27 @@ func (f GenericFlag) getName() string {
return f.Name
}
+// StringSlice is an opaque type for []string to satisfy flag.Value
type StringSlice []string
+// Set appends the string value to the list of values
func (f *StringSlice) Set(value string) error {
*f = append(*f, value)
return nil
}
+// String returns a readable representation of this value (for usage defaults)
func (f *StringSlice) String() string {
return fmt.Sprintf("%s", *f)
}
+// Value returns the slice of strings set by this flag
func (f *StringSlice) Value() []string {
return *f
}
+// StringSlice is a string flag that can be specified multiple times on the
+// command-line
type StringSliceFlag struct {
Name string
Value *StringSlice
@@ -121,12 +127,14 @@ type StringSliceFlag struct {
EnvVar string
}
+// String returns the usage
func (f StringSliceFlag) String() string {
firstName := strings.Trim(strings.Split(f.Name, ",")[0], " ")
pref := prefixFor(firstName)
return withEnvHint(f.EnvVar, fmt.Sprintf("%s [%v]\t%v", prefixedNames(f.Name), pref+firstName+" option "+pref+firstName+" option", f.Usage))
}
+// Apply populates the flag given the flag set and environment
func (f StringSliceFlag) Apply(set *flag.FlagSet) {
if f.EnvVar != "" {
for _, envVar := range strings.Split(f.EnvVar, ",") {
@@ -144,6 +152,9 @@ func (f StringSliceFlag) Apply(set *flag.FlagSet) {
}
eachName(f.Name, func(name string) {
+ if f.Value == nil {
+ f.Value = &StringSlice{}
+ }
set.Var(f.Value, name, f.Usage)
})
}
@@ -152,10 +163,11 @@ func (f StringSliceFlag) getName() string {
return f.Name
}
+// StringSlice is an opaque type for []int to satisfy flag.Value
type IntSlice []int
+// Set parses the value into an integer and appends it to the list of values
func (f *IntSlice) Set(value string) error {
-
tmp, err := strconv.Atoi(value)
if err != nil {
return err
@@ -165,14 +177,18 @@ func (f *IntSlice) Set(value string) error {
return nil
}
+// String returns a readable representation of this value (for usage defaults)
func (f *IntSlice) String() string {
return fmt.Sprintf("%d", *f)
}
+// Value returns the slice of ints set by this flag
func (f *IntSlice) Value() []int {
return *f
}
+// IntSliceFlag is an int flag that can be specified multiple times on the
+// command-line
type IntSliceFlag struct {
Name string
Value *IntSlice
@@ -180,12 +196,14 @@ type IntSliceFlag struct {
EnvVar string
}
+// String returns the usage
func (f IntSliceFlag) String() string {
firstName := strings.Trim(strings.Split(f.Name, ",")[0], " ")
pref := prefixFor(firstName)
return withEnvHint(f.EnvVar, fmt.Sprintf("%s [%v]\t%v", prefixedNames(f.Name), pref+firstName+" option "+pref+firstName+" option", f.Usage))
}
+// Apply populates the flag given the flag set and environment
func (f IntSliceFlag) Apply(set *flag.FlagSet) {
if f.EnvVar != "" {
for _, envVar := range strings.Split(f.EnvVar, ",") {
@@ -206,6 +224,9 @@ func (f IntSliceFlag) Apply(set *flag.FlagSet) {
}
eachName(f.Name, func(name string) {
+ if f.Value == nil {
+ f.Value = &IntSlice{}
+ }
set.Var(f.Value, name, f.Usage)
})
}
@@ -214,16 +235,19 @@ func (f IntSliceFlag) getName() string {
return f.Name
}
+// BoolFlag is a switch that defaults to false
type BoolFlag struct {
Name string
Usage string
EnvVar string
}
+// String returns a readable representation of this value (for usage defaults)
func (f BoolFlag) String() string {
return withEnvHint(f.EnvVar, fmt.Sprintf("%s\t%v", prefixedNames(f.Name), f.Usage))
}
+// Apply populates the flag given the flag set and environment
func (f BoolFlag) Apply(set *flag.FlagSet) {
val := false
if f.EnvVar != "" {
@@ -248,16 +272,20 @@ func (f BoolFlag) getName() string {
return f.Name
}
+// BoolTFlag this represents a boolean flag that is true by default, but can
+// still be set to false by --some-flag=false
type BoolTFlag struct {
Name string
Usage string
EnvVar string
}
+// String returns a readable representation of this value (for usage defaults)
func (f BoolTFlag) String() string {
return withEnvHint(f.EnvVar, fmt.Sprintf("%s\t%v", prefixedNames(f.Name), f.Usage))
}
+// Apply populates the flag given the flag set and environment
func (f BoolTFlag) Apply(set *flag.FlagSet) {
val := true
if f.EnvVar != "" {
@@ -282,6 +310,7 @@ func (f BoolTFlag) getName() string {
return f.Name
}
+// StringFlag represents a flag that takes as string value
type StringFlag struct {
Name string
Value string
@@ -289,6 +318,7 @@ type StringFlag struct {
EnvVar string
}
+// String returns the usage
func (f StringFlag) String() string {
var fmtString string
fmtString = "%s %v\t%v"
@@ -302,6 +332,7 @@ func (f StringFlag) String() string {
return withEnvHint(f.EnvVar, fmt.Sprintf(fmtString, prefixedNames(f.Name), f.Value, f.Usage))
}
+// Apply populates the flag given the flag set and environment
func (f StringFlag) Apply(set *flag.FlagSet) {
if f.EnvVar != "" {
for _, envVar := range strings.Split(f.EnvVar, ",") {
@@ -322,6 +353,8 @@ func (f StringFlag) getName() string {
return f.Name
}
+// IntFlag is a flag that takes an integer
+// Errors if the value provided cannot be parsed
type IntFlag struct {
Name string
Value int
@@ -329,10 +362,12 @@ type IntFlag struct {
EnvVar string
}
+// String returns the usage
func (f IntFlag) String() string {
return withEnvHint(f.EnvVar, fmt.Sprintf("%s \"%v\"\t%v", prefixedNames(f.Name), f.Value, f.Usage))
}
+// Apply populates the flag given the flag set and environment
func (f IntFlag) Apply(set *flag.FlagSet) {
if f.EnvVar != "" {
for _, envVar := range strings.Split(f.EnvVar, ",") {
@@ -356,6 +391,8 @@ func (f IntFlag) getName() string {
return f.Name
}
+// DurationFlag is a flag that takes a duration specified in Go's duration
+// format: https://golang.org/pkg/time/#ParseDuration
type DurationFlag struct {
Name string
Value time.Duration
@@ -363,10 +400,12 @@ type DurationFlag struct {
EnvVar string
}
+// String returns a readable representation of this value (for usage defaults)
func (f DurationFlag) String() string {
return withEnvHint(f.EnvVar, fmt.Sprintf("%s \"%v\"\t%v", prefixedNames(f.Name), f.Value, f.Usage))
}
+// Apply populates the flag given the flag set and environment
func (f DurationFlag) Apply(set *flag.FlagSet) {
if f.EnvVar != "" {
for _, envVar := range strings.Split(f.EnvVar, ",") {
@@ -390,6 +429,8 @@ func (f DurationFlag) getName() string {
return f.Name
}
+// Float64Flag is a flag that takes an float value
+// Errors if the value provided cannot be parsed
type Float64Flag struct {
Name string
Value float64
@@ -397,10 +438,12 @@ type Float64Flag struct {
EnvVar string
}
+// String returns the usage
func (f Float64Flag) String() string {
return withEnvHint(f.EnvVar, fmt.Sprintf("%s \"%v\"\t%v", prefixedNames(f.Name), f.Value, f.Usage))
}
+// Apply populates the flag given the flag set and environment
func (f Float64Flag) Apply(set *flag.FlagSet) {
if f.EnvVar != "" {
for _, envVar := range strings.Split(f.EnvVar, ",") {
diff --git a/Godeps/_workspace/src/github.com/codegangsta/cli/flag_test.go b/Godeps/_workspace/src/github.com/codegangsta/cli/flag_test.go
deleted file mode 100644
index f0f096a2d..000000000
--- a/Godeps/_workspace/src/github.com/codegangsta/cli/flag_test.go
+++ /dev/null
@@ -1,742 +0,0 @@
-package cli_test
-
-import (
- "fmt"
- "os"
- "reflect"
- "strings"
- "testing"
-
- "github.com/codegangsta/cli"
-)
-
-var boolFlagTests = []struct {
- name string
- expected string
-}{
- {"help", "--help\t"},
- {"h", "-h\t"},
-}
-
-func TestBoolFlagHelpOutput(t *testing.T) {
-
- for _, test := range boolFlagTests {
- flag := cli.BoolFlag{Name: test.name}
- output := flag.String()
-
- if output != test.expected {
- t.Errorf("%s does not match %s", output, test.expected)
- }
- }
-}
-
-var stringFlagTests = []struct {
- name string
- value string
- expected string
-}{
- {"help", "", "--help \t"},
- {"h", "", "-h \t"},
- {"h", "", "-h \t"},
- {"test", "Something", "--test \"Something\"\t"},
-}
-
-func TestStringFlagHelpOutput(t *testing.T) {
-
- for _, test := range stringFlagTests {
- flag := cli.StringFlag{Name: test.name, Value: test.value}
- output := flag.String()
-
- if output != test.expected {
- t.Errorf("%s does not match %s", output, test.expected)
- }
- }
-}
-
-func TestStringFlagWithEnvVarHelpOutput(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_FOO", "derp")
- for _, test := range stringFlagTests {
- flag := cli.StringFlag{Name: test.name, Value: test.value, EnvVar: "APP_FOO"}
- output := flag.String()
-
- if !strings.HasSuffix(output, " [$APP_FOO]") {
- t.Errorf("%s does not end with [$APP_FOO]", output)
- }
- }
-}
-
-var stringSliceFlagTests = []struct {
- name string
- value *cli.StringSlice
- expected string
-}{
- {"help", func() *cli.StringSlice {
- s := &cli.StringSlice{}
- s.Set("")
- return s
- }(), "--help [--help option --help option]\t"},
- {"h", func() *cli.StringSlice {
- s := &cli.StringSlice{}
- s.Set("")
- return s
- }(), "-h [-h option -h option]\t"},
- {"h", func() *cli.StringSlice {
- s := &cli.StringSlice{}
- s.Set("")
- return s
- }(), "-h [-h option -h option]\t"},
- {"test", func() *cli.StringSlice {
- s := &cli.StringSlice{}
- s.Set("Something")
- return s
- }(), "--test [--test option --test option]\t"},
-}
-
-func TestStringSliceFlagHelpOutput(t *testing.T) {
-
- for _, test := range stringSliceFlagTests {
- flag := cli.StringSliceFlag{Name: test.name, Value: test.value}
- output := flag.String()
-
- if output != test.expected {
- t.Errorf("%q does not match %q", output, test.expected)
- }
- }
-}
-
-func TestStringSliceFlagWithEnvVarHelpOutput(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_QWWX", "11,4")
- for _, test := range stringSliceFlagTests {
- flag := cli.StringSliceFlag{Name: test.name, Value: test.value, EnvVar: "APP_QWWX"}
- output := flag.String()
-
- if !strings.HasSuffix(output, " [$APP_QWWX]") {
- t.Errorf("%q does not end with [$APP_QWWX]", output)
- }
- }
-}
-
-var intFlagTests = []struct {
- name string
- expected string
-}{
- {"help", "--help \"0\"\t"},
- {"h", "-h \"0\"\t"},
-}
-
-func TestIntFlagHelpOutput(t *testing.T) {
-
- for _, test := range intFlagTests {
- flag := cli.IntFlag{Name: test.name}
- output := flag.String()
-
- if output != test.expected {
- t.Errorf("%s does not match %s", output, test.expected)
- }
- }
-}
-
-func TestIntFlagWithEnvVarHelpOutput(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_BAR", "2")
- for _, test := range intFlagTests {
- flag := cli.IntFlag{Name: test.name, EnvVar: "APP_BAR"}
- output := flag.String()
-
- if !strings.HasSuffix(output, " [$APP_BAR]") {
- t.Errorf("%s does not end with [$APP_BAR]", output)
- }
- }
-}
-
-var durationFlagTests = []struct {
- name string
- expected string
-}{
- {"help", "--help \"0\"\t"},
- {"h", "-h \"0\"\t"},
-}
-
-func TestDurationFlagHelpOutput(t *testing.T) {
-
- for _, test := range durationFlagTests {
- flag := cli.DurationFlag{Name: test.name}
- output := flag.String()
-
- if output != test.expected {
- t.Errorf("%s does not match %s", output, test.expected)
- }
- }
-}
-
-func TestDurationFlagWithEnvVarHelpOutput(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_BAR", "2h3m6s")
- for _, test := range durationFlagTests {
- flag := cli.DurationFlag{Name: test.name, EnvVar: "APP_BAR"}
- output := flag.String()
-
- if !strings.HasSuffix(output, " [$APP_BAR]") {
- t.Errorf("%s does not end with [$APP_BAR]", output)
- }
- }
-}
-
-var intSliceFlagTests = []struct {
- name string
- value *cli.IntSlice
- expected string
-}{
- {"help", &cli.IntSlice{}, "--help [--help option --help option]\t"},
- {"h", &cli.IntSlice{}, "-h [-h option -h option]\t"},
- {"h", &cli.IntSlice{}, "-h [-h option -h option]\t"},
- {"test", func() *cli.IntSlice {
- i := &cli.IntSlice{}
- i.Set("9")
- return i
- }(), "--test [--test option --test option]\t"},
-}
-
-func TestIntSliceFlagHelpOutput(t *testing.T) {
-
- for _, test := range intSliceFlagTests {
- flag := cli.IntSliceFlag{Name: test.name, Value: test.value}
- output := flag.String()
-
- if output != test.expected {
- t.Errorf("%q does not match %q", output, test.expected)
- }
- }
-}
-
-func TestIntSliceFlagWithEnvVarHelpOutput(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_SMURF", "42,3")
- for _, test := range intSliceFlagTests {
- flag := cli.IntSliceFlag{Name: test.name, Value: test.value, EnvVar: "APP_SMURF"}
- output := flag.String()
-
- if !strings.HasSuffix(output, " [$APP_SMURF]") {
- t.Errorf("%q does not end with [$APP_SMURF]", output)
- }
- }
-}
-
-var float64FlagTests = []struct {
- name string
- expected string
-}{
- {"help", "--help \"0\"\t"},
- {"h", "-h \"0\"\t"},
-}
-
-func TestFloat64FlagHelpOutput(t *testing.T) {
-
- for _, test := range float64FlagTests {
- flag := cli.Float64Flag{Name: test.name}
- output := flag.String()
-
- if output != test.expected {
- t.Errorf("%s does not match %s", output, test.expected)
- }
- }
-}
-
-func TestFloat64FlagWithEnvVarHelpOutput(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_BAZ", "99.4")
- for _, test := range float64FlagTests {
- flag := cli.Float64Flag{Name: test.name, EnvVar: "APP_BAZ"}
- output := flag.String()
-
- if !strings.HasSuffix(output, " [$APP_BAZ]") {
- t.Errorf("%s does not end with [$APP_BAZ]", output)
- }
- }
-}
-
-var genericFlagTests = []struct {
- name string
- value cli.Generic
- expected string
-}{
- {"test", &Parser{"abc", "def"}, "--test \"abc,def\"\ttest flag"},
- {"t", &Parser{"abc", "def"}, "-t \"abc,def\"\ttest flag"},
-}
-
-func TestGenericFlagHelpOutput(t *testing.T) {
-
- for _, test := range genericFlagTests {
- flag := cli.GenericFlag{Name: test.name, Value: test.value, Usage: "test flag"}
- output := flag.String()
-
- if output != test.expected {
- t.Errorf("%q does not match %q", output, test.expected)
- }
- }
-}
-
-func TestGenericFlagWithEnvVarHelpOutput(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_ZAP", "3")
- for _, test := range genericFlagTests {
- flag := cli.GenericFlag{Name: test.name, EnvVar: "APP_ZAP"}
- output := flag.String()
-
- if !strings.HasSuffix(output, " [$APP_ZAP]") {
- t.Errorf("%s does not end with [$APP_ZAP]", output)
- }
- }
-}
-
-func TestParseMultiString(t *testing.T) {
- (&cli.App{
- Flags: []cli.Flag{
- cli.StringFlag{Name: "serve, s"},
- },
- Action: func(ctx *cli.Context) {
- if ctx.String("serve") != "10" {
- t.Errorf("main name not set")
- }
- if ctx.String("s") != "10" {
- t.Errorf("short name not set")
- }
- },
- }).Run([]string{"run", "-s", "10"})
-}
-
-func TestParseMultiStringFromEnv(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_COUNT", "20")
- (&cli.App{
- Flags: []cli.Flag{
- cli.StringFlag{Name: "count, c", EnvVar: "APP_COUNT"},
- },
- Action: func(ctx *cli.Context) {
- if ctx.String("count") != "20" {
- t.Errorf("main name not set")
- }
- if ctx.String("c") != "20" {
- t.Errorf("short name not set")
- }
- },
- }).Run([]string{"run"})
-}
-
-func TestParseMultiStringFromEnvCascade(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_COUNT", "20")
- (&cli.App{
- Flags: []cli.Flag{
- cli.StringFlag{Name: "count, c", EnvVar: "COMPAT_COUNT,APP_COUNT"},
- },
- Action: func(ctx *cli.Context) {
- if ctx.String("count") != "20" {
- t.Errorf("main name not set")
- }
- if ctx.String("c") != "20" {
- t.Errorf("short name not set")
- }
- },
- }).Run([]string{"run"})
-}
-
-func TestParseMultiStringSlice(t *testing.T) {
- (&cli.App{
- Flags: []cli.Flag{
- cli.StringSliceFlag{Name: "serve, s", Value: &cli.StringSlice{}},
- },
- Action: func(ctx *cli.Context) {
- if !reflect.DeepEqual(ctx.StringSlice("serve"), []string{"10", "20"}) {
- t.Errorf("main name not set")
- }
- if !reflect.DeepEqual(ctx.StringSlice("s"), []string{"10", "20"}) {
- t.Errorf("short name not set")
- }
- },
- }).Run([]string{"run", "-s", "10", "-s", "20"})
-}
-
-func TestParseMultiStringSliceFromEnv(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_INTERVALS", "20,30,40")
-
- (&cli.App{
- Flags: []cli.Flag{
- cli.StringSliceFlag{Name: "intervals, i", Value: &cli.StringSlice{}, EnvVar: "APP_INTERVALS"},
- },
- Action: func(ctx *cli.Context) {
- if !reflect.DeepEqual(ctx.StringSlice("intervals"), []string{"20", "30", "40"}) {
- t.Errorf("main name not set from env")
- }
- if !reflect.DeepEqual(ctx.StringSlice("i"), []string{"20", "30", "40"}) {
- t.Errorf("short name not set from env")
- }
- },
- }).Run([]string{"run"})
-}
-
-func TestParseMultiStringSliceFromEnvCascade(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_INTERVALS", "20,30,40")
-
- (&cli.App{
- Flags: []cli.Flag{
- cli.StringSliceFlag{Name: "intervals, i", Value: &cli.StringSlice{}, EnvVar: "COMPAT_INTERVALS,APP_INTERVALS"},
- },
- Action: func(ctx *cli.Context) {
- if !reflect.DeepEqual(ctx.StringSlice("intervals"), []string{"20", "30", "40"}) {
- t.Errorf("main name not set from env")
- }
- if !reflect.DeepEqual(ctx.StringSlice("i"), []string{"20", "30", "40"}) {
- t.Errorf("short name not set from env")
- }
- },
- }).Run([]string{"run"})
-}
-
-func TestParseMultiInt(t *testing.T) {
- a := cli.App{
- Flags: []cli.Flag{
- cli.IntFlag{Name: "serve, s"},
- },
- Action: func(ctx *cli.Context) {
- if ctx.Int("serve") != 10 {
- t.Errorf("main name not set")
- }
- if ctx.Int("s") != 10 {
- t.Errorf("short name not set")
- }
- },
- }
- a.Run([]string{"run", "-s", "10"})
-}
-
-func TestParseMultiIntFromEnv(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_TIMEOUT_SECONDS", "10")
- a := cli.App{
- Flags: []cli.Flag{
- cli.IntFlag{Name: "timeout, t", EnvVar: "APP_TIMEOUT_SECONDS"},
- },
- Action: func(ctx *cli.Context) {
- if ctx.Int("timeout") != 10 {
- t.Errorf("main name not set")
- }
- if ctx.Int("t") != 10 {
- t.Errorf("short name not set")
- }
- },
- }
- a.Run([]string{"run"})
-}
-
-func TestParseMultiIntFromEnvCascade(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_TIMEOUT_SECONDS", "10")
- a := cli.App{
- Flags: []cli.Flag{
- cli.IntFlag{Name: "timeout, t", EnvVar: "COMPAT_TIMEOUT_SECONDS,APP_TIMEOUT_SECONDS"},
- },
- Action: func(ctx *cli.Context) {
- if ctx.Int("timeout") != 10 {
- t.Errorf("main name not set")
- }
- if ctx.Int("t") != 10 {
- t.Errorf("short name not set")
- }
- },
- }
- a.Run([]string{"run"})
-}
-
-func TestParseMultiIntSlice(t *testing.T) {
- (&cli.App{
- Flags: []cli.Flag{
- cli.IntSliceFlag{Name: "serve, s", Value: &cli.IntSlice{}},
- },
- Action: func(ctx *cli.Context) {
- if !reflect.DeepEqual(ctx.IntSlice("serve"), []int{10, 20}) {
- t.Errorf("main name not set")
- }
- if !reflect.DeepEqual(ctx.IntSlice("s"), []int{10, 20}) {
- t.Errorf("short name not set")
- }
- },
- }).Run([]string{"run", "-s", "10", "-s", "20"})
-}
-
-func TestParseMultiIntSliceFromEnv(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_INTERVALS", "20,30,40")
-
- (&cli.App{
- Flags: []cli.Flag{
- cli.IntSliceFlag{Name: "intervals, i", Value: &cli.IntSlice{}, EnvVar: "APP_INTERVALS"},
- },
- Action: func(ctx *cli.Context) {
- if !reflect.DeepEqual(ctx.IntSlice("intervals"), []int{20, 30, 40}) {
- t.Errorf("main name not set from env")
- }
- if !reflect.DeepEqual(ctx.IntSlice("i"), []int{20, 30, 40}) {
- t.Errorf("short name not set from env")
- }
- },
- }).Run([]string{"run"})
-}
-
-func TestParseMultiIntSliceFromEnvCascade(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_INTERVALS", "20,30,40")
-
- (&cli.App{
- Flags: []cli.Flag{
- cli.IntSliceFlag{Name: "intervals, i", Value: &cli.IntSlice{}, EnvVar: "COMPAT_INTERVALS,APP_INTERVALS"},
- },
- Action: func(ctx *cli.Context) {
- if !reflect.DeepEqual(ctx.IntSlice("intervals"), []int{20, 30, 40}) {
- t.Errorf("main name not set from env")
- }
- if !reflect.DeepEqual(ctx.IntSlice("i"), []int{20, 30, 40}) {
- t.Errorf("short name not set from env")
- }
- },
- }).Run([]string{"run"})
-}
-
-func TestParseMultiFloat64(t *testing.T) {
- a := cli.App{
- Flags: []cli.Flag{
- cli.Float64Flag{Name: "serve, s"},
- },
- Action: func(ctx *cli.Context) {
- if ctx.Float64("serve") != 10.2 {
- t.Errorf("main name not set")
- }
- if ctx.Float64("s") != 10.2 {
- t.Errorf("short name not set")
- }
- },
- }
- a.Run([]string{"run", "-s", "10.2"})
-}
-
-func TestParseMultiFloat64FromEnv(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_TIMEOUT_SECONDS", "15.5")
- a := cli.App{
- Flags: []cli.Flag{
- cli.Float64Flag{Name: "timeout, t", EnvVar: "APP_TIMEOUT_SECONDS"},
- },
- Action: func(ctx *cli.Context) {
- if ctx.Float64("timeout") != 15.5 {
- t.Errorf("main name not set")
- }
- if ctx.Float64("t") != 15.5 {
- t.Errorf("short name not set")
- }
- },
- }
- a.Run([]string{"run"})
-}
-
-func TestParseMultiFloat64FromEnvCascade(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_TIMEOUT_SECONDS", "15.5")
- a := cli.App{
- Flags: []cli.Flag{
- cli.Float64Flag{Name: "timeout, t", EnvVar: "COMPAT_TIMEOUT_SECONDS,APP_TIMEOUT_SECONDS"},
- },
- Action: func(ctx *cli.Context) {
- if ctx.Float64("timeout") != 15.5 {
- t.Errorf("main name not set")
- }
- if ctx.Float64("t") != 15.5 {
- t.Errorf("short name not set")
- }
- },
- }
- a.Run([]string{"run"})
-}
-
-func TestParseMultiBool(t *testing.T) {
- a := cli.App{
- Flags: []cli.Flag{
- cli.BoolFlag{Name: "serve, s"},
- },
- Action: func(ctx *cli.Context) {
- if ctx.Bool("serve") != true {
- t.Errorf("main name not set")
- }
- if ctx.Bool("s") != true {
- t.Errorf("short name not set")
- }
- },
- }
- a.Run([]string{"run", "--serve"})
-}
-
-func TestParseMultiBoolFromEnv(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_DEBUG", "1")
- a := cli.App{
- Flags: []cli.Flag{
- cli.BoolFlag{Name: "debug, d", EnvVar: "APP_DEBUG"},
- },
- Action: func(ctx *cli.Context) {
- if ctx.Bool("debug") != true {
- t.Errorf("main name not set from env")
- }
- if ctx.Bool("d") != true {
- t.Errorf("short name not set from env")
- }
- },
- }
- a.Run([]string{"run"})
-}
-
-func TestParseMultiBoolFromEnvCascade(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_DEBUG", "1")
- a := cli.App{
- Flags: []cli.Flag{
- cli.BoolFlag{Name: "debug, d", EnvVar: "COMPAT_DEBUG,APP_DEBUG"},
- },
- Action: func(ctx *cli.Context) {
- if ctx.Bool("debug") != true {
- t.Errorf("main name not set from env")
- }
- if ctx.Bool("d") != true {
- t.Errorf("short name not set from env")
- }
- },
- }
- a.Run([]string{"run"})
-}
-
-func TestParseMultiBoolT(t *testing.T) {
- a := cli.App{
- Flags: []cli.Flag{
- cli.BoolTFlag{Name: "serve, s"},
- },
- Action: func(ctx *cli.Context) {
- if ctx.BoolT("serve") != true {
- t.Errorf("main name not set")
- }
- if ctx.BoolT("s") != true {
- t.Errorf("short name not set")
- }
- },
- }
- a.Run([]string{"run", "--serve"})
-}
-
-func TestParseMultiBoolTFromEnv(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_DEBUG", "0")
- a := cli.App{
- Flags: []cli.Flag{
- cli.BoolTFlag{Name: "debug, d", EnvVar: "APP_DEBUG"},
- },
- Action: func(ctx *cli.Context) {
- if ctx.BoolT("debug") != false {
- t.Errorf("main name not set from env")
- }
- if ctx.BoolT("d") != false {
- t.Errorf("short name not set from env")
- }
- },
- }
- a.Run([]string{"run"})
-}
-
-func TestParseMultiBoolTFromEnvCascade(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_DEBUG", "0")
- a := cli.App{
- Flags: []cli.Flag{
- cli.BoolTFlag{Name: "debug, d", EnvVar: "COMPAT_DEBUG,APP_DEBUG"},
- },
- Action: func(ctx *cli.Context) {
- if ctx.BoolT("debug") != false {
- t.Errorf("main name not set from env")
- }
- if ctx.BoolT("d") != false {
- t.Errorf("short name not set from env")
- }
- },
- }
- a.Run([]string{"run"})
-}
-
-type Parser [2]string
-
-func (p *Parser) Set(value string) error {
- parts := strings.Split(value, ",")
- if len(parts) != 2 {
- return fmt.Errorf("invalid format")
- }
-
- (*p)[0] = parts[0]
- (*p)[1] = parts[1]
-
- return nil
-}
-
-func (p *Parser) String() string {
- return fmt.Sprintf("%s,%s", p[0], p[1])
-}
-
-func TestParseGeneric(t *testing.T) {
- a := cli.App{
- Flags: []cli.Flag{
- cli.GenericFlag{Name: "serve, s", Value: &Parser{}},
- },
- Action: func(ctx *cli.Context) {
- if !reflect.DeepEqual(ctx.Generic("serve"), &Parser{"10", "20"}) {
- t.Errorf("main name not set")
- }
- if !reflect.DeepEqual(ctx.Generic("s"), &Parser{"10", "20"}) {
- t.Errorf("short name not set")
- }
- },
- }
- a.Run([]string{"run", "-s", "10,20"})
-}
-
-func TestParseGenericFromEnv(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_SERVE", "20,30")
- a := cli.App{
- Flags: []cli.Flag{
- cli.GenericFlag{Name: "serve, s", Value: &Parser{}, EnvVar: "APP_SERVE"},
- },
- Action: func(ctx *cli.Context) {
- if !reflect.DeepEqual(ctx.Generic("serve"), &Parser{"20", "30"}) {
- t.Errorf("main name not set from env")
- }
- if !reflect.DeepEqual(ctx.Generic("s"), &Parser{"20", "30"}) {
- t.Errorf("short name not set from env")
- }
- },
- }
- a.Run([]string{"run"})
-}
-
-func TestParseGenericFromEnvCascade(t *testing.T) {
- os.Clearenv()
- os.Setenv("APP_FOO", "99,2000")
- a := cli.App{
- Flags: []cli.Flag{
- cli.GenericFlag{Name: "foos", Value: &Parser{}, EnvVar: "COMPAT_FOO,APP_FOO"},
- },
- Action: func(ctx *cli.Context) {
- if !reflect.DeepEqual(ctx.Generic("foos"), &Parser{"99", "2000"}) {
- t.Errorf("value not set from env")
- }
- },
- }
- a.Run([]string{"run"})
-}
diff --git a/Godeps/_workspace/src/github.com/codegangsta/cli/help.go b/Godeps/_workspace/src/github.com/codegangsta/cli/help.go
index 7c4f81be6..a246f63ac 100644
--- a/Godeps/_workspace/src/github.com/codegangsta/cli/help.go
+++ b/Godeps/_workspace/src/github.com/codegangsta/cli/help.go
@@ -1,6 +1,12 @@
package cli
-import "fmt"
+import (
+ "fmt"
+ "io"
+ "strings"
+ "text/tabwriter"
+ "text/template"
+)
// The text template for the Default help topic.
// cli.go uses text/template to render templates. You can
@@ -9,30 +15,33 @@ var AppHelpTemplate = `NAME:
{{.Name}} - {{.Usage}}
USAGE:
- {{.Name}} {{if .Flags}}[global options] {{end}}command{{if .Flags}} [command options]{{end}} [arguments...]
-
+ {{.HelpName}} {{if .Flags}}[global options]{{end}}{{if .Commands}} command [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}
+ {{if .Version}}
VERSION:
{{.Version}}
-
-AUTHOR(S):
- {{range .Authors}}{{ . }}
- {{end}}
+ {{end}}{{if len .Authors}}
+AUTHOR(S):
+ {{range .Authors}}{{ . }}{{end}}
+ {{end}}{{if .Commands}}
COMMANDS:
{{range .Commands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}}
- {{end}}{{if .Flags}}
+ {{end}}{{end}}{{if .Flags}}
GLOBAL OPTIONS:
{{range .Flags}}{{.}}
- {{end}}{{end}}
+ {{end}}{{end}}{{if .Copyright }}
+COPYRIGHT:
+ {{.Copyright}}
+ {{end}}
`
// The text template for the command help topic.
// cli.go uses text/template to render templates. You can
// render custom help text by setting this variable.
var CommandHelpTemplate = `NAME:
- {{.Name}} - {{.Usage}}
+ {{.HelpName}} - {{.Usage}}
USAGE:
- command {{.Name}}{{if .Flags}} [command options]{{end}} [arguments...]{{if .Description}}
+ {{.HelpName}}{{if .Flags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}{{if .Description}}
DESCRIPTION:
{{.Description}}{{end}}{{if .Flags}}
@@ -46,10 +55,10 @@ OPTIONS:
// cli.go uses text/template to render templates. You can
// render custom help text by setting this variable.
var SubcommandHelpTemplate = `NAME:
- {{.Name}} - {{.Usage}}
+ {{.HelpName}} - {{.Usage}}
USAGE:
- {{.Name}} command{{if .Flags}} [command options]{{end}} [arguments...]
+ {{.HelpName}} command{{if .Flags}} [command options]{{end}} {{if .ArgsUsage}}{{.ArgsUsage}}{{else}}[arguments...]{{end}}
COMMANDS:
{{range .Commands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}}
@@ -60,9 +69,10 @@ OPTIONS:
`
var helpCommand = Command{
- Name: "help",
- Aliases: []string{"h"},
- Usage: "Shows a list of commands or help for one command",
+ Name: "help",
+ Aliases: []string{"h"},
+ Usage: "Shows a list of commands or help for one command",
+ ArgsUsage: "[command]",
Action: func(c *Context) {
args := c.Args()
if args.Present() {
@@ -74,9 +84,10 @@ var helpCommand = Command{
}
var helpSubcommand = Command{
- Name: "help",
- Aliases: []string{"h"},
- Usage: "Shows a list of commands or help for one command",
+ Name: "help",
+ Aliases: []string{"h"},
+ Usage: "Shows a list of commands or help for one command",
+ ArgsUsage: "[command]",
Action: func(c *Context) {
args := c.Args()
if args.Present() {
@@ -87,16 +98,16 @@ var helpSubcommand = Command{
},
}
-// Prints help for the App
-type helpPrinter func(templ string, data interface{})
+// Prints help for the App or Command
+type helpPrinter func(w io.Writer, templ string, data interface{})
-var HelpPrinter helpPrinter = nil
+var HelpPrinter helpPrinter = printHelp
// Prints version for the App
var VersionPrinter = printVersion
func ShowAppHelp(c *Context) {
- HelpPrinter(AppHelpTemplate, c.App)
+ HelpPrinter(c.App.Writer, AppHelpTemplate, c.App)
}
// Prints the list of subcommands as the default app completion method
@@ -109,24 +120,24 @@ func DefaultAppComplete(c *Context) {
}
// Prints help for the given command
-func ShowCommandHelp(c *Context, command string) {
+func ShowCommandHelp(ctx *Context, command string) {
// show the subcommand help for a command with subcommands
if command == "" {
- HelpPrinter(SubcommandHelpTemplate, c.App)
+ HelpPrinter(ctx.App.Writer, SubcommandHelpTemplate, ctx.App)
return
}
- for _, c := range c.App.Commands {
+ for _, c := range ctx.App.Commands {
if c.HasName(command) {
- HelpPrinter(CommandHelpTemplate, c)
+ HelpPrinter(ctx.App.Writer, CommandHelpTemplate, c)
return
}
}
- if c.App.CommandNotFound != nil {
- c.App.CommandNotFound(c, command)
+ if ctx.App.CommandNotFound != nil {
+ ctx.App.CommandNotFound(ctx, command)
} else {
- fmt.Fprintf(c.App.Writer, "No help topic for '%v'\n", command)
+ fmt.Fprintf(ctx.App.Writer, "No help topic for '%v'\n", command)
}
}
@@ -160,22 +171,42 @@ func ShowCommandCompletions(ctx *Context, command string) {
}
}
-func checkVersion(c *Context) bool {
- if c.GlobalBool("version") {
- ShowVersion(c)
- return true
+func printHelp(out io.Writer, templ string, data interface{}) {
+ funcMap := template.FuncMap{
+ "join": strings.Join,
}
- return false
+ w := tabwriter.NewWriter(out, 0, 8, 1, '\t', 0)
+ t := template.Must(template.New("help").Funcs(funcMap).Parse(templ))
+ err := t.Execute(w, data)
+ if err != nil {
+ panic(err)
+ }
+ w.Flush()
}
-func checkHelp(c *Context) bool {
- if c.GlobalBool("h") || c.GlobalBool("help") {
- ShowAppHelp(c)
- return true
+func checkVersion(c *Context) bool {
+ found := false
+ if VersionFlag.Name != "" {
+ eachName(VersionFlag.Name, func(name string) {
+ if c.GlobalBool(name) || c.Bool(name) {
+ found = true
+ }
+ })
}
+ return found
+}
- return false
+func checkHelp(c *Context) bool {
+ found := false
+ if HelpFlag.Name != "" {
+ eachName(HelpFlag.Name, func(name string) {
+ if c.GlobalBool(name) || c.Bool(name) {
+ found = true
+ }
+ })
+ }
+ return found
}
func checkCommandHelp(c *Context, name string) bool {
diff --git a/Godeps/_workspace/src/github.com/codegangsta/cli/helpers_test.go b/Godeps/_workspace/src/github.com/codegangsta/cli/helpers_test.go
deleted file mode 100644
index cdc4feb2f..000000000
--- a/Godeps/_workspace/src/github.com/codegangsta/cli/helpers_test.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package cli_test
-
-import (
- "reflect"
- "testing"
-)
-
-/* Test Helpers */
-func expect(t *testing.T, a interface{}, b interface{}) {
- if a != b {
- t.Errorf("Expected %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a))
- }
-}
-
-func refute(t *testing.T, a interface{}, b interface{}) {
- if a == b {
- t.Errorf("Did not expect %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a))
- }
-}
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go b/Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go
index d0864da7f..2199dbec1 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/ethash.go
@@ -1,3 +1,21 @@
+// Copyright 2015 The go-ethereum Authors
+// Copyright 2015 Lefteris Karapetsas <lefteris@refu.co>
+// Copyright 2015 Matthew Wampler-Doty <matthew.wampler.doty@gmail.com>
+// This file is part of the go-ethereum library.
+//
+// The go-ethereum library is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// The go-ethereum library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
+
package ethash
/*
@@ -30,8 +48,8 @@ import (
)
var (
- minDifficulty = new(big.Int).Exp(big.NewInt(2), big.NewInt(256), big.NewInt(0))
- sharedLight = new(Light)
+ maxUint256 = new(big.Int).Exp(big.NewInt(2), big.NewInt(256), big.NewInt(0))
+ sharedLight = new(Light)
)
const (
@@ -140,7 +158,7 @@ func (l *Light) Verify(block pow.Block) bool {
// the finalizer before the call completes.
_ = cache
// The actual check.
- target := new(big.Int).Div(minDifficulty, difficulty)
+ target := new(big.Int).Div(maxUint256, difficulty)
return h256ToHash(ret.result).Big().Cmp(target) <= 0
}
@@ -199,7 +217,7 @@ func (d *dag) generate() {
if d.dir == "" {
d.dir = DefaultDir
}
- glog.V(logger.Info).Infof("Generating DAG for epoch %d (%x)", d.epoch, seedHash)
+ glog.V(logger.Info).Infof("Generating DAG for epoch %d (size %d) (%x)", d.epoch, dagSize, seedHash)
// Generate a temporary cache.
// TODO: this could share the cache with Light
cache := C.ethash_light_new_internal(cacheSize, (*C.ethash_h256_t)(unsafe.Pointer(&seedHash[0])))
@@ -220,14 +238,18 @@ func (d *dag) generate() {
})
}
-func freeDAG(h *dag) {
- C.ethash_full_delete(h.ptr)
- h.ptr = nil
+func freeDAG(d *dag) {
+ C.ethash_full_delete(d.ptr)
+ d.ptr = nil
+}
+
+func (d *dag) Ptr() unsafe.Pointer {
+ return unsafe.Pointer(d.ptr.data)
}
//export ethashGoCallback
func ethashGoCallback(percent C.unsigned) C.int {
- glog.V(logger.Info).Infof("Still generating DAG: %d%%", percent)
+ glog.V(logger.Info).Infof("Generating DAG: %d%%", percent)
return 0
}
@@ -273,7 +295,7 @@ func (pow *Full) getDAG(blockNum uint64) (d *dag) {
return d
}
-func (pow *Full) Search(block pow.Block, stop <-chan struct{}) (nonce uint64, mixDigest []byte) {
+func (pow *Full) Search(block pow.Block, stop <-chan struct{}, index int) (nonce uint64, mixDigest []byte) {
dag := pow.getDAG(block.NumberU64())
r := rand.New(rand.NewSource(time.Now().UnixNano()))
@@ -286,7 +308,7 @@ func (pow *Full) Search(block pow.Block, stop <-chan struct{}) (nonce uint64, mi
nonce = uint64(r.Int63())
hash := hashToH256(block.HashNoNonce())
- target := new(big.Int).Div(minDifficulty, diff)
+ target := new(big.Int).Div(maxUint256, diff)
for {
select {
case <-stop:
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/ethash_opencl.go b/Godeps/_workspace/src/github.com/ethereum/ethash/ethash_opencl.go
new file mode 100644
index 000000000..332b7f524
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/ethash_opencl.go
@@ -0,0 +1,629 @@
+// Copyright 2014 The go-ethereum Authors
+// This file is part of the go-ethereum library.
+//
+// The go-ethereum library is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// The go-ethereum library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
+
+// +build opencl
+
+package ethash
+
+//#cgo LDFLAGS: -w
+//#include <stdint.h>
+//#include <string.h>
+//#include "src/libethash/internal.h"
+import "C"
+
+import (
+ crand "crypto/rand"
+ "encoding/binary"
+ "fmt"
+ "math"
+ "math/big"
+ mrand "math/rand"
+ "strconv"
+ "strings"
+ "sync"
+ "sync/atomic"
+ "time"
+ "unsafe"
+
+ "github.com/Gustav-Simonsson/go-opencl/cl"
+ "github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/pow"
+)
+
+/*
+
+ This code have two main entry points:
+
+ 1. The initCL(...) function configures one or more OpenCL device
+ (for now only GPU) and loads the Ethash DAG onto device memory
+
+ 2. The Search(...) function loads a Ethash nonce into device(s) memory and
+ executes the Ethash OpenCL kernel.
+
+ Throughout the code, we refer to "host memory" and "device memory".
+ For most systems (e.g. regular PC GPU miner) the host memory is RAM and
+ device memory is the GPU global memory (e.g. GDDR5).
+
+ References mentioned in code comments:
+
+ 1. https://github.com/ethereum/wiki/wiki/Ethash
+ 2. https://github.com/ethereum/cpp-ethereum/blob/develop/libethash-cl/ethash_cl_miner.cpp
+ 3. https://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/
+ 4. http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2013/12/AMD_OpenCL_Programming_User_Guide.pdf
+
+*/
+
+type OpenCLDevice struct {
+ deviceId int
+ device *cl.Device
+ openCL11 bool // OpenCL version 1.1 and 1.2 are handled a bit different
+ openCL12 bool
+
+ dagBuf *cl.MemObject // Ethash full DAG in device mem
+ headerBuf *cl.MemObject // Hash of block-to-mine in device mem
+ searchBuffers []*cl.MemObject
+
+ searchKernel *cl.Kernel
+ hashKernel *cl.Kernel
+
+ queue *cl.CommandQueue
+ ctx *cl.Context
+ workGroupSize int
+
+ nonceRand *mrand.Rand // seeded by crypto/rand, see comments where it's initialised
+ result common.Hash
+}
+
+type OpenCLMiner struct {
+ mu sync.Mutex
+
+ ethash *Ethash // Ethash full DAG & cache in host mem
+
+ deviceIds []int
+ devices []*OpenCLDevice
+
+ dagSize uint64
+
+ hashRate int32 // Go atomics & uint64 have some issues; int32 is supported on all platforms
+}
+
+type pendingSearch struct {
+ bufIndex uint32
+ startNonce uint64
+}
+
+const (
+ SIZEOF_UINT32 = 4
+
+ // See [1]
+ ethashMixBytesLen = 128
+ ethashAccesses = 64
+
+ // See [4]
+ workGroupSize = 32 // must be multiple of 8
+ maxSearchResults = 63
+ searchBufSize = 2
+ globalWorkSize = 1024 * 256
+)
+
+func NewCL(deviceIds []int) *OpenCLMiner {
+ ids := make([]int, len(deviceIds))
+ copy(ids, deviceIds)
+ return &OpenCLMiner{
+ ethash: New(),
+ dagSize: 0, // to see if we need to update DAG.
+ deviceIds: ids,
+ }
+}
+
+func PrintDevices() {
+ fmt.Println("=============================================")
+ fmt.Println("============ OpenCL Device Info =============")
+ fmt.Println("=============================================")
+
+ var found []*cl.Device
+
+ platforms, err := cl.GetPlatforms()
+ if err != nil {
+ fmt.Println("Plaform error (check your OpenCL installation): %v", err)
+ return
+ }
+
+ for i, p := range platforms {
+ fmt.Println("Platform id ", i)
+ fmt.Println("Platform Name ", p.Name())
+ fmt.Println("Platform Vendor ", p.Vendor())
+ fmt.Println("Platform Version ", p.Version())
+ fmt.Println("Platform Extensions ", p.Extensions())
+ fmt.Println("Platform Profile ", p.Profile())
+ fmt.Println("")
+
+ devices, err := cl.GetDevices(p, cl.DeviceTypeGPU)
+ if err != nil {
+ fmt.Println("Device error (check your GPU drivers) :", err)
+ return
+ }
+
+ for _, d := range devices {
+ fmt.Println("Device OpenCL id ", i)
+ fmt.Println("Device id for mining ", len(found))
+ fmt.Println("Device Name ", d.Name())
+ fmt.Println("Vendor ", d.Vendor())
+ fmt.Println("Version ", d.Version())
+ fmt.Println("Driver version ", d.DriverVersion())
+ fmt.Println("Address bits ", d.AddressBits())
+ fmt.Println("Max clock freq ", d.MaxClockFrequency())
+ fmt.Println("Global mem size ", d.GlobalMemSize())
+ fmt.Println("Max constant buffer size", d.MaxConstantBufferSize())
+ fmt.Println("Max mem alloc size ", d.MaxMemAllocSize())
+ fmt.Println("Max compute units ", d.MaxComputeUnits())
+ fmt.Println("Max work group size ", d.MaxWorkGroupSize())
+ fmt.Println("Max work item sizes ", d.MaxWorkItemSizes())
+ fmt.Println("=============================================")
+
+ found = append(found, d)
+ }
+ }
+ if len(found) == 0 {
+ fmt.Println("Found no GPU(s). Check that your OS can see the GPU(s)")
+ } else {
+ var idsFormat string
+ for i := 0; i < len(found); i++ {
+ idsFormat += strconv.Itoa(i)
+ if i != len(found)-1 {
+ idsFormat += ","
+ }
+ }
+ fmt.Printf("Found %v devices. Benchmark first GPU: geth gpubench 0\n", len(found))
+ fmt.Printf("Mine using all GPUs: geth --minegpu %v\n", idsFormat)
+ }
+}
+
+// See [2]. We basically do the same here, but the Go OpenCL bindings
+// are at a slightly higher abtraction level.
+func InitCL(blockNum uint64, c *OpenCLMiner) error {
+ platforms, err := cl.GetPlatforms()
+ if err != nil {
+ return fmt.Errorf("Plaform error: %v\nCheck your OpenCL installation and then run geth gpuinfo", err)
+ }
+
+ var devices []*cl.Device
+ for _, p := range platforms {
+ ds, err := cl.GetDevices(p, cl.DeviceTypeGPU)
+ if err != nil {
+ return fmt.Errorf("Devices error: %v\nCheck your GPU drivers and then run geth gpuinfo", err)
+ }
+ for _, d := range ds {
+ devices = append(devices, d)
+ }
+ }
+
+ pow := New()
+ _ = pow.getDAG(blockNum) // generates DAG if we don't have it
+ pow.Light.getCache(blockNum) // and cache
+
+ c.ethash = pow
+ dagSize := uint64(C.ethash_get_datasize(C.uint64_t(blockNum)))
+ c.dagSize = dagSize
+
+ for _, id := range c.deviceIds {
+ if id > len(devices)-1 {
+ return fmt.Errorf("Device id not found. See available device ids with: geth gpuinfo")
+ } else {
+ err := initCLDevice(id, devices[id], c)
+ if err != nil {
+ return err
+ }
+ }
+ }
+ if len(c.devices) == 0 {
+ return fmt.Errorf("No GPU devices found")
+ }
+ return nil
+}
+
+func initCLDevice(deviceId int, device *cl.Device, c *OpenCLMiner) error {
+ devMaxAlloc := uint64(device.MaxMemAllocSize())
+ devGlobalMem := uint64(device.GlobalMemSize())
+
+ // TODO: more fine grained version logic
+ if device.Version() == "OpenCL 1.0" {
+ fmt.Println("Device OpenCL version not supported: ", device.Version())
+ return fmt.Errorf("opencl version not supported")
+ }
+
+ var cl11, cl12 bool
+ if device.Version() == "OpenCL 1.1" {
+ cl11 = true
+ }
+ if device.Version() == "OpenCL 1.2" {
+ cl12 = true
+ }
+
+ // log warnings but carry on; some device drivers report inaccurate values
+ if c.dagSize > devGlobalMem {
+ fmt.Printf("WARNING: device memory may be insufficient: %v. DAG size: %v.\n", devGlobalMem, c.dagSize)
+ }
+
+ if c.dagSize > devMaxAlloc {
+ fmt.Printf("WARNING: DAG size (%v) larger than device max memory allocation size (%v).\n", c.dagSize, devMaxAlloc)
+ fmt.Printf("You probably have to export GPU_MAX_ALLOC_PERCENT=95\n")
+ }
+
+ fmt.Printf("Initialising device %v: %v\n", deviceId, device.Name())
+
+ context, err := cl.CreateContext([]*cl.Device{device})
+ if err != nil {
+ return fmt.Errorf("failed creating context:", err)
+ }
+
+ // TODO: test running with CL_QUEUE_PROFILING_ENABLE for profiling?
+ queue, err := context.CreateCommandQueue(device, 0)
+ if err != nil {
+ return fmt.Errorf("command queue err:", err)
+ }
+
+ // See [4] section 3.2 and [3] "clBuildProgram".
+ // The OpenCL kernel code is compiled at run-time.
+ kvs := make(map[string]string, 4)
+ kvs["GROUP_SIZE"] = strconv.FormatUint(workGroupSize, 10)
+ kvs["DAG_SIZE"] = strconv.FormatUint(c.dagSize/ethashMixBytesLen, 10)
+ kvs["ACCESSES"] = strconv.FormatUint(ethashAccesses, 10)
+ kvs["MAX_OUTPUTS"] = strconv.FormatUint(maxSearchResults, 10)
+ kernelCode := replaceWords(kernel, kvs)
+
+ program, err := context.CreateProgramWithSource([]string{kernelCode})
+ if err != nil {
+ return fmt.Errorf("program err:", err)
+ }
+
+ /* if using AMD OpenCL impl, you can set this to debug on x86 CPU device.
+ see AMD OpenCL programming guide section 4.2
+
+ export in shell before running:
+ export AMD_OCL_BUILD_OPTIONS_APPEND="-g -O0"
+ export CPU_MAX_COMPUTE_UNITS=1
+
+ buildOpts := "-g -cl-opt-disable"
+
+ */
+ buildOpts := ""
+ err = program.BuildProgram([]*cl.Device{device}, buildOpts)
+ if err != nil {
+ return fmt.Errorf("program build err:", err)
+ }
+
+ var searchKernelName, hashKernelName string
+ searchKernelName = "ethash_search"
+ hashKernelName = "ethash_hash"
+
+ searchKernel, err := program.CreateKernel(searchKernelName)
+ hashKernel, err := program.CreateKernel(hashKernelName)
+ if err != nil {
+ return fmt.Errorf("kernel err:", err)
+ }
+
+ // TODO: when this DAG size appears, patch the Go bindings
+ // (context.go) to work with uint64 as size_t
+ if c.dagSize > math.MaxInt32 {
+ fmt.Println("DAG too large for allocation.")
+ return fmt.Errorf("DAG too large for alloc")
+ }
+
+ // TODO: patch up Go bindings to work with size_t, will overflow if > maxint32
+ // TODO: fuck. shit's gonna overflow around 2017-06-09 12:17:02
+ dagBuf := *(new(*cl.MemObject))
+ dagBuf, err = context.CreateEmptyBuffer(cl.MemReadOnly, int(c.dagSize))
+ if err != nil {
+ return fmt.Errorf("allocating dag buf failed: ", err)
+ }
+
+ // write DAG to device mem
+ dagPtr := unsafe.Pointer(c.ethash.Full.current.ptr.data)
+ _, err = queue.EnqueueWriteBuffer(dagBuf, true, 0, int(c.dagSize), dagPtr, nil)
+ if err != nil {
+ return fmt.Errorf("writing to dag buf failed: ", err)
+ }
+
+ searchBuffers := make([]*cl.MemObject, searchBufSize)
+ for i := 0; i < searchBufSize; i++ {
+ searchBuff, err := context.CreateEmptyBuffer(cl.MemWriteOnly, (1+maxSearchResults)*SIZEOF_UINT32)
+ if err != nil {
+ return fmt.Errorf("search buffer err:", err)
+ }
+ searchBuffers[i] = searchBuff
+ }
+
+ headerBuf, err := context.CreateEmptyBuffer(cl.MemReadOnly, 32)
+ if err != nil {
+ return fmt.Errorf("header buffer err:", err)
+ }
+
+ // Unique, random nonces are crucial for mining efficieny.
+ // While we do not need cryptographically secure PRNG for nonces,
+ // we want to have uniform distribution and minimal repetition of nonces.
+ // We could guarantee strict uniqueness of nonces by generating unique ranges,
+ // but a int64 seed from crypto/rand should be good enough.
+ // we then use math/rand for speed and to avoid draining OS entropy pool
+ seed, err := crand.Int(crand.Reader, big.NewInt(math.MaxInt64))
+ if err != nil {
+ return err
+ }
+ nonceRand := mrand.New(mrand.NewSource(seed.Int64()))
+
+ deviceStruct := &OpenCLDevice{
+ deviceId: deviceId,
+ device: device,
+ openCL11: cl11,
+ openCL12: cl12,
+
+ dagBuf: dagBuf,
+ headerBuf: headerBuf,
+ searchBuffers: searchBuffers,
+
+ searchKernel: searchKernel,
+ hashKernel: hashKernel,
+
+ queue: queue,
+ ctx: context,
+
+ workGroupSize: workGroupSize,
+
+ nonceRand: nonceRand,
+ }
+ c.devices = append(c.devices, deviceStruct)
+
+ return nil
+}
+
+func (c *OpenCLMiner) Search(block pow.Block, stop <-chan struct{}, index int) (uint64, []byte) {
+ c.mu.Lock()
+ newDagSize := uint64(C.ethash_get_datasize(C.uint64_t(block.NumberU64())))
+ if newDagSize > c.dagSize {
+ // TODO: clean up buffers from previous DAG?
+ err := InitCL(block.NumberU64(), c)
+ if err != nil {
+ fmt.Println("OpenCL init error: ", err)
+ return 0, []byte{0}
+ }
+ }
+ defer c.mu.Unlock()
+
+ // Avoid unneeded OpenCL initialisation if we received stop while running InitCL
+ select {
+ case <-stop:
+ return 0, []byte{0}
+ default:
+ }
+
+ headerHash := block.HashNoNonce()
+ diff := block.Difficulty()
+ target256 := new(big.Int).Div(maxUint256, diff)
+ target64 := new(big.Int).Rsh(target256, 192).Uint64()
+ var zero uint32 = 0
+
+ d := c.devices[index]
+
+ _, err := d.queue.EnqueueWriteBuffer(d.headerBuf, false, 0, 32, unsafe.Pointer(&headerHash[0]), nil)
+ if err != nil {
+ fmt.Println("Error in Search clEnqueueWriterBuffer : ", err)
+ return 0, []byte{0}
+ }
+
+ for i := 0; i < searchBufSize; i++ {
+ _, err := d.queue.EnqueueWriteBuffer(d.searchBuffers[i], false, 0, 4, unsafe.Pointer(&zero), nil)
+ if err != nil {
+ fmt.Println("Error in Search clEnqueueWriterBuffer : ", err)
+ return 0, []byte{0}
+ }
+ }
+
+ // wait for all search buffers to complete
+ err = d.queue.Finish()
+ if err != nil {
+ fmt.Println("Error in Search clFinish : ", err)
+ return 0, []byte{0}
+ }
+
+ err = d.searchKernel.SetArg(1, d.headerBuf)
+ if err != nil {
+ fmt.Println("Error in Search clSetKernelArg : ", err)
+ return 0, []byte{0}
+ }
+
+ err = d.searchKernel.SetArg(2, d.dagBuf)
+ if err != nil {
+ fmt.Println("Error in Search clSetKernelArg : ", err)
+ return 0, []byte{0}
+ }
+
+ err = d.searchKernel.SetArg(4, target64)
+ if err != nil {
+ fmt.Println("Error in Search clSetKernelArg : ", err)
+ return 0, []byte{0}
+ }
+ err = d.searchKernel.SetArg(5, uint32(math.MaxUint32))
+ if err != nil {
+ fmt.Println("Error in Search clSetKernelArg : ", err)
+ return 0, []byte{0}
+ }
+
+ // wait on this before returning
+ var preReturnEvent *cl.Event
+ if d.openCL12 {
+ preReturnEvent, err = d.ctx.CreateUserEvent()
+ if err != nil {
+ fmt.Println("Error in Search create CL user event : ", err)
+ return 0, []byte{0}
+ }
+ }
+
+ pending := make([]pendingSearch, 0, searchBufSize)
+ var p *pendingSearch
+ searchBufIndex := uint32(0)
+ var checkNonce uint64
+ loops := int64(0)
+ prevHashRate := int32(0)
+ start := time.Now().UnixNano()
+ // we grab a single random nonce and sets this as argument to the kernel search function
+ // the device will then add each local threads gid to the nonce, creating a unique nonce
+ // for each device computing unit executing in parallel
+ initNonce := uint64(d.nonceRand.Int63())
+ for nonce := initNonce; ; nonce += uint64(globalWorkSize) {
+ select {
+ case <-stop:
+
+ /*
+ if d.openCL12 {
+ err = cl.WaitForEvents([]*cl.Event{preReturnEvent})
+ if err != nil {
+ fmt.Println("Error in Search WaitForEvents: ", err)
+ }
+ }
+ */
+
+ atomic.AddInt32(&c.hashRate, -prevHashRate)
+ return 0, []byte{0}
+ default:
+ }
+
+ if (loops % (1 << 7)) == 0 {
+ elapsed := time.Now().UnixNano() - start
+ // TODO: verify if this is correct hash rate calculation
+ hashes := (float64(1e9) / float64(elapsed)) * float64(loops*1024*256)
+ hashrateDiff := int32(hashes) - prevHashRate
+ prevHashRate = int32(hashes)
+ atomic.AddInt32(&c.hashRate, hashrateDiff)
+ }
+ loops++
+
+ err = d.searchKernel.SetArg(0, d.searchBuffers[searchBufIndex])
+ if err != nil {
+ fmt.Println("Error in Search clSetKernelArg : ", err)
+ return 0, []byte{0}
+ }
+ err = d.searchKernel.SetArg(3, nonce)
+ if err != nil {
+ fmt.Println("Error in Search clSetKernelArg : ", err)
+ return 0, []byte{0}
+ }
+
+ // execute kernel
+ _, err := d.queue.EnqueueNDRangeKernel(
+ d.searchKernel,
+ []int{0},
+ []int{globalWorkSize},
+ []int{d.workGroupSize},
+ nil)
+ if err != nil {
+ fmt.Println("Error in Search clEnqueueNDRangeKernel : ", err)
+ return 0, []byte{0}
+ }
+
+ pending = append(pending, pendingSearch{bufIndex: searchBufIndex, startNonce: nonce})
+ searchBufIndex = (searchBufIndex + 1) % searchBufSize
+
+ if len(pending) == searchBufSize {
+ p = &(pending[searchBufIndex])
+ cres, _, err := d.queue.EnqueueMapBuffer(d.searchBuffers[p.bufIndex], true,
+ cl.MapFlagRead, 0, (1+maxSearchResults)*SIZEOF_UINT32,
+ nil)
+ if err != nil {
+ fmt.Println("Error in Search clEnqueueMapBuffer: ", err)
+ return 0, []byte{0}
+ }
+
+ results := cres.ByteSlice()
+ nfound := binary.LittleEndian.Uint32(results)
+ nfound = uint32(math.Min(float64(nfound), float64(maxSearchResults)))
+ // OpenCL returns the offsets from the start nonce
+ for i := uint32(0); i < nfound; i++ {
+ lo := (i + 1) * SIZEOF_UINT32
+ hi := (i + 2) * SIZEOF_UINT32
+ upperNonce := uint64(binary.LittleEndian.Uint32(results[lo:hi]))
+ checkNonce = p.startNonce + upperNonce
+ if checkNonce != 0 {
+ cn := C.uint64_t(checkNonce)
+ ds := C.uint64_t(c.dagSize)
+ // We verify that the nonce is indeed a solution by
+ // executing the Ethash verification function (on the CPU).
+ ret := C.ethash_light_compute_internal(c.ethash.Light.current.ptr, ds, hashToH256(headerHash), cn)
+ // TODO: return result first
+ if ret.success && h256ToHash(ret.result).Big().Cmp(target256) <= 0 {
+ _, err = d.queue.EnqueueUnmapMemObject(d.searchBuffers[p.bufIndex], cres, nil)
+ if err != nil {
+ fmt.Println("Error in Search clEnqueueUnmapMemObject: ", err)
+ }
+ if d.openCL12 {
+ err = cl.WaitForEvents([]*cl.Event{preReturnEvent})
+ if err != nil {
+ fmt.Println("Error in Search WaitForEvents: ", err)
+ }
+ }
+ return checkNonce, C.GoBytes(unsafe.Pointer(&ret.mix_hash), C.int(32))
+ }
+
+ _, err := d.queue.EnqueueWriteBuffer(d.searchBuffers[p.bufIndex], false, 0, 4, unsafe.Pointer(&zero), nil)
+ if err != nil {
+ fmt.Println("Error in Search cl: EnqueueWriteBuffer", err)
+ return 0, []byte{0}
+ }
+ }
+ }
+ _, err = d.queue.EnqueueUnmapMemObject(d.searchBuffers[p.bufIndex], cres, nil)
+ if err != nil {
+ fmt.Println("Error in Search clEnqueueUnMapMemObject: ", err)
+ return 0, []byte{0}
+ }
+ pending = append(pending[:searchBufIndex], pending[searchBufIndex+1:]...)
+ }
+ }
+ if d.openCL12 {
+ err := cl.WaitForEvents([]*cl.Event{preReturnEvent})
+ if err != nil {
+ fmt.Println("Error in Search clWaitForEvents: ", err)
+ return 0, []byte{0}
+ }
+ }
+ return 0, []byte{0}
+}
+
+func (c *OpenCLMiner) Verify(block pow.Block) bool {
+ return c.ethash.Light.Verify(block)
+}
+func (c *OpenCLMiner) GetHashrate() int64 {
+ return int64(atomic.LoadInt32(&c.hashRate))
+}
+func (c *OpenCLMiner) Turbo(on bool) {
+ // This is GPU mining. Always be turbo.
+}
+
+func replaceWords(text string, kvs map[string]string) string {
+ for k, v := range kvs {
+ text = strings.Replace(text, k, v, -1)
+ }
+ return text
+}
+
+func logErr(err error) {
+ if err != nil {
+ fmt.Println("Error in OpenCL call:", err)
+ }
+}
+
+func argErr(err error) error {
+ return fmt.Errorf("arg err: %v", err)
+}
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/ethash_opencl_kernel_go_str.go b/Godeps/_workspace/src/github.com/ethereum/ethash/ethash_opencl_kernel_go_str.go
new file mode 100644
index 000000000..695ff1829
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/ethash_opencl_kernel_go_str.go
@@ -0,0 +1,600 @@
+package ethash
+
+/* DO NOT EDIT!!!
+
+ This code is version controlled at
+ https://github.com/ethereum/cpp-ethereum/blob/develop/libethash-cl/ethash_cl_miner_kernel.cl
+
+ If needed change it there first, then copy over here.
+*/
+
+const kernel = `
+// author Tim Hughes <tim@twistedfury.com>
+// Tested on Radeon HD 7850
+// Hashrate: 15940347 hashes/s
+// Bandwidth: 124533 MB/s
+// search kernel should fit in <= 84 VGPRS (3 wavefronts)
+
+#define THREADS_PER_HASH (128 / 16)
+#define HASHES_PER_LOOP (GROUP_SIZE / THREADS_PER_HASH)
+
+#define FNV_PRIME 0x01000193
+
+__constant uint2 const Keccak_f1600_RC[24] = {
+ (uint2)(0x00000001, 0x00000000),
+ (uint2)(0x00008082, 0x00000000),
+ (uint2)(0x0000808a, 0x80000000),
+ (uint2)(0x80008000, 0x80000000),
+ (uint2)(0x0000808b, 0x00000000),
+ (uint2)(0x80000001, 0x00000000),
+ (uint2)(0x80008081, 0x80000000),
+ (uint2)(0x00008009, 0x80000000),
+ (uint2)(0x0000008a, 0x00000000),
+ (uint2)(0x00000088, 0x00000000),
+ (uint2)(0x80008009, 0x00000000),
+ (uint2)(0x8000000a, 0x00000000),
+ (uint2)(0x8000808b, 0x00000000),
+ (uint2)(0x0000008b, 0x80000000),
+ (uint2)(0x00008089, 0x80000000),
+ (uint2)(0x00008003, 0x80000000),
+ (uint2)(0x00008002, 0x80000000),
+ (uint2)(0x00000080, 0x80000000),
+ (uint2)(0x0000800a, 0x00000000),
+ (uint2)(0x8000000a, 0x80000000),
+ (uint2)(0x80008081, 0x80000000),
+ (uint2)(0x00008080, 0x80000000),
+ (uint2)(0x80000001, 0x00000000),
+ (uint2)(0x80008008, 0x80000000),
+};
+
+void keccak_f1600_round(uint2* a, uint r, uint out_size)
+{
+ #if !__ENDIAN_LITTLE__
+ for (uint i = 0; i != 25; ++i)
+ a[i] = a[i].yx;
+ #endif
+
+ uint2 b[25];
+ uint2 t;
+
+ // Theta
+ b[0] = a[0] ^ a[5] ^ a[10] ^ a[15] ^ a[20];
+ b[1] = a[1] ^ a[6] ^ a[11] ^ a[16] ^ a[21];
+ b[2] = a[2] ^ a[7] ^ a[12] ^ a[17] ^ a[22];
+ b[3] = a[3] ^ a[8] ^ a[13] ^ a[18] ^ a[23];
+ b[4] = a[4] ^ a[9] ^ a[14] ^ a[19] ^ a[24];
+ t = b[4] ^ (uint2)(b[1].x << 1 | b[1].y >> 31, b[1].y << 1 | b[1].x >> 31);
+ a[0] ^= t;
+ a[5] ^= t;
+ a[10] ^= t;
+ a[15] ^= t;
+ a[20] ^= t;
+ t = b[0] ^ (uint2)(b[2].x << 1 | b[2].y >> 31, b[2].y << 1 | b[2].x >> 31);
+ a[1] ^= t;
+ a[6] ^= t;
+ a[11] ^= t;
+ a[16] ^= t;
+ a[21] ^= t;
+ t = b[1] ^ (uint2)(b[3].x << 1 | b[3].y >> 31, b[3].y << 1 | b[3].x >> 31);
+ a[2] ^= t;
+ a[7] ^= t;
+ a[12] ^= t;
+ a[17] ^= t;
+ a[22] ^= t;
+ t = b[2] ^ (uint2)(b[4].x << 1 | b[4].y >> 31, b[4].y << 1 | b[4].x >> 31);
+ a[3] ^= t;
+ a[8] ^= t;
+ a[13] ^= t;
+ a[18] ^= t;
+ a[23] ^= t;
+ t = b[3] ^ (uint2)(b[0].x << 1 | b[0].y >> 31, b[0].y << 1 | b[0].x >> 31);
+ a[4] ^= t;
+ a[9] ^= t;
+ a[14] ^= t;
+ a[19] ^= t;
+ a[24] ^= t;
+
+ // Rho Pi
+ b[0] = a[0];
+ b[10] = (uint2)(a[1].x << 1 | a[1].y >> 31, a[1].y << 1 | a[1].x >> 31);
+ b[7] = (uint2)(a[10].x << 3 | a[10].y >> 29, a[10].y << 3 | a[10].x >> 29);
+ b[11] = (uint2)(a[7].x << 6 | a[7].y >> 26, a[7].y << 6 | a[7].x >> 26);
+ b[17] = (uint2)(a[11].x << 10 | a[11].y >> 22, a[11].y << 10 | a[11].x >> 22);
+ b[18] = (uint2)(a[17].x << 15 | a[17].y >> 17, a[17].y << 15 | a[17].x >> 17);
+ b[3] = (uint2)(a[18].x << 21 | a[18].y >> 11, a[18].y << 21 | a[18].x >> 11);
+ b[5] = (uint2)(a[3].x << 28 | a[3].y >> 4, a[3].y << 28 | a[3].x >> 4);
+ b[16] = (uint2)(a[5].y << 4 | a[5].x >> 28, a[5].x << 4 | a[5].y >> 28);
+ b[8] = (uint2)(a[16].y << 13 | a[16].x >> 19, a[16].x << 13 | a[16].y >> 19);
+ b[21] = (uint2)(a[8].y << 23 | a[8].x >> 9, a[8].x << 23 | a[8].y >> 9);
+ b[24] = (uint2)(a[21].x << 2 | a[21].y >> 30, a[21].y << 2 | a[21].x >> 30);
+ b[4] = (uint2)(a[24].x << 14 | a[24].y >> 18, a[24].y << 14 | a[24].x >> 18);
+ b[15] = (uint2)(a[4].x << 27 | a[4].y >> 5, a[4].y << 27 | a[4].x >> 5);
+ b[23] = (uint2)(a[15].y << 9 | a[15].x >> 23, a[15].x << 9 | a[15].y >> 23);
+ b[19] = (uint2)(a[23].y << 24 | a[23].x >> 8, a[23].x << 24 | a[23].y >> 8);
+ b[13] = (uint2)(a[19].x << 8 | a[19].y >> 24, a[19].y << 8 | a[19].x >> 24);
+ b[12] = (uint2)(a[13].x << 25 | a[13].y >> 7, a[13].y << 25 | a[13].x >> 7);
+ b[2] = (uint2)(a[12].y << 11 | a[12].x >> 21, a[12].x << 11 | a[12].y >> 21);
+ b[20] = (uint2)(a[2].y << 30 | a[2].x >> 2, a[2].x << 30 | a[2].y >> 2);
+ b[14] = (uint2)(a[20].x << 18 | a[20].y >> 14, a[20].y << 18 | a[20].x >> 14);
+ b[22] = (uint2)(a[14].y << 7 | a[14].x >> 25, a[14].x << 7 | a[14].y >> 25);
+ b[9] = (uint2)(a[22].y << 29 | a[22].x >> 3, a[22].x << 29 | a[22].y >> 3);
+ b[6] = (uint2)(a[9].x << 20 | a[9].y >> 12, a[9].y << 20 | a[9].x >> 12);
+ b[1] = (uint2)(a[6].y << 12 | a[6].x >> 20, a[6].x << 12 | a[6].y >> 20);
+
+ // Chi
+ a[0] = bitselect(b[0] ^ b[2], b[0], b[1]);
+ a[1] = bitselect(b[1] ^ b[3], b[1], b[2]);
+ a[2] = bitselect(b[2] ^ b[4], b[2], b[3]);
+ a[3] = bitselect(b[3] ^ b[0], b[3], b[4]);
+ if (out_size >= 4)
+ {
+ a[4] = bitselect(b[4] ^ b[1], b[4], b[0]);
+ a[5] = bitselect(b[5] ^ b[7], b[5], b[6]);
+ a[6] = bitselect(b[6] ^ b[8], b[6], b[7]);
+ a[7] = bitselect(b[7] ^ b[9], b[7], b[8]);
+ a[8] = bitselect(b[8] ^ b[5], b[8], b[9]);
+ if (out_size >= 8)
+ {
+ a[9] = bitselect(b[9] ^ b[6], b[9], b[5]);
+ a[10] = bitselect(b[10] ^ b[12], b[10], b[11]);
+ a[11] = bitselect(b[11] ^ b[13], b[11], b[12]);
+ a[12] = bitselect(b[12] ^ b[14], b[12], b[13]);
+ a[13] = bitselect(b[13] ^ b[10], b[13], b[14]);
+ a[14] = bitselect(b[14] ^ b[11], b[14], b[10]);
+ a[15] = bitselect(b[15] ^ b[17], b[15], b[16]);
+ a[16] = bitselect(b[16] ^ b[18], b[16], b[17]);
+ a[17] = bitselect(b[17] ^ b[19], b[17], b[18]);
+ a[18] = bitselect(b[18] ^ b[15], b[18], b[19]);
+ a[19] = bitselect(b[19] ^ b[16], b[19], b[15]);
+ a[20] = bitselect(b[20] ^ b[22], b[20], b[21]);
+ a[21] = bitselect(b[21] ^ b[23], b[21], b[22]);
+ a[22] = bitselect(b[22] ^ b[24], b[22], b[23]);
+ a[23] = bitselect(b[23] ^ b[20], b[23], b[24]);
+ a[24] = bitselect(b[24] ^ b[21], b[24], b[20]);
+ }
+ }
+
+ // Iota
+ a[0] ^= Keccak_f1600_RC[r];
+
+ #if !__ENDIAN_LITTLE__
+ for (uint i = 0; i != 25; ++i)
+ a[i] = a[i].yx;
+ #endif
+}
+
+void keccak_f1600_no_absorb(ulong* a, uint in_size, uint out_size, uint isolate)
+{
+ for (uint i = in_size; i != 25; ++i)
+ {
+ a[i] = 0;
+ }
+#if __ENDIAN_LITTLE__
+ a[in_size] ^= 0x0000000000000001;
+ a[24-out_size*2] ^= 0x8000000000000000;
+#else
+ a[in_size] ^= 0x0100000000000000;
+ a[24-out_size*2] ^= 0x0000000000000080;
+#endif
+
+ // Originally I unrolled the first and last rounds to interface
+ // better with surrounding code, however I haven't done this
+ // without causing the AMD compiler to blow up the VGPR usage.
+ uint r = 0;
+ do
+ {
+ // This dynamic branch stops the AMD compiler unrolling the loop
+ // and additionally saves about 33% of the VGPRs, enough to gain another
+ // wavefront. Ideally we'd get 4 in flight, but 3 is the best I can
+ // massage out of the compiler. It doesn't really seem to matter how
+ // much we try and help the compiler save VGPRs because it seems to throw
+ // that information away, hence the implementation of keccak here
+ // doesn't bother.
+ if (isolate)
+ {
+ keccak_f1600_round((uint2*)a, r++, 25);
+ }
+ }
+ while (r < 23);
+
+ // final round optimised for digest size
+ keccak_f1600_round((uint2*)a, r++, out_size);
+}
+
+#define copy(dst, src, count) for (uint i = 0; i != count; ++i) { (dst)[i] = (src)[i]; }
+
+#define countof(x) (sizeof(x) / sizeof(x[0]))
+
+uint fnv(uint x, uint y)
+{
+ return x * FNV_PRIME ^ y;
+}
+
+uint4 fnv4(uint4 x, uint4 y)
+{
+ return x * FNV_PRIME ^ y;
+}
+
+uint fnv_reduce(uint4 v)
+{
+ return fnv(fnv(fnv(v.x, v.y), v.z), v.w);
+}
+
+typedef union
+{
+ ulong ulongs[32 / sizeof(ulong)];
+ uint uints[32 / sizeof(uint)];
+} hash32_t;
+
+typedef union
+{
+ ulong ulongs[64 / sizeof(ulong)];
+ uint4 uint4s[64 / sizeof(uint4)];
+} hash64_t;
+
+typedef union
+{
+ uint uints[128 / sizeof(uint)];
+ uint4 uint4s[128 / sizeof(uint4)];
+} hash128_t;
+
+hash64_t init_hash(__constant hash32_t const* header, ulong nonce, uint isolate)
+{
+ hash64_t init;
+ uint const init_size = countof(init.ulongs);
+ uint const hash_size = countof(header->ulongs);
+
+ // sha3_512(header .. nonce)
+ ulong state[25];
+ copy(state, header->ulongs, hash_size);
+ state[hash_size] = nonce;
+ keccak_f1600_no_absorb(state, hash_size + 1, init_size, isolate);
+
+ copy(init.ulongs, state, init_size);
+ return init;
+}
+
+uint inner_loop_chunks(uint4 init, uint thread_id, __local uint* share, __global hash128_t const* g_dag, __global hash128_t const* g_dag1, __global hash128_t const* g_dag2, __global hash128_t const* g_dag3, uint isolate)
+{
+ uint4 mix = init;
+
+ // share init0
+ if (thread_id == 0)
+ *share = mix.x;
+ barrier(CLK_LOCAL_MEM_FENCE);
+ uint init0 = *share;
+
+ uint a = 0;
+ do
+ {
+ bool update_share = thread_id == (a/4) % THREADS_PER_HASH;
+
+ #pragma unroll
+ for (uint i = 0; i != 4; ++i)
+ {
+ if (update_share)
+ {
+ uint m[4] = { mix.x, mix.y, mix.z, mix.w };
+ *share = fnv(init0 ^ (a+i), m[i]) % DAG_SIZE;
+ }
+ barrier(CLK_LOCAL_MEM_FENCE);
+
+ mix = fnv4(mix, *share>=3 * DAG_SIZE / 4 ? g_dag3[*share - 3 * DAG_SIZE / 4].uint4s[thread_id] : *share>=DAG_SIZE / 2 ? g_dag2[*share - DAG_SIZE / 2].uint4s[thread_id] : *share>=DAG_SIZE / 4 ? g_dag1[*share - DAG_SIZE / 4].uint4s[thread_id]:g_dag[*share].uint4s[thread_id]);
+ }
+ } while ((a += 4) != (ACCESSES & isolate));
+
+ return fnv_reduce(mix);
+}
+
+
+
+uint inner_loop(uint4 init, uint thread_id, __local uint* share, __global hash128_t const* g_dag, uint isolate)
+{
+ uint4 mix = init;
+
+ // share init0
+ if (thread_id == 0)
+ *share = mix.x;
+ barrier(CLK_LOCAL_MEM_FENCE);
+ uint init0 = *share;
+
+ uint a = 0;
+ do
+ {
+ bool update_share = thread_id == (a/4) % THREADS_PER_HASH;
+
+ #pragma unroll
+ for (uint i = 0; i != 4; ++i)
+ {
+ if (update_share)
+ {
+ uint m[4] = { mix.x, mix.y, mix.z, mix.w };
+ *share = fnv(init0 ^ (a+i), m[i]) % DAG_SIZE;
+ }
+ barrier(CLK_LOCAL_MEM_FENCE);
+
+ mix = fnv4(mix, g_dag[*share].uint4s[thread_id]);
+ }
+ }
+ while ((a += 4) != (ACCESSES & isolate));
+
+ return fnv_reduce(mix);
+}
+
+
+hash32_t final_hash(hash64_t const* init, hash32_t const* mix, uint isolate)
+{
+ ulong state[25];
+
+ hash32_t hash;
+ uint const hash_size = countof(hash.ulongs);
+ uint const init_size = countof(init->ulongs);
+ uint const mix_size = countof(mix->ulongs);
+
+ // keccak_256(keccak_512(header..nonce) .. mix);
+ copy(state, init->ulongs, init_size);
+ copy(state + init_size, mix->ulongs, mix_size);
+ keccak_f1600_no_absorb(state, init_size+mix_size, hash_size, isolate);
+
+ // copy out
+ copy(hash.ulongs, state, hash_size);
+ return hash;
+}
+
+hash32_t compute_hash_simple(
+ __constant hash32_t const* g_header,
+ __global hash128_t const* g_dag,
+ ulong nonce,
+ uint isolate
+ )
+{
+ hash64_t init = init_hash(g_header, nonce, isolate);
+
+ hash128_t mix;
+ for (uint i = 0; i != countof(mix.uint4s); ++i)
+ {
+ mix.uint4s[i] = init.uint4s[i % countof(init.uint4s)];
+ }
+
+ uint mix_val = mix.uints[0];
+ uint init0 = mix.uints[0];
+ uint a = 0;
+ do
+ {
+ uint pi = fnv(init0 ^ a, mix_val) % DAG_SIZE;
+ uint n = (a+1) % countof(mix.uints);
+
+ #pragma unroll
+ for (uint i = 0; i != countof(mix.uints); ++i)
+ {
+ mix.uints[i] = fnv(mix.uints[i], g_dag[pi].uints[i]);
+ mix_val = i == n ? mix.uints[i] : mix_val;
+ }
+ }
+ while (++a != (ACCESSES & isolate));
+
+ // reduce to output
+ hash32_t fnv_mix;
+ for (uint i = 0; i != countof(fnv_mix.uints); ++i)
+ {
+ fnv_mix.uints[i] = fnv_reduce(mix.uint4s[i]);
+ }
+
+ return final_hash(&init, &fnv_mix, isolate);
+}
+
+typedef union
+{
+ struct
+ {
+ hash64_t init;
+ uint pad; // avoid lds bank conflicts
+ };
+ hash32_t mix;
+} compute_hash_share;
+
+
+hash32_t compute_hash(
+ __local compute_hash_share* share,
+ __constant hash32_t const* g_header,
+ __global hash128_t const* g_dag,
+ ulong nonce,
+ uint isolate
+ )
+{
+ uint const gid = get_global_id(0);
+
+ // Compute one init hash per work item.
+ hash64_t init = init_hash(g_header, nonce, isolate);
+
+ // Threads work together in this phase in groups of 8.
+ uint const thread_id = gid % THREADS_PER_HASH;
+ uint const hash_id = (gid % GROUP_SIZE) / THREADS_PER_HASH;
+
+ hash32_t mix;
+ uint i = 0;
+ do
+ {
+ // share init with other threads
+ if (i == thread_id)
+ share[hash_id].init = init;
+ barrier(CLK_LOCAL_MEM_FENCE);
+
+ uint4 thread_init = share[hash_id].init.uint4s[thread_id % (64 / sizeof(uint4))];
+ barrier(CLK_LOCAL_MEM_FENCE);
+
+ uint thread_mix = inner_loop(thread_init, thread_id, share[hash_id].mix.uints, g_dag, isolate);
+
+ share[hash_id].mix.uints[thread_id] = thread_mix;
+ barrier(CLK_LOCAL_MEM_FENCE);
+
+ if (i == thread_id)
+ mix = share[hash_id].mix;
+ barrier(CLK_LOCAL_MEM_FENCE);
+ }
+ while (++i != (THREADS_PER_HASH & isolate));
+
+ return final_hash(&init, &mix, isolate);
+}
+
+
+hash32_t compute_hash_chunks(
+ __local compute_hash_share* share,
+ __constant hash32_t const* g_header,
+ __global hash128_t const* g_dag,
+ __global hash128_t const* g_dag1,
+ __global hash128_t const* g_dag2,
+ __global hash128_t const* g_dag3,
+ ulong nonce,
+ uint isolate
+ )
+{
+ uint const gid = get_global_id(0);
+
+ // Compute one init hash per work item.
+ hash64_t init = init_hash(g_header, nonce, isolate);
+
+ // Threads work together in this phase in groups of 8.
+ uint const thread_id = gid % THREADS_PER_HASH;
+ uint const hash_id = (gid % GROUP_SIZE) / THREADS_PER_HASH;
+
+ hash32_t mix;
+ uint i = 0;
+ do
+ {
+ // share init with other threads
+ if (i == thread_id)
+ share[hash_id].init = init;
+ barrier(CLK_LOCAL_MEM_FENCE);
+
+ uint4 thread_init = share[hash_id].init.uint4s[thread_id % (64 / sizeof(uint4))];
+ barrier(CLK_LOCAL_MEM_FENCE);
+
+ uint thread_mix = inner_loop_chunks(thread_init, thread_id, share[hash_id].mix.uints, g_dag, g_dag1, g_dag2, g_dag3, isolate);
+
+ share[hash_id].mix.uints[thread_id] = thread_mix;
+ barrier(CLK_LOCAL_MEM_FENCE);
+
+ if (i == thread_id)
+ mix = share[hash_id].mix;
+ barrier(CLK_LOCAL_MEM_FENCE);
+ }
+ while (++i != (THREADS_PER_HASH & isolate));
+
+ return final_hash(&init, &mix, isolate);
+}
+
+__attribute__((reqd_work_group_size(GROUP_SIZE, 1, 1)))
+__kernel void ethash_hash_simple(
+ __global hash32_t* g_hashes,
+ __constant hash32_t const* g_header,
+ __global hash128_t const* g_dag,
+ ulong start_nonce,
+ uint isolate
+ )
+{
+ uint const gid = get_global_id(0);
+ g_hashes[gid] = compute_hash_simple(g_header, g_dag, start_nonce + gid, isolate);
+}
+
+__attribute__((reqd_work_group_size(GROUP_SIZE, 1, 1)))
+__kernel void ethash_search_simple(
+ __global volatile uint* restrict g_output,
+ __constant hash32_t const* g_header,
+ __global hash128_t const* g_dag,
+ ulong start_nonce,
+ ulong target,
+ uint isolate
+ )
+{
+ uint const gid = get_global_id(0);
+ hash32_t hash = compute_hash_simple(g_header, g_dag, start_nonce + gid, isolate);
+
+ if (hash.ulongs[countof(hash.ulongs)-1] < target)
+ {
+ uint slot = min(convert_uint(MAX_OUTPUTS), convert_uint(atomic_inc(&g_output[0]) + 1));
+ g_output[slot] = gid;
+ }
+}
+
+
+__attribute__((reqd_work_group_size(GROUP_SIZE, 1, 1)))
+__kernel void ethash_hash(
+ __global hash32_t* g_hashes,
+ __constant hash32_t const* g_header,
+ __global hash128_t const* g_dag,
+ ulong start_nonce,
+ uint isolate
+ )
+{
+ __local compute_hash_share share[HASHES_PER_LOOP];
+
+ uint const gid = get_global_id(0);
+ g_hashes[gid] = compute_hash(share, g_header, g_dag, start_nonce + gid, isolate);
+}
+
+__attribute__((reqd_work_group_size(GROUP_SIZE, 1, 1)))
+__kernel void ethash_search(
+ __global volatile uint* restrict g_output,
+ __constant hash32_t const* g_header,
+ __global hash128_t const* g_dag,
+ ulong start_nonce,
+ ulong target,
+ uint isolate
+ )
+{
+ __local compute_hash_share share[HASHES_PER_LOOP];
+
+ uint const gid = get_global_id(0);
+ hash32_t hash = compute_hash(share, g_header, g_dag, start_nonce + gid, isolate);
+
+ if (as_ulong(as_uchar8(hash.ulongs[0]).s76543210) < target)
+ {
+ uint slot = min((uint)MAX_OUTPUTS, atomic_inc(&g_output[0]) + 1);
+ g_output[slot] = gid;
+ }
+}
+
+__attribute__((reqd_work_group_size(GROUP_SIZE, 1, 1)))
+__kernel void ethash_hash_chunks(
+ __global hash32_t* g_hashes,
+ __constant hash32_t const* g_header,
+ __global hash128_t const* g_dag,
+ __global hash128_t const* g_dag1,
+ __global hash128_t const* g_dag2,
+ __global hash128_t const* g_dag3,
+ ulong start_nonce,
+ uint isolate
+ )
+{
+ __local compute_hash_share share[HASHES_PER_LOOP];
+
+ uint const gid = get_global_id(0);
+ g_hashes[gid] = compute_hash_chunks(share, g_header, g_dag, g_dag1, g_dag2, g_dag3,start_nonce + gid, isolate);
+}
+
+__attribute__((reqd_work_group_size(GROUP_SIZE, 1, 1)))
+__kernel void ethash_search_chunks(
+ __global volatile uint* restrict g_output,
+ __constant hash32_t const* g_header,
+ __global hash128_t const* g_dag,
+ __global hash128_t const* g_dag1,
+ __global hash128_t const* g_dag2,
+ __global hash128_t const* g_dag3,
+ ulong start_nonce,
+ ulong target,
+ uint isolate
+ )
+{
+ __local compute_hash_share share[HASHES_PER_LOOP];
+
+ uint const gid = get_global_id(0);
+ hash32_t hash = compute_hash_chunks(share, g_header, g_dag, g_dag1, g_dag2, g_dag3, start_nonce + gid, isolate);
+
+ if (as_ulong(as_uchar8(hash.ulongs[0]).s76543210) < target)
+ {
+ uint slot = min(convert_uint(MAX_OUTPUTS), convert_uint(atomic_inc(&g_output[0]) + 1));
+ g_output[slot] = gid;
+ }
+}
+`
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/ethash_test.go b/Godeps/_workspace/src/github.com/ethereum/ethash/ethash_test.go
index 1e1de989d..e0ca0bd85 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/ethash_test.go
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/ethash_test.go
@@ -1,3 +1,20 @@
+// Copyright 2015 The go-ethereum Authors
+// Copyright 2015 Lefteris Karapetsas <lefteris@refu.co>
+// This file is part of the go-ethereum library.
+//
+// The go-ethereum library is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// The go-ethereum library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
+
package ethash
import (
@@ -92,7 +109,7 @@ func TestEthashConcurrentVerify(t *testing.T) {
defer os.RemoveAll(eth.Full.Dir)
block := &testBlock{difficulty: big.NewInt(10)}
- nonce, md := eth.Search(block, nil)
+ nonce, md := eth.Search(block, nil, 0)
block.nonce = nonce
block.mixDigest = common.BytesToHash(md)
@@ -135,7 +152,7 @@ func TestEthashConcurrentSearch(t *testing.T) {
// launch n searches concurrently.
for i := 0; i < nsearch; i++ {
go func() {
- nonce, md := eth.Search(block, stop)
+ nonce, md := eth.Search(block, stop, 0)
select {
case found <- searchRes{n: nonce, md: md}:
case <-stop:
@@ -167,7 +184,7 @@ func TestEthashSearchAcrossEpoch(t *testing.T) {
for i := epochLength - 40; i < epochLength+40; i++ {
block := &testBlock{number: i, difficulty: big.NewInt(90)}
rand.Read(block.hashNoNonce[:])
- nonce, md := eth.Search(block, nil)
+ nonce, md := eth.Search(block, nil, 0)
block.nonce = nonce
block.mixDigest = common.BytesToHash(md)
if !eth.Verify(block) {
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/ethashc.go b/Godeps/_workspace/src/github.com/ethereum/ethash/ethashc.go
index 8a441525d..1d2ba1613 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/ethashc.go
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/ethashc.go
@@ -1,3 +1,19 @@
+// Copyright 2015 The go-ethereum Authors
+// This file is part of the go-ethereum library.
+//
+// The go-ethereum library is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// The go-ethereum library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
+
package ethash
/*
diff --git a/Godeps/_workspace/src/github.com/huin/goupnp/.gitignore b/Godeps/_workspace/src/github.com/huin/goupnp/.gitignore
new file mode 100644
index 000000000..09ef375e8
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/huin/goupnp/.gitignore
@@ -0,0 +1 @@
+/gotasks/specs
diff --git a/Godeps/_workspace/src/github.com/huin/goupnp/README.md b/Godeps/_workspace/src/github.com/huin/goupnp/README.md
index ea2c155a1..a228ccea6 100644
--- a/Godeps/_workspace/src/github.com/huin/goupnp/README.md
+++ b/Godeps/_workspace/src/github.com/huin/goupnp/README.md
@@ -5,10 +5,40 @@ Installation
Run `go get -u github.com/huin/goupnp`.
+Documentation
+-------------
+
+All doc links below are for ![GoDoc](https://godoc.org/github.com/huin/goupnp?status.svg).
+
+Supported DCPs (you probably want to start with one of these):
+* [av1](https://godoc.org/github.com/huin/goupnp/dcps/av1) - Client for UPnP Device Control Protocol MediaServer v1 and MediaRenderer v1.
+* [internetgateway1](https://godoc.org/github.com/huin/goupnp/dcps/internetgateway1) - Client for UPnP Device Control Protocol Internet Gateway Device v1.
+* [internetgateway2](https://godoc.org/github.com/huin/goupnp/dcps/internetgateway2) - Client for UPnP Device Control Protocol Internet Gateway Device v2.
+
+Core components:
+* [(goupnp)](https://godoc.org/github.com/huin/goupnp) core library - contains datastructures and utilities typically used by the implemented DCPs.
+* [httpu](https://godoc.org/github.com/huin/goupnp/httpu) HTTPU implementation, underlies SSDP.
+* [ssdp](https://godoc.org/github.com/huin/goupnp/ssdp) SSDP client implementation (simple service discovery protocol) - used to discover UPnP services on a network.
+* [soap](https://godoc.org/github.com/huin/goupnp/soap) SOAP client implementation (simple object access protocol) - used to communicate with discovered services.
+
+
Regenerating dcps generated source code:
----------------------------------------
1. Install gotasks: `go get -u github.com/jingweno/gotask`
2. Change to the gotasks directory: `cd gotasks`
-3. Download UPnP specification data (if not done already): `wget http://upnp.org/resources/upnpresources.zip`
-4. Regenerate source code: `gotask specgen -s upnpresources.zip -o ../dcps`
+3. Run specgen task: `gotask specgen`
+
+Supporting additional UPnP devices and services:
+------------------------------------------------
+
+Supporting additional services is, in the trivial case, simply a matter of
+adding the service to the `dcpMetadata` whitelist in `gotasks/specgen_task.go`,
+regenerating the source code (see above), and committing that source code.
+
+However, it would be helpful if anyone needing such a service could test the
+service against the service they have, and then reporting any trouble
+encountered as an [issue on this
+project](https://github.com/huin/goupnp/issues/new). If it just works, then
+please report at least minimal working functionality as an issue, and
+optionally contribute the metadata upstream.
diff --git a/Godeps/_workspace/src/github.com/huin/goupnp/cmd/example_ssdp_registry/example_ssdp_registry.go b/Godeps/_workspace/src/github.com/huin/goupnp/cmd/example_ssdp_registry/example_ssdp_registry.go
new file mode 100644
index 000000000..05f0df003
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/huin/goupnp/cmd/example_ssdp_registry/example_ssdp_registry.go
@@ -0,0 +1,27 @@
+package main
+
+import (
+ "log"
+
+ "github.com/huin/goupnp/ssdp"
+)
+
+func main() {
+ c := make(chan ssdp.Update)
+ srv, reg := ssdp.NewServerAndRegistry()
+ reg.AddListener(c)
+ go listener(c)
+ if err := srv.ListenAndServe(); err != nil {
+ log.Print("ListenAndServe failed: ", err)
+ }
+}
+
+func listener(c <-chan ssdp.Update) {
+ for u := range c {
+ if u.Entry != nil {
+ log.Printf("Event: %v USN: %s Entry: %#v", u.EventType, u.USN, *u.Entry)
+ } else {
+ log.Printf("Event: %v USN: %s Entry: <nil>", u.EventType, u.USN)
+ }
+ }
+}
diff --git a/Godeps/_workspace/src/github.com/huin/goupnp/dcps/av1/av1.go b/Godeps/_workspace/src/github.com/huin/goupnp/dcps/av1/av1.go
new file mode 100644
index 000000000..5f9683d1f
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/huin/goupnp/dcps/av1/av1.go
@@ -0,0 +1,8452 @@
+// Client for UPnP Device Control Protocol MediaServer v1 and MediaRenderer v1.
+//
+// This DCP is documented in detail at: http://upnp.org/specs/av/av1/
+//
+// Typically, use one of the New* functions to create clients for services.
+package av1
+
+// Generated file - do not edit by hand. See README.md
+
+import (
+ "net/url"
+ "time"
+
+ "github.com/huin/goupnp"
+ "github.com/huin/goupnp/soap"
+)
+
+// Hack to avoid Go complaining if time isn't used.
+var _ time.Time
+
+// Device URNs:
+const ()
+
+// Service URNs:
+const (
+ URN_AVTransport_1 = "urn:schemas-upnp-org:service:AVTransport:1"
+ URN_AVTransport_2 = "urn:schemas-upnp-org:service:AVTransport:2"
+ URN_ConnectionManager_1 = "urn:schemas-upnp-org:service:ConnectionManager:1"
+ URN_ConnectionManager_2 = "urn:schemas-upnp-org:service:ConnectionManager:2"
+ URN_ContentDirectory_1 = "urn:schemas-upnp-org:service:ContentDirectory:1"
+ URN_ContentDirectory_2 = "urn:schemas-upnp-org:service:ContentDirectory:2"
+ URN_ContentDirectory_3 = "urn:schemas-upnp-org:service:ContentDirectory:3"
+ URN_RenderingControl_1 = "urn:schemas-upnp-org:service:RenderingControl:1"
+ URN_RenderingControl_2 = "urn:schemas-upnp-org:service:RenderingControl:2"
+ URN_ScheduledRecording_1 = "urn:schemas-upnp-org:service:ScheduledRecording:1"
+ URN_ScheduledRecording_2 = "urn:schemas-upnp-org:service:ScheduledRecording:2"
+)
+
+// AVTransport1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:AVTransport:1". See
+// goupnp.ServiceClient, which contains RootDevice and Service attributes which
+// are provided for informational value.
+type AVTransport1 struct {
+ goupnp.ServiceClient
+}
+
+// NewAVTransport1Clients discovers instances of the service on the network,
+// and returns clients to any that are found. errors will contain an error for
+// any devices that replied but which could not be queried, and err will be set
+// if the discovery process failed outright.
+//
+// This is a typical entry calling point into this package.
+func NewAVTransport1Clients() (clients []*AVTransport1, errors []error, err error) {
+ var genericClients []goupnp.ServiceClient
+ if genericClients, errors, err = goupnp.NewServiceClients(URN_AVTransport_1); err != nil {
+ return
+ }
+ clients = newAVTransport1ClientsFromGenericClients(genericClients)
+ return
+}
+
+// NewAVTransport1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewAVTransport1ClientsByURL(loc *url.URL) ([]*AVTransport1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_AVTransport_1)
+ if err != nil {
+ return nil, err
+ }
+ return newAVTransport1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewAVTransport1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewAVTransport1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*AVTransport1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_AVTransport_1)
+ if err != nil {
+ return nil, err
+ }
+ return newAVTransport1ClientsFromGenericClients(genericClients), nil
+}
+
+func newAVTransport1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*AVTransport1 {
+ clients := make([]*AVTransport1, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &AVTransport1{genericClients[i]}
+ }
+ return clients
+}
+
+func (client *AVTransport1) SetAVTransportURI(InstanceID uint32, CurrentURI string, CurrentURIMetaData string) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ CurrentURI string
+
+ CurrentURIMetaData string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.CurrentURI, err = soap.MarshalString(CurrentURI); err != nil {
+ return
+ }
+ if request.CurrentURIMetaData, err = soap.MarshalString(CurrentURIMetaData); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_1, "SetAVTransportURI", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *AVTransport1) SetNextAVTransportURI(InstanceID uint32, NextURI string, NextURIMetaData string) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ NextURI string
+
+ NextURIMetaData string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.NextURI, err = soap.MarshalString(NextURI); err != nil {
+ return
+ }
+ if request.NextURIMetaData, err = soap.MarshalString(NextURIMetaData); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_1, "SetNextAVTransportURI", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * NrTracks: allowed value range: minimum=0
+func (client *AVTransport1) GetMediaInfo(InstanceID uint32) (NrTracks uint32, MediaDuration string, CurrentURI string, CurrentURIMetaData string, NextURI string, NextURIMetaData string, PlayMedium string, RecordMedium string, WriteStatus string, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ NrTracks string
+
+ MediaDuration string
+
+ CurrentURI string
+
+ CurrentURIMetaData string
+
+ NextURI string
+
+ NextURIMetaData string
+
+ PlayMedium string
+
+ RecordMedium string
+
+ WriteStatus string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_1, "GetMediaInfo", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if NrTracks, err = soap.UnmarshalUi4(response.NrTracks); err != nil {
+ return
+ }
+ if MediaDuration, err = soap.UnmarshalString(response.MediaDuration); err != nil {
+ return
+ }
+ if CurrentURI, err = soap.UnmarshalString(response.CurrentURI); err != nil {
+ return
+ }
+ if CurrentURIMetaData, err = soap.UnmarshalString(response.CurrentURIMetaData); err != nil {
+ return
+ }
+ if NextURI, err = soap.UnmarshalString(response.NextURI); err != nil {
+ return
+ }
+ if NextURIMetaData, err = soap.UnmarshalString(response.NextURIMetaData); err != nil {
+ return
+ }
+ if PlayMedium, err = soap.UnmarshalString(response.PlayMedium); err != nil {
+ return
+ }
+ if RecordMedium, err = soap.UnmarshalString(response.RecordMedium); err != nil {
+ return
+ }
+ if WriteStatus, err = soap.UnmarshalString(response.WriteStatus); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentTransportState: allowed values: STOPPED, PLAYING
+//
+// * CurrentTransportStatus: allowed values: OK, ERROR_OCCURRED
+//
+// * CurrentSpeed: allowed values: 1
+func (client *AVTransport1) GetTransportInfo(InstanceID uint32) (CurrentTransportState string, CurrentTransportStatus string, CurrentSpeed string, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentTransportState string
+
+ CurrentTransportStatus string
+
+ CurrentSpeed string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_1, "GetTransportInfo", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentTransportState, err = soap.UnmarshalString(response.CurrentTransportState); err != nil {
+ return
+ }
+ if CurrentTransportStatus, err = soap.UnmarshalString(response.CurrentTransportStatus); err != nil {
+ return
+ }
+ if CurrentSpeed, err = soap.UnmarshalString(response.CurrentSpeed); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * Track: allowed value range: minimum=0, step=1
+func (client *AVTransport1) GetPositionInfo(InstanceID uint32) (Track uint32, TrackDuration string, TrackMetaData string, TrackURI string, RelTime string, AbsTime string, RelCount int32, AbsCount int32, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Track string
+
+ TrackDuration string
+
+ TrackMetaData string
+
+ TrackURI string
+
+ RelTime string
+
+ AbsTime string
+
+ RelCount string
+
+ AbsCount string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_1, "GetPositionInfo", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Track, err = soap.UnmarshalUi4(response.Track); err != nil {
+ return
+ }
+ if TrackDuration, err = soap.UnmarshalString(response.TrackDuration); err != nil {
+ return
+ }
+ if TrackMetaData, err = soap.UnmarshalString(response.TrackMetaData); err != nil {
+ return
+ }
+ if TrackURI, err = soap.UnmarshalString(response.TrackURI); err != nil {
+ return
+ }
+ if RelTime, err = soap.UnmarshalString(response.RelTime); err != nil {
+ return
+ }
+ if AbsTime, err = soap.UnmarshalString(response.AbsTime); err != nil {
+ return
+ }
+ if RelCount, err = soap.UnmarshalI4(response.RelCount); err != nil {
+ return
+ }
+ if AbsCount, err = soap.UnmarshalI4(response.AbsCount); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *AVTransport1) GetDeviceCapabilities(InstanceID uint32) (PlayMedia string, RecMedia string, RecQualityModes string, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ PlayMedia string
+
+ RecMedia string
+
+ RecQualityModes string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_1, "GetDeviceCapabilities", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if PlayMedia, err = soap.UnmarshalString(response.PlayMedia); err != nil {
+ return
+ }
+ if RecMedia, err = soap.UnmarshalString(response.RecMedia); err != nil {
+ return
+ }
+ if RecQualityModes, err = soap.UnmarshalString(response.RecQualityModes); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * PlayMode: allowed values: NORMAL
+func (client *AVTransport1) GetTransportSettings(InstanceID uint32) (PlayMode string, RecQualityMode string, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ PlayMode string
+
+ RecQualityMode string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_1, "GetTransportSettings", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if PlayMode, err = soap.UnmarshalString(response.PlayMode); err != nil {
+ return
+ }
+ if RecQualityMode, err = soap.UnmarshalString(response.RecQualityMode); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *AVTransport1) Stop(InstanceID uint32) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_1, "Stop", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Speed: allowed values: 1
+
+func (client *AVTransport1) Play(InstanceID uint32, Speed string) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ Speed string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.Speed, err = soap.MarshalString(Speed); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_1, "Play", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *AVTransport1) Pause(InstanceID uint32) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_1, "Pause", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *AVTransport1) Record(InstanceID uint32) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_1, "Record", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Unit: allowed values: TRACK_NR
+
+func (client *AVTransport1) Seek(InstanceID uint32, Unit string, Target string) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ Unit string
+
+ Target string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.Unit, err = soap.MarshalString(Unit); err != nil {
+ return
+ }
+ if request.Target, err = soap.MarshalString(Target); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_1, "Seek", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *AVTransport1) Next(InstanceID uint32) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_1, "Next", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *AVTransport1) Previous(InstanceID uint32) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_1, "Previous", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * NewPlayMode: allowed values: NORMAL
+
+func (client *AVTransport1) SetPlayMode(InstanceID uint32, NewPlayMode string) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ NewPlayMode string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.NewPlayMode, err = soap.MarshalString(NewPlayMode); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_1, "SetPlayMode", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *AVTransport1) SetRecordQualityMode(InstanceID uint32, NewRecordQualityMode string) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ NewRecordQualityMode string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.NewRecordQualityMode, err = soap.MarshalString(NewRecordQualityMode); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_1, "SetRecordQualityMode", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *AVTransport1) GetCurrentTransportActions(InstanceID uint32) (Actions string, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Actions string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_1, "GetCurrentTransportActions", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Actions, err = soap.UnmarshalString(response.Actions); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+// AVTransport2 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:AVTransport:2". See
+// goupnp.ServiceClient, which contains RootDevice and Service attributes which
+// are provided for informational value.
+type AVTransport2 struct {
+ goupnp.ServiceClient
+}
+
+// NewAVTransport2Clients discovers instances of the service on the network,
+// and returns clients to any that are found. errors will contain an error for
+// any devices that replied but which could not be queried, and err will be set
+// if the discovery process failed outright.
+//
+// This is a typical entry calling point into this package.
+func NewAVTransport2Clients() (clients []*AVTransport2, errors []error, err error) {
+ var genericClients []goupnp.ServiceClient
+ if genericClients, errors, err = goupnp.NewServiceClients(URN_AVTransport_2); err != nil {
+ return
+ }
+ clients = newAVTransport2ClientsFromGenericClients(genericClients)
+ return
+}
+
+// NewAVTransport2ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewAVTransport2ClientsByURL(loc *url.URL) ([]*AVTransport2, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_AVTransport_2)
+ if err != nil {
+ return nil, err
+ }
+ return newAVTransport2ClientsFromGenericClients(genericClients), nil
+}
+
+// NewAVTransport2ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewAVTransport2ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*AVTransport2, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_AVTransport_2)
+ if err != nil {
+ return nil, err
+ }
+ return newAVTransport2ClientsFromGenericClients(genericClients), nil
+}
+
+func newAVTransport2ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*AVTransport2 {
+ clients := make([]*AVTransport2, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &AVTransport2{genericClients[i]}
+ }
+ return clients
+}
+
+func (client *AVTransport2) SetAVTransportURI(InstanceID uint32, CurrentURI string, CurrentURIMetaData string) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ CurrentURI string
+
+ CurrentURIMetaData string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.CurrentURI, err = soap.MarshalString(CurrentURI); err != nil {
+ return
+ }
+ if request.CurrentURIMetaData, err = soap.MarshalString(CurrentURIMetaData); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_2, "SetAVTransportURI", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *AVTransport2) SetNextAVTransportURI(InstanceID uint32, NextURI string, NextURIMetaData string) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ NextURI string
+
+ NextURIMetaData string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.NextURI, err = soap.MarshalString(NextURI); err != nil {
+ return
+ }
+ if request.NextURIMetaData, err = soap.MarshalString(NextURIMetaData); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_2, "SetNextAVTransportURI", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * NrTracks: allowed value range: minimum=0
+func (client *AVTransport2) GetMediaInfo(InstanceID uint32) (NrTracks uint32, MediaDuration string, CurrentURI string, CurrentURIMetaData string, NextURI string, NextURIMetaData string, PlayMedium string, RecordMedium string, WriteStatus string, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ NrTracks string
+
+ MediaDuration string
+
+ CurrentURI string
+
+ CurrentURIMetaData string
+
+ NextURI string
+
+ NextURIMetaData string
+
+ PlayMedium string
+
+ RecordMedium string
+
+ WriteStatus string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_2, "GetMediaInfo", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if NrTracks, err = soap.UnmarshalUi4(response.NrTracks); err != nil {
+ return
+ }
+ if MediaDuration, err = soap.UnmarshalString(response.MediaDuration); err != nil {
+ return
+ }
+ if CurrentURI, err = soap.UnmarshalString(response.CurrentURI); err != nil {
+ return
+ }
+ if CurrentURIMetaData, err = soap.UnmarshalString(response.CurrentURIMetaData); err != nil {
+ return
+ }
+ if NextURI, err = soap.UnmarshalString(response.NextURI); err != nil {
+ return
+ }
+ if NextURIMetaData, err = soap.UnmarshalString(response.NextURIMetaData); err != nil {
+ return
+ }
+ if PlayMedium, err = soap.UnmarshalString(response.PlayMedium); err != nil {
+ return
+ }
+ if RecordMedium, err = soap.UnmarshalString(response.RecordMedium); err != nil {
+ return
+ }
+ if WriteStatus, err = soap.UnmarshalString(response.WriteStatus); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentType: allowed values: NO_MEDIA, TRACK_AWARE, TRACK_UNAWARE
+//
+// * NrTracks: allowed value range: minimum=0
+func (client *AVTransport2) GetMediaInfo_Ext(InstanceID uint32) (CurrentType string, NrTracks uint32, MediaDuration string, CurrentURI string, CurrentURIMetaData string, NextURI string, NextURIMetaData string, PlayMedium string, RecordMedium string, WriteStatus string, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentType string
+
+ NrTracks string
+
+ MediaDuration string
+
+ CurrentURI string
+
+ CurrentURIMetaData string
+
+ NextURI string
+
+ NextURIMetaData string
+
+ PlayMedium string
+
+ RecordMedium string
+
+ WriteStatus string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_2, "GetMediaInfo_Ext", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentType, err = soap.UnmarshalString(response.CurrentType); err != nil {
+ return
+ }
+ if NrTracks, err = soap.UnmarshalUi4(response.NrTracks); err != nil {
+ return
+ }
+ if MediaDuration, err = soap.UnmarshalString(response.MediaDuration); err != nil {
+ return
+ }
+ if CurrentURI, err = soap.UnmarshalString(response.CurrentURI); err != nil {
+ return
+ }
+ if CurrentURIMetaData, err = soap.UnmarshalString(response.CurrentURIMetaData); err != nil {
+ return
+ }
+ if NextURI, err = soap.UnmarshalString(response.NextURI); err != nil {
+ return
+ }
+ if NextURIMetaData, err = soap.UnmarshalString(response.NextURIMetaData); err != nil {
+ return
+ }
+ if PlayMedium, err = soap.UnmarshalString(response.PlayMedium); err != nil {
+ return
+ }
+ if RecordMedium, err = soap.UnmarshalString(response.RecordMedium); err != nil {
+ return
+ }
+ if WriteStatus, err = soap.UnmarshalString(response.WriteStatus); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentTransportState: allowed values: STOPPED, PLAYING
+//
+// * CurrentTransportStatus: allowed values: OK, ERROR_OCCURRED
+//
+// * CurrentSpeed: allowed values: 1
+func (client *AVTransport2) GetTransportInfo(InstanceID uint32) (CurrentTransportState string, CurrentTransportStatus string, CurrentSpeed string, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentTransportState string
+
+ CurrentTransportStatus string
+
+ CurrentSpeed string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_2, "GetTransportInfo", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentTransportState, err = soap.UnmarshalString(response.CurrentTransportState); err != nil {
+ return
+ }
+ if CurrentTransportStatus, err = soap.UnmarshalString(response.CurrentTransportStatus); err != nil {
+ return
+ }
+ if CurrentSpeed, err = soap.UnmarshalString(response.CurrentSpeed); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * Track: allowed value range: minimum=0, step=1
+func (client *AVTransport2) GetPositionInfo(InstanceID uint32) (Track uint32, TrackDuration string, TrackMetaData string, TrackURI string, RelTime string, AbsTime string, RelCount int32, AbsCount int32, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Track string
+
+ TrackDuration string
+
+ TrackMetaData string
+
+ TrackURI string
+
+ RelTime string
+
+ AbsTime string
+
+ RelCount string
+
+ AbsCount string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_2, "GetPositionInfo", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Track, err = soap.UnmarshalUi4(response.Track); err != nil {
+ return
+ }
+ if TrackDuration, err = soap.UnmarshalString(response.TrackDuration); err != nil {
+ return
+ }
+ if TrackMetaData, err = soap.UnmarshalString(response.TrackMetaData); err != nil {
+ return
+ }
+ if TrackURI, err = soap.UnmarshalString(response.TrackURI); err != nil {
+ return
+ }
+ if RelTime, err = soap.UnmarshalString(response.RelTime); err != nil {
+ return
+ }
+ if AbsTime, err = soap.UnmarshalString(response.AbsTime); err != nil {
+ return
+ }
+ if RelCount, err = soap.UnmarshalI4(response.RelCount); err != nil {
+ return
+ }
+ if AbsCount, err = soap.UnmarshalI4(response.AbsCount); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *AVTransport2) GetDeviceCapabilities(InstanceID uint32) (PlayMedia string, RecMedia string, RecQualityModes string, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ PlayMedia string
+
+ RecMedia string
+
+ RecQualityModes string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_2, "GetDeviceCapabilities", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if PlayMedia, err = soap.UnmarshalString(response.PlayMedia); err != nil {
+ return
+ }
+ if RecMedia, err = soap.UnmarshalString(response.RecMedia); err != nil {
+ return
+ }
+ if RecQualityModes, err = soap.UnmarshalString(response.RecQualityModes); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * PlayMode: allowed values: NORMAL
+func (client *AVTransport2) GetTransportSettings(InstanceID uint32) (PlayMode string, RecQualityMode string, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ PlayMode string
+
+ RecQualityMode string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_2, "GetTransportSettings", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if PlayMode, err = soap.UnmarshalString(response.PlayMode); err != nil {
+ return
+ }
+ if RecQualityMode, err = soap.UnmarshalString(response.RecQualityMode); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *AVTransport2) Stop(InstanceID uint32) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_2, "Stop", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Speed: allowed values: 1
+
+func (client *AVTransport2) Play(InstanceID uint32, Speed string) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ Speed string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.Speed, err = soap.MarshalString(Speed); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_2, "Play", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *AVTransport2) Pause(InstanceID uint32) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_2, "Pause", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *AVTransport2) Record(InstanceID uint32) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_2, "Record", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Unit: allowed values: TRACK_NR
+
+func (client *AVTransport2) Seek(InstanceID uint32, Unit string, Target string) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ Unit string
+
+ Target string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.Unit, err = soap.MarshalString(Unit); err != nil {
+ return
+ }
+ if request.Target, err = soap.MarshalString(Target); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_2, "Seek", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *AVTransport2) Next(InstanceID uint32) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_2, "Next", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *AVTransport2) Previous(InstanceID uint32) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_2, "Previous", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * NewPlayMode: allowed values: NORMAL
+
+func (client *AVTransport2) SetPlayMode(InstanceID uint32, NewPlayMode string) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ NewPlayMode string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.NewPlayMode, err = soap.MarshalString(NewPlayMode); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_2, "SetPlayMode", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *AVTransport2) SetRecordQualityMode(InstanceID uint32, NewRecordQualityMode string) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ NewRecordQualityMode string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.NewRecordQualityMode, err = soap.MarshalString(NewRecordQualityMode); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_2, "SetRecordQualityMode", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *AVTransport2) GetCurrentTransportActions(InstanceID uint32) (Actions string, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Actions string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_2, "GetCurrentTransportActions", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Actions, err = soap.UnmarshalString(response.Actions); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentDRMState: allowed values: OK
+func (client *AVTransport2) GetDRMState(InstanceID uint32) (CurrentDRMState string, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentDRMState string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_2, "GetDRMState", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentDRMState, err = soap.UnmarshalString(response.CurrentDRMState); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *AVTransport2) GetStateVariables(InstanceID uint32, StateVariableList string) (StateVariableValuePairs string, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ StateVariableList string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.StateVariableList, err = soap.MarshalString(StateVariableList); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ StateVariableValuePairs string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_2, "GetStateVariables", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if StateVariableValuePairs, err = soap.UnmarshalString(response.StateVariableValuePairs); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *AVTransport2) SetStateVariables(InstanceID uint32, AVTransportUDN string, ServiceType string, ServiceId string, StateVariableValuePairs string) (StateVariableList string, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ AVTransportUDN string
+
+ ServiceType string
+
+ ServiceId string
+
+ StateVariableValuePairs string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.AVTransportUDN, err = soap.MarshalString(AVTransportUDN); err != nil {
+ return
+ }
+ if request.ServiceType, err = soap.MarshalString(ServiceType); err != nil {
+ return
+ }
+ if request.ServiceId, err = soap.MarshalString(ServiceId); err != nil {
+ return
+ }
+ if request.StateVariableValuePairs, err = soap.MarshalString(StateVariableValuePairs); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ StateVariableList string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_AVTransport_2, "SetStateVariables", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if StateVariableList, err = soap.UnmarshalString(response.StateVariableList); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+// ConnectionManager1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:ConnectionManager:1". See
+// goupnp.ServiceClient, which contains RootDevice and Service attributes which
+// are provided for informational value.
+type ConnectionManager1 struct {
+ goupnp.ServiceClient
+}
+
+// NewConnectionManager1Clients discovers instances of the service on the network,
+// and returns clients to any that are found. errors will contain an error for
+// any devices that replied but which could not be queried, and err will be set
+// if the discovery process failed outright.
+//
+// This is a typical entry calling point into this package.
+func NewConnectionManager1Clients() (clients []*ConnectionManager1, errors []error, err error) {
+ var genericClients []goupnp.ServiceClient
+ if genericClients, errors, err = goupnp.NewServiceClients(URN_ConnectionManager_1); err != nil {
+ return
+ }
+ clients = newConnectionManager1ClientsFromGenericClients(genericClients)
+ return
+}
+
+// NewConnectionManager1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewConnectionManager1ClientsByURL(loc *url.URL) ([]*ConnectionManager1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_ConnectionManager_1)
+ if err != nil {
+ return nil, err
+ }
+ return newConnectionManager1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewConnectionManager1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewConnectionManager1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*ConnectionManager1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_ConnectionManager_1)
+ if err != nil {
+ return nil, err
+ }
+ return newConnectionManager1ClientsFromGenericClients(genericClients), nil
+}
+
+func newConnectionManager1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*ConnectionManager1 {
+ clients := make([]*ConnectionManager1, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &ConnectionManager1{genericClients[i]}
+ }
+ return clients
+}
+
+func (client *ConnectionManager1) GetProtocolInfo() (Source string, Sink string, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Source string
+
+ Sink string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ConnectionManager_1, "GetProtocolInfo", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Source, err = soap.UnmarshalString(response.Source); err != nil {
+ return
+ }
+ if Sink, err = soap.UnmarshalString(response.Sink); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Direction: allowed values: Input, Output
+
+func (client *ConnectionManager1) PrepareForConnection(RemoteProtocolInfo string, PeerConnectionManager string, PeerConnectionID int32, Direction string) (ConnectionID int32, AVTransportID int32, RcsID int32, err error) {
+ // Request structure.
+ request := &struct {
+ RemoteProtocolInfo string
+
+ PeerConnectionManager string
+
+ PeerConnectionID string
+
+ Direction string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RemoteProtocolInfo, err = soap.MarshalString(RemoteProtocolInfo); err != nil {
+ return
+ }
+ if request.PeerConnectionManager, err = soap.MarshalString(PeerConnectionManager); err != nil {
+ return
+ }
+ if request.PeerConnectionID, err = soap.MarshalI4(PeerConnectionID); err != nil {
+ return
+ }
+ if request.Direction, err = soap.MarshalString(Direction); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ ConnectionID string
+
+ AVTransportID string
+
+ RcsID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ConnectionManager_1, "PrepareForConnection", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if ConnectionID, err = soap.UnmarshalI4(response.ConnectionID); err != nil {
+ return
+ }
+ if AVTransportID, err = soap.UnmarshalI4(response.AVTransportID); err != nil {
+ return
+ }
+ if RcsID, err = soap.UnmarshalI4(response.RcsID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ConnectionManager1) ConnectionComplete(ConnectionID int32) (err error) {
+ // Request structure.
+ request := &struct {
+ ConnectionID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ConnectionID, err = soap.MarshalI4(ConnectionID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ConnectionManager_1, "ConnectionComplete", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ConnectionManager1) GetCurrentConnectionIDs() (ConnectionIDs string, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ ConnectionIDs string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ConnectionManager_1, "GetCurrentConnectionIDs", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if ConnectionIDs, err = soap.UnmarshalString(response.ConnectionIDs); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * Direction: allowed values: Input, Output
+//
+// * Status: allowed values: OK, ContentFormatMismatch, InsufficientBandwidth, UnreliableChannel, Unknown
+func (client *ConnectionManager1) GetCurrentConnectionInfo(ConnectionID int32) (RcsID int32, AVTransportID int32, ProtocolInfo string, PeerConnectionManager string, PeerConnectionID int32, Direction string, Status string, err error) {
+ // Request structure.
+ request := &struct {
+ ConnectionID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ConnectionID, err = soap.MarshalI4(ConnectionID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ RcsID string
+
+ AVTransportID string
+
+ ProtocolInfo string
+
+ PeerConnectionManager string
+
+ PeerConnectionID string
+
+ Direction string
+
+ Status string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ConnectionManager_1, "GetCurrentConnectionInfo", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if RcsID, err = soap.UnmarshalI4(response.RcsID); err != nil {
+ return
+ }
+ if AVTransportID, err = soap.UnmarshalI4(response.AVTransportID); err != nil {
+ return
+ }
+ if ProtocolInfo, err = soap.UnmarshalString(response.ProtocolInfo); err != nil {
+ return
+ }
+ if PeerConnectionManager, err = soap.UnmarshalString(response.PeerConnectionManager); err != nil {
+ return
+ }
+ if PeerConnectionID, err = soap.UnmarshalI4(response.PeerConnectionID); err != nil {
+ return
+ }
+ if Direction, err = soap.UnmarshalString(response.Direction); err != nil {
+ return
+ }
+ if Status, err = soap.UnmarshalString(response.Status); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+// ConnectionManager2 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:ConnectionManager:2". See
+// goupnp.ServiceClient, which contains RootDevice and Service attributes which
+// are provided for informational value.
+type ConnectionManager2 struct {
+ goupnp.ServiceClient
+}
+
+// NewConnectionManager2Clients discovers instances of the service on the network,
+// and returns clients to any that are found. errors will contain an error for
+// any devices that replied but which could not be queried, and err will be set
+// if the discovery process failed outright.
+//
+// This is a typical entry calling point into this package.
+func NewConnectionManager2Clients() (clients []*ConnectionManager2, errors []error, err error) {
+ var genericClients []goupnp.ServiceClient
+ if genericClients, errors, err = goupnp.NewServiceClients(URN_ConnectionManager_2); err != nil {
+ return
+ }
+ clients = newConnectionManager2ClientsFromGenericClients(genericClients)
+ return
+}
+
+// NewConnectionManager2ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewConnectionManager2ClientsByURL(loc *url.URL) ([]*ConnectionManager2, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_ConnectionManager_2)
+ if err != nil {
+ return nil, err
+ }
+ return newConnectionManager2ClientsFromGenericClients(genericClients), nil
+}
+
+// NewConnectionManager2ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewConnectionManager2ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*ConnectionManager2, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_ConnectionManager_2)
+ if err != nil {
+ return nil, err
+ }
+ return newConnectionManager2ClientsFromGenericClients(genericClients), nil
+}
+
+func newConnectionManager2ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*ConnectionManager2 {
+ clients := make([]*ConnectionManager2, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &ConnectionManager2{genericClients[i]}
+ }
+ return clients
+}
+
+func (client *ConnectionManager2) GetProtocolInfo() (Source string, Sink string, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Source string
+
+ Sink string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ConnectionManager_2, "GetProtocolInfo", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Source, err = soap.UnmarshalString(response.Source); err != nil {
+ return
+ }
+ if Sink, err = soap.UnmarshalString(response.Sink); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Direction: allowed values: Input, Output
+
+func (client *ConnectionManager2) PrepareForConnection(RemoteProtocolInfo string, PeerConnectionManager string, PeerConnectionID int32, Direction string) (ConnectionID int32, AVTransportID int32, RcsID int32, err error) {
+ // Request structure.
+ request := &struct {
+ RemoteProtocolInfo string
+
+ PeerConnectionManager string
+
+ PeerConnectionID string
+
+ Direction string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RemoteProtocolInfo, err = soap.MarshalString(RemoteProtocolInfo); err != nil {
+ return
+ }
+ if request.PeerConnectionManager, err = soap.MarshalString(PeerConnectionManager); err != nil {
+ return
+ }
+ if request.PeerConnectionID, err = soap.MarshalI4(PeerConnectionID); err != nil {
+ return
+ }
+ if request.Direction, err = soap.MarshalString(Direction); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ ConnectionID string
+
+ AVTransportID string
+
+ RcsID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ConnectionManager_2, "PrepareForConnection", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if ConnectionID, err = soap.UnmarshalI4(response.ConnectionID); err != nil {
+ return
+ }
+ if AVTransportID, err = soap.UnmarshalI4(response.AVTransportID); err != nil {
+ return
+ }
+ if RcsID, err = soap.UnmarshalI4(response.RcsID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ConnectionManager2) ConnectionComplete(ConnectionID int32) (err error) {
+ // Request structure.
+ request := &struct {
+ ConnectionID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ConnectionID, err = soap.MarshalI4(ConnectionID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ConnectionManager_2, "ConnectionComplete", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ConnectionManager2) GetCurrentConnectionIDs() (ConnectionIDs string, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ ConnectionIDs string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ConnectionManager_2, "GetCurrentConnectionIDs", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if ConnectionIDs, err = soap.UnmarshalString(response.ConnectionIDs); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * Direction: allowed values: Input, Output
+//
+// * Status: allowed values: OK, ContentFormatMismatch, InsufficientBandwidth, UnreliableChannel, Unknown
+func (client *ConnectionManager2) GetCurrentConnectionInfo(ConnectionID int32) (RcsID int32, AVTransportID int32, ProtocolInfo string, PeerConnectionManager string, PeerConnectionID int32, Direction string, Status string, err error) {
+ // Request structure.
+ request := &struct {
+ ConnectionID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ConnectionID, err = soap.MarshalI4(ConnectionID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ RcsID string
+
+ AVTransportID string
+
+ ProtocolInfo string
+
+ PeerConnectionManager string
+
+ PeerConnectionID string
+
+ Direction string
+
+ Status string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ConnectionManager_2, "GetCurrentConnectionInfo", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if RcsID, err = soap.UnmarshalI4(response.RcsID); err != nil {
+ return
+ }
+ if AVTransportID, err = soap.UnmarshalI4(response.AVTransportID); err != nil {
+ return
+ }
+ if ProtocolInfo, err = soap.UnmarshalString(response.ProtocolInfo); err != nil {
+ return
+ }
+ if PeerConnectionManager, err = soap.UnmarshalString(response.PeerConnectionManager); err != nil {
+ return
+ }
+ if PeerConnectionID, err = soap.UnmarshalI4(response.PeerConnectionID); err != nil {
+ return
+ }
+ if Direction, err = soap.UnmarshalString(response.Direction); err != nil {
+ return
+ }
+ if Status, err = soap.UnmarshalString(response.Status); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+// ContentDirectory1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:ContentDirectory:1". See
+// goupnp.ServiceClient, which contains RootDevice and Service attributes which
+// are provided for informational value.
+type ContentDirectory1 struct {
+ goupnp.ServiceClient
+}
+
+// NewContentDirectory1Clients discovers instances of the service on the network,
+// and returns clients to any that are found. errors will contain an error for
+// any devices that replied but which could not be queried, and err will be set
+// if the discovery process failed outright.
+//
+// This is a typical entry calling point into this package.
+func NewContentDirectory1Clients() (clients []*ContentDirectory1, errors []error, err error) {
+ var genericClients []goupnp.ServiceClient
+ if genericClients, errors, err = goupnp.NewServiceClients(URN_ContentDirectory_1); err != nil {
+ return
+ }
+ clients = newContentDirectory1ClientsFromGenericClients(genericClients)
+ return
+}
+
+// NewContentDirectory1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewContentDirectory1ClientsByURL(loc *url.URL) ([]*ContentDirectory1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_ContentDirectory_1)
+ if err != nil {
+ return nil, err
+ }
+ return newContentDirectory1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewContentDirectory1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewContentDirectory1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*ContentDirectory1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_ContentDirectory_1)
+ if err != nil {
+ return nil, err
+ }
+ return newContentDirectory1ClientsFromGenericClients(genericClients), nil
+}
+
+func newContentDirectory1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*ContentDirectory1 {
+ clients := make([]*ContentDirectory1, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &ContentDirectory1{genericClients[i]}
+ }
+ return clients
+}
+
+func (client *ContentDirectory1) GetSearchCapabilities() (SearchCaps string, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ SearchCaps string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_1, "GetSearchCapabilities", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if SearchCaps, err = soap.UnmarshalString(response.SearchCaps); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory1) GetSortCapabilities() (SortCaps string, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ SortCaps string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_1, "GetSortCapabilities", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if SortCaps, err = soap.UnmarshalString(response.SortCaps); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory1) GetSystemUpdateID() (Id uint32, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Id string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_1, "GetSystemUpdateID", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Id, err = soap.UnmarshalUi4(response.Id); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * BrowseFlag: allowed values: BrowseMetadata, BrowseDirectChildren
+
+func (client *ContentDirectory1) Browse(ObjectID string, BrowseFlag string, Filter string, StartingIndex uint32, RequestedCount uint32, SortCriteria string) (Result string, NumberReturned uint32, TotalMatches uint32, UpdateID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ ObjectID string
+
+ BrowseFlag string
+
+ Filter string
+
+ StartingIndex string
+
+ RequestedCount string
+
+ SortCriteria string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ObjectID, err = soap.MarshalString(ObjectID); err != nil {
+ return
+ }
+ if request.BrowseFlag, err = soap.MarshalString(BrowseFlag); err != nil {
+ return
+ }
+ if request.Filter, err = soap.MarshalString(Filter); err != nil {
+ return
+ }
+ if request.StartingIndex, err = soap.MarshalUi4(StartingIndex); err != nil {
+ return
+ }
+ if request.RequestedCount, err = soap.MarshalUi4(RequestedCount); err != nil {
+ return
+ }
+ if request.SortCriteria, err = soap.MarshalString(SortCriteria); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Result string
+
+ NumberReturned string
+
+ TotalMatches string
+
+ UpdateID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_1, "Browse", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Result, err = soap.UnmarshalString(response.Result); err != nil {
+ return
+ }
+ if NumberReturned, err = soap.UnmarshalUi4(response.NumberReturned); err != nil {
+ return
+ }
+ if TotalMatches, err = soap.UnmarshalUi4(response.TotalMatches); err != nil {
+ return
+ }
+ if UpdateID, err = soap.UnmarshalUi4(response.UpdateID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory1) Search(ContainerID string, SearchCriteria string, Filter string, StartingIndex uint32, RequestedCount uint32, SortCriteria string) (Result string, NumberReturned uint32, TotalMatches uint32, UpdateID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ ContainerID string
+
+ SearchCriteria string
+
+ Filter string
+
+ StartingIndex string
+
+ RequestedCount string
+
+ SortCriteria string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ContainerID, err = soap.MarshalString(ContainerID); err != nil {
+ return
+ }
+ if request.SearchCriteria, err = soap.MarshalString(SearchCriteria); err != nil {
+ return
+ }
+ if request.Filter, err = soap.MarshalString(Filter); err != nil {
+ return
+ }
+ if request.StartingIndex, err = soap.MarshalUi4(StartingIndex); err != nil {
+ return
+ }
+ if request.RequestedCount, err = soap.MarshalUi4(RequestedCount); err != nil {
+ return
+ }
+ if request.SortCriteria, err = soap.MarshalString(SortCriteria); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Result string
+
+ NumberReturned string
+
+ TotalMatches string
+
+ UpdateID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_1, "Search", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Result, err = soap.UnmarshalString(response.Result); err != nil {
+ return
+ }
+ if NumberReturned, err = soap.UnmarshalUi4(response.NumberReturned); err != nil {
+ return
+ }
+ if TotalMatches, err = soap.UnmarshalUi4(response.TotalMatches); err != nil {
+ return
+ }
+ if UpdateID, err = soap.UnmarshalUi4(response.UpdateID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory1) CreateObject(ContainerID string, Elements string) (ObjectID string, Result string, err error) {
+ // Request structure.
+ request := &struct {
+ ContainerID string
+
+ Elements string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ContainerID, err = soap.MarshalString(ContainerID); err != nil {
+ return
+ }
+ if request.Elements, err = soap.MarshalString(Elements); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ ObjectID string
+
+ Result string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_1, "CreateObject", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if ObjectID, err = soap.UnmarshalString(response.ObjectID); err != nil {
+ return
+ }
+ if Result, err = soap.UnmarshalString(response.Result); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory1) DestroyObject(ObjectID string) (err error) {
+ // Request structure.
+ request := &struct {
+ ObjectID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ObjectID, err = soap.MarshalString(ObjectID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_1, "DestroyObject", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory1) UpdateObject(ObjectID string, CurrentTagValue string, NewTagValue string) (err error) {
+ // Request structure.
+ request := &struct {
+ ObjectID string
+
+ CurrentTagValue string
+
+ NewTagValue string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ObjectID, err = soap.MarshalString(ObjectID); err != nil {
+ return
+ }
+ if request.CurrentTagValue, err = soap.MarshalString(CurrentTagValue); err != nil {
+ return
+ }
+ if request.NewTagValue, err = soap.MarshalString(NewTagValue); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_1, "UpdateObject", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory1) ImportResource(SourceURI *url.URL, DestinationURI *url.URL) (TransferID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ SourceURI string
+
+ DestinationURI string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.SourceURI, err = soap.MarshalURI(SourceURI); err != nil {
+ return
+ }
+ if request.DestinationURI, err = soap.MarshalURI(DestinationURI); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ TransferID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_1, "ImportResource", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if TransferID, err = soap.UnmarshalUi4(response.TransferID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory1) ExportResource(SourceURI *url.URL, DestinationURI *url.URL) (TransferID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ SourceURI string
+
+ DestinationURI string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.SourceURI, err = soap.MarshalURI(SourceURI); err != nil {
+ return
+ }
+ if request.DestinationURI, err = soap.MarshalURI(DestinationURI); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ TransferID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_1, "ExportResource", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if TransferID, err = soap.UnmarshalUi4(response.TransferID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory1) StopTransferResource(TransferID uint32) (err error) {
+ // Request structure.
+ request := &struct {
+ TransferID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.TransferID, err = soap.MarshalUi4(TransferID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_1, "StopTransferResource", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * TransferStatus: allowed values: COMPLETED, ERROR, IN_PROGRESS, STOPPED
+func (client *ContentDirectory1) GetTransferProgress(TransferID uint32) (TransferStatus string, TransferLength string, TransferTotal string, err error) {
+ // Request structure.
+ request := &struct {
+ TransferID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.TransferID, err = soap.MarshalUi4(TransferID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ TransferStatus string
+
+ TransferLength string
+
+ TransferTotal string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_1, "GetTransferProgress", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if TransferStatus, err = soap.UnmarshalString(response.TransferStatus); err != nil {
+ return
+ }
+ if TransferLength, err = soap.UnmarshalString(response.TransferLength); err != nil {
+ return
+ }
+ if TransferTotal, err = soap.UnmarshalString(response.TransferTotal); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory1) DeleteResource(ResourceURI *url.URL) (err error) {
+ // Request structure.
+ request := &struct {
+ ResourceURI string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ResourceURI, err = soap.MarshalURI(ResourceURI); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_1, "DeleteResource", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory1) CreateReference(ContainerID string, ObjectID string) (NewID string, err error) {
+ // Request structure.
+ request := &struct {
+ ContainerID string
+
+ ObjectID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ContainerID, err = soap.MarshalString(ContainerID); err != nil {
+ return
+ }
+ if request.ObjectID, err = soap.MarshalString(ObjectID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ NewID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_1, "CreateReference", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if NewID, err = soap.UnmarshalString(response.NewID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+// ContentDirectory2 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:ContentDirectory:2". See
+// goupnp.ServiceClient, which contains RootDevice and Service attributes which
+// are provided for informational value.
+type ContentDirectory2 struct {
+ goupnp.ServiceClient
+}
+
+// NewContentDirectory2Clients discovers instances of the service on the network,
+// and returns clients to any that are found. errors will contain an error for
+// any devices that replied but which could not be queried, and err will be set
+// if the discovery process failed outright.
+//
+// This is a typical entry calling point into this package.
+func NewContentDirectory2Clients() (clients []*ContentDirectory2, errors []error, err error) {
+ var genericClients []goupnp.ServiceClient
+ if genericClients, errors, err = goupnp.NewServiceClients(URN_ContentDirectory_2); err != nil {
+ return
+ }
+ clients = newContentDirectory2ClientsFromGenericClients(genericClients)
+ return
+}
+
+// NewContentDirectory2ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewContentDirectory2ClientsByURL(loc *url.URL) ([]*ContentDirectory2, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_ContentDirectory_2)
+ if err != nil {
+ return nil, err
+ }
+ return newContentDirectory2ClientsFromGenericClients(genericClients), nil
+}
+
+// NewContentDirectory2ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewContentDirectory2ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*ContentDirectory2, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_ContentDirectory_2)
+ if err != nil {
+ return nil, err
+ }
+ return newContentDirectory2ClientsFromGenericClients(genericClients), nil
+}
+
+func newContentDirectory2ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*ContentDirectory2 {
+ clients := make([]*ContentDirectory2, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &ContentDirectory2{genericClients[i]}
+ }
+ return clients
+}
+
+func (client *ContentDirectory2) GetSearchCapabilities() (SearchCaps string, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ SearchCaps string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_2, "GetSearchCapabilities", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if SearchCaps, err = soap.UnmarshalString(response.SearchCaps); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory2) GetSortCapabilities() (SortCaps string, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ SortCaps string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_2, "GetSortCapabilities", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if SortCaps, err = soap.UnmarshalString(response.SortCaps); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory2) GetSortExtensionCapabilities() (SortExtensionCaps string, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ SortExtensionCaps string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_2, "GetSortExtensionCapabilities", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if SortExtensionCaps, err = soap.UnmarshalString(response.SortExtensionCaps); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory2) GetFeatureList() (FeatureList string, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ FeatureList string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_2, "GetFeatureList", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if FeatureList, err = soap.UnmarshalString(response.FeatureList); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory2) GetSystemUpdateID() (Id uint32, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Id string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_2, "GetSystemUpdateID", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Id, err = soap.UnmarshalUi4(response.Id); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * BrowseFlag: allowed values: BrowseMetadata, BrowseDirectChildren
+
+func (client *ContentDirectory2) Browse(ObjectID string, BrowseFlag string, Filter string, StartingIndex uint32, RequestedCount uint32, SortCriteria string) (Result string, NumberReturned uint32, TotalMatches uint32, UpdateID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ ObjectID string
+
+ BrowseFlag string
+
+ Filter string
+
+ StartingIndex string
+
+ RequestedCount string
+
+ SortCriteria string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ObjectID, err = soap.MarshalString(ObjectID); err != nil {
+ return
+ }
+ if request.BrowseFlag, err = soap.MarshalString(BrowseFlag); err != nil {
+ return
+ }
+ if request.Filter, err = soap.MarshalString(Filter); err != nil {
+ return
+ }
+ if request.StartingIndex, err = soap.MarshalUi4(StartingIndex); err != nil {
+ return
+ }
+ if request.RequestedCount, err = soap.MarshalUi4(RequestedCount); err != nil {
+ return
+ }
+ if request.SortCriteria, err = soap.MarshalString(SortCriteria); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Result string
+
+ NumberReturned string
+
+ TotalMatches string
+
+ UpdateID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_2, "Browse", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Result, err = soap.UnmarshalString(response.Result); err != nil {
+ return
+ }
+ if NumberReturned, err = soap.UnmarshalUi4(response.NumberReturned); err != nil {
+ return
+ }
+ if TotalMatches, err = soap.UnmarshalUi4(response.TotalMatches); err != nil {
+ return
+ }
+ if UpdateID, err = soap.UnmarshalUi4(response.UpdateID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory2) Search(ContainerID string, SearchCriteria string, Filter string, StartingIndex uint32, RequestedCount uint32, SortCriteria string) (Result string, NumberReturned uint32, TotalMatches uint32, UpdateID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ ContainerID string
+
+ SearchCriteria string
+
+ Filter string
+
+ StartingIndex string
+
+ RequestedCount string
+
+ SortCriteria string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ContainerID, err = soap.MarshalString(ContainerID); err != nil {
+ return
+ }
+ if request.SearchCriteria, err = soap.MarshalString(SearchCriteria); err != nil {
+ return
+ }
+ if request.Filter, err = soap.MarshalString(Filter); err != nil {
+ return
+ }
+ if request.StartingIndex, err = soap.MarshalUi4(StartingIndex); err != nil {
+ return
+ }
+ if request.RequestedCount, err = soap.MarshalUi4(RequestedCount); err != nil {
+ return
+ }
+ if request.SortCriteria, err = soap.MarshalString(SortCriteria); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Result string
+
+ NumberReturned string
+
+ TotalMatches string
+
+ UpdateID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_2, "Search", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Result, err = soap.UnmarshalString(response.Result); err != nil {
+ return
+ }
+ if NumberReturned, err = soap.UnmarshalUi4(response.NumberReturned); err != nil {
+ return
+ }
+ if TotalMatches, err = soap.UnmarshalUi4(response.TotalMatches); err != nil {
+ return
+ }
+ if UpdateID, err = soap.UnmarshalUi4(response.UpdateID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory2) CreateObject(ContainerID string, Elements string) (ObjectID string, Result string, err error) {
+ // Request structure.
+ request := &struct {
+ ContainerID string
+
+ Elements string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ContainerID, err = soap.MarshalString(ContainerID); err != nil {
+ return
+ }
+ if request.Elements, err = soap.MarshalString(Elements); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ ObjectID string
+
+ Result string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_2, "CreateObject", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if ObjectID, err = soap.UnmarshalString(response.ObjectID); err != nil {
+ return
+ }
+ if Result, err = soap.UnmarshalString(response.Result); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory2) DestroyObject(ObjectID string) (err error) {
+ // Request structure.
+ request := &struct {
+ ObjectID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ObjectID, err = soap.MarshalString(ObjectID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_2, "DestroyObject", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory2) UpdateObject(ObjectID string, CurrentTagValue string, NewTagValue string) (err error) {
+ // Request structure.
+ request := &struct {
+ ObjectID string
+
+ CurrentTagValue string
+
+ NewTagValue string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ObjectID, err = soap.MarshalString(ObjectID); err != nil {
+ return
+ }
+ if request.CurrentTagValue, err = soap.MarshalString(CurrentTagValue); err != nil {
+ return
+ }
+ if request.NewTagValue, err = soap.MarshalString(NewTagValue); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_2, "UpdateObject", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory2) MoveObject(ObjectID string, NewParentID string) (NewObjectID string, err error) {
+ // Request structure.
+ request := &struct {
+ ObjectID string
+
+ NewParentID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ObjectID, err = soap.MarshalString(ObjectID); err != nil {
+ return
+ }
+ if request.NewParentID, err = soap.MarshalString(NewParentID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ NewObjectID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_2, "MoveObject", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if NewObjectID, err = soap.UnmarshalString(response.NewObjectID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory2) ImportResource(SourceURI *url.URL, DestinationURI *url.URL) (TransferID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ SourceURI string
+
+ DestinationURI string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.SourceURI, err = soap.MarshalURI(SourceURI); err != nil {
+ return
+ }
+ if request.DestinationURI, err = soap.MarshalURI(DestinationURI); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ TransferID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_2, "ImportResource", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if TransferID, err = soap.UnmarshalUi4(response.TransferID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory2) ExportResource(SourceURI *url.URL, DestinationURI *url.URL) (TransferID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ SourceURI string
+
+ DestinationURI string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.SourceURI, err = soap.MarshalURI(SourceURI); err != nil {
+ return
+ }
+ if request.DestinationURI, err = soap.MarshalURI(DestinationURI); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ TransferID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_2, "ExportResource", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if TransferID, err = soap.UnmarshalUi4(response.TransferID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory2) DeleteResource(ResourceURI *url.URL) (err error) {
+ // Request structure.
+ request := &struct {
+ ResourceURI string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ResourceURI, err = soap.MarshalURI(ResourceURI); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_2, "DeleteResource", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory2) StopTransferResource(TransferID uint32) (err error) {
+ // Request structure.
+ request := &struct {
+ TransferID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.TransferID, err = soap.MarshalUi4(TransferID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_2, "StopTransferResource", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * TransferStatus: allowed values: COMPLETED, ERROR, IN_PROGRESS, STOPPED
+func (client *ContentDirectory2) GetTransferProgress(TransferID uint32) (TransferStatus string, TransferLength string, TransferTotal string, err error) {
+ // Request structure.
+ request := &struct {
+ TransferID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.TransferID, err = soap.MarshalUi4(TransferID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ TransferStatus string
+
+ TransferLength string
+
+ TransferTotal string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_2, "GetTransferProgress", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if TransferStatus, err = soap.UnmarshalString(response.TransferStatus); err != nil {
+ return
+ }
+ if TransferLength, err = soap.UnmarshalString(response.TransferLength); err != nil {
+ return
+ }
+ if TransferTotal, err = soap.UnmarshalString(response.TransferTotal); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory2) CreateReference(ContainerID string, ObjectID string) (NewID string, err error) {
+ // Request structure.
+ request := &struct {
+ ContainerID string
+
+ ObjectID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ContainerID, err = soap.MarshalString(ContainerID); err != nil {
+ return
+ }
+ if request.ObjectID, err = soap.MarshalString(ObjectID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ NewID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_2, "CreateReference", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if NewID, err = soap.UnmarshalString(response.NewID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+// ContentDirectory3 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:ContentDirectory:3". See
+// goupnp.ServiceClient, which contains RootDevice and Service attributes which
+// are provided for informational value.
+type ContentDirectory3 struct {
+ goupnp.ServiceClient
+}
+
+// NewContentDirectory3Clients discovers instances of the service on the network,
+// and returns clients to any that are found. errors will contain an error for
+// any devices that replied but which could not be queried, and err will be set
+// if the discovery process failed outright.
+//
+// This is a typical entry calling point into this package.
+func NewContentDirectory3Clients() (clients []*ContentDirectory3, errors []error, err error) {
+ var genericClients []goupnp.ServiceClient
+ if genericClients, errors, err = goupnp.NewServiceClients(URN_ContentDirectory_3); err != nil {
+ return
+ }
+ clients = newContentDirectory3ClientsFromGenericClients(genericClients)
+ return
+}
+
+// NewContentDirectory3ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewContentDirectory3ClientsByURL(loc *url.URL) ([]*ContentDirectory3, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_ContentDirectory_3)
+ if err != nil {
+ return nil, err
+ }
+ return newContentDirectory3ClientsFromGenericClients(genericClients), nil
+}
+
+// NewContentDirectory3ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewContentDirectory3ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*ContentDirectory3, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_ContentDirectory_3)
+ if err != nil {
+ return nil, err
+ }
+ return newContentDirectory3ClientsFromGenericClients(genericClients), nil
+}
+
+func newContentDirectory3ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*ContentDirectory3 {
+ clients := make([]*ContentDirectory3, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &ContentDirectory3{genericClients[i]}
+ }
+ return clients
+}
+
+func (client *ContentDirectory3) GetSearchCapabilities() (SearchCaps string, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ SearchCaps string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_3, "GetSearchCapabilities", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if SearchCaps, err = soap.UnmarshalString(response.SearchCaps); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory3) GetSortCapabilities() (SortCaps string, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ SortCaps string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_3, "GetSortCapabilities", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if SortCaps, err = soap.UnmarshalString(response.SortCaps); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory3) GetSortExtensionCapabilities() (SortExtensionCaps string, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ SortExtensionCaps string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_3, "GetSortExtensionCapabilities", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if SortExtensionCaps, err = soap.UnmarshalString(response.SortExtensionCaps); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory3) GetFeatureList() (FeatureList string, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ FeatureList string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_3, "GetFeatureList", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if FeatureList, err = soap.UnmarshalString(response.FeatureList); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory3) GetSystemUpdateID() (Id uint32, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Id string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_3, "GetSystemUpdateID", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Id, err = soap.UnmarshalUi4(response.Id); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory3) GetServiceResetToken() (ResetToken string, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ ResetToken string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_3, "GetServiceResetToken", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if ResetToken, err = soap.UnmarshalString(response.ResetToken); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * BrowseFlag: allowed values: BrowseMetadata, BrowseDirectChildren
+
+func (client *ContentDirectory3) Browse(ObjectID string, BrowseFlag string, Filter string, StartingIndex uint32, RequestedCount uint32, SortCriteria string) (Result string, NumberReturned uint32, TotalMatches uint32, UpdateID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ ObjectID string
+
+ BrowseFlag string
+
+ Filter string
+
+ StartingIndex string
+
+ RequestedCount string
+
+ SortCriteria string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ObjectID, err = soap.MarshalString(ObjectID); err != nil {
+ return
+ }
+ if request.BrowseFlag, err = soap.MarshalString(BrowseFlag); err != nil {
+ return
+ }
+ if request.Filter, err = soap.MarshalString(Filter); err != nil {
+ return
+ }
+ if request.StartingIndex, err = soap.MarshalUi4(StartingIndex); err != nil {
+ return
+ }
+ if request.RequestedCount, err = soap.MarshalUi4(RequestedCount); err != nil {
+ return
+ }
+ if request.SortCriteria, err = soap.MarshalString(SortCriteria); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Result string
+
+ NumberReturned string
+
+ TotalMatches string
+
+ UpdateID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_3, "Browse", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Result, err = soap.UnmarshalString(response.Result); err != nil {
+ return
+ }
+ if NumberReturned, err = soap.UnmarshalUi4(response.NumberReturned); err != nil {
+ return
+ }
+ if TotalMatches, err = soap.UnmarshalUi4(response.TotalMatches); err != nil {
+ return
+ }
+ if UpdateID, err = soap.UnmarshalUi4(response.UpdateID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory3) Search(ContainerID string, SearchCriteria string, Filter string, StartingIndex uint32, RequestedCount uint32, SortCriteria string) (Result string, NumberReturned uint32, TotalMatches uint32, UpdateID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ ContainerID string
+
+ SearchCriteria string
+
+ Filter string
+
+ StartingIndex string
+
+ RequestedCount string
+
+ SortCriteria string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ContainerID, err = soap.MarshalString(ContainerID); err != nil {
+ return
+ }
+ if request.SearchCriteria, err = soap.MarshalString(SearchCriteria); err != nil {
+ return
+ }
+ if request.Filter, err = soap.MarshalString(Filter); err != nil {
+ return
+ }
+ if request.StartingIndex, err = soap.MarshalUi4(StartingIndex); err != nil {
+ return
+ }
+ if request.RequestedCount, err = soap.MarshalUi4(RequestedCount); err != nil {
+ return
+ }
+ if request.SortCriteria, err = soap.MarshalString(SortCriteria); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Result string
+
+ NumberReturned string
+
+ TotalMatches string
+
+ UpdateID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_3, "Search", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Result, err = soap.UnmarshalString(response.Result); err != nil {
+ return
+ }
+ if NumberReturned, err = soap.UnmarshalUi4(response.NumberReturned); err != nil {
+ return
+ }
+ if TotalMatches, err = soap.UnmarshalUi4(response.TotalMatches); err != nil {
+ return
+ }
+ if UpdateID, err = soap.UnmarshalUi4(response.UpdateID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory3) CreateObject(ContainerID string, Elements string) (ObjectID string, Result string, err error) {
+ // Request structure.
+ request := &struct {
+ ContainerID string
+
+ Elements string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ContainerID, err = soap.MarshalString(ContainerID); err != nil {
+ return
+ }
+ if request.Elements, err = soap.MarshalString(Elements); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ ObjectID string
+
+ Result string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_3, "CreateObject", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if ObjectID, err = soap.UnmarshalString(response.ObjectID); err != nil {
+ return
+ }
+ if Result, err = soap.UnmarshalString(response.Result); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory3) DestroyObject(ObjectID string) (err error) {
+ // Request structure.
+ request := &struct {
+ ObjectID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ObjectID, err = soap.MarshalString(ObjectID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_3, "DestroyObject", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory3) UpdateObject(ObjectID string, CurrentTagValue string, NewTagValue string) (err error) {
+ // Request structure.
+ request := &struct {
+ ObjectID string
+
+ CurrentTagValue string
+
+ NewTagValue string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ObjectID, err = soap.MarshalString(ObjectID); err != nil {
+ return
+ }
+ if request.CurrentTagValue, err = soap.MarshalString(CurrentTagValue); err != nil {
+ return
+ }
+ if request.NewTagValue, err = soap.MarshalString(NewTagValue); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_3, "UpdateObject", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory3) MoveObject(ObjectID string, NewParentID string) (NewObjectID string, err error) {
+ // Request structure.
+ request := &struct {
+ ObjectID string
+
+ NewParentID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ObjectID, err = soap.MarshalString(ObjectID); err != nil {
+ return
+ }
+ if request.NewParentID, err = soap.MarshalString(NewParentID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ NewObjectID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_3, "MoveObject", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if NewObjectID, err = soap.UnmarshalString(response.NewObjectID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory3) ImportResource(SourceURI *url.URL, DestinationURI *url.URL) (TransferID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ SourceURI string
+
+ DestinationURI string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.SourceURI, err = soap.MarshalURI(SourceURI); err != nil {
+ return
+ }
+ if request.DestinationURI, err = soap.MarshalURI(DestinationURI); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ TransferID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_3, "ImportResource", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if TransferID, err = soap.UnmarshalUi4(response.TransferID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory3) ExportResource(SourceURI *url.URL, DestinationURI *url.URL) (TransferID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ SourceURI string
+
+ DestinationURI string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.SourceURI, err = soap.MarshalURI(SourceURI); err != nil {
+ return
+ }
+ if request.DestinationURI, err = soap.MarshalURI(DestinationURI); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ TransferID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_3, "ExportResource", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if TransferID, err = soap.UnmarshalUi4(response.TransferID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory3) DeleteResource(ResourceURI *url.URL) (err error) {
+ // Request structure.
+ request := &struct {
+ ResourceURI string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ResourceURI, err = soap.MarshalURI(ResourceURI); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_3, "DeleteResource", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory3) StopTransferResource(TransferID uint32) (err error) {
+ // Request structure.
+ request := &struct {
+ TransferID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.TransferID, err = soap.MarshalUi4(TransferID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_3, "StopTransferResource", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * TransferStatus: allowed values: COMPLETED, ERROR, IN_PROGRESS, STOPPED
+func (client *ContentDirectory3) GetTransferProgress(TransferID uint32) (TransferStatus string, TransferLength string, TransferTotal string, err error) {
+ // Request structure.
+ request := &struct {
+ TransferID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.TransferID, err = soap.MarshalUi4(TransferID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ TransferStatus string
+
+ TransferLength string
+
+ TransferTotal string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_3, "GetTransferProgress", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if TransferStatus, err = soap.UnmarshalString(response.TransferStatus); err != nil {
+ return
+ }
+ if TransferLength, err = soap.UnmarshalString(response.TransferLength); err != nil {
+ return
+ }
+ if TransferTotal, err = soap.UnmarshalString(response.TransferTotal); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory3) CreateReference(ContainerID string, ObjectID string) (NewID string, err error) {
+ // Request structure.
+ request := &struct {
+ ContainerID string
+
+ ObjectID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ContainerID, err = soap.MarshalString(ContainerID); err != nil {
+ return
+ }
+ if request.ObjectID, err = soap.MarshalString(ObjectID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ NewID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_3, "CreateReference", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if NewID, err = soap.UnmarshalString(response.NewID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory3) FreeFormQuery(ContainerID string, CDSView uint32, QueryRequest string) (QueryResult string, UpdateID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ ContainerID string
+
+ CDSView string
+
+ QueryRequest string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ContainerID, err = soap.MarshalString(ContainerID); err != nil {
+ return
+ }
+ if request.CDSView, err = soap.MarshalUi4(CDSView); err != nil {
+ return
+ }
+ if request.QueryRequest, err = soap.MarshalString(QueryRequest); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ QueryResult string
+
+ UpdateID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_3, "FreeFormQuery", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if QueryResult, err = soap.UnmarshalString(response.QueryResult); err != nil {
+ return
+ }
+ if UpdateID, err = soap.UnmarshalUi4(response.UpdateID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ContentDirectory3) GetFreeFormQueryCapabilities() (FFQCapabilities string, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ FFQCapabilities string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ContentDirectory_3, "GetFreeFormQueryCapabilities", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if FFQCapabilities, err = soap.UnmarshalString(response.FFQCapabilities); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+// RenderingControl1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:RenderingControl:1". See
+// goupnp.ServiceClient, which contains RootDevice and Service attributes which
+// are provided for informational value.
+type RenderingControl1 struct {
+ goupnp.ServiceClient
+}
+
+// NewRenderingControl1Clients discovers instances of the service on the network,
+// and returns clients to any that are found. errors will contain an error for
+// any devices that replied but which could not be queried, and err will be set
+// if the discovery process failed outright.
+//
+// This is a typical entry calling point into this package.
+func NewRenderingControl1Clients() (clients []*RenderingControl1, errors []error, err error) {
+ var genericClients []goupnp.ServiceClient
+ if genericClients, errors, err = goupnp.NewServiceClients(URN_RenderingControl_1); err != nil {
+ return
+ }
+ clients = newRenderingControl1ClientsFromGenericClients(genericClients)
+ return
+}
+
+// NewRenderingControl1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewRenderingControl1ClientsByURL(loc *url.URL) ([]*RenderingControl1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_RenderingControl_1)
+ if err != nil {
+ return nil, err
+ }
+ return newRenderingControl1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewRenderingControl1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewRenderingControl1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*RenderingControl1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_RenderingControl_1)
+ if err != nil {
+ return nil, err
+ }
+ return newRenderingControl1ClientsFromGenericClients(genericClients), nil
+}
+
+func newRenderingControl1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*RenderingControl1 {
+ clients := make([]*RenderingControl1, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &RenderingControl1{genericClients[i]}
+ }
+ return clients
+}
+
+func (client *RenderingControl1) ListPresets(InstanceID uint32) (CurrentPresetNameList string, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentPresetNameList string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "ListPresets", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentPresetNameList, err = soap.UnmarshalString(response.CurrentPresetNameList); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * PresetName: allowed values: FactoryDefaults
+
+func (client *RenderingControl1) SelectPreset(InstanceID uint32, PresetName string) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ PresetName string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.PresetName, err = soap.MarshalString(PresetName); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "SelectPreset", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentBrightness: allowed value range: minimum=0, step=1
+func (client *RenderingControl1) GetBrightness(InstanceID uint32) (CurrentBrightness uint16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentBrightness string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "GetBrightness", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentBrightness, err = soap.UnmarshalUi2(response.CurrentBrightness); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredBrightness: allowed value range: minimum=0, step=1
+
+func (client *RenderingControl1) SetBrightness(InstanceID uint32, DesiredBrightness uint16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredBrightness string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredBrightness, err = soap.MarshalUi2(DesiredBrightness); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "SetBrightness", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentContrast: allowed value range: minimum=0, step=1
+func (client *RenderingControl1) GetContrast(InstanceID uint32) (CurrentContrast uint16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentContrast string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "GetContrast", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentContrast, err = soap.UnmarshalUi2(response.CurrentContrast); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredContrast: allowed value range: minimum=0, step=1
+
+func (client *RenderingControl1) SetContrast(InstanceID uint32, DesiredContrast uint16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredContrast string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredContrast, err = soap.MarshalUi2(DesiredContrast); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "SetContrast", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentSharpness: allowed value range: minimum=0, step=1
+func (client *RenderingControl1) GetSharpness(InstanceID uint32) (CurrentSharpness uint16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentSharpness string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "GetSharpness", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentSharpness, err = soap.UnmarshalUi2(response.CurrentSharpness); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredSharpness: allowed value range: minimum=0, step=1
+
+func (client *RenderingControl1) SetSharpness(InstanceID uint32, DesiredSharpness uint16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredSharpness string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredSharpness, err = soap.MarshalUi2(DesiredSharpness); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "SetSharpness", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *RenderingControl1) GetRedVideoGain(InstanceID uint32) (CurrentRedVideoGain uint16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentRedVideoGain string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "GetRedVideoGain", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentRedVideoGain, err = soap.UnmarshalUi2(response.CurrentRedVideoGain); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *RenderingControl1) SetRedVideoGain(InstanceID uint32, DesiredRedVideoGain uint16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredRedVideoGain string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredRedVideoGain, err = soap.MarshalUi2(DesiredRedVideoGain); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "SetRedVideoGain", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentGreenVideoGain: allowed value range: minimum=0, step=1
+func (client *RenderingControl1) GetGreenVideoGain(InstanceID uint32) (CurrentGreenVideoGain uint16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentGreenVideoGain string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "GetGreenVideoGain", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentGreenVideoGain, err = soap.UnmarshalUi2(response.CurrentGreenVideoGain); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredGreenVideoGain: allowed value range: minimum=0, step=1
+
+func (client *RenderingControl1) SetGreenVideoGain(InstanceID uint32, DesiredGreenVideoGain uint16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredGreenVideoGain string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredGreenVideoGain, err = soap.MarshalUi2(DesiredGreenVideoGain); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "SetGreenVideoGain", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentBlueVideoGain: allowed value range: minimum=0, step=1
+func (client *RenderingControl1) GetBlueVideoGain(InstanceID uint32) (CurrentBlueVideoGain uint16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentBlueVideoGain string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "GetBlueVideoGain", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentBlueVideoGain, err = soap.UnmarshalUi2(response.CurrentBlueVideoGain); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredBlueVideoGain: allowed value range: minimum=0, step=1
+
+func (client *RenderingControl1) SetBlueVideoGain(InstanceID uint32, DesiredBlueVideoGain uint16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredBlueVideoGain string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredBlueVideoGain, err = soap.MarshalUi2(DesiredBlueVideoGain); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "SetBlueVideoGain", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentRedVideoBlackLevel: allowed value range: minimum=0, step=1
+func (client *RenderingControl1) GetRedVideoBlackLevel(InstanceID uint32) (CurrentRedVideoBlackLevel uint16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentRedVideoBlackLevel string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "GetRedVideoBlackLevel", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentRedVideoBlackLevel, err = soap.UnmarshalUi2(response.CurrentRedVideoBlackLevel); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredRedVideoBlackLevel: allowed value range: minimum=0, step=1
+
+func (client *RenderingControl1) SetRedVideoBlackLevel(InstanceID uint32, DesiredRedVideoBlackLevel uint16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredRedVideoBlackLevel string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredRedVideoBlackLevel, err = soap.MarshalUi2(DesiredRedVideoBlackLevel); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "SetRedVideoBlackLevel", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentGreenVideoBlackLevel: allowed value range: minimum=0, step=1
+func (client *RenderingControl1) GetGreenVideoBlackLevel(InstanceID uint32) (CurrentGreenVideoBlackLevel uint16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentGreenVideoBlackLevel string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "GetGreenVideoBlackLevel", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentGreenVideoBlackLevel, err = soap.UnmarshalUi2(response.CurrentGreenVideoBlackLevel); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredGreenVideoBlackLevel: allowed value range: minimum=0, step=1
+
+func (client *RenderingControl1) SetGreenVideoBlackLevel(InstanceID uint32, DesiredGreenVideoBlackLevel uint16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredGreenVideoBlackLevel string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredGreenVideoBlackLevel, err = soap.MarshalUi2(DesiredGreenVideoBlackLevel); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "SetGreenVideoBlackLevel", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentBlueVideoBlackLevel: allowed value range: minimum=0, step=1
+func (client *RenderingControl1) GetBlueVideoBlackLevel(InstanceID uint32) (CurrentBlueVideoBlackLevel uint16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentBlueVideoBlackLevel string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "GetBlueVideoBlackLevel", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentBlueVideoBlackLevel, err = soap.UnmarshalUi2(response.CurrentBlueVideoBlackLevel); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredBlueVideoBlackLevel: allowed value range: minimum=0, step=1
+
+func (client *RenderingControl1) SetBlueVideoBlackLevel(InstanceID uint32, DesiredBlueVideoBlackLevel uint16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredBlueVideoBlackLevel string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredBlueVideoBlackLevel, err = soap.MarshalUi2(DesiredBlueVideoBlackLevel); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "SetBlueVideoBlackLevel", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentColorTemperature: allowed value range: minimum=0, step=1
+func (client *RenderingControl1) GetColorTemperature(InstanceID uint32) (CurrentColorTemperature uint16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentColorTemperature string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "GetColorTemperature", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentColorTemperature, err = soap.UnmarshalUi2(response.CurrentColorTemperature); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredColorTemperature: allowed value range: minimum=0, step=1
+
+func (client *RenderingControl1) SetColorTemperature(InstanceID uint32, DesiredColorTemperature uint16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredColorTemperature string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredColorTemperature, err = soap.MarshalUi2(DesiredColorTemperature); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "SetColorTemperature", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentHorizontalKeystone: allowed value range: step=1
+func (client *RenderingControl1) GetHorizontalKeystone(InstanceID uint32) (CurrentHorizontalKeystone int16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentHorizontalKeystone string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "GetHorizontalKeystone", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentHorizontalKeystone, err = soap.UnmarshalI2(response.CurrentHorizontalKeystone); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredHorizontalKeystone: allowed value range: step=1
+
+func (client *RenderingControl1) SetHorizontalKeystone(InstanceID uint32, DesiredHorizontalKeystone int16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredHorizontalKeystone string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredHorizontalKeystone, err = soap.MarshalI2(DesiredHorizontalKeystone); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "SetHorizontalKeystone", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentVerticalKeystone: allowed value range: step=1
+func (client *RenderingControl1) GetVerticalKeystone(InstanceID uint32) (CurrentVerticalKeystone int16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentVerticalKeystone string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "GetVerticalKeystone", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentVerticalKeystone, err = soap.UnmarshalI2(response.CurrentVerticalKeystone); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredVerticalKeystone: allowed value range: step=1
+
+func (client *RenderingControl1) SetVerticalKeystone(InstanceID uint32, DesiredVerticalKeystone int16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredVerticalKeystone string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredVerticalKeystone, err = soap.MarshalI2(DesiredVerticalKeystone); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "SetVerticalKeystone", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Channel: allowed values: Master
+
+func (client *RenderingControl1) GetMute(InstanceID uint32, Channel string) (CurrentMute bool, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ Channel string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.Channel, err = soap.MarshalString(Channel); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentMute string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "GetMute", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentMute, err = soap.UnmarshalBoolean(response.CurrentMute); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Channel: allowed values: Master
+
+func (client *RenderingControl1) SetMute(InstanceID uint32, Channel string, DesiredMute bool) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ Channel string
+
+ DesiredMute string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.Channel, err = soap.MarshalString(Channel); err != nil {
+ return
+ }
+ if request.DesiredMute, err = soap.MarshalBoolean(DesiredMute); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "SetMute", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Channel: allowed values: Master
+
+//
+// Return values:
+//
+// * CurrentVolume: allowed value range: minimum=0, step=1
+func (client *RenderingControl1) GetVolume(InstanceID uint32, Channel string) (CurrentVolume uint16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ Channel string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.Channel, err = soap.MarshalString(Channel); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentVolume string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "GetVolume", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentVolume, err = soap.UnmarshalUi2(response.CurrentVolume); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Channel: allowed values: Master
+//
+// * DesiredVolume: allowed value range: minimum=0, step=1
+
+func (client *RenderingControl1) SetVolume(InstanceID uint32, Channel string, DesiredVolume uint16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ Channel string
+
+ DesiredVolume string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.Channel, err = soap.MarshalString(Channel); err != nil {
+ return
+ }
+ if request.DesiredVolume, err = soap.MarshalUi2(DesiredVolume); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "SetVolume", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Channel: allowed values: Master
+
+func (client *RenderingControl1) GetVolumeDB(InstanceID uint32, Channel string) (CurrentVolume int16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ Channel string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.Channel, err = soap.MarshalString(Channel); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentVolume string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "GetVolumeDB", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentVolume, err = soap.UnmarshalI2(response.CurrentVolume); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Channel: allowed values: Master
+
+func (client *RenderingControl1) SetVolumeDB(InstanceID uint32, Channel string, DesiredVolume int16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ Channel string
+
+ DesiredVolume string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.Channel, err = soap.MarshalString(Channel); err != nil {
+ return
+ }
+ if request.DesiredVolume, err = soap.MarshalI2(DesiredVolume); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "SetVolumeDB", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Channel: allowed values: Master
+
+func (client *RenderingControl1) GetVolumeDBRange(InstanceID uint32, Channel string) (MinValue int16, MaxValue int16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ Channel string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.Channel, err = soap.MarshalString(Channel); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ MinValue string
+
+ MaxValue string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "GetVolumeDBRange", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if MinValue, err = soap.UnmarshalI2(response.MinValue); err != nil {
+ return
+ }
+ if MaxValue, err = soap.UnmarshalI2(response.MaxValue); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Channel: allowed values: Master
+
+func (client *RenderingControl1) GetLoudness(InstanceID uint32, Channel string) (CurrentLoudness bool, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ Channel string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.Channel, err = soap.MarshalString(Channel); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentLoudness string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "GetLoudness", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentLoudness, err = soap.UnmarshalBoolean(response.CurrentLoudness); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Channel: allowed values: Master
+
+func (client *RenderingControl1) SetLoudness(InstanceID uint32, Channel string, DesiredLoudness bool) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ Channel string
+
+ DesiredLoudness string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.Channel, err = soap.MarshalString(Channel); err != nil {
+ return
+ }
+ if request.DesiredLoudness, err = soap.MarshalBoolean(DesiredLoudness); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_1, "SetLoudness", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+// RenderingControl2 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:RenderingControl:2". See
+// goupnp.ServiceClient, which contains RootDevice and Service attributes which
+// are provided for informational value.
+type RenderingControl2 struct {
+ goupnp.ServiceClient
+}
+
+// NewRenderingControl2Clients discovers instances of the service on the network,
+// and returns clients to any that are found. errors will contain an error for
+// any devices that replied but which could not be queried, and err will be set
+// if the discovery process failed outright.
+//
+// This is a typical entry calling point into this package.
+func NewRenderingControl2Clients() (clients []*RenderingControl2, errors []error, err error) {
+ var genericClients []goupnp.ServiceClient
+ if genericClients, errors, err = goupnp.NewServiceClients(URN_RenderingControl_2); err != nil {
+ return
+ }
+ clients = newRenderingControl2ClientsFromGenericClients(genericClients)
+ return
+}
+
+// NewRenderingControl2ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewRenderingControl2ClientsByURL(loc *url.URL) ([]*RenderingControl2, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_RenderingControl_2)
+ if err != nil {
+ return nil, err
+ }
+ return newRenderingControl2ClientsFromGenericClients(genericClients), nil
+}
+
+// NewRenderingControl2ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewRenderingControl2ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*RenderingControl2, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_RenderingControl_2)
+ if err != nil {
+ return nil, err
+ }
+ return newRenderingControl2ClientsFromGenericClients(genericClients), nil
+}
+
+func newRenderingControl2ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*RenderingControl2 {
+ clients := make([]*RenderingControl2, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &RenderingControl2{genericClients[i]}
+ }
+ return clients
+}
+
+func (client *RenderingControl2) ListPresets(InstanceID uint32) (CurrentPresetNameList string, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentPresetNameList string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "ListPresets", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentPresetNameList, err = soap.UnmarshalString(response.CurrentPresetNameList); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * PresetName: allowed values: FactoryDefaults
+
+func (client *RenderingControl2) SelectPreset(InstanceID uint32, PresetName string) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ PresetName string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.PresetName, err = soap.MarshalString(PresetName); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "SelectPreset", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentBrightness: allowed value range: minimum=0, step=1
+func (client *RenderingControl2) GetBrightness(InstanceID uint32) (CurrentBrightness uint16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentBrightness string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "GetBrightness", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentBrightness, err = soap.UnmarshalUi2(response.CurrentBrightness); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredBrightness: allowed value range: minimum=0, step=1
+
+func (client *RenderingControl2) SetBrightness(InstanceID uint32, DesiredBrightness uint16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredBrightness string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredBrightness, err = soap.MarshalUi2(DesiredBrightness); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "SetBrightness", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentContrast: allowed value range: minimum=0, step=1
+func (client *RenderingControl2) GetContrast(InstanceID uint32) (CurrentContrast uint16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentContrast string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "GetContrast", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentContrast, err = soap.UnmarshalUi2(response.CurrentContrast); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredContrast: allowed value range: minimum=0, step=1
+
+func (client *RenderingControl2) SetContrast(InstanceID uint32, DesiredContrast uint16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredContrast string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredContrast, err = soap.MarshalUi2(DesiredContrast); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "SetContrast", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentSharpness: allowed value range: minimum=0, step=1
+func (client *RenderingControl2) GetSharpness(InstanceID uint32) (CurrentSharpness uint16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentSharpness string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "GetSharpness", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentSharpness, err = soap.UnmarshalUi2(response.CurrentSharpness); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredSharpness: allowed value range: minimum=0, step=1
+
+func (client *RenderingControl2) SetSharpness(InstanceID uint32, DesiredSharpness uint16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredSharpness string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredSharpness, err = soap.MarshalUi2(DesiredSharpness); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "SetSharpness", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentRedVideoGain: allowed value range: minimum=0, step=1
+func (client *RenderingControl2) GetRedVideoGain(InstanceID uint32) (CurrentRedVideoGain uint16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentRedVideoGain string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "GetRedVideoGain", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentRedVideoGain, err = soap.UnmarshalUi2(response.CurrentRedVideoGain); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredRedVideoGain: allowed value range: minimum=0, step=1
+
+func (client *RenderingControl2) SetRedVideoGain(InstanceID uint32, DesiredRedVideoGain uint16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredRedVideoGain string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredRedVideoGain, err = soap.MarshalUi2(DesiredRedVideoGain); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "SetRedVideoGain", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentGreenVideoGain: allowed value range: minimum=0, step=1
+func (client *RenderingControl2) GetGreenVideoGain(InstanceID uint32) (CurrentGreenVideoGain uint16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentGreenVideoGain string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "GetGreenVideoGain", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentGreenVideoGain, err = soap.UnmarshalUi2(response.CurrentGreenVideoGain); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredGreenVideoGain: allowed value range: minimum=0, step=1
+
+func (client *RenderingControl2) SetGreenVideoGain(InstanceID uint32, DesiredGreenVideoGain uint16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredGreenVideoGain string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredGreenVideoGain, err = soap.MarshalUi2(DesiredGreenVideoGain); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "SetGreenVideoGain", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentBlueVideoGain: allowed value range: minimum=0, step=1
+func (client *RenderingControl2) GetBlueVideoGain(InstanceID uint32) (CurrentBlueVideoGain uint16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentBlueVideoGain string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "GetBlueVideoGain", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentBlueVideoGain, err = soap.UnmarshalUi2(response.CurrentBlueVideoGain); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredBlueVideoGain: allowed value range: minimum=0, step=1
+
+func (client *RenderingControl2) SetBlueVideoGain(InstanceID uint32, DesiredBlueVideoGain uint16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredBlueVideoGain string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredBlueVideoGain, err = soap.MarshalUi2(DesiredBlueVideoGain); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "SetBlueVideoGain", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentRedVideoBlackLevel: allowed value range: minimum=0, step=1
+func (client *RenderingControl2) GetRedVideoBlackLevel(InstanceID uint32) (CurrentRedVideoBlackLevel uint16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentRedVideoBlackLevel string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "GetRedVideoBlackLevel", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentRedVideoBlackLevel, err = soap.UnmarshalUi2(response.CurrentRedVideoBlackLevel); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredRedVideoBlackLevel: allowed value range: minimum=0, step=1
+
+func (client *RenderingControl2) SetRedVideoBlackLevel(InstanceID uint32, DesiredRedVideoBlackLevel uint16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredRedVideoBlackLevel string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredRedVideoBlackLevel, err = soap.MarshalUi2(DesiredRedVideoBlackLevel); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "SetRedVideoBlackLevel", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentGreenVideoBlackLevel: allowed value range: minimum=0, step=1
+func (client *RenderingControl2) GetGreenVideoBlackLevel(InstanceID uint32) (CurrentGreenVideoBlackLevel uint16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentGreenVideoBlackLevel string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "GetGreenVideoBlackLevel", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentGreenVideoBlackLevel, err = soap.UnmarshalUi2(response.CurrentGreenVideoBlackLevel); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredGreenVideoBlackLevel: allowed value range: minimum=0, step=1
+
+func (client *RenderingControl2) SetGreenVideoBlackLevel(InstanceID uint32, DesiredGreenVideoBlackLevel uint16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredGreenVideoBlackLevel string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredGreenVideoBlackLevel, err = soap.MarshalUi2(DesiredGreenVideoBlackLevel); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "SetGreenVideoBlackLevel", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentBlueVideoBlackLevel: allowed value range: minimum=0, step=1
+func (client *RenderingControl2) GetBlueVideoBlackLevel(InstanceID uint32) (CurrentBlueVideoBlackLevel uint16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentBlueVideoBlackLevel string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "GetBlueVideoBlackLevel", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentBlueVideoBlackLevel, err = soap.UnmarshalUi2(response.CurrentBlueVideoBlackLevel); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredBlueVideoBlackLevel: allowed value range: minimum=0, step=1
+
+func (client *RenderingControl2) SetBlueVideoBlackLevel(InstanceID uint32, DesiredBlueVideoBlackLevel uint16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredBlueVideoBlackLevel string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredBlueVideoBlackLevel, err = soap.MarshalUi2(DesiredBlueVideoBlackLevel); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "SetBlueVideoBlackLevel", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentColorTemperature: allowed value range: minimum=0, step=1
+func (client *RenderingControl2) GetColorTemperature(InstanceID uint32) (CurrentColorTemperature uint16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentColorTemperature string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "GetColorTemperature", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentColorTemperature, err = soap.UnmarshalUi2(response.CurrentColorTemperature); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredColorTemperature: allowed value range: minimum=0, step=1
+
+func (client *RenderingControl2) SetColorTemperature(InstanceID uint32, DesiredColorTemperature uint16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredColorTemperature string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredColorTemperature, err = soap.MarshalUi2(DesiredColorTemperature); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "SetColorTemperature", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentHorizontalKeystone: allowed value range: step=1
+func (client *RenderingControl2) GetHorizontalKeystone(InstanceID uint32) (CurrentHorizontalKeystone int16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentHorizontalKeystone string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "GetHorizontalKeystone", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentHorizontalKeystone, err = soap.UnmarshalI2(response.CurrentHorizontalKeystone); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredHorizontalKeystone: allowed value range: step=1
+
+func (client *RenderingControl2) SetHorizontalKeystone(InstanceID uint32, DesiredHorizontalKeystone int16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredHorizontalKeystone string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredHorizontalKeystone, err = soap.MarshalI2(DesiredHorizontalKeystone); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "SetHorizontalKeystone", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Return values:
+//
+// * CurrentVerticalKeystone: allowed value range: step=1
+func (client *RenderingControl2) GetVerticalKeystone(InstanceID uint32) (CurrentVerticalKeystone int16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentVerticalKeystone string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "GetVerticalKeystone", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentVerticalKeystone, err = soap.UnmarshalI2(response.CurrentVerticalKeystone); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DesiredVerticalKeystone: allowed value range: step=1
+
+func (client *RenderingControl2) SetVerticalKeystone(InstanceID uint32, DesiredVerticalKeystone int16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ DesiredVerticalKeystone string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.DesiredVerticalKeystone, err = soap.MarshalI2(DesiredVerticalKeystone); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "SetVerticalKeystone", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Channel: allowed values: Master
+
+func (client *RenderingControl2) GetMute(InstanceID uint32, Channel string) (CurrentMute bool, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ Channel string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.Channel, err = soap.MarshalString(Channel); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentMute string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "GetMute", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentMute, err = soap.UnmarshalBoolean(response.CurrentMute); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Channel: allowed values: Master
+
+func (client *RenderingControl2) SetMute(InstanceID uint32, Channel string, DesiredMute bool) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ Channel string
+
+ DesiredMute string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.Channel, err = soap.MarshalString(Channel); err != nil {
+ return
+ }
+ if request.DesiredMute, err = soap.MarshalBoolean(DesiredMute); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "SetMute", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Channel: allowed values: Master
+
+//
+// Return values:
+//
+// * CurrentVolume: allowed value range: minimum=0, step=1
+func (client *RenderingControl2) GetVolume(InstanceID uint32, Channel string) (CurrentVolume uint16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ Channel string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.Channel, err = soap.MarshalString(Channel); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentVolume string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "GetVolume", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentVolume, err = soap.UnmarshalUi2(response.CurrentVolume); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Channel: allowed values: Master
+//
+// * DesiredVolume: allowed value range: minimum=0, step=1
+
+func (client *RenderingControl2) SetVolume(InstanceID uint32, Channel string, DesiredVolume uint16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ Channel string
+
+ DesiredVolume string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.Channel, err = soap.MarshalString(Channel); err != nil {
+ return
+ }
+ if request.DesiredVolume, err = soap.MarshalUi2(DesiredVolume); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "SetVolume", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Channel: allowed values: Master
+
+func (client *RenderingControl2) GetVolumeDB(InstanceID uint32, Channel string) (CurrentVolume int16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ Channel string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.Channel, err = soap.MarshalString(Channel); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentVolume string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "GetVolumeDB", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentVolume, err = soap.UnmarshalI2(response.CurrentVolume); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Channel: allowed values: Master
+
+func (client *RenderingControl2) SetVolumeDB(InstanceID uint32, Channel string, DesiredVolume int16) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ Channel string
+
+ DesiredVolume string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.Channel, err = soap.MarshalString(Channel); err != nil {
+ return
+ }
+ if request.DesiredVolume, err = soap.MarshalI2(DesiredVolume); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "SetVolumeDB", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Channel: allowed values: Master
+
+func (client *RenderingControl2) GetVolumeDBRange(InstanceID uint32, Channel string) (MinValue int16, MaxValue int16, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ Channel string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.Channel, err = soap.MarshalString(Channel); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ MinValue string
+
+ MaxValue string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "GetVolumeDBRange", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if MinValue, err = soap.UnmarshalI2(response.MinValue); err != nil {
+ return
+ }
+ if MaxValue, err = soap.UnmarshalI2(response.MaxValue); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Channel: allowed values: Master
+
+func (client *RenderingControl2) GetLoudness(InstanceID uint32, Channel string) (CurrentLoudness bool, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ Channel string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.Channel, err = soap.MarshalString(Channel); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ CurrentLoudness string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "GetLoudness", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if CurrentLoudness, err = soap.UnmarshalBoolean(response.CurrentLoudness); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * Channel: allowed values: Master
+
+func (client *RenderingControl2) SetLoudness(InstanceID uint32, Channel string, DesiredLoudness bool) (err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ Channel string
+
+ DesiredLoudness string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.Channel, err = soap.MarshalString(Channel); err != nil {
+ return
+ }
+ if request.DesiredLoudness, err = soap.MarshalBoolean(DesiredLoudness); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "SetLoudness", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *RenderingControl2) GetStateVariables(InstanceID uint32, StateVariableList string) (StateVariableValuePairs string, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ StateVariableList string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.StateVariableList, err = soap.MarshalString(StateVariableList); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ StateVariableValuePairs string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "GetStateVariables", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if StateVariableValuePairs, err = soap.UnmarshalString(response.StateVariableValuePairs); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *RenderingControl2) SetStateVariables(InstanceID uint32, RenderingControlUDN string, ServiceType string, ServiceId string, StateVariableValuePairs string) (StateVariableList string, err error) {
+ // Request structure.
+ request := &struct {
+ InstanceID string
+
+ RenderingControlUDN string
+
+ ServiceType string
+
+ ServiceId string
+
+ StateVariableValuePairs string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
+ return
+ }
+ if request.RenderingControlUDN, err = soap.MarshalString(RenderingControlUDN); err != nil {
+ return
+ }
+ if request.ServiceType, err = soap.MarshalString(ServiceType); err != nil {
+ return
+ }
+ if request.ServiceId, err = soap.MarshalString(ServiceId); err != nil {
+ return
+ }
+ if request.StateVariableValuePairs, err = soap.MarshalString(StateVariableValuePairs); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ StateVariableList string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_RenderingControl_2, "SetStateVariables", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if StateVariableList, err = soap.UnmarshalString(response.StateVariableList); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+// ScheduledRecording1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:ScheduledRecording:1". See
+// goupnp.ServiceClient, which contains RootDevice and Service attributes which
+// are provided for informational value.
+type ScheduledRecording1 struct {
+ goupnp.ServiceClient
+}
+
+// NewScheduledRecording1Clients discovers instances of the service on the network,
+// and returns clients to any that are found. errors will contain an error for
+// any devices that replied but which could not be queried, and err will be set
+// if the discovery process failed outright.
+//
+// This is a typical entry calling point into this package.
+func NewScheduledRecording1Clients() (clients []*ScheduledRecording1, errors []error, err error) {
+ var genericClients []goupnp.ServiceClient
+ if genericClients, errors, err = goupnp.NewServiceClients(URN_ScheduledRecording_1); err != nil {
+ return
+ }
+ clients = newScheduledRecording1ClientsFromGenericClients(genericClients)
+ return
+}
+
+// NewScheduledRecording1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewScheduledRecording1ClientsByURL(loc *url.URL) ([]*ScheduledRecording1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_ScheduledRecording_1)
+ if err != nil {
+ return nil, err
+ }
+ return newScheduledRecording1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewScheduledRecording1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewScheduledRecording1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*ScheduledRecording1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_ScheduledRecording_1)
+ if err != nil {
+ return nil, err
+ }
+ return newScheduledRecording1ClientsFromGenericClients(genericClients), nil
+}
+
+func newScheduledRecording1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*ScheduledRecording1 {
+ clients := make([]*ScheduledRecording1, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &ScheduledRecording1{genericClients[i]}
+ }
+ return clients
+}
+
+func (client *ScheduledRecording1) GetSortCapabilities() (SortCaps string, SortLevelCap uint32, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ SortCaps string
+
+ SortLevelCap string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_1, "GetSortCapabilities", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if SortCaps, err = soap.UnmarshalString(response.SortCaps); err != nil {
+ return
+ }
+ if SortLevelCap, err = soap.UnmarshalUi4(response.SortLevelCap); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DataTypeID: allowed values: A_ARG_TYPE_RecordSchedule, A_ARG_TYPE_RecordTask, A_ARG_TYPE_RecordScheduleParts
+
+func (client *ScheduledRecording1) GetPropertyList(DataTypeID string) (PropertyList string, err error) {
+ // Request structure.
+ request := &struct {
+ DataTypeID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.DataTypeID, err = soap.MarshalString(DataTypeID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ PropertyList string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_1, "GetPropertyList", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if PropertyList, err = soap.UnmarshalString(response.PropertyList); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DataTypeID: allowed values: A_ARG_TYPE_RecordSchedule, A_ARG_TYPE_RecordTask, A_ARG_TYPE_RecordScheduleParts
+
+func (client *ScheduledRecording1) GetAllowedValues(DataTypeID string, Filter string) (PropertyInfo string, err error) {
+ // Request structure.
+ request := &struct {
+ DataTypeID string
+
+ Filter string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.DataTypeID, err = soap.MarshalString(DataTypeID); err != nil {
+ return
+ }
+ if request.Filter, err = soap.MarshalString(Filter); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ PropertyInfo string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_1, "GetAllowedValues", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if PropertyInfo, err = soap.UnmarshalString(response.PropertyInfo); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording1) GetStateUpdateID() (Id uint32, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Id string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_1, "GetStateUpdateID", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Id, err = soap.UnmarshalUi4(response.Id); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording1) BrowseRecordSchedules(Filter string, StartingIndex uint32, RequestedCount uint32, SortCriteria string) (Result string, NumberReturned uint32, TotalMatches uint32, UpdateID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ Filter string
+
+ StartingIndex string
+
+ RequestedCount string
+
+ SortCriteria string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.Filter, err = soap.MarshalString(Filter); err != nil {
+ return
+ }
+ if request.StartingIndex, err = soap.MarshalUi4(StartingIndex); err != nil {
+ return
+ }
+ if request.RequestedCount, err = soap.MarshalUi4(RequestedCount); err != nil {
+ return
+ }
+ if request.SortCriteria, err = soap.MarshalString(SortCriteria); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Result string
+
+ NumberReturned string
+
+ TotalMatches string
+
+ UpdateID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_1, "BrowseRecordSchedules", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Result, err = soap.UnmarshalString(response.Result); err != nil {
+ return
+ }
+ if NumberReturned, err = soap.UnmarshalUi4(response.NumberReturned); err != nil {
+ return
+ }
+ if TotalMatches, err = soap.UnmarshalUi4(response.TotalMatches); err != nil {
+ return
+ }
+ if UpdateID, err = soap.UnmarshalUi4(response.UpdateID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording1) BrowseRecordTasks(RecordScheduleID string, Filter string, StartingIndex uint32, RequestedCount uint32, SortCriteria string) (Result string, NumberReturned uint32, TotalMatches uint32, UpdateID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ RecordScheduleID string
+
+ Filter string
+
+ StartingIndex string
+
+ RequestedCount string
+
+ SortCriteria string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordScheduleID, err = soap.MarshalString(RecordScheduleID); err != nil {
+ return
+ }
+ if request.Filter, err = soap.MarshalString(Filter); err != nil {
+ return
+ }
+ if request.StartingIndex, err = soap.MarshalUi4(StartingIndex); err != nil {
+ return
+ }
+ if request.RequestedCount, err = soap.MarshalUi4(RequestedCount); err != nil {
+ return
+ }
+ if request.SortCriteria, err = soap.MarshalString(SortCriteria); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Result string
+
+ NumberReturned string
+
+ TotalMatches string
+
+ UpdateID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_1, "BrowseRecordTasks", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Result, err = soap.UnmarshalString(response.Result); err != nil {
+ return
+ }
+ if NumberReturned, err = soap.UnmarshalUi4(response.NumberReturned); err != nil {
+ return
+ }
+ if TotalMatches, err = soap.UnmarshalUi4(response.TotalMatches); err != nil {
+ return
+ }
+ if UpdateID, err = soap.UnmarshalUi4(response.UpdateID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording1) CreateRecordSchedule(Elements string) (RecordScheduleID string, Result string, UpdateID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ Elements string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.Elements, err = soap.MarshalString(Elements); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ RecordScheduleID string
+
+ Result string
+
+ UpdateID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_1, "CreateRecordSchedule", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if RecordScheduleID, err = soap.UnmarshalString(response.RecordScheduleID); err != nil {
+ return
+ }
+ if Result, err = soap.UnmarshalString(response.Result); err != nil {
+ return
+ }
+ if UpdateID, err = soap.UnmarshalUi4(response.UpdateID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording1) DeleteRecordSchedule(RecordScheduleID string) (err error) {
+ // Request structure.
+ request := &struct {
+ RecordScheduleID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordScheduleID, err = soap.MarshalString(RecordScheduleID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_1, "DeleteRecordSchedule", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording1) GetRecordSchedule(RecordScheduleID string, Filter string) (Result string, UpdateID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ RecordScheduleID string
+
+ Filter string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordScheduleID, err = soap.MarshalString(RecordScheduleID); err != nil {
+ return
+ }
+ if request.Filter, err = soap.MarshalString(Filter); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Result string
+
+ UpdateID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_1, "GetRecordSchedule", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Result, err = soap.UnmarshalString(response.Result); err != nil {
+ return
+ }
+ if UpdateID, err = soap.UnmarshalUi4(response.UpdateID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording1) EnableRecordSchedule(RecordScheduleID string) (err error) {
+ // Request structure.
+ request := &struct {
+ RecordScheduleID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordScheduleID, err = soap.MarshalString(RecordScheduleID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_1, "EnableRecordSchedule", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording1) DisableRecordSchedule(RecordScheduleID string) (err error) {
+ // Request structure.
+ request := &struct {
+ RecordScheduleID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordScheduleID, err = soap.MarshalString(RecordScheduleID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_1, "DisableRecordSchedule", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording1) DeleteRecordTask(RecordTaskID string) (err error) {
+ // Request structure.
+ request := &struct {
+ RecordTaskID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordTaskID, err = soap.MarshalString(RecordTaskID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_1, "DeleteRecordTask", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording1) GetRecordTask(RecordTaskID string, Filter string) (Result string, UpdateID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ RecordTaskID string
+
+ Filter string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordTaskID, err = soap.MarshalString(RecordTaskID); err != nil {
+ return
+ }
+ if request.Filter, err = soap.MarshalString(Filter); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Result string
+
+ UpdateID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_1, "GetRecordTask", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Result, err = soap.UnmarshalString(response.Result); err != nil {
+ return
+ }
+ if UpdateID, err = soap.UnmarshalUi4(response.UpdateID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording1) EnableRecordTask(RecordTaskID string) (err error) {
+ // Request structure.
+ request := &struct {
+ RecordTaskID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordTaskID, err = soap.MarshalString(RecordTaskID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_1, "EnableRecordTask", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording1) DisableRecordTask(RecordTaskID string) (err error) {
+ // Request structure.
+ request := &struct {
+ RecordTaskID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordTaskID, err = soap.MarshalString(RecordTaskID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_1, "DisableRecordTask", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording1) ResetRecordTask(RecordTaskID string) (err error) {
+ // Request structure.
+ request := &struct {
+ RecordTaskID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordTaskID, err = soap.MarshalString(RecordTaskID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_1, "ResetRecordTask", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording1) GetRecordScheduleConflicts(RecordScheduleID string) (RecordScheduleConflictIDList string, UpdateID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ RecordScheduleID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordScheduleID, err = soap.MarshalString(RecordScheduleID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ RecordScheduleConflictIDList string
+
+ UpdateID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_1, "GetRecordScheduleConflicts", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if RecordScheduleConflictIDList, err = soap.UnmarshalString(response.RecordScheduleConflictIDList); err != nil {
+ return
+ }
+ if UpdateID, err = soap.UnmarshalUi4(response.UpdateID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording1) GetRecordTaskConflicts(RecordTaskID string) (RecordTaskConflictIDList string, UpdateID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ RecordTaskID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordTaskID, err = soap.MarshalString(RecordTaskID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ RecordTaskConflictIDList string
+
+ UpdateID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_1, "GetRecordTaskConflicts", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if RecordTaskConflictIDList, err = soap.UnmarshalString(response.RecordTaskConflictIDList); err != nil {
+ return
+ }
+ if UpdateID, err = soap.UnmarshalUi4(response.UpdateID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+// ScheduledRecording2 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:ScheduledRecording:2". See
+// goupnp.ServiceClient, which contains RootDevice and Service attributes which
+// are provided for informational value.
+type ScheduledRecording2 struct {
+ goupnp.ServiceClient
+}
+
+// NewScheduledRecording2Clients discovers instances of the service on the network,
+// and returns clients to any that are found. errors will contain an error for
+// any devices that replied but which could not be queried, and err will be set
+// if the discovery process failed outright.
+//
+// This is a typical entry calling point into this package.
+func NewScheduledRecording2Clients() (clients []*ScheduledRecording2, errors []error, err error) {
+ var genericClients []goupnp.ServiceClient
+ if genericClients, errors, err = goupnp.NewServiceClients(URN_ScheduledRecording_2); err != nil {
+ return
+ }
+ clients = newScheduledRecording2ClientsFromGenericClients(genericClients)
+ return
+}
+
+// NewScheduledRecording2ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewScheduledRecording2ClientsByURL(loc *url.URL) ([]*ScheduledRecording2, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_ScheduledRecording_2)
+ if err != nil {
+ return nil, err
+ }
+ return newScheduledRecording2ClientsFromGenericClients(genericClients), nil
+}
+
+// NewScheduledRecording2ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewScheduledRecording2ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*ScheduledRecording2, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_ScheduledRecording_2)
+ if err != nil {
+ return nil, err
+ }
+ return newScheduledRecording2ClientsFromGenericClients(genericClients), nil
+}
+
+func newScheduledRecording2ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*ScheduledRecording2 {
+ clients := make([]*ScheduledRecording2, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &ScheduledRecording2{genericClients[i]}
+ }
+ return clients
+}
+
+func (client *ScheduledRecording2) GetSortCapabilities() (SortCaps string, SortLevelCap uint32, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ SortCaps string
+
+ SortLevelCap string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_2, "GetSortCapabilities", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if SortCaps, err = soap.UnmarshalString(response.SortCaps); err != nil {
+ return
+ }
+ if SortLevelCap, err = soap.UnmarshalUi4(response.SortLevelCap); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DataTypeID: allowed values: A_ARG_TYPE_RecordSchedule, A_ARG_TYPE_RecordTask, A_ARG_TYPE_RecordScheduleParts
+
+func (client *ScheduledRecording2) GetPropertyList(DataTypeID string) (PropertyList string, err error) {
+ // Request structure.
+ request := &struct {
+ DataTypeID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.DataTypeID, err = soap.MarshalString(DataTypeID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ PropertyList string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_2, "GetPropertyList", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if PropertyList, err = soap.UnmarshalString(response.PropertyList); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+//
+// Arguments:
+//
+// * DataTypeID: allowed values: A_ARG_TYPE_RecordSchedule, A_ARG_TYPE_RecordTask, A_ARG_TYPE_RecordScheduleParts
+
+func (client *ScheduledRecording2) GetAllowedValues(DataTypeID string, Filter string) (PropertyInfo string, err error) {
+ // Request structure.
+ request := &struct {
+ DataTypeID string
+
+ Filter string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.DataTypeID, err = soap.MarshalString(DataTypeID); err != nil {
+ return
+ }
+ if request.Filter, err = soap.MarshalString(Filter); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ PropertyInfo string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_2, "GetAllowedValues", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if PropertyInfo, err = soap.UnmarshalString(response.PropertyInfo); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording2) GetStateUpdateID() (Id uint32, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Id string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_2, "GetStateUpdateID", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Id, err = soap.UnmarshalUi4(response.Id); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording2) BrowseRecordSchedules(Filter string, StartingIndex uint32, RequestedCount uint32, SortCriteria string) (Result string, NumberReturned uint32, TotalMatches uint32, UpdateID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ Filter string
+
+ StartingIndex string
+
+ RequestedCount string
+
+ SortCriteria string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.Filter, err = soap.MarshalString(Filter); err != nil {
+ return
+ }
+ if request.StartingIndex, err = soap.MarshalUi4(StartingIndex); err != nil {
+ return
+ }
+ if request.RequestedCount, err = soap.MarshalUi4(RequestedCount); err != nil {
+ return
+ }
+ if request.SortCriteria, err = soap.MarshalString(SortCriteria); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Result string
+
+ NumberReturned string
+
+ TotalMatches string
+
+ UpdateID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_2, "BrowseRecordSchedules", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Result, err = soap.UnmarshalString(response.Result); err != nil {
+ return
+ }
+ if NumberReturned, err = soap.UnmarshalUi4(response.NumberReturned); err != nil {
+ return
+ }
+ if TotalMatches, err = soap.UnmarshalUi4(response.TotalMatches); err != nil {
+ return
+ }
+ if UpdateID, err = soap.UnmarshalUi4(response.UpdateID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording2) BrowseRecordTasks(RecordScheduleID string, Filter string, StartingIndex uint32, RequestedCount uint32, SortCriteria string) (Result string, NumberReturned uint32, TotalMatches uint32, UpdateID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ RecordScheduleID string
+
+ Filter string
+
+ StartingIndex string
+
+ RequestedCount string
+
+ SortCriteria string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordScheduleID, err = soap.MarshalString(RecordScheduleID); err != nil {
+ return
+ }
+ if request.Filter, err = soap.MarshalString(Filter); err != nil {
+ return
+ }
+ if request.StartingIndex, err = soap.MarshalUi4(StartingIndex); err != nil {
+ return
+ }
+ if request.RequestedCount, err = soap.MarshalUi4(RequestedCount); err != nil {
+ return
+ }
+ if request.SortCriteria, err = soap.MarshalString(SortCriteria); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Result string
+
+ NumberReturned string
+
+ TotalMatches string
+
+ UpdateID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_2, "BrowseRecordTasks", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Result, err = soap.UnmarshalString(response.Result); err != nil {
+ return
+ }
+ if NumberReturned, err = soap.UnmarshalUi4(response.NumberReturned); err != nil {
+ return
+ }
+ if TotalMatches, err = soap.UnmarshalUi4(response.TotalMatches); err != nil {
+ return
+ }
+ if UpdateID, err = soap.UnmarshalUi4(response.UpdateID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording2) CreateRecordSchedule(Elements string) (RecordScheduleID string, Result string, UpdateID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ Elements string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.Elements, err = soap.MarshalString(Elements); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ RecordScheduleID string
+
+ Result string
+
+ UpdateID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_2, "CreateRecordSchedule", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if RecordScheduleID, err = soap.UnmarshalString(response.RecordScheduleID); err != nil {
+ return
+ }
+ if Result, err = soap.UnmarshalString(response.Result); err != nil {
+ return
+ }
+ if UpdateID, err = soap.UnmarshalUi4(response.UpdateID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording2) DeleteRecordSchedule(RecordScheduleID string) (err error) {
+ // Request structure.
+ request := &struct {
+ RecordScheduleID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordScheduleID, err = soap.MarshalString(RecordScheduleID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_2, "DeleteRecordSchedule", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording2) GetRecordSchedule(RecordScheduleID string, Filter string) (Result string, UpdateID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ RecordScheduleID string
+
+ Filter string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordScheduleID, err = soap.MarshalString(RecordScheduleID); err != nil {
+ return
+ }
+ if request.Filter, err = soap.MarshalString(Filter); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Result string
+
+ UpdateID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_2, "GetRecordSchedule", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Result, err = soap.UnmarshalString(response.Result); err != nil {
+ return
+ }
+ if UpdateID, err = soap.UnmarshalUi4(response.UpdateID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording2) EnableRecordSchedule(RecordScheduleID string) (err error) {
+ // Request structure.
+ request := &struct {
+ RecordScheduleID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordScheduleID, err = soap.MarshalString(RecordScheduleID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_2, "EnableRecordSchedule", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording2) DisableRecordSchedule(RecordScheduleID string) (err error) {
+ // Request structure.
+ request := &struct {
+ RecordScheduleID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordScheduleID, err = soap.MarshalString(RecordScheduleID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_2, "DisableRecordSchedule", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording2) DeleteRecordTask(RecordTaskID string) (err error) {
+ // Request structure.
+ request := &struct {
+ RecordTaskID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordTaskID, err = soap.MarshalString(RecordTaskID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_2, "DeleteRecordTask", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording2) GetRecordTask(RecordTaskID string, Filter string) (Result string, UpdateID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ RecordTaskID string
+
+ Filter string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordTaskID, err = soap.MarshalString(RecordTaskID); err != nil {
+ return
+ }
+ if request.Filter, err = soap.MarshalString(Filter); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Result string
+
+ UpdateID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_2, "GetRecordTask", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Result, err = soap.UnmarshalString(response.Result); err != nil {
+ return
+ }
+ if UpdateID, err = soap.UnmarshalUi4(response.UpdateID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording2) EnableRecordTask(RecordTaskID string) (err error) {
+ // Request structure.
+ request := &struct {
+ RecordTaskID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordTaskID, err = soap.MarshalString(RecordTaskID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_2, "EnableRecordTask", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording2) DisableRecordTask(RecordTaskID string) (err error) {
+ // Request structure.
+ request := &struct {
+ RecordTaskID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordTaskID, err = soap.MarshalString(RecordTaskID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_2, "DisableRecordTask", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording2) ResetRecordTask(RecordTaskID string) (err error) {
+ // Request structure.
+ request := &struct {
+ RecordTaskID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordTaskID, err = soap.MarshalString(RecordTaskID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_2, "ResetRecordTask", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording2) GetRecordScheduleConflicts(RecordScheduleID string) (RecordScheduleConflictIDList string, UpdateID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ RecordScheduleID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordScheduleID, err = soap.MarshalString(RecordScheduleID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ RecordScheduleConflictIDList string
+
+ UpdateID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_2, "GetRecordScheduleConflicts", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if RecordScheduleConflictIDList, err = soap.UnmarshalString(response.RecordScheduleConflictIDList); err != nil {
+ return
+ }
+ if UpdateID, err = soap.UnmarshalUi4(response.UpdateID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *ScheduledRecording2) GetRecordTaskConflicts(RecordTaskID string) (RecordTaskConflictIDList string, UpdateID uint32, err error) {
+ // Request structure.
+ request := &struct {
+ RecordTaskID string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.RecordTaskID, err = soap.MarshalString(RecordTaskID); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ RecordTaskConflictIDList string
+
+ UpdateID string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_ScheduledRecording_2, "GetRecordTaskConflicts", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if RecordTaskConflictIDList, err = soap.UnmarshalString(response.RecordTaskConflictIDList); err != nil {
+ return
+ }
+ if UpdateID, err = soap.UnmarshalUi4(response.UpdateID); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
diff --git a/Godeps/_workspace/src/github.com/huin/goupnp/dcps/internetgateway1/internetgateway1.go b/Godeps/_workspace/src/github.com/huin/goupnp/dcps/internetgateway1/internetgateway1.go
index be71855a9..1e0802cd4 100644
--- a/Godeps/_workspace/src/github.com/huin/goupnp/dcps/internetgateway1/internetgateway1.go
+++ b/Godeps/_workspace/src/github.com/huin/goupnp/dcps/internetgateway1/internetgateway1.go
@@ -2,13 +2,13 @@
//
// This DCP is documented in detail at: http://upnp.org/specs/gw/UPnP-gw-InternetGatewayDevice-v1-Device.pdf
//
-// Typically, use one of the New* functions to discover services on the local
-// network.
+// Typically, use one of the New* functions to create clients for services.
package internetgateway1
// Generated file - do not edit by hand. See README.md
import (
+ "net/url"
"time"
"github.com/huin/goupnp"
@@ -56,18 +56,48 @@ func NewLANHostConfigManagement1Clients() (clients []*LANHostConfigManagement1,
if genericClients, errors, err = goupnp.NewServiceClients(URN_LANHostConfigManagement_1); err != nil {
return
}
- clients = make([]*LANHostConfigManagement1, len(genericClients))
- for i := range genericClients {
- clients[i] = &LANHostConfigManagement1{genericClients[i]}
- }
+ clients = newLANHostConfigManagement1ClientsFromGenericClients(genericClients)
return
}
-// Arguments:
-//
-// * NewDHCPServerConfigurable:
+// NewLANHostConfigManagement1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewLANHostConfigManagement1ClientsByURL(loc *url.URL) ([]*LANHostConfigManagement1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_LANHostConfigManagement_1)
+ if err != nil {
+ return nil, err
+ }
+ return newLANHostConfigManagement1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewLANHostConfigManagement1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewLANHostConfigManagement1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*LANHostConfigManagement1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_LANHostConfigManagement_1)
+ if err != nil {
+ return nil, err
+ }
+ return newLANHostConfigManagement1ClientsFromGenericClients(genericClients), nil
+}
+
+func newLANHostConfigManagement1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*LANHostConfigManagement1 {
+ clients := make([]*LANHostConfigManagement1, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &LANHostConfigManagement1{genericClients[i]}
+ }
+ return clients
+}
+
func (client *LANHostConfigManagement1) SetDHCPServerConfigurable(NewDHCPServerConfigurable bool) (err error) {
// Request structure.
request := &struct {
@@ -94,11 +124,6 @@ func (client *LANHostConfigManagement1) SetDHCPServerConfigurable(NewDHCPServerC
return
}
-//
-//
-// Return values:
-//
-// * NewDHCPServerConfigurable:
func (client *LANHostConfigManagement1) GetDHCPServerConfigurable() (NewDHCPServerConfigurable bool, err error) {
// Request structure.
request := interface{}(nil)
@@ -125,11 +150,6 @@ func (client *LANHostConfigManagement1) GetDHCPServerConfigurable() (NewDHCPServ
return
}
-// Arguments:
-//
-// * NewDHCPRelay:
-//
-//
func (client *LANHostConfigManagement1) SetDHCPRelay(NewDHCPRelay bool) (err error) {
// Request structure.
request := &struct {
@@ -156,11 +176,6 @@ func (client *LANHostConfigManagement1) SetDHCPRelay(NewDHCPRelay bool) (err err
return
}
-//
-//
-// Return values:
-//
-// * NewDHCPRelay:
func (client *LANHostConfigManagement1) GetDHCPRelay() (NewDHCPRelay bool, err error) {
// Request structure.
request := interface{}(nil)
@@ -187,11 +202,6 @@ func (client *LANHostConfigManagement1) GetDHCPRelay() (NewDHCPRelay bool, err e
return
}
-// Arguments:
-//
-// * NewSubnetMask:
-//
-//
func (client *LANHostConfigManagement1) SetSubnetMask(NewSubnetMask string) (err error) {
// Request structure.
request := &struct {
@@ -218,11 +228,6 @@ func (client *LANHostConfigManagement1) SetSubnetMask(NewSubnetMask string) (err
return
}
-//
-//
-// Return values:
-//
-// * NewSubnetMask:
func (client *LANHostConfigManagement1) GetSubnetMask() (NewSubnetMask string, err error) {
// Request structure.
request := interface{}(nil)
@@ -249,11 +254,6 @@ func (client *LANHostConfigManagement1) GetSubnetMask() (NewSubnetMask string, e
return
}
-// Arguments:
-//
-// * NewIPRouters:
-//
-//
func (client *LANHostConfigManagement1) SetIPRouter(NewIPRouters string) (err error) {
// Request structure.
request := &struct {
@@ -280,11 +280,6 @@ func (client *LANHostConfigManagement1) SetIPRouter(NewIPRouters string) (err er
return
}
-// Arguments:
-//
-// * NewIPRouters:
-//
-//
func (client *LANHostConfigManagement1) DeleteIPRouter(NewIPRouters string) (err error) {
// Request structure.
request := &struct {
@@ -311,11 +306,6 @@ func (client *LANHostConfigManagement1) DeleteIPRouter(NewIPRouters string) (err
return
}
-//
-//
-// Return values:
-//
-// * NewIPRouters:
func (client *LANHostConfigManagement1) GetIPRoutersList() (NewIPRouters string, err error) {
// Request structure.
request := interface{}(nil)
@@ -342,11 +332,6 @@ func (client *LANHostConfigManagement1) GetIPRoutersList() (NewIPRouters string,
return
}
-// Arguments:
-//
-// * NewDomainName:
-//
-//
func (client *LANHostConfigManagement1) SetDomainName(NewDomainName string) (err error) {
// Request structure.
request := &struct {
@@ -373,11 +358,6 @@ func (client *LANHostConfigManagement1) SetDomainName(NewDomainName string) (err
return
}
-//
-//
-// Return values:
-//
-// * NewDomainName:
func (client *LANHostConfigManagement1) GetDomainName() (NewDomainName string, err error) {
// Request structure.
request := interface{}(nil)
@@ -404,13 +384,6 @@ func (client *LANHostConfigManagement1) GetDomainName() (NewDomainName string, e
return
}
-// Arguments:
-//
-// * NewMinAddress:
-//
-// * NewMaxAddress:
-//
-//
func (client *LANHostConfigManagement1) SetAddressRange(NewMinAddress string, NewMaxAddress string) (err error) {
// Request structure.
request := &struct {
@@ -442,13 +415,6 @@ func (client *LANHostConfigManagement1) SetAddressRange(NewMinAddress string, Ne
return
}
-//
-//
-// Return values:
-//
-// * NewMinAddress:
-//
-// * NewMaxAddress:
func (client *LANHostConfigManagement1) GetAddressRange() (NewMinAddress string, NewMaxAddress string, err error) {
// Request structure.
request := interface{}(nil)
@@ -480,11 +446,6 @@ func (client *LANHostConfigManagement1) GetAddressRange() (NewMinAddress string,
return
}
-// Arguments:
-//
-// * NewReservedAddresses:
-//
-//
func (client *LANHostConfigManagement1) SetReservedAddress(NewReservedAddresses string) (err error) {
// Request structure.
request := &struct {
@@ -511,11 +472,6 @@ func (client *LANHostConfigManagement1) SetReservedAddress(NewReservedAddresses
return
}
-// Arguments:
-//
-// * NewReservedAddresses:
-//
-//
func (client *LANHostConfigManagement1) DeleteReservedAddress(NewReservedAddresses string) (err error) {
// Request structure.
request := &struct {
@@ -542,11 +498,6 @@ func (client *LANHostConfigManagement1) DeleteReservedAddress(NewReservedAddress
return
}
-//
-//
-// Return values:
-//
-// * NewReservedAddresses:
func (client *LANHostConfigManagement1) GetReservedAddresses() (NewReservedAddresses string, err error) {
// Request structure.
request := interface{}(nil)
@@ -573,11 +524,6 @@ func (client *LANHostConfigManagement1) GetReservedAddresses() (NewReservedAddre
return
}
-// Arguments:
-//
-// * NewDNSServers:
-//
-//
func (client *LANHostConfigManagement1) SetDNSServer(NewDNSServers string) (err error) {
// Request structure.
request := &struct {
@@ -604,11 +550,6 @@ func (client *LANHostConfigManagement1) SetDNSServer(NewDNSServers string) (err
return
}
-// Arguments:
-//
-// * NewDNSServers:
-//
-//
func (client *LANHostConfigManagement1) DeleteDNSServer(NewDNSServers string) (err error) {
// Request structure.
request := &struct {
@@ -635,11 +576,6 @@ func (client *LANHostConfigManagement1) DeleteDNSServer(NewDNSServers string) (e
return
}
-//
-//
-// Return values:
-//
-// * NewDNSServers:
func (client *LANHostConfigManagement1) GetDNSServers() (NewDNSServers string, err error) {
// Request structure.
request := interface{}(nil)
@@ -684,18 +620,48 @@ func NewLayer3Forwarding1Clients() (clients []*Layer3Forwarding1, errors []error
if genericClients, errors, err = goupnp.NewServiceClients(URN_Layer3Forwarding_1); err != nil {
return
}
- clients = make([]*Layer3Forwarding1, len(genericClients))
- for i := range genericClients {
- clients[i] = &Layer3Forwarding1{genericClients[i]}
- }
+ clients = newLayer3Forwarding1ClientsFromGenericClients(genericClients)
return
}
-// Arguments:
-//
-// * NewDefaultConnectionService:
+// NewLayer3Forwarding1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewLayer3Forwarding1ClientsByURL(loc *url.URL) ([]*Layer3Forwarding1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_Layer3Forwarding_1)
+ if err != nil {
+ return nil, err
+ }
+ return newLayer3Forwarding1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewLayer3Forwarding1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewLayer3Forwarding1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*Layer3Forwarding1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_Layer3Forwarding_1)
+ if err != nil {
+ return nil, err
+ }
+ return newLayer3Forwarding1ClientsFromGenericClients(genericClients), nil
+}
+
+func newLayer3Forwarding1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*Layer3Forwarding1 {
+ clients := make([]*Layer3Forwarding1, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &Layer3Forwarding1{genericClients[i]}
+ }
+ return clients
+}
+
func (client *Layer3Forwarding1) SetDefaultConnectionService(NewDefaultConnectionService string) (err error) {
// Request structure.
request := &struct {
@@ -722,11 +688,6 @@ func (client *Layer3Forwarding1) SetDefaultConnectionService(NewDefaultConnectio
return
}
-//
-//
-// Return values:
-//
-// * NewDefaultConnectionService:
func (client *Layer3Forwarding1) GetDefaultConnectionService() (NewDefaultConnectionService string, err error) {
// Request structure.
request := interface{}(nil)
@@ -771,15 +732,49 @@ func NewWANCableLinkConfig1Clients() (clients []*WANCableLinkConfig1, errors []e
if genericClients, errors, err = goupnp.NewServiceClients(URN_WANCableLinkConfig_1); err != nil {
return
}
- clients = make([]*WANCableLinkConfig1, len(genericClients))
+ clients = newWANCableLinkConfig1ClientsFromGenericClients(genericClients)
+ return
+}
+
+// NewWANCableLinkConfig1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewWANCableLinkConfig1ClientsByURL(loc *url.URL) ([]*WANCableLinkConfig1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANCableLinkConfig_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANCableLinkConfig1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewWANCableLinkConfig1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewWANCableLinkConfig1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*WANCableLinkConfig1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_WANCableLinkConfig_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANCableLinkConfig1ClientsFromGenericClients(genericClients), nil
+}
+
+func newWANCableLinkConfig1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*WANCableLinkConfig1 {
+ clients := make([]*WANCableLinkConfig1, len(genericClients))
for i := range genericClients {
clients[i] = &WANCableLinkConfig1{genericClients[i]}
}
- return
+ return clients
}
//
-//
// Return values:
//
// * NewCableLinkConfigState: allowed values: notReady, dsSyncComplete, usParamAcquired, rangingComplete, ipComplete, todEstablished, paramTransferComplete, registrationComplete, operational, accessDenied
@@ -816,11 +811,6 @@ func (client *WANCableLinkConfig1) GetCableLinkConfigInfo() (NewCableLinkConfigS
return
}
-//
-//
-// Return values:
-//
-// * NewDownstreamFrequency:
func (client *WANCableLinkConfig1) GetDownstreamFrequency() (NewDownstreamFrequency uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -848,7 +838,6 @@ func (client *WANCableLinkConfig1) GetDownstreamFrequency() (NewDownstreamFreque
}
//
-//
// Return values:
//
// * NewDownstreamModulation: allowed values: 64QAM, 256QAM
@@ -878,11 +867,6 @@ func (client *WANCableLinkConfig1) GetDownstreamModulation() (NewDownstreamModul
return
}
-//
-//
-// Return values:
-//
-// * NewUpstreamFrequency:
func (client *WANCableLinkConfig1) GetUpstreamFrequency() (NewUpstreamFrequency uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -910,7 +894,6 @@ func (client *WANCableLinkConfig1) GetUpstreamFrequency() (NewUpstreamFrequency
}
//
-//
// Return values:
//
// * NewUpstreamModulation: allowed values: QPSK, 16QAM
@@ -940,11 +923,6 @@ func (client *WANCableLinkConfig1) GetUpstreamModulation() (NewUpstreamModulatio
return
}
-//
-//
-// Return values:
-//
-// * NewUpstreamChannelID:
func (client *WANCableLinkConfig1) GetUpstreamChannelID() (NewUpstreamChannelID uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -971,11 +949,6 @@ func (client *WANCableLinkConfig1) GetUpstreamChannelID() (NewUpstreamChannelID
return
}
-//
-//
-// Return values:
-//
-// * NewUpstreamPowerLevel:
func (client *WANCableLinkConfig1) GetUpstreamPowerLevel() (NewUpstreamPowerLevel uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -1002,11 +975,6 @@ func (client *WANCableLinkConfig1) GetUpstreamPowerLevel() (NewUpstreamPowerLeve
return
}
-//
-//
-// Return values:
-//
-// * NewBPIEncryptionEnabled:
func (client *WANCableLinkConfig1) GetBPIEncryptionEnabled() (NewBPIEncryptionEnabled bool, err error) {
// Request structure.
request := interface{}(nil)
@@ -1033,11 +1001,6 @@ func (client *WANCableLinkConfig1) GetBPIEncryptionEnabled() (NewBPIEncryptionEn
return
}
-//
-//
-// Return values:
-//
-// * NewConfigFile:
func (client *WANCableLinkConfig1) GetConfigFile() (NewConfigFile string, err error) {
// Request structure.
request := interface{}(nil)
@@ -1064,11 +1027,6 @@ func (client *WANCableLinkConfig1) GetConfigFile() (NewConfigFile string, err er
return
}
-//
-//
-// Return values:
-//
-// * NewTFTPServer:
func (client *WANCableLinkConfig1) GetTFTPServer() (NewTFTPServer string, err error) {
// Request structure.
request := interface{}(nil)
@@ -1113,18 +1071,48 @@ func NewWANCommonInterfaceConfig1Clients() (clients []*WANCommonInterfaceConfig1
if genericClients, errors, err = goupnp.NewServiceClients(URN_WANCommonInterfaceConfig_1); err != nil {
return
}
- clients = make([]*WANCommonInterfaceConfig1, len(genericClients))
- for i := range genericClients {
- clients[i] = &WANCommonInterfaceConfig1{genericClients[i]}
- }
+ clients = newWANCommonInterfaceConfig1ClientsFromGenericClients(genericClients)
return
}
-// Arguments:
-//
-// * NewEnabledForInternet:
+// NewWANCommonInterfaceConfig1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewWANCommonInterfaceConfig1ClientsByURL(loc *url.URL) ([]*WANCommonInterfaceConfig1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANCommonInterfaceConfig_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANCommonInterfaceConfig1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewWANCommonInterfaceConfig1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewWANCommonInterfaceConfig1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*WANCommonInterfaceConfig1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_WANCommonInterfaceConfig_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANCommonInterfaceConfig1ClientsFromGenericClients(genericClients), nil
+}
+
+func newWANCommonInterfaceConfig1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*WANCommonInterfaceConfig1 {
+ clients := make([]*WANCommonInterfaceConfig1, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &WANCommonInterfaceConfig1{genericClients[i]}
+ }
+ return clients
+}
+
func (client *WANCommonInterfaceConfig1) SetEnabledForInternet(NewEnabledForInternet bool) (err error) {
// Request structure.
request := &struct {
@@ -1151,11 +1139,6 @@ func (client *WANCommonInterfaceConfig1) SetEnabledForInternet(NewEnabledForInte
return
}
-//
-//
-// Return values:
-//
-// * NewEnabledForInternet:
func (client *WANCommonInterfaceConfig1) GetEnabledForInternet() (NewEnabledForInternet bool, err error) {
// Request structure.
request := interface{}(nil)
@@ -1183,15 +1166,10 @@ func (client *WANCommonInterfaceConfig1) GetEnabledForInternet() (NewEnabledForI
}
//
-//
// Return values:
//
// * NewWANAccessType: allowed values: DSL, POTS, Cable, Ethernet
//
-// * NewLayer1UpstreamMaxBitRate:
-//
-// * NewLayer1DownstreamMaxBitRate:
-//
// * NewPhysicalLinkStatus: allowed values: Up, Down
func (client *WANCommonInterfaceConfig1) GetCommonLinkProperties() (NewWANAccessType string, NewLayer1UpstreamMaxBitRate uint32, NewLayer1DownstreamMaxBitRate uint32, NewPhysicalLinkStatus string, err error) {
// Request structure.
@@ -1234,11 +1212,6 @@ func (client *WANCommonInterfaceConfig1) GetCommonLinkProperties() (NewWANAccess
return
}
-//
-//
-// Return values:
-//
-// * NewWANAccessProvider:
func (client *WANCommonInterfaceConfig1) GetWANAccessProvider() (NewWANAccessProvider string, err error) {
// Request structure.
request := interface{}(nil)
@@ -1266,7 +1239,6 @@ func (client *WANCommonInterfaceConfig1) GetWANAccessProvider() (NewWANAccessPro
}
//
-//
// Return values:
//
// * NewMaximumActiveConnections: allowed value range: minimum=1, step=1
@@ -1296,11 +1268,6 @@ func (client *WANCommonInterfaceConfig1) GetMaximumActiveConnections() (NewMaxim
return
}
-//
-//
-// Return values:
-//
-// * NewTotalBytesSent:
func (client *WANCommonInterfaceConfig1) GetTotalBytesSent() (NewTotalBytesSent uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -1327,11 +1294,6 @@ func (client *WANCommonInterfaceConfig1) GetTotalBytesSent() (NewTotalBytesSent
return
}
-//
-//
-// Return values:
-//
-// * NewTotalBytesReceived:
func (client *WANCommonInterfaceConfig1) GetTotalBytesReceived() (NewTotalBytesReceived uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -1358,11 +1320,6 @@ func (client *WANCommonInterfaceConfig1) GetTotalBytesReceived() (NewTotalBytesR
return
}
-//
-//
-// Return values:
-//
-// * NewTotalPacketsSent:
func (client *WANCommonInterfaceConfig1) GetTotalPacketsSent() (NewTotalPacketsSent uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -1389,11 +1346,6 @@ func (client *WANCommonInterfaceConfig1) GetTotalPacketsSent() (NewTotalPacketsS
return
}
-//
-//
-// Return values:
-//
-// * NewTotalPacketsReceived:
func (client *WANCommonInterfaceConfig1) GetTotalPacketsReceived() (NewTotalPacketsReceived uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -1420,15 +1372,6 @@ func (client *WANCommonInterfaceConfig1) GetTotalPacketsReceived() (NewTotalPack
return
}
-// Arguments:
-//
-// * NewActiveConnectionIndex:
-//
-// Return values:
-//
-// * NewActiveConnDeviceContainer:
-//
-// * NewActiveConnectionServiceID:
func (client *WANCommonInterfaceConfig1) GetActiveConnection(NewActiveConnectionIndex uint16) (NewActiveConnDeviceContainer string, NewActiveConnectionServiceID string, err error) {
// Request structure.
request := &struct {
@@ -1483,18 +1426,48 @@ func NewWANDSLLinkConfig1Clients() (clients []*WANDSLLinkConfig1, errors []error
if genericClients, errors, err = goupnp.NewServiceClients(URN_WANDSLLinkConfig_1); err != nil {
return
}
- clients = make([]*WANDSLLinkConfig1, len(genericClients))
- for i := range genericClients {
- clients[i] = &WANDSLLinkConfig1{genericClients[i]}
- }
+ clients = newWANDSLLinkConfig1ClientsFromGenericClients(genericClients)
return
}
-// Arguments:
-//
-// * NewLinkType:
+// NewWANDSLLinkConfig1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewWANDSLLinkConfig1ClientsByURL(loc *url.URL) ([]*WANDSLLinkConfig1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANDSLLinkConfig_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANDSLLinkConfig1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewWANDSLLinkConfig1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewWANDSLLinkConfig1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*WANDSLLinkConfig1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_WANDSLLinkConfig_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANDSLLinkConfig1ClientsFromGenericClients(genericClients), nil
+}
+
+func newWANDSLLinkConfig1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*WANDSLLinkConfig1 {
+ clients := make([]*WANDSLLinkConfig1, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &WANDSLLinkConfig1{genericClients[i]}
+ }
+ return clients
+}
+
func (client *WANDSLLinkConfig1) SetDSLLinkType(NewLinkType string) (err error) {
// Request structure.
request := &struct {
@@ -1522,11 +1495,8 @@ func (client *WANDSLLinkConfig1) SetDSLLinkType(NewLinkType string) (err error)
}
//
-//
// Return values:
//
-// * NewLinkType:
-//
// * NewLinkStatus: allowed values: Up, Down
func (client *WANDSLLinkConfig1) GetDSLLinkInfo() (NewLinkType string, NewLinkStatus string, err error) {
// Request structure.
@@ -1559,11 +1529,6 @@ func (client *WANDSLLinkConfig1) GetDSLLinkInfo() (NewLinkType string, NewLinkSt
return
}
-//
-//
-// Return values:
-//
-// * NewAutoConfig:
func (client *WANDSLLinkConfig1) GetAutoConfig() (NewAutoConfig bool, err error) {
// Request structure.
request := interface{}(nil)
@@ -1590,11 +1555,6 @@ func (client *WANDSLLinkConfig1) GetAutoConfig() (NewAutoConfig bool, err error)
return
}
-//
-//
-// Return values:
-//
-// * NewModulationType:
func (client *WANDSLLinkConfig1) GetModulationType() (NewModulationType string, err error) {
// Request structure.
request := interface{}(nil)
@@ -1621,11 +1581,6 @@ func (client *WANDSLLinkConfig1) GetModulationType() (NewModulationType string,
return
}
-// Arguments:
-//
-// * NewDestinationAddress:
-//
-//
func (client *WANDSLLinkConfig1) SetDestinationAddress(NewDestinationAddress string) (err error) {
// Request structure.
request := &struct {
@@ -1652,11 +1607,6 @@ func (client *WANDSLLinkConfig1) SetDestinationAddress(NewDestinationAddress str
return
}
-//
-//
-// Return values:
-//
-// * NewDestinationAddress:
func (client *WANDSLLinkConfig1) GetDestinationAddress() (NewDestinationAddress string, err error) {
// Request structure.
request := interface{}(nil)
@@ -1683,11 +1633,6 @@ func (client *WANDSLLinkConfig1) GetDestinationAddress() (NewDestinationAddress
return
}
-// Arguments:
-//
-// * NewATMEncapsulation:
-//
-//
func (client *WANDSLLinkConfig1) SetATMEncapsulation(NewATMEncapsulation string) (err error) {
// Request structure.
request := &struct {
@@ -1714,11 +1659,6 @@ func (client *WANDSLLinkConfig1) SetATMEncapsulation(NewATMEncapsulation string)
return
}
-//
-//
-// Return values:
-//
-// * NewATMEncapsulation:
func (client *WANDSLLinkConfig1) GetATMEncapsulation() (NewATMEncapsulation string, err error) {
// Request structure.
request := interface{}(nil)
@@ -1745,11 +1685,6 @@ func (client *WANDSLLinkConfig1) GetATMEncapsulation() (NewATMEncapsulation stri
return
}
-// Arguments:
-//
-// * NewFCSPreserved:
-//
-//
func (client *WANDSLLinkConfig1) SetFCSPreserved(NewFCSPreserved bool) (err error) {
// Request structure.
request := &struct {
@@ -1776,11 +1711,6 @@ func (client *WANDSLLinkConfig1) SetFCSPreserved(NewFCSPreserved bool) (err erro
return
}
-//
-//
-// Return values:
-//
-// * NewFCSPreserved:
func (client *WANDSLLinkConfig1) GetFCSPreserved() (NewFCSPreserved bool, err error) {
// Request structure.
request := interface{}(nil)
@@ -1825,15 +1755,49 @@ func NewWANEthernetLinkConfig1Clients() (clients []*WANEthernetLinkConfig1, erro
if genericClients, errors, err = goupnp.NewServiceClients(URN_WANEthernetLinkConfig_1); err != nil {
return
}
- clients = make([]*WANEthernetLinkConfig1, len(genericClients))
+ clients = newWANEthernetLinkConfig1ClientsFromGenericClients(genericClients)
+ return
+}
+
+// NewWANEthernetLinkConfig1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewWANEthernetLinkConfig1ClientsByURL(loc *url.URL) ([]*WANEthernetLinkConfig1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANEthernetLinkConfig_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANEthernetLinkConfig1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewWANEthernetLinkConfig1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewWANEthernetLinkConfig1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*WANEthernetLinkConfig1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_WANEthernetLinkConfig_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANEthernetLinkConfig1ClientsFromGenericClients(genericClients), nil
+}
+
+func newWANEthernetLinkConfig1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*WANEthernetLinkConfig1 {
+ clients := make([]*WANEthernetLinkConfig1, len(genericClients))
for i := range genericClients {
clients[i] = &WANEthernetLinkConfig1{genericClients[i]}
}
- return
+ return clients
}
//
-//
// Return values:
//
// * NewEthernetLinkStatus: allowed values: Up, Down
@@ -1881,18 +1845,48 @@ func NewWANIPConnection1Clients() (clients []*WANIPConnection1, errors []error,
if genericClients, errors, err = goupnp.NewServiceClients(URN_WANIPConnection_1); err != nil {
return
}
- clients = make([]*WANIPConnection1, len(genericClients))
- for i := range genericClients {
- clients[i] = &WANIPConnection1{genericClients[i]}
- }
+ clients = newWANIPConnection1ClientsFromGenericClients(genericClients)
return
}
-// Arguments:
-//
-// * NewConnectionType:
+// NewWANIPConnection1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewWANIPConnection1ClientsByURL(loc *url.URL) ([]*WANIPConnection1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANIPConnection_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANIPConnection1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewWANIPConnection1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewWANIPConnection1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*WANIPConnection1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_WANIPConnection_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANIPConnection1ClientsFromGenericClients(genericClients), nil
+}
+
+func newWANIPConnection1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*WANIPConnection1 {
+ clients := make([]*WANIPConnection1, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &WANIPConnection1{genericClients[i]}
+ }
+ return clients
+}
+
func (client *WANIPConnection1) SetConnectionType(NewConnectionType string) (err error) {
// Request structure.
request := &struct {
@@ -1920,11 +1914,8 @@ func (client *WANIPConnection1) SetConnectionType(NewConnectionType string) (err
}
//
-//
// Return values:
//
-// * NewConnectionType:
-//
// * NewPossibleConnectionTypes: allowed values: Unconfigured, IP_Routed, IP_Bridged
func (client *WANIPConnection1) GetConnectionTypeInfo() (NewConnectionType string, NewPossibleConnectionTypes string, err error) {
// Request structure.
@@ -1957,9 +1948,6 @@ func (client *WANIPConnection1) GetConnectionTypeInfo() (NewConnectionType strin
return
}
-//
-//
-//
func (client *WANIPConnection1) RequestConnection() (err error) {
// Request structure.
request := interface{}(nil)
@@ -1981,9 +1969,6 @@ func (client *WANIPConnection1) RequestConnection() (err error) {
return
}
-//
-//
-//
func (client *WANIPConnection1) RequestTermination() (err error) {
// Request structure.
request := interface{}(nil)
@@ -2005,9 +1990,6 @@ func (client *WANIPConnection1) RequestTermination() (err error) {
return
}
-//
-//
-//
func (client *WANIPConnection1) ForceTermination() (err error) {
// Request structure.
request := interface{}(nil)
@@ -2029,11 +2011,6 @@ func (client *WANIPConnection1) ForceTermination() (err error) {
return
}
-// Arguments:
-//
-// * NewAutoDisconnectTime:
-//
-//
func (client *WANIPConnection1) SetAutoDisconnectTime(NewAutoDisconnectTime uint32) (err error) {
// Request structure.
request := &struct {
@@ -2060,11 +2037,6 @@ func (client *WANIPConnection1) SetAutoDisconnectTime(NewAutoDisconnectTime uint
return
}
-// Arguments:
-//
-// * NewIdleDisconnectTime:
-//
-//
func (client *WANIPConnection1) SetIdleDisconnectTime(NewIdleDisconnectTime uint32) (err error) {
// Request structure.
request := &struct {
@@ -2091,11 +2063,6 @@ func (client *WANIPConnection1) SetIdleDisconnectTime(NewIdleDisconnectTime uint
return
}
-// Arguments:
-//
-// * NewWarnDisconnectDelay:
-//
-//
func (client *WANIPConnection1) SetWarnDisconnectDelay(NewWarnDisconnectDelay uint32) (err error) {
// Request structure.
request := &struct {
@@ -2123,14 +2090,11 @@ func (client *WANIPConnection1) SetWarnDisconnectDelay(NewWarnDisconnectDelay ui
}
//
-//
// Return values:
//
// * NewConnectionStatus: allowed values: Unconfigured, Connected, Disconnected
//
// * NewLastConnectionError: allowed values: ERROR_NONE
-//
-// * NewUptime:
func (client *WANIPConnection1) GetStatusInfo() (NewConnectionStatus string, NewLastConnectionError string, NewUptime uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -2167,11 +2131,6 @@ func (client *WANIPConnection1) GetStatusInfo() (NewConnectionStatus string, New
return
}
-//
-//
-// Return values:
-//
-// * NewAutoDisconnectTime:
func (client *WANIPConnection1) GetAutoDisconnectTime() (NewAutoDisconnectTime uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -2198,11 +2157,6 @@ func (client *WANIPConnection1) GetAutoDisconnectTime() (NewAutoDisconnectTime u
return
}
-//
-//
-// Return values:
-//
-// * NewIdleDisconnectTime:
func (client *WANIPConnection1) GetIdleDisconnectTime() (NewIdleDisconnectTime uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -2229,11 +2183,6 @@ func (client *WANIPConnection1) GetIdleDisconnectTime() (NewIdleDisconnectTime u
return
}
-//
-//
-// Return values:
-//
-// * NewWarnDisconnectDelay:
func (client *WANIPConnection1) GetWarnDisconnectDelay() (NewWarnDisconnectDelay uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -2260,13 +2209,6 @@ func (client *WANIPConnection1) GetWarnDisconnectDelay() (NewWarnDisconnectDelay
return
}
-//
-//
-// Return values:
-//
-// * NewRSIPAvailable:
-//
-// * NewNATEnabled:
func (client *WANIPConnection1) GetNATRSIPStatus() (NewRSIPAvailable bool, NewNATEnabled bool, err error) {
// Request structure.
request := interface{}(nil)
@@ -2298,27 +2240,10 @@ func (client *WANIPConnection1) GetNATRSIPStatus() (NewRSIPAvailable bool, NewNA
return
}
-// Arguments:
-//
-// * NewPortMappingIndex:
//
// Return values:
//
-// * NewRemoteHost:
-//
-// * NewExternalPort:
-//
// * NewProtocol: allowed values: TCP, UDP
-//
-// * NewInternalPort:
-//
-// * NewInternalClient:
-//
-// * NewEnabled:
-//
-// * NewPortMappingDescription:
-//
-// * NewLeaseDuration:
func (client *WANIPConnection1) GetGenericPortMappingEntry(NewPortMappingIndex uint16) (NewRemoteHost string, NewExternalPort uint16, NewProtocol string, NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32, err error) {
// Request structure.
request := &struct {
@@ -2385,25 +2310,11 @@ func (client *WANIPConnection1) GetGenericPortMappingEntry(NewPortMappingIndex u
return
}
-// Arguments:
-//
-// * NewRemoteHost:
//
-// * NewExternalPort:
+// Arguments:
//
// * NewProtocol: allowed values: TCP, UDP
-//
-// Return values:
-//
-// * NewInternalPort:
-//
-// * NewInternalClient:
-//
-// * NewEnabled:
-//
-// * NewPortMappingDescription:
-//
-// * NewLeaseDuration:
+
func (client *WANIPConnection1) GetSpecificPortMappingEntry(NewRemoteHost string, NewExternalPort uint16, NewProtocol string) (NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32, err error) {
// Request structure.
request := &struct {
@@ -2465,25 +2376,11 @@ func (client *WANIPConnection1) GetSpecificPortMappingEntry(NewRemoteHost string
return
}
-// Arguments:
-//
-// * NewRemoteHost:
//
-// * NewExternalPort:
+// Arguments:
//
// * NewProtocol: allowed values: TCP, UDP
-//
-// * NewInternalPort:
-//
-// * NewInternalClient:
-//
-// * NewEnabled:
-//
-// * NewPortMappingDescription:
-//
-// * NewLeaseDuration:
-//
-//
+
func (client *WANIPConnection1) AddPortMapping(NewRemoteHost string, NewExternalPort uint16, NewProtocol string, NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32) (err error) {
// Request structure.
request := &struct {
@@ -2545,15 +2442,11 @@ func (client *WANIPConnection1) AddPortMapping(NewRemoteHost string, NewExternal
return
}
-// Arguments:
//
-// * NewRemoteHost:
-//
-// * NewExternalPort:
+// Arguments:
//
// * NewProtocol: allowed values: TCP, UDP
-//
-//
+
func (client *WANIPConnection1) DeletePortMapping(NewRemoteHost string, NewExternalPort uint16, NewProtocol string) (err error) {
// Request structure.
request := &struct {
@@ -2590,11 +2483,6 @@ func (client *WANIPConnection1) DeletePortMapping(NewRemoteHost string, NewExter
return
}
-//
-//
-// Return values:
-//
-// * NewExternalIPAddress:
func (client *WANIPConnection1) GetExternalIPAddress() (NewExternalIPAddress string, err error) {
// Request structure.
request := interface{}(nil)
@@ -2639,22 +2527,53 @@ func NewWANPOTSLinkConfig1Clients() (clients []*WANPOTSLinkConfig1, errors []err
if genericClients, errors, err = goupnp.NewServiceClients(URN_WANPOTSLinkConfig_1); err != nil {
return
}
- clients = make([]*WANPOTSLinkConfig1, len(genericClients))
+ clients = newWANPOTSLinkConfig1ClientsFromGenericClients(genericClients)
+ return
+}
+
+// NewWANPOTSLinkConfig1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewWANPOTSLinkConfig1ClientsByURL(loc *url.URL) ([]*WANPOTSLinkConfig1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANPOTSLinkConfig_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANPOTSLinkConfig1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewWANPOTSLinkConfig1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewWANPOTSLinkConfig1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*WANPOTSLinkConfig1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_WANPOTSLinkConfig_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANPOTSLinkConfig1ClientsFromGenericClients(genericClients), nil
+}
+
+func newWANPOTSLinkConfig1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*WANPOTSLinkConfig1 {
+ clients := make([]*WANPOTSLinkConfig1, len(genericClients))
for i := range genericClients {
clients[i] = &WANPOTSLinkConfig1{genericClients[i]}
}
- return
+ return clients
}
-// Arguments:
//
-// * NewISPPhoneNumber:
-//
-// * NewISPInfo:
+// Arguments:
//
// * NewLinkType: allowed values: PPP_Dialup
-//
-//
+
func (client *WANPOTSLinkConfig1) SetISPInfo(NewISPPhoneNumber string, NewISPInfo string, NewLinkType string) (err error) {
// Request structure.
request := &struct {
@@ -2691,13 +2610,6 @@ func (client *WANPOTSLinkConfig1) SetISPInfo(NewISPPhoneNumber string, NewISPInf
return
}
-// Arguments:
-//
-// * NewNumberOfRetries:
-//
-// * NewDelayBetweenRetries:
-//
-//
func (client *WANPOTSLinkConfig1) SetCallRetryInfo(NewNumberOfRetries uint32, NewDelayBetweenRetries uint32) (err error) {
// Request structure.
request := &struct {
@@ -2730,13 +2642,8 @@ func (client *WANPOTSLinkConfig1) SetCallRetryInfo(NewNumberOfRetries uint32, Ne
}
//
-//
// Return values:
//
-// * NewISPPhoneNumber:
-//
-// * NewISPInfo:
-//
// * NewLinkType: allowed values: PPP_Dialup
func (client *WANPOTSLinkConfig1) GetISPInfo() (NewISPPhoneNumber string, NewISPInfo string, NewLinkType string, err error) {
// Request structure.
@@ -2774,13 +2681,6 @@ func (client *WANPOTSLinkConfig1) GetISPInfo() (NewISPPhoneNumber string, NewISP
return
}
-//
-//
-// Return values:
-//
-// * NewNumberOfRetries:
-//
-// * NewDelayBetweenRetries:
func (client *WANPOTSLinkConfig1) GetCallRetryInfo() (NewNumberOfRetries uint32, NewDelayBetweenRetries uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -2812,11 +2712,6 @@ func (client *WANPOTSLinkConfig1) GetCallRetryInfo() (NewNumberOfRetries uint32,
return
}
-//
-//
-// Return values:
-//
-// * NewFclass:
func (client *WANPOTSLinkConfig1) GetFclass() (NewFclass string, err error) {
// Request structure.
request := interface{}(nil)
@@ -2843,11 +2738,6 @@ func (client *WANPOTSLinkConfig1) GetFclass() (NewFclass string, err error) {
return
}
-//
-//
-// Return values:
-//
-// * NewDataModulationSupported:
func (client *WANPOTSLinkConfig1) GetDataModulationSupported() (NewDataModulationSupported string, err error) {
// Request structure.
request := interface{}(nil)
@@ -2874,11 +2764,6 @@ func (client *WANPOTSLinkConfig1) GetDataModulationSupported() (NewDataModulatio
return
}
-//
-//
-// Return values:
-//
-// * NewDataProtocol:
func (client *WANPOTSLinkConfig1) GetDataProtocol() (NewDataProtocol string, err error) {
// Request structure.
request := interface{}(nil)
@@ -2905,11 +2790,6 @@ func (client *WANPOTSLinkConfig1) GetDataProtocol() (NewDataProtocol string, err
return
}
-//
-//
-// Return values:
-//
-// * NewDataCompression:
func (client *WANPOTSLinkConfig1) GetDataCompression() (NewDataCompression string, err error) {
// Request structure.
request := interface{}(nil)
@@ -2936,11 +2816,6 @@ func (client *WANPOTSLinkConfig1) GetDataCompression() (NewDataCompression strin
return
}
-//
-//
-// Return values:
-//
-// * NewPlusVTRCommandSupported:
func (client *WANPOTSLinkConfig1) GetPlusVTRCommandSupported() (NewPlusVTRCommandSupported bool, err error) {
// Request structure.
request := interface{}(nil)
@@ -2985,18 +2860,48 @@ func NewWANPPPConnection1Clients() (clients []*WANPPPConnection1, errors []error
if genericClients, errors, err = goupnp.NewServiceClients(URN_WANPPPConnection_1); err != nil {
return
}
- clients = make([]*WANPPPConnection1, len(genericClients))
- for i := range genericClients {
- clients[i] = &WANPPPConnection1{genericClients[i]}
- }
+ clients = newWANPPPConnection1ClientsFromGenericClients(genericClients)
return
}
-// Arguments:
-//
-// * NewConnectionType:
+// NewWANPPPConnection1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewWANPPPConnection1ClientsByURL(loc *url.URL) ([]*WANPPPConnection1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANPPPConnection_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANPPPConnection1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewWANPPPConnection1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewWANPPPConnection1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*WANPPPConnection1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_WANPPPConnection_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANPPPConnection1ClientsFromGenericClients(genericClients), nil
+}
+
+func newWANPPPConnection1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*WANPPPConnection1 {
+ clients := make([]*WANPPPConnection1, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &WANPPPConnection1{genericClients[i]}
+ }
+ return clients
+}
+
func (client *WANPPPConnection1) SetConnectionType(NewConnectionType string) (err error) {
// Request structure.
request := &struct {
@@ -3024,11 +2929,8 @@ func (client *WANPPPConnection1) SetConnectionType(NewConnectionType string) (er
}
//
-//
// Return values:
//
-// * NewConnectionType:
-//
// * NewPossibleConnectionTypes: allowed values: Unconfigured, IP_Routed, DHCP_Spoofed, PPPoE_Bridged, PPTP_Relay, L2TP_Relay, PPPoE_Relay
func (client *WANPPPConnection1) GetConnectionTypeInfo() (NewConnectionType string, NewPossibleConnectionTypes string, err error) {
// Request structure.
@@ -3061,13 +2963,6 @@ func (client *WANPPPConnection1) GetConnectionTypeInfo() (NewConnectionType stri
return
}
-// Arguments:
-//
-// * NewUserName:
-//
-// * NewPassword:
-//
-//
func (client *WANPPPConnection1) ConfigureConnection(NewUserName string, NewPassword string) (err error) {
// Request structure.
request := &struct {
@@ -3099,9 +2994,6 @@ func (client *WANPPPConnection1) ConfigureConnection(NewUserName string, NewPass
return
}
-//
-//
-//
func (client *WANPPPConnection1) RequestConnection() (err error) {
// Request structure.
request := interface{}(nil)
@@ -3123,9 +3015,6 @@ func (client *WANPPPConnection1) RequestConnection() (err error) {
return
}
-//
-//
-//
func (client *WANPPPConnection1) RequestTermination() (err error) {
// Request structure.
request := interface{}(nil)
@@ -3147,9 +3036,6 @@ func (client *WANPPPConnection1) RequestTermination() (err error) {
return
}
-//
-//
-//
func (client *WANPPPConnection1) ForceTermination() (err error) {
// Request structure.
request := interface{}(nil)
@@ -3171,11 +3057,6 @@ func (client *WANPPPConnection1) ForceTermination() (err error) {
return
}
-// Arguments:
-//
-// * NewAutoDisconnectTime:
-//
-//
func (client *WANPPPConnection1) SetAutoDisconnectTime(NewAutoDisconnectTime uint32) (err error) {
// Request structure.
request := &struct {
@@ -3202,11 +3083,6 @@ func (client *WANPPPConnection1) SetAutoDisconnectTime(NewAutoDisconnectTime uin
return
}
-// Arguments:
-//
-// * NewIdleDisconnectTime:
-//
-//
func (client *WANPPPConnection1) SetIdleDisconnectTime(NewIdleDisconnectTime uint32) (err error) {
// Request structure.
request := &struct {
@@ -3233,11 +3109,6 @@ func (client *WANPPPConnection1) SetIdleDisconnectTime(NewIdleDisconnectTime uin
return
}
-// Arguments:
-//
-// * NewWarnDisconnectDelay:
-//
-//
func (client *WANPPPConnection1) SetWarnDisconnectDelay(NewWarnDisconnectDelay uint32) (err error) {
// Request structure.
request := &struct {
@@ -3265,14 +3136,11 @@ func (client *WANPPPConnection1) SetWarnDisconnectDelay(NewWarnDisconnectDelay u
}
//
-//
// Return values:
//
// * NewConnectionStatus: allowed values: Unconfigured, Connected, Disconnected
//
// * NewLastConnectionError: allowed values: ERROR_NONE
-//
-// * NewUptime:
func (client *WANPPPConnection1) GetStatusInfo() (NewConnectionStatus string, NewLastConnectionError string, NewUptime uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -3309,13 +3177,6 @@ func (client *WANPPPConnection1) GetStatusInfo() (NewConnectionStatus string, Ne
return
}
-//
-//
-// Return values:
-//
-// * NewUpstreamMaxBitRate:
-//
-// * NewDownstreamMaxBitRate:
func (client *WANPPPConnection1) GetLinkLayerMaxBitRates() (NewUpstreamMaxBitRate uint32, NewDownstreamMaxBitRate uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -3347,11 +3208,6 @@ func (client *WANPPPConnection1) GetLinkLayerMaxBitRates() (NewUpstreamMaxBitRat
return
}
-//
-//
-// Return values:
-//
-// * NewPPPEncryptionProtocol:
func (client *WANPPPConnection1) GetPPPEncryptionProtocol() (NewPPPEncryptionProtocol string, err error) {
// Request structure.
request := interface{}(nil)
@@ -3378,11 +3234,6 @@ func (client *WANPPPConnection1) GetPPPEncryptionProtocol() (NewPPPEncryptionPro
return
}
-//
-//
-// Return values:
-//
-// * NewPPPCompressionProtocol:
func (client *WANPPPConnection1) GetPPPCompressionProtocol() (NewPPPCompressionProtocol string, err error) {
// Request structure.
request := interface{}(nil)
@@ -3409,11 +3260,6 @@ func (client *WANPPPConnection1) GetPPPCompressionProtocol() (NewPPPCompressionP
return
}
-//
-//
-// Return values:
-//
-// * NewPPPAuthenticationProtocol:
func (client *WANPPPConnection1) GetPPPAuthenticationProtocol() (NewPPPAuthenticationProtocol string, err error) {
// Request structure.
request := interface{}(nil)
@@ -3440,11 +3286,6 @@ func (client *WANPPPConnection1) GetPPPAuthenticationProtocol() (NewPPPAuthentic
return
}
-//
-//
-// Return values:
-//
-// * NewUserName:
func (client *WANPPPConnection1) GetUserName() (NewUserName string, err error) {
// Request structure.
request := interface{}(nil)
@@ -3471,11 +3312,6 @@ func (client *WANPPPConnection1) GetUserName() (NewUserName string, err error) {
return
}
-//
-//
-// Return values:
-//
-// * NewPassword:
func (client *WANPPPConnection1) GetPassword() (NewPassword string, err error) {
// Request structure.
request := interface{}(nil)
@@ -3502,11 +3338,6 @@ func (client *WANPPPConnection1) GetPassword() (NewPassword string, err error) {
return
}
-//
-//
-// Return values:
-//
-// * NewAutoDisconnectTime:
func (client *WANPPPConnection1) GetAutoDisconnectTime() (NewAutoDisconnectTime uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -3533,11 +3364,6 @@ func (client *WANPPPConnection1) GetAutoDisconnectTime() (NewAutoDisconnectTime
return
}
-//
-//
-// Return values:
-//
-// * NewIdleDisconnectTime:
func (client *WANPPPConnection1) GetIdleDisconnectTime() (NewIdleDisconnectTime uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -3564,11 +3390,6 @@ func (client *WANPPPConnection1) GetIdleDisconnectTime() (NewIdleDisconnectTime
return
}
-//
-//
-// Return values:
-//
-// * NewWarnDisconnectDelay:
func (client *WANPPPConnection1) GetWarnDisconnectDelay() (NewWarnDisconnectDelay uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -3595,13 +3416,6 @@ func (client *WANPPPConnection1) GetWarnDisconnectDelay() (NewWarnDisconnectDela
return
}
-//
-//
-// Return values:
-//
-// * NewRSIPAvailable:
-//
-// * NewNATEnabled:
func (client *WANPPPConnection1) GetNATRSIPStatus() (NewRSIPAvailable bool, NewNATEnabled bool, err error) {
// Request structure.
request := interface{}(nil)
@@ -3633,27 +3447,10 @@ func (client *WANPPPConnection1) GetNATRSIPStatus() (NewRSIPAvailable bool, NewN
return
}
-// Arguments:
-//
-// * NewPortMappingIndex:
//
// Return values:
//
-// * NewRemoteHost:
-//
-// * NewExternalPort:
-//
// * NewProtocol: allowed values: TCP, UDP
-//
-// * NewInternalPort:
-//
-// * NewInternalClient:
-//
-// * NewEnabled:
-//
-// * NewPortMappingDescription:
-//
-// * NewLeaseDuration:
func (client *WANPPPConnection1) GetGenericPortMappingEntry(NewPortMappingIndex uint16) (NewRemoteHost string, NewExternalPort uint16, NewProtocol string, NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32, err error) {
// Request structure.
request := &struct {
@@ -3720,25 +3517,11 @@ func (client *WANPPPConnection1) GetGenericPortMappingEntry(NewPortMappingIndex
return
}
-// Arguments:
//
-// * NewRemoteHost:
-//
-// * NewExternalPort:
+// Arguments:
//
// * NewProtocol: allowed values: TCP, UDP
-//
-// Return values:
-//
-// * NewInternalPort:
-//
-// * NewInternalClient:
-//
-// * NewEnabled:
-//
-// * NewPortMappingDescription:
-//
-// * NewLeaseDuration:
+
func (client *WANPPPConnection1) GetSpecificPortMappingEntry(NewRemoteHost string, NewExternalPort uint16, NewProtocol string) (NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32, err error) {
// Request structure.
request := &struct {
@@ -3800,25 +3583,11 @@ func (client *WANPPPConnection1) GetSpecificPortMappingEntry(NewRemoteHost strin
return
}
-// Arguments:
-//
-// * NewRemoteHost:
//
-// * NewExternalPort:
+// Arguments:
//
// * NewProtocol: allowed values: TCP, UDP
-//
-// * NewInternalPort:
-//
-// * NewInternalClient:
-//
-// * NewEnabled:
-//
-// * NewPortMappingDescription:
-//
-// * NewLeaseDuration:
-//
-//
+
func (client *WANPPPConnection1) AddPortMapping(NewRemoteHost string, NewExternalPort uint16, NewProtocol string, NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32) (err error) {
// Request structure.
request := &struct {
@@ -3880,15 +3649,11 @@ func (client *WANPPPConnection1) AddPortMapping(NewRemoteHost string, NewExterna
return
}
-// Arguments:
-//
-// * NewRemoteHost:
//
-// * NewExternalPort:
+// Arguments:
//
// * NewProtocol: allowed values: TCP, UDP
-//
-//
+
func (client *WANPPPConnection1) DeletePortMapping(NewRemoteHost string, NewExternalPort uint16, NewProtocol string) (err error) {
// Request structure.
request := &struct {
@@ -3925,11 +3690,6 @@ func (client *WANPPPConnection1) DeletePortMapping(NewRemoteHost string, NewExte
return
}
-//
-//
-// Return values:
-//
-// * NewExternalIPAddress:
func (client *WANPPPConnection1) GetExternalIPAddress() (NewExternalIPAddress string, err error) {
// Request structure.
request := interface{}(nil)
diff --git a/Godeps/_workspace/src/github.com/huin/goupnp/dcps/internetgateway2/internetgateway2.go b/Godeps/_workspace/src/github.com/huin/goupnp/dcps/internetgateway2/internetgateway2.go
index a5892288e..2d67a4a2e 100644
--- a/Godeps/_workspace/src/github.com/huin/goupnp/dcps/internetgateway2/internetgateway2.go
+++ b/Godeps/_workspace/src/github.com/huin/goupnp/dcps/internetgateway2/internetgateway2.go
@@ -2,13 +2,13 @@
//
// This DCP is documented in detail at: http://upnp.org/specs/gw/UPnP-gw-InternetGatewayDevice-v2-Device.pdf
//
-// Typically, use one of the New* functions to discover services on the local
-// network.
+// Typically, use one of the New* functions to create clients for services.
package internetgateway2
// Generated file - do not edit by hand. See README.md
import (
+ "net/url"
"time"
"github.com/huin/goupnp"
@@ -29,6 +29,7 @@ const (
// Service URNs:
const (
+ URN_DeviceProtection_1 = "urn:schemas-upnp-org:service:DeviceProtection:1"
URN_LANHostConfigManagement_1 = "urn:schemas-upnp-org:service:LANHostConfigManagement:1"
URN_Layer3Forwarding_1 = "urn:schemas-upnp-org:service:Layer3Forwarding:1"
URN_WANCableLinkConfig_1 = "urn:schemas-upnp-org:service:WANCableLinkConfig:1"
@@ -42,6 +43,484 @@ const (
URN_WANPPPConnection_1 = "urn:schemas-upnp-org:service:WANPPPConnection:1"
)
+// DeviceProtection1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:DeviceProtection:1". See
+// goupnp.ServiceClient, which contains RootDevice and Service attributes which
+// are provided for informational value.
+type DeviceProtection1 struct {
+ goupnp.ServiceClient
+}
+
+// NewDeviceProtection1Clients discovers instances of the service on the network,
+// and returns clients to any that are found. errors will contain an error for
+// any devices that replied but which could not be queried, and err will be set
+// if the discovery process failed outright.
+//
+// This is a typical entry calling point into this package.
+func NewDeviceProtection1Clients() (clients []*DeviceProtection1, errors []error, err error) {
+ var genericClients []goupnp.ServiceClient
+ if genericClients, errors, err = goupnp.NewServiceClients(URN_DeviceProtection_1); err != nil {
+ return
+ }
+ clients = newDeviceProtection1ClientsFromGenericClients(genericClients)
+ return
+}
+
+// NewDeviceProtection1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewDeviceProtection1ClientsByURL(loc *url.URL) ([]*DeviceProtection1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_DeviceProtection_1)
+ if err != nil {
+ return nil, err
+ }
+ return newDeviceProtection1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewDeviceProtection1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewDeviceProtection1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*DeviceProtection1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_DeviceProtection_1)
+ if err != nil {
+ return nil, err
+ }
+ return newDeviceProtection1ClientsFromGenericClients(genericClients), nil
+}
+
+func newDeviceProtection1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*DeviceProtection1 {
+ clients := make([]*DeviceProtection1, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &DeviceProtection1{genericClients[i]}
+ }
+ return clients
+}
+
+func (client *DeviceProtection1) SendSetupMessage(ProtocolType string, InMessage []byte) (OutMessage []byte, err error) {
+ // Request structure.
+ request := &struct {
+ ProtocolType string
+
+ InMessage string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ProtocolType, err = soap.MarshalString(ProtocolType); err != nil {
+ return
+ }
+ if request.InMessage, err = soap.MarshalBinBase64(InMessage); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ OutMessage string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_DeviceProtection_1, "SendSetupMessage", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if OutMessage, err = soap.UnmarshalBinBase64(response.OutMessage); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *DeviceProtection1) GetSupportedProtocols() (ProtocolList string, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ ProtocolList string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_DeviceProtection_1, "GetSupportedProtocols", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if ProtocolList, err = soap.UnmarshalString(response.ProtocolList); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *DeviceProtection1) GetAssignedRoles() (RoleList string, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ RoleList string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_DeviceProtection_1, "GetAssignedRoles", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if RoleList, err = soap.UnmarshalString(response.RoleList); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *DeviceProtection1) GetRolesForAction(DeviceUDN string, ServiceId string, ActionName string) (RoleList string, RestrictedRoleList string, err error) {
+ // Request structure.
+ request := &struct {
+ DeviceUDN string
+
+ ServiceId string
+
+ ActionName string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.DeviceUDN, err = soap.MarshalString(DeviceUDN); err != nil {
+ return
+ }
+ if request.ServiceId, err = soap.MarshalString(ServiceId); err != nil {
+ return
+ }
+ if request.ActionName, err = soap.MarshalString(ActionName); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ RoleList string
+
+ RestrictedRoleList string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_DeviceProtection_1, "GetRolesForAction", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if RoleList, err = soap.UnmarshalString(response.RoleList); err != nil {
+ return
+ }
+ if RestrictedRoleList, err = soap.UnmarshalString(response.RestrictedRoleList); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *DeviceProtection1) GetUserLoginChallenge(ProtocolType string, Name string) (Salt []byte, Challenge []byte, err error) {
+ // Request structure.
+ request := &struct {
+ ProtocolType string
+
+ Name string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ProtocolType, err = soap.MarshalString(ProtocolType); err != nil {
+ return
+ }
+ if request.Name, err = soap.MarshalString(Name); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ Salt string
+
+ Challenge string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_DeviceProtection_1, "GetUserLoginChallenge", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if Salt, err = soap.UnmarshalBinBase64(response.Salt); err != nil {
+ return
+ }
+ if Challenge, err = soap.UnmarshalBinBase64(response.Challenge); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *DeviceProtection1) UserLogin(ProtocolType string, Challenge []byte, Authenticator []byte) (err error) {
+ // Request structure.
+ request := &struct {
+ ProtocolType string
+
+ Challenge string
+
+ Authenticator string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ProtocolType, err = soap.MarshalString(ProtocolType); err != nil {
+ return
+ }
+ if request.Challenge, err = soap.MarshalBinBase64(Challenge); err != nil {
+ return
+ }
+ if request.Authenticator, err = soap.MarshalBinBase64(Authenticator); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_DeviceProtection_1, "UserLogin", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *DeviceProtection1) UserLogout() (err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_DeviceProtection_1, "UserLogout", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *DeviceProtection1) GetACLData() (ACL string, err error) {
+ // Request structure.
+ request := interface{}(nil)
+ // BEGIN Marshal arguments into request.
+
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ ACL string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_DeviceProtection_1, "GetACLData", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if ACL, err = soap.UnmarshalString(response.ACL); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *DeviceProtection1) AddIdentityList(IdentityList string) (IdentityListResult string, err error) {
+ // Request structure.
+ request := &struct {
+ IdentityList string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.IdentityList, err = soap.MarshalString(IdentityList); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := &struct {
+ IdentityListResult string
+ }{}
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_DeviceProtection_1, "AddIdentityList", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ if IdentityListResult, err = soap.UnmarshalString(response.IdentityListResult); err != nil {
+ return
+ }
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *DeviceProtection1) RemoveIdentity(Identity string) (err error) {
+ // Request structure.
+ request := &struct {
+ Identity string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.Identity, err = soap.MarshalString(Identity); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_DeviceProtection_1, "RemoveIdentity", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *DeviceProtection1) SetUserLoginPassword(ProtocolType string, Name string, Stored []byte, Salt []byte) (err error) {
+ // Request structure.
+ request := &struct {
+ ProtocolType string
+
+ Name string
+
+ Stored string
+
+ Salt string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.ProtocolType, err = soap.MarshalString(ProtocolType); err != nil {
+ return
+ }
+ if request.Name, err = soap.MarshalString(Name); err != nil {
+ return
+ }
+ if request.Stored, err = soap.MarshalBinBase64(Stored); err != nil {
+ return
+ }
+ if request.Salt, err = soap.MarshalBinBase64(Salt); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_DeviceProtection_1, "SetUserLoginPassword", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *DeviceProtection1) AddRolesForIdentity(Identity string, RoleList string) (err error) {
+ // Request structure.
+ request := &struct {
+ Identity string
+
+ RoleList string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.Identity, err = soap.MarshalString(Identity); err != nil {
+ return
+ }
+ if request.RoleList, err = soap.MarshalString(RoleList); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_DeviceProtection_1, "AddRolesForIdentity", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
+func (client *DeviceProtection1) RemoveRolesForIdentity(Identity string, RoleList string) (err error) {
+ // Request structure.
+ request := &struct {
+ Identity string
+
+ RoleList string
+ }{}
+ // BEGIN Marshal arguments into request.
+
+ if request.Identity, err = soap.MarshalString(Identity); err != nil {
+ return
+ }
+ if request.RoleList, err = soap.MarshalString(RoleList); err != nil {
+ return
+ }
+ // END Marshal arguments into request.
+
+ // Response structure.
+ response := interface{}(nil)
+
+ // Perform the SOAP call.
+ if err = client.SOAPClient.PerformAction(URN_DeviceProtection_1, "RemoveRolesForIdentity", request, response); err != nil {
+ return
+ }
+
+ // BEGIN Unmarshal arguments from response.
+
+ // END Unmarshal arguments from response.
+ return
+}
+
// LANHostConfigManagement1 is a client for UPnP SOAP service with URN "urn:schemas-upnp-org:service:LANHostConfigManagement:1". See
// goupnp.ServiceClient, which contains RootDevice and Service attributes which
// are provided for informational value.
@@ -60,18 +539,48 @@ func NewLANHostConfigManagement1Clients() (clients []*LANHostConfigManagement1,
if genericClients, errors, err = goupnp.NewServiceClients(URN_LANHostConfigManagement_1); err != nil {
return
}
- clients = make([]*LANHostConfigManagement1, len(genericClients))
- for i := range genericClients {
- clients[i] = &LANHostConfigManagement1{genericClients[i]}
- }
+ clients = newLANHostConfigManagement1ClientsFromGenericClients(genericClients)
return
}
-// Arguments:
-//
-// * NewDHCPServerConfigurable:
+// NewLANHostConfigManagement1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewLANHostConfigManagement1ClientsByURL(loc *url.URL) ([]*LANHostConfigManagement1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_LANHostConfigManagement_1)
+ if err != nil {
+ return nil, err
+ }
+ return newLANHostConfigManagement1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewLANHostConfigManagement1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewLANHostConfigManagement1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*LANHostConfigManagement1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_LANHostConfigManagement_1)
+ if err != nil {
+ return nil, err
+ }
+ return newLANHostConfigManagement1ClientsFromGenericClients(genericClients), nil
+}
+
+func newLANHostConfigManagement1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*LANHostConfigManagement1 {
+ clients := make([]*LANHostConfigManagement1, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &LANHostConfigManagement1{genericClients[i]}
+ }
+ return clients
+}
+
func (client *LANHostConfigManagement1) SetDHCPServerConfigurable(NewDHCPServerConfigurable bool) (err error) {
// Request structure.
request := &struct {
@@ -98,11 +607,6 @@ func (client *LANHostConfigManagement1) SetDHCPServerConfigurable(NewDHCPServerC
return
}
-//
-//
-// Return values:
-//
-// * NewDHCPServerConfigurable:
func (client *LANHostConfigManagement1) GetDHCPServerConfigurable() (NewDHCPServerConfigurable bool, err error) {
// Request structure.
request := interface{}(nil)
@@ -129,11 +633,6 @@ func (client *LANHostConfigManagement1) GetDHCPServerConfigurable() (NewDHCPServ
return
}
-// Arguments:
-//
-// * NewDHCPRelay:
-//
-//
func (client *LANHostConfigManagement1) SetDHCPRelay(NewDHCPRelay bool) (err error) {
// Request structure.
request := &struct {
@@ -160,11 +659,6 @@ func (client *LANHostConfigManagement1) SetDHCPRelay(NewDHCPRelay bool) (err err
return
}
-//
-//
-// Return values:
-//
-// * NewDHCPRelay:
func (client *LANHostConfigManagement1) GetDHCPRelay() (NewDHCPRelay bool, err error) {
// Request structure.
request := interface{}(nil)
@@ -191,11 +685,6 @@ func (client *LANHostConfigManagement1) GetDHCPRelay() (NewDHCPRelay bool, err e
return
}
-// Arguments:
-//
-// * NewSubnetMask:
-//
-//
func (client *LANHostConfigManagement1) SetSubnetMask(NewSubnetMask string) (err error) {
// Request structure.
request := &struct {
@@ -222,11 +711,6 @@ func (client *LANHostConfigManagement1) SetSubnetMask(NewSubnetMask string) (err
return
}
-//
-//
-// Return values:
-//
-// * NewSubnetMask:
func (client *LANHostConfigManagement1) GetSubnetMask() (NewSubnetMask string, err error) {
// Request structure.
request := interface{}(nil)
@@ -253,11 +737,6 @@ func (client *LANHostConfigManagement1) GetSubnetMask() (NewSubnetMask string, e
return
}
-// Arguments:
-//
-// * NewIPRouters:
-//
-//
func (client *LANHostConfigManagement1) SetIPRouter(NewIPRouters string) (err error) {
// Request structure.
request := &struct {
@@ -284,11 +763,6 @@ func (client *LANHostConfigManagement1) SetIPRouter(NewIPRouters string) (err er
return
}
-// Arguments:
-//
-// * NewIPRouters:
-//
-//
func (client *LANHostConfigManagement1) DeleteIPRouter(NewIPRouters string) (err error) {
// Request structure.
request := &struct {
@@ -315,11 +789,6 @@ func (client *LANHostConfigManagement1) DeleteIPRouter(NewIPRouters string) (err
return
}
-//
-//
-// Return values:
-//
-// * NewIPRouters:
func (client *LANHostConfigManagement1) GetIPRoutersList() (NewIPRouters string, err error) {
// Request structure.
request := interface{}(nil)
@@ -346,11 +815,6 @@ func (client *LANHostConfigManagement1) GetIPRoutersList() (NewIPRouters string,
return
}
-// Arguments:
-//
-// * NewDomainName:
-//
-//
func (client *LANHostConfigManagement1) SetDomainName(NewDomainName string) (err error) {
// Request structure.
request := &struct {
@@ -377,11 +841,6 @@ func (client *LANHostConfigManagement1) SetDomainName(NewDomainName string) (err
return
}
-//
-//
-// Return values:
-//
-// * NewDomainName:
func (client *LANHostConfigManagement1) GetDomainName() (NewDomainName string, err error) {
// Request structure.
request := interface{}(nil)
@@ -408,13 +867,6 @@ func (client *LANHostConfigManagement1) GetDomainName() (NewDomainName string, e
return
}
-// Arguments:
-//
-// * NewMinAddress:
-//
-// * NewMaxAddress:
-//
-//
func (client *LANHostConfigManagement1) SetAddressRange(NewMinAddress string, NewMaxAddress string) (err error) {
// Request structure.
request := &struct {
@@ -446,13 +898,6 @@ func (client *LANHostConfigManagement1) SetAddressRange(NewMinAddress string, Ne
return
}
-//
-//
-// Return values:
-//
-// * NewMinAddress:
-//
-// * NewMaxAddress:
func (client *LANHostConfigManagement1) GetAddressRange() (NewMinAddress string, NewMaxAddress string, err error) {
// Request structure.
request := interface{}(nil)
@@ -484,11 +929,6 @@ func (client *LANHostConfigManagement1) GetAddressRange() (NewMinAddress string,
return
}
-// Arguments:
-//
-// * NewReservedAddresses:
-//
-//
func (client *LANHostConfigManagement1) SetReservedAddress(NewReservedAddresses string) (err error) {
// Request structure.
request := &struct {
@@ -515,11 +955,6 @@ func (client *LANHostConfigManagement1) SetReservedAddress(NewReservedAddresses
return
}
-// Arguments:
-//
-// * NewReservedAddresses:
-//
-//
func (client *LANHostConfigManagement1) DeleteReservedAddress(NewReservedAddresses string) (err error) {
// Request structure.
request := &struct {
@@ -546,11 +981,6 @@ func (client *LANHostConfigManagement1) DeleteReservedAddress(NewReservedAddress
return
}
-//
-//
-// Return values:
-//
-// * NewReservedAddresses:
func (client *LANHostConfigManagement1) GetReservedAddresses() (NewReservedAddresses string, err error) {
// Request structure.
request := interface{}(nil)
@@ -577,11 +1007,6 @@ func (client *LANHostConfigManagement1) GetReservedAddresses() (NewReservedAddre
return
}
-// Arguments:
-//
-// * NewDNSServers:
-//
-//
func (client *LANHostConfigManagement1) SetDNSServer(NewDNSServers string) (err error) {
// Request structure.
request := &struct {
@@ -608,11 +1033,6 @@ func (client *LANHostConfigManagement1) SetDNSServer(NewDNSServers string) (err
return
}
-// Arguments:
-//
-// * NewDNSServers:
-//
-//
func (client *LANHostConfigManagement1) DeleteDNSServer(NewDNSServers string) (err error) {
// Request structure.
request := &struct {
@@ -639,11 +1059,6 @@ func (client *LANHostConfigManagement1) DeleteDNSServer(NewDNSServers string) (e
return
}
-//
-//
-// Return values:
-//
-// * NewDNSServers:
func (client *LANHostConfigManagement1) GetDNSServers() (NewDNSServers string, err error) {
// Request structure.
request := interface{}(nil)
@@ -688,18 +1103,48 @@ func NewLayer3Forwarding1Clients() (clients []*Layer3Forwarding1, errors []error
if genericClients, errors, err = goupnp.NewServiceClients(URN_Layer3Forwarding_1); err != nil {
return
}
- clients = make([]*Layer3Forwarding1, len(genericClients))
- for i := range genericClients {
- clients[i] = &Layer3Forwarding1{genericClients[i]}
- }
+ clients = newLayer3Forwarding1ClientsFromGenericClients(genericClients)
return
}
-// Arguments:
-//
-// * NewDefaultConnectionService:
+// NewLayer3Forwarding1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewLayer3Forwarding1ClientsByURL(loc *url.URL) ([]*Layer3Forwarding1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_Layer3Forwarding_1)
+ if err != nil {
+ return nil, err
+ }
+ return newLayer3Forwarding1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewLayer3Forwarding1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewLayer3Forwarding1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*Layer3Forwarding1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_Layer3Forwarding_1)
+ if err != nil {
+ return nil, err
+ }
+ return newLayer3Forwarding1ClientsFromGenericClients(genericClients), nil
+}
+
+func newLayer3Forwarding1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*Layer3Forwarding1 {
+ clients := make([]*Layer3Forwarding1, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &Layer3Forwarding1{genericClients[i]}
+ }
+ return clients
+}
+
func (client *Layer3Forwarding1) SetDefaultConnectionService(NewDefaultConnectionService string) (err error) {
// Request structure.
request := &struct {
@@ -726,11 +1171,6 @@ func (client *Layer3Forwarding1) SetDefaultConnectionService(NewDefaultConnectio
return
}
-//
-//
-// Return values:
-//
-// * NewDefaultConnectionService:
func (client *Layer3Forwarding1) GetDefaultConnectionService() (NewDefaultConnectionService string, err error) {
// Request structure.
request := interface{}(nil)
@@ -775,15 +1215,49 @@ func NewWANCableLinkConfig1Clients() (clients []*WANCableLinkConfig1, errors []e
if genericClients, errors, err = goupnp.NewServiceClients(URN_WANCableLinkConfig_1); err != nil {
return
}
- clients = make([]*WANCableLinkConfig1, len(genericClients))
+ clients = newWANCableLinkConfig1ClientsFromGenericClients(genericClients)
+ return
+}
+
+// NewWANCableLinkConfig1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewWANCableLinkConfig1ClientsByURL(loc *url.URL) ([]*WANCableLinkConfig1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANCableLinkConfig_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANCableLinkConfig1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewWANCableLinkConfig1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewWANCableLinkConfig1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*WANCableLinkConfig1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_WANCableLinkConfig_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANCableLinkConfig1ClientsFromGenericClients(genericClients), nil
+}
+
+func newWANCableLinkConfig1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*WANCableLinkConfig1 {
+ clients := make([]*WANCableLinkConfig1, len(genericClients))
for i := range genericClients {
clients[i] = &WANCableLinkConfig1{genericClients[i]}
}
- return
+ return clients
}
//
-//
// Return values:
//
// * NewCableLinkConfigState: allowed values: notReady, dsSyncComplete, usParamAcquired, rangingComplete, ipComplete, todEstablished, paramTransferComplete, registrationComplete, operational, accessDenied
@@ -820,11 +1294,6 @@ func (client *WANCableLinkConfig1) GetCableLinkConfigInfo() (NewCableLinkConfigS
return
}
-//
-//
-// Return values:
-//
-// * NewDownstreamFrequency:
func (client *WANCableLinkConfig1) GetDownstreamFrequency() (NewDownstreamFrequency uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -852,7 +1321,6 @@ func (client *WANCableLinkConfig1) GetDownstreamFrequency() (NewDownstreamFreque
}
//
-//
// Return values:
//
// * NewDownstreamModulation: allowed values: 64QAM, 256QAM
@@ -882,11 +1350,6 @@ func (client *WANCableLinkConfig1) GetDownstreamModulation() (NewDownstreamModul
return
}
-//
-//
-// Return values:
-//
-// * NewUpstreamFrequency:
func (client *WANCableLinkConfig1) GetUpstreamFrequency() (NewUpstreamFrequency uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -914,7 +1377,6 @@ func (client *WANCableLinkConfig1) GetUpstreamFrequency() (NewUpstreamFrequency
}
//
-//
// Return values:
//
// * NewUpstreamModulation: allowed values: QPSK, 16QAM
@@ -944,11 +1406,6 @@ func (client *WANCableLinkConfig1) GetUpstreamModulation() (NewUpstreamModulatio
return
}
-//
-//
-// Return values:
-//
-// * NewUpstreamChannelID:
func (client *WANCableLinkConfig1) GetUpstreamChannelID() (NewUpstreamChannelID uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -975,11 +1432,6 @@ func (client *WANCableLinkConfig1) GetUpstreamChannelID() (NewUpstreamChannelID
return
}
-//
-//
-// Return values:
-//
-// * NewUpstreamPowerLevel:
func (client *WANCableLinkConfig1) GetUpstreamPowerLevel() (NewUpstreamPowerLevel uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -1006,11 +1458,6 @@ func (client *WANCableLinkConfig1) GetUpstreamPowerLevel() (NewUpstreamPowerLeve
return
}
-//
-//
-// Return values:
-//
-// * NewBPIEncryptionEnabled:
func (client *WANCableLinkConfig1) GetBPIEncryptionEnabled() (NewBPIEncryptionEnabled bool, err error) {
// Request structure.
request := interface{}(nil)
@@ -1037,11 +1484,6 @@ func (client *WANCableLinkConfig1) GetBPIEncryptionEnabled() (NewBPIEncryptionEn
return
}
-//
-//
-// Return values:
-//
-// * NewConfigFile:
func (client *WANCableLinkConfig1) GetConfigFile() (NewConfigFile string, err error) {
// Request structure.
request := interface{}(nil)
@@ -1068,11 +1510,6 @@ func (client *WANCableLinkConfig1) GetConfigFile() (NewConfigFile string, err er
return
}
-//
-//
-// Return values:
-//
-// * NewTFTPServer:
func (client *WANCableLinkConfig1) GetTFTPServer() (NewTFTPServer string, err error) {
// Request structure.
request := interface{}(nil)
@@ -1117,18 +1554,48 @@ func NewWANCommonInterfaceConfig1Clients() (clients []*WANCommonInterfaceConfig1
if genericClients, errors, err = goupnp.NewServiceClients(URN_WANCommonInterfaceConfig_1); err != nil {
return
}
- clients = make([]*WANCommonInterfaceConfig1, len(genericClients))
- for i := range genericClients {
- clients[i] = &WANCommonInterfaceConfig1{genericClients[i]}
- }
+ clients = newWANCommonInterfaceConfig1ClientsFromGenericClients(genericClients)
return
}
-// Arguments:
-//
-// * NewEnabledForInternet:
+// NewWANCommonInterfaceConfig1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewWANCommonInterfaceConfig1ClientsByURL(loc *url.URL) ([]*WANCommonInterfaceConfig1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANCommonInterfaceConfig_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANCommonInterfaceConfig1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewWANCommonInterfaceConfig1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewWANCommonInterfaceConfig1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*WANCommonInterfaceConfig1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_WANCommonInterfaceConfig_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANCommonInterfaceConfig1ClientsFromGenericClients(genericClients), nil
+}
+
+func newWANCommonInterfaceConfig1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*WANCommonInterfaceConfig1 {
+ clients := make([]*WANCommonInterfaceConfig1, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &WANCommonInterfaceConfig1{genericClients[i]}
+ }
+ return clients
+}
+
func (client *WANCommonInterfaceConfig1) SetEnabledForInternet(NewEnabledForInternet bool) (err error) {
// Request structure.
request := &struct {
@@ -1155,11 +1622,6 @@ func (client *WANCommonInterfaceConfig1) SetEnabledForInternet(NewEnabledForInte
return
}
-//
-//
-// Return values:
-//
-// * NewEnabledForInternet:
func (client *WANCommonInterfaceConfig1) GetEnabledForInternet() (NewEnabledForInternet bool, err error) {
// Request structure.
request := interface{}(nil)
@@ -1187,15 +1649,10 @@ func (client *WANCommonInterfaceConfig1) GetEnabledForInternet() (NewEnabledForI
}
//
-//
// Return values:
//
// * NewWANAccessType: allowed values: DSL, POTS, Cable, Ethernet
//
-// * NewLayer1UpstreamMaxBitRate:
-//
-// * NewLayer1DownstreamMaxBitRate:
-//
// * NewPhysicalLinkStatus: allowed values: Up, Down
func (client *WANCommonInterfaceConfig1) GetCommonLinkProperties() (NewWANAccessType string, NewLayer1UpstreamMaxBitRate uint32, NewLayer1DownstreamMaxBitRate uint32, NewPhysicalLinkStatus string, err error) {
// Request structure.
@@ -1238,11 +1695,6 @@ func (client *WANCommonInterfaceConfig1) GetCommonLinkProperties() (NewWANAccess
return
}
-//
-//
-// Return values:
-//
-// * NewWANAccessProvider:
func (client *WANCommonInterfaceConfig1) GetWANAccessProvider() (NewWANAccessProvider string, err error) {
// Request structure.
request := interface{}(nil)
@@ -1270,7 +1722,6 @@ func (client *WANCommonInterfaceConfig1) GetWANAccessProvider() (NewWANAccessPro
}
//
-//
// Return values:
//
// * NewMaximumActiveConnections: allowed value range: minimum=1, step=1
@@ -1300,11 +1751,6 @@ func (client *WANCommonInterfaceConfig1) GetMaximumActiveConnections() (NewMaxim
return
}
-//
-//
-// Return values:
-//
-// * NewTotalBytesSent:
func (client *WANCommonInterfaceConfig1) GetTotalBytesSent() (NewTotalBytesSent uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -1331,11 +1777,6 @@ func (client *WANCommonInterfaceConfig1) GetTotalBytesSent() (NewTotalBytesSent
return
}
-//
-//
-// Return values:
-//
-// * NewTotalBytesReceived:
func (client *WANCommonInterfaceConfig1) GetTotalBytesReceived() (NewTotalBytesReceived uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -1362,11 +1803,6 @@ func (client *WANCommonInterfaceConfig1) GetTotalBytesReceived() (NewTotalBytesR
return
}
-//
-//
-// Return values:
-//
-// * NewTotalPacketsSent:
func (client *WANCommonInterfaceConfig1) GetTotalPacketsSent() (NewTotalPacketsSent uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -1393,11 +1829,6 @@ func (client *WANCommonInterfaceConfig1) GetTotalPacketsSent() (NewTotalPacketsS
return
}
-//
-//
-// Return values:
-//
-// * NewTotalPacketsReceived:
func (client *WANCommonInterfaceConfig1) GetTotalPacketsReceived() (NewTotalPacketsReceived uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -1424,15 +1855,6 @@ func (client *WANCommonInterfaceConfig1) GetTotalPacketsReceived() (NewTotalPack
return
}
-// Arguments:
-//
-// * NewActiveConnectionIndex:
-//
-// Return values:
-//
-// * NewActiveConnDeviceContainer:
-//
-// * NewActiveConnectionServiceID:
func (client *WANCommonInterfaceConfig1) GetActiveConnection(NewActiveConnectionIndex uint16) (NewActiveConnDeviceContainer string, NewActiveConnectionServiceID string, err error) {
// Request structure.
request := &struct {
@@ -1487,18 +1909,48 @@ func NewWANDSLLinkConfig1Clients() (clients []*WANDSLLinkConfig1, errors []error
if genericClients, errors, err = goupnp.NewServiceClients(URN_WANDSLLinkConfig_1); err != nil {
return
}
- clients = make([]*WANDSLLinkConfig1, len(genericClients))
- for i := range genericClients {
- clients[i] = &WANDSLLinkConfig1{genericClients[i]}
- }
+ clients = newWANDSLLinkConfig1ClientsFromGenericClients(genericClients)
return
}
-// Arguments:
-//
-// * NewLinkType:
+// NewWANDSLLinkConfig1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewWANDSLLinkConfig1ClientsByURL(loc *url.URL) ([]*WANDSLLinkConfig1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANDSLLinkConfig_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANDSLLinkConfig1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewWANDSLLinkConfig1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewWANDSLLinkConfig1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*WANDSLLinkConfig1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_WANDSLLinkConfig_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANDSLLinkConfig1ClientsFromGenericClients(genericClients), nil
+}
+
+func newWANDSLLinkConfig1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*WANDSLLinkConfig1 {
+ clients := make([]*WANDSLLinkConfig1, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &WANDSLLinkConfig1{genericClients[i]}
+ }
+ return clients
+}
+
func (client *WANDSLLinkConfig1) SetDSLLinkType(NewLinkType string) (err error) {
// Request structure.
request := &struct {
@@ -1526,11 +1978,8 @@ func (client *WANDSLLinkConfig1) SetDSLLinkType(NewLinkType string) (err error)
}
//
-//
// Return values:
//
-// * NewLinkType:
-//
// * NewLinkStatus: allowed values: Up, Down
func (client *WANDSLLinkConfig1) GetDSLLinkInfo() (NewLinkType string, NewLinkStatus string, err error) {
// Request structure.
@@ -1563,11 +2012,6 @@ func (client *WANDSLLinkConfig1) GetDSLLinkInfo() (NewLinkType string, NewLinkSt
return
}
-//
-//
-// Return values:
-//
-// * NewAutoConfig:
func (client *WANDSLLinkConfig1) GetAutoConfig() (NewAutoConfig bool, err error) {
// Request structure.
request := interface{}(nil)
@@ -1594,11 +2038,6 @@ func (client *WANDSLLinkConfig1) GetAutoConfig() (NewAutoConfig bool, err error)
return
}
-//
-//
-// Return values:
-//
-// * NewModulationType:
func (client *WANDSLLinkConfig1) GetModulationType() (NewModulationType string, err error) {
// Request structure.
request := interface{}(nil)
@@ -1625,11 +2064,6 @@ func (client *WANDSLLinkConfig1) GetModulationType() (NewModulationType string,
return
}
-// Arguments:
-//
-// * NewDestinationAddress:
-//
-//
func (client *WANDSLLinkConfig1) SetDestinationAddress(NewDestinationAddress string) (err error) {
// Request structure.
request := &struct {
@@ -1656,11 +2090,6 @@ func (client *WANDSLLinkConfig1) SetDestinationAddress(NewDestinationAddress str
return
}
-//
-//
-// Return values:
-//
-// * NewDestinationAddress:
func (client *WANDSLLinkConfig1) GetDestinationAddress() (NewDestinationAddress string, err error) {
// Request structure.
request := interface{}(nil)
@@ -1687,11 +2116,6 @@ func (client *WANDSLLinkConfig1) GetDestinationAddress() (NewDestinationAddress
return
}
-// Arguments:
-//
-// * NewATMEncapsulation:
-//
-//
func (client *WANDSLLinkConfig1) SetATMEncapsulation(NewATMEncapsulation string) (err error) {
// Request structure.
request := &struct {
@@ -1718,11 +2142,6 @@ func (client *WANDSLLinkConfig1) SetATMEncapsulation(NewATMEncapsulation string)
return
}
-//
-//
-// Return values:
-//
-// * NewATMEncapsulation:
func (client *WANDSLLinkConfig1) GetATMEncapsulation() (NewATMEncapsulation string, err error) {
// Request structure.
request := interface{}(nil)
@@ -1749,11 +2168,6 @@ func (client *WANDSLLinkConfig1) GetATMEncapsulation() (NewATMEncapsulation stri
return
}
-// Arguments:
-//
-// * NewFCSPreserved:
-//
-//
func (client *WANDSLLinkConfig1) SetFCSPreserved(NewFCSPreserved bool) (err error) {
// Request structure.
request := &struct {
@@ -1780,11 +2194,6 @@ func (client *WANDSLLinkConfig1) SetFCSPreserved(NewFCSPreserved bool) (err erro
return
}
-//
-//
-// Return values:
-//
-// * NewFCSPreserved:
func (client *WANDSLLinkConfig1) GetFCSPreserved() (NewFCSPreserved bool, err error) {
// Request structure.
request := interface{}(nil)
@@ -1829,15 +2238,49 @@ func NewWANEthernetLinkConfig1Clients() (clients []*WANEthernetLinkConfig1, erro
if genericClients, errors, err = goupnp.NewServiceClients(URN_WANEthernetLinkConfig_1); err != nil {
return
}
- clients = make([]*WANEthernetLinkConfig1, len(genericClients))
+ clients = newWANEthernetLinkConfig1ClientsFromGenericClients(genericClients)
+ return
+}
+
+// NewWANEthernetLinkConfig1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewWANEthernetLinkConfig1ClientsByURL(loc *url.URL) ([]*WANEthernetLinkConfig1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANEthernetLinkConfig_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANEthernetLinkConfig1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewWANEthernetLinkConfig1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewWANEthernetLinkConfig1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*WANEthernetLinkConfig1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_WANEthernetLinkConfig_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANEthernetLinkConfig1ClientsFromGenericClients(genericClients), nil
+}
+
+func newWANEthernetLinkConfig1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*WANEthernetLinkConfig1 {
+ clients := make([]*WANEthernetLinkConfig1, len(genericClients))
for i := range genericClients {
clients[i] = &WANEthernetLinkConfig1{genericClients[i]}
}
- return
+ return clients
}
//
-//
// Return values:
//
// * NewEthernetLinkStatus: allowed values: Up, Down
@@ -1885,18 +2328,48 @@ func NewWANIPConnection1Clients() (clients []*WANIPConnection1, errors []error,
if genericClients, errors, err = goupnp.NewServiceClients(URN_WANIPConnection_1); err != nil {
return
}
- clients = make([]*WANIPConnection1, len(genericClients))
- for i := range genericClients {
- clients[i] = &WANIPConnection1{genericClients[i]}
- }
+ clients = newWANIPConnection1ClientsFromGenericClients(genericClients)
return
}
-// Arguments:
-//
-// * NewConnectionType:
+// NewWANIPConnection1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewWANIPConnection1ClientsByURL(loc *url.URL) ([]*WANIPConnection1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANIPConnection_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANIPConnection1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewWANIPConnection1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewWANIPConnection1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*WANIPConnection1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_WANIPConnection_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANIPConnection1ClientsFromGenericClients(genericClients), nil
+}
+
+func newWANIPConnection1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*WANIPConnection1 {
+ clients := make([]*WANIPConnection1, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &WANIPConnection1{genericClients[i]}
+ }
+ return clients
+}
+
func (client *WANIPConnection1) SetConnectionType(NewConnectionType string) (err error) {
// Request structure.
request := &struct {
@@ -1924,11 +2397,8 @@ func (client *WANIPConnection1) SetConnectionType(NewConnectionType string) (err
}
//
-//
// Return values:
//
-// * NewConnectionType:
-//
// * NewPossibleConnectionTypes: allowed values: Unconfigured, IP_Routed, IP_Bridged
func (client *WANIPConnection1) GetConnectionTypeInfo() (NewConnectionType string, NewPossibleConnectionTypes string, err error) {
// Request structure.
@@ -1961,9 +2431,6 @@ func (client *WANIPConnection1) GetConnectionTypeInfo() (NewConnectionType strin
return
}
-//
-//
-//
func (client *WANIPConnection1) RequestConnection() (err error) {
// Request structure.
request := interface{}(nil)
@@ -1985,9 +2452,6 @@ func (client *WANIPConnection1) RequestConnection() (err error) {
return
}
-//
-//
-//
func (client *WANIPConnection1) RequestTermination() (err error) {
// Request structure.
request := interface{}(nil)
@@ -2009,9 +2473,6 @@ func (client *WANIPConnection1) RequestTermination() (err error) {
return
}
-//
-//
-//
func (client *WANIPConnection1) ForceTermination() (err error) {
// Request structure.
request := interface{}(nil)
@@ -2033,11 +2494,6 @@ func (client *WANIPConnection1) ForceTermination() (err error) {
return
}
-// Arguments:
-//
-// * NewAutoDisconnectTime:
-//
-//
func (client *WANIPConnection1) SetAutoDisconnectTime(NewAutoDisconnectTime uint32) (err error) {
// Request structure.
request := &struct {
@@ -2064,11 +2520,6 @@ func (client *WANIPConnection1) SetAutoDisconnectTime(NewAutoDisconnectTime uint
return
}
-// Arguments:
-//
-// * NewIdleDisconnectTime:
-//
-//
func (client *WANIPConnection1) SetIdleDisconnectTime(NewIdleDisconnectTime uint32) (err error) {
// Request structure.
request := &struct {
@@ -2095,11 +2546,6 @@ func (client *WANIPConnection1) SetIdleDisconnectTime(NewIdleDisconnectTime uint
return
}
-// Arguments:
-//
-// * NewWarnDisconnectDelay:
-//
-//
func (client *WANIPConnection1) SetWarnDisconnectDelay(NewWarnDisconnectDelay uint32) (err error) {
// Request structure.
request := &struct {
@@ -2127,14 +2573,11 @@ func (client *WANIPConnection1) SetWarnDisconnectDelay(NewWarnDisconnectDelay ui
}
//
-//
// Return values:
//
// * NewConnectionStatus: allowed values: Unconfigured, Connected, Disconnected
//
// * NewLastConnectionError: allowed values: ERROR_NONE
-//
-// * NewUptime:
func (client *WANIPConnection1) GetStatusInfo() (NewConnectionStatus string, NewLastConnectionError string, NewUptime uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -2171,11 +2614,6 @@ func (client *WANIPConnection1) GetStatusInfo() (NewConnectionStatus string, New
return
}
-//
-//
-// Return values:
-//
-// * NewAutoDisconnectTime:
func (client *WANIPConnection1) GetAutoDisconnectTime() (NewAutoDisconnectTime uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -2202,11 +2640,6 @@ func (client *WANIPConnection1) GetAutoDisconnectTime() (NewAutoDisconnectTime u
return
}
-//
-//
-// Return values:
-//
-// * NewIdleDisconnectTime:
func (client *WANIPConnection1) GetIdleDisconnectTime() (NewIdleDisconnectTime uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -2233,11 +2666,6 @@ func (client *WANIPConnection1) GetIdleDisconnectTime() (NewIdleDisconnectTime u
return
}
-//
-//
-// Return values:
-//
-// * NewWarnDisconnectDelay:
func (client *WANIPConnection1) GetWarnDisconnectDelay() (NewWarnDisconnectDelay uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -2264,13 +2692,6 @@ func (client *WANIPConnection1) GetWarnDisconnectDelay() (NewWarnDisconnectDelay
return
}
-//
-//
-// Return values:
-//
-// * NewRSIPAvailable:
-//
-// * NewNATEnabled:
func (client *WANIPConnection1) GetNATRSIPStatus() (NewRSIPAvailable bool, NewNATEnabled bool, err error) {
// Request structure.
request := interface{}(nil)
@@ -2302,27 +2723,10 @@ func (client *WANIPConnection1) GetNATRSIPStatus() (NewRSIPAvailable bool, NewNA
return
}
-// Arguments:
-//
-// * NewPortMappingIndex:
//
// Return values:
//
-// * NewRemoteHost:
-//
-// * NewExternalPort:
-//
// * NewProtocol: allowed values: TCP, UDP
-//
-// * NewInternalPort:
-//
-// * NewInternalClient:
-//
-// * NewEnabled:
-//
-// * NewPortMappingDescription:
-//
-// * NewLeaseDuration:
func (client *WANIPConnection1) GetGenericPortMappingEntry(NewPortMappingIndex uint16) (NewRemoteHost string, NewExternalPort uint16, NewProtocol string, NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32, err error) {
// Request structure.
request := &struct {
@@ -2389,25 +2793,11 @@ func (client *WANIPConnection1) GetGenericPortMappingEntry(NewPortMappingIndex u
return
}
-// Arguments:
//
-// * NewRemoteHost:
-//
-// * NewExternalPort:
+// Arguments:
//
// * NewProtocol: allowed values: TCP, UDP
-//
-// Return values:
-//
-// * NewInternalPort:
-//
-// * NewInternalClient:
-//
-// * NewEnabled:
-//
-// * NewPortMappingDescription:
-//
-// * NewLeaseDuration:
+
func (client *WANIPConnection1) GetSpecificPortMappingEntry(NewRemoteHost string, NewExternalPort uint16, NewProtocol string) (NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32, err error) {
// Request structure.
request := &struct {
@@ -2469,25 +2859,11 @@ func (client *WANIPConnection1) GetSpecificPortMappingEntry(NewRemoteHost string
return
}
-// Arguments:
//
-// * NewRemoteHost:
-//
-// * NewExternalPort:
+// Arguments:
//
// * NewProtocol: allowed values: TCP, UDP
-//
-// * NewInternalPort:
-//
-// * NewInternalClient:
-//
-// * NewEnabled:
-//
-// * NewPortMappingDescription:
-//
-// * NewLeaseDuration:
-//
-//
+
func (client *WANIPConnection1) AddPortMapping(NewRemoteHost string, NewExternalPort uint16, NewProtocol string, NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32) (err error) {
// Request structure.
request := &struct {
@@ -2549,15 +2925,11 @@ func (client *WANIPConnection1) AddPortMapping(NewRemoteHost string, NewExternal
return
}
-// Arguments:
-//
-// * NewRemoteHost:
//
-// * NewExternalPort:
+// Arguments:
//
// * NewProtocol: allowed values: TCP, UDP
-//
-//
+
func (client *WANIPConnection1) DeletePortMapping(NewRemoteHost string, NewExternalPort uint16, NewProtocol string) (err error) {
// Request structure.
request := &struct {
@@ -2594,11 +2966,6 @@ func (client *WANIPConnection1) DeletePortMapping(NewRemoteHost string, NewExter
return
}
-//
-//
-// Return values:
-//
-// * NewExternalIPAddress:
func (client *WANIPConnection1) GetExternalIPAddress() (NewExternalIPAddress string, err error) {
// Request structure.
request := interface{}(nil)
@@ -2643,18 +3010,48 @@ func NewWANIPConnection2Clients() (clients []*WANIPConnection2, errors []error,
if genericClients, errors, err = goupnp.NewServiceClients(URN_WANIPConnection_2); err != nil {
return
}
- clients = make([]*WANIPConnection2, len(genericClients))
- for i := range genericClients {
- clients[i] = &WANIPConnection2{genericClients[i]}
- }
+ clients = newWANIPConnection2ClientsFromGenericClients(genericClients)
return
}
-// Arguments:
-//
-// * NewConnectionType: allowed values: Unconfigured, IP_Routed, IP_Bridged
+// NewWANIPConnection2ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewWANIPConnection2ClientsByURL(loc *url.URL) ([]*WANIPConnection2, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANIPConnection_2)
+ if err != nil {
+ return nil, err
+ }
+ return newWANIPConnection2ClientsFromGenericClients(genericClients), nil
+}
+
+// NewWANIPConnection2ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewWANIPConnection2ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*WANIPConnection2, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_WANIPConnection_2)
+ if err != nil {
+ return nil, err
+ }
+ return newWANIPConnection2ClientsFromGenericClients(genericClients), nil
+}
+
+func newWANIPConnection2ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*WANIPConnection2 {
+ clients := make([]*WANIPConnection2, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &WANIPConnection2{genericClients[i]}
+ }
+ return clients
+}
+
func (client *WANIPConnection2) SetConnectionType(NewConnectionType string) (err error) {
// Request structure.
request := &struct {
@@ -2681,13 +3078,6 @@ func (client *WANIPConnection2) SetConnectionType(NewConnectionType string) (err
return
}
-//
-//
-// Return values:
-//
-// * NewConnectionType: allowed values: Unconfigured, IP_Routed, IP_Bridged
-//
-// * NewPossibleConnectionTypes:
func (client *WANIPConnection2) GetConnectionTypeInfo() (NewConnectionType string, NewPossibleConnectionTypes string, err error) {
// Request structure.
request := interface{}(nil)
@@ -2719,9 +3109,6 @@ func (client *WANIPConnection2) GetConnectionTypeInfo() (NewConnectionType strin
return
}
-//
-//
-//
func (client *WANIPConnection2) RequestConnection() (err error) {
// Request structure.
request := interface{}(nil)
@@ -2743,9 +3130,6 @@ func (client *WANIPConnection2) RequestConnection() (err error) {
return
}
-//
-//
-//
func (client *WANIPConnection2) RequestTermination() (err error) {
// Request structure.
request := interface{}(nil)
@@ -2767,9 +3151,6 @@ func (client *WANIPConnection2) RequestTermination() (err error) {
return
}
-//
-//
-//
func (client *WANIPConnection2) ForceTermination() (err error) {
// Request structure.
request := interface{}(nil)
@@ -2791,11 +3172,6 @@ func (client *WANIPConnection2) ForceTermination() (err error) {
return
}
-// Arguments:
-//
-// * NewAutoDisconnectTime:
-//
-//
func (client *WANIPConnection2) SetAutoDisconnectTime(NewAutoDisconnectTime uint32) (err error) {
// Request structure.
request := &struct {
@@ -2822,11 +3198,6 @@ func (client *WANIPConnection2) SetAutoDisconnectTime(NewAutoDisconnectTime uint
return
}
-// Arguments:
-//
-// * NewIdleDisconnectTime:
-//
-//
func (client *WANIPConnection2) SetIdleDisconnectTime(NewIdleDisconnectTime uint32) (err error) {
// Request structure.
request := &struct {
@@ -2853,11 +3224,6 @@ func (client *WANIPConnection2) SetIdleDisconnectTime(NewIdleDisconnectTime uint
return
}
-// Arguments:
-//
-// * NewWarnDisconnectDelay:
-//
-//
func (client *WANIPConnection2) SetWarnDisconnectDelay(NewWarnDisconnectDelay uint32) (err error) {
// Request structure.
request := &struct {
@@ -2885,14 +3251,11 @@ func (client *WANIPConnection2) SetWarnDisconnectDelay(NewWarnDisconnectDelay ui
}
//
-//
// Return values:
//
-// * NewConnectionStatus: allowed values: Unconfigured, Connected, Disconnected
-//
-// * NewLastConnectionError: allowed values: ERROR_NONE
+// * NewConnectionStatus: allowed values: Unconfigured, Connecting, Connected, PendingDisconnect, Disconnecting, Disconnected
//
-// * NewUptime:
+// * NewLastConnectionError: allowed values: ERROR_NONE, ERROR_COMMAND_ABORTED, ERROR_NOT_ENABLED_FOR_INTERNET, ERROR_USER_DISCONNECT, ERROR_ISP_DISCONNECT, ERROR_IDLE_DISCONNECT, ERROR_FORCED_DISCONNECT, ERROR_NO_CARRIER, ERROR_IP_CONFIGURATION, ERROR_UNKNOWN
func (client *WANIPConnection2) GetStatusInfo() (NewConnectionStatus string, NewLastConnectionError string, NewUptime uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -2929,11 +3292,6 @@ func (client *WANIPConnection2) GetStatusInfo() (NewConnectionStatus string, New
return
}
-//
-//
-// Return values:
-//
-// * NewAutoDisconnectTime:
func (client *WANIPConnection2) GetAutoDisconnectTime() (NewAutoDisconnectTime uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -2960,11 +3318,6 @@ func (client *WANIPConnection2) GetAutoDisconnectTime() (NewAutoDisconnectTime u
return
}
-//
-//
-// Return values:
-//
-// * NewIdleDisconnectTime:
func (client *WANIPConnection2) GetIdleDisconnectTime() (NewIdleDisconnectTime uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -2991,11 +3344,6 @@ func (client *WANIPConnection2) GetIdleDisconnectTime() (NewIdleDisconnectTime u
return
}
-//
-//
-// Return values:
-//
-// * NewWarnDisconnectDelay:
func (client *WANIPConnection2) GetWarnDisconnectDelay() (NewWarnDisconnectDelay uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -3022,13 +3370,6 @@ func (client *WANIPConnection2) GetWarnDisconnectDelay() (NewWarnDisconnectDelay
return
}
-//
-//
-// Return values:
-//
-// * NewRSIPAvailable:
-//
-// * NewNATEnabled:
func (client *WANIPConnection2) GetNATRSIPStatus() (NewRSIPAvailable bool, NewNATEnabled bool, err error) {
// Request structure.
request := interface{}(nil)
@@ -3060,27 +3401,10 @@ func (client *WANIPConnection2) GetNATRSIPStatus() (NewRSIPAvailable bool, NewNA
return
}
-// Arguments:
-//
-// * NewPortMappingIndex:
//
// Return values:
//
-// * NewRemoteHost:
-//
-// * NewExternalPort:
-//
// * NewProtocol: allowed values: TCP, UDP
-//
-// * NewInternalPort: allowed value range: minimum=1, maximum=65535
-//
-// * NewInternalClient:
-//
-// * NewEnabled:
-//
-// * NewPortMappingDescription:
-//
-// * NewLeaseDuration: allowed value range: minimum=0, maximum=604800
func (client *WANIPConnection2) GetGenericPortMappingEntry(NewPortMappingIndex uint16) (NewRemoteHost string, NewExternalPort uint16, NewProtocol string, NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32, err error) {
// Request structure.
request := &struct {
@@ -3147,25 +3471,11 @@ func (client *WANIPConnection2) GetGenericPortMappingEntry(NewPortMappingIndex u
return
}
-// Arguments:
//
-// * NewRemoteHost:
-//
-// * NewExternalPort:
+// Arguments:
//
// * NewProtocol: allowed values: TCP, UDP
-//
-// Return values:
-//
-// * NewInternalPort: allowed value range: minimum=1, maximum=65535
-//
-// * NewInternalClient:
-//
-// * NewEnabled:
-//
-// * NewPortMappingDescription:
-//
-// * NewLeaseDuration: allowed value range: minimum=0, maximum=604800
+
func (client *WANIPConnection2) GetSpecificPortMappingEntry(NewRemoteHost string, NewExternalPort uint16, NewProtocol string) (NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32, err error) {
// Request structure.
request := &struct {
@@ -3227,25 +3537,11 @@ func (client *WANIPConnection2) GetSpecificPortMappingEntry(NewRemoteHost string
return
}
-// Arguments:
//
-// * NewRemoteHost:
-//
-// * NewExternalPort:
+// Arguments:
//
// * NewProtocol: allowed values: TCP, UDP
-//
-// * NewInternalPort: allowed value range: minimum=1, maximum=65535
-//
-// * NewInternalClient:
-//
-// * NewEnabled:
-//
-// * NewPortMappingDescription:
-//
-// * NewLeaseDuration: allowed value range: minimum=0, maximum=604800
-//
-//
+
func (client *WANIPConnection2) AddPortMapping(NewRemoteHost string, NewExternalPort uint16, NewProtocol string, NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32) (err error) {
// Request structure.
request := &struct {
@@ -3307,15 +3603,11 @@ func (client *WANIPConnection2) AddPortMapping(NewRemoteHost string, NewExternal
return
}
-// Arguments:
-//
-// * NewRemoteHost:
//
-// * NewExternalPort:
+// Arguments:
//
// * NewProtocol: allowed values: TCP, UDP
-//
-//
+
func (client *WANIPConnection2) DeletePortMapping(NewRemoteHost string, NewExternalPort uint16, NewProtocol string) (err error) {
// Request structure.
request := &struct {
@@ -3352,17 +3644,11 @@ func (client *WANIPConnection2) DeletePortMapping(NewRemoteHost string, NewExter
return
}
-// Arguments:
//
-// * NewStartPort:
-//
-// * NewEndPort:
+// Arguments:
//
// * NewProtocol: allowed values: TCP, UDP
-//
-// * NewManage:
-//
-//
+
func (client *WANIPConnection2) DeletePortMappingRange(NewStartPort uint16, NewEndPort uint16, NewProtocol string, NewManage bool) (err error) {
// Request structure.
request := &struct {
@@ -3404,11 +3690,6 @@ func (client *WANIPConnection2) DeletePortMappingRange(NewStartPort uint16, NewE
return
}
-//
-//
-// Return values:
-//
-// * NewExternalIPAddress:
func (client *WANIPConnection2) GetExternalIPAddress() (NewExternalIPAddress string, err error) {
// Request structure.
request := interface{}(nil)
@@ -3435,21 +3716,11 @@ func (client *WANIPConnection2) GetExternalIPAddress() (NewExternalIPAddress str
return
}
-// Arguments:
//
-// * NewStartPort:
-//
-// * NewEndPort:
+// Arguments:
//
// * NewProtocol: allowed values: TCP, UDP
-//
-// * NewManage:
-//
-// * NewNumberOfPorts:
-//
-// Return values:
-//
-// * NewPortListing:
+
func (client *WANIPConnection2) GetListOfPortMappings(NewStartPort uint16, NewEndPort uint16, NewProtocol string, NewManage bool, NewNumberOfPorts uint16) (NewPortListing string, err error) {
// Request structure.
request := &struct {
@@ -3501,27 +3772,11 @@ func (client *WANIPConnection2) GetListOfPortMappings(NewStartPort uint16, NewEn
return
}
-// Arguments:
//
-// * NewRemoteHost:
-//
-// * NewExternalPort:
+// Arguments:
//
// * NewProtocol: allowed values: TCP, UDP
-//
-// * NewInternalPort: allowed value range: minimum=1, maximum=65535
-//
-// * NewInternalClient:
-//
-// * NewEnabled:
-//
-// * NewPortMappingDescription:
-//
-// * NewLeaseDuration: allowed value range: minimum=0, maximum=604800
-//
-// Return values:
-//
-// * NewReservedPort:
+
func (client *WANIPConnection2) AddAnyPortMapping(NewRemoteHost string, NewExternalPort uint16, NewProtocol string, NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32) (NewReservedPort uint16, err error) {
// Request structure.
request := &struct {
@@ -3606,20 +3861,48 @@ func NewWANIPv6FirewallControl1Clients() (clients []*WANIPv6FirewallControl1, er
if genericClients, errors, err = goupnp.NewServiceClients(URN_WANIPv6FirewallControl_1); err != nil {
return
}
- clients = make([]*WANIPv6FirewallControl1, len(genericClients))
- for i := range genericClients {
- clients[i] = &WANIPv6FirewallControl1{genericClients[i]}
- }
+ clients = newWANIPv6FirewallControl1ClientsFromGenericClients(genericClients)
return
}
+// NewWANIPv6FirewallControl1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewWANIPv6FirewallControl1ClientsByURL(loc *url.URL) ([]*WANIPv6FirewallControl1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANIPv6FirewallControl_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANIPv6FirewallControl1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewWANIPv6FirewallControl1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
//
-// Return values:
-//
-// * FirewallEnabled:
-//
-// * InboundPinholeAllowed:
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewWANIPv6FirewallControl1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*WANIPv6FirewallControl1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_WANIPv6FirewallControl_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANIPv6FirewallControl1ClientsFromGenericClients(genericClients), nil
+}
+
+func newWANIPv6FirewallControl1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*WANIPv6FirewallControl1 {
+ clients := make([]*WANIPv6FirewallControl1, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &WANIPv6FirewallControl1{genericClients[i]}
+ }
+ return clients
+}
+
func (client *WANIPv6FirewallControl1) GetFirewallStatus() (FirewallEnabled bool, InboundPinholeAllowed bool, err error) {
// Request structure.
request := interface{}(nil)
@@ -3651,21 +3934,6 @@ func (client *WANIPv6FirewallControl1) GetFirewallStatus() (FirewallEnabled bool
return
}
-// Arguments:
-//
-// * RemoteHost:
-//
-// * RemotePort:
-//
-// * InternalClient:
-//
-// * InternalPort:
-//
-// * Protocol:
-//
-// Return values:
-//
-// * OutboundPinholeTimeout:
func (client *WANIPv6FirewallControl1) GetOutboundPinholeTimeout(RemoteHost string, RemotePort uint16, InternalClient string, InternalPort uint16, Protocol uint16) (OutboundPinholeTimeout uint32, err error) {
// Request structure.
request := &struct {
@@ -3717,23 +3985,11 @@ func (client *WANIPv6FirewallControl1) GetOutboundPinholeTimeout(RemoteHost stri
return
}
-// Arguments:
-//
-// * RemoteHost:
-//
-// * RemotePort:
-//
-// * InternalClient:
-//
-// * InternalPort:
//
-// * Protocol:
+// Arguments:
//
// * LeaseTime: allowed value range: minimum=1, maximum=86400
-//
-// Return values:
-//
-// * UniqueID:
+
func (client *WANIPv6FirewallControl1) AddPinhole(RemoteHost string, RemotePort uint16, InternalClient string, InternalPort uint16, Protocol uint16, LeaseTime uint32) (UniqueID uint16, err error) {
// Request structure.
request := &struct {
@@ -3790,13 +4046,11 @@ func (client *WANIPv6FirewallControl1) AddPinhole(RemoteHost string, RemotePort
return
}
-// Arguments:
//
-// * UniqueID:
+// Arguments:
//
// * NewLeaseTime: allowed value range: minimum=1, maximum=86400
-//
-//
+
func (client *WANIPv6FirewallControl1) UpdatePinhole(UniqueID uint16, NewLeaseTime uint32) (err error) {
// Request structure.
request := &struct {
@@ -3828,11 +4082,6 @@ func (client *WANIPv6FirewallControl1) UpdatePinhole(UniqueID uint16, NewLeaseTi
return
}
-// Arguments:
-//
-// * UniqueID:
-//
-//
func (client *WANIPv6FirewallControl1) DeletePinhole(UniqueID uint16) (err error) {
// Request structure.
request := &struct {
@@ -3859,13 +4108,6 @@ func (client *WANIPv6FirewallControl1) DeletePinhole(UniqueID uint16) (err error
return
}
-// Arguments:
-//
-// * UniqueID:
-//
-// Return values:
-//
-// * PinholePackets:
func (client *WANIPv6FirewallControl1) GetPinholePackets(UniqueID uint16) (PinholePackets uint32, err error) {
// Request structure.
request := &struct {
@@ -3897,13 +4139,6 @@ func (client *WANIPv6FirewallControl1) GetPinholePackets(UniqueID uint16) (Pinho
return
}
-// Arguments:
-//
-// * UniqueID:
-//
-// Return values:
-//
-// * IsWorking:
func (client *WANIPv6FirewallControl1) CheckPinholeWorking(UniqueID uint16) (IsWorking bool, err error) {
// Request structure.
request := &struct {
@@ -3953,22 +4188,53 @@ func NewWANPOTSLinkConfig1Clients() (clients []*WANPOTSLinkConfig1, errors []err
if genericClients, errors, err = goupnp.NewServiceClients(URN_WANPOTSLinkConfig_1); err != nil {
return
}
- clients = make([]*WANPOTSLinkConfig1, len(genericClients))
+ clients = newWANPOTSLinkConfig1ClientsFromGenericClients(genericClients)
+ return
+}
+
+// NewWANPOTSLinkConfig1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewWANPOTSLinkConfig1ClientsByURL(loc *url.URL) ([]*WANPOTSLinkConfig1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANPOTSLinkConfig_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANPOTSLinkConfig1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewWANPOTSLinkConfig1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewWANPOTSLinkConfig1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*WANPOTSLinkConfig1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_WANPOTSLinkConfig_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANPOTSLinkConfig1ClientsFromGenericClients(genericClients), nil
+}
+
+func newWANPOTSLinkConfig1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*WANPOTSLinkConfig1 {
+ clients := make([]*WANPOTSLinkConfig1, len(genericClients))
for i := range genericClients {
clients[i] = &WANPOTSLinkConfig1{genericClients[i]}
}
- return
+ return clients
}
-// Arguments:
//
-// * NewISPPhoneNumber:
-//
-// * NewISPInfo:
+// Arguments:
//
// * NewLinkType: allowed values: PPP_Dialup
-//
-//
+
func (client *WANPOTSLinkConfig1) SetISPInfo(NewISPPhoneNumber string, NewISPInfo string, NewLinkType string) (err error) {
// Request structure.
request := &struct {
@@ -4005,13 +4271,6 @@ func (client *WANPOTSLinkConfig1) SetISPInfo(NewISPPhoneNumber string, NewISPInf
return
}
-// Arguments:
-//
-// * NewNumberOfRetries:
-//
-// * NewDelayBetweenRetries:
-//
-//
func (client *WANPOTSLinkConfig1) SetCallRetryInfo(NewNumberOfRetries uint32, NewDelayBetweenRetries uint32) (err error) {
// Request structure.
request := &struct {
@@ -4044,13 +4303,8 @@ func (client *WANPOTSLinkConfig1) SetCallRetryInfo(NewNumberOfRetries uint32, Ne
}
//
-//
// Return values:
//
-// * NewISPPhoneNumber:
-//
-// * NewISPInfo:
-//
// * NewLinkType: allowed values: PPP_Dialup
func (client *WANPOTSLinkConfig1) GetISPInfo() (NewISPPhoneNumber string, NewISPInfo string, NewLinkType string, err error) {
// Request structure.
@@ -4088,13 +4342,6 @@ func (client *WANPOTSLinkConfig1) GetISPInfo() (NewISPPhoneNumber string, NewISP
return
}
-//
-//
-// Return values:
-//
-// * NewNumberOfRetries:
-//
-// * NewDelayBetweenRetries:
func (client *WANPOTSLinkConfig1) GetCallRetryInfo() (NewNumberOfRetries uint32, NewDelayBetweenRetries uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -4126,11 +4373,6 @@ func (client *WANPOTSLinkConfig1) GetCallRetryInfo() (NewNumberOfRetries uint32,
return
}
-//
-//
-// Return values:
-//
-// * NewFclass:
func (client *WANPOTSLinkConfig1) GetFclass() (NewFclass string, err error) {
// Request structure.
request := interface{}(nil)
@@ -4157,11 +4399,6 @@ func (client *WANPOTSLinkConfig1) GetFclass() (NewFclass string, err error) {
return
}
-//
-//
-// Return values:
-//
-// * NewDataModulationSupported:
func (client *WANPOTSLinkConfig1) GetDataModulationSupported() (NewDataModulationSupported string, err error) {
// Request structure.
request := interface{}(nil)
@@ -4188,11 +4425,6 @@ func (client *WANPOTSLinkConfig1) GetDataModulationSupported() (NewDataModulatio
return
}
-//
-//
-// Return values:
-//
-// * NewDataProtocol:
func (client *WANPOTSLinkConfig1) GetDataProtocol() (NewDataProtocol string, err error) {
// Request structure.
request := interface{}(nil)
@@ -4219,11 +4451,6 @@ func (client *WANPOTSLinkConfig1) GetDataProtocol() (NewDataProtocol string, err
return
}
-//
-//
-// Return values:
-//
-// * NewDataCompression:
func (client *WANPOTSLinkConfig1) GetDataCompression() (NewDataCompression string, err error) {
// Request structure.
request := interface{}(nil)
@@ -4250,11 +4477,6 @@ func (client *WANPOTSLinkConfig1) GetDataCompression() (NewDataCompression strin
return
}
-//
-//
-// Return values:
-//
-// * NewPlusVTRCommandSupported:
func (client *WANPOTSLinkConfig1) GetPlusVTRCommandSupported() (NewPlusVTRCommandSupported bool, err error) {
// Request structure.
request := interface{}(nil)
@@ -4299,18 +4521,48 @@ func NewWANPPPConnection1Clients() (clients []*WANPPPConnection1, errors []error
if genericClients, errors, err = goupnp.NewServiceClients(URN_WANPPPConnection_1); err != nil {
return
}
- clients = make([]*WANPPPConnection1, len(genericClients))
- for i := range genericClients {
- clients[i] = &WANPPPConnection1{genericClients[i]}
- }
+ clients = newWANPPPConnection1ClientsFromGenericClients(genericClients)
return
}
-// Arguments:
-//
-// * NewConnectionType:
+// NewWANPPPConnection1ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func NewWANPPPConnection1ClientsByURL(loc *url.URL) ([]*WANPPPConnection1, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, URN_WANPPPConnection_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANPPPConnection1ClientsFromGenericClients(genericClients), nil
+}
+
+// NewWANPPPConnection1ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func NewWANPPPConnection1ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*WANPPPConnection1, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, URN_WANPPPConnection_1)
+ if err != nil {
+ return nil, err
+ }
+ return newWANPPPConnection1ClientsFromGenericClients(genericClients), nil
+}
+
+func newWANPPPConnection1ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*WANPPPConnection1 {
+ clients := make([]*WANPPPConnection1, len(genericClients))
+ for i := range genericClients {
+ clients[i] = &WANPPPConnection1{genericClients[i]}
+ }
+ return clients
+}
+
func (client *WANPPPConnection1) SetConnectionType(NewConnectionType string) (err error) {
// Request structure.
request := &struct {
@@ -4338,11 +4590,8 @@ func (client *WANPPPConnection1) SetConnectionType(NewConnectionType string) (er
}
//
-//
// Return values:
//
-// * NewConnectionType:
-//
// * NewPossibleConnectionTypes: allowed values: Unconfigured, IP_Routed, DHCP_Spoofed, PPPoE_Bridged, PPTP_Relay, L2TP_Relay, PPPoE_Relay
func (client *WANPPPConnection1) GetConnectionTypeInfo() (NewConnectionType string, NewPossibleConnectionTypes string, err error) {
// Request structure.
@@ -4375,13 +4624,6 @@ func (client *WANPPPConnection1) GetConnectionTypeInfo() (NewConnectionType stri
return
}
-// Arguments:
-//
-// * NewUserName:
-//
-// * NewPassword:
-//
-//
func (client *WANPPPConnection1) ConfigureConnection(NewUserName string, NewPassword string) (err error) {
// Request structure.
request := &struct {
@@ -4413,9 +4655,6 @@ func (client *WANPPPConnection1) ConfigureConnection(NewUserName string, NewPass
return
}
-//
-//
-//
func (client *WANPPPConnection1) RequestConnection() (err error) {
// Request structure.
request := interface{}(nil)
@@ -4437,9 +4676,6 @@ func (client *WANPPPConnection1) RequestConnection() (err error) {
return
}
-//
-//
-//
func (client *WANPPPConnection1) RequestTermination() (err error) {
// Request structure.
request := interface{}(nil)
@@ -4461,9 +4697,6 @@ func (client *WANPPPConnection1) RequestTermination() (err error) {
return
}
-//
-//
-//
func (client *WANPPPConnection1) ForceTermination() (err error) {
// Request structure.
request := interface{}(nil)
@@ -4485,11 +4718,6 @@ func (client *WANPPPConnection1) ForceTermination() (err error) {
return
}
-// Arguments:
-//
-// * NewAutoDisconnectTime:
-//
-//
func (client *WANPPPConnection1) SetAutoDisconnectTime(NewAutoDisconnectTime uint32) (err error) {
// Request structure.
request := &struct {
@@ -4516,11 +4744,6 @@ func (client *WANPPPConnection1) SetAutoDisconnectTime(NewAutoDisconnectTime uin
return
}
-// Arguments:
-//
-// * NewIdleDisconnectTime:
-//
-//
func (client *WANPPPConnection1) SetIdleDisconnectTime(NewIdleDisconnectTime uint32) (err error) {
// Request structure.
request := &struct {
@@ -4547,11 +4770,6 @@ func (client *WANPPPConnection1) SetIdleDisconnectTime(NewIdleDisconnectTime uin
return
}
-// Arguments:
-//
-// * NewWarnDisconnectDelay:
-//
-//
func (client *WANPPPConnection1) SetWarnDisconnectDelay(NewWarnDisconnectDelay uint32) (err error) {
// Request structure.
request := &struct {
@@ -4579,14 +4797,11 @@ func (client *WANPPPConnection1) SetWarnDisconnectDelay(NewWarnDisconnectDelay u
}
//
-//
// Return values:
//
// * NewConnectionStatus: allowed values: Unconfigured, Connected, Disconnected
//
// * NewLastConnectionError: allowed values: ERROR_NONE
-//
-// * NewUptime:
func (client *WANPPPConnection1) GetStatusInfo() (NewConnectionStatus string, NewLastConnectionError string, NewUptime uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -4623,13 +4838,6 @@ func (client *WANPPPConnection1) GetStatusInfo() (NewConnectionStatus string, Ne
return
}
-//
-//
-// Return values:
-//
-// * NewUpstreamMaxBitRate:
-//
-// * NewDownstreamMaxBitRate:
func (client *WANPPPConnection1) GetLinkLayerMaxBitRates() (NewUpstreamMaxBitRate uint32, NewDownstreamMaxBitRate uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -4661,11 +4869,6 @@ func (client *WANPPPConnection1) GetLinkLayerMaxBitRates() (NewUpstreamMaxBitRat
return
}
-//
-//
-// Return values:
-//
-// * NewPPPEncryptionProtocol:
func (client *WANPPPConnection1) GetPPPEncryptionProtocol() (NewPPPEncryptionProtocol string, err error) {
// Request structure.
request := interface{}(nil)
@@ -4692,11 +4895,6 @@ func (client *WANPPPConnection1) GetPPPEncryptionProtocol() (NewPPPEncryptionPro
return
}
-//
-//
-// Return values:
-//
-// * NewPPPCompressionProtocol:
func (client *WANPPPConnection1) GetPPPCompressionProtocol() (NewPPPCompressionProtocol string, err error) {
// Request structure.
request := interface{}(nil)
@@ -4723,11 +4921,6 @@ func (client *WANPPPConnection1) GetPPPCompressionProtocol() (NewPPPCompressionP
return
}
-//
-//
-// Return values:
-//
-// * NewPPPAuthenticationProtocol:
func (client *WANPPPConnection1) GetPPPAuthenticationProtocol() (NewPPPAuthenticationProtocol string, err error) {
// Request structure.
request := interface{}(nil)
@@ -4754,11 +4947,6 @@ func (client *WANPPPConnection1) GetPPPAuthenticationProtocol() (NewPPPAuthentic
return
}
-//
-//
-// Return values:
-//
-// * NewUserName:
func (client *WANPPPConnection1) GetUserName() (NewUserName string, err error) {
// Request structure.
request := interface{}(nil)
@@ -4785,11 +4973,6 @@ func (client *WANPPPConnection1) GetUserName() (NewUserName string, err error) {
return
}
-//
-//
-// Return values:
-//
-// * NewPassword:
func (client *WANPPPConnection1) GetPassword() (NewPassword string, err error) {
// Request structure.
request := interface{}(nil)
@@ -4816,11 +4999,6 @@ func (client *WANPPPConnection1) GetPassword() (NewPassword string, err error) {
return
}
-//
-//
-// Return values:
-//
-// * NewAutoDisconnectTime:
func (client *WANPPPConnection1) GetAutoDisconnectTime() (NewAutoDisconnectTime uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -4847,11 +5025,6 @@ func (client *WANPPPConnection1) GetAutoDisconnectTime() (NewAutoDisconnectTime
return
}
-//
-//
-// Return values:
-//
-// * NewIdleDisconnectTime:
func (client *WANPPPConnection1) GetIdleDisconnectTime() (NewIdleDisconnectTime uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -4878,11 +5051,6 @@ func (client *WANPPPConnection1) GetIdleDisconnectTime() (NewIdleDisconnectTime
return
}
-//
-//
-// Return values:
-//
-// * NewWarnDisconnectDelay:
func (client *WANPPPConnection1) GetWarnDisconnectDelay() (NewWarnDisconnectDelay uint32, err error) {
// Request structure.
request := interface{}(nil)
@@ -4909,13 +5077,6 @@ func (client *WANPPPConnection1) GetWarnDisconnectDelay() (NewWarnDisconnectDela
return
}
-//
-//
-// Return values:
-//
-// * NewRSIPAvailable:
-//
-// * NewNATEnabled:
func (client *WANPPPConnection1) GetNATRSIPStatus() (NewRSIPAvailable bool, NewNATEnabled bool, err error) {
// Request structure.
request := interface{}(nil)
@@ -4947,27 +5108,10 @@ func (client *WANPPPConnection1) GetNATRSIPStatus() (NewRSIPAvailable bool, NewN
return
}
-// Arguments:
-//
-// * NewPortMappingIndex:
//
// Return values:
//
-// * NewRemoteHost:
-//
-// * NewExternalPort:
-//
// * NewProtocol: allowed values: TCP, UDP
-//
-// * NewInternalPort:
-//
-// * NewInternalClient:
-//
-// * NewEnabled:
-//
-// * NewPortMappingDescription:
-//
-// * NewLeaseDuration:
func (client *WANPPPConnection1) GetGenericPortMappingEntry(NewPortMappingIndex uint16) (NewRemoteHost string, NewExternalPort uint16, NewProtocol string, NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32, err error) {
// Request structure.
request := &struct {
@@ -5034,25 +5178,11 @@ func (client *WANPPPConnection1) GetGenericPortMappingEntry(NewPortMappingIndex
return
}
-// Arguments:
//
-// * NewRemoteHost:
-//
-// * NewExternalPort:
+// Arguments:
//
// * NewProtocol: allowed values: TCP, UDP
-//
-// Return values:
-//
-// * NewInternalPort:
-//
-// * NewInternalClient:
-//
-// * NewEnabled:
-//
-// * NewPortMappingDescription:
-//
-// * NewLeaseDuration:
+
func (client *WANPPPConnection1) GetSpecificPortMappingEntry(NewRemoteHost string, NewExternalPort uint16, NewProtocol string) (NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32, err error) {
// Request structure.
request := &struct {
@@ -5114,25 +5244,11 @@ func (client *WANPPPConnection1) GetSpecificPortMappingEntry(NewRemoteHost strin
return
}
-// Arguments:
-//
-// * NewRemoteHost:
//
-// * NewExternalPort:
+// Arguments:
//
// * NewProtocol: allowed values: TCP, UDP
-//
-// * NewInternalPort:
-//
-// * NewInternalClient:
-//
-// * NewEnabled:
-//
-// * NewPortMappingDescription:
-//
-// * NewLeaseDuration:
-//
-//
+
func (client *WANPPPConnection1) AddPortMapping(NewRemoteHost string, NewExternalPort uint16, NewProtocol string, NewInternalPort uint16, NewInternalClient string, NewEnabled bool, NewPortMappingDescription string, NewLeaseDuration uint32) (err error) {
// Request structure.
request := &struct {
@@ -5194,15 +5310,11 @@ func (client *WANPPPConnection1) AddPortMapping(NewRemoteHost string, NewExterna
return
}
-// Arguments:
-//
-// * NewRemoteHost:
//
-// * NewExternalPort:
+// Arguments:
//
// * NewProtocol: allowed values: TCP, UDP
-//
-//
+
func (client *WANPPPConnection1) DeletePortMapping(NewRemoteHost string, NewExternalPort uint16, NewProtocol string) (err error) {
// Request structure.
request := &struct {
@@ -5239,11 +5351,6 @@ func (client *WANPPPConnection1) DeletePortMapping(NewRemoteHost string, NewExte
return
}
-//
-//
-// Return values:
-//
-// * NewExternalIPAddress:
func (client *WANPPPConnection1) GetExternalIPAddress() (NewExternalIPAddress string, err error) {
// Request structure.
request := interface{}(nil)
diff --git a/Godeps/_workspace/src/github.com/huin/goupnp/example/example_test.go b/Godeps/_workspace/src/github.com/huin/goupnp/example/example_test.go
deleted file mode 100644
index 1f3667df7..000000000
--- a/Godeps/_workspace/src/github.com/huin/goupnp/example/example_test.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package example_test
-
-import (
- "fmt"
- "os"
-
- "github.com/huin/goupnp"
- "github.com/huin/goupnp/dcps/internetgateway1"
-)
-
-// Use discovered WANPPPConnection1 services to find external IP addresses.
-func Example_WANPPPConnection1_GetExternalIPAddress() {
- clients, errors, err := internetgateway1.NewWANPPPConnection1Clients()
- extIPClients := make([]GetExternalIPAddresser, len(clients))
- for i, client := range clients {
- extIPClients[i] = client
- }
- DisplayExternalIPResults(extIPClients, errors, err)
- // Output:
-}
-
-// Use discovered WANIPConnection services to find external IP addresses.
-func Example_WANIPConnection_GetExternalIPAddress() {
- clients, errors, err := internetgateway1.NewWANIPConnection1Clients()
- extIPClients := make([]GetExternalIPAddresser, len(clients))
- for i, client := range clients {
- extIPClients[i] = client
- }
- DisplayExternalIPResults(extIPClients, errors, err)
- // Output:
-}
-
-type GetExternalIPAddresser interface {
- GetExternalIPAddress() (NewExternalIPAddress string, err error)
- GetServiceClient() *goupnp.ServiceClient
-}
-
-func DisplayExternalIPResults(clients []GetExternalIPAddresser, errors []error, err error) {
- if err != nil {
- fmt.Fprintln(os.Stderr, "Error discovering service with UPnP: ", err)
- return
- }
-
- if len(errors) > 0 {
- fmt.Fprintf(os.Stderr, "Error discovering %d services:\n", len(errors))
- for _, err := range errors {
- fmt.Println(" ", err)
- }
- }
-
- fmt.Fprintf(os.Stderr, "Successfully discovered %d services:\n", len(clients))
- for _, client := range clients {
- device := &client.GetServiceClient().RootDevice.Device
-
- fmt.Fprintln(os.Stderr, " Device:", device.FriendlyName)
- if addr, err := client.GetExternalIPAddress(); err != nil {
- fmt.Fprintf(os.Stderr, " Failed to get external IP address: %v\n", err)
- } else {
- fmt.Fprintf(os.Stderr, " External IP address: %v\n", addr)
- }
- }
-}
diff --git a/Godeps/_workspace/src/github.com/huin/goupnp/gotasks/specgen_task.go b/Godeps/_workspace/src/github.com/huin/goupnp/gotasks/specgen_task.go
index 0ac1d4ff3..921e8c857 100644
--- a/Godeps/_workspace/src/github.com/huin/goupnp/gotasks/specgen_task.go
+++ b/Godeps/_workspace/src/github.com/huin/goupnp/gotasks/specgen_task.go
@@ -4,12 +4,11 @@ package gotasks
import (
"archive/zip"
- "bytes"
"encoding/xml"
"fmt"
"io"
- "io/ioutil"
"log"
+ "net/http"
"os"
"path"
"path/filepath"
@@ -28,6 +27,53 @@ var (
serviceURNPrefix = "urn:schemas-upnp-org:service:"
)
+// DCP contains extra metadata to use when generating DCP source files.
+type DCPMetadata struct {
+ Name string // What to name the Go DCP package.
+ OfficialName string // Official name for the DCP.
+ DocURL string // Optional - URL for futher documentation about the DCP.
+ XMLSpecURL string // Where to download the XML spec from.
+ // Any special-case functions to run against the DCP before writing it out.
+ Hacks []DCPHackFn
+}
+
+var dcpMetadata = []DCPMetadata{
+ {
+ Name: "internetgateway1",
+ OfficialName: "Internet Gateway Device v1",
+ DocURL: "http://upnp.org/specs/gw/UPnP-gw-InternetGatewayDevice-v1-Device.pdf",
+ XMLSpecURL: "http://upnp.org/specs/gw/UPnP-gw-IGD-TestFiles-20010921.zip",
+ },
+ {
+ Name: "internetgateway2",
+ OfficialName: "Internet Gateway Device v2",
+ DocURL: "http://upnp.org/specs/gw/UPnP-gw-InternetGatewayDevice-v2-Device.pdf",
+ XMLSpecURL: "http://upnp.org/specs/gw/UPnP-gw-IGD-Testfiles-20110224.zip",
+ Hacks: []DCPHackFn{
+ func(dcp *DCP) error {
+ missingURN := "urn:schemas-upnp-org:service:WANIPv6FirewallControl:1"
+ if _, ok := dcp.ServiceTypes[missingURN]; ok {
+ return nil
+ }
+ urnParts, err := extractURNParts(missingURN, serviceURNPrefix)
+ if err != nil {
+ return err
+ }
+ dcp.ServiceTypes[missingURN] = urnParts
+ return nil
+ },
+ },
+ },
+ {
+ Name: "av1",
+ OfficialName: "MediaServer v1 and MediaRenderer v1",
+ DocURL: "http://upnp.org/specs/av/av1/",
+ XMLSpecURL: "http://upnp.org/specs/av/UPnP-av-TestFiles-20070927.zip",
+ },
+}
+
+type DCPHackFn func(*DCP) error
+
// NAME
// specgen - generates Go code from the UPnP specification files.
//
@@ -35,104 +81,90 @@ var (
// The specification is available for download from:
//
// OPTIONS
-// -s, --spec_filename=<upnpresources.zip>
-// Path to the specification file, available from http://upnp.org/resources/upnpresources.zip
+// -s, --specs_dir=<spec directory>
+// Path to the specification storage directory. This is used to find (and download if not present) the specification ZIP files. Defaults to 'specs'
// -o, --out_dir=<output directory>
-// Path to the output directory. This is is where the DCP source files will be placed. Should normally correspond to the directory for github.com/huin/goupnp/dcps
+// Path to the output directory. This is is where the DCP source files will be placed. Should normally correspond to the directory for github.com/huin/goupnp/dcps. Defaults to '../dcps'
// --nogofmt
// Disable passing the output through gofmt. Do this if debugging code output problems and needing to see the generated code prior to being passed through gofmt.
func TaskSpecgen(t *tasking.T) {
- specFilename := t.Flags.String("spec-filename")
- if specFilename == "" {
- specFilename = t.Flags.String("s")
- }
- if specFilename == "" {
- t.Fatal("--spec_filename is required")
- }
- outDir := t.Flags.String("out-dir")
- if outDir == "" {
- outDir = t.Flags.String("o")
- }
- if outDir == "" {
- log.Fatal("--out_dir is required")
+ specsDir := fallbackStrValue("specs", t.Flags.String("specs_dir"), t.Flags.String("s"))
+ if err := os.MkdirAll(specsDir, os.ModePerm); err != nil {
+ t.Fatalf("Could not create specs-dir %q: %v\n", specsDir, err)
}
+ outDir := fallbackStrValue("../dcps", t.Flags.String("out_dir"), t.Flags.String("o"))
useGofmt := !t.Flags.Bool("nogofmt")
- specArchive, err := openZipfile(specFilename)
- if err != nil {
- t.Fatalf("Error opening spec file: %v", err)
- }
- defer specArchive.Close()
-
- dcpCol := newDcpsCollection()
- for _, f := range globFiles("standardizeddcps/*/*.zip", specArchive.Reader) {
- dirName := strings.TrimPrefix(f.Name, "standardizeddcps/")
- slashIndex := strings.Index(dirName, "/")
- if slashIndex == -1 {
- // Should not happen.
- t.Logf("Could not find / in %q", dirName)
- return
+NEXT_DCP:
+ for _, d := range dcpMetadata {
+ specFilename := filepath.Join(specsDir, d.Name+".zip")
+ err := acquireFile(specFilename, d.XMLSpecURL)
+ if err != nil {
+ t.Logf("Could not acquire spec for %s, skipping: %v\n", d.Name, err)
+ continue NEXT_DCP
}
- dirName = dirName[:slashIndex]
-
- dcp := dcpCol.dcpForDir(dirName)
- if dcp == nil {
- t.Logf("No alias defined for directory %q: skipping %s\n", dirName, f.Name)
- continue
- } else {
- t.Logf("Alias found for directory %q: processing %s\n", dirName, f.Name)
+ dcp := newDCP(d)
+ if err := dcp.processZipFile(specFilename); err != nil {
+ log.Printf("Error processing spec for %s in file %q: %v", d.Name, specFilename, err)
+ continue NEXT_DCP
}
-
- dcp.processZipFile(f)
- }
-
- for _, dcp := range dcpCol.dcpByAlias {
+ for i, hack := range d.Hacks {
+ if err := hack(dcp); err != nil {
+ log.Printf("Error with Hack[%d] for %s: %v", i, d.Name, err)
+ continue NEXT_DCP
+ }
+ }
+ dcp.writePackage(outDir, useGofmt)
if err := dcp.writePackage(outDir, useGofmt); err != nil {
log.Printf("Error writing package %q: %v", dcp.Metadata.Name, err)
+ continue NEXT_DCP
}
}
}
-// DCP contains extra metadata to use when generating DCP source files.
-type DCPMetadata struct {
- Name string // What to name the Go DCP package.
- OfficialName string // Official name for the DCP.
- DocURL string // Optional - URL for futher documentation about the DCP.
+func fallbackStrValue(defaultValue string, values ...string) string {
+ for _, v := range values {
+ if v != "" {
+ return v
+ }
+ }
+ return defaultValue
}
-var dcpMetadataByDir = map[string]DCPMetadata{
- "Internet Gateway_1": {
- Name: "internetgateway1",
- OfficialName: "Internet Gateway Device v1",
- DocURL: "http://upnp.org/specs/gw/UPnP-gw-InternetGatewayDevice-v1-Device.pdf",
- },
- "Internet Gateway_2": {
- Name: "internetgateway2",
- OfficialName: "Internet Gateway Device v2",
- DocURL: "http://upnp.org/specs/gw/UPnP-gw-InternetGatewayDevice-v2-Device.pdf",
- },
-}
+func acquireFile(specFilename string, xmlSpecURL string) error {
+ if f, err := os.Open(specFilename); err != nil {
+ if !os.IsNotExist(err) {
+ return err
+ }
+ } else {
+ f.Close()
+ return nil
+ }
-type dcpCollection struct {
- dcpByAlias map[string]*DCP
-}
+ resp, err := http.Get(xmlSpecURL)
+ if err != nil {
+ return err
+ }
+ defer resp.Body.Close()
-func newDcpsCollection() *dcpCollection {
- c := &dcpCollection{
- dcpByAlias: make(map[string]*DCP),
+ if resp.StatusCode != http.StatusOK {
+ return fmt.Errorf("could not download spec %q from %q: ",
+ specFilename, xmlSpecURL, resp.Status)
}
- for _, metadata := range dcpMetadataByDir {
- c.dcpByAlias[metadata.Name] = newDCP(metadata)
+
+ tmpFilename := specFilename + ".download"
+ w, err := os.Create(tmpFilename)
+ if err != nil {
+ return err
}
- return c
-}
+ defer w.Close()
-func (c *dcpCollection) dcpForDir(dirName string) *DCP {
- metadata, ok := dcpMetadataByDir[dirName]
- if !ok {
- return nil
+ _, err = io.Copy(w, resp.Body)
+ if err != nil {
+ return err
}
- return c.dcpByAlias[metadata.Name]
+
+ return os.Rename(tmpFilename, specFilename)
}
// DCP collects together information about a UPnP Device Control Protocol.
@@ -151,33 +183,37 @@ func newDCP(metadata DCPMetadata) *DCP {
}
}
-func (dcp *DCP) processZipFile(file *zip.File) {
- archive, err := openChildZip(file)
+func (dcp *DCP) processZipFile(filename string) error {
+ archive, err := zip.OpenReader(filename)
if err != nil {
- log.Println("Error reading child zip file:", err)
- return
+ return fmt.Errorf("error reading zip file %q: %v", filename, err)
}
+ defer archive.Close()
for _, deviceFile := range globFiles("*/device/*.xml", archive) {
- dcp.processDeviceFile(deviceFile)
+ if err := dcp.processDeviceFile(deviceFile); err != nil {
+ return err
+ }
}
for _, scpdFile := range globFiles("*/service/*.xml", archive) {
- dcp.processSCPDFile(scpdFile)
+ if err := dcp.processSCPDFile(scpdFile); err != nil {
+ return err
+ }
}
+ return nil
}
-func (dcp *DCP) processDeviceFile(file *zip.File) {
+func (dcp *DCP) processDeviceFile(file *zip.File) error {
var device goupnp.Device
if err := unmarshalXmlFile(file, &device); err != nil {
- log.Printf("Error decoding device XML from file %q: %v", file.Name, err)
- return
+ return fmt.Errorf("error decoding device XML from file %q: %v", file.Name, err)
}
+ var mainErr error
device.VisitDevices(func(d *goupnp.Device) {
t := strings.TrimSpace(d.DeviceType)
if t != "" {
u, err := extractURNParts(t, deviceURNPrefix)
if err != nil {
- log.Println(err)
- return
+ mainErr = err
}
dcp.DeviceTypes[t] = u
}
@@ -185,11 +221,11 @@ func (dcp *DCP) processDeviceFile(file *zip.File) {
device.VisitServices(func(s *goupnp.Service) {
u, err := extractURNParts(s.ServiceType, serviceURNPrefix)
if err != nil {
- log.Println(err)
- return
+ mainErr = err
}
dcp.ServiceTypes[s.ServiceType] = u
})
+ return mainErr
}
func (dcp *DCP) writePackage(outDir string, useGofmt bool) error {
@@ -217,22 +253,21 @@ func (dcp *DCP) writePackage(outDir string, useGofmt bool) error {
return output.Close()
}
-func (dcp *DCP) processSCPDFile(file *zip.File) {
+func (dcp *DCP) processSCPDFile(file *zip.File) error {
scpd := new(scpd.SCPD)
if err := unmarshalXmlFile(file, scpd); err != nil {
- log.Printf("Error decoding SCPD XML from file %q: %v", file.Name, err)
- return
+ return fmt.Errorf("error decoding SCPD XML from file %q: %v", file.Name, err)
}
scpd.Clean()
urnParts, err := urnPartsFromSCPDFilename(file.Name)
if err != nil {
- log.Printf("Could not recognize SCPD filename %q: %v", file.Name, err)
- return
+ return fmt.Errorf("could not recognize SCPD filename %q: %v", file.Name, err)
}
dcp.Services = append(dcp.Services, SCPDWithURN{
URNParts: urnParts,
SCPD: scpd,
})
+ return nil
}
type SCPDWithURN struct {
@@ -240,7 +275,19 @@ type SCPDWithURN struct {
SCPD *scpd.SCPD
}
-func (s *SCPDWithURN) WrapArgument(arg scpd.Argument) (*argumentWrapper, error) {
+func (s *SCPDWithURN) WrapArguments(args []*scpd.Argument) (argumentWrapperList, error) {
+ wrappedArgs := make(argumentWrapperList, len(args))
+ for i, arg := range args {
+ wa, err := s.wrapArgument(arg)
+ if err != nil {
+ return nil, err
+ }
+ wrappedArgs[i] = wa
+ }
+ return wrappedArgs, nil
+}
+
+func (s *SCPDWithURN) wrapArgument(arg *scpd.Argument) (*argumentWrapper, error) {
relVar := s.SCPD.GetStateVariable(arg.RelatedStateVariable)
if relVar == nil {
return nil, fmt.Errorf("no such state variable: %q, for argument %q", arg.RelatedStateVariable, arg.Name)
@@ -250,7 +297,7 @@ func (s *SCPDWithURN) WrapArgument(arg scpd.Argument) (*argumentWrapper, error)
return nil, fmt.Errorf("unknown data type: %q, for state variable %q, for argument %q", relVar.DataType.Type, arg.RelatedStateVariable, arg.Name)
}
return &argumentWrapper{
- Argument: arg,
+ Argument: *arg,
relVar: relVar,
conv: cnv,
}, nil
@@ -266,6 +313,12 @@ func (arg *argumentWrapper) AsParameter() string {
return fmt.Sprintf("%s %s", arg.Name, arg.conv.ExtType)
}
+func (arg *argumentWrapper) HasDoc() bool {
+ rng := arg.relVar.AllowedValueRange
+ return ((rng != nil && (rng.Minimum != "" || rng.Maximum != "" || rng.Step != "")) ||
+ len(arg.relVar.AllowedValues) > 0)
+}
+
func (arg *argumentWrapper) Document() string {
relVar := arg.relVar
if rng := relVar.AllowedValueRange; rng != nil {
@@ -295,6 +348,17 @@ func (arg *argumentWrapper) Unmarshal(objVar string) string {
return fmt.Sprintf("soap.Unmarshal%s(%s.%s)", arg.conv.FuncSuffix, objVar, arg.Name)
}
+type argumentWrapperList []*argumentWrapper
+
+func (args argumentWrapperList) HasDoc() bool {
+ for _, arg := range args {
+ if arg.HasDoc() {
+ return true
+ }
+ }
+ return false
+}
+
type conv struct {
FuncSuffix string
ExtType string
@@ -325,49 +389,10 @@ var typeConvs = map[string]conv{
"boolean": conv{"Boolean", "bool"},
"bin.base64": conv{"BinBase64", "[]byte"},
"bin.hex": conv{"BinHex", "[]byte"},
+ "uri": conv{"URI", "*url.URL"},
}
-type closeableZipReader struct {
- io.Closer
- *zip.Reader
-}
-
-func openZipfile(filename string) (*closeableZipReader, error) {
- file, err := os.Open(filename)
- if err != nil {
- return nil, err
- }
- fi, err := file.Stat()
- if err != nil {
- return nil, err
- }
- archive, err := zip.NewReader(file, fi.Size())
- if err != nil {
- return nil, err
- }
- return &closeableZipReader{
- Closer: file,
- Reader: archive,
- }, nil
-}
-
-// openChildZip opens a zip file within another zip file.
-func openChildZip(file *zip.File) (*zip.Reader, error) {
- zipFile, err := file.Open()
- if err != nil {
- return nil, err
- }
- defer zipFile.Close()
-
- zipBytes, err := ioutil.ReadAll(zipFile)
- if err != nil {
- return nil, err
- }
-
- return zip.NewReader(bytes.NewReader(zipBytes), int64(len(zipBytes)))
-}
-
-func globFiles(pattern string, archive *zip.Reader) []*zip.File {
+func globFiles(pattern string, archive *zip.ReadCloser) []*zip.File {
var files []*zip.File
for _, f := range archive.File {
if matched, err := path.Match(pattern, f.Name); err != nil {
@@ -435,14 +460,14 @@ var packageTmpl = template.Must(template.New("package").Parse(`{{$name := .Metad
// {{if .Metadata.DocURL}}
// This DCP is documented in detail at: {{.Metadata.DocURL}}{{end}}
//
-// Typically, use one of the New* functions to discover services on the local
-// network.
+// Typically, use one of the New* functions to create clients for services.
package {{$name}}
// Generated file - do not edit by hand. See README.md
import (
+ "net/url"
"time"
"github.com/huin/goupnp"
@@ -484,38 +509,77 @@ func New{{$srvIdent}}Clients() (clients []*{{$srvIdent}}, errors []error, err er
if genericClients, errors, err = goupnp.NewServiceClients({{$srv.Const}}); err != nil {
return
}
- clients = make([]*{{$srvIdent}}, len(genericClients))
+ clients = new{{$srvIdent}}ClientsFromGenericClients(genericClients)
+ return
+}
+
+// New{{$srvIdent}}ClientsByURL discovers instances of the service at the given
+// URL, and returns clients to any that are found. An error is returned if
+// there was an error probing the service.
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered service URL.
+func New{{$srvIdent}}ClientsByURL(loc *url.URL) ([]*{{$srvIdent}}, error) {
+ genericClients, err := goupnp.NewServiceClientsByURL(loc, {{$srv.Const}})
+ if err != nil {
+ return nil, err
+ }
+ return new{{$srvIdent}}ClientsFromGenericClients(genericClients), nil
+}
+
+// New{{$srvIdent}}ClientsFromRootDevice discovers instances of the service in
+// a given root device, and returns clients to any that are found. An error is
+// returned if there was not at least one instance of the service within the
+// device. The location parameter is simply assigned to the Location attribute
+// of the wrapped ServiceClient(s).
+//
+// This is a typical entry calling point into this package when reusing an
+// previously discovered root device.
+func New{{$srvIdent}}ClientsFromRootDevice(rootDevice *goupnp.RootDevice, loc *url.URL) ([]*{{$srvIdent}}, error) {
+ genericClients, err := goupnp.NewServiceClientsFromRootDevice(rootDevice, loc, {{$srv.Const}})
+ if err != nil {
+ return nil, err
+ }
+ return new{{$srvIdent}}ClientsFromGenericClients(genericClients), nil
+}
+
+func new{{$srvIdent}}ClientsFromGenericClients(genericClients []goupnp.ServiceClient) []*{{$srvIdent}} {
+ clients := make([]*{{$srvIdent}}, len(genericClients))
for i := range genericClients {
clients[i] = &{{$srvIdent}}{genericClients[i]}
}
- return
+ return clients
}
{{range .SCPD.Actions}}{{/* loops over *SCPDWithURN values */}}
-{{$inargs := .InputArguments}}{{$outargs := .OutputArguments}}
-// {{if $inargs}}Arguments:{{range $inargs}}{{$argWrap := $srv.WrapArgument .}}
+{{$winargs := $srv.WrapArguments .InputArguments}}
+{{$woutargs := $srv.WrapArguments .OutputArguments}}
+{{if $winargs.HasDoc}}
+//
+// Arguments:{{range $winargs}}{{if .HasDoc}}
//
-// * {{.Name}}: {{$argWrap.Document}}{{end}}{{end}}
+// * {{.Name}}: {{.Document}}{{end}}{{end}}{{end}}
+{{if $woutargs.HasDoc}}
//
-// {{if $outargs}}Return values:{{range $outargs}}{{$argWrap := $srv.WrapArgument .}}
+// Return values:{{range $woutargs}}{{if .HasDoc}}
//
-// * {{.Name}}: {{$argWrap.Document}}{{end}}{{end}}
-func (client *{{$srvIdent}}) {{.Name}}({{range $inargs}}{{/*
-*/}}{{$argWrap := $srv.WrapArgument .}}{{$argWrap.AsParameter}}, {{end}}{{/*
-*/}}) ({{range $outargs}}{{/*
-*/}}{{$argWrap := $srv.WrapArgument .}}{{$argWrap.AsParameter}}, {{end}} err error) {
+// * {{.Name}}: {{.Document}}{{end}}{{end}}{{end}}
+func (client *{{$srvIdent}}) {{.Name}}({{range $winargs}}{{/*
+*/}}{{.AsParameter}}, {{end}}{{/*
+*/}}) ({{range $woutargs}}{{/*
+*/}}{{.AsParameter}}, {{end}} err error) {
// Request structure.
- request := {{if $inargs}}&{{template "argstruct" $inargs}}{{"{}"}}{{else}}{{"interface{}(nil)"}}{{end}}
+ request := {{if $winargs}}&{{template "argstruct" $winargs}}{{"{}"}}{{else}}{{"interface{}(nil)"}}{{end}}
// BEGIN Marshal arguments into request.
-{{range $inargs}}{{$argWrap := $srv.WrapArgument .}}
- if request.{{.Name}}, err = {{$argWrap.Marshal}}; err != nil {
+{{range $winargs}}
+ if request.{{.Name}}, err = {{.Marshal}}; err != nil {
return
}{{end}}
// END Marshal arguments into request.
// Response structure.
- response := {{if $outargs}}&{{template "argstruct" $outargs}}{{"{}"}}{{else}}{{"interface{}(nil)"}}{{end}}
+ response := {{if $woutargs}}&{{template "argstruct" $woutargs}}{{"{}"}}{{else}}{{"interface{}(nil)"}}{{end}}
// Perform the SOAP call.
if err = client.SOAPClient.PerformAction({{$srv.URNParts.Const}}, "{{.Name}}", request, response); err != nil {
@@ -523,8 +587,8 @@ func (client *{{$srvIdent}}) {{.Name}}({{range $inargs}}{{/*
}
// BEGIN Unmarshal arguments from response.
-{{range $outargs}}{{$argWrap := $srv.WrapArgument .}}
- if {{.Name}}, err = {{$argWrap.Unmarshal "response"}}; err != nil {
+{{range $woutargs}}
+ if {{.Name}}, err = {{.Unmarshal "response"}}; err != nil {
return
}{{end}}
// END Unmarshal arguments from response.
diff --git a/Godeps/_workspace/src/github.com/huin/goupnp/goupnp.go b/Godeps/_workspace/src/github.com/huin/goupnp/goupnp.go
index 7799a32ce..fcb8dcd23 100644
--- a/Godeps/_workspace/src/github.com/huin/goupnp/goupnp.go
+++ b/Godeps/_workspace/src/github.com/huin/goupnp/goupnp.go
@@ -20,6 +20,7 @@ import (
"net/http"
"net/url"
"time"
+
"golang.org/x/net/html/charset"
"github.com/huin/goupnp/httpu"
@@ -38,8 +39,16 @@ func (err ContextError) Error() string {
// MaybeRootDevice contains either a RootDevice or an error.
type MaybeRootDevice struct {
+ // Set iff Err == nil.
Root *RootDevice
- Err error
+
+ // The location the device was discovered at. This can be used with
+ // DeviceByURL, assuming the device is still present. A location represents
+ // the discovery of a device, regardless of if there was an error probing it.
+ Location *url.URL
+
+ // Any error encountered probing a discovered device.
+ Err error
}
// DiscoverDevices attempts to find targets of the given type. This is
@@ -67,30 +76,37 @@ func DiscoverDevices(searchTarget string) ([]MaybeRootDevice, error) {
maybe.Err = ContextError{"unexpected bad location from search", err}
continue
}
- locStr := loc.String()
- root := new(RootDevice)
- if err := requestXml(locStr, DeviceXMLNamespace, root); err != nil {
- maybe.Err = ContextError{fmt.Sprintf("error requesting root device details from %q", locStr), err}
- continue
- }
- var urlBaseStr string
- if root.URLBaseStr != "" {
- urlBaseStr = root.URLBaseStr
+ maybe.Location = loc
+ if root, err := DeviceByURL(loc); err != nil {
+ maybe.Err = err
} else {
- urlBaseStr = locStr
- }
- urlBase, err := url.Parse(urlBaseStr)
- if err != nil {
- maybe.Err = ContextError{fmt.Sprintf("error parsing location URL %q", locStr), err}
- continue
+ maybe.Root = root
}
- root.SetURLBase(urlBase)
- maybe.Root = root
}
return results, nil
}
+func DeviceByURL(loc *url.URL) (*RootDevice, error) {
+ locStr := loc.String()
+ root := new(RootDevice)
+ if err := requestXml(locStr, DeviceXMLNamespace, root); err != nil {
+ return nil, ContextError{fmt.Sprintf("error requesting root device details from %q", locStr), err}
+ }
+ var urlBaseStr string
+ if root.URLBaseStr != "" {
+ urlBaseStr = root.URLBaseStr
+ } else {
+ urlBaseStr = locStr
+ }
+ urlBase, err := url.Parse(urlBaseStr)
+ if err != nil {
+ return nil, ContextError{fmt.Sprintf("error parsing location URL %q", locStr), err}
+ }
+ root.SetURLBase(urlBase)
+ return root, nil
+}
+
func requestXml(url string, defaultSpace string, doc interface{}) error {
timeout := time.Duration(3 * time.Second)
client := http.Client{
diff --git a/Godeps/_workspace/src/github.com/huin/goupnp/service_client.go b/Godeps/_workspace/src/github.com/huin/goupnp/service_client.go
index c0d16ce2a..9111c93cb 100644
--- a/Godeps/_workspace/src/github.com/huin/goupnp/service_client.go
+++ b/Godeps/_workspace/src/github.com/huin/goupnp/service_client.go
@@ -2,18 +2,26 @@ package goupnp
import (
"fmt"
+ "net/url"
+
"github.com/huin/goupnp/soap"
)
// ServiceClient is a SOAP client, root device and the service for the SOAP
-// client rolled into one value. The root device and service are intended to be
-// informational.
+// client rolled into one value. The root device, location, and service are
+// intended to be informational. Location can be used to later recreate a
+// ServiceClient with NewServiceClientByURL if the service is still present;
+// bypassing the discovery process.
type ServiceClient struct {
SOAPClient *soap.SOAPClient
RootDevice *RootDevice
+ Location *url.URL
Service *Service
}
+// NewServiceClients discovers services, and returns clients for them. err will
+// report any error with the discovery process (blocking any device/service
+// discovery), errors reports errors on a per-root-device basis.
func NewServiceClients(searchTarget string) (clients []ServiceClient, errors []error, err error) {
var maybeRootDevices []MaybeRootDevice
if maybeRootDevices, err = DiscoverDevices(searchTarget); err != nil {
@@ -28,26 +36,50 @@ func NewServiceClients(searchTarget string) (clients []ServiceClient, errors []e
continue
}
- device := &maybeRootDevice.Root.Device
- srvs := device.FindService(searchTarget)
- if len(srvs) == 0 {
- errors = append(errors, fmt.Errorf("goupnp: service %q not found within device %q (UDN=%q)",
- searchTarget, device.FriendlyName, device.UDN))
+ deviceClients, err := NewServiceClientsFromRootDevice(maybeRootDevice.Root, maybeRootDevice.Location, searchTarget)
+ if err != nil {
+ errors = append(errors, err)
continue
}
-
- for _, srv := range srvs {
- clients = append(clients, ServiceClient{
- SOAPClient: srv.NewSOAPClient(),
- RootDevice: maybeRootDevice.Root,
- Service: srv,
- })
- }
+ clients = append(clients, deviceClients...)
}
return
}
+// NewServiceClientsByURL creates client(s) for the given service URN, for a
+// root device at the given URL.
+func NewServiceClientsByURL(loc *url.URL, searchTarget string) ([]ServiceClient, error) {
+ rootDevice, err := DeviceByURL(loc)
+ if err != nil {
+ return nil, err
+ }
+ return NewServiceClientsFromRootDevice(rootDevice, loc, searchTarget)
+}
+
+// NewServiceClientsFromDevice creates client(s) for the given service URN, in
+// a given root device. The loc parameter is simply assigned to the
+// Location attribute of the returned ServiceClient(s).
+func NewServiceClientsFromRootDevice(rootDevice *RootDevice, loc *url.URL, searchTarget string) ([]ServiceClient, error) {
+ device := &rootDevice.Device
+ srvs := device.FindService(searchTarget)
+ if len(srvs) == 0 {
+ return nil, fmt.Errorf("goupnp: service %q not found within device %q (UDN=%q)",
+ searchTarget, device.FriendlyName, device.UDN)
+ }
+
+ clients := make([]ServiceClient, 0, len(srvs))
+ for _, srv := range srvs {
+ clients = append(clients, ServiceClient{
+ SOAPClient: srv.NewSOAPClient(),
+ RootDevice: rootDevice,
+ Location: loc,
+ Service: srv,
+ })
+ }
+ return clients, nil
+}
+
// GetServiceClient returns the ServiceClient itself. This is provided so that the
// service client attributes can be accessed via an interface method on a
// wrapping type.
diff --git a/Godeps/_workspace/src/github.com/huin/goupnp/soap/soap_test.go b/Godeps/_workspace/src/github.com/huin/goupnp/soap/soap_test.go
deleted file mode 100644
index 75dbbdbf1..000000000
--- a/Godeps/_workspace/src/github.com/huin/goupnp/soap/soap_test.go
+++ /dev/null
@@ -1,85 +0,0 @@
-package soap
-
-import (
- "bytes"
- "io/ioutil"
- "net/http"
- "net/url"
- "reflect"
- "testing"
-)
-
-type capturingRoundTripper struct {
- err error
- resp *http.Response
- capturedReq *http.Request
-}
-
-func (rt *capturingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
- rt.capturedReq = req
- return rt.resp, rt.err
-}
-
-func TestActionInputs(t *testing.T) {
- url, err := url.Parse("http://example.com/soap")
- if err != nil {
- t.Fatal(err)
- }
- rt := &capturingRoundTripper{
- err: nil,
- resp: &http.Response{
- StatusCode: 200,
- Body: ioutil.NopCloser(bytes.NewBufferString(`
- <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
- <s:Body>
- <u:myactionResponse xmlns:u="mynamespace">
- <A>valueA</A>
- <B>valueB</B>
- </u:myactionResponse>
- </s:Body>
- </s:Envelope>
- `)),
- },
- }
- client := SOAPClient{
- EndpointURL: *url,
- HTTPClient: http.Client{
- Transport: rt,
- },
- }
-
- type In struct {
- Foo string
- Bar string `soap:"bar"`
- }
- type Out struct {
- A string
- B string
- }
- in := In{"foo", "bar"}
- gotOut := Out{}
- err = client.PerformAction("mynamespace", "myaction", &in, &gotOut)
- if err != nil {
- t.Fatal(err)
- }
-
- wantBody := (soapPrefix +
- `<u:myaction xmlns:u="mynamespace">` +
- `<Foo>foo</Foo>` +
- `<bar>bar</bar>` +
- `</u:myaction>` +
- soapSuffix)
- body, err := ioutil.ReadAll(rt.capturedReq.Body)
- if err != nil {
- t.Fatal(err)
- }
- gotBody := string(body)
- if wantBody != gotBody {
- t.Errorf("Bad request body\nwant: %q\n got: %q", wantBody, gotBody)
- }
-
- wantOut := Out{"valueA", "valueB"}
- if !reflect.DeepEqual(wantOut, gotOut) {
- t.Errorf("Bad output\nwant: %+v\n got: %+v", wantOut, gotOut)
- }
-}
diff --git a/Godeps/_workspace/src/github.com/huin/goupnp/soap/types.go b/Godeps/_workspace/src/github.com/huin/goupnp/soap/types.go
index cd16510e3..fdbeec8d4 100644
--- a/Godeps/_workspace/src/github.com/huin/goupnp/soap/types.go
+++ b/Godeps/_workspace/src/github.com/huin/goupnp/soap/types.go
@@ -5,6 +5,7 @@ import (
"encoding/hex"
"errors"
"fmt"
+ "net/url"
"regexp"
"strconv"
"strings"
@@ -506,3 +507,13 @@ func MarshalBinHex(v []byte) (string, error) {
func UnmarshalBinHex(s string) ([]byte, error) {
return hex.DecodeString(s)
}
+
+// MarshalURI marshals *url.URL to SOAP "uri" type.
+func MarshalURI(v *url.URL) (string, error) {
+ return v.String(), nil
+}
+
+// UnmarshalURI unmarshals *url.URL from the SOAP "uri" type.
+func UnmarshalURI(s string) (*url.URL, error) {
+ return url.Parse(s)
+}
diff --git a/Godeps/_workspace/src/github.com/huin/goupnp/soap/types_test.go b/Godeps/_workspace/src/github.com/huin/goupnp/soap/types_test.go
deleted file mode 100644
index da6816190..000000000
--- a/Godeps/_workspace/src/github.com/huin/goupnp/soap/types_test.go
+++ /dev/null
@@ -1,481 +0,0 @@
-package soap
-
-import (
- "bytes"
- "math"
- "testing"
- "time"
-)
-
-type convTest interface {
- Marshal() (string, error)
- Unmarshal(string) (interface{}, error)
- Equal(result interface{}) bool
-}
-
-// duper is an interface that convTest values may optionally also implement to
-// generate another convTest for a value in an otherwise identical testCase.
-type duper interface {
- Dupe(tag string) []convTest
-}
-
-type testCase struct {
- value convTest
- str string
- wantMarshalErr bool
- wantUnmarshalErr bool
- noMarshal bool
- noUnMarshal bool
- tag string
-}
-
-type Ui1Test uint8
-
-func (v Ui1Test) Marshal() (string, error) {
- return MarshalUi1(uint8(v))
-}
-func (v Ui1Test) Unmarshal(s string) (interface{}, error) {
- return UnmarshalUi1(s)
-}
-func (v Ui1Test) Equal(result interface{}) bool {
- return uint8(v) == result.(uint8)
-}
-func (v Ui1Test) Dupe(tag string) []convTest {
- if tag == "dupe" {
- return []convTest{
- Ui2Test(v),
- Ui4Test(v),
- }
- }
- return nil
-}
-
-type Ui2Test uint16
-
-func (v Ui2Test) Marshal() (string, error) {
- return MarshalUi2(uint16(v))
-}
-func (v Ui2Test) Unmarshal(s string) (interface{}, error) {
- return UnmarshalUi2(s)
-}
-func (v Ui2Test) Equal(result interface{}) bool {
- return uint16(v) == result.(uint16)
-}
-
-type Ui4Test uint32
-
-func (v Ui4Test) Marshal() (string, error) {
- return MarshalUi4(uint32(v))
-}
-func (v Ui4Test) Unmarshal(s string) (interface{}, error) {
- return UnmarshalUi4(s)
-}
-func (v Ui4Test) Equal(result interface{}) bool {
- return uint32(v) == result.(uint32)
-}
-
-type I1Test int8
-
-func (v I1Test) Marshal() (string, error) {
- return MarshalI1(int8(v))
-}
-func (v I1Test) Unmarshal(s string) (interface{}, error) {
- return UnmarshalI1(s)
-}
-func (v I1Test) Equal(result interface{}) bool {
- return int8(v) == result.(int8)
-}
-func (v I1Test) Dupe(tag string) []convTest {
- if tag == "dupe" {
- return []convTest{
- I2Test(v),
- I4Test(v),
- }
- }
- return nil
-}
-
-type I2Test int16
-
-func (v I2Test) Marshal() (string, error) {
- return MarshalI2(int16(v))
-}
-func (v I2Test) Unmarshal(s string) (interface{}, error) {
- return UnmarshalI2(s)
-}
-func (v I2Test) Equal(result interface{}) bool {
- return int16(v) == result.(int16)
-}
-
-type I4Test int32
-
-func (v I4Test) Marshal() (string, error) {
- return MarshalI4(int32(v))
-}
-func (v I4Test) Unmarshal(s string) (interface{}, error) {
- return UnmarshalI4(s)
-}
-func (v I4Test) Equal(result interface{}) bool {
- return int32(v) == result.(int32)
-}
-
-type IntTest int64
-
-func (v IntTest) Marshal() (string, error) {
- return MarshalInt(int64(v))
-}
-func (v IntTest) Unmarshal(s string) (interface{}, error) {
- return UnmarshalInt(s)
-}
-func (v IntTest) Equal(result interface{}) bool {
- return int64(v) == result.(int64)
-}
-
-type Fixed14_4Test float64
-
-func (v Fixed14_4Test) Marshal() (string, error) {
- return MarshalFixed14_4(float64(v))
-}
-func (v Fixed14_4Test) Unmarshal(s string) (interface{}, error) {
- return UnmarshalFixed14_4(s)
-}
-func (v Fixed14_4Test) Equal(result interface{}) bool {
- return math.Abs(float64(v)-result.(float64)) < 0.001
-}
-
-type CharTest rune
-
-func (v CharTest) Marshal() (string, error) {
- return MarshalChar(rune(v))
-}
-func (v CharTest) Unmarshal(s string) (interface{}, error) {
- return UnmarshalChar(s)
-}
-func (v CharTest) Equal(result interface{}) bool {
- return rune(v) == result.(rune)
-}
-
-type DateTest struct{ time.Time }
-
-func (v DateTest) Marshal() (string, error) {
- return MarshalDate(time.Time(v.Time))
-}
-func (v DateTest) Unmarshal(s string) (interface{}, error) {
- return UnmarshalDate(s)
-}
-func (v DateTest) Equal(result interface{}) bool {
- return v.Time.Equal(result.(time.Time))
-}
-func (v DateTest) Dupe(tag string) []convTest {
- if tag != "no:dateTime" {
- return []convTest{DateTimeTest{v.Time}}
- }
- return nil
-}
-
-type TimeOfDayTest struct {
- TimeOfDay
-}
-
-func (v TimeOfDayTest) Marshal() (string, error) {
- return MarshalTimeOfDay(v.TimeOfDay)
-}
-func (v TimeOfDayTest) Unmarshal(s string) (interface{}, error) {
- return UnmarshalTimeOfDay(s)
-}
-func (v TimeOfDayTest) Equal(result interface{}) bool {
- return v.TimeOfDay == result.(TimeOfDay)
-}
-func (v TimeOfDayTest) Dupe(tag string) []convTest {
- if tag != "no:time.tz" {
- return []convTest{TimeOfDayTzTest{v.TimeOfDay}}
- }
- return nil
-}
-
-type TimeOfDayTzTest struct {
- TimeOfDay
-}
-
-func (v TimeOfDayTzTest) Marshal() (string, error) {
- return MarshalTimeOfDayTz(v.TimeOfDay)
-}
-func (v TimeOfDayTzTest) Unmarshal(s string) (interface{}, error) {
- return UnmarshalTimeOfDayTz(s)
-}
-func (v TimeOfDayTzTest) Equal(result interface{}) bool {
- return v.TimeOfDay == result.(TimeOfDay)
-}
-
-type DateTimeTest struct{ time.Time }
-
-func (v DateTimeTest) Marshal() (string, error) {
- return MarshalDateTime(time.Time(v.Time))
-}
-func (v DateTimeTest) Unmarshal(s string) (interface{}, error) {
- return UnmarshalDateTime(s)
-}
-func (v DateTimeTest) Equal(result interface{}) bool {
- return v.Time.Equal(result.(time.Time))
-}
-func (v DateTimeTest) Dupe(tag string) []convTest {
- if tag != "no:dateTime.tz" {
- return []convTest{DateTimeTzTest{v.Time}}
- }
- return nil
-}
-
-type DateTimeTzTest struct{ time.Time }
-
-func (v DateTimeTzTest) Marshal() (string, error) {
- return MarshalDateTimeTz(time.Time(v.Time))
-}
-func (v DateTimeTzTest) Unmarshal(s string) (interface{}, error) {
- return UnmarshalDateTimeTz(s)
-}
-func (v DateTimeTzTest) Equal(result interface{}) bool {
- return v.Time.Equal(result.(time.Time))
-}
-
-type BooleanTest bool
-
-func (v BooleanTest) Marshal() (string, error) {
- return MarshalBoolean(bool(v))
-}
-func (v BooleanTest) Unmarshal(s string) (interface{}, error) {
- return UnmarshalBoolean(s)
-}
-func (v BooleanTest) Equal(result interface{}) bool {
- return bool(v) == result.(bool)
-}
-
-type BinBase64Test []byte
-
-func (v BinBase64Test) Marshal() (string, error) {
- return MarshalBinBase64([]byte(v))
-}
-func (v BinBase64Test) Unmarshal(s string) (interface{}, error) {
- return UnmarshalBinBase64(s)
-}
-func (v BinBase64Test) Equal(result interface{}) bool {
- return bytes.Equal([]byte(v), result.([]byte))
-}
-
-type BinHexTest []byte
-
-func (v BinHexTest) Marshal() (string, error) {
- return MarshalBinHex([]byte(v))
-}
-func (v BinHexTest) Unmarshal(s string) (interface{}, error) {
- return UnmarshalBinHex(s)
-}
-func (v BinHexTest) Equal(result interface{}) bool {
- return bytes.Equal([]byte(v), result.([]byte))
-}
-
-func Test(t *testing.T) {
- const time010203 time.Duration = (1*3600 + 2*60 + 3) * time.Second
- const time0102 time.Duration = (1*3600 + 2*60) * time.Second
- const time01 time.Duration = (1 * 3600) * time.Second
- const time235959 time.Duration = (23*3600 + 59*60 + 59) * time.Second
-
- // Fake out the local time for the implementation.
- localLoc = time.FixedZone("Fake/Local", 6*3600)
- defer func() {
- localLoc = time.Local
- }()
-
- tests := []testCase{
- // ui1
- {str: "", value: Ui1Test(0), wantUnmarshalErr: true, noMarshal: true, tag: "dupe"},
- {str: " ", value: Ui1Test(0), wantUnmarshalErr: true, noMarshal: true, tag: "dupe"},
- {str: "abc", value: Ui1Test(0), wantUnmarshalErr: true, noMarshal: true, tag: "dupe"},
- {str: "-1", value: Ui1Test(0), wantUnmarshalErr: true, noMarshal: true, tag: "dupe"},
- {str: "0", value: Ui1Test(0), tag: "dupe"},
- {str: "1", value: Ui1Test(1), tag: "dupe"},
- {str: "255", value: Ui1Test(255), tag: "dupe"},
- {str: "256", value: Ui1Test(0), wantUnmarshalErr: true, noMarshal: true},
-
- // ui2
- {str: "65535", value: Ui2Test(65535)},
- {str: "65536", value: Ui2Test(0), wantUnmarshalErr: true, noMarshal: true},
-
- // ui4
- {str: "4294967295", value: Ui4Test(4294967295)},
- {str: "4294967296", value: Ui4Test(0), wantUnmarshalErr: true, noMarshal: true},
-
- // i1
- {str: "", value: I1Test(0), wantUnmarshalErr: true, noMarshal: true, tag: "dupe"},
- {str: " ", value: I1Test(0), wantUnmarshalErr: true, noMarshal: true, tag: "dupe"},
- {str: "abc", value: I1Test(0), wantUnmarshalErr: true, noMarshal: true, tag: "dupe"},
- {str: "0", value: I1Test(0), tag: "dupe"},
- {str: "-1", value: I1Test(-1), tag: "dupe"},
- {str: "127", value: I1Test(127), tag: "dupe"},
- {str: "-128", value: I1Test(-128), tag: "dupe"},
- {str: "128", value: I1Test(0), wantUnmarshalErr: true, noMarshal: true},
- {str: "-129", value: I1Test(0), wantUnmarshalErr: true, noMarshal: true},
-
- // i2
- {str: "32767", value: I2Test(32767)},
- {str: "-32768", value: I2Test(-32768)},
- {str: "32768", value: I2Test(0), wantUnmarshalErr: true, noMarshal: true},
- {str: "-32769", value: I2Test(0), wantUnmarshalErr: true, noMarshal: true},
-
- // i4
- {str: "2147483647", value: I4Test(2147483647)},
- {str: "-2147483648", value: I4Test(-2147483648)},
- {str: "2147483648", value: I4Test(0), wantUnmarshalErr: true, noMarshal: true},
- {str: "-2147483649", value: I4Test(0), wantUnmarshalErr: true, noMarshal: true},
-
- // int
- {str: "9223372036854775807", value: IntTest(9223372036854775807)},
- {str: "-9223372036854775808", value: IntTest(-9223372036854775808)},
- {str: "9223372036854775808", value: IntTest(0), wantUnmarshalErr: true, noMarshal: true},
- {str: "-9223372036854775809", value: IntTest(0), wantUnmarshalErr: true, noMarshal: true},
-
- // fixed.14.4
- {str: "0.0000", value: Fixed14_4Test(0)},
- {str: "1.0000", value: Fixed14_4Test(1)},
- {str: "1.2346", value: Fixed14_4Test(1.23456)},
- {str: "-1.0000", value: Fixed14_4Test(-1)},
- {str: "-1.2346", value: Fixed14_4Test(-1.23456)},
- {str: "10000000000000.0000", value: Fixed14_4Test(1e13)},
- {str: "100000000000000.0000", value: Fixed14_4Test(1e14), wantMarshalErr: true, wantUnmarshalErr: true},
- {str: "-10000000000000.0000", value: Fixed14_4Test(-1e13)},
- {str: "-100000000000000.0000", value: Fixed14_4Test(-1e14), wantMarshalErr: true, wantUnmarshalErr: true},
-
- // char
- {str: "a", value: CharTest('a')},
- {str: "z", value: CharTest('z')},
- {str: "\u1234", value: CharTest(0x1234)},
- {str: "aa", value: CharTest(0), wantMarshalErr: true, wantUnmarshalErr: true},
- {str: "", value: CharTest(0), wantMarshalErr: true, wantUnmarshalErr: true},
-
- // date
- {str: "2013-10-08", value: DateTest{time.Date(2013, 10, 8, 0, 0, 0, 0, localLoc)}, tag: "no:dateTime"},
- {str: "20131008", value: DateTest{time.Date(2013, 10, 8, 0, 0, 0, 0, localLoc)}, noMarshal: true, tag: "no:dateTime"},
- {str: "2013-10-08T10:30:50", value: DateTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:dateTime"},
- {str: "2013-10-08T10:30:50Z", value: DateTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:dateTime"},
- {str: "", value: DateTest{}, wantMarshalErr: true, wantUnmarshalErr: true, noMarshal: true},
- {str: "-1", value: DateTest{}, wantUnmarshalErr: true, noMarshal: true},
-
- // time
- {str: "00:00:00", value: TimeOfDayTest{TimeOfDay{FromMidnight: 0}}},
- {str: "000000", value: TimeOfDayTest{TimeOfDay{FromMidnight: 0}}, noMarshal: true},
- {str: "24:00:00", value: TimeOfDayTest{TimeOfDay{FromMidnight: 24 * time.Hour}}, noMarshal: true}, // ISO8601 special case
- {str: "24:01:00", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true},
- {str: "24:00:01", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true},
- {str: "25:00:00", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true},
- {str: "00:60:00", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true},
- {str: "00:00:60", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true},
- {str: "01:02:03", value: TimeOfDayTest{TimeOfDay{FromMidnight: time010203}}},
- {str: "010203", value: TimeOfDayTest{TimeOfDay{FromMidnight: time010203}}, noMarshal: true},
- {str: "23:59:59", value: TimeOfDayTest{TimeOfDay{FromMidnight: time235959}}},
- {str: "235959", value: TimeOfDayTest{TimeOfDay{FromMidnight: time235959}}, noMarshal: true},
- {str: "01:02", value: TimeOfDayTest{TimeOfDay{FromMidnight: time0102}}, noMarshal: true},
- {str: "0102", value: TimeOfDayTest{TimeOfDay{FromMidnight: time0102}}, noMarshal: true},
- {str: "01", value: TimeOfDayTest{TimeOfDay{FromMidnight: time01}}, noMarshal: true},
- {str: "foo 01:02:03", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:time.tz"},
- {str: "foo\n01:02:03", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:time.tz"},
- {str: "01:02:03 foo", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:time.tz"},
- {str: "01:02:03\nfoo", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:time.tz"},
- {str: "01:02:03Z", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:time.tz"},
- {str: "01:02:03+01", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:time.tz"},
- {str: "01:02:03+01:23", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:time.tz"},
- {str: "01:02:03+0123", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:time.tz"},
- {str: "01:02:03-01", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:time.tz"},
- {str: "01:02:03-01:23", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:time.tz"},
- {str: "01:02:03-0123", value: TimeOfDayTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:time.tz"},
-
- // time.tz
- {str: "24:00:01", value: TimeOfDayTzTest{}, wantUnmarshalErr: true, noMarshal: true},
- {str: "01Z", value: TimeOfDayTzTest{TimeOfDay{time01, true, 0}}, noMarshal: true},
- {str: "01:02:03Z", value: TimeOfDayTzTest{TimeOfDay{time010203, true, 0}}},
- {str: "01+01", value: TimeOfDayTzTest{TimeOfDay{time01, true, 3600}}, noMarshal: true},
- {str: "01:02:03+01", value: TimeOfDayTzTest{TimeOfDay{time010203, true, 3600}}, noMarshal: true},
- {str: "01:02:03+01:23", value: TimeOfDayTzTest{TimeOfDay{time010203, true, 3600 + 23*60}}},
- {str: "01:02:03+0123", value: TimeOfDayTzTest{TimeOfDay{time010203, true, 3600 + 23*60}}, noMarshal: true},
- {str: "01:02:03-01", value: TimeOfDayTzTest{TimeOfDay{time010203, true, -3600}}, noMarshal: true},
- {str: "01:02:03-01:23", value: TimeOfDayTzTest{TimeOfDay{time010203, true, -(3600 + 23*60)}}},
- {str: "01:02:03-0123", value: TimeOfDayTzTest{TimeOfDay{time010203, true, -(3600 + 23*60)}}, noMarshal: true},
-
- // dateTime
- {str: "2013-10-08T00:00:00", value: DateTimeTest{time.Date(2013, 10, 8, 0, 0, 0, 0, localLoc)}, tag: "no:dateTime.tz"},
- {str: "20131008", value: DateTimeTest{time.Date(2013, 10, 8, 0, 0, 0, 0, localLoc)}, noMarshal: true},
- {str: "2013-10-08T10:30:50", value: DateTimeTest{time.Date(2013, 10, 8, 10, 30, 50, 0, localLoc)}, tag: "no:dateTime.tz"},
- {str: "2013-10-08T10:30:50T", value: DateTimeTest{}, wantUnmarshalErr: true, noMarshal: true},
- {str: "2013-10-08T10:30:50+01", value: DateTimeTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:dateTime.tz"},
- {str: "2013-10-08T10:30:50+01:23", value: DateTimeTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:dateTime.tz"},
- {str: "2013-10-08T10:30:50+0123", value: DateTimeTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:dateTime.tz"},
- {str: "2013-10-08T10:30:50-01", value: DateTimeTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:dateTime.tz"},
- {str: "2013-10-08T10:30:50-01:23", value: DateTimeTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:dateTime.tz"},
- {str: "2013-10-08T10:30:50-0123", value: DateTimeTest{}, wantUnmarshalErr: true, noMarshal: true, tag: "no:dateTime.tz"},
-
- // dateTime.tz
- {str: "2013-10-08T10:30:50", value: DateTimeTzTest{time.Date(2013, 10, 8, 10, 30, 50, 0, localLoc)}, noMarshal: true},
- {str: "2013-10-08T10:30:50+01", value: DateTimeTzTest{time.Date(2013, 10, 8, 10, 30, 50, 0, time.FixedZone("+01:00", 3600))}, noMarshal: true},
- {str: "2013-10-08T10:30:50+01:23", value: DateTimeTzTest{time.Date(2013, 10, 8, 10, 30, 50, 0, time.FixedZone("+01:23", 3600+23*60))}},
- {str: "2013-10-08T10:30:50+0123", value: DateTimeTzTest{time.Date(2013, 10, 8, 10, 30, 50, 0, time.FixedZone("+01:23", 3600+23*60))}, noMarshal: true},
- {str: "2013-10-08T10:30:50-01", value: DateTimeTzTest{time.Date(2013, 10, 8, 10, 30, 50, 0, time.FixedZone("-01:00", -3600))}, noMarshal: true},
- {str: "2013-10-08T10:30:50-01:23", value: DateTimeTzTest{time.Date(2013, 10, 8, 10, 30, 50, 0, time.FixedZone("-01:23", -(3600+23*60)))}},
- {str: "2013-10-08T10:30:50-0123", value: DateTimeTzTest{time.Date(2013, 10, 8, 10, 30, 50, 0, time.FixedZone("-01:23", -(3600+23*60)))}, noMarshal: true},
-
- // boolean
- {str: "0", value: BooleanTest(false)},
- {str: "1", value: BooleanTest(true)},
- {str: "false", value: BooleanTest(false), noMarshal: true},
- {str: "true", value: BooleanTest(true), noMarshal: true},
- {str: "no", value: BooleanTest(false), noMarshal: true},
- {str: "yes", value: BooleanTest(true), noMarshal: true},
- {str: "", value: BooleanTest(false), noMarshal: true, wantUnmarshalErr: true},
- {str: "other", value: BooleanTest(false), noMarshal: true, wantUnmarshalErr: true},
- {str: "2", value: BooleanTest(false), noMarshal: true, wantUnmarshalErr: true},
- {str: "-1", value: BooleanTest(false), noMarshal: true, wantUnmarshalErr: true},
-
- // bin.base64
- {str: "", value: BinBase64Test{}},
- {str: "YQ==", value: BinBase64Test("a")},
- {str: "TG9uZ2VyIFN0cmluZy4=", value: BinBase64Test("Longer String.")},
- {str: "TG9uZ2VyIEFsaWduZWQu", value: BinBase64Test("Longer Aligned.")},
-
- // bin.hex
- {str: "", value: BinHexTest{}},
- {str: "61", value: BinHexTest("a")},
- {str: "4c6f6e67657220537472696e672e", value: BinHexTest("Longer String.")},
- {str: "4C6F6E67657220537472696E672E", value: BinHexTest("Longer String."), noMarshal: true},
- }
-
- // Generate extra test cases from convTests that implement duper.
- var extras []testCase
- for i := range tests {
- if duper, ok := tests[i].value.(duper); ok {
- dupes := duper.Dupe(tests[i].tag)
- for _, duped := range dupes {
- dupedCase := testCase(tests[i])
- dupedCase.value = duped
- extras = append(extras, dupedCase)
- }
- }
- }
- tests = append(tests, extras...)
-
- for _, test := range tests {
- if test.noMarshal {
- } else if resultStr, err := test.value.Marshal(); err != nil && !test.wantMarshalErr {
- t.Errorf("For %T marshal %v, want %q, got error: %v", test.value, test.value, test.str, err)
- } else if err == nil && test.wantMarshalErr {
- t.Errorf("For %T marshal %v, want error, got %q", test.value, test.value, resultStr)
- } else if err == nil && resultStr != test.str {
- t.Errorf("For %T marshal %v, want %q, got %q", test.value, test.value, test.str, resultStr)
- }
-
- if test.noUnMarshal {
- } else if resultValue, err := test.value.Unmarshal(test.str); err != nil && !test.wantUnmarshalErr {
- t.Errorf("For %T unmarshal %q, want %v, got error: %v", test.value, test.str, test.value, err)
- } else if err == nil && test.wantUnmarshalErr {
- t.Errorf("For %T unmarshal %q, want error, got %v", test.value, test.str, resultValue)
- } else if err == nil && !test.value.Equal(resultValue) {
- t.Errorf("For %T unmarshal %q, want %v, got %v", test.value, test.str, test.value, resultValue)
- }
- }
-}
diff --git a/Godeps/_workspace/src/github.com/huin/goupnp/ssdp/registry.go b/Godeps/_workspace/src/github.com/huin/goupnp/ssdp/registry.go
index 38d10203f..2f84beaae 100644
--- a/Godeps/_workspace/src/github.com/huin/goupnp/ssdp/registry.go
+++ b/Godeps/_workspace/src/github.com/huin/goupnp/ssdp/registry.go
@@ -21,6 +21,40 @@ var (
maxAgeRx = regexp.MustCompile("max-age=([0-9]+)")
)
+const (
+ EventAlive = EventType(iota)
+ EventUpdate
+ EventByeBye
+)
+
+type EventType int8
+
+func (et EventType) String() string {
+ switch et {
+ case EventAlive:
+ return "EventAlive"
+ case EventUpdate:
+ return "EventUpdate"
+ case EventByeBye:
+ return "EventByeBye"
+ default:
+ return fmt.Sprintf("EventUnknown(%d)", int8(et))
+ }
+}
+
+type Update struct {
+ // The USN of the service.
+ USN string
+ // What happened.
+ EventType EventType
+ // The entry, which is nil if the service was not known and
+ // EventType==EventByeBye. The contents of this must not be modified as it is
+ // shared with the registry and other listeners. Once created, the Registry
+ // does not modify the Entry value - any updates are replaced with a new
+ // Entry value.
+ Entry *Entry
+}
+
type Entry struct {
// The address that the entry data was actually received from.
RemoteAddr string
@@ -32,7 +66,7 @@ type Entry struct {
Server string
Host string
// Location of the UPnP root device description.
- Location *url.URL
+ Location url.URL
// Despite BOOTID,CONFIGID being required fields, apparently they are not
// always set by devices. Set to -1 if not present.
@@ -83,7 +117,7 @@ func newEntryFromRequest(r *http.Request) (*Entry, error) {
NT: r.Header.Get("NT"),
Server: r.Header.Get("SERVER"),
Host: r.Header.Get("HOST"),
- Location: loc,
+ Location: *loc,
BootID: bootID,
ConfigID: configID,
SearchPort: uint16(searchPort),
@@ -125,15 +159,71 @@ func parseUpnpIntHeader(headers http.Header, headerName string, def int32) (int3
var _ httpu.Handler = new(Registry)
// Registry maintains knowledge of discovered devices and services.
+//
+// NOTE: the interface for this is experimental and may change, or go away
+// entirely.
type Registry struct {
lock sync.Mutex
byUSN map[string]*Entry
+
+ listenersLock sync.RWMutex
+ listeners map[chan<- Update]struct{}
}
func NewRegistry() *Registry {
return &Registry{
- byUSN: make(map[string]*Entry),
+ byUSN: make(map[string]*Entry),
+ listeners: make(map[chan<- Update]struct{}),
+ }
+}
+
+// NewServerAndRegistry is a convenience function to create a registry, and an
+// httpu server to pass it messages. Call ListenAndServe on the server for
+// messages to be processed.
+func NewServerAndRegistry() (*httpu.Server, *Registry) {
+ reg := NewRegistry()
+ srv := &httpu.Server{
+ Addr: ssdpUDP4Addr,
+ Multicast: true,
+ Handler: reg,
+ }
+ return srv, reg
+}
+
+func (reg *Registry) AddListener(c chan<- Update) {
+ reg.listenersLock.Lock()
+ defer reg.listenersLock.Unlock()
+ reg.listeners[c] = struct{}{}
+}
+
+func (reg *Registry) RemoveListener(c chan<- Update) {
+ reg.listenersLock.Lock()
+ defer reg.listenersLock.Unlock()
+ delete(reg.listeners, c)
+}
+
+func (reg *Registry) sendUpdate(u Update) {
+ reg.listenersLock.RLock()
+ defer reg.listenersLock.RUnlock()
+ for c := range reg.listeners {
+ c <- u
+ }
+}
+
+// GetService returns known service (or device) entries for the given service
+// URN.
+func (reg *Registry) GetService(serviceURN string) []*Entry {
+ // Currently assumes that the map is small, so we do a linear search rather
+ // than indexed to avoid maintaining two maps.
+ var results []*Entry
+ reg.lock.Lock()
+ defer reg.lock.Unlock()
+ for _, entry := range reg.byUSN {
+ if entry.NT == serviceURN {
+ results = append(results, entry)
+ }
}
+ return results
}
// ServeMessage implements httpu.Handler, and uses SSDP NOTIFY requests to
@@ -156,7 +246,9 @@ func (reg *Registry) ServeMessage(r *http.Request) {
default:
err = fmt.Errorf("unknown NTS value: %q", nts)
}
- log.Printf("In %s request from %s: %v", nts, r.RemoteAddr, err)
+ if err != nil {
+ log.Printf("goupnp/ssdp: failed to handle %s message from %s: %v", nts, r.RemoteAddr, err)
+ }
}
func (reg *Registry) handleNTSAlive(r *http.Request) error {
@@ -166,9 +258,14 @@ func (reg *Registry) handleNTSAlive(r *http.Request) error {
}
reg.lock.Lock()
- defer reg.lock.Unlock()
-
reg.byUSN[entry.USN] = entry
+ reg.lock.Unlock()
+
+ reg.sendUpdate(Update{
+ USN: entry.USN,
+ EventType: EventAlive,
+ Entry: entry,
+ })
return nil
}
@@ -185,18 +282,31 @@ func (reg *Registry) handleNTSUpdate(r *http.Request) error {
entry.BootID = nextBootID
reg.lock.Lock()
- defer reg.lock.Unlock()
-
reg.byUSN[entry.USN] = entry
+ reg.lock.Unlock()
+
+ reg.sendUpdate(Update{
+ USN: entry.USN,
+ EventType: EventUpdate,
+ Entry: entry,
+ })
return nil
}
func (reg *Registry) handleNTSByebye(r *http.Request) error {
- reg.lock.Lock()
- defer reg.lock.Unlock()
+ usn := r.Header.Get("USN")
- delete(reg.byUSN, r.Header.Get("USN"))
+ reg.lock.Lock()
+ entry := reg.byUSN[usn]
+ delete(reg.byUSN, usn)
+ reg.lock.Unlock()
+
+ reg.sendUpdate(Update{
+ USN: usn,
+ EventType: EventByeBye,
+ Entry: entry,
+ })
return nil
}