updated libraries
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/tag Build is failing

This commit is contained in:
Paul 2021-01-30 12:50:30 +01:00
parent 21dcea6c7f
commit 521d3b0945
42 changed files with 1419 additions and 168 deletions

9
go.mod
View File

@ -28,11 +28,11 @@ require (
github.com/spf13/cobra v1.1.1 github.com/spf13/cobra v1.1.1
github.com/stretchr/testify v1.6.1 // indirect github.com/stretchr/testify v1.6.1 // indirect
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect
golang.org/x/net v0.0.0-20201224014010-6772e930b67b golang.org/x/net v0.0.0-20210119194325-5f4716e94777
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a // indirect golang.org/x/sync v0.0.0-20201207232520-09787c993a3a // indirect
golang.org/x/sys v0.0.0-20201223074533-0d417f636930 // indirect golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf // indirect golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf // indirect
golang.org/x/text v0.3.4 // indirect golang.org/x/text v0.3.5 // indirect
golang.org/x/tools v0.0.0-20201226215659-b1c90890d22a // indirect golang.org/x/tools v0.0.0-20201226215659-b1c90890d22a // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/protobuf v1.25.0 // indirect google.golang.org/protobuf v1.25.0 // indirect
@ -40,5 +40,6 @@ require (
gopkg.in/ini.v1 v1.62.0 gopkg.in/ini.v1 v1.62.0
gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
xorm.io/xorm v1.0.5 xorm.io/builder v0.3.8 // indirect
xorm.io/xorm v1.0.7
) )

10
go.sum
View File

@ -386,6 +386,8 @@ golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb h1:eBmm0M9fYhWpKZLjQUUKka/Lt
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201224014010-6772e930b67b h1:iFwSg7t5GZmB/Q5TjiEAsdoLDrdJRC1RiF2WhuV29Qw= golang.org/x/net v0.0.0-20201224014010-6772e930b67b h1:iFwSg7t5GZmB/Q5TjiEAsdoLDrdJRC1RiF2WhuV29Qw=
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 h1:003p0dJM77cxMSyCPFphvZf/Y5/NXf5fzg6ufd1/Oew=
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@ -430,6 +432,8 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201223074533-0d417f636930 h1:vRgIt+nup/B/BwIS0g2oC0haq0iqbV3ZA+u6+0TlNCo= golang.org/x/sys v0.0.0-20201223074533-0d417f636930 h1:vRgIt+nup/B/BwIS0g2oC0haq0iqbV3ZA+u6+0TlNCo=
golang.org/x/sys v0.0.0-20201223074533-0d417f636930/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201223074533-0d417f636930/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221 h1:/ZHdbVpdR/jk3g30/d4yUL0JU9kksj8+F/bnQUVLGDM= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221 h1:/ZHdbVpdR/jk3g30/d4yUL0JU9kksj8+F/bnQUVLGDM=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
@ -444,6 +448,8 @@ golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc= golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@ -553,5 +559,9 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
xorm.io/builder v0.3.7 h1:2pETdKRK+2QG4mLX4oODHEhn5Z8j1m8sXa7jfu+/SZI= xorm.io/builder v0.3.7 h1:2pETdKRK+2QG4mLX4oODHEhn5Z8j1m8sXa7jfu+/SZI=
xorm.io/builder v0.3.7/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE= xorm.io/builder v0.3.7/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
xorm.io/builder v0.3.8 h1:P/wPgRqa9kX5uE0aA1/ukJ23u9KH0aSRpHLwDKXigSE=
xorm.io/builder v0.3.8/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
xorm.io/xorm v1.0.5 h1:LRr5PfOUb4ODPR63YwbowkNDwcolT2LnkwP/TUaMaB0= xorm.io/xorm v1.0.5 h1:LRr5PfOUb4ODPR63YwbowkNDwcolT2LnkwP/TUaMaB0=
xorm.io/xorm v1.0.5/go.mod h1:uF9EtbhODq5kNWxMbnBEj8hRRZnlcNSz2t2N7HW/+A4= xorm.io/xorm v1.0.5/go.mod h1:uF9EtbhODq5kNWxMbnBEj8hRRZnlcNSz2t2N7HW/+A4=
xorm.io/xorm v1.0.7 h1:26yBTDVI+CfQpVz2Y88fISh+aiJXIPP4eNoTJlwzsC4=
xorm.io/xorm v1.0.7/go.mod h1:uF9EtbhODq5kNWxMbnBEj8hRRZnlcNSz2t2N7HW/+A4=

View File

@ -204,6 +204,7 @@ struct ltchars {
#include <linux/devlink.h> #include <linux/devlink.h>
#include <linux/dm-ioctl.h> #include <linux/dm-ioctl.h>
#include <linux/errqueue.h> #include <linux/errqueue.h>
#include <linux/ethtool_netlink.h>
#include <linux/falloc.h> #include <linux/falloc.h>
#include <linux/fanotify.h> #include <linux/fanotify.h>
#include <linux/filter.h> #include <linux/filter.h>
@ -563,6 +564,7 @@ ccflags="$@"
$2 ~ /^TIPC_/ || $2 ~ /^TIPC_/ ||
$2 !~ "DEVLINK_RELOAD_LIMITS_VALID_MASK" && $2 !~ "DEVLINK_RELOAD_LIMITS_VALID_MASK" &&
$2 ~ /^DEVLINK_/ || $2 ~ /^DEVLINK_/ ||
$2 ~ /^ETHTOOL_/ ||
$2 ~ /^LWTUNNEL_IP/ || $2 ~ /^LWTUNNEL_IP/ ||
$2 !~ "WMESGLEN" && $2 !~ "WMESGLEN" &&
$2 ~ /^W[A-Z0-9]+$/ || $2 ~ /^W[A-Z0-9]+$/ ||

View File

@ -119,13 +119,16 @@ type attrList struct {
Forkattr uint32 Forkattr uint32
} }
//sysnb pipe() (r int, w int, err error) //sysnb pipe(p *[2]int32) (err error)
func Pipe(p []int) (err error) { func Pipe(p []int) (err error) {
if len(p) != 2 { if len(p) != 2 {
return EINVAL return EINVAL
} }
p[0], p[1], err = pipe() var x [2]int32
err = pipe(&x)
p[0] = int(x[0])
p[1] = int(x[1])
return return
} }

View File

@ -75,16 +75,3 @@ func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error) {
} }
return return
} }
//sysnb pipe2(p *[2]_C_int, flags int) (err error)
func Pipe2(p []int, flags int) error {
if len(p) != 2 {
return EINVAL
}
var pp [2]_C_int
err := pipe2(&pp, flags)
p[0] = int(pp[0])
p[1] = int(pp[1])
return err
}

View File

@ -68,6 +68,19 @@ func Pipe(p []int) (err error) {
return nil return nil
} }
//sysnb pipe2(p *[2]_C_int, flags int) (err error)
func Pipe2(p []int, flags int) error {
if len(p) != 2 {
return EINVAL
}
var pp [2]_C_int
err := pipe2(&pp, flags)
p[0] = int(pp[0])
p[1] = int(pp[1])
return err
}
func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) {
if sa.Port < 0 || sa.Port > 0xFFFF { if sa.Port < 0 || sa.Port > 0xFFFF {
return nil, 0, EINVAL return nil, 0, EINVAL

View File

@ -527,6 +527,119 @@ const (
EPOLL_CTL_DEL = 0x2 EPOLL_CTL_DEL = 0x2
EPOLL_CTL_MOD = 0x3 EPOLL_CTL_MOD = 0x3
EROFS_SUPER_MAGIC_V1 = 0xe0f5e1e2 EROFS_SUPER_MAGIC_V1 = 0xe0f5e1e2
ESP_V4_FLOW = 0xa
ESP_V6_FLOW = 0xc
ETHER_FLOW = 0x12
ETHTOOL_BUSINFO_LEN = 0x20
ETHTOOL_EROMVERS_LEN = 0x20
ETHTOOL_FEC_AUTO = 0x2
ETHTOOL_FEC_BASER = 0x10
ETHTOOL_FEC_LLRS = 0x20
ETHTOOL_FEC_NONE = 0x1
ETHTOOL_FEC_OFF = 0x4
ETHTOOL_FEC_RS = 0x8
ETHTOOL_FLAG_ALL = 0x7
ETHTOOL_FLAG_COMPACT_BITSETS = 0x1
ETHTOOL_FLAG_OMIT_REPLY = 0x2
ETHTOOL_FLAG_STATS = 0x4
ETHTOOL_FLASHDEV = 0x33
ETHTOOL_FLASH_MAX_FILENAME = 0x80
ETHTOOL_FWVERS_LEN = 0x20
ETHTOOL_F_COMPAT = 0x4
ETHTOOL_F_UNSUPPORTED = 0x1
ETHTOOL_F_WISH = 0x2
ETHTOOL_GCHANNELS = 0x3c
ETHTOOL_GCOALESCE = 0xe
ETHTOOL_GDRVINFO = 0x3
ETHTOOL_GEEE = 0x44
ETHTOOL_GEEPROM = 0xb
ETHTOOL_GENL_NAME = "ethtool"
ETHTOOL_GENL_VERSION = 0x1
ETHTOOL_GET_DUMP_DATA = 0x40
ETHTOOL_GET_DUMP_FLAG = 0x3f
ETHTOOL_GET_TS_INFO = 0x41
ETHTOOL_GFEATURES = 0x3a
ETHTOOL_GFECPARAM = 0x50
ETHTOOL_GFLAGS = 0x25
ETHTOOL_GGRO = 0x2b
ETHTOOL_GGSO = 0x23
ETHTOOL_GLINK = 0xa
ETHTOOL_GLINKSETTINGS = 0x4c
ETHTOOL_GMODULEEEPROM = 0x43
ETHTOOL_GMODULEINFO = 0x42
ETHTOOL_GMSGLVL = 0x7
ETHTOOL_GPAUSEPARAM = 0x12
ETHTOOL_GPERMADDR = 0x20
ETHTOOL_GPFLAGS = 0x27
ETHTOOL_GPHYSTATS = 0x4a
ETHTOOL_GREGS = 0x4
ETHTOOL_GRINGPARAM = 0x10
ETHTOOL_GRSSH = 0x46
ETHTOOL_GRXCLSRLALL = 0x30
ETHTOOL_GRXCLSRLCNT = 0x2e
ETHTOOL_GRXCLSRULE = 0x2f
ETHTOOL_GRXCSUM = 0x14
ETHTOOL_GRXFH = 0x29
ETHTOOL_GRXFHINDIR = 0x38
ETHTOOL_GRXNTUPLE = 0x36
ETHTOOL_GRXRINGS = 0x2d
ETHTOOL_GSET = 0x1
ETHTOOL_GSG = 0x18
ETHTOOL_GSSET_INFO = 0x37
ETHTOOL_GSTATS = 0x1d
ETHTOOL_GSTRINGS = 0x1b
ETHTOOL_GTSO = 0x1e
ETHTOOL_GTUNABLE = 0x48
ETHTOOL_GTXCSUM = 0x16
ETHTOOL_GUFO = 0x21
ETHTOOL_GWOL = 0x5
ETHTOOL_MCGRP_MONITOR_NAME = "monitor"
ETHTOOL_NWAY_RST = 0x9
ETHTOOL_PERQUEUE = 0x4b
ETHTOOL_PHYS_ID = 0x1c
ETHTOOL_PHY_EDPD_DFLT_TX_MSECS = 0xffff
ETHTOOL_PHY_EDPD_DISABLE = 0x0
ETHTOOL_PHY_EDPD_NO_TX = 0xfffe
ETHTOOL_PHY_FAST_LINK_DOWN_OFF = 0xff
ETHTOOL_PHY_FAST_LINK_DOWN_ON = 0x0
ETHTOOL_PHY_GTUNABLE = 0x4e
ETHTOOL_PHY_STUNABLE = 0x4f
ETHTOOL_RESET = 0x34
ETHTOOL_RXNTUPLE_ACTION_CLEAR = -0x2
ETHTOOL_RXNTUPLE_ACTION_DROP = -0x1
ETHTOOL_RX_FLOW_SPEC_RING = 0xffffffff
ETHTOOL_RX_FLOW_SPEC_RING_VF = 0xff00000000
ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF = 0x20
ETHTOOL_SCHANNELS = 0x3d
ETHTOOL_SCOALESCE = 0xf
ETHTOOL_SEEE = 0x45
ETHTOOL_SEEPROM = 0xc
ETHTOOL_SET_DUMP = 0x3e
ETHTOOL_SFEATURES = 0x3b
ETHTOOL_SFECPARAM = 0x51
ETHTOOL_SFLAGS = 0x26
ETHTOOL_SGRO = 0x2c
ETHTOOL_SGSO = 0x24
ETHTOOL_SLINKSETTINGS = 0x4d
ETHTOOL_SMSGLVL = 0x8
ETHTOOL_SPAUSEPARAM = 0x13
ETHTOOL_SPFLAGS = 0x28
ETHTOOL_SRINGPARAM = 0x11
ETHTOOL_SRSSH = 0x47
ETHTOOL_SRXCLSRLDEL = 0x31
ETHTOOL_SRXCLSRLINS = 0x32
ETHTOOL_SRXCSUM = 0x15
ETHTOOL_SRXFH = 0x2a
ETHTOOL_SRXFHINDIR = 0x39
ETHTOOL_SRXNTUPLE = 0x35
ETHTOOL_SSET = 0x2
ETHTOOL_SSG = 0x19
ETHTOOL_STSO = 0x1f
ETHTOOL_STUNABLE = 0x49
ETHTOOL_STXCSUM = 0x17
ETHTOOL_SUFO = 0x22
ETHTOOL_SWOL = 0x6
ETHTOOL_TEST = 0x1a
ETH_P_1588 = 0x88f7 ETH_P_1588 = 0x88f7
ETH_P_8021AD = 0x88a8 ETH_P_8021AD = 0x88a8
ETH_P_8021AH = 0x88e7 ETH_P_8021AH = 0x88e7
@ -996,6 +1109,7 @@ const (
IPV6_DONTFRAG = 0x3e IPV6_DONTFRAG = 0x3e
IPV6_DROP_MEMBERSHIP = 0x15 IPV6_DROP_MEMBERSHIP = 0x15
IPV6_DSTOPTS = 0x3b IPV6_DSTOPTS = 0x3b
IPV6_FLOW = 0x11
IPV6_FREEBIND = 0x4e IPV6_FREEBIND = 0x4e
IPV6_HDRINCL = 0x24 IPV6_HDRINCL = 0x24
IPV6_HOPLIMIT = 0x34 IPV6_HOPLIMIT = 0x34
@ -1045,6 +1159,7 @@ const (
IPV6_TRANSPARENT = 0x4b IPV6_TRANSPARENT = 0x4b
IPV6_UNICAST_HOPS = 0x10 IPV6_UNICAST_HOPS = 0x10
IPV6_UNICAST_IF = 0x4c IPV6_UNICAST_IF = 0x4c
IPV6_USER_FLOW = 0xe
IPV6_V6ONLY = 0x1a IPV6_V6ONLY = 0x1a
IPV6_XFRM_POLICY = 0x23 IPV6_XFRM_POLICY = 0x23
IP_ADD_MEMBERSHIP = 0x23 IP_ADD_MEMBERSHIP = 0x23
@ -1101,6 +1216,7 @@ const (
IP_TTL = 0x2 IP_TTL = 0x2
IP_UNBLOCK_SOURCE = 0x25 IP_UNBLOCK_SOURCE = 0x25
IP_UNICAST_IF = 0x32 IP_UNICAST_IF = 0x32
IP_USER_FLOW = 0xd
IP_XFRM_POLICY = 0x11 IP_XFRM_POLICY = 0x11
ISOFS_SUPER_MAGIC = 0x9660 ISOFS_SUPER_MAGIC = 0x9660
ISTRIP = 0x20 ISTRIP = 0x20
@ -2340,6 +2456,8 @@ const (
TCP_TX_DELAY = 0x25 TCP_TX_DELAY = 0x25
TCP_ULP = 0x1f TCP_ULP = 0x1f
TCP_USER_TIMEOUT = 0x12 TCP_USER_TIMEOUT = 0x12
TCP_V4_FLOW = 0x1
TCP_V6_FLOW = 0x5
TCP_WINDOW_CLAMP = 0xa TCP_WINDOW_CLAMP = 0xa
TCP_ZEROCOPY_RECEIVE = 0x23 TCP_ZEROCOPY_RECEIVE = 0x23
TFD_TIMER_ABSTIME = 0x1 TFD_TIMER_ABSTIME = 0x1
@ -2466,6 +2584,7 @@ const (
VM_SOCKETS_INVALID_VERSION = 0xffffffff VM_SOCKETS_INVALID_VERSION = 0xffffffff
VQUIT = 0x1 VQUIT = 0x1
VT0 = 0x0 VT0 = 0x0
WAKE_MAGIC = 0x20
WALL = 0x40000000 WALL = 0x40000000
WCLONE = 0x80000000 WCLONE = 0x80000000
WCONTINUED = 0x8 WCONTINUED = 0x8

View File

@ -462,10 +462,8 @@ func libc_munlockall_trampoline()
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pipe() (r int, w int, err error) { func pipe(p *[2]int32) (err error) {
r0, r1, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), 0, 0, 0) _, _, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), uintptr(unsafe.Pointer(p)), 0, 0)
r = int(r0)
w = int(r1)
if e1 != 0 { if e1 != 0 {
err = errnoErr(e1) err = errnoErr(e1)
} }

View File

@ -462,10 +462,8 @@ func libc_munlockall_trampoline()
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pipe() (r int, w int, err error) { func pipe(p *[2]int32) (err error) {
r0, r1, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), 0, 0, 0) _, _, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), uintptr(unsafe.Pointer(p)), 0, 0)
r = int(r0)
w = int(r1)
if e1 != 0 { if e1 != 0 {
err = errnoErr(e1) err = errnoErr(e1)
} }

View File

@ -462,10 +462,8 @@ func libc_munlockall_trampoline()
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pipe() (r int, w int, err error) { func pipe(p *[2]int32) (err error) {
r0, r1, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), 0, 0, 0) _, _, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), uintptr(unsafe.Pointer(p)), 0, 0)
r = int(r0)
w = int(r1)
if e1 != 0 { if e1 != 0 {
err = errnoErr(e1) err = errnoErr(e1)
} }

View File

@ -462,10 +462,8 @@ func libc_munlockall_trampoline()
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pipe() (r int, w int, err error) { func pipe(p *[2]int32) (err error) {
r0, r1, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), 0, 0, 0) _, _, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), uintptr(unsafe.Pointer(p)), 0, 0)
r = int(r0)
w = int(r1)
if e1 != 0 { if e1 != 0 {
err = errnoErr(e1) err = errnoErr(e1)
} }

View File

@ -14,22 +14,19 @@ import (
//go:cgo_import_dynamic libc_writev writev "libc.so" //go:cgo_import_dynamic libc_writev writev "libc.so"
//go:cgo_import_dynamic libc_pwritev pwritev "libc.so" //go:cgo_import_dynamic libc_pwritev pwritev "libc.so"
//go:cgo_import_dynamic libc_accept4 accept4 "libsocket.so" //go:cgo_import_dynamic libc_accept4 accept4 "libsocket.so"
//go:cgo_import_dynamic libc_pipe2 pipe2 "libc.so"
//go:linkname procreadv libc_readv //go:linkname procreadv libc_readv
//go:linkname procpreadv libc_preadv //go:linkname procpreadv libc_preadv
//go:linkname procwritev libc_writev //go:linkname procwritev libc_writev
//go:linkname procpwritev libc_pwritev //go:linkname procpwritev libc_pwritev
//go:linkname procaccept4 libc_accept4 //go:linkname procaccept4 libc_accept4
//go:linkname procpipe2 libc_pipe2
var ( var (
procreadv, procreadv,
procpreadv, procpreadv,
procwritev, procwritev,
procpwritev, procpwritev,
procaccept4, procaccept4 syscallFunc
procpipe2 syscallFunc
) )
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
@ -102,13 +99,3 @@ func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int,
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pipe2(p *[2]_C_int, flags int) (err error) {
_, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procpipe2)), 2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0, 0, 0, 0)
if e1 != 0 {
err = e1
}
return
}

