You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2015/11/21 01:43:04 UTC
[39/42] incubator-mynewt-newt git commit: Move newt source into a
"newt" subdirectory.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/andelf/go-curl/easy.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/andelf/go-curl/easy.go b/Godeps/_workspace/src/github.com/andelf/go-curl/easy.go
deleted file mode 100644
index 4593590..0000000
--- a/Godeps/_workspace/src/github.com/andelf/go-curl/easy.go
+++ /dev/null
@@ -1,495 +0,0 @@
-package curl
-
-/*
-#include <stdlib.h>
-#include <curl/curl.h>
-#include "callback.h"
-#include "compat.h"
-
-static CURLcode curl_easy_setopt_long(CURL *handle, CURLoption option, long parameter) {
- return curl_easy_setopt(handle, option, parameter);
-}
-static CURLcode curl_easy_setopt_string(CURL *handle, CURLoption option, char *parameter) {
- return curl_easy_setopt(handle, option, parameter);
-}
-static CURLcode curl_easy_setopt_slist(CURL *handle, CURLoption option, struct curl_slist *parameter) {
- return curl_easy_setopt(handle, option, parameter);
-}
-static CURLcode curl_easy_setopt_pointer(CURL *handle, CURLoption option, void *parameter) {
- return curl_easy_setopt(handle, option, parameter);
-}
-static CURLcode curl_easy_setopt_off_t(CURL *handle, CURLoption option, off_t parameter) {
- return curl_easy_setopt(handle, option, parameter);
-}
-
-static CURLcode curl_easy_getinfo_string(CURL *curl, CURLINFO info, char **p) {
- return curl_easy_getinfo(curl, info, p);
-}
-static CURLcode curl_easy_getinfo_long(CURL *curl, CURLINFO info, long *p) {
- return curl_easy_getinfo(curl, info, p);
-}
-static CURLcode curl_easy_getinfo_double(CURL *curl, CURLINFO info, double *p) {
- return curl_easy_getinfo(curl, info, p);
-}
-static CURLcode curl_easy_getinfo_slist(CURL *curl, CURLINFO info, struct curl_slist **p) {
- return curl_easy_getinfo(curl, info, p);
-}
-
-static CURLFORMcode curl_formadd_name_content_length(
- struct curl_httppost **httppost, struct curl_httppost **last_post, char *name, char *content, int length) {
- return curl_formadd(httppost, last_post,
- CURLFORM_COPYNAME, name,
- CURLFORM_COPYCONTENTS, content,
- CURLFORM_CONTENTSLENGTH, length, CURLFORM_END);
-}
-static CURLFORMcode curl_formadd_name_content_length_type(
- struct curl_httppost **httppost, struct curl_httppost **last_post, char *name, char *content, int length, char *type) {
- return curl_formadd(httppost, last_post,
- CURLFORM_COPYNAME, name,
- CURLFORM_COPYCONTENTS, content,
- CURLFORM_CONTENTSLENGTH, length,
- CURLFORM_CONTENTTYPE, type, CURLFORM_END);
-}
-static CURLFORMcode curl_formadd_name_file_type(
- struct curl_httppost **httppost, struct curl_httppost **last_post, char *name, char *filename, char *type) {
- return curl_formadd(httppost, last_post,
- CURLFORM_COPYNAME, name,
- CURLFORM_FILE, filename,
- CURLFORM_CONTENTTYPE, type, CURLFORM_END);
-}
- // TODO: support multi file
-
-*/
-import "C"
-
-import (
- "fmt"
- "mime"
- "path"
- "reflect"
- "unsafe"
-)
-
-type CurlInfo C.CURLINFO
-type CurlError C.CURLcode
-
-type CurlString *C.char
-
-func NewCurlString(s string) CurlString {
- return CurlString(unsafe.Pointer(C.CString(s)))
-}
-
-func FreeCurlString(s CurlString) {
- C.free(unsafe.Pointer(s))
-}
-
-func (e CurlError) Error() string {
- // ret is const char*, no need to free
- ret := C.curl_easy_strerror(C.CURLcode(e))
- return fmt.Sprintf("curl: %s", C.GoString(ret))
-}
-
-func newCurlError(errno C.CURLcode) error {
- if errno == C.CURLE_OK { // if nothing wrong
- return nil
- }
- return CurlError(errno)
-}
-
-// curl_easy interface
-type CURL struct {
- handle unsafe.Pointer
- // callback functions, bool ret means ok or not
- headerFunction, writeFunction *func([]byte, interface{}) bool
- readFunction *func([]byte, interface{}) int // return num of bytes writed to buf
- progressFunction *func(float64, float64, float64, float64, interface{}) bool
- fnmatchFunction *func(string, string, interface{}) int
- // callback datas
- headerData, writeData, readData, progressData, fnmatchData *interface{}
- // list of C allocs
- mallocAllocs []*C.char
-}
-
-// curl_easy_init - Start a libcurl easy session
-func EasyInit() *CURL {
- p := C.curl_easy_init()
- return &CURL{handle: p, mallocAllocs: make([]*C.char, 0)} // other field defaults to nil
-}
-
-// curl_easy_duphandle - Clone a libcurl session handle
-func (curl *CURL) Duphandle() *CURL {
- p := curl.handle
- return &CURL{handle: C.curl_easy_duphandle(p)}
-}
-
-// curl_easy_cleanup - End a libcurl easy session
-func (curl *CURL) Cleanup() {
- p := curl.handle
- C.curl_easy_cleanup(p)
- curl.MallocFreeAfter(0)
-}
-
-// curl_easy_setopt - set options for a curl easy handle
-// WARNING: a function pointer is &fun, but function addr is reflect.ValueOf(fun).Pointer()
-func (curl *CURL) Setopt(opt int, param interface{}) error {
- p := curl.handle
- if param == nil {
- // NOTE: some option will crash program when got a nil param
- return newCurlError(C.curl_easy_setopt_pointer(p, C.CURLoption(opt), nil))
- }
- switch {
- // not really set
- case opt == OPT_READDATA: // OPT_INFILE
- curl.readData = ¶m
- return nil
- case opt == OPT_PROGRESSDATA:
- curl.progressData = ¶m
- return nil
- case opt == OPT_HEADERDATA: // also known as OPT_WRITEHEADER
- curl.headerData = ¶m
- return nil
- case opt == OPT_WRITEDATA: // OPT_FILE
- curl.writeData = ¶m
- return nil
-
- case opt == OPT_READFUNCTION:
- fun := param.(func([]byte, interface{}) int)
- curl.readFunction = &fun
-
- ptr := C.return_read_function()
- if err := newCurlError(C.curl_easy_setopt_pointer(p, C.CURLoption(opt), ptr)); err == nil {
- return newCurlError(C.curl_easy_setopt_pointer(p, OPT_READDATA,
- unsafe.Pointer(reflect.ValueOf(curl).Pointer())))
- } else {
- return err
- }
-
- case opt == OPT_PROGRESSFUNCTION:
- fun := param.(func(float64, float64, float64, float64, interface{}) bool)
- curl.progressFunction = &fun
-
- ptr := C.return_progress_function()
- if err := newCurlError(C.curl_easy_setopt_pointer(p, C.CURLoption(opt), ptr)); err == nil {
- return newCurlError(C.curl_easy_setopt_pointer(p, OPT_PROGRESSDATA,
- unsafe.Pointer(reflect.ValueOf(curl).Pointer())))
- } else {
- return err
- }
-
- case opt == OPT_HEADERFUNCTION:
- fun := param.(func([]byte, interface{}) bool)
- curl.headerFunction = &fun
-
- ptr := C.return_header_function()
- if err := newCurlError(C.curl_easy_setopt_pointer(p, C.CURLoption(opt), ptr)); err == nil {
- return newCurlError(C.curl_easy_setopt_pointer(p, OPT_HEADERDATA,
- unsafe.Pointer(reflect.ValueOf(curl).Pointer())))
- } else {
- return err
- }
-
- case opt == OPT_WRITEFUNCTION:
- fun := param.(func([]byte, interface{}) bool)
- curl.writeFunction = &fun
-
- ptr := C.return_write_function()
- if err := newCurlError(C.curl_easy_setopt_pointer(p, C.CURLoption(opt), ptr)); err == nil {
- return newCurlError(C.curl_easy_setopt_pointer(p, OPT_WRITEDATA,
- unsafe.Pointer(reflect.ValueOf(curl).Pointer())))
- } else {
- return err
- }
-
- // for OPT_HTTPPOST, use struct Form
- case opt == OPT_HTTPPOST:
- post := param.(*Form)
- ptr := post.head
- return newCurlError(C.curl_easy_setopt_pointer(p, C.CURLoption(opt), unsafe.Pointer(ptr)))
-
- case opt >= C.CURLOPTTYPE_OFF_T:
- val := C.off_t(0)
- switch t := param.(type) {
- case int:
- val = C.off_t(t)
- case uint64:
- val = C.off_t(t)
- default:
- panic("OFF_T conversion not supported")
- }
- return newCurlError(C.curl_easy_setopt_off_t(p, C.CURLoption(opt), val))
-
- case opt >= C.CURLOPTTYPE_FUNCTIONPOINT:
- // function pointer
- panic("function pointer not implemented yet!")
-
- case opt >= C.CURLOPTTYPE_OBJECTPOINT:
- switch t := param.(type) {
- case string:
- ptr := C.CString(t)
- curl.mallocAddPtr(ptr)
- return newCurlError(C.curl_easy_setopt_string(p, C.CURLoption(opt), ptr))
- case CurlString:
- ptr := (*C.char)(t)
- return newCurlError(C.curl_easy_setopt_string(p, C.CURLoption(opt), ptr))
- case []string:
- if len(t) > 0 {
- ptr := C.CString(t[0])
- curl.mallocAddPtr(ptr)
- a_slist := C.curl_slist_append(nil, ptr)
- for _, s := range t[1:] {
- ptr := C.CString(s)
- curl.mallocAddPtr(ptr)
- a_slist = C.curl_slist_append(a_slist, ptr)
- }
- return newCurlError(C.curl_easy_setopt_slist(p, C.CURLoption(opt), a_slist))
- } else {
- return newCurlError(C.curl_easy_setopt_slist(p, C.CURLoption(opt), nil))
- }
- case []CurlString:
- if len(t) > 0 {
- ptr := (*C.char)(t[0])
- a_slist := C.curl_slist_append(nil, ptr)
- for _, s := range t[1:] {
- ptr := (*C.char)(s)
- a_slist = C.curl_slist_append(a_slist, ptr)
- }
- return newCurlError(C.curl_easy_setopt_slist(p, C.CURLoption(opt), a_slist))
- } else {
- return newCurlError(C.curl_easy_setopt_slist(p, C.CURLoption(opt), nil))
- }
- default:
- // It panics if v's Kind is not Chan, Func, Map, Ptr, Slice, or UnsafePointer.
- // val := reflect.ValueOf(param)
- //fmt.Printf("DEBUG(Setopt): param=%x\n", val.Pointer())
- //println("DEBUG can addr =", val.Pointer(), "opt=", opt)
- // pass a pointer to GoInterface
- return newCurlError(C.curl_easy_setopt_pointer(p, C.CURLoption(opt),
- unsafe.Pointer(¶m)))
- }
- case opt >= C.CURLOPTTYPE_LONG:
- val := C.long(0)
- switch t := param.(type) {
- case int:
- val = C.long(t)
- case bool:
- if t {
- val = 1
- }
- case int64:
- val = C.long(t)
- case int32:
- val = C.long(t)
- default:
- panic("not supported converstion to c long")
- }
- return newCurlError(C.curl_easy_setopt_long(p, C.CURLoption(opt), val))
- }
- panic("opt param error!")
-}
-
-// curl_easy_send - sends raw data over an "easy" connection
-func (curl *CURL) Send(buffer []byte) (int, error) {
- p := curl.handle
- buflen := len(buffer)
- n := C.size_t(0)
- ret := C.curl_easy_send(p, unsafe.Pointer(&buffer[0]), C.size_t(buflen), &n)
- return int(n), newCurlError(ret)
-}
-
-// curl_easy_recv - receives raw data on an "easy" connection
-func (curl *CURL) Recv(buffer []byte) (int, error) {
- p := curl.handle
- buflen := len(buffer)
- buf := C.CString(string(buffer))
- n := C.size_t(0)
- ret := C.curl_easy_recv(p, unsafe.Pointer(buf), C.size_t(buflen), &n)
- return copy(buffer, C.GoStringN(buf, C.int(n))), newCurlError(ret)
-}
-
-// curl_easy_perform - Perform a file transfer
-func (curl *CURL) Perform() error {
- p := curl.handle
- return newCurlError(C.curl_easy_perform(p))
-}
-
-// curl_easy_pause - pause and unpause a connection
-func (curl *CURL) Pause(bitmask int) error {
- p := curl.handle
- return newCurlError(C.curl_easy_pause(p, C.int(bitmask)))
-}
-
-// curl_easy_reset - reset all options of a libcurl session handle
-func (curl *CURL) Reset() {
- p := curl.handle
- C.curl_easy_reset(p)
-}
-
-// curl_easy_escape - URL encodes the given string
-func (curl *CURL) Escape(url string) string {
- p := curl.handle
- oldUrl := C.CString(url)
- defer C.free(unsafe.Pointer(oldUrl))
- newUrl := C.curl_easy_escape(p, oldUrl, 0)
- defer C.curl_free(unsafe.Pointer(newUrl))
- return C.GoString(newUrl)
-}
-
-// curl_easy_unescape - URL decodes the given string
-func (curl *CURL) Unescape(url string) string {
- p := curl.handle
- oldUrl := C.CString(url)
- outlength := C.int(0)
- defer C.free(unsafe.Pointer(oldUrl))
- // If outlength is non-NULL, the function will write the length of the
- // returned string in the integer it points to. This allows an
- // escaped string containing %00 to still get used properly after unescaping.
- newUrl := C.curl_easy_unescape(p, oldUrl, 0, &outlength)
- defer C.curl_free(unsafe.Pointer(newUrl))
- return C.GoStringN(newUrl, outlength)
-}
-
-// curl_easy_getinfo - extract information from a curl handle
-func (curl *CURL) Getinfo(info CurlInfo) (ret interface{}, err error) {
- p := curl.handle
- cInfo := C.CURLINFO(info)
- switch cInfo & C.CURLINFO_TYPEMASK {
- case C.CURLINFO_STRING:
- a_string := C.CString("")
- defer C.free(unsafe.Pointer(a_string))
- err := newCurlError(C.curl_easy_getinfo_string(p, cInfo, &a_string))
- ret := C.GoString(a_string)
- debugf("Getinfo %s", ret)
- return ret, err
- case C.CURLINFO_LONG:
- a_long := C.long(-1)
- err := newCurlError(C.curl_easy_getinfo_long(p, cInfo, &a_long))
- ret := int(a_long)
- debugf("Getinfo %s", ret)
- return ret, err
- case C.CURLINFO_DOUBLE:
- a_double := C.double(0.0)
- err := newCurlError(C.curl_easy_getinfo_double(p, cInfo, &a_double))
- ret := float64(a_double)
- debugf("Getinfo %s", ret)
- return ret, err
- case C.CURLINFO_SLIST:
- a_ptr_slist := new(_Ctype_struct_curl_slist)
- err := newCurlError(C.curl_easy_getinfo_slist(p, cInfo, &a_ptr_slist))
- ret := []string{}
- for a_ptr_slist != nil {
- debugf("Getinfo %s %v", C.GoString(a_ptr_slist.data), a_ptr_slist.next)
- ret = append(ret, C.GoString(a_ptr_slist.data))
- a_ptr_slist = a_ptr_slist.next
- }
- return ret, err
- default:
- panic("error calling Getinfo\n")
- }
- panic("not implemented yet!")
- return nil, nil
-}
-
-func (curl *CURL) GetHandle() unsafe.Pointer {
- return curl.handle
-}
-
-func (curl *CURL) MallocGetPos() int {
- return len(curl.mallocAllocs)
-}
-
-func (curl *CURL) MallocFreeAfter(from int) {
- l := len(curl.mallocAllocs)
- for idx := from; idx < l; idx++ {
- C.free(unsafe.Pointer(curl.mallocAllocs[idx]))
- curl.mallocAllocs[idx] = nil
- }
- curl.mallocAllocs = curl.mallocAllocs[0:from]
-}
-
-func (curl *CURL) mallocAddPtr(ptr *C.char) {
- curl.mallocAllocs = append(curl.mallocAllocs, ptr)
-}
-
-// A multipart/formdata HTTP POST form
-type Form struct {
- head, last *C.struct_curl_httppost
-}
-
-func NewForm() *Form {
- return &Form{}
-}
-
-func (form *Form) Add(name string, content interface{}) error {
- head, last := form.head, form.last
- namestr := C.CString(name)
- defer C.free(unsafe.Pointer(namestr))
- var (
- buffer *C.char
- length C.int
- )
- switch t := content.(type) {
- case string:
- buffer = C.CString(t)
- length = C.int(len(t))
- case []byte:
- buffer = C.CString(string(t))
- length = C.int(len(t))
- default:
- panic("not implemented")
- }
- defer C.free(unsafe.Pointer(buffer))
- C.curl_formadd_name_content_length(&head, &last, namestr, buffer, length)
- form.head, form.last = head, last
- return nil
-}
-
-func (form *Form) AddWithType(name string, content interface{}, content_type string) error {
- head, last := form.head, form.last
- namestr := C.CString(name)
- typestr := C.CString(content_type)
- defer C.free(unsafe.Pointer(namestr))
- defer C.free(unsafe.Pointer(typestr))
- var (
- buffer *C.char
- length C.int
- )
- switch t := content.(type) {
- case string:
- buffer = C.CString(t)
- length = C.int(len(t))
- case []byte:
- buffer = C.CString(string(t))
- length = C.int(len(t))
- default:
- panic("not implemented")
- }
- defer C.free(unsafe.Pointer(buffer))
- C.curl_formadd_name_content_length_type(&head, &last, namestr, buffer, length, typestr)
- form.head, form.last = head, last
- return nil
-}
-
-func (form *Form) AddFile(name, filename string) error {
- head, last := form.head, form.last
- namestr := C.CString(name)
- pathstr := C.CString(filename)
- typestr := C.CString(guessType(filename))
- defer C.free(unsafe.Pointer(namestr))
- defer C.free(unsafe.Pointer(pathstr))
- defer C.free(unsafe.Pointer(typestr))
- C.curl_formadd_name_file_type(&head, &last, namestr, pathstr, typestr)
- form.head, form.last = head, last
- return nil
-}
-
-func (form *Form) AddFromFile(name, filename string) {
-}
-
-func guessType(filename string) string {
- ext := path.Ext(filename)
- file_type := mime.TypeByExtension(ext)
- if file_type == "" {
- return "application/octet-stream"
- }
- return file_type
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/andelf/go-curl/easy_test.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/andelf/go-curl/easy_test.go b/Godeps/_workspace/src/github.com/andelf/go-curl/easy_test.go
deleted file mode 100644
index 071245c..0000000
--- a/Godeps/_workspace/src/github.com/andelf/go-curl/easy_test.go
+++ /dev/null
@@ -1,61 +0,0 @@
-package curl
-
-import (
- "fmt"
- "net/http"
- "net/http/httptest"
- "testing"
-)
-
-func setupTestServer(serverContent string) *httptest.Server {
- return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- fmt.Fprintln(w, serverContent)
- }))
-}
-
-func TestEasyInterface(t *testing.T) {
- ts := setupTestServer("")
- defer ts.Close()
-
- easy := EasyInit()
- defer easy.Cleanup()
-
- easy.Setopt(OPT_URL, ts.URL)
- if err := easy.Perform(); err != nil {
- t.Fatal(err)
- }
-}
-
-func TestCallbackFunction(t *testing.T) {
- serverContent := "A random string"
- ts := setupTestServer(serverContent)
- defer ts.Close()
-
- easy := EasyInit()
- defer easy.Cleanup()
-
- easy.Setopt(OPT_URL, ts.URL)
- easy.Setopt(OPT_WRITEFUNCTION, func(buf []byte, userdata interface{}) bool {
- result := string(buf)
- expected := serverContent + "\n"
- if result != expected {
- t.Errorf("output should be %q and is %q.", expected, result)
- }
- return true
- })
- if err := easy.Perform(); err != nil {
- t.Fatal(err)
- }
-}
-
-func TestEscape(t *testing.T) {
- easy := EasyInit()
- defer easy.Cleanup()
-
- payload := `payload={"msg": "First line\nSecond Line"}`
- expected := `payload%3D%7B%22msg%22%3A%20%22First%20line%5CnSecond%20Line%22%7D`
- result := easy.Escape(payload)
- if result != expected {
- t.Errorf("escaped output should be %q and is %q.", expected, result)
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/andelf/go-curl/examples/channal_callback.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/channal_callback.go b/Godeps/_workspace/src/github.com/andelf/go-curl/examples/channal_callback.go
deleted file mode 100644
index c9c93f6..0000000
--- a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/channal_callback.go
+++ /dev/null
@@ -1,47 +0,0 @@
-package main
-
-import (
- curl "github.com/andelf/go-curl"
- "time"
-)
-
-func write_data(ptr []byte, userdata interface{}) bool {
- ch, ok := userdata.(chan string)
- if ok {
- ch <- string(ptr)
- return true // ok
- } else {
- println("ERROR!")
- return false
- }
- return false
-}
-
-func main() {
- curl.GlobalInit(curl.GLOBAL_ALL)
-
- // init the curl session
- easy := curl.EasyInit()
- defer easy.Cleanup()
-
- easy.Setopt(curl.OPT_URL, "http://cn.bing.com/")
-
- easy.Setopt(curl.OPT_WRITEFUNCTION, write_data)
-
- // make a chan
- ch := make(chan string, 100)
- go func(ch chan string) {
- for {
- data := <-ch
- println("Got data size=", len(data))
- }
- }(ch)
-
- easy.Setopt(curl.OPT_WRITEDATA, ch)
-
- if err := easy.Perform(); err != nil {
- println("ERROR: ", err.Error())
- }
-
- time.Sleep(10000) // wait gorotine
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/andelf/go-curl/examples/ftpget.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/ftpget.go b/Godeps/_workspace/src/github.com/andelf/go-curl/examples/ftpget.go
deleted file mode 100644
index 1c1502d..0000000
--- a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/ftpget.go
+++ /dev/null
@@ -1,37 +0,0 @@
-package main
-
-import (
- curl "github.com/andelf/go-curl"
- "os"
-)
-
-const filename = "README"
-
-func main() {
- curl.GlobalInit(curl.GLOBAL_DEFAULT)
- defer curl.GlobalCleanup()
- easy := curl.EasyInit()
- defer easy.Cleanup()
-
- easy.Setopt(curl.OPT_URL, "ftp://ftp.gnu.org/README")
-
- // define our callback use lambda function
- easy.Setopt(curl.OPT_WRITEFUNCTION, func(ptr []byte, userdata interface{}) bool {
- file := userdata.(*os.File)
- if _, err := file.Write(ptr); err != nil {
- return false
- }
- return true
- })
-
- fp, _ := os.OpenFile(filename, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0777)
- defer fp.Close() // defer close
-
- easy.Setopt(curl.OPT_WRITEDATA, fp)
-
- easy.Setopt(curl.OPT_VERBOSE, true)
-
- if err := easy.Perform(); err != nil {
- println("ERROR", err.Error())
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/andelf/go-curl/examples/https.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/https.go b/Godeps/_workspace/src/github.com/andelf/go-curl/examples/https.go
deleted file mode 100644
index 0a4e031..0000000
--- a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/https.go
+++ /dev/null
@@ -1,17 +0,0 @@
-package main
-
-import (
- curl "github.com/andelf/go-curl"
-)
-
-func main() {
- easy := curl.EasyInit()
- defer easy.Cleanup()
- if easy != nil {
- easy.Setopt(curl.OPT_URL, "https://mail.google.com/")
- // skip_peer_verification
- easy.Setopt(curl.OPT_SSL_VERIFYPEER, false) // 0 is ok
-
- easy.Perform()
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/andelf/go-curl/examples/misc.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/misc.go b/Godeps/_workspace/src/github.com/andelf/go-curl/examples/misc.go
deleted file mode 100644
index d66d2b7..0000000
--- a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/misc.go
+++ /dev/null
@@ -1,104 +0,0 @@
-package main
-
-import (
- "fmt"
- curl "github.com/andelf/go-curl"
- "os"
- "reflect"
-)
-
-const endl = "\n"
-
-func main() {
- println("DEBUG chdir=>", os.Chdir("/sadf"))
- ret := curl.EasyInit()
- defer ret.Cleanup()
- print("init =>", ret, " ", reflect.TypeOf(ret).String(), endl)
- ret = ret.Duphandle()
- defer ret.Cleanup()
-
- print("dup =>", ret, " ", reflect.TypeOf(ret).String(), endl)
- print("global init =>", curl.GlobalInit(curl.GLOBAL_ALL), endl)
- print("version =>", curl.Version(), endl)
- // debug
- //print("set verbose =>", ret.Setopt(curl.OPT_VERBOSE, true), endl)
-
- //print("set header =>", ret.Setopt(curl.OPT_HEADER, true), endl)
-
- // auto calculate port
- // print("set port =>", ret.EasySetopt(curl.OPT_PORT, 6060), endl)
- fmt.Printf("XXXX debug setopt %#v \n", ret.Setopt(30000, 19).Error())
-
- print("set timeout =>", ret.Setopt(curl.OPT_TIMEOUT, 20), endl)
-
- //print("set post size =>", ret.Setopt(curl.OPT_POSTFIELDSIZE, 10), endl)
- if ret.Setopt(curl.OPT_URL, "http://www.baidu.com:8000/") != nil {
- println("set url ok!")
- }
- //print("set url =>", ret.Setopt(curl.OPT_URL, "http://commondatastorage.googleapis.com/chromium-browser-continuous/Linux_x64/104547/chrome-linux.zip"), endl)
-
- print("set user_agent =>", ret.Setopt(curl.OPT_USERAGENT, "go-curl v0.0.1") == nil, endl)
- // add to DNS cache
- print("set resolve =>", ret.Setopt(curl.OPT_RESOLVE, []string{"www.baidu.com:8000:127.0.0.1"}) == nil, endl)
- // ret.EasyReset() clean seted
-
- // currently not finished!
- //
- fooTest := func(buf []byte, userdata interface{}) bool {
- // buf := ptr.([]byte)
- println("size=>", len(buf))
- println("DEBUG(in callback)", buf, userdata)
- println("data = >", string(buf))
- return true
- }
-
- ret.Setopt(curl.OPT_WRITEFUNCTION, fooTest) // curl.CallbackWriteFunction(fooTest))
- println("set opt!")
- // for test only
-
- code := ret.Perform()
- // dump.Dump(code)
- fmt.Printf("code -> %v\n", code)
-
- println("================================")
- print("pause =>", ret.Pause(curl.PAUSE_ALL), endl)
-
- print("escape =>", ret.Escape("http://baidu.com/"), endl)
- print("unescape =>", ret.Unescape("http://baidu.com/-%00-%5c"), endl)
-
- print("unescape lenght =>", len(ret.Unescape("http://baidu.com/-%00-%5c")), endl)
- // print("version info data =>", curl.VersionInfo(1), endl)
- ver := curl.VersionInfo(curl.VERSION_NOW)
- fmt.Printf("VersionInfo: Age: %d, Version:%s, Host:%s, Features:%d, SslVer: %s, LibzV: %s, ssh: %s\n",
- ver.Age, ver.Version, ver.Host, ver.Features, ver.SslVersion, ver.LibzVersion, ver.LibsshVersion)
-
- print("Protocols:")
- for _, p := range ver.Protocols {
- print(p, ", ")
- }
- print(endl)
- println(curl.Getdate("20111002 15:05:58 +0800").String())
- ret.Getinfo(curl.INFO_EFFECTIVE_URL)
- ret.Getinfo(curl.INFO_RESPONSE_CODE)
-
- ret.Getinfo(curl.INFO_FILETIME)
- ret.Getinfo(curl.INFO_SSL_ENGINES)
-
- ret.Getinfo(curl.INFO_TOTAL_TIME)
-
- println("================================")
-
- // ret.Getinfo(curl.INFO_SSL_ENGINES)
-
- /* mret := curl.MultiInit()
- mret.AddHandle(ret) // works
- defer mret.Cleanup()
- if ok, handles := mret.Perform(); ok == curl.OK {
- fmt.Printf("ok=%s, handles=%d\n", ok, handles)
- } else {
- fmt.Printf("error calling multi\n")
- }
- */
- println("================================")
- //println(curl.GlobalInit(curl.GLOBAL_SSL))
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/andelf/go-curl/examples/multi_and_select.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/multi_and_select.go b/Godeps/_workspace/src/github.com/andelf/go-curl/examples/multi_and_select.go
deleted file mode 100644
index 950da36..0000000
--- a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/multi_and_select.go
+++ /dev/null
@@ -1,101 +0,0 @@
-package main
-
-/*
-#include <stdlib.h>
-#include <sys/select.h>
-static void _FD_ZERO(void *set) {
- FD_ZERO((fd_set*)set);
-}
-static void _FD_SET(int sysfd, void *set) {
- FD_SET(sysfd, (fd_set*)set);
-}
-static int _FD_ISSET (int sysfd, void *set) {
- return FD_ISSET(sysfd, (fd_set*)set);
-}
-*/
-import "C"
-
-import (
- curl "github.com/Pyrrvs/go-curl"
- "syscall"
- "unsafe"
- "fmt"
-)
-
-func FD_ZERO(set *syscall.FdSet) {
- s := unsafe.Pointer(set)
- C._FD_ZERO(s)
-}
-
-func FD_SET(sysfd int, set *syscall.FdSet) {
- s := unsafe.Pointer(set)
- fd := C.int(sysfd)
- C._FD_SET(fd, s)
-}
-
-func FD_ISSET(sysfd int, set *syscall.FdSet) bool {
- s := unsafe.Pointer(set)
- fd := C.int(sysfd)
- return C._FD_ISSET(fd, s) != 0
-}
-
-func main() {
- var (
- rset, wset, eset syscall.FdSet
- still_running, curl_timeout int = 0, 0
- err error
- )
-
- ch1 := curl.EasyInit()
- ch2 := curl.EasyInit()
-
- ch1.Setopt(curl.OPT_URL, "http://www.163.com")
- ch1.Setopt(curl.OPT_HEADER, 0)
- ch1.Setopt(curl.OPT_VERBOSE, true)
- ch2.Setopt(curl.OPT_URL, "http://www.baidu.com")
- ch2.Setopt(curl.OPT_HEADER, 0)
- ch2.Setopt(curl.OPT_VERBOSE, true)
-
- mh := curl.MultiInit()
-
- mh.AddHandle(ch1)
- mh.AddHandle(ch2)
-
- for {
- FD_ZERO(&rset)
- FD_ZERO(&wset)
- FD_ZERO(&eset)
-
- timeout := syscall.Timeval{Sec:1, Usec:0}
- curl_timeout, err = mh.Timeout()
- if err != nil {
- fmt.Printf("Error multi_timeout: %s\n", err)
- }
- if curl_timeout >= 0 {
- timeout.Sec = int64(curl_timeout / 1000)
- if timeout.Sec > 1 {
- timeout.Sec = 1
- } else {
- timeout.Usec = int64((curl_timeout % 1000)) * 1000
- }
- }
-
- max_fd, err := mh.Fdset(&rset, &wset, &eset)
- if err != nil {
- fmt.Printf("Error FDSET: %s\n", err)
- }
-
- _, err = syscall.Select(int(max_fd + 1), &rset, &wset, &eset, &timeout)
- if err != nil {
- fmt.Printf("Error select: %s\n", err)
- } else {
- still_running, err = mh.Perform()
- if still_running > 0 {
- fmt.Printf("Still running: %d\n", still_running)
- } else {
- break
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/andelf/go-curl/examples/multi_sample.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/multi_sample.go b/Godeps/_workspace/src/github.com/andelf/go-curl/examples/multi_sample.go
deleted file mode 100644
index a0563a8..0000000
--- a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/multi_sample.go
+++ /dev/null
@@ -1,36 +0,0 @@
-
-package main
-
-import (
- curl "github.com/andelf/go-curl"
- "time"
-)
-
-func main() {
-
- ch1 := curl.EasyInit()
- ch2 := curl.EasyInit()
-
- ch1.Setopt(curl.OPT_URL, "http://www.163.com")
- ch1.Setopt(curl.OPT_HEADER, 0)
- ch1.Setopt(curl.OPT_VERBOSE, true)
- ch2.Setopt(curl.OPT_URL, "http://www.baidu.com")
- ch2.Setopt(curl.OPT_HEADER, 0)
- ch2.Setopt(curl.OPT_VERBOSE, true)
-
- mh := curl.MultiInit()
-
- mh.AddHandle(ch1)
- mh.AddHandle(ch2)
-
- for {
- nRunning, _ := mh.Perform()
- // println("n =", nRunning)
- if nRunning == 0 {
- println("ok")
- break
- }
- time.Sleep(1000)
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/andelf/go-curl/examples/post-callback.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/post-callback.go b/Godeps/_workspace/src/github.com/andelf/go-curl/examples/post-callback.go
deleted file mode 100644
index 3b02802..0000000
--- a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/post-callback.go
+++ /dev/null
@@ -1,43 +0,0 @@
-package main
-
-import (
- curl "github.com/andelf/go-curl"
- "time"
-)
-
-const POST_DATA = "a_test_data_only"
-
-var sent = false
-
-func main() {
- // init the curl session
- easy := curl.EasyInit()
- defer easy.Cleanup()
-
- easy.Setopt(curl.OPT_URL, "http://www.google.com")
-
- easy.Setopt(curl.OPT_POST, true)
- easy.Setopt(curl.OPT_VERBOSE, true)
-
- easy.Setopt(curl.OPT_READFUNCTION,
- func(ptr []byte, userdata interface{}) int {
- // WARNING: never use append()
- if !sent {
- sent = true
- ret := copy(ptr, POST_DATA)
- return ret
- }
- return 0 // sent ok
- })
-
- // disable HTTP/1.1 Expect 100
- easy.Setopt(curl.OPT_HTTPHEADER, []string{"Expect:"})
- // must set
- easy.Setopt(curl.OPT_POSTFIELDSIZE, len(POST_DATA))
-
- if err := easy.Perform(); err != nil {
- println("ERROR: ", err.Error())
- }
-
- time.Sleep(10000) // wait gorotine
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/andelf/go-curl/examples/progress.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/progress.go b/Godeps/_workspace/src/github.com/andelf/go-curl/examples/progress.go
deleted file mode 100644
index 09efcf5..0000000
--- a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/progress.go
+++ /dev/null
@@ -1,47 +0,0 @@
-// A sample program to show how to use PROGRESS callback to calculate
-// downloading percentage and speed
-package main
-
-import (
- "fmt"
- curl "github.com/andelf/go-curl"
- "time"
-)
-
-func write_data(ptr []byte, userdata interface{}) bool {
- // make it ok, do nothing
- return true
-}
-
-func main() {
- curl.GlobalInit(curl.GLOBAL_ALL)
-
- // init the curl session
- easy := curl.EasyInit()
- defer easy.Cleanup()
-
- easy.Setopt(curl.OPT_URL, "http://curl.haxx.se/download/curl-7.22.0.tar.gz")
-
- easy.Setopt(curl.OPT_WRITEFUNCTION, write_data)
-
- easy.Setopt(curl.OPT_NOPROGRESS, false)
-
- started := int64(0)
- easy.Setopt(curl.OPT_PROGRESSFUNCTION, func(dltotal, dlnow, ultotal, ulnow float64, userdata interface{}) bool {
- // canceled when 50% finished
- if dlnow/dltotal > 0.5 {
- println("")
- // abort downloading
- return false
- }
- if started == 0 {
- started = time.Now().Unix()
- }
- fmt.Printf("Downloaded: %3.2f%%, Speed: %.1fKiB/s \r", dlnow/dltotal*100, dlnow/1000/float64((time.Now().Unix()-started)))
- return true
- })
-
- if err := easy.Perform(); err != nil {
- fmt.Printf("ERROR: %v\n", err)
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/andelf/go-curl/examples/renren_login.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/renren_login.go b/Godeps/_workspace/src/github.com/andelf/go-curl/examples/renren_login.go
deleted file mode 100644
index 60ef84c..0000000
--- a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/renren_login.go
+++ /dev/null
@@ -1,36 +0,0 @@
-// 测试人人网登录, 并保存cookiejar
-package main
-
-import (
- "flag"
- curl "github.com/andelf/go-curl"
-)
-
-func main() {
- // init the curl session
-
- var username *string = flag.String("username", "test", "renren.com email")
- var password *string = flag.String("password", "test", "renren.com password")
-
- flag.Parse()
-
- easy := curl.EasyInit()
- defer easy.Cleanup()
-
- easy.Setopt(curl.OPT_URL, "http://m.renren.com/home.do")
-
- easy.Setopt(curl.OPT_PORT, 80)
- easy.Setopt(curl.OPT_VERBOSE, true)
-
- easy.Setopt(curl.OPT_COOKIEJAR, "./cookie.jar")
-
- // disable HTTP/1.1 Expect: 100-continue
- easy.Setopt(curl.OPT_HTTPHEADER, []string{"Expect:"})
-
- postdata := "email=" + *username + "&password=" + *password + "&login=" + easy.Escape("登录")
- easy.Setopt(curl.OPT_POSTFIELDS, postdata)
-
- if err := easy.Perform(); err != nil {
- println("ERROR: ", err.Error())
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/andelf/go-curl/examples/renren_upload.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/renren_upload.go b/Godeps/_workspace/src/github.com/andelf/go-curl/examples/renren_upload.go
deleted file mode 100644
index d02e320..0000000
--- a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/renren_upload.go
+++ /dev/null
@@ -1,77 +0,0 @@
-// 人人网图片上传
-package main
-
-import (
- "fmt"
- curl "github.com/andelf/go-curl"
- "regexp"
- "time"
-)
-
-func getUploadUrl() string {
- page := ""
- easy := curl.EasyInit()
- defer easy.Cleanup()
-
- u := "http://3g.renren.com/album/wuploadphoto.do"
- easy.Setopt(curl.OPT_URL, u)
- easy.Setopt(curl.OPT_COOKIEFILE, "./cookie.jar")
- easy.Setopt(curl.OPT_COOKIEJAR, "./cookie.jar")
- easy.Setopt(curl.OPT_VERBOSE, true)
- easy.Setopt(curl.OPT_WRITEFUNCTION, func(ptr []byte, _ interface{}) bool {
- page += string(ptr)
- return true
- })
- easy.Perform()
- // extract url from
- // <form enctype="multipart/form-data" action="http://3g.renren.com/album/wuploadphoto.do?type=3&sid=zv3tiXTZr6Cu1rj5dhgX_X"
- pattern, _ := regexp.Compile(`action="(.*?)"`)
-
- if matches := pattern.FindStringSubmatch(page); len(matches) == 2 {
- return matches[1]
- }
- return ""
-}
-
-func main() {
- // init the curl session
-
- easy := curl.EasyInit()
- defer easy.Cleanup()
-
- posturl := getUploadUrl()
-
- easy.Setopt(curl.OPT_URL, posturl)
-
- easy.Setopt(curl.OPT_PORT, 80)
- easy.Setopt(curl.OPT_VERBOSE, true)
-
- // save cookie and load cookie
- easy.Setopt(curl.OPT_COOKIEFILE, "./cookie.jar")
- easy.Setopt(curl.OPT_COOKIEJAR, "./cookie.jar")
-
- // disable HTTP/1.1 Expect: 100-continue
- easy.Setopt(curl.OPT_HTTPHEADER, []string{"Expect:"})
-
- form := curl.NewForm()
- form.Add("albumid", "452618633") // your album id
- form.AddFile("theFile", "./test.jpg")
- form.Add("description", "我就尝试下这段代码靠谱不。。截图下看看")
- form.Add("post", "上传照片")
-
- easy.Setopt(curl.OPT_HTTPPOST, form)
-
- // print upload progress
- easy.Setopt(curl.OPT_NOPROGRESS, false)
- easy.Setopt(curl.OPT_PROGRESSFUNCTION, func(dltotal, dlnow, ultotal, ulnow float64, _ interface{}) bool {
- fmt.Printf("Download %3.2f%%, Uploading %3.2f%%\r", dlnow/dltotal*100, ulnow/ultotal*100)
- return true
- })
-
- if err := easy.Perform(); err != nil {
- println("ERROR: ", err.Error())
- }
-
- time.Sleep(1000000000) // wait gorotine
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/andelf/go-curl/examples/sendrecv.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/sendrecv.go b/Godeps/_workspace/src/github.com/andelf/go-curl/examples/sendrecv.go
deleted file mode 100644
index 841825c..0000000
--- a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/sendrecv.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package main
-
-import (
- "fmt"
- curl "github.com/andelf/go-curl"
- "time"
-)
-
-const POST_DATA = "a_test_data_only"
-
-var sent = false
-
-func main() {
- // init the curl session
-
- easy := curl.EasyInit()
- defer easy.Cleanup()
-
- easy.Setopt(curl.OPT_URL, "http://www.renren.com")
-
- easy.Setopt(curl.OPT_PORT, 80)
- easy.Setopt(curl.OPT_VERBOSE, true)
- easy.Setopt(curl.OPT_CONNECT_ONLY, true)
-
- easy.Setopt(curl.OPT_WRITEFUNCTION, nil)
-
- if err := easy.Perform(); err != nil {
- println("ERROR: ", err.Error())
- }
-
- easy.Send([]byte("HEAD / HTTP/1.0\r\nHost: www.renren.com\r\n\r\n"))
-
- buf := make([]byte, 1000)
- time.Sleep(1000000000) // wait gorotine
- num, err := easy.Recv(buf)
- if err != nil {
- println("ERROR:", err.Error())
- }
- println("recv num = ", num)
- // NOTE: must use buf[:num]
- println(string(buf[:num]))
-
- fmt.Printf("got:\n%#v\n", string(buf[:num]))
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/andelf/go-curl/examples/sepheaders.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/sepheaders.go b/Godeps/_workspace/src/github.com/andelf/go-curl/examples/sepheaders.go
deleted file mode 100644
index b7603e3..0000000
--- a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/sepheaders.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package main
-
-import (
- curl "github.com/andelf/go-curl"
- "os"
-)
-
-const (
- headerfilename = "head.out"
- bodyfilename = "body.out"
-)
-
-func write_data(ptr []byte, userdata interface{}) bool {
- //println("DEBUG(write_data): ", userdata)
- //println("DEBUG", userdata.(interface{}))
- fp := userdata.(*os.File)
- if _, err := fp.Write(ptr); err == nil {
- return true
- }
- return false
-}
-
-func main() {
- curl.GlobalInit(curl.GLOBAL_ALL)
-
- // init the curl session
- easy := curl.EasyInit()
- defer easy.Cleanup()
-
- // set URL to get
- easy.Setopt(curl.OPT_URL, "http://cn.bing.com/")
-
- // no progress meter
- easy.Setopt(curl.OPT_NOPROGRESS, true)
-
- easy.Setopt(curl.OPT_WRITEFUNCTION, write_data)
-
- // write file
- fp, _ := os.OpenFile(bodyfilename, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0777)
- defer fp.Close()
- easy.Setopt(curl.OPT_WRITEDATA, fp)
-
- // easy.Setopt(curl.OPT_WRITEHEADER, 0)
-
- if err := easy.Perform(); err != nil {
- println("ERROR: ", err.Error())
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/andelf/go-curl/examples/simple.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/simple.go b/Godeps/_workspace/src/github.com/andelf/go-curl/examples/simple.go
deleted file mode 100644
index 8261ec6..0000000
--- a/Godeps/_workspace/src/github.com/andelf/go-curl/examples/simple.go
+++ /dev/null
@@ -1,14 +0,0 @@
-package main
-
-import (
- curl "github.com/andelf/go-curl"
-)
-
-func main() {
- easy := curl.EasyInit()
- defer easy.Cleanup()
- if easy != nil {
- easy.Setopt(curl.OPT_URL, "http://www.google.com/")
- easy.Perform()
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/andelf/go-curl/logging.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/andelf/go-curl/logging.go b/Godeps/_workspace/src/github.com/andelf/go-curl/logging.go
deleted file mode 100644
index 8976233..0000000
--- a/Godeps/_workspace/src/github.com/andelf/go-curl/logging.go
+++ /dev/null
@@ -1,56 +0,0 @@
-package curl
-
-import (
- "log"
-)
-
-const (
- _DEBUG = 10 * (iota + 1)
- _INFO
- _WARN
- _ERROR
-)
-
-const _DEFAULT_LOG_LEVEL = _WARN
-
-var log_level = _DEFAULT_LOG_LEVEL
-
-// SetLogLevel changes the log level which determines the granularity of the
-// messages that are logged. Available log levels are: "DEBUG", "INFO",
-// "WARN", "ERROR" and "DEFAULT_LOG_LEVEL".
-func SetLogLevel(levelName string) {
- switch levelName {
- case "DEBUG":
- log_level = _DEBUG
- case "INFO":
- log_level = _INFO
- case "WARN":
- log_level = _WARN
- case "ERROR":
- log_level = _ERROR
- case "DEFAULT_LOG_LEVEL":
- log_level = _DEFAULT_LOG_LEVEL
- }
-}
-
-func logf(limitLevel int, format string, args ...interface{}) {
- if log_level <= limitLevel {
- log.Printf(format, args...)
- }
-}
-
-func debugf(format string, args ...interface{}) {
- logf(_DEBUG, format, args...)
-}
-
-func infof(format string, args ...interface{}) {
- logf(_INFO, format, args...)
-}
-
-func warnf(format string, args ...interface{}) {
- logf(_WARN, format, args...)
-}
-
-func errorf(format string, args ...interface{}) {
- logf(_ERROR, format, args...)
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/andelf/go-curl/logging_test.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/andelf/go-curl/logging_test.go b/Godeps/_workspace/src/github.com/andelf/go-curl/logging_test.go
deleted file mode 100644
index 387705a..0000000
--- a/Godeps/_workspace/src/github.com/andelf/go-curl/logging_test.go
+++ /dev/null
@@ -1,64 +0,0 @@
-
-package curl
-
-import (
- "testing"
- "bytes"
- "log"
- "os"
- "fmt"
- "regexp"
-)
-
-func TestDefaultLogLevel(t *testing.T) {
- if log_level != _DEFAULT_LOG_LEVEL {t.Error("Test failed, expected DEFAULT_LOG_LEVEL level.")}
-}
-
-func TestSetLogLevel(t *testing.T) {
- SetLogLevel("DEBUG")
- defer SetLogLevel("DEFAULT_LOG_LEVEL")
- if log_level != _DEBUG {t.Error("Test failed, expected DEBUG level.")}
- SetLogLevel("INFO")
- if log_level != _INFO {t.Error("Test failed, expected INFO level.")}
- SetLogLevel("WARN")
- if log_level != _WARN {t.Error("Test failed, expected WARN level.")}
- SetLogLevel("ERROR")
- if log_level != _ERROR {t.Error("Test failed, expected ERROR level.")}
-}
-
-var (
- testFormat = "test format %s"
- testArgument = "test string 1"
- expectedRegexp = regexp.MustCompile(".*" + fmt.Sprintf(testFormat, testArgument) + "\n$")
-)
-
-
-func TestLogf(t *testing.T) {
- buf := new(bytes.Buffer)
- log.SetOutput(buf)
- defer log.SetOutput(os.Stderr)
- SetLogLevel("DEBUG")
- defer SetLogLevel("DEFAULT_LOG_LEVEL")
-
- logf(_DEBUG, testFormat, testArgument)
- line := buf.String()
- matched := expectedRegexp.MatchString(line)
- if !matched {
- t.Errorf("log output should match %q and is %q.", expectedRegexp, line)
- }
-}
-
-func TestLogfUsesLogLevel(t *testing.T) {
- buf := new(bytes.Buffer)
- log.SetOutput(buf)
- defer log.SetOutput(os.Stderr)
- SetLogLevel("WARN")
- defer SetLogLevel("DEFAULT_LOG_LEVEL")
-
- logf(_DEBUG, testFormat, testArgument)
- line := buf.String()
- expectedLine := ""
- if line != expectedLine {
- t.Errorf("log output should match %q and is %q.", expectedLine, line)
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/andelf/go-curl/misc/codegen.py
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/andelf/go-curl/misc/codegen.py b/Godeps/_workspace/src/github.com/andelf/go-curl/misc/codegen.py
deleted file mode 100644
index 08047e5..0000000
--- a/Godeps/_workspace/src/github.com/andelf/go-curl/misc/codegen.py
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/env python2
-# -*- coding: utf-8 -*-
-
-import re
-
-
-
-opts = []
-codes = []
-infos = []
-pattern = re.compile(r'CINIT\((.*?),\s+(LONG|OBJECTPOINT|FUNCTIONPOINT|OFF_T),\s+(\d+)\)')
-pattern2 = re.compile('^\s+(CURLE_[A-Z_0-9]+),')
-pattern3 = re.compile('^\s+(CURLINFO_[A-Z_0-9]+)\s+=')
-for line in open("./curl/include/curl/curl.h"):
- match = pattern.findall(line)
- if match:
- opts.append(match[0][0])
- if line.startswith('#define CURLOPT_'):
- o = line.split()
- opts.append(o[1][8:]) # strip :(
-
- match = pattern2.findall(line)
- if match:
- codes.append(match[0])
-
- if line.startswith('#define CURLE_'):
- c = line.split()
- codes.append(c[1])
-
- match = pattern3.findall(line)
- if match:
- infos.append(match[0])
-
- if line.startswith('#define CURLINFO_'):
- i = line.split()
- if '0x' not in i[2]: # :(
- infos.append(i[1])
-
-
-template = """
-// generated by codegen.py
-
-package curl
-/*
-#include <curl/curl.h>
-#include "compat.h"
-*/
-import "C"
-
-// CURLcode
-const (
-{code_part}
-)
-
-// easy.Setopt(flag, ...)
-const (
-{opt_part}
-)
-
-// easy.Getinfo(flag)
-const (
-{info_part}
-)
-
-// generated ends
-"""
-
-code_part = []
-for c in codes:
- code_part.append("\t{:<25} = C.{}".format(c[4:], c))
-
-code_part = '\n'.join(code_part)
-
-opt_part = []
-for o in opts:
- opt_part.append("\tOPT_{0:<25} = C.CURLOPT_{0}".format(o))
-
-opt_part = '\n'.join(opt_part)
-
-info_part = []
-for i in infos:
- info_part.append("\t{:<25} = C.{}".format(i[4:], i))
-
-info_part = '\n'.join(info_part)
-
-
-with open('./const_gen.go', 'w') as fp:
- fp.write(template.format(**locals()))
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/andelf/go-curl/misc/compatgen.py
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/andelf/go-curl/misc/compatgen.py b/Godeps/_workspace/src/github.com/andelf/go-curl/misc/compatgen.py
deleted file mode 100644
index e7f2860..0000000
--- a/Godeps/_workspace/src/github.com/andelf/go-curl/misc/compatgen.py
+++ /dev/null
@@ -1,162 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-import re
-import os
-
-def version_symbol(ver):
- os.system("cd ./curl && git checkout {}".format(ver))
- opts = []
- codes = []
- infos = []
- vers = []
- pattern = re.compile(r'CINIT\((.*?), (LONG|OBJECTPOINT|FUNCTIONPOINT|OFF_T), (\d+)\)')
- pattern2 = re.compile('^\s+(CURLE_[A-Z_0-9]+),')
- pattern3 = re.compile('^\s+(CURLINFO_[A-Z_0-9]+)\s+=')
- for line in open("./curl/include/curl/curl.h"):
- match = pattern.findall(line)
- if match:
- opts.append("CURLOPT_" + match[0][0])
- if line.startswith('#define CURLOPT_'):
- o = line.split()
- opts.append(o[1])
-
- match = pattern2.findall(line)
- if match:
- codes.append(match[0])
-
- if line.startswith('#define CURLE_'):
- c = line.split()
- codes.append(c[1])
-
- match = pattern3.findall(line)
- if match:
- infos.append(match[0])
-
- if line.startswith('#define CURLINFO_'):
- i = line.split()
- if '0x' not in i[2]: # :(
- infos.append(i[1])
-
- if line.startswith('#define CURL_VERSION_'):
- i = line.split()
- vers.append(i[1])
-
- return opts, codes, infos, vers
-
-
-versions = """
-curl-7_10_1
-curl-7_10_2
-curl-7_10_3
-curl-7_10_4
-curl-7_10_5
-curl-7_10_6
-curl-7_10_7
-curl-7_10_8
-curl-7_11_0
-curl-7_11_1
-curl-7_11_2
-curl-7_12_0
-curl-7_12_1
-curl-7_12_2
-curl-7_12_3
-curl-7_13_0
-curl-7_13_1
-curl-7_13_2
-curl-7_14_0
-curl-7_14_1
-curl-7_15_0
-curl-7_15_1
-curl-7_15_2
-curl-7_15_3
-curl-7_15_4
-curl-7_15_5
-curl-7_16_0
-curl-7_16_1
-curl-7_16_2
-curl-7_16_3
-curl-7_16_4
-curl-7_17_0
-curl-7_17_1
-curl-7_18_0
-curl-7_18_1
-curl-7_18_2
-curl-7_19_0
-curl-7_19_1
-curl-7_19_2
-curl-7_19_3
-curl-7_19_4
-curl-7_19_5
-curl-7_19_6
-curl-7_19_7
-curl-7_20_0
-curl-7_20_1
-curl-7_21_0
-curl-7_21_1
-curl-7_21_2
-curl-7_21_3
-curl-7_21_4
-curl-7_21_5
-curl-7_21_6
-curl-7_21_7
-curl-7_22_0
-curl-7_23_0
-curl-7_23_1
-curl-7_24_0
-curl-7_25_0
-curl-7_26_0
-curl-7_27_0
-curl-7_28_0
-curl-7_28_1
-curl-7_29_0
-curl-7_30_0
-curl-7_31_0
-curl-7_32_0
-curl-7_33_0
-curl-7_34_0
-curl-7_35_0
-curl-7_36_0""".split()[::-1]
-
-last = version_symbol("master")
-
-template = """
-/* generated by compatgen.py */
-#include<curl/curl.h>
-
-
-"""
-
-result = [template]
-result_tail = ["/* generated ends */\n"]
-if __name__ == '__main__':
- for ver in versions:
- minor, patch = map(int, ver.split("_")[-2:])
-
- opts, codes, infos, vers = curr = version_symbol(ver)
-
- for o in last[0]:
- if o not in opts:
- result.append("#define {} 0".format(o)) # 0 for nil option
- for c in last[1]:
- if c not in codes:
- result.append("#define {} -1".format(c)) # -1 for error
- for i in last[2]:
- if i not in infos:
- result.append("#define {} 0".format(i)) # 0 for nil
- for v in last[3]:
- if v not in vers:
- result.append("#define {} 0".format(v)) # 0 for nil
-
- result.append("#if (LIBCURL_VERSION_MINOR == {} && LIBCURL_VERSION_PATCH < {}) || LIBCURL_VERSION_MINOR < {} ".format(minor, patch, minor))
-
- result_tail.insert(0, "#endif /* 7.{}.{} */".format(minor, patch))
-
- last = curr
-
-result.append("#error your version is TOOOOOOOO low")
-
-result.extend(result_tail)
-
-with open("./compat.h", 'w') as fp:
- fp.write('\n'.join(result))
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/andelf/go-curl/multi.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/andelf/go-curl/multi.go b/Godeps/_workspace/src/github.com/andelf/go-curl/multi.go
deleted file mode 100644
index 814fd6e..0000000
--- a/Godeps/_workspace/src/github.com/andelf/go-curl/multi.go
+++ /dev/null
@@ -1,154 +0,0 @@
-package curl
-
-/*
-#include <stdlib.h>
-#include <curl/curl.h>
-
-static CURLMcode curl_multi_setopt_long(CURLM *handle, CURLMoption option, long parameter) {
- return curl_multi_setopt(handle, option, parameter);
-}
-static CURLMcode curl_multi_setopt_pointer(CURLM *handle, CURLMoption option, void *parameter) {
- return curl_multi_setopt(handle, option, parameter);
-}
-static CURLMcode curl_multi_fdset_pointer(CURLM *handle,
- void *read_fd_set,
- void *write_fd_set,
- void *exc_fd_set,
- int *max_fd)
-{
- return curl_multi_fdset(handle, read_fd_set, write_fd_set, exc_fd_set, max_fd);
-}
-static CURLMsg *curl_multi_info_read_pointer(CURLM *handle, int *msgs_in_queue)
-{
- return curl_multi_info_read(handle, msgs_in_queue);
-}
-*/
-import "C"
-
-import (
- "unsafe"
- "syscall"
-)
-
-type CurlMultiError C.CURLMcode
-type CurlMultiMsg C.CURLMSG
-
-func (e CurlMultiError) Error() string {
- // ret is const char*, no need to free
- ret := C.curl_multi_strerror(C.CURLMcode(e))
- return C.GoString(ret)
-}
-
-func newCurlMultiError(errno C.CURLMcode) error {
- // cannot use C.CURLM_OK here, cause multi.h use a undefined emum num
- if errno == 0 { // if nothing wrong
- return nil
- }
- return CurlMultiError(errno)
-}
-
-func newCURLMessage(message *C.CURLMsg) (msg *CURLMessage){
- if message == nil {
- return nil
- }
- msg = new(CURLMessage)
- msg.Msg = CurlMultiMsg(message.msg)
- msg.Easy_handle = &CURL{handle: message.easy_handle}
- msg.Data = message.data
- return msg
-}
-
-type CURLM struct {
- handle unsafe.Pointer
-}
-
-type CURLMessage struct {
- Msg CurlMultiMsg
- Easy_handle *CURL
- Data [8]byte
-}
-
-// curl_multi_init - create a multi handle
-func MultiInit() *CURLM {
- p := C.curl_multi_init()
- return &CURLM{p}
-}
-
-// curl_multi_cleanup - close down a multi session
-func (mcurl *CURLM) Cleanup() error {
- p := mcurl.handle
- return newCurlMultiError(C.curl_multi_cleanup(p))
-}
-
-// curl_multi_perform - reads/writes available data from each easy handle
-func (mcurl *CURLM) Perform() (int, error) {
- p := mcurl.handle
- running_handles := C.int(-1)
- err := newCurlMultiError(C.curl_multi_perform(p, &running_handles))
- return int(running_handles), err
-}
-
-// curl_multi_add_handle - add an easy handle to a multi session
-func (mcurl *CURLM) AddHandle(easy *CURL) error {
- mp := mcurl.handle
- easy_handle := easy.handle
- return newCurlMultiError(C.curl_multi_add_handle(mp, easy_handle))
-}
-
-// curl_multi_remove_handle - remove an easy handle from a multi session
-func (mcurl *CURLM) RemoveHandle(easy *CURL) error {
- mp := mcurl.handle
- easy_handle := easy.handle
- return newCurlMultiError(C.curl_multi_remove_handle(mp, easy_handle))
-}
-
-func (mcurl *CURLM) Timeout() (int, error) {
- p := mcurl.handle
- timeout := C.long(-1)
- err := newCurlMultiError(C.curl_multi_timeout(p, &timeout))
- return int(timeout), err
-}
-
-func (mcurl *CURLM) Setopt(opt int, param interface{}) error {
- p := mcurl.handle
- if param == nil {
- return newCurlMultiError(C.curl_multi_setopt_pointer(p, C.CURLMoption(opt), nil))
- }
- switch {
- // currently cannot support these option
- // case MOPT_SOCKETFUNCTION, MOPT_SOCKETDATA, MOPT_TIMERFUNCTION, MOPT_TIMERDATA:
- // panic("not supported CURLM.Setopt opt")
- case opt >= C.CURLOPTTYPE_LONG:
- val := C.long(0)
- switch t := param.(type) {
- case int:
- val := C.long(t)
- return newCurlMultiError(C.curl_multi_setopt_long(p, C.CURLMoption(opt), val))
- case bool:
- val = C.long(0)
- if t {
- val = C.long(1)
- }
- return newCurlMultiError(C.curl_multi_setopt_long(p, C.CURLMoption(opt), val))
- }
- }
- panic("not supported CURLM.Setopt opt or param")
- return nil
-}
-
-func (mcurl *CURLM) Fdset(rset, wset, eset *syscall.FdSet) (int, error) {
- p := mcurl.handle
- read := unsafe.Pointer(rset)
- write := unsafe.Pointer(wset)
- exc := unsafe.Pointer(eset)
- maxfd := C.int(-1)
- err := newCurlMultiError(C.curl_multi_fdset_pointer(p, read, write,
- exc, &maxfd))
- return int(maxfd), err
-}
-
-func (mcurl *CURLM) Info_read() (*CURLMessage, int) {
- p := mcurl.handle
- left := C.int(0)
- return newCURLMessage(C.curl_multi_info_read_pointer(p, &left)), int(left)
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/andelf/go-curl/share.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/andelf/go-curl/share.go b/Godeps/_workspace/src/github.com/andelf/go-curl/share.go
deleted file mode 100644
index 8d1e16d..0000000
--- a/Godeps/_workspace/src/github.com/andelf/go-curl/share.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package curl
-
-/*
-#include <curl/curl.h>
-
-static CURLSHcode curl_share_setopt_long(CURLSH *handle, CURLSHoption option, long parameter) {
- return curl_share_setopt(handle, option, parameter);
-}
-static CURLSHcode curl_share_setopt_pointer(CURLSH *handle, CURLSHoption option, void *parameter) {
- return curl_share_setopt(handle, option, parameter);
-}
-*/
-import "C"
-
-import "unsafe"
-
-// implement os.Error interface
-type CurlShareError C.CURLMcode
-
-func (e CurlShareError) Error() string {
- // ret is const char*, no need to free
- ret := C.curl_share_strerror(C.CURLSHcode(e))
- return C.GoString(ret)
-}
-
-func newCurlShareError(errno C.CURLSHcode) error {
- if errno == 0 { // if nothing wrong
- return nil
- }
- return CurlShareError(errno)
-}
-
-type CURLSH struct {
- handle unsafe.Pointer
-}
-
-func ShareInit() *CURLSH {
- p := C.curl_share_init()
- return &CURLSH{p}
-}
-
-func (shcurl *CURLSH) Cleanup() error {
- p := shcurl.handle
- return newCurlShareError(C.curl_share_cleanup(p))
-}
-
-func (shcurl *CURLSH) Setopt(opt int, param interface{}) error {
- p := shcurl.handle
- if param == nil {
- return newCurlShareError(C.curl_share_setopt_pointer(p, C.CURLSHoption(opt), nil))
- }
- switch opt {
- // case SHOPT_LOCKFUNC, SHOPT_UNLOCKFUNC, SHOPT_USERDATA:
- // panic("not supported")
- case SHOPT_SHARE, SHOPT_UNSHARE:
- if val, ok := param.(int); ok {
- return newCurlShareError(C.curl_share_setopt_long(p, C.CURLSHoption(opt), C.long(val)))
- }
- }
- panic("not supported CURLSH.Setopt opt or param")
- return nil
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/hashicorp/logutils/.gitignore
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/hashicorp/logutils/.gitignore b/Godeps/_workspace/src/github.com/hashicorp/logutils/.gitignore
deleted file mode 100644
index 0026861..0000000
--- a/Godeps/_workspace/src/github.com/hashicorp/logutils/.gitignore
+++ /dev/null
@@ -1,22 +0,0 @@
-# Compiled Object files, Static and Dynamic libs (Shared Objects)
-*.o
-*.a
-*.so
-
-# Folders
-_obj
-_test
-
-# Architecture specific extensions/prefixes
-*.[568vq]
-[568vq].out
-
-*.cgo1.go
-*.cgo2.c
-_cgo_defun.c
-_cgo_gotypes.go
-_cgo_export.*
-
-_testmain.go
-
-*.exe
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/hashicorp/logutils/LICENSE
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/hashicorp/logutils/LICENSE b/Godeps/_workspace/src/github.com/hashicorp/logutils/LICENSE
deleted file mode 100644
index c33dcc7..0000000
--- a/Godeps/_workspace/src/github.com/hashicorp/logutils/LICENSE
+++ /dev/null
@@ -1,354 +0,0 @@
-Mozilla Public License, version 2.0
-
-1. Definitions
-
-1.1. “Contributor”
-
- means each individual or legal entity that creates, contributes to the
- creation of, or owns Covered Software.
-
-1.2. “Contributor Version”
-
- means the combination of the Contributions of others (if any) used by a
- Contributor and that particular Contributor’s Contribution.
-
-1.3. “Contribution”
-
- means Covered Software of a particular Contributor.
-
-1.4. “Covered Software”
-
- means Source Code Form to which the initial Contributor has attached the
- notice in Exhibit A, the Executable Form of such Source Code Form, and
- Modifications of such Source Code Form, in each case including portions
- thereof.
-
-1.5. “Incompatible With Secondary Licenses”
- means
-
- a. that the initial Contributor has attached the notice described in
- Exhibit B to the Covered Software; or
-
- b. that the Covered Software was made available under the terms of version
- 1.1 or earlier of the License, but not also under the terms of a
- Secondary License.
-
-1.6. “Executable Form”
-
- means any form of the work other than Source Code Form.
-
-1.7. “Larger Work”
-
- means a work that combines Covered Software with other material, in a separate
- file or files, that is not Covered Software.
-
-1.8. “License”
-
- means this document.
-
-1.9. “Licensable”
-
- means having the right to grant, to the maximum extent possible, whether at the
- time of the initial grant or subsequently, any and all of the rights conveyed by
- this License.
-
-1.10. “Modifications”
-
- means any of the following:
-
- a. any file in Source Code Form that results from an addition to, deletion
- from, or modification of the contents of Covered Software; or
-
- b. any new file in Source Code Form that contains any Covered Software.
-
-1.11. “Patent Claims” of a Contributor
-
- means any patent claim(s), including without limitation, method, process,
- and apparatus claims, in any patent Licensable by such Contributor that
- would be infringed, but for the grant of the License, by the making,
- using, selling, offering for sale, having made, import, or transfer of
- either its Contributions or its Contributor Version.
-
-1.12. “Secondary License”
-
- means either the GNU General Public License, Version 2.0, the GNU Lesser
- General Public License, Version 2.1, the GNU Affero General Public
- License, Version 3.0, or any later versions of those licenses.
-
-1.13. “Source Code Form”
-
- means the form of the work preferred for making modifications.
-
-1.14. “You” (or “Your”)
-
- means an individual or a legal entity exercising rights under this
- License. For legal entities, “You” includes any entity that controls, is
- controlled by, or is under common control with You. For purposes of this
- definition, “control” means (a) the power, direct or indirect, to cause
- the direction or management of such entity, whether by contract or
- otherwise, or (b) ownership of more than fifty percent (50%) of the
- outstanding shares or beneficial ownership of such entity.
-
-
-2. License Grants and Conditions
-
-2.1. Grants
-
- Each Contributor hereby grants You a world-wide, royalty-free,
- non-exclusive license:
-
- a. under intellectual property rights (other than patent or trademark)
- Licensable by such Contributor to use, reproduce, make available,
- modify, display, perform, distribute, and otherwise exploit its
- Contributions, either on an unmodified basis, with Modifications, or as
- part of a Larger Work; and
-
- b. under Patent Claims of such Contributor to make, use, sell, offer for
- sale, have made, import, and otherwise transfer either its Contributions
- or its Contributor Version.
-
-2.2. Effective Date
-
- The licenses granted in Section 2.1 with respect to any Contribution become
- effective for each Contribution on the date the Contributor first distributes
- such Contribution.
-
-2.3. Limitations on Grant Scope
-
- The licenses granted in this Section 2 are the only rights granted under this
- License. No additional rights or licenses will be implied from the distribution
- or licensing of Covered Software under this License. Notwithstanding Section
- 2.1(b) above, no patent license is granted by a Contributor:
-
- a. for any code that a Contributor has removed from Covered Software; or
-
- b. for infringements caused by: (i) Your and any other third party’s
- modifications of Covered Software, or (ii) the combination of its
- Contributions with other software (except as part of its Contributor
- Version); or
-
- c. under Patent Claims infringed by Covered Software in the absence of its
- Contributions.
-
- This License does not grant any rights in the trademarks, service marks, or
- logos of any Contributor (except as may be necessary to comply with the
- notice requirements in Section 3.4).
-
-2.4. Subsequent Licenses
-
- No Contributor makes additional grants as a result of Your choice to
- distribute the Covered Software under a subsequent version of this License
- (see Section 10.2) or under the terms of a Secondary License (if permitted
- under the terms of Section 3.3).
-
-2.5. Representation
-
- Each Contributor represents that the Contributor believes its Contributions
- are its original creation(s) or it has sufficient rights to grant the
- rights to its Contributions conveyed by this License.
-
-2.6. Fair Use
-
- This License is not intended to limit any rights You have under applicable
- copyright doctrines of fair use, fair dealing, or other equivalents.
-
-2.7. Conditions
-
- Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
- Section 2.1.
-
-
-3. Responsibilities
-
-3.1. Distribution of Source Form
-
- All distribution of Covered Software in Source Code Form, including any
- Modifications that You create or to which You contribute, must be under the
- terms of this License. You must inform recipients that the Source Code Form
- of the Covered Software is governed by the terms of this License, and how
- they can obtain a copy of this License. You may not attempt to alter or
- restrict the recipients’ rights in the Source Code Form.
-
-3.2. Distribution of Executable Form
-
- If You distribute Covered Software in Executable Form then:
-
- a. such Covered Software must also be made available in Source Code Form,
- as described in Section 3.1, and You must inform recipients of the
- Executable Form how they can obtain a copy of such Source Code Form by
- reasonable means in a timely manner, at a charge no more than the cost
- of distribution to the recipient; and
-
- b. You may distribute such Executable Form under the terms of this License,
- or sublicense it under different terms, provided that the license for
- the Executable Form does not attempt to limit or alter the recipients’
- rights in the Source Code Form under this License.
-
-3.3. Distribution of a Larger Work
-
- You may create and distribute a Larger Work under terms of Your choice,
- provided that You also comply with the requirements of this License for the
- Covered Software. If the Larger Work is a combination of Covered Software
- with a work governed by one or more Secondary Licenses, and the Covered
- Software is not Incompatible With Secondary Licenses, this License permits
- You to additionally distribute such Covered Software under the terms of
- such Secondary License(s), so that the recipient of the Larger Work may, at
- their option, further distribute the Covered Software under the terms of
- either this License or such Secondary License(s).
-
-3.4. Notices
-
- You may not remove or alter the substance of any license notices (including
- copyright notices, patent notices, disclaimers of warranty, or limitations
- of liability) contained within the Source Code Form of the Covered
- Software, except that You may alter any license notices to the extent
- required to remedy known factual inaccuracies.
-
-3.5. Application of Additional Terms
-
- You may choose to offer, and to charge a fee for, warranty, support,
- indemnity or liability obligations to one or more recipients of Covered
- Software. However, You may do so only on Your own behalf, and not on behalf
- of any Contributor. You must make it absolutely clear that any such
- warranty, support, indemnity, or liability obligation is offered by You
- alone, and You hereby agree to indemnify every Contributor for any
- liability incurred by such Contributor as a result of warranty, support,
- indemnity or liability terms You offer. You may include additional
- disclaimers of warranty and limitations of liability specific to any
- jurisdiction.
-
-4. Inability to Comply Due to Statute or Regulation
-
- If it is impossible for You to comply with any of the terms of this License
- with respect to some or all of the Covered Software due to statute, judicial
- order, or regulation then You must: (a) comply with the terms of this License
- to the maximum extent possible; and (b) describe the limitations and the code
- they affect. Such description must be placed in a text file included with all
- distributions of the Covered Software under this License. Except to the
- extent prohibited by statute or regulation, such description must be
- sufficiently detailed for a recipient of ordinary skill to be able to
- understand it.
-
-5. Termination
-
-5.1. The rights granted under this License will terminate automatically if You
- fail to comply with any of its terms. However, if You become compliant,
- then the rights granted under this License from a particular Contributor
- are reinstated (a) provisionally, unless and until such Contributor
- explicitly and finally terminates Your grants, and (b) on an ongoing basis,
- if such Contributor fails to notify You of the non-compliance by some
- reasonable means prior to 60 days after You have come back into compliance.
- Moreover, Your grants from a particular Contributor are reinstated on an
- ongoing basis if such Contributor notifies You of the non-compliance by
- some reasonable means, this is the first time You have received notice of
- non-compliance with this License from such Contributor, and You become
- compliant prior to 30 days after Your receipt of the notice.
-
-5.2. If You initiate litigation against any entity by asserting a patent
- infringement claim (excluding declaratory judgment actions, counter-claims,
- and cross-claims) alleging that a Contributor Version directly or
- indirectly infringes any patent, then the rights granted to You by any and
- all Contributors for the Covered Software under Section 2.1 of this License
- shall terminate.
-
-5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
- license agreements (excluding distributors and resellers) which have been
- validly granted by You or Your distributors under this License prior to
- termination shall survive termination.
-
-6. Disclaimer of Warranty
-
- Covered Software is provided under this License on an “as is” basis, without
- warranty of any kind, either expressed, implied, or statutory, including,
- without limitation, warranties that the Covered Software is free of defects,
- merchantable, fit for a particular purpose or non-infringing. The entire
- risk as to the quality and performance of the Covered Software is with You.
- Should any Covered Software prove defective in any respect, You (not any
- Contributor) assume the cost of any necessary servicing, repair, or
- correction. This disclaimer of warranty constitutes an essential part of this
- License. No use of any Covered Software is authorized under this License
- except under this disclaimer.
-
-7. Limitation of Liability
-
- Under no circumstances and under no legal theory, whether tort (including
- negligence), contract, or otherwise, shall any Contributor, or anyone who
- distributes Covered Software as permitted above, be liable to You for any
- direct, indirect, special, incidental, or consequential damages of any
- character including, without limitation, damages for lost profits, loss of
- goodwill, work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses, even if such party shall have been
- informed of the possibility of such damages. This limitation of liability
- shall not apply to liability for death or personal injury resulting from such
- party’s negligence to the extent applicable law prohibits such limitation.
- Some jurisdictions do not allow the exclusion or limitation of incidental or
- consequential damages, so this exclusion and limitation may not apply to You.
-
-8. Litigation
-
- Any litigation relating to this License may be brought only in the courts of
- a jurisdiction where the defendant maintains its principal place of business
- and such litigation shall be governed by laws of that jurisdiction, without
- reference to its conflict-of-law provisions. Nothing in this Section shall
- prevent a party’s ability to bring cross-claims or counter-claims.
-
-9. Miscellaneous
-
- This License represents the complete agreement concerning the subject matter
- hereof. If any provision of this License is held to be unenforceable, such
- provision shall be reformed only to the extent necessary to make it
- enforceable. Any law or regulation which provides that the language of a
- contract shall be construed against the drafter shall not be used to construe
- this License against a Contributor.
-
-
-10. Versions of the License
-
-10.1. New Versions
-
- Mozilla Foundation is the license steward. Except as provided in Section
- 10.3, no one other than the license steward has the right to modify or
- publish new versions of this License. Each version will be given a
- distinguishing version number.
-
-10.2. Effect of New Versions
-
- You may distribute the Covered Software under the terms of the version of
- the License under which You originally received the Covered Software, or
- under the terms of any subsequent version published by the license
- steward.
-
-10.3. Modified Versions
-
- If you create software not governed by this License, and you want to
- create a new license for such software, you may create and use a modified
- version of this License if you rename the license and remove any
- references to the name of the license steward (except to note that such
- modified license differs from this License).
-
-10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
- If You choose to distribute Source Code Form that is Incompatible With
- Secondary Licenses under the terms of this version of the License, the
- notice described in Exhibit B of this License must be attached.
-
-Exhibit A - Source Code Form License Notice
-
- This Source Code Form is subject to the
- terms of the Mozilla Public License, v.
- 2.0. If a copy of the MPL was not
- distributed with this file, You can
- obtain one at
- http://mozilla.org/MPL/2.0/.
-
-If it is not possible or desirable to put the notice in a particular file, then
-You may include the notice in a location (such as a LICENSE file in a relevant
-directory) where a recipient would be likely to look for such a notice.
-
-You may add additional accurate notices of copyright ownership.
-
-Exhibit B - “Incompatible With Secondary Licenses” Notice
-
- This Source Code Form is “Incompatible
- With Secondary Licenses”, as defined by
- the Mozilla Public License, v. 2.0.
-
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/hashicorp/logutils/README.md
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/hashicorp/logutils/README.md b/Godeps/_workspace/src/github.com/hashicorp/logutils/README.md
deleted file mode 100644
index 49490ea..0000000
--- a/Godeps/_workspace/src/github.com/hashicorp/logutils/README.md
+++ /dev/null
@@ -1,36 +0,0 @@
-# logutils
-
-logutils is a Go package that augments the standard library "log" package
-to make logging a bit more modern, without fragmenting the Go ecosystem
-with new logging packages.
-
-## The simplest thing that could possibly work
-
-Presumably your application already uses the default `log` package. To switch, you'll want your code to look like the following:
-
-```go
-package main
-
-import (
- "log"
- "os"
-
- "github.com/hashicorp/logutils"
-)
-
-func main() {
- filter := &logutils.LevelFilter{
- Levels: []logutils.LogLevel{"DEBUG", "WARN", "ERROR"},
- MinLevel: logutils.LogLevel("WARN"),
- Writer: os.Stderr,
- }
- log.SetOutput(filter)
-
- log.Print("[DEBUG] Debugging") // this will not print
- log.Print("[WARN] Warning") // this will
- log.Print("[ERROR] Erring") // and so will this
- log.Print("Message I haven't updated") // and so will this
-}
-```
-
-This logs to standard error exactly like go's standard logger. Any log messages you haven't converted to have a level will continue to print as before.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/hashicorp/logutils/level.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/hashicorp/logutils/level.go b/Godeps/_workspace/src/github.com/hashicorp/logutils/level.go
deleted file mode 100644
index 6381bf1..0000000
--- a/Godeps/_workspace/src/github.com/hashicorp/logutils/level.go
+++ /dev/null
@@ -1,81 +0,0 @@
-// Package logutils augments the standard log package with levels.
-package logutils
-
-import (
- "bytes"
- "io"
- "sync"
-)
-
-type LogLevel string
-
-// LevelFilter is an io.Writer that can be used with a logger that
-// will filter out log messages that aren't at least a certain level.
-//
-// Once the filter is in use somewhere, it is not safe to modify
-// the structure.
-type LevelFilter struct {
- // Levels is the list of log levels, in increasing order of
- // severity. Example might be: {"DEBUG", "WARN", "ERROR"}.
- Levels []LogLevel
-
- // MinLevel is the minimum level allowed through
- MinLevel LogLevel
-
- // The underlying io.Writer where log messages that pass the filter
- // will be set.
- Writer io.Writer
-
- badLevels map[LogLevel]struct{}
- once sync.Once
-}
-
-// Check will check a given line if it would be included in the level
-// filter.
-func (f *LevelFilter) Check(line []byte) bool {
- f.once.Do(f.init)
-
- // Check for a log level
- var level LogLevel
- x := bytes.IndexByte(line, '[')
- if x >= 0 {
- y := bytes.IndexByte(line[x:], ']')
- if y >= 0 {
- level = LogLevel(line[x+1 : x+y])
- }
- }
-
- _, ok := f.badLevels[level]
- return !ok
-}
-
-func (f *LevelFilter) Write(p []byte) (n int, err error) {
- // Note in general that io.Writer can receive any byte sequence
- // to write, but the "log" package always guarantees that we only
- // get a single line. We use that as a slight optimization within
- // this method, assuming we're dealing with a single, complete line
- // of log data.
-
- if !f.Check(p) {
- return len(p), nil
- }
-
- return f.Writer.Write(p)
-}
-
-// SetMinLevel is used to update the minimum log level
-func (f *LevelFilter) SetMinLevel(min LogLevel) {
- f.MinLevel = min
- f.init()
-}
-
-func (f *LevelFilter) init() {
- badLevels := make(map[LogLevel]struct{})
- for _, level := range f.Levels {
- if level == f.MinLevel {
- break
- }
- badLevels[level] = struct{}{}
- }
- f.badLevels = badLevels
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/hashicorp/logutils/level_benchmark_test.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/hashicorp/logutils/level_benchmark_test.go b/Godeps/_workspace/src/github.com/hashicorp/logutils/level_benchmark_test.go
deleted file mode 100644
index 3c2caf7..0000000
--- a/Godeps/_workspace/src/github.com/hashicorp/logutils/level_benchmark_test.go
+++ /dev/null
@@ -1,37 +0,0 @@
-package logutils
-
-import (
- "io/ioutil"
- "testing"
-)
-
-var messages [][]byte
-
-func init() {
- messages = [][]byte{
- []byte("[TRACE] foo"),
- []byte("[DEBUG] foo"),
- []byte("[INFO] foo"),
- []byte("[WARN] foo"),
- []byte("[ERROR] foo"),
- }
-}
-
-func BenchmarkDiscard(b *testing.B) {
- for i := 0; i < b.N; i++ {
- ioutil.Discard.Write(messages[i%len(messages)])
- }
-}
-
-func BenchmarkLevelFilter(b *testing.B) {
- filter := &LevelFilter{
- Levels: []LogLevel{"TRACE", "DEBUG", "INFO", "WARN", "ERROR"},
- MinLevel: "WARN",
- Writer: ioutil.Discard,
- }
-
- b.ResetTimer()
- for i := 0; i < b.N; i++ {
- filter.Write(messages[i%len(messages)])
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/hashicorp/logutils/level_test.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/hashicorp/logutils/level_test.go b/Godeps/_workspace/src/github.com/hashicorp/logutils/level_test.go
deleted file mode 100644
index f6b6ac3..0000000
--- a/Godeps/_workspace/src/github.com/hashicorp/logutils/level_test.go
+++ /dev/null
@@ -1,94 +0,0 @@
-package logutils
-
-import (
- "bytes"
- "io"
- "log"
- "testing"
-)
-
-func TestLevelFilter_impl(t *testing.T) {
- var _ io.Writer = new(LevelFilter)
-}
-
-func TestLevelFilter(t *testing.T) {
- buf := new(bytes.Buffer)
- filter := &LevelFilter{
- Levels: []LogLevel{"DEBUG", "WARN", "ERROR"},
- MinLevel: "WARN",
- Writer: buf,
- }
-
- logger := log.New(filter, "", 0)
- logger.Print("[WARN] foo")
- logger.Println("[ERROR] bar")
- logger.Println("[DEBUG] baz")
- logger.Println("[WARN] buzz")
-
- result := buf.String()
- expected := "[WARN] foo\n[ERROR] bar\n[WARN] buzz\n"
- if result != expected {
- t.Fatalf("bad: %#v", result)
- }
-}
-
-func TestLevelFilterCheck(t *testing.T) {
- filter := &LevelFilter{
- Levels: []LogLevel{"DEBUG", "WARN", "ERROR"},
- MinLevel: "WARN",
- Writer: nil,
- }
-
- testCases := []struct {
- line string
- check bool
- }{
- {"[WARN] foo\n", true},
- {"[ERROR] bar\n", true},
- {"[DEBUG] baz\n", false},
- {"[WARN] buzz\n", true},
- }
-
- for _, testCase := range testCases {
- result := filter.Check([]byte(testCase.line))
- if result != testCase.check {
- t.Errorf("Fail: %s", testCase.line)
- }
- }
-}
-
-func TestLevelFilter_SetMinLevel(t *testing.T) {
- filter := &LevelFilter{
- Levels: []LogLevel{"DEBUG", "WARN", "ERROR"},
- MinLevel: "ERROR",
- Writer: nil,
- }
-
- testCases := []struct {
- line string
- checkBefore bool
- checkAfter bool
- }{
- {"[WARN] foo\n", false, true},
- {"[ERROR] bar\n", true, true},
- {"[DEBUG] baz\n", false, false},
- {"[WARN] buzz\n", false, true},
- }
-
- for _, testCase := range testCases {
- result := filter.Check([]byte(testCase.line))
- if result != testCase.checkBefore {
- t.Errorf("Fail: %s", testCase.line)
- }
- }
-
- // Update the minimum level to WARN
- filter.SetMinLevel("WARN")
-
- for _, testCase := range testCases {
- result := filter.Check([]byte(testCase.line))
- if result != testCase.checkAfter {
- t.Errorf("Fail: %s", testCase.line)
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/LICENSE
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/LICENSE b/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/LICENSE
deleted file mode 100644
index 5f0d1fb..0000000
--- a/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/LICENSE
+++ /dev/null
@@ -1,13 +0,0 @@
-Copyright 2014 Alan Shreve
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/README.md
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/README.md b/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/README.md
deleted file mode 100644
index 7a950d1..0000000
--- a/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/README.md
+++ /dev/null
@@ -1,23 +0,0 @@
-# mousetrap
-
-mousetrap is a tiny library that answers a single question.
-
-On a Windows machine, was the process invoked by someone double clicking on
-the executable file while browsing in explorer?
-
-### Motivation
-
-Windows developers unfamiliar with command line tools will often "double-click"
-the executable for a tool. Because most CLI tools print the help and then exit
-when invoked without arguments, this is often very frustrating for those users.
-
-mousetrap provides a way to detect these invocations so that you can provide
-more helpful behavior and instructions on how to run the CLI tool. To see what
-this looks like, both from an organizational and a technical perspective, see
-https://inconshreveable.com/09-09-2014/sweat-the-small-stuff/
-
-### The interface
-
-The library exposes a single interface:
-
- func StartedByExplorer() (bool)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_others.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_others.go b/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_others.go
deleted file mode 100644
index 9d2d8a4..0000000
--- a/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_others.go
+++ /dev/null
@@ -1,15 +0,0 @@
-// +build !windows
-
-package mousetrap
-
-// StartedByExplorer returns true if the program was invoked by the user
-// double-clicking on the executable from explorer.exe
-//
-// It is conservative and returns false if any of the internal calls fail.
-// It does not guarantee that the program was run from a terminal. It only can tell you
-// whether it was launched from explorer.exe
-//
-// On non-Windows platforms, it always returns false.
-func StartedByExplorer() bool {
- return false
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e95057f4/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_windows.go
----------------------------------------------------------------------
diff --git a/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_windows.go b/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_windows.go
deleted file mode 100644
index 336142a..0000000
--- a/Godeps/_workspace/src/github.com/inconshreveable/mousetrap/trap_windows.go
+++ /dev/null
@@ -1,98 +0,0 @@
-// +build windows
-// +build !go1.4
-
-package mousetrap
-
-import (
- "fmt"
- "os"
- "syscall"
- "unsafe"
-)
-
-const (
- // defined by the Win32 API
- th32cs_snapprocess uintptr = 0x2
-)
-
-var (
- kernel = syscall.MustLoadDLL("kernel32.dll")
- CreateToolhelp32Snapshot = kernel.MustFindProc("CreateToolhelp32Snapshot")
- Process32First = kernel.MustFindProc("Process32FirstW")
- Process32Next = kernel.MustFindProc("Process32NextW")
-)
-
-// ProcessEntry32 structure defined by the Win32 API
-type processEntry32 struct {
- dwSize uint32
- cntUsage uint32
- th32ProcessID uint32
- th32DefaultHeapID int
- th32ModuleID uint32
- cntThreads uint32
- th32ParentProcessID uint32
- pcPriClassBase int32
- dwFlags uint32
- szExeFile [syscall.MAX_PATH]uint16
-}
-
-func getProcessEntry(pid int) (pe *processEntry32, err error) {
- snapshot, _, e1 := CreateToolhelp32Snapshot.Call(th32cs_snapprocess, uintptr(0))
- if snapshot == uintptr(syscall.InvalidHandle) {
- err = fmt.Errorf("CreateToolhelp32Snapshot: %v", e1)
- return
- }
- defer syscall.CloseHandle(syscall.Handle(snapshot))
-
- var processEntry processEntry32
- processEntry.dwSize = uint32(unsafe.Sizeof(processEntry))
- ok, _, e1 := Process32First.Call(snapshot, uintptr(unsafe.Pointer(&processEntry)))
- if ok == 0 {
- err = fmt.Errorf("Process32First: %v", e1)
- return
- }
-
- for {
- if processEntry.th32ProcessID == uint32(pid) {
- pe = &processEntry
- return
- }
-
- ok, _, e1 = Process32Next.Call(snapshot, uintptr(unsafe.Pointer(&processEntry)))
- if ok == 0 {
- err = fmt.Errorf("Process32Next: %v", e1)
- return
- }
- }
-}
-
-func getppid() (pid int, err error) {
- pe, err := getProcessEntry(os.Getpid())
- if err != nil {
- return
- }
-
- pid = int(pe.th32ParentProcessID)
- return
-}
-
-// StartedByExplorer returns true if the program was invoked by the user double-clicking
-// on the executable from explorer.exe
-//
-// It is conservative and returns false if any of the internal calls fail.
-// It does not guarantee that the program was run from a terminal. It only can tell you
-// whether it was launched from explorer.exe
-func StartedByExplorer() bool {
- ppid, err := getppid()
- if err != nil {
- return false
- }
-
- pe, err := getProcessEntry(ppid)
- if err != nil {
- return false
- }
-
- name := syscall.UTF16ToString(pe.szExeFile[:])
- return name == "explorer.exe"
-}