View File

@ -11,6 +11,7 @@ import (
) )
//go:cgo_import_dynamic libc_pipe pipe "libc.so" //go:cgo_import_dynamic libc_pipe pipe "libc.so"
//go:cgo_import_dynamic libc_pipe2 pipe2 "libc.so"
//go:cgo_import_dynamic libc_getsockname getsockname "libsocket.so" //go:cgo_import_dynamic libc_getsockname getsockname "libsocket.so"
//go:cgo_import_dynamic libc_getcwd getcwd "libc.so" //go:cgo_import_dynamic libc_getcwd getcwd "libc.so"
//go:cgo_import_dynamic libc_getgroups getgroups "libc.so" //go:cgo_import_dynamic libc_getgroups getgroups "libc.so"
@ -140,6 +141,7 @@ import (
//go:cgo_import_dynamic libc_recvfrom recvfrom "libsocket.so" //go:cgo_import_dynamic libc_recvfrom recvfrom "libsocket.so"
//go:linkname procpipe libc_pipe //go:linkname procpipe libc_pipe
//go:linkname procpipe2 libc_pipe2
//go:linkname procgetsockname libc_getsockname //go:linkname procgetsockname libc_getsockname
//go:linkname procGetcwd libc_getcwd //go:linkname procGetcwd libc_getcwd
//go:linkname procgetgroups libc_getgroups //go:linkname procgetgroups libc_getgroups
@ -270,6 +272,7 @@ import (
var ( var (
procpipe, procpipe,
procpipe2,
procgetsockname, procgetsockname,
procGetcwd, procGetcwd,
procgetgroups, procgetgroups,
@ -412,6 +415,16 @@ func pipe(p *[2]_C_int) (n int, err error) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func pipe2(p *[2]_C_int, flags int) (err error) {
_, _, e1 := rawSysvicall6(uintptr(unsafe.Pointer(&procpipe2)), 2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0, 0, 0, 0)
if e1 != 0 {
err = e1
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
_, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procgetsockname)), 3, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0) _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procgetsockname)), 3, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0)
if e1 != 0 { if e1 != 0 {

View File

@ -3222,3 +3222,461 @@ const (
MPLS_IPTUNNEL_TTL = 0x2 MPLS_IPTUNNEL_TTL = 0x2
MPLS_IPTUNNEL_MAX = 0x2 MPLS_IPTUNNEL_MAX = 0x2
) )
const (
ETHTOOL_ID_UNSPEC = 0x0
ETHTOOL_RX_COPYBREAK = 0x1
ETHTOOL_TX_COPYBREAK = 0x2
ETHTOOL_PFC_PREVENTION_TOUT = 0x3
ETHTOOL_TUNABLE_UNSPEC = 0x0
ETHTOOL_TUNABLE_U8 = 0x1
ETHTOOL_TUNABLE_U16 = 0x2
ETHTOOL_TUNABLE_U32 = 0x3
ETHTOOL_TUNABLE_U64 = 0x4
ETHTOOL_TUNABLE_STRING = 0x5
ETHTOOL_TUNABLE_S8 = 0x6
ETHTOOL_TUNABLE_S16 = 0x7
ETHTOOL_TUNABLE_S32 = 0x8
ETHTOOL_TUNABLE_S64 = 0x9
ETHTOOL_PHY_ID_UNSPEC = 0x0
ETHTOOL_PHY_DOWNSHIFT = 0x1
ETHTOOL_PHY_FAST_LINK_DOWN = 0x2
ETHTOOL_PHY_EDPD = 0x3
ETHTOOL_LINK_EXT_STATE_AUTONEG = 0x0
ETHTOOL_LINK_EXT_STATE_LINK_TRAINING_FAILURE = 0x1
ETHTOOL_LINK_EXT_STATE_LINK_LOGICAL_MISMATCH = 0x2
ETHTOOL_LINK_EXT_STATE_BAD_SIGNAL_INTEGRITY = 0x3
ETHTOOL_LINK_EXT_STATE_NO_CABLE = 0x4
ETHTOOL_LINK_EXT_STATE_CABLE_ISSUE = 0x5
ETHTOOL_LINK_EXT_STATE_EEPROM_ISSUE = 0x6
ETHTOOL_LINK_EXT_STATE_CALIBRATION_FAILURE = 0x7
ETHTOOL_LINK_EXT_STATE_POWER_BUDGET_EXCEEDED = 0x8
ETHTOOL_LINK_EXT_STATE_OVERHEAT = 0x9
ETHTOOL_LINK_EXT_SUBSTATE_AN_NO_PARTNER_DETECTED = 0x1
ETHTOOL_LINK_EXT_SUBSTATE_AN_ACK_NOT_RECEIVED = 0x2
ETHTOOL_LINK_EXT_SUBSTATE_AN_NEXT_PAGE_EXCHANGE_FAILED = 0x3
ETHTOOL_LINK_EXT_SUBSTATE_AN_NO_PARTNER_DETECTED_FORCE_MODE = 0x4
ETHTOOL_LINK_EXT_SUBSTATE_AN_FEC_MISMATCH_DURING_OVERRIDE = 0x5
ETHTOOL_LINK_EXT_SUBSTATE_AN_NO_HCD = 0x6
ETHTOOL_LINK_EXT_SUBSTATE_LT_KR_FRAME_LOCK_NOT_ACQUIRED = 0x1
ETHTOOL_LINK_EXT_SUBSTATE_LT_KR_LINK_INHIBIT_TIMEOUT = 0x2
ETHTOOL_LINK_EXT_SUBSTATE_LT_KR_LINK_PARTNER_DID_NOT_SET_RECEIVER_READY = 0x3
ETHTOOL_LINK_EXT_SUBSTATE_LT_REMOTE_FAULT = 0x4
ETHTOOL_LINK_EXT_SUBSTATE_LLM_PCS_DID_NOT_ACQUIRE_BLOCK_LOCK = 0x1
ETHTOOL_LINK_EXT_SUBSTATE_LLM_PCS_DID_NOT_ACQUIRE_AM_LOCK = 0x2
ETHTOOL_LINK_EXT_SUBSTATE_LLM_PCS_DID_NOT_GET_ALIGN_STATUS = 0x3
ETHTOOL_LINK_EXT_SUBSTATE_LLM_FC_FEC_IS_NOT_LOCKED = 0x4
ETHTOOL_LINK_EXT_SUBSTATE_LLM_RS_FEC_IS_NOT_LOCKED = 0x5
ETHTOOL_LINK_EXT_SUBSTATE_BSI_LARGE_NUMBER_OF_PHYSICAL_ERRORS = 0x1
ETHTOOL_LINK_EXT_SUBSTATE_BSI_UNSUPPORTED_RATE = 0x2
ETHTOOL_LINK_EXT_SUBSTATE_CI_UNSUPPORTED_CABLE = 0x1
ETHTOOL_LINK_EXT_SUBSTATE_CI_CABLE_TEST_FAILURE = 0x2
ETHTOOL_FLASH_ALL_REGIONS = 0x0
ETHTOOL_F_UNSUPPORTED__BIT = 0x0
ETHTOOL_F_WISH__BIT = 0x1
ETHTOOL_F_COMPAT__BIT = 0x2
ETHTOOL_FEC_NONE_BIT = 0x0
ETHTOOL_FEC_AUTO_BIT = 0x1
ETHTOOL_FEC_OFF_BIT = 0x2
ETHTOOL_FEC_RS_BIT = 0x3
ETHTOOL_FEC_BASER_BIT = 0x4
ETHTOOL_FEC_LLRS_BIT = 0x5
ETHTOOL_LINK_MODE_10baseT_Half_BIT = 0x0
ETHTOOL_LINK_MODE_10baseT_Full_BIT = 0x1
ETHTOOL_LINK_MODE_100baseT_Half_BIT = 0x2
ETHTOOL_LINK_MODE_100baseT_Full_BIT = 0x3
ETHTOOL_LINK_MODE_1000baseT_Half_BIT = 0x4
ETHTOOL_LINK_MODE_1000baseT_Full_BIT = 0x5
ETHTOOL_LINK_MODE_Autoneg_BIT = 0x6
ETHTOOL_LINK_MODE_TP_BIT = 0x7
ETHTOOL_LINK_MODE_AUI_BIT = 0x8
ETHTOOL_LINK_MODE_MII_BIT = 0x9
ETHTOOL_LINK_MODE_FIBRE_BIT = 0xa
ETHTOOL_LINK_MODE_BNC_BIT = 0xb
ETHTOOL_LINK_MODE_10000baseT_Full_BIT = 0xc
ETHTOOL_LINK_MODE_Pause_BIT = 0xd
ETHTOOL_LINK_MODE_Asym_Pause_BIT = 0xe
ETHTOOL_LINK_MODE_2500baseX_Full_BIT = 0xf
ETHTOOL_LINK_MODE_Backplane_BIT = 0x10
ETHTOOL_LINK_MODE_1000baseKX_Full_BIT = 0x11
ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT = 0x12
ETHTOOL_LINK_MODE_10000baseKR_Full_BIT = 0x13
ETHTOOL_LINK_MODE_10000baseR_FEC_BIT = 0x14
ETHTOOL_LINK_MODE_20000baseMLD2_Full_BIT = 0x15
ETHTOOL_LINK_MODE_20000baseKR2_Full_BIT = 0x16
ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT = 0x17
ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT = 0x18
ETHTOOL_LINK_MODE_40000baseSR4_Full_BIT = 0x19
ETHTOOL_LINK_MODE_40000baseLR4_Full_BIT = 0x1a
ETHTOOL_LINK_MODE_56000baseKR4_Full_BIT = 0x1b
ETHTOOL_LINK_MODE_56000baseCR4_Full_BIT = 0x1c
ETHTOOL_LINK_MODE_56000baseSR4_Full_BIT = 0x1d
ETHTOOL_LINK_MODE_56000baseLR4_Full_BIT = 0x1e
ETHTOOL_LINK_MODE_25000baseCR_Full_BIT = 0x1f
ETHTOOL_LINK_MODE_25000baseKR_Full_BIT = 0x20
ETHTOOL_LINK_MODE_25000baseSR_Full_BIT = 0x21
ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT = 0x22
ETHTOOL_LINK_MODE_50000baseKR2_Full_BIT = 0x23
ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT = 0x24
ETHTOOL_LINK_MODE_100000baseSR4_Full_BIT = 0x25
ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT = 0x26
ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT = 0x27
ETHTOOL_LINK_MODE_50000baseSR2_Full_BIT = 0x28
ETHTOOL_LINK_MODE_1000baseX_Full_BIT = 0x29
ETHTOOL_LINK_MODE_10000baseCR_Full_BIT = 0x2a
ETHTOOL_LINK_MODE_10000baseSR_Full_BIT = 0x2b
ETHTOOL_LINK_MODE_10000baseLR_Full_BIT = 0x2c
ETHTOOL_LINK_MODE_10000baseLRM_Full_BIT = 0x2d
ETHTOOL_LINK_MODE_10000baseER_Full_BIT = 0x2e
ETHTOOL_LINK_MODE_2500baseT_Full_BIT = 0x2f
ETHTOOL_LINK_MODE_5000baseT_Full_BIT = 0x30
ETHTOOL_LINK_MODE_FEC_NONE_BIT = 0x31
ETHTOOL_LINK_MODE_FEC_RS_BIT = 0x32
ETHTOOL_LINK_MODE_FEC_BASER_BIT = 0x33
ETHTOOL_LINK_MODE_50000baseKR_Full_BIT = 0x34
ETHTOOL_LINK_MODE_50000baseSR_Full_BIT = 0x35
ETHTOOL_LINK_MODE_50000baseCR_Full_BIT = 0x36
ETHTOOL_LINK_MODE_50000baseLR_ER_FR_Full_BIT = 0x37
ETHTOOL_LINK_MODE_50000baseDR_Full_BIT = 0x38
ETHTOOL_LINK_MODE_100000baseKR2_Full_BIT = 0x39
ETHTOOL_LINK_MODE_100000baseSR2_Full_BIT = 0x3a
ETHTOOL_LINK_MODE_100000baseCR2_Full_BIT = 0x3b
ETHTOOL_LINK_MODE_100000baseLR2_ER2_FR2_Full_BIT = 0x3c
ETHTOOL_LINK_MODE_100000baseDR2_Full_BIT = 0x3d
ETHTOOL_LINK_MODE_200000baseKR4_Full_BIT = 0x3e
ETHTOOL_LINK_MODE_200000baseSR4_Full_BIT = 0x3f
ETHTOOL_LINK_MODE_200000baseLR4_ER4_FR4_Full_BIT = 0x40
ETHTOOL_LINK_MODE_200000baseDR4_Full_BIT = 0x41
ETHTOOL_LINK_MODE_200000baseCR4_Full_BIT = 0x42
ETHTOOL_LINK_MODE_100baseT1_Full_BIT = 0x43
ETHTOOL_LINK_MODE_1000baseT1_Full_BIT = 0x44
ETHTOOL_LINK_MODE_400000baseKR8_Full_BIT = 0x45
ETHTOOL_LINK_MODE_400000baseSR8_Full_BIT = 0x46
ETHTOOL_LINK_MODE_400000baseLR8_ER8_FR8_Full_BIT = 0x47
ETHTOOL_LINK_MODE_400000baseDR8_Full_BIT = 0x48
ETHTOOL_LINK_MODE_400000baseCR8_Full_BIT = 0x49
ETHTOOL_LINK_MODE_FEC_LLRS_BIT = 0x4a
ETHTOOL_LINK_MODE_100000baseKR_Full_BIT = 0x4b
ETHTOOL_LINK_MODE_100000baseSR_Full_BIT = 0x4c
ETHTOOL_LINK_MODE_100000baseLR_ER_FR_Full_BIT = 0x4d
ETHTOOL_LINK_MODE_100000baseCR_Full_BIT = 0x4e
ETHTOOL_LINK_MODE_100000baseDR_Full_BIT = 0x4f
ETHTOOL_LINK_MODE_200000baseKR2_Full_BIT = 0x50
ETHTOOL_LINK_MODE_200000baseSR2_Full_BIT = 0x51
ETHTOOL_LINK_MODE_200000baseLR2_ER2_FR2_Full_BIT = 0x52
ETHTOOL_LINK_MODE_200000baseDR2_Full_BIT = 0x53
ETHTOOL_LINK_MODE_200000baseCR2_Full_BIT = 0x54
ETHTOOL_LINK_MODE_400000baseKR4_Full_BIT = 0x55
ETHTOOL_LINK_MODE_400000baseSR4_Full_BIT = 0x56
ETHTOOL_LINK_MODE_400000baseLR4_ER4_FR4_Full_BIT = 0x57
ETHTOOL_LINK_MODE_400000baseDR4_Full_BIT = 0x58
ETHTOOL_LINK_MODE_400000baseCR4_Full_BIT = 0x59
ETHTOOL_LINK_MODE_100baseFX_Half_BIT = 0x5a
ETHTOOL_LINK_MODE_100baseFX_Full_BIT = 0x5b
ETHTOOL_MSG_USER_NONE = 0x0
ETHTOOL_MSG_STRSET_GET = 0x1
ETHTOOL_MSG_LINKINFO_GET = 0x2
ETHTOOL_MSG_LINKINFO_SET = 0x3
ETHTOOL_MSG_LINKMODES_GET = 0x4
ETHTOOL_MSG_LINKMODES_SET = 0x5
ETHTOOL_MSG_LINKSTATE_GET = 0x6
ETHTOOL_MSG_DEBUG_GET = 0x7
ETHTOOL_MSG_DEBUG_SET = 0x8
ETHTOOL_MSG_WOL_GET = 0x9
ETHTOOL_MSG_WOL_SET = 0xa
ETHTOOL_MSG_FEATURES_GET = 0xb
ETHTOOL_MSG_FEATURES_SET = 0xc
ETHTOOL_MSG_PRIVFLAGS_GET = 0xd
ETHTOOL_MSG_PRIVFLAGS_SET = 0xe
ETHTOOL_MSG_RINGS_GET = 0xf
ETHTOOL_MSG_RINGS_SET = 0x10
ETHTOOL_MSG_CHANNELS_GET = 0x11
ETHTOOL_MSG_CHANNELS_SET = 0x12
ETHTOOL_MSG_COALESCE_GET = 0x13
ETHTOOL_MSG_COALESCE_SET = 0x14
ETHTOOL_MSG_PAUSE_GET = 0x15
ETHTOOL_MSG_PAUSE_SET = 0x16
ETHTOOL_MSG_EEE_GET = 0x17
ETHTOOL_MSG_EEE_SET = 0x18
ETHTOOL_MSG_TSINFO_GET = 0x19
ETHTOOL_MSG_CABLE_TEST_ACT = 0x1a
ETHTOOL_MSG_CABLE_TEST_TDR_ACT = 0x1b
ETHTOOL_MSG_TUNNEL_INFO_GET = 0x1c
ETHTOOL_MSG_USER_MAX = 0x1c
ETHTOOL_MSG_KERNEL_NONE = 0x0
ETHTOOL_MSG_STRSET_GET_REPLY = 0x1
ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2
ETHTOOL_MSG_LINKINFO_NTF = 0x3
ETHTOOL_MSG_LINKMODES_GET_REPLY = 0x4
ETHTOOL_MSG_LINKMODES_NTF = 0x5
ETHTOOL_MSG_LINKSTATE_GET_REPLY = 0x6
ETHTOOL_MSG_DEBUG_GET_REPLY = 0x7
ETHTOOL_MSG_DEBUG_NTF = 0x8
ETHTOOL_MSG_WOL_GET_REPLY = 0x9
ETHTOOL_MSG_WOL_NTF = 0xa
ETHTOOL_MSG_FEATURES_GET_REPLY = 0xb
ETHTOOL_MSG_FEATURES_SET_REPLY = 0xc
ETHTOOL_MSG_FEATURES_NTF = 0xd
ETHTOOL_MSG_PRIVFLAGS_GET_REPLY = 0xe
ETHTOOL_MSG_PRIVFLAGS_NTF = 0xf
ETHTOOL_MSG_RINGS_GET_REPLY = 0x10
ETHTOOL_MSG_RINGS_NTF = 0x11
ETHTOOL_MSG_CHANNELS_GET_REPLY = 0x12
ETHTOOL_MSG_CHANNELS_NTF = 0x13
ETHTOOL_MSG_COALESCE_GET_REPLY = 0x14
ETHTOOL_MSG_COALESCE_NTF = 0x15
ETHTOOL_MSG_PAUSE_GET_REPLY = 0x16
ETHTOOL_MSG_PAUSE_NTF = 0x17
ETHTOOL_MSG_EEE_GET_REPLY = 0x18
ETHTOOL_MSG_EEE_NTF = 0x19
ETHTOOL_MSG_TSINFO_GET_REPLY = 0x1a
ETHTOOL_MSG_CABLE_TEST_NTF = 0x1b
ETHTOOL_MSG_CABLE_TEST_TDR_NTF = 0x1c
ETHTOOL_MSG_TUNNEL_INFO_GET_REPLY = 0x1d
ETHTOOL_MSG_KERNEL_MAX = 0x1d
ETHTOOL_A_HEADER_UNSPEC = 0x0
ETHTOOL_A_HEADER_DEV_INDEX = 0x1
ETHTOOL_A_HEADER_DEV_NAME = 0x2
ETHTOOL_A_HEADER_FLAGS = 0x3
ETHTOOL_A_HEADER_MAX = 0x3
ETHTOOL_A_BITSET_BIT_UNSPEC = 0x0
ETHTOOL_A_BITSET_BIT_INDEX = 0x1
ETHTOOL_A_BITSET_BIT_NAME = 0x2
ETHTOOL_A_BITSET_BIT_VALUE = 0x3
ETHTOOL_A_BITSET_BIT_MAX = 0x3
ETHTOOL_A_BITSET_BITS_UNSPEC = 0x0
ETHTOOL_A_BITSET_BITS_BIT = 0x1
ETHTOOL_A_BITSET_BITS_MAX = 0x1
ETHTOOL_A_BITSET_UNSPEC = 0x0
ETHTOOL_A_BITSET_NOMASK = 0x1
ETHTOOL_A_BITSET_SIZE = 0x2
ETHTOOL_A_BITSET_BITS = 0x3
ETHTOOL_A_BITSET_VALUE = 0x4
ETHTOOL_A_BITSET_MASK = 0x5
ETHTOOL_A_BITSET_MAX = 0x5
ETHTOOL_A_STRING_UNSPEC = 0x0
ETHTOOL_A_STRING_INDEX = 0x1
ETHTOOL_A_STRING_VALUE = 0x2
ETHTOOL_A_STRING_MAX = 0x2
ETHTOOL_A_STRINGS_UNSPEC = 0x0
ETHTOOL_A_STRINGS_STRING = 0x1
ETHTOOL_A_STRINGS_MAX = 0x1
ETHTOOL_A_STRINGSET_UNSPEC = 0x0
ETHTOOL_A_STRINGSET_ID = 0x1
ETHTOOL_A_STRINGSET_COUNT = 0x2
ETHTOOL_A_STRINGSET_STRINGS = 0x3
ETHTOOL_A_STRINGSET_MAX = 0x3
ETHTOOL_A_STRINGSETS_UNSPEC = 0x0
ETHTOOL_A_STRINGSETS_STRINGSET = 0x1
ETHTOOL_A_STRINGSETS_MAX = 0x1
ETHTOOL_A_STRSET_UNSPEC = 0x0
ETHTOOL_A_STRSET_HEADER = 0x1
ETHTOOL_A_STRSET_STRINGSETS = 0x2
ETHTOOL_A_STRSET_COUNTS_ONLY = 0x3
ETHTOOL_A_STRSET_MAX = 0x3
ETHTOOL_A_LINKINFO_UNSPEC = 0x0
ETHTOOL_A_LINKINFO_HEADER = 0x1
ETHTOOL_A_LINKINFO_PORT = 0x2
ETHTOOL_A_LINKINFO_PHYADDR = 0x3
ETHTOOL_A_LINKINFO_TP_MDIX = 0x4
ETHTOOL_A_LINKINFO_TP_MDIX_CTRL = 0x5
ETHTOOL_A_LINKINFO_TRANSCEIVER = 0x6
ETHTOOL_A_LINKINFO_MAX = 0x6
ETHTOOL_A_LINKMODES_UNSPEC = 0x0
ETHTOOL_A_LINKMODES_HEADER = 0x1
ETHTOOL_A_LINKMODES_AUTONEG = 0x2
ETHTOOL_A_LINKMODES_OURS = 0x3
ETHTOOL_A_LINKMODES_PEER = 0x4
ETHTOOL_A_LINKMODES_SPEED = 0x5
ETHTOOL_A_LINKMODES_DUPLEX = 0x6
ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG = 0x7
ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE = 0x8
ETHTOOL_A_LINKMODES_MAX = 0x8
ETHTOOL_A_LINKSTATE_UNSPEC = 0x0
ETHTOOL_A_LINKSTATE_HEADER = 0x1
ETHTOOL_A_LINKSTATE_LINK = 0x2
ETHTOOL_A_LINKSTATE_SQI = 0x3
ETHTOOL_A_LINKSTATE_SQI_MAX = 0x4
ETHTOOL_A_LINKSTATE_EXT_STATE = 0x5
ETHTOOL_A_LINKSTATE_EXT_SUBSTATE = 0x6
ETHTOOL_A_LINKSTATE_MAX = 0x6
ETHTOOL_A_DEBUG_UNSPEC = 0x0
ETHTOOL_A_DEBUG_HEADER = 0x1
ETHTOOL_A_DEBUG_MSGMASK = 0x2
ETHTOOL_A_DEBUG_MAX = 0x2
ETHTOOL_A_WOL_UNSPEC = 0x0
ETHTOOL_A_WOL_HEADER = 0x1
ETHTOOL_A_WOL_MODES = 0x2
ETHTOOL_A_WOL_SOPASS = 0x3
ETHTOOL_A_WOL_MAX = 0x3
ETHTOOL_A_FEATURES_UNSPEC = 0x0
ETHTOOL_A_FEATURES_HEADER = 0x1
ETHTOOL_A_FEATURES_HW = 0x2
ETHTOOL_A_FEATURES_WANTED = 0x3
ETHTOOL_A_FEATURES_ACTIVE = 0x4
ETHTOOL_A_FEATURES_NOCHANGE = 0x5
ETHTOOL_A_FEATURES_MAX = 0x5
ETHTOOL_A_PRIVFLAGS_UNSPEC = 0x0
ETHTOOL_A_PRIVFLAGS_HEADER = 0x1
ETHTOOL_A_PRIVFLAGS_FLAGS = 0x2
ETHTOOL_A_PRIVFLAGS_MAX = 0x2
ETHTOOL_A_RINGS_UNSPEC = 0x0
ETHTOOL_A_RINGS_HEADER = 0x1
ETHTOOL_A_RINGS_RX_MAX = 0x2
ETHTOOL_A_RINGS_RX_MINI_MAX = 0x3
ETHTOOL_A_RINGS_RX_JUMBO_MAX = 0x4
ETHTOOL_A_RINGS_TX_MAX = 0x5
ETHTOOL_A_RINGS_RX = 0x6
ETHTOOL_A_RINGS_RX_MINI = 0x7
ETHTOOL_A_RINGS_RX_JUMBO = 0x8
ETHTOOL_A_RINGS_TX = 0x9
ETHTOOL_A_RINGS_MAX = 0x9
ETHTOOL_A_CHANNELS_UNSPEC = 0x0
ETHTOOL_A_CHANNELS_HEADER = 0x1
ETHTOOL_A_CHANNELS_RX_MAX = 0x2
ETHTOOL_A_CHANNELS_TX_MAX = 0x3
ETHTOOL_A_CHANNELS_OTHER_MAX = 0x4
ETHTOOL_A_CHANNELS_COMBINED_MAX = 0x5
ETHTOOL_A_CHANNELS_RX_COUNT = 0x6
ETHTOOL_A_CHANNELS_TX_COUNT = 0x7
ETHTOOL_A_CHANNELS_OTHER_COUNT = 0x8
ETHTOOL_A_CHANNELS_COMBINED_COUNT = 0x9
ETHTOOL_A_CHANNELS_MAX = 0x9
ETHTOOL_A_COALESCE_UNSPEC = 0x0
ETHTOOL_A_COALESCE_HEADER = 0x1
ETHTOOL_A_COALESCE_RX_USECS = 0x2
ETHTOOL_A_COALESCE_RX_MAX_FRAMES = 0x3
ETHTOOL_A_COALESCE_RX_USECS_IRQ = 0x4
ETHTOOL_A_COALESCE_RX_MAX_FRAMES_IRQ = 0x5
ETHTOOL_A_COALESCE_TX_USECS = 0x6
ETHTOOL_A_COALESCE_TX_MAX_FRAMES = 0x7
ETHTOOL_A_COALESCE_TX_USECS_IRQ = 0x8
ETHTOOL_A_COALESCE_TX_MAX_FRAMES_IRQ = 0x9
ETHTOOL_A_COALESCE_STATS_BLOCK_USECS = 0xa
ETHTOOL_A_COALESCE_USE_ADAPTIVE_RX = 0xb
ETHTOOL_A_COALESCE_USE_ADAPTIVE_TX = 0xc
ETHTOOL_A_COALESCE_PKT_RATE_LOW = 0xd
ETHTOOL_A_COALESCE_RX_USECS_LOW = 0xe
ETHTOOL_A_COALESCE_RX_MAX_FRAMES_LOW = 0xf
ETHTOOL_A_COALESCE_TX_USECS_LOW = 0x10
ETHTOOL_A_COALESCE_TX_MAX_FRAMES_LOW = 0x11
ETHTOOL_A_COALESCE_PKT_RATE_HIGH = 0x12
ETHTOOL_A_COALESCE_RX_USECS_HIGH = 0x13
ETHTOOL_A_COALESCE_RX_MAX_FRAMES_HIGH = 0x14
ETHTOOL_A_COALESCE_TX_USECS_HIGH = 0x15
ETHTOOL_A_COALESCE_TX_MAX_FRAMES_HIGH = 0x16
ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL = 0x17
ETHTOOL_A_COALESCE_MAX = 0x17
ETHTOOL_A_PAUSE_UNSPEC = 0x0
ETHTOOL_A_PAUSE_HEADER = 0x1
ETHTOOL_A_PAUSE_AUTONEG = 0x2
ETHTOOL_A_PAUSE_RX = 0x3
ETHTOOL_A_PAUSE_TX = 0x4
ETHTOOL_A_PAUSE_STATS = 0x5
ETHTOOL_A_PAUSE_MAX = 0x5
ETHTOOL_A_PAUSE_STAT_UNSPEC = 0x0
ETHTOOL_A_PAUSE_STAT_PAD = 0x1
ETHTOOL_A_PAUSE_STAT_TX_FRAMES = 0x2
ETHTOOL_A_PAUSE_STAT_RX_FRAMES = 0x3
ETHTOOL_A_PAUSE_STAT_MAX = 0x3
ETHTOOL_A_EEE_UNSPEC = 0x0
ETHTOOL_A_EEE_HEADER = 0x1
ETHTOOL_A_EEE_MODES_OURS = 0x2
ETHTOOL_A_EEE_MODES_PEER = 0x3
ETHTOOL_A_EEE_ACTIVE = 0x4
ETHTOOL_A_EEE_ENABLED = 0x5
ETHTOOL_A_EEE_TX_LPI_ENABLED = 0x6
ETHTOOL_A_EEE_TX_LPI_TIMER = 0x7
ETHTOOL_A_EEE_MAX = 0x7
ETHTOOL_A_TSINFO_UNSPEC = 0x0
ETHTOOL_A_TSINFO_HEADER = 0x1
ETHTOOL_A_TSINFO_TIMESTAMPING = 0x2
ETHTOOL_A_TSINFO_TX_TYPES = 0x3
ETHTOOL_A_TSINFO_RX_FILTERS = 0x4
ETHTOOL_A_TSINFO_PHC_INDEX = 0x5
ETHTOOL_A_TSINFO_MAX = 0x5
ETHTOOL_A_CABLE_TEST_UNSPEC = 0x0
ETHTOOL_A_CABLE_TEST_HEADER = 0x1
ETHTOOL_A_CABLE_TEST_MAX = 0x1
ETHTOOL_A_CABLE_RESULT_CODE_UNSPEC = 0x0
ETHTOOL_A_CABLE_RESULT_CODE_OK = 0x1
ETHTOOL_A_CABLE_RESULT_CODE_OPEN = 0x2
ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT = 0x3
ETHTOOL_A_CABLE_RESULT_CODE_CROSS_SHORT = 0x4
ETHTOOL_A_CABLE_PAIR_A = 0x0
ETHTOOL_A_CABLE_PAIR_B = 0x1
ETHTOOL_A_CABLE_PAIR_C = 0x2
ETHTOOL_A_CABLE_PAIR_D = 0x3
ETHTOOL_A_CABLE_RESULT_UNSPEC = 0x0
ETHTOOL_A_CABLE_RESULT_PAIR = 0x1
ETHTOOL_A_CABLE_RESULT_CODE = 0x2
ETHTOOL_A_CABLE_RESULT_MAX = 0x2
ETHTOOL_A_CABLE_FAULT_LENGTH_UNSPEC = 0x0
ETHTOOL_A_CABLE_FAULT_LENGTH_PAIR = 0x1
ETHTOOL_A_CABLE_FAULT_LENGTH_CM = 0x2
ETHTOOL_A_CABLE_FAULT_LENGTH_MAX = 0x2
ETHTOOL_A_CABLE_TEST_NTF_STATUS_UNSPEC = 0x0
ETHTOOL_A_CABLE_TEST_NTF_STATUS_STARTED = 0x1
ETHTOOL_A_CABLE_TEST_NTF_STATUS_COMPLETED = 0x2
ETHTOOL_A_CABLE_NEST_UNSPEC = 0x0
ETHTOOL_A_CABLE_NEST_RESULT = 0x1
ETHTOOL_A_CABLE_NEST_FAULT_LENGTH = 0x2
ETHTOOL_A_CABLE_NEST_MAX = 0x2
ETHTOOL_A_CABLE_TEST_NTF_UNSPEC = 0x0
ETHTOOL_A_CABLE_TEST_NTF_HEADER = 0x1
ETHTOOL_A_CABLE_TEST_NTF_STATUS = 0x2
ETHTOOL_A_CABLE_TEST_NTF_NEST = 0x3
ETHTOOL_A_CABLE_TEST_NTF_MAX = 0x3
ETHTOOL_A_CABLE_TEST_TDR_CFG_UNSPEC = 0x0
ETHTOOL_A_CABLE_TEST_TDR_CFG_FIRST = 0x1
ETHTOOL_A_CABLE_TEST_TDR_CFG_LAST = 0x2
ETHTOOL_A_CABLE_TEST_TDR_CFG_STEP = 0x3
ETHTOOL_A_CABLE_TEST_TDR_CFG_PAIR = 0x4
ETHTOOL_A_CABLE_TEST_TDR_CFG_MAX = 0x4
ETHTOOL_A_CABLE_TEST_TDR_UNSPEC = 0x0
ETHTOOL_A_CABLE_TEST_TDR_HEADER = 0x1
ETHTOOL_A_CABLE_TEST_TDR_CFG = 0x2
ETHTOOL_A_CABLE_TEST_TDR_MAX = 0x2
ETHTOOL_A_CABLE_AMPLITUDE_UNSPEC = 0x0
ETHTOOL_A_CABLE_AMPLITUDE_PAIR = 0x1
ETHTOOL_A_CABLE_AMPLITUDE_mV = 0x2
ETHTOOL_A_CABLE_AMPLITUDE_MAX = 0x2
ETHTOOL_A_CABLE_PULSE_UNSPEC = 0x0
ETHTOOL_A_CABLE_PULSE_mV = 0x1
ETHTOOL_A_CABLE_PULSE_MAX = 0x1
ETHTOOL_A_CABLE_STEP_UNSPEC = 0x0
ETHTOOL_A_CABLE_STEP_FIRST_DISTANCE = 0x1
ETHTOOL_A_CABLE_STEP_LAST_DISTANCE = 0x2
ETHTOOL_A_CABLE_STEP_STEP_DISTANCE = 0x3
ETHTOOL_A_CABLE_STEP_MAX = 0x3
ETHTOOL_A_CABLE_TDR_NEST_UNSPEC = 0x0
ETHTOOL_A_CABLE_TDR_NEST_STEP = 0x1
ETHTOOL_A_CABLE_TDR_NEST_AMPLITUDE = 0x2
ETHTOOL_A_CABLE_TDR_NEST_PULSE = 0x3
ETHTOOL_A_CABLE_TDR_NEST_MAX = 0x3
ETHTOOL_A_CABLE_TEST_TDR_NTF_UNSPEC = 0x0
ETHTOOL_A_CABLE_TEST_TDR_NTF_HEADER = 0x1
ETHTOOL_A_CABLE_TEST_TDR_NTF_STATUS = 0x2
ETHTOOL_A_CABLE_TEST_TDR_NTF_NEST = 0x3
ETHTOOL_A_CABLE_TEST_TDR_NTF_MAX = 0x3
ETHTOOL_UDP_TUNNEL_TYPE_VXLAN = 0x0
ETHTOOL_UDP_TUNNEL_TYPE_GENEVE = 0x1
ETHTOOL_UDP_TUNNEL_TYPE_VXLAN_GPE = 0x2
ETHTOOL_A_TUNNEL_UDP_ENTRY_UNSPEC = 0x0
ETHTOOL_A_TUNNEL_UDP_ENTRY_PORT = 0x1
ETHTOOL_A_TUNNEL_UDP_ENTRY_TYPE = 0x2
ETHTOOL_A_TUNNEL_UDP_ENTRY_MAX = 0x2
ETHTOOL_A_TUNNEL_UDP_TABLE_UNSPEC = 0x0
ETHTOOL_A_TUNNEL_UDP_TABLE_SIZE = 0x1
ETHTOOL_A_TUNNEL_UDP_TABLE_TYPES = 0x2
ETHTOOL_A_TUNNEL_UDP_TABLE_ENTRY = 0x3
ETHTOOL_A_TUNNEL_UDP_TABLE_MAX = 0x3
ETHTOOL_A_TUNNEL_UDP_UNSPEC = 0x0
ETHTOOL_A_TUNNEL_UDP_TABLE = 0x1
ETHTOOL_A_TUNNEL_UDP_MAX = 0x1
ETHTOOL_A_TUNNEL_INFO_UNSPEC = 0x0
ETHTOOL_A_TUNNEL_INFO_HEADER = 0x1
ETHTOOL_A_TUNNEL_INFO_UDP_PORTS = 0x2
ETHTOOL_A_TUNNEL_INFO_MAX = 0x2
)

View File

@ -18,9 +18,11 @@ import (
) )
type Handle uintptr type Handle uintptr
type HWND uintptr
const ( const (
InvalidHandle = ^Handle(0) InvalidHandle = ^Handle(0)
InvalidHWND = ^HWND(0)
// Flags for DefineDosDevice. // Flags for DefineDosDevice.
DDD_EXACT_MATCH_ON_REMOVE = 0x00000004 DDD_EXACT_MATCH_ON_REMOVE = 0x00000004
@ -214,6 +216,10 @@ func NewCallbackCDecl(fn interface{}) uintptr {
//sys CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) = CreateProcessW //sys CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) = CreateProcessW
//sys OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error) //sys OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error)
//sys ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) [failretval<=32] = shell32.ShellExecuteW //sys ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) [failretval<=32] = shell32.ShellExecuteW
//sys GetWindowThreadProcessId(hwnd HWND, pid *uint32) (tid uint32, err error) = user32.GetWindowThreadProcessId
//sys GetShellWindow() (shellWindow HWND) = user32.GetShellWindow
//sys MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) [failretval==0] = user32.MessageBoxW
//sys ExitWindowsEx(flags uint32, reason uint32) (err error) = user32.ExitWindowsEx
//sys shGetKnownFolderPath(id *KNOWNFOLDERID, flags uint32, token Token, path **uint16) (ret error) = shell32.SHGetKnownFolderPath //sys shGetKnownFolderPath(id *KNOWNFOLDERID, flags uint32, token Token, path **uint16) (ret error) = shell32.SHGetKnownFolderPath
//sys TerminateProcess(handle Handle, exitcode uint32) (err error) //sys TerminateProcess(handle Handle, exitcode uint32) (err error)
//sys GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) //sys GetExitCodeProcess(handle Handle, exitcode *uint32) (err error)
@ -259,17 +265,29 @@ func NewCallbackCDecl(fn interface{}) uintptr {
//sys VirtualProtect(address uintptr, size uintptr, newprotect uint32, oldprotect *uint32) (err error) = kernel32.VirtualProtect //sys VirtualProtect(address uintptr, size uintptr, newprotect uint32, oldprotect *uint32) (err error) = kernel32.VirtualProtect
//sys TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) = mswsock.TransmitFile //sys TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) = mswsock.TransmitFile
//sys ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) = kernel32.ReadDirectoryChangesW //sys ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) = kernel32.ReadDirectoryChangesW
//sys FindFirstChangeNotification(path string, watchSubtree bool, notifyFilter uint32) (handle Handle, err error) [failretval==InvalidHandle] = kernel32.FindFirstChangeNotificationW
//sys FindNextChangeNotification(handle Handle) (err error)
//sys FindCloseChangeNotification(handle Handle) (err error)
//sys CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) = crypt32.CertOpenSystemStoreW //sys CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) = crypt32.CertOpenSystemStoreW
//sys CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) = crypt32.CertOpenStore //sys CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) = crypt32.CertOpenStore
//sys CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) [failretval==nil] = crypt32.CertEnumCertificatesInStore //sys CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) [failretval==nil] = crypt32.CertEnumCertificatesInStore
//sys CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) = crypt32.CertAddCertificateContextToStore //sys CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) = crypt32.CertAddCertificateContextToStore
//sys CertCloseStore(store Handle, flags uint32) (err error) = crypt32.CertCloseStore //sys CertCloseStore(store Handle, flags uint32) (err error) = crypt32.CertCloseStore
//sys CertDeleteCertificateFromStore(certContext *CertContext) (err error) = crypt32.CertDeleteCertificateFromStore //sys CertDeleteCertificateFromStore(certContext *CertContext) (err error) = crypt32.CertDeleteCertificateFromStore
//sys CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) = crypt32.CertGetCertificateChain //sys CertDuplicateCertificateContext(certContext *CertContext) (dupContext *CertContext) = crypt32.CertDuplicateCertificateContext
//sys CertFreeCertificateChain(ctx *CertChainContext) = crypt32.CertFreeCertificateChain //sys PFXImportCertStore(pfx *CryptDataBlob, password *uint16, flags uint32) (store Handle, err error) = crypt32.PFXImportCertStore
//sys CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, encodedLen uint32) (context *CertContext, err error) [failretval==nil] = crypt32.CertCreateCertificateContext //sys CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) = crypt32.CertGetCertificateChain
//sys CertFreeCertificateContext(ctx *CertContext) (err error) = crypt32.CertFreeCertificateContext //sys CertFreeCertificateChain(ctx *CertChainContext) = crypt32.CertFreeCertificateChain
//sys CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) = crypt32.CertVerifyCertificateChainPolicy //sys CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, encodedLen uint32) (context *CertContext, err error) [failretval==nil] = crypt32.CertCreateCertificateContext
//sys CertFreeCertificateContext(ctx *CertContext) (err error) = crypt32.CertFreeCertificateContext
//sys CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) = crypt32.CertVerifyCertificateChainPolicy
//sys CertGetNameString(certContext *CertContext, nameType uint32, flags uint32, typePara unsafe.Pointer, name *uint16, size uint32) (chars uint32) = crypt32.CertGetNameStringW
//sys CertFindExtension(objId *byte, countExtensions uint32, extensions *CertExtension) (ret *CertExtension) = crypt32.CertFindExtension
//sys CryptQueryObject(objectType uint32, object unsafe.Pointer, expectedContentTypeFlags uint32, expectedFormatTypeFlags uint32, flags uint32, msgAndCertEncodingType *uint32, contentType *uint32, formatType *uint32, certStore *Handle, msg *Handle, context *unsafe.Pointer) (err error) = crypt32.CryptQueryObject
//sys CryptDecodeObject(encodingType uint32, structType *byte, encodedBytes *byte, lenEncodedBytes uint32, flags uint32, decoded unsafe.Pointer, decodedLen *uint32) (err error) = crypt32.CryptDecodeObject
//sys CryptProtectData(dataIn *DataBlob, name *uint16, optionalEntropy *DataBlob, reserved uintptr, promptStruct *CryptProtectPromptStruct, flags uint32, dataOut *DataBlob) (err error) = crypt32.CryptProtectData
//sys CryptUnprotectData(dataIn *DataBlob, name **uint16, optionalEntropy *DataBlob, reserved uintptr, promptStruct *CryptProtectPromptStruct, flags uint32, dataOut *DataBlob) (err error) = crypt32.CryptUnprotectData
//sys WinVerifyTrustEx(hwnd HWND, actionId *GUID, data *WinTrustData) (ret error) = wintrust.WinVerifyTrustEx
//sys RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno error) = advapi32.RegOpenKeyExW //sys RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno error) = advapi32.RegOpenKeyExW
//sys RegCloseKey(key Handle) (regerrno error) = advapi32.RegCloseKey //sys RegCloseKey(key Handle) (regerrno error) = advapi32.RegCloseKey
//sys RegQueryInfoKey(key Handle, class *uint16, classLen *uint32, reserved *uint32, subkeysLen *uint32, maxSubkeyLen *uint32, maxClassLen *uint32, valuesLen *uint32, maxValueNameLen *uint32, maxValueLen *uint32, saLen *uint32, lastWriteTime *Filetime) (regerrno error) = advapi32.RegQueryInfoKeyW //sys RegQueryInfoKey(key Handle, class *uint16, classLen *uint32, reserved *uint32, subkeysLen *uint32, maxSubkeyLen *uint32, maxClassLen *uint32, valuesLen *uint32, maxValueNameLen *uint32, maxValueLen *uint32, saLen *uint32, lastWriteTime *Filetime) (regerrno error) = advapi32.RegQueryInfoKeyW
@ -342,8 +360,6 @@ func NewCallbackCDecl(fn interface{}) uintptr {
//sys QueryDosDevice(deviceName *uint16, targetPath *uint16, max uint32) (n uint32, err error) [failretval==0] = QueryDosDeviceW //sys QueryDosDevice(deviceName *uint16, targetPath *uint16, max uint32) (n uint32, err error) [failretval==0] = QueryDosDeviceW
//sys SetVolumeLabel(rootPathName *uint16, volumeName *uint16) (err error) = SetVolumeLabelW //sys SetVolumeLabel(rootPathName *uint16, volumeName *uint16) (err error) = SetVolumeLabelW
//sys SetVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16) (err error) = SetVolumeMountPointW //sys SetVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16) (err error) = SetVolumeMountPointW
//sys MessageBox(hwnd Handle, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) [failretval==0] = user32.MessageBoxW
//sys ExitWindowsEx(flags uint32, reason uint32) (err error) = user32.ExitWindowsEx
//sys InitiateSystemShutdownEx(machineName *uint16, message *uint16, timeout uint32, forceAppsClosed bool, rebootAfterShutdown bool, reason uint32) (err error) = advapi32.InitiateSystemShutdownExW //sys InitiateSystemShutdownEx(machineName *uint16, message *uint16, timeout uint32, forceAppsClosed bool, rebootAfterShutdown bool, reason uint32) (err error) = advapi32.InitiateSystemShutdownExW
//sys SetProcessShutdownParameters(level uint32, flags uint32) (err error) = kernel32.SetProcessShutdownParameters //sys SetProcessShutdownParameters(level uint32, flags uint32) (err error) = kernel32.SetProcessShutdownParameters
//sys GetProcessShutdownParameters(level *uint32, flags *uint32) (err error) = kernel32.GetProcessShutdownParameters //sys GetProcessShutdownParameters(level *uint32, flags *uint32) (err error) = kernel32.GetProcessShutdownParameters

View File

@ -227,7 +227,7 @@ const (
) )
const ( const (
// filters for ReadDirectoryChangesW // filters for ReadDirectoryChangesW and FindFirstChangeNotificationW
FILE_NOTIFY_CHANGE_FILE_NAME = 0x001 FILE_NOTIFY_CHANGE_FILE_NAME = 0x001
FILE_NOTIFY_CHANGE_DIR_NAME = 0x002 FILE_NOTIFY_CHANGE_DIR_NAME = 0x002
FILE_NOTIFY_CHANGE_ATTRIBUTES = 0x004 FILE_NOTIFY_CHANGE_ATTRIBUTES = 0x004
@ -249,24 +249,27 @@ const (
const ( const (
// wincrypt.h // wincrypt.h
PROV_RSA_FULL = 1 /* certenrolld_begin -- PROV_RSA_*/
PROV_RSA_SIG = 2 PROV_RSA_FULL = 1
PROV_DSS = 3 PROV_RSA_SIG = 2
PROV_FORTEZZA = 4 PROV_DSS = 3
PROV_MS_EXCHANGE = 5 PROV_FORTEZZA = 4
PROV_SSL = 6 PROV_MS_EXCHANGE = 5
PROV_RSA_SCHANNEL = 12 PROV_SSL = 6
PROV_DSS_DH = 13 PROV_RSA_SCHANNEL = 12
PROV_EC_ECDSA_SIG = 14 PROV_DSS_DH = 13
PROV_EC_ECNRA_SIG = 15 PROV_EC_ECDSA_SIG = 14
PROV_EC_ECDSA_FULL = 16 PROV_EC_ECNRA_SIG = 15
PROV_EC_ECNRA_FULL = 17 PROV_EC_ECDSA_FULL = 16
PROV_DH_SCHANNEL = 18 PROV_EC_ECNRA_FULL = 17
PROV_SPYRUS_LYNKS = 20 PROV_DH_SCHANNEL = 18
PROV_RNG = 21 PROV_SPYRUS_LYNKS = 20
PROV_INTEL_SEC = 22 PROV_RNG = 21
PROV_REPLACE_OWF = 23 PROV_INTEL_SEC = 22
PROV_RSA_AES = 24 PROV_REPLACE_OWF = 23
PROV_RSA_AES = 24
/* dwFlags definitions for CryptAcquireContext */
CRYPT_VERIFYCONTEXT = 0xF0000000 CRYPT_VERIFYCONTEXT = 0xF0000000
CRYPT_NEWKEYSET = 0x00000008 CRYPT_NEWKEYSET = 0x00000008
CRYPT_DELETEKEYSET = 0x00000010 CRYPT_DELETEKEYSET = 0x00000010
@ -274,6 +277,17 @@ const (
CRYPT_SILENT = 0x00000040 CRYPT_SILENT = 0x00000040
CRYPT_DEFAULT_CONTAINER_OPTIONAL = 0x00000080 CRYPT_DEFAULT_CONTAINER_OPTIONAL = 0x00000080
/* Flags for PFXImportCertStore */
CRYPT_EXPORTABLE = 0x00000001
CRYPT_USER_PROTECTED = 0x00000002
CRYPT_USER_KEYSET = 0x00001000
PKCS12_PREFER_CNG_KSP = 0x00000100
PKCS12_ALWAYS_CNG_KSP = 0x00000200
PKCS12_ALLOW_OVERWRITE_KEY = 0x00004000
PKCS12_NO_PERSIST_KEY = 0x00008000
PKCS12_INCLUDE_EXTENDED_PROPERTIES = 0x00000010
/* Default usage match type is AND with value zero */
USAGE_MATCH_TYPE_AND = 0 USAGE_MATCH_TYPE_AND = 0
USAGE_MATCH_TYPE_OR = 1 USAGE_MATCH_TYPE_OR = 1
@ -409,6 +423,71 @@ const (
CERT_CHAIN_POLICY_EV = 8 CERT_CHAIN_POLICY_EV = 8
CERT_CHAIN_POLICY_SSL_F12 = 9 CERT_CHAIN_POLICY_SSL_F12 = 9
/* Certificate Store close flags */
CERT_CLOSE_STORE_FORCE_FLAG = 0x00000001
CERT_CLOSE_STORE_CHECK_FLAG = 0x00000002
/* CryptQueryObject object type */
CERT_QUERY_OBJECT_FILE = 1
CERT_QUERY_OBJECT_BLOB = 2
/* CryptQueryObject content type flags */
CERT_QUERY_CONTENT_CERT = 1
CERT_QUERY_CONTENT_CTL = 2
CERT_QUERY_CONTENT_CRL = 3
CERT_QUERY_CONTENT_SERIALIZED_STORE = 4
CERT_QUERY_CONTENT_SERIALIZED_CERT = 5
CERT_QUERY_CONTENT_SERIALIZED_CTL = 6
CERT_QUERY_CONTENT_SERIALIZED_CRL = 7
CERT_QUERY_CONTENT_PKCS7_SIGNED = 8
CERT_QUERY_CONTENT_PKCS7_UNSIGNED = 9
CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED = 10
CERT_QUERY_CONTENT_PKCS10 = 11
CERT_QUERY_CONTENT_PFX = 12
CERT_QUERY_CONTENT_CERT_PAIR = 13
CERT_QUERY_CONTENT_PFX_AND_LOAD = 14
CERT_QUERY_CONTENT_FLAG_CERT = (1 << CERT_QUERY_CONTENT_CERT)
CERT_QUERY_CONTENT_FLAG_CTL = (1 << CERT_QUERY_CONTENT_CTL)
CERT_QUERY_CONTENT_FLAG_CRL = (1 << CERT_QUERY_CONTENT_CRL)
CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE = (1 << CERT_QUERY_CONTENT_SERIALIZED_STORE)
CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT = (1 << CERT_QUERY_CONTENT_SERIALIZED_CERT)
CERT_QUERY_CONTENT_FLAG_SERIALIZED_CTL = (1 << CERT_QUERY_CONTENT_SERIALIZED_CTL)
CERT_QUERY_CONTENT_FLAG_SERIALIZED_CRL = (1 << CERT_QUERY_CONTENT_SERIALIZED_CRL)
CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED = (1 << CERT_QUERY_CONTENT_PKCS7_SIGNED)
CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED = (1 << CERT_QUERY_CONTENT_PKCS7_UNSIGNED)
CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED = (1 << CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED)
CERT_QUERY_CONTENT_FLAG_PKCS10 = (1 << CERT_QUERY_CONTENT_PKCS10)
CERT_QUERY_CONTENT_FLAG_PFX = (1 << CERT_QUERY_CONTENT_PFX)
CERT_QUERY_CONTENT_FLAG_CERT_PAIR = (1 << CERT_QUERY_CONTENT_CERT_PAIR)
CERT_QUERY_CONTENT_FLAG_PFX_AND_LOAD = (1 << CERT_QUERY_CONTENT_PFX_AND_LOAD)
CERT_QUERY_CONTENT_FLAG_ALL = (CERT_QUERY_CONTENT_FLAG_CERT | CERT_QUERY_CONTENT_FLAG_CTL | CERT_QUERY_CONTENT_FLAG_CRL | CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE | CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT | CERT_QUERY_CONTENT_FLAG_SERIALIZED_CTL | CERT_QUERY_CONTENT_FLAG_SERIALIZED_CRL | CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED | CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED | CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED | CERT_QUERY_CONTENT_FLAG_PKCS10 | CERT_QUERY_CONTENT_FLAG_PFX | CERT_QUERY_CONTENT_FLAG_CERT_PAIR)
CERT_QUERY_CONTENT_FLAG_ALL_ISSUER_CERT = (CERT_QUERY_CONTENT_FLAG_CERT | CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE | CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT | CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED | CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED)
/* CryptQueryObject format type flags */
CERT_QUERY_FORMAT_BINARY = 1
CERT_QUERY_FORMAT_BASE64_ENCODED = 2
CERT_QUERY_FORMAT_ASN_ASCII_HEX_ENCODED = 3
CERT_QUERY_FORMAT_FLAG_BINARY = (1 << CERT_QUERY_FORMAT_BINARY)
CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED = (1 << CERT_QUERY_FORMAT_BASE64_ENCODED)
CERT_QUERY_FORMAT_FLAG_ASN_ASCII_HEX_ENCODED = (1 << CERT_QUERY_FORMAT_ASN_ASCII_HEX_ENCODED)
CERT_QUERY_FORMAT_FLAG_ALL = (CERT_QUERY_FORMAT_FLAG_BINARY | CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED | CERT_QUERY_FORMAT_FLAG_ASN_ASCII_HEX_ENCODED)
/* CertGetNameString name types */
CERT_NAME_EMAIL_TYPE = 1
CERT_NAME_RDN_TYPE = 2
CERT_NAME_ATTR_TYPE = 3
CERT_NAME_SIMPLE_DISPLAY_TYPE = 4
CERT_NAME_FRIENDLY_DISPLAY_TYPE = 5
CERT_NAME_DNS_TYPE = 6
CERT_NAME_URL_TYPE = 7
CERT_NAME_UPN_TYPE = 8
/* CertGetNameString flags */
CERT_NAME_ISSUER_FLAG = 0x1
CERT_NAME_DISABLE_IE4_UTF8_FLAG = 0x10000
CERT_NAME_SEARCH_ALL_NAMES_FLAG = 0x2
CERT_NAME_STR_ENABLE_PUNYCODE_FLAG = 0x00200000
/* AuthType values for SSLExtraCertChainPolicyPara struct */ /* AuthType values for SSLExtraCertChainPolicyPara struct */
AUTHTYPE_CLIENT = 1 AUTHTYPE_CLIENT = 1
AUTHTYPE_SERVER = 2 AUTHTYPE_SERVER = 2
@ -419,6 +498,22 @@ const (
SECURITY_FLAG_IGNORE_WRONG_USAGE = 0x00000200 SECURITY_FLAG_IGNORE_WRONG_USAGE = 0x00000200
SECURITY_FLAG_IGNORE_CERT_CN_INVALID = 0x00001000 SECURITY_FLAG_IGNORE_CERT_CN_INVALID = 0x00001000
SECURITY_FLAG_IGNORE_CERT_DATE_INVALID = 0x00002000 SECURITY_FLAG_IGNORE_CERT_DATE_INVALID = 0x00002000
/* Flags for Crypt[Un]ProtectData */
CRYPTPROTECT_UI_FORBIDDEN = 0x1
CRYPTPROTECT_LOCAL_MACHINE = 0x4
CRYPTPROTECT_CRED_SYNC = 0x8
CRYPTPROTECT_AUDIT = 0x10
CRYPTPROTECT_NO_RECOVERY = 0x20
CRYPTPROTECT_VERIFY_PROTECTION = 0x40
CRYPTPROTECT_CRED_REGENERATE = 0x80
/* Flags for CryptProtectPromptStruct */
CRYPTPROTECT_PROMPT_ON_UNPROTECT = 1
CRYPTPROTECT_PROMPT_ON_PROTECT = 2
CRYPTPROTECT_PROMPT_RESERVED = 4
CRYPTPROTECT_PROMPT_STRONG = 8
CRYPTPROTECT_PROMPT_REQUIRE_STRONG = 16
) )
const ( const (
@ -441,10 +536,58 @@ const (
REALTIME_PRIORITY_CLASS = 0x00000100 REALTIME_PRIORITY_CLASS = 0x00000100
) )
/* wintrust.h constants for WinVerifyTrustEx */
const (
WTD_UI_ALL = 1
WTD_UI_NONE = 2
WTD_UI_NOBAD = 3
WTD_UI_NOGOOD = 4
WTD_REVOKE_NONE = 0
WTD_REVOKE_WHOLECHAIN = 1
WTD_CHOICE_FILE = 1
WTD_CHOICE_CATALOG = 2
WTD_CHOICE_BLOB = 3
WTD_CHOICE_SIGNER = 4
WTD_CHOICE_CERT = 5
WTD_STATEACTION_IGNORE = 0x00000000
WTD_STATEACTION_VERIFY = 0x00000010
WTD_STATEACTION_CLOSE = 0x00000002
WTD_STATEACTION_AUTO_CACHE = 0x00000003
WTD_STATEACTION_AUTO_CACHE_FLUSH = 0x00000004
WTD_USE_IE4_TRUST_FLAG = 0x1
WTD_NO_IE4_CHAIN_FLAG = 0x2
WTD_NO_POLICY_USAGE_FLAG = 0x4
WTD_REVOCATION_CHECK_NONE = 0x10
WTD_REVOCATION_CHECK_END_CERT = 0x20
WTD_REVOCATION_CHECK_CHAIN = 0x40
WTD_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT = 0x80
WTD_SAFER_FLAG = 0x100
WTD_HASH_ONLY_FLAG = 0x200
WTD_USE_DEFAULT_OSVER_CHECK = 0x400
WTD_LIFETIME_SIGNING_FLAG = 0x800
WTD_CACHE_ONLY_URL_RETRIEVAL = 0x1000
WTD_DISABLE_MD2_MD4 = 0x2000
WTD_MOTW = 0x4000
WTD_UICONTEXT_EXECUTE = 0
WTD_UICONTEXT_INSTALL = 1
)
var ( var (
OID_PKIX_KP_SERVER_AUTH = []byte("1.3.6.1.5.5.7.3.1\x00") OID_PKIX_KP_SERVER_AUTH = []byte("1.3.6.1.5.5.7.3.1\x00")
OID_SERVER_GATED_CRYPTO = []byte("1.3.6.1.4.1.311.10.3.3\x00") OID_SERVER_GATED_CRYPTO = []byte("1.3.6.1.4.1.311.10.3.3\x00")
OID_SGC_NETSCAPE = []byte("2.16.840.1.113730.4.1\x00") OID_SGC_NETSCAPE = []byte("2.16.840.1.113730.4.1\x00")
WINTRUST_ACTION_GENERIC_VERIFY_V2 = GUID{
Data1: 0xaac56b,
Data2: 0xcd44,
Data3: 0x11d0,
Data4: [8]byte{0x8c, 0xc2, 0x0, 0xc0, 0x4f, 0xc2, 0x95, 0xee},
}
) )
// Pointer represents a pointer to an arbitrary Windows type. // Pointer represents a pointer to an arbitrary Windows type.
@ -1033,7 +1176,57 @@ type MibIfRow struct {
} }
type CertInfo struct { type CertInfo struct {
// Not implemented Version uint32
SerialNumber CryptIntegerBlob
SignatureAlgorithm CryptAlgorithmIdentifier
Issuer CertNameBlob
NotBefore Filetime
NotAfter Filetime
Subject CertNameBlob
SubjectPublicKeyInfo CertPublicKeyInfo
IssuerUniqueId CryptBitBlob
SubjectUniqueId CryptBitBlob
CountExtensions uint32
Extensions *CertExtension
}
type CertExtension struct {
ObjId *byte
Critical int32
Value CryptObjidBlob
}
type CryptAlgorithmIdentifier struct {
ObjId *byte
Parameters CryptObjidBlob
}
type CertPublicKeyInfo struct {
Algorithm CryptAlgorithmIdentifier
PublicKey CryptBitBlob
}
type DataBlob struct {
Size uint32
Data *byte
}
type CryptIntegerBlob DataBlob
type CryptUintBlob DataBlob
type CryptObjidBlob DataBlob
type CertNameBlob DataBlob
type CertRdnValueBlob DataBlob
type CertBlob DataBlob
type CrlBlob DataBlob
type CryptDataBlob DataBlob
type CryptHashBlob DataBlob
type CryptDigestBlob DataBlob
type CryptDerBlob DataBlob
type CryptAttrBlob DataBlob
type CryptBitBlob struct {
Size uint32
Data *byte
UnusedBits uint32
} }
type CertContext struct { type CertContext struct {
@ -1139,6 +1332,66 @@ type CertChainPolicyStatus struct {
ExtraPolicyStatus Pointer ExtraPolicyStatus Pointer
} }
type CertPolicyInfo struct {
Identifier *byte
CountQualifiers uint32
Qualifiers *CertPolicyQualifierInfo
}
type CertPoliciesInfo struct {
Count uint32
PolicyInfos *CertPolicyInfo
}
type CertPolicyQualifierInfo struct {
// Not implemented
}
type CertStrongSignPara struct {
Size uint32
InfoChoice uint32
InfoOrSerializedInfoOrOID unsafe.Pointer
}
type CryptProtectPromptStruct struct {
Size uint32
PromptFlags uint32
App HWND
Prompt *uint16
}
type WinTrustData struct {
Size uint32
PolicyCallbackData uintptr
SIPClientData uintptr
UIChoice uint32
RevocationChecks uint32
UnionChoice uint32
FileOrCatalogOrBlobOrSgnrOrCert unsafe.Pointer
StateAction uint32
StateData Handle
URLReference *uint16
ProvFlags uint32
UIContext uint32
SignatureSettings *WinTrustSignatureSettings
}
type WinTrustFileInfo struct {
Size uint32
FilePath *uint16
File Handle
KnownSubject *GUID
}
type WinTrustSignatureSettings struct {
Size uint32
Index uint32
Flags uint32
SecondarySigs uint32
VerifiedSigIndex uint32
CryptoPolicy *CertStrongSignPara
}
const ( const (
// do not reorder // do not reorder
HKEY_CLASSES_ROOT = 0x80000000 + iota HKEY_CLASSES_ROOT = 0x80000000 + iota

View File

@ -51,6 +51,7 @@ var (
modshell32 = NewLazySystemDLL("shell32.dll") modshell32 = NewLazySystemDLL("shell32.dll")
moduser32 = NewLazySystemDLL("user32.dll") moduser32 = NewLazySystemDLL("user32.dll")
moduserenv = NewLazySystemDLL("userenv.dll") moduserenv = NewLazySystemDLL("userenv.dll")
modwintrust = NewLazySystemDLL("wintrust.dll")
modws2_32 = NewLazySystemDLL("ws2_32.dll") modws2_32 = NewLazySystemDLL("ws2_32.dll")
modwtsapi32 = NewLazySystemDLL("wtsapi32.dll") modwtsapi32 = NewLazySystemDLL("wtsapi32.dll")
@ -143,13 +144,21 @@ var (
procCertCloseStore = modcrypt32.NewProc("CertCloseStore") procCertCloseStore = modcrypt32.NewProc("CertCloseStore")
procCertCreateCertificateContext = modcrypt32.NewProc("CertCreateCertificateContext") procCertCreateCertificateContext = modcrypt32.NewProc("CertCreateCertificateContext")
procCertDeleteCertificateFromStore = modcrypt32.NewProc("CertDeleteCertificateFromStore") procCertDeleteCertificateFromStore = modcrypt32.NewProc("CertDeleteCertificateFromStore")
procCertDuplicateCertificateContext = modcrypt32.NewProc("CertDuplicateCertificateContext")
procCertEnumCertificatesInStore = modcrypt32.NewProc("CertEnumCertificatesInStore") procCertEnumCertificatesInStore = modcrypt32.NewProc("CertEnumCertificatesInStore")
procCertFindExtension = modcrypt32.NewProc("CertFindExtension")
procCertFreeCertificateChain = modcrypt32.NewProc("CertFreeCertificateChain") procCertFreeCertificateChain = modcrypt32.NewProc("CertFreeCertificateChain")
procCertFreeCertificateContext = modcrypt32.NewProc("CertFreeCertificateContext") procCertFreeCertificateContext = modcrypt32.NewProc("CertFreeCertificateContext")
procCertGetCertificateChain = modcrypt32.NewProc("CertGetCertificateChain") procCertGetCertificateChain = modcrypt32.NewProc("CertGetCertificateChain")
procCertGetNameStringW = modcrypt32.NewProc("CertGetNameStringW")
procCertOpenStore = modcrypt32.NewProc("CertOpenStore") procCertOpenStore = modcrypt32.NewProc("CertOpenStore")
procCertOpenSystemStoreW = modcrypt32.NewProc("CertOpenSystemStoreW") procCertOpenSystemStoreW = modcrypt32.NewProc("CertOpenSystemStoreW")
procCertVerifyCertificateChainPolicy = modcrypt32.NewProc("CertVerifyCertificateChainPolicy") procCertVerifyCertificateChainPolicy = modcrypt32.NewProc("CertVerifyCertificateChainPolicy")
procCryptDecodeObject = modcrypt32.NewProc("CryptDecodeObject")
procCryptProtectData = modcrypt32.NewProc("CryptProtectData")
procCryptQueryObject = modcrypt32.NewProc("CryptQueryObject")
procCryptUnprotectData = modcrypt32.NewProc("CryptUnprotectData")
procPFXImportCertStore = modcrypt32.NewProc("PFXImportCertStore")
procDnsNameCompare_W = moddnsapi.NewProc("DnsNameCompare_W") procDnsNameCompare_W = moddnsapi.NewProc("DnsNameCompare_W")
procDnsQuery_W = moddnsapi.NewProc("DnsQuery_W") procDnsQuery_W = moddnsapi.NewProc("DnsQuery_W")
procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree") procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree")
@ -181,9 +190,12 @@ var (
procDuplicateHandle = modkernel32.NewProc("DuplicateHandle") procDuplicateHandle = modkernel32.NewProc("DuplicateHandle")
procExitProcess = modkernel32.NewProc("ExitProcess") procExitProcess = modkernel32.NewProc("ExitProcess")
procFindClose = modkernel32.NewProc("FindClose") procFindClose = modkernel32.NewProc("FindClose")
procFindCloseChangeNotification = modkernel32.NewProc("FindCloseChangeNotification")
procFindFirstChangeNotificationW = modkernel32.NewProc("FindFirstChangeNotificationW")
procFindFirstFileW = modkernel32.NewProc("FindFirstFileW") procFindFirstFileW = modkernel32.NewProc("FindFirstFileW")
procFindFirstVolumeMountPointW = modkernel32.NewProc("FindFirstVolumeMountPointW") procFindFirstVolumeMountPointW = modkernel32.NewProc("FindFirstVolumeMountPointW")
procFindFirstVolumeW = modkernel32.NewProc("FindFirstVolumeW") procFindFirstVolumeW = modkernel32.NewProc("FindFirstVolumeW")
procFindNextChangeNotification = modkernel32.NewProc("FindNextChangeNotification")
procFindNextFileW = modkernel32.NewProc("FindNextFileW") procFindNextFileW = modkernel32.NewProc("FindNextFileW")
procFindNextVolumeMountPointW = modkernel32.NewProc("FindNextVolumeMountPointW") procFindNextVolumeMountPointW = modkernel32.NewProc("FindNextVolumeMountPointW")
procFindNextVolumeW = modkernel32.NewProc("FindNextVolumeW") procFindNextVolumeW = modkernel32.NewProc("FindNextVolumeW")
@ -339,10 +351,13 @@ var (
procSHGetKnownFolderPath = modshell32.NewProc("SHGetKnownFolderPath") procSHGetKnownFolderPath = modshell32.NewProc("SHGetKnownFolderPath")
procShellExecuteW = modshell32.NewProc("ShellExecuteW") procShellExecuteW = modshell32.NewProc("ShellExecuteW")
procExitWindowsEx = moduser32.NewProc("ExitWindowsEx") procExitWindowsEx = moduser32.NewProc("ExitWindowsEx")
procGetShellWindow = moduser32.NewProc("GetShellWindow")
procGetWindowThreadProcessId = moduser32.NewProc("GetWindowThreadProcessId")
procMessageBoxW = moduser32.NewProc("MessageBoxW") procMessageBoxW = moduser32.NewProc("MessageBoxW")
procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock") procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock")
procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock") procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock")
procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW") procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW")
procWinVerifyTrustEx = modwintrust.NewProc("WinVerifyTrustEx")
procFreeAddrInfoW = modws2_32.NewProc("FreeAddrInfoW") procFreeAddrInfoW = modws2_32.NewProc("FreeAddrInfoW")
procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW") procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW")
procWSACleanup = modws2_32.NewProc("WSACleanup") procWSACleanup = modws2_32.NewProc("WSACleanup")
@ -1180,6 +1195,12 @@ func CertDeleteCertificateFromStore(certContext *CertContext) (err error) {
return return
} }
func CertDuplicateCertificateContext(certContext *CertContext) (dupContext *CertContext) {
r0, _, _ := syscall.Syscall(procCertDuplicateCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(certContext)), 0, 0)
dupContext = (*CertContext)(unsafe.Pointer(r0))
return
}
func CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) { func CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) {
r0, _, e1 := syscall.Syscall(procCertEnumCertificatesInStore.Addr(), 2, uintptr(store), uintptr(unsafe.Pointer(prevContext)), 0) r0, _, e1 := syscall.Syscall(procCertEnumCertificatesInStore.Addr(), 2, uintptr(store), uintptr(unsafe.Pointer(prevContext)), 0)
context = (*CertContext)(unsafe.Pointer(r0)) context = (*CertContext)(unsafe.Pointer(r0))
@ -1189,6 +1210,12 @@ func CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (contex
return return
} }
func CertFindExtension(objId *byte, countExtensions uint32, extensions *CertExtension) (ret *CertExtension) {
r0, _, _ := syscall.Syscall(procCertFindExtension.Addr(), 3, uintptr(unsafe.Pointer(objId)), uintptr(countExtensions), uintptr(unsafe.Pointer(extensions)))
ret = (*CertExtension)(unsafe.Pointer(r0))
return
}
func CertFreeCertificateChain(ctx *CertChainContext) { func CertFreeCertificateChain(ctx *CertChainContext) {
syscall.Syscall(procCertFreeCertificateChain.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0) syscall.Syscall(procCertFreeCertificateChain.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
return return
@ -1210,6 +1237,12 @@ func CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, a
return return
} }
func CertGetNameString(certContext *CertContext, nameType uint32, flags uint32, typePara unsafe.Pointer, name *uint16, size uint32) (chars uint32) {
r0, _, _ := syscall.Syscall6(procCertGetNameStringW.Addr(), 6, uintptr(unsafe.Pointer(certContext)), uintptr(nameType), uintptr(flags), uintptr(typePara), uintptr(unsafe.Pointer(name)), uintptr(size))
chars = uint32(r0)
return
}
func CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) { func CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) {
r0, _, e1 := syscall.Syscall6(procCertOpenStore.Addr(), 5, uintptr(storeProvider), uintptr(msgAndCertEncodingType), uintptr(cryptProv), uintptr(flags), uintptr(para), 0) r0, _, e1 := syscall.Syscall6(procCertOpenStore.Addr(), 5, uintptr(storeProvider), uintptr(msgAndCertEncodingType), uintptr(cryptProv), uintptr(flags), uintptr(para), 0)
handle = Handle(r0) handle = Handle(r0)
@ -1236,6 +1269,47 @@ func CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext
return return
} }
func CryptDecodeObject(encodingType uint32, structType *byte, encodedBytes *byte, lenEncodedBytes uint32, flags uint32, decoded unsafe.Pointer, decodedLen *uint32) (err error) {
r1, _, e1 := syscall.Syscall9(procCryptDecodeObject.Addr(), 7, uintptr(encodingType), uintptr(unsafe.Pointer(structType)), uintptr(unsafe.Pointer(encodedBytes)), uintptr(lenEncodedBytes), uintptr(flags), uintptr(decoded), uintptr(unsafe.Pointer(decodedLen)), 0, 0)
if r1 == 0 {
err = errnoErr(e1)
}
return
}
func CryptProtectData(dataIn *DataBlob, name *uint16, optionalEntropy *DataBlob, reserved uintptr, promptStruct *CryptProtectPromptStruct, flags uint32, dataOut *DataBlob) (err error) {
r1, _, e1 := syscall.Syscall9(procCryptProtectData.Addr(), 7, uintptr(unsafe.Pointer(dataIn)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(optionalEntropy)), uintptr(reserved), uintptr(unsafe.Pointer(promptStruct)), uintptr(flags), uintptr(unsafe.Pointer(dataOut)), 0, 0)
if r1 == 0 {
err = errnoErr(e1)
}
return
}
func CryptQueryObject(objectType uint32, object unsafe.Pointer, expectedContentTypeFlags uint32, expectedFormatTypeFlags uint32, flags uint32, msgAndCertEncodingType *uint32, contentType *uint32, formatType *uint32, certStore *Handle, msg *Handle, context *unsafe.Pointer) (err error) {
r1, _, e1 := syscall.Syscall12(procCryptQueryObject.Addr(), 11, uintptr(objectType), uintptr(object), uintptr(expectedContentTypeFlags), uintptr(expectedFormatTypeFlags), uintptr(flags), uintptr(unsafe.Pointer(msgAndCertEncodingType)), uintptr(unsafe.Pointer(contentType)), uintptr(unsafe.Pointer(formatType)), uintptr(unsafe.Pointer(certStore)), uintptr(unsafe.Pointer(msg)), uintptr(unsafe.Pointer(context)), 0)
if r1 == 0 {
err = errnoErr(e1)
}
return
}
func CryptUnprotectData(dataIn *DataBlob, name **uint16, optionalEntropy *DataBlob, reserved uintptr, promptStruct *CryptProtectPromptStruct, flags uint32, dataOut *DataBlob) (err error) {
r1, _, e1 := syscall.Syscall9(procCryptUnprotectData.Addr(), 7, uintptr(unsafe.Pointer(dataIn)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(optionalEntropy)), uintptr(reserved), uintptr(unsafe.Pointer(promptStruct)), uintptr(flags), uintptr(unsafe.Pointer(dataOut)), 0, 0)
if r1 == 0 {
err = errnoErr(e1)
}
return
}
func PFXImportCertStore(pfx *CryptDataBlob, password *uint16, flags uint32) (store Handle, err error) {
r0, _, e1 := syscall.Syscall(procPFXImportCertStore.Addr(), 3, uintptr(unsafe.Pointer(pfx)), uintptr(unsafe.Pointer(password)), uintptr(flags))
store = Handle(r0)
if store == 0 {
err = errnoErr(e1)
}
return
}
func DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) { func DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) {
r0, _, _ := syscall.Syscall(procDnsNameCompare_W.Addr(), 2, uintptr(unsafe.Pointer(name1)), uintptr(unsafe.Pointer(name2)), 0) r0, _, _ := syscall.Syscall(procDnsNameCompare_W.Addr(), 2, uintptr(unsafe.Pointer(name1)), uintptr(unsafe.Pointer(name2)), 0)
same = r0 != 0 same = r0 != 0
@ -1506,6 +1580,36 @@ func FindClose(handle Handle) (err error) {
return return
} }
func FindCloseChangeNotification(handle Handle) (err error) {
r1, _, e1 := syscall.Syscall(procFindCloseChangeNotification.Addr(), 1, uintptr(handle), 0, 0)
if r1 == 0 {
err = errnoErr(e1)
}
return
}
func FindFirstChangeNotification(path string, watchSubtree bool, notifyFilter uint32) (handle Handle, err error) {
var _p0 *uint16
_p0, err = syscall.UTF16PtrFromString(path)
if err != nil {
return
}
return _FindFirstChangeNotification(_p0, watchSubtree, notifyFilter)
}
func _FindFirstChangeNotification(path *uint16, watchSubtree bool, notifyFilter uint32) (handle Handle, err error) {
var _p1 uint32
if watchSubtree {
_p1 = 1
}
r0, _, e1 := syscall.Syscall(procFindFirstChangeNotificationW.Addr(), 3, uintptr(unsafe.Pointer(path)), uintptr(_p1), uintptr(notifyFilter))
handle = Handle(r0)
if handle == InvalidHandle {
err = errnoErr(e1)
}
return
}
func findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err error) { func findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err error) {
r0, _, e1 := syscall.Syscall(procFindFirstFileW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(data)), 0) r0, _, e1 := syscall.Syscall(procFindFirstFileW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(data)), 0)
handle = Handle(r0) handle = Handle(r0)
@ -1533,6 +1637,14 @@ func FindFirstVolume(volumeName *uint16, bufferLength uint32) (handle Handle, er
return return
} }
func FindNextChangeNotification(handle Handle) (err error) {
r1, _, e1 := syscall.Syscall(procFindNextChangeNotification.Addr(), 1, uintptr(handle), 0, 0)
if r1 == 0 {
err = errnoErr(e1)
}
return
}
func findNextFile1(handle Handle, data *win32finddata1) (err error) { func findNextFile1(handle Handle, data *win32finddata1) (err error) {
r1, _, e1 := syscall.Syscall(procFindNextFileW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0) r1, _, e1 := syscall.Syscall(procFindNextFileW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
if r1 == 0 { if r1 == 0 {
@ -2879,7 +2991,22 @@ func ExitWindowsEx(flags uint32, reason uint32) (err error) {
return return
} }
func MessageBox(hwnd Handle, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) { func GetShellWindow() (shellWindow HWND) {
r0, _, _ := syscall.Syscall(procGetShellWindow.Addr(), 0, 0, 0, 0)
shellWindow = HWND(r0)
return
}
func GetWindowThreadProcessId(hwnd HWND, pid *uint32) (tid uint32, err error) {
r0, _, e1 := syscall.Syscall(procGetWindowThreadProcessId.Addr(), 2, uintptr(hwnd), uintptr(unsafe.Pointer(pid)), 0)
tid = uint32(r0)
if tid == 0 {
err = errnoErr(e1)
}
return
}
func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) {
r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0) r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0)
ret = int32(r0) ret = int32(r0)
if ret == 0 { if ret == 0 {
@ -2916,6 +3043,14 @@ func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) {
return return
} }
func WinVerifyTrustEx(hwnd HWND, actionId *GUID, data *WinTrustData) (ret error) {
r0, _, _ := syscall.Syscall(procWinVerifyTrustEx.Addr(), 3, uintptr(hwnd), uintptr(unsafe.Pointer(actionId)), uintptr(unsafe.Pointer(data)))
if r0 != 0 {
ret = syscall.Errno(r0)
}
return
}
func FreeAddrInfoW(addrinfo *AddrinfoW) { func FreeAddrInfoW(addrinfo *AddrinfoW) {
syscall.Syscall(procFreeAddrInfoW.Addr(), 1, uintptr(unsafe.Pointer(addrinfo)), 0, 0) syscall.Syscall(procFreeAddrInfoW.Addr(), 1, uintptr(unsafe.Pointer(addrinfo)), 0, 0)
return return

View File

@ -57,7 +57,7 @@ loop:
err = transform.ErrShortSrc err = transform.ErrShortSrc
break loop break loop
} }
r = utf8.RuneError r, size = utf8.RuneError, 1
goto write goto write
} }
size = 2 size = 2

View File

@ -133,14 +133,15 @@ func (s *scanner) resizeRange(oldStart, oldEnd, newSize int) {
s.start = oldStart s.start = oldStart
if end := oldStart + newSize; end != oldEnd { if end := oldStart + newSize; end != oldEnd {
diff := end - oldEnd diff := end - oldEnd
if end < cap(s.b) { var b []byte
b := make([]byte, len(s.b)+diff) if n := len(s.b) + diff; n > cap(s.b) {
b = make([]byte, n)
copy(b, s.b[:oldStart]) copy(b, s.b[:oldStart])
copy(b[end:], s.b[oldEnd:])
s.b = b
} else { } else {
s.b = append(s.b[end:], s.b[oldEnd:]...) b = s.b[:n:n]
} }
copy(b[end:], s.b[oldEnd:])
s.b = b
s.next = end + (s.next - s.end) s.next = end + (s.next - s.end)
s.end = end s.end = end
} }

View File

@ -12,15 +12,14 @@
// and without notice. // and without notice.
package bidi // import "golang.org/x/text/unicode/bidi" package bidi // import "golang.org/x/text/unicode/bidi"
// TODO: // TODO
// The following functionality would not be hard to implement, but hinges on
// the definition of a Segmenter interface. For now this is up to the user.
// - Iterate over paragraphs
// - Segmenter to iterate over runs directly from a given text.
// Also:
// - Transformer for reordering? // - Transformer for reordering?
// - Transformer (validator, really) for Bidi Rule. // - Transformer (validator, really) for Bidi Rule.
import (
"bytes"
)
// This API tries to avoid dealing with embedding levels for now. Under the hood // This API tries to avoid dealing with embedding levels for now. Under the hood
// these will be computed, but the question is to which extent the user should // these will be computed, but the question is to which extent the user should
// know they exist. We should at some point allow the user to specify an // know they exist. We should at some point allow the user to specify an
@ -49,7 +48,9 @@ const (
Neutral Neutral
) )
type options struct{} type options struct {
defaultDirection Direction
}
// An Option is an option for Bidi processing. // An Option is an option for Bidi processing.
type Option func(*options) type Option func(*options)
@ -66,12 +67,62 @@ type Option func(*options)
// DefaultDirection sets the default direction for a Paragraph. The direction is // DefaultDirection sets the default direction for a Paragraph. The direction is
// overridden if the text contains directional characters. // overridden if the text contains directional characters.
func DefaultDirection(d Direction) Option { func DefaultDirection(d Direction) Option {
panic("unimplemented") return func(opts *options) {
opts.defaultDirection = d
}
} }
// A Paragraph holds a single Paragraph for Bidi processing. // A Paragraph holds a single Paragraph for Bidi processing.
type Paragraph struct { type Paragraph struct {
// buffers p []byte
o Ordering
opts []Option
types []Class
pairTypes []bracketType
pairValues []rune
runes []rune
options options
}
// Initialize the p.pairTypes, p.pairValues and p.types from the input previously
// set by p.SetBytes() or p.SetString(). Also limit the input up to (and including) a paragraph
// separator (bidi class B).
//
// The function p.Order() needs these values to be set, so this preparation could be postponed.
// But since the SetBytes and SetStrings functions return the length of the input up to the paragraph
// separator, the whole input needs to be processed anyway and should not be done twice.
//
// The function has the same return values as SetBytes() / SetString()
func (p *Paragraph) prepareInput() (n int, err error) {
p.runes = bytes.Runes(p.p)
bytecount := 0
// clear slices from previous SetString or SetBytes
p.pairTypes = nil
p.pairValues = nil
p.types = nil
for _, r := range p.runes {
props, i := LookupRune(r)
bytecount += i
cls := props.Class()
if cls == B {
return bytecount, nil
}
p.types = append(p.types, cls)
if props.IsOpeningBracket() {
p.pairTypes = append(p.pairTypes, bpOpen)
p.pairValues = append(p.pairValues, r)
} else if props.IsBracket() {
// this must be a closing bracket,
// since IsOpeningBracket is not true
p.pairTypes = append(p.pairTypes, bpClose)
p.pairValues = append(p.pairValues, r)
} else {
p.pairTypes = append(p.pairTypes, bpNone)
p.pairValues = append(p.pairValues, 0)
}
}
return bytecount, nil
} }
// SetBytes configures p for the given paragraph text. It replaces text // SetBytes configures p for the given paragraph text. It replaces text
@ -80,70 +131,150 @@ type Paragraph struct {
// consumed from b including this separator. Error may be non-nil if options are // consumed from b including this separator. Error may be non-nil if options are
// given. // given.
func (p *Paragraph) SetBytes(b []byte, opts ...Option) (n int, err error) { func (p *Paragraph) SetBytes(b []byte, opts ...Option) (n int, err error) {
panic("unimplemented") p.p = b
p.opts = opts
return p.prepareInput()
} }
// SetString configures p for the given paragraph text. It replaces text // SetString configures s for the given paragraph text. It replaces text
// previously set by SetBytes or SetString. If b contains a paragraph separator // previously set by SetBytes or SetString. If s contains a paragraph separator
// it will only process the first paragraph and report the number of bytes // it will only process the first paragraph and report the number of bytes
// consumed from b including this separator. Error may be non-nil if options are // consumed from s including this separator. Error may be non-nil if options are
// given. // given.
func (p *Paragraph) SetString(s string, opts ...Option) (n int, err error) { func (p *Paragraph) SetString(s string, opts ...Option) (n int, err error) {
panic("unimplemented") p.p = []byte(s)
p.opts = opts
return p.prepareInput()
} }
// IsLeftToRight reports whether the principle direction of rendering for this // IsLeftToRight reports whether the principle direction of rendering for this
// paragraphs is left-to-right. If this returns false, the principle direction // paragraphs is left-to-right. If this returns false, the principle direction
// of rendering is right-to-left. // of rendering is right-to-left.
func (p *Paragraph) IsLeftToRight() bool { func (p *Paragraph) IsLeftToRight() bool {
panic("unimplemented") return p.Direction() == LeftToRight
} }
// Direction returns the direction of the text of this paragraph. // Direction returns the direction of the text of this paragraph.
// //
// The direction may be LeftToRight, RightToLeft, Mixed, or Neutral. // The direction may be LeftToRight, RightToLeft, Mixed, or Neutral.
func (p *Paragraph) Direction() Direction { func (p *Paragraph) Direction() Direction {
panic("unimplemented") return p.o.Direction()
} }
// TODO: what happens if the position is > len(input)? This should return an error.
// RunAt reports the Run at the given position of the input text. // RunAt reports the Run at the given position of the input text.
// //
// This method can be used for computing line breaks on paragraphs. // This method can be used for computing line breaks on paragraphs.
func (p *Paragraph) RunAt(pos int) Run { func (p *Paragraph) RunAt(pos int) Run {
panic("unimplemented") c := 0
runNumber := 0
for i, r := range p.o.runes {
c += len(r)
if pos < c {
runNumber = i
}
}
return p.o.Run(runNumber)
}
func calculateOrdering(levels []level, runes []rune) Ordering {
var curDir Direction
prevDir := Neutral
prevI := 0
o := Ordering{}
// lvl = 0,2,4,...: left to right
// lvl = 1,3,5,...: right to left
for i, lvl := range levels {
if lvl%2 == 0 {
curDir = LeftToRight
} else {
curDir = RightToLeft
}
if curDir != prevDir {
if i > 0 {
o.runes = append(o.runes, runes[prevI:i])
o.directions = append(o.directions, prevDir)
o.startpos = append(o.startpos, prevI)
}
prevI = i
prevDir = curDir
}
}
o.runes = append(o.runes, runes[prevI:])
o.directions = append(o.directions, prevDir)
o.startpos = append(o.startpos, prevI)
return o
} }
// Order computes the visual ordering of all the runs in a Paragraph. // Order computes the visual ordering of all the runs in a Paragraph.
func (p *Paragraph) Order() (Ordering, error) { func (p *Paragraph) Order() (Ordering, error) {
panic("unimplemented") if len(p.types) == 0 {
return Ordering{}, nil
}
for _, fn := range p.opts {
fn(&p.options)
}
lvl := level(-1)
if p.options.defaultDirection == RightToLeft {
lvl = 1
}
para, err := newParagraph(p.types, p.pairTypes, p.pairValues, lvl)
if err != nil {
return Ordering{}, err
}
levels := para.getLevels([]int{len(p.types)})
p.o = calculateOrdering(levels, p.runes)
return p.o, nil
} }
// Line computes the visual ordering of runs for a single line starting and // Line computes the visual ordering of runs for a single line starting and
// ending at the given positions in the original text. // ending at the given positions in the original text.
func (p *Paragraph) Line(start, end int) (Ordering, error) { func (p *Paragraph) Line(start, end int) (Ordering, error) {
panic("unimplemented") lineTypes := p.types[start:end]
para, err := newParagraph(lineTypes, p.pairTypes[start:end], p.pairValues[start:end], -1)
if err != nil {
return Ordering{}, err
}
levels := para.getLevels([]int{len(lineTypes)})
o := calculateOrdering(levels, p.runes[start:end])
return o, nil
} }
// An Ordering holds the computed visual order of runs of a Paragraph. Calling // An Ordering holds the computed visual order of runs of a Paragraph. Calling
// SetBytes or SetString on the originating Paragraph invalidates an Ordering. // SetBytes or SetString on the originating Paragraph invalidates an Ordering.
// The methods of an Ordering should only be called by one goroutine at a time. // The methods of an Ordering should only be called by one goroutine at a time.
type Ordering struct{} type Ordering struct {
runes [][]rune
directions []Direction
startpos []int
}
// Direction reports the directionality of the runs. // Direction reports the directionality of the runs.
// //
// The direction may be LeftToRight, RightToLeft, Mixed, or Neutral. // The direction may be LeftToRight, RightToLeft, Mixed, or Neutral.
func (o *Ordering) Direction() Direction { func (o *Ordering) Direction() Direction {
panic("unimplemented") return o.directions[0]
} }
// NumRuns returns the number of runs. // NumRuns returns the number of runs.
func (o *Ordering) NumRuns() int { func (o *Ordering) NumRuns() int {
panic("unimplemented") return len(o.runes)
} }
// Run returns the ith run within the ordering. // Run returns the ith run within the ordering.
func (o *Ordering) Run(i int) Run { func (o *Ordering) Run(i int) Run {
panic("unimplemented") r := Run{
runes: o.runes[i],
direction: o.directions[i],
startpos: o.startpos[i],
}
return r
} }
// TODO: perhaps with options. // TODO: perhaps with options.
@ -155,16 +286,19 @@ func (o *Ordering) Run(i int) Run {
// A Run is a continuous sequence of characters of a single direction. // A Run is a continuous sequence of characters of a single direction.
type Run struct { type Run struct {
runes []rune
direction Direction
startpos int
} }
// String returns the text of the run in its original order. // String returns the text of the run in its original order.
func (r *Run) String() string { func (r *Run) String() string {
panic("unimplemented") return string(r.runes)
} }
// Bytes returns the text of the run in its original order. // Bytes returns the text of the run in its original order.
func (r *Run) Bytes() []byte { func (r *Run) Bytes() []byte {
panic("unimplemented") return []byte(r.String())
} }
// TODO: methods for // TODO: methods for
@ -174,25 +308,52 @@ func (r *Run) Bytes() []byte {
// Direction reports the direction of the run. // Direction reports the direction of the run.
func (r *Run) Direction() Direction { func (r *Run) Direction() Direction {
panic("unimplemented") return r.direction
} }
// Position of the Run within the text passed to SetBytes or SetString of the // Pos returns the position of the Run within the text passed to SetBytes or SetString of the
// originating Paragraph value. // originating Paragraph value.
func (r *Run) Pos() (start, end int) { func (r *Run) Pos() (start, end int) {
panic("unimplemented") return r.startpos, r.startpos + len(r.runes) - 1
} }
// AppendReverse reverses the order of characters of in, appends them to out, // AppendReverse reverses the order of characters of in, appends them to out,
// and returns the result. Modifiers will still follow the runes they modify. // and returns the result. Modifiers will still follow the runes they modify.
// Brackets are replaced with their counterparts. // Brackets are replaced with their counterparts.
func AppendReverse(out, in []byte) []byte { func AppendReverse(out, in []byte) []byte {
panic("unimplemented") ret := make([]byte, len(in)+len(out))
copy(ret, out)
inRunes := bytes.Runes(in)
for i, r := range inRunes {
prop, _ := LookupRune(r)
if prop.IsBracket() {
inRunes[i] = prop.reverseBracket(r)
}
}
for i, j := 0, len(inRunes)-1; i < j; i, j = i+1, j-1 {
inRunes[i], inRunes[j] = inRunes[j], inRunes[i]
}
copy(ret[len(out):], string(inRunes))
return ret
} }
// ReverseString reverses the order of characters in s and returns a new string. // ReverseString reverses the order of characters in s and returns a new string.
// Modifiers will still follow the runes they modify. Brackets are replaced with // Modifiers will still follow the runes they modify. Brackets are replaced with
// their counterparts. // their counterparts.
func ReverseString(s string) string { func ReverseString(s string) string {
panic("unimplemented") input := []rune(s)
li := len(input)
ret := make([]rune, li)
for i, r := range input {
prop, _ := LookupRune(r)
if prop.IsBracket() {
ret[li-i-1] = prop.reverseBracket(r)
} else {
ret[li-i-1] = r
}
}
return string(ret)
} }

View File

@ -4,7 +4,10 @@
package bidi package bidi
import "log" import (
"fmt"
"log"
)
// This implementation is a port based on the reference implementation found at: // This implementation is a port based on the reference implementation found at:
// https://www.unicode.org/Public/PROGRAMS/BidiReferenceJava/ // https://www.unicode.org/Public/PROGRAMS/BidiReferenceJava/
@ -97,13 +100,20 @@ type paragraph struct {
// rune (suggested is the rune of the open bracket for opening and matching // rune (suggested is the rune of the open bracket for opening and matching
// close brackets, after normalization). The embedding levels are optional, but // close brackets, after normalization). The embedding levels are optional, but
// may be supplied to encode embedding levels of styled text. // may be supplied to encode embedding levels of styled text.
// func newParagraph(types []Class, pairTypes []bracketType, pairValues []rune, levels level) (*paragraph, error) {
// TODO: return an error. var err error
func newParagraph(types []Class, pairTypes []bracketType, pairValues []rune, levels level) *paragraph { if err = validateTypes(types); err != nil {
validateTypes(types) return nil, err
validatePbTypes(pairTypes) }
validatePbValues(pairValues, pairTypes) if err = validatePbTypes(pairTypes); err != nil {
validateParagraphEmbeddingLevel(levels) return nil, err
}
if err = validatePbValues(pairValues, pairTypes); err != nil {
return nil, err
}
if err = validateParagraphEmbeddingLevel(levels); err != nil {
return nil, err
}
p := &paragraph{ p := &paragraph{
initialTypes: append([]Class(nil), types...), initialTypes: append([]Class(nil), types...),
@ -115,7 +125,7 @@ func newParagraph(types []Class, pairTypes []bracketType, pairValues []rune, lev
resultTypes: append([]Class(nil), types...), resultTypes: append([]Class(nil), types...),
} }
p.run() p.run()
return p return p, nil
} }
func (p *paragraph) Len() int { return len(p.initialTypes) } func (p *paragraph) Len() int { return len(p.initialTypes) }
@ -1001,58 +1011,61 @@ func typeForLevel(level level) Class {
return R return R
} }
// TODO: change validation to not panic func validateTypes(types []Class) error {
func validateTypes(types []Class) {
if len(types) == 0 { if len(types) == 0 {
log.Panic("types is null") return fmt.Errorf("types is null")
} }
for i, t := range types[:len(types)-1] { for i, t := range types[:len(types)-1] {
if t == B { if t == B {
log.Panicf("B type before end of paragraph at index: %d", i) return fmt.Errorf("B type before end of paragraph at index: %d", i)
} }
} }
return nil
} }
func validateParagraphEmbeddingLevel(embeddingLevel level) { func validateParagraphEmbeddingLevel(embeddingLevel level) error {
if embeddingLevel != implicitLevel && if embeddingLevel != implicitLevel &&
embeddingLevel != 0 && embeddingLevel != 0 &&
embeddingLevel != 1 { embeddingLevel != 1 {
log.Panicf("illegal paragraph embedding level: %d", embeddingLevel) return fmt.Errorf("illegal paragraph embedding level: %d", embeddingLevel)
} }
return nil
} }
func validateLineBreaks(linebreaks []int, textLength int) { func validateLineBreaks(linebreaks []int, textLength int) error {
prev := 0 prev := 0
for i, next := range linebreaks { for i, next := range linebreaks {
if next <= prev { if next <= prev {
log.Panicf("bad linebreak: %d at index: %d", next, i) return fmt.Errorf("bad linebreak: %d at index: %d", next, i)
} }
prev = next prev = next
} }
if prev != textLength { if prev != textLength {
log.Panicf("last linebreak was %d, want %d", prev, textLength) return fmt.Errorf("last linebreak was %d, want %d", prev, textLength)
} }
return nil
} }
func validatePbTypes(pairTypes []bracketType) { func validatePbTypes(pairTypes []bracketType) error {
if len(pairTypes) == 0 { if len(pairTypes) == 0 {
log.Panic("pairTypes is null") return fmt.Errorf("pairTypes is null")
} }
for i, pt := range pairTypes { for i, pt := range pairTypes {
switch pt { switch pt {
case bpNone, bpOpen, bpClose: case bpNone, bpOpen, bpClose:
default: default:
log.Panicf("illegal pairType value at %d: %v", i, pairTypes[i]) return fmt.Errorf("illegal pairType value at %d: %v", i, pairTypes[i])
} }
} }
return nil
} }
func validatePbValues(pairValues []rune, pairTypes []bracketType) { func validatePbValues(pairValues []rune, pairTypes []bracketType) error {
if pairValues == nil { if pairValues == nil {
log.Panic("pairValues is null") return fmt.Errorf("pairValues is null")
} }
if len(pairTypes) != len(pairValues) { if len(pairTypes) != len(pairValues) {
log.Panic("pairTypes is different length from pairValues") return fmt.Errorf("pairTypes is different length from pairValues")
} }
return nil
} }

11
vendor/modules.txt vendored
View File

@ -114,7 +114,7 @@ github.com/valyala/fasttemplate
golang.org/x/crypto/acme golang.org/x/crypto/acme
golang.org/x/crypto/acme/autocert golang.org/x/crypto/acme/autocert
golang.org/x/crypto/ssh/terminal golang.org/x/crypto/ssh/terminal
# golang.org/x/net v0.0.0-20201224014010-6772e930b67b # golang.org/x/net v0.0.0-20210119194325-5f4716e94777
## explicit ## explicit
golang.org/x/net/html golang.org/x/net/html
golang.org/x/net/html/atom golang.org/x/net/html/atom
@ -126,7 +126,7 @@ golang.org/x/net/http2/hpack
golang.org/x/net/idna golang.org/x/net/idna
# golang.org/x/sync v0.0.0-20201207232520-09787c993a3a # golang.org/x/sync v0.0.0-20201207232520-09787c993a3a
## explicit ## explicit
# golang.org/x/sys v0.0.0-20201223074533-0d417f636930 # golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c
## explicit ## explicit
golang.org/x/sys/internal/unsafeheader golang.org/x/sys/internal/unsafeheader
golang.org/x/sys/plan9 golang.org/x/sys/plan9
@ -135,7 +135,7 @@ golang.org/x/sys/windows
# golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf # golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf
## explicit ## explicit
golang.org/x/term golang.org/x/term
# golang.org/x/text v0.3.4 # golang.org/x/text v0.3.5
## explicit ## explicit
golang.org/x/text/encoding golang.org/x/text/encoding
golang.org/x/text/encoding/charmap golang.org/x/text/encoding/charmap
@ -172,9 +172,10 @@ gopkg.in/ini.v1
## explicit ## explicit
# gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 # gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
## explicit ## explicit
# xorm.io/builder v0.3.7 # xorm.io/builder v0.3.8
## explicit
xorm.io/builder xorm.io/builder
# xorm.io/xorm v1.0.5 # xorm.io/xorm v1.0.7
## explicit ## explicit
xorm.io/xorm xorm.io/xorm
xorm.io/xorm/caches xorm.io/xorm/caches

2
vendor/xorm.io/builder/cond_in.go generated vendored
View File

@ -23,7 +23,7 @@ func In(col string, values ...interface{}) Cond {
} }
func (condIn condIn) handleBlank(w Writer) error { func (condIn condIn) handleBlank(w Writer) error {
_, err := fmt.Fprint(w, "0=1") _, err := fmt.Fprintf(w, "%s IN ()", condIn.col)
return err return err
} }

View File

@ -20,7 +20,7 @@ func NotIn(col string, values ...interface{}) Cond {
} }
func (condNotIn condNotIn) handleBlank(w Writer) error { func (condNotIn condNotIn) handleBlank(w Writer) error {
_, err := fmt.Fprint(w, "0=0") _, err := fmt.Fprintf(w, "%s NOT IN ()", condNotIn.col)
return err return err
} }

3
vendor/xorm.io/builder/sql.go generated vendored
View File

@ -59,6 +59,9 @@ func ToBoundSQL(cond interface{}) (string, error) {
} }
func noSQLQuoteNeeded(a interface{}) bool { func noSQLQuoteNeeded(a interface{}) bool {
if a == nil {
return false
}
switch a.(type) { switch a.(type) {
case int, int8, int16, int32, int64: case int, int8, int16, int32, int64:
return true return true

21
vendor/xorm.io/xorm/CHANGELOG.md generated vendored
View File

@ -3,6 +3,27 @@
This changelog goes through all the changes that have been made in each release This changelog goes through all the changes that have been made in each release
without substantial changes to our git log. without substantial changes to our git log.
## [1.0.7](https://gitea.com/xorm/xorm/pulls?q=&type=all&state=closed&milestone=1336) - 2021-01-21
* BUGFIXES
* Fix bug for mssql (#1854)
* MISC
* fix_bugs_for_mssql (#1852)
## [1.0.6](https://gitea.com/xorm/xorm/pulls?q=&type=all&state=closed&milestone=1308) - 2021-01-05
* BUGFIXES
* Fix bug when modify column on mssql (#1849)
* Fix find and count bug with cols (#1826)
* Fix update bug (#1823)
* Fix json tag with other type (#1822)
* ENHANCEMENTS
* prevent panic when struct with unexport field (#1839)
* Automatically convert datetime to int64 (#1715)
* MISC
* Fix index (#1841)
* Performance improvement for columnsbyName (#1788)
## [1.0.5](https://gitea.com/xorm/xorm/pulls?q=&type=all&state=closed&milestone=1299) - 2020-09-08 ## [1.0.5](https://gitea.com/xorm/xorm/pulls?q=&type=all&state=closed&milestone=1299) - 2020-09-08
* BUGFIXES * BUGFIXES

View File

@ -163,7 +163,7 @@ func (db *Base) DropIndexSQL(tableName string, index *schemas.Index) string {
func (db *Base) ModifyColumnSQL(tableName string, col *schemas.Column) string { func (db *Base) ModifyColumnSQL(tableName string, col *schemas.Column) string {
s, _ := ColumnString(db.dialect, col, false) s, _ := ColumnString(db.dialect, col, false)
return fmt.Sprintf("alter table %s MODIFY COLUMN %s", tableName, s) return fmt.Sprintf("ALTER TABLE %s MODIFY COLUMN %s", tableName, s)
} }
func (b *Base) ForUpdateSQL(query string) string { func (b *Base) ForUpdateSQL(query string) string {

View File

@ -220,6 +220,8 @@ type mssql struct {
func (db *mssql) Init(uri *URI) error { func (db *mssql) Init(uri *URI) error {
db.quoter = mssqlQuoter db.quoter = mssqlQuoter
db.defaultChar = "CHAR"
db.defaultVarchar = "VARCHAR"
return db.Base.Init(db, uri) return db.Base.Init(db, uri)
} }
@ -368,6 +370,11 @@ func (db *mssql) DropTableSQL(tableName string) (string, bool) {
"DROP TABLE \"%s\"", tableName, tableName), true "DROP TABLE \"%s\"", tableName, tableName), true
} }
func (db *mssql) ModifyColumnSQL(tableName string, col *schemas.Column) string {
s, _ := ColumnString(db.dialect, col, false)
return fmt.Sprintf("ALTER TABLE %s ALTER COLUMN %s", tableName, s)
}
func (db *mssql) IndexCheckSQL(tableName, idxName string) (string, []interface{}) { func (db *mssql) IndexCheckSQL(tableName, idxName string) (string, []interface{}) {
args := []interface{}{idxName} args := []interface{}{idxName}
sql := "select name from sysindexes where id=object_id('" + tableName + "') and name=?" sql := "select name from sysindexes where id=object_id('" + tableName + "') and name=?"
@ -533,7 +540,7 @@ WHERE IXS.TYPE_DESC='NONCLUSTERED' and OBJECT_NAME(IXS.OBJECT_ID) =?
colName = strings.Trim(colName, "` ") colName = strings.Trim(colName, "` ")
var isRegular bool var isRegular bool
if strings.HasPrefix(indexName, "IDX_"+tableName) || strings.HasPrefix(indexName, "UQE_"+tableName) { if (strings.HasPrefix(indexName, "IDX_"+tableName) || strings.HasPrefix(indexName, "UQE_"+tableName)) && len(indexName) > (5+len(tableName)) {
indexName = indexName[5+len(tableName):] indexName = indexName[5+len(tableName):]
isRegular = true isRegular = true
} }

View File

@ -483,7 +483,7 @@ func (db *sqlite3) GetIndexes(queryer core.Queryer, ctx context.Context, tableNa
continue continue
} }
indexName := strings.Trim(sql[nNStart+6:nNEnd], "` []'\"") indexName := strings.Trim(strings.TrimSpace(sql[nNStart+6:nNEnd]), "`[]'\"")
var isRegular bool var isRegular bool
if strings.HasPrefix(indexName, "IDX_"+tableName) || strings.HasPrefix(indexName, "UQE_"+tableName) { if strings.HasPrefix(indexName, "IDX_"+tableName) || strings.HasPrefix(indexName, "UQE_"+tableName) {
index.Name = indexName[5+len(tableName):] index.Name = indexName[5+len(tableName):]

21
vendor/xorm.io/xorm/engine.go generated vendored
View File

@ -61,6 +61,10 @@ func NewEngine(driverName string, dataSourceName string) (*Engine, error) {
return nil, err return nil, err
} }
return newEngine(driverName, dataSourceName, dialect, db)
}
func newEngine(driverName, dataSourceName string, dialect dialects.Dialect, db *core.DB) (*Engine, error) {
cacherMgr := caches.NewManager() cacherMgr := caches.NewManager()
mapper := names.NewCacheMapper(new(names.SnakeMapper)) mapper := names.NewCacheMapper(new(names.SnakeMapper))
tagParser := tags.NewParser("xorm", dialect, mapper, mapper, cacherMgr) tagParser := tags.NewParser("xorm", dialect, mapper, mapper, cacherMgr)
@ -88,7 +92,7 @@ func NewEngine(driverName string, dataSourceName string) (*Engine, error) {
engine.SetLogger(log.NewLoggerAdapter(logger)) engine.SetLogger(log.NewLoggerAdapter(logger))
runtime.SetFinalizer(engine, func(engine *Engine) { runtime.SetFinalizer(engine, func(engine *Engine) {
engine.Close() _ = engine.Close()
}) })
return engine, nil return engine, nil
@ -101,6 +105,14 @@ func NewEngineWithParams(driverName string, dataSourceName string, params map[st
return engine, err return engine, err
} }
// NewEngineWithDialectAndDB new a db manager according to the parameter.
// If you do not want to use your own dialect or db, please use NewEngine.
// For creating dialect, you can call dialects.OpenDialect. And, for creating db,
// you can call core.Open or core.FromDB.
func NewEngineWithDialectAndDB(driverName, dataSourceName string, dialect dialects.Dialect, db *core.DB) (*Engine, error) {
return newEngine(driverName, dataSourceName, dialect, db)
}
// EnableSessionID if enable session id // EnableSessionID if enable session id
func (engine *Engine) EnableSessionID(enable bool) { func (engine *Engine) EnableSessionID(enable bool) {
engine.logSessionID = enable engine.logSessionID = enable
@ -347,13 +359,16 @@ func (engine *Engine) loadTableInfo(table *schemas.Table) error {
var seq int var seq int
for _, index := range indexes { for _, index := range indexes {
for _, name := range index.Cols { for _, name := range index.Cols {
parts := strings.Split(name, " ") parts := strings.Split(strings.TrimSpace(name), " ")
if len(parts) > 1 { if len(parts) > 1 {
if parts[1] == "DESC" { if parts[1] == "DESC" {
seq = 1 seq = 1
} else if parts[1] == "ASC" {
seq = 0
} }
} }
if col := table.GetColumn(parts[0]); col != nil { var colName = strings.Trim(parts[0], `"`)
if col := table.GetColumn(colName); col != nil {
col.Indexes[index.Name] = index.Type col.Indexes[index.Name] = index.Type
} else { } else {
return fmt.Errorf("Unknown col %s seq %d, in index %v of table %v, columns %v", name, seq, index.Name, table.Name, table.ColumnsSeq()) return fmt.Errorf("Unknown col %s seq %d, in index %v of table %v, columns %v", name, seq, index.Name, table.Name, table.ColumnsSeq())

View File

@ -704,7 +704,7 @@ func (statement *Statement) buildConds2(table *schemas.Table, bean interface{},
col.SQLType.IsBlob() || col.SQLType.Name == schemas.TimeStampz) { col.SQLType.IsBlob() || col.SQLType.Name == schemas.TimeStampz) {
continue continue
} }
if col.SQLType.IsJson() { if col.IsJSON {
continue continue
} }
@ -813,7 +813,7 @@ func (statement *Statement) buildConds2(table *schemas.Table, bean interface{},
continue continue
} }
} else { } else {
if col.SQLType.IsJson() { if col.IsJSON {
if col.SQLType.IsText() { if col.SQLType.IsText() {
bytes, err := json.DefaultJSONHandler.Marshal(fieldValue.Interface()) bytes, err := json.DefaultJSONHandler.Marshal(fieldValue.Interface())
if err != nil { if err != nil {

View File

@ -204,7 +204,7 @@ func (statement *Statement) BuildUpdates(tableValue reflect.Value,
continue continue
} }
} else { } else {
if !col.SQLType.IsJson() { if !col.IsJSON {
table, err := statement.tagParser.ParseWithCache(fieldValue) table, err := statement.tagParser.ParseWithCache(fieldValue)
if err != nil { if err != nil {
val = fieldValue.Interface() val = fieldValue.Interface()

View File

@ -86,7 +86,7 @@ func (statement *Statement) Value2Interface(col *schemas.Column, fieldValue refl
return t.Float64, nil return t.Float64, nil
} }
if !col.SQLType.IsJson() { if !col.IsJSON {
// !<winxxp>! 增加支持driver.Valuer接口的结构如sql.NullString // !<winxxp>! 增加支持driver.Valuer接口的结构如sql.NullString
if v, ok := fieldValue.Interface().(driver.Valuer); ok { if v, ok := fieldValue.Interface().(driver.Valuer); ok {
return v.Value() return v.Value()

View File

@ -51,6 +51,7 @@ type Column struct {
func NewColumn(name, fieldName string, sqlType SQLType, len1, len2 int, nullable bool) *Column { func NewColumn(name, fieldName string, sqlType SQLType, len1, len2 int, nullable bool) *Column {
return &Column{ return &Column{
Name: name, Name: name,
IsJSON: sqlType.IsJson(),
TableName: "", TableName: "",
FieldName: fieldName, FieldName: fieldName,
SQLType: sqlType, SQLType: sqlType,

View File

@ -58,12 +58,7 @@ func (table *Table) ColumnsSeq() []string {
} }
func (table *Table) columnsByName(name string) []*Column { func (table *Table) columnsByName(name string) []*Column {
for k, cols := range table.columnsMap { return table.columnsMap[strings.ToLower(name)]
if strings.EqualFold(k, name) {
return cols
}
}
return nil
} }
// GetColumn returns column according column name, if column not found, return nil // GetColumn returns column according column name, if column not found, return nil

View File

@ -68,6 +68,10 @@ func (s *SQLType) IsJson() bool {
return s.Name == Json || s.Name == Jsonb return s.Name == Json || s.Name == Jsonb
} }
func (s *SQLType) IsXML() bool {
return s.Name == XML
}
var ( var (
Bit = "BIT" Bit = "BIT"
TinyInt = "TINYINT" TinyInt = "TINYINT"
@ -128,6 +132,7 @@ var (
Json = "JSON" Json = "JSON"
Jsonb = "JSONB" Jsonb = "JSONB"
XML = "XML"
Array = "ARRAY" Array = "ARRAY"
SqlTypes = map[string]int{ SqlTypes = map[string]int{
@ -144,6 +149,8 @@ var (
Json: TEXT_TYPE, Json: TEXT_TYPE,
Jsonb: TEXT_TYPE, Jsonb: TEXT_TYPE,
XML: TEXT_TYPE,
Char: TEXT_TYPE, Char: TEXT_TYPE,
NChar: TEXT_TYPE, NChar: TEXT_TYPE,
Varchar: TEXT_TYPE, Varchar: TEXT_TYPE,

4
vendor/xorm.io/xorm/session.go generated vendored
View File

@ -503,7 +503,7 @@ func (session *Session) slice2Bean(scanResults []interface{}, fields []string, b
fieldType := fieldValue.Type() fieldType := fieldValue.Type()
hasAssigned := false hasAssigned := false
if col.SQLType.IsJson() { if col.IsJSON {
var bs []byte var bs []byte
if rawValueType.Kind() == reflect.String { if rawValueType.Kind() == reflect.String {
bs = []byte(vv.String()) bs = []byte(vv.String())
@ -683,7 +683,7 @@ func (session *Session) slice2Bean(scanResults []interface{}, fields []string, b
session.engine.logger.Errorf("sql.Sanner error: %v", err) session.engine.logger.Errorf("sql.Sanner error: %v", err)
hasAssigned = false hasAssigned = false
} }
} else if col.SQLType.IsJson() { } else if col.IsJSON {
if rawValueType.Kind() == reflect.String { if rawValueType.Kind() == reflect.String {
hasAssigned = true hasAssigned = true
x := reflect.New(fieldType) x := reflect.New(fieldType)

View File

@ -168,7 +168,29 @@ func (session *Session) bytes2Value(col *schemas.Column, fieldValue *reflect.Val
} else if strings.EqualFold(sdata, "false") { } else if strings.EqualFold(sdata, "false") {
x = 0 x = 0
} else { } else {
x, err = strconv.ParseInt(sdata, 10, 64) if col.SQLType.Name == schemas.DateTime {
if len(sdata) == 20 {
t, err := time.Parse("2006-01-02T15:04:05Z", sdata)
if err != nil {
return fmt.Errorf("arg %v as int: %s", key, err.Error())
}
x = t.Unix()
} else if len(sdata) == 19 {
var parseFormat = "2006-01-02 15:04:05"
if sdata[10] == 'T' {
parseFormat = "2006-01-02T15:04:05"
}
t, err := time.Parse(parseFormat, sdata)
if err != nil {
return fmt.Errorf("arg %v as int: %s", key, err.Error())
}
x = t.Unix()
} else {
x, err = strconv.ParseInt(sdata, 10, 64)
}
} else {
x, err = strconv.ParseInt(sdata, 10, 64)
}
} }
if err != nil { if err != nil {
return fmt.Errorf("arg %v as int: %s", key, err.Error()) return fmt.Errorf("arg %v as int: %s", key, err.Error())

View File

@ -57,6 +57,9 @@ func (session *Session) FindAndCount(rowsSlicePtr interface{}, condiBean ...inte
if session.statement.SelectStr != "" { if session.statement.SelectStr != "" {
session.statement.SelectStr = "" session.statement.SelectStr = ""
} }
if len(session.statement.ColumnMap) > 0 {
session.statement.ColumnMap = []string{}
}
if session.statement.OrderStr != "" { if session.statement.OrderStr != "" {
session.statement.OrderStr = "" session.statement.OrderStr = ""
} }

View File

@ -273,8 +273,15 @@ func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int6
k = ct.Elem().Kind() k = ct.Elem().Kind()
} }
if k == reflect.Struct { if k == reflect.Struct {
var refTable = session.statement.RefTable
if refTable == nil {
refTable, err = session.engine.TableInfo(condiBean[0])
if err != nil {
return 0, err
}
}
var err error var err error
autoCond, err = session.statement.BuildConds(session.statement.RefTable, condiBean[0], true, true, false, true, false) autoCond, err = session.statement.BuildConds(refTable, condiBean[0], true, true, false, true, false)
if err != nil { if err != nil {
return 0, err return 0, err
} }

4
vendor/xorm.io/xorm/tags/parser.go generated vendored
View File

@ -253,7 +253,7 @@ func (parser *Parser) Parse(v reflect.Value) (*schemas.Table, error) {
addIndex(indexName, table, col, indexType) addIndex(indexName, table, col, indexType)
} }
} }
} else { } else if fieldValue.CanSet() {
var sqlType schemas.SQLType var sqlType schemas.SQLType
if fieldValue.CanAddr() { if fieldValue.CanAddr() {
if _, ok := fieldValue.Addr().Interface().(convert.Conversion); ok { if _, ok := fieldValue.Addr().Interface().(convert.Conversion); ok {
@ -272,6 +272,8 @@ func (parser *Parser) Parse(v reflect.Value) (*schemas.Table, error) {
if fieldType.Kind() == reflect.Int64 && (strings.ToUpper(col.FieldName) == "ID" || strings.HasSuffix(strings.ToUpper(col.FieldName), ".ID")) { if fieldType.Kind() == reflect.Int64 && (strings.ToUpper(col.FieldName) == "ID" || strings.HasSuffix(strings.ToUpper(col.FieldName), ".ID")) {
idFieldColName = col.Name idFieldColName = col.Name
} }
} else {
continue
} }
if col.IsAutoIncrement { if col.IsAutoIncrement {
col.Nullable = false col.Nullable = false

3
vendor/xorm.io/xorm/tags/tag.go generated vendored
View File

@ -226,6 +226,9 @@ func CommentTagHandler(ctx *Context) error {
// SQLTypeTagHandler describes SQL Type tag handler // SQLTypeTagHandler describes SQL Type tag handler
func SQLTypeTagHandler(ctx *Context) error { func SQLTypeTagHandler(ctx *Context) error {
ctx.col.SQLType = schemas.SQLType{Name: ctx.tagName} ctx.col.SQLType = schemas.SQLType{Name: ctx.tagName}
if strings.EqualFold(ctx.tagName, "JSON") {
ctx.col.IsJSON = true
}
if len(ctx.params) > 0 { if len(ctx.params) > 0 {
if ctx.tagName == schemas.Enum { if ctx.tagName == schemas.Enum {
ctx.col.EnumOptions = make(map[string]int) ctx.col.EnumOptions = make(map[string]int)