当前位置: 首页>>代码示例>>Golang>>正文


Golang syscall.StringBytePtr函数代码示例

本文整理汇总了Golang中syscall.StringBytePtr函数的典型用法代码示例。如果您正苦于以下问题:Golang StringBytePtr函数的具体用法?Golang StringBytePtr怎么用?Golang StringBytePtr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了StringBytePtr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: setxattr

func setxattr(path string, name string, value *byte, size int) (err error) {
	_, _, e1 := syscall.Syscall6(syscall.SYS_SETXATTR,
		uintptr(unsafe.Pointer(syscall.StringBytePtr(path))),
		uintptr(unsafe.Pointer(syscall.StringBytePtr(name))),
		uintptr(unsafe.Pointer(value)), uintptr(size), 0, 0)
	return e1
}
开发者ID:redsift,项目名称:xattr,代码行数:7,代码来源:syscall_linux.go

示例2: fight

func fight(w1 string, w2 string, rounds int) result {
	r := result{}

	f2w.Call(
		uintptr(unsafe.Pointer(syscall.StringBytePtr(w1))),
		uintptr(unsafe.Pointer(syscall.StringBytePtr(w2))),
		uintptr(currentConfig.Mars.Coresize),
		uintptr(currentConfig.Mars.Cycles),
		uintptr(currentConfig.Mars.Maxprocess),
		uintptr(rounds),
		uintptr(currentConfig.Mars.Maxwarriorlen),
		uintptr(currentConfig.Mars.FixedPos),
		uintptr(unsafe.Pointer(&r.Win)),
		uintptr(unsafe.Pointer(&r.Lose)),
		uintptr(unsafe.Pointer(&r.Equal)))

	fightMetrics++
	roundsMetrics += rounds

	if r.Equal+r.Lose+r.Win != rounds {
		return result{0, 0, 0}
	}

	return r
}
开发者ID:BigJk,项目名称:gomax,代码行数:25,代码来源:exmars.go

示例3: Removexattr

func Removexattr(path string, attr string) (errno int) {
	pathbs := syscall.StringBytePtr(path)
	attrbs := syscall.StringBytePtr(attr)
	_, _, errNo := syscall.Syscall(
		syscall.SYS_REMOVEXATTR,
		uintptr(unsafe.Pointer(pathbs)),
		uintptr(unsafe.Pointer(attrbs)), 0)
	return int(errNo)
}
开发者ID:hoffoo,项目名称:go-fuse,代码行数:9,代码来源:syscall_darwin.go

示例4: readdirnames

func (file *File) readdirnames(n int) (names []string, err error) {
	if elen == 0 {
		var dummy syscall.Dirent
		elen = (int(unsafe.Offsetof(dummy.Name)) +
			libc_pathconf(syscall.StringBytePtr(file.name), syscall.PC_NAME_MAX) +
			1)
	}

	if file.dirinfo == nil {
		file.dirinfo = new(dirInfo)
		file.dirinfo.buf = make([]byte, elen)
		p := syscall.StringBytePtr(file.name)
		syscall.Entersyscall()
		r := libc_opendir(p)
		syscall.Exitsyscall()
		file.dirinfo.dir = r
	}

	entry_dirent := (*syscall.Dirent)(unsafe.Pointer(&file.dirinfo.buf[0]))

	size := n
	if size <= 0 {
		size = 100
		n = -1
	}

	names = make([]string, 0, size) // Empty with room to grow.

	dir := file.dirinfo.dir
	if dir == nil {
		return names, NewSyscallError("opendir", syscall.GetErrno())
	}

	for n != 0 {
		var result *syscall.Dirent
		pr := &result
		syscall.Entersyscall()
		i := libc_readdir_r(dir, entry_dirent, pr)
		syscall.Exitsyscall()
		if i != 0 {
			return names, NewSyscallError("readdir_r", i)
		}
		if result == nil {
			break // EOF
		}
		var name = string(result.Name[0:clen(result.Name[0:])])
		if name == "." || name == ".." { // Useless names
			continue
		}
		names = append(names, name)
		n--
	}
	if n >= 0 && len(names) == 0 {
		return names, io.EOF
	}
	return names, nil
}
开发者ID:mm120,项目名称:gcc,代码行数:57,代码来源:dir.go

示例5: removexattr

// int removexattr(const char *path, const char *name, int options);
func removexattr(path string, name string) (e error) {
	_, _, e1 := syscall.Syscall(syscall.SYS_REMOVEXATTR,
		uintptr(unsafe.Pointer(syscall.StringBytePtr(path))),
		uintptr(unsafe.Pointer(syscall.StringBytePtr(name))),
		0)
	if e1 != noError {
		e = e1
	}
	return
}
开发者ID:AlekSi,项目名称:xattr,代码行数:11,代码来源:syscall_darwin.go

示例6: getxattr

func getxattr(path string, attr string, dest []byte) (sz int, errno int) {
	pathBs := syscall.StringBytePtr(path)
	attrBs := syscall.StringBytePtr(attr)
	size, _, errNo := syscall.Syscall6(
		syscall.SYS_GETXATTR,
		uintptr(unsafe.Pointer(pathBs)),
		uintptr(unsafe.Pointer(attrBs)),
		uintptr(unsafe.Pointer(&dest[0])),
		uintptr(len(dest)),
		0, 0)
	return int(size), int(errNo)
}
开发者ID:hoffoo,项目名称:go-fuse,代码行数:12,代码来源:syscall_darwin.go

示例7: getxattr

// ssize_t getxattr(const char *path, const char *name, void *value, size_t size, u_int32_t position, int options);
func getxattr(path string, name string, value *byte, size int) (resSize int, e error) {
	r0, _, e1 := syscall.Syscall6(syscall.SYS_GETXATTR,
		uintptr(unsafe.Pointer(syscall.StringBytePtr(path))),
		uintptr(unsafe.Pointer(syscall.StringBytePtr(name))),
		uintptr(unsafe.Pointer(value)),
		uintptr(size), 0, 0)
	resSize = int(r0)
	if e1 != noError {
		e = e1
	}
	return
}
开发者ID:AlekSi,项目名称:xattr,代码行数:13,代码来源:syscall_darwin.go

示例8: getxattr

func getxattr(path string, name string, value *byte, size int) (int, error) {
	if r0, _, e1 := syscall.Syscall6(syscall.SYS_GETXATTR,
		uintptr(unsafe.Pointer(syscall.StringBytePtr(path))),
		uintptr(unsafe.Pointer(syscall.StringBytePtr(name))),
		uintptr(unsafe.Pointer(value)), uintptr(size), 0, 0); e1 != syscall.Errno(0) {
		if e1 == syscall.ENODATA {
			return 0, e1
		}
		return -1, e1
	} else {
		return int(r0), nil
	}
}
开发者ID:redsift,项目名称:xattr,代码行数:13,代码来源:syscall_linux.go

示例9: Setxattr

func Setxattr(path string, attr string, data []byte, flags int) (errno int) {
	pathbs := syscall.StringBytePtr(path)
	attrbs := syscall.StringBytePtr(attr)
	_, _, errNo := syscall.Syscall6(
		syscall.SYS_SETXATTR,
		uintptr(unsafe.Pointer(pathbs)),
		uintptr(unsafe.Pointer(attrbs)),
		uintptr(unsafe.Pointer(&data[0])),
		uintptr(len(data)),
		uintptr(flags), 0)

	return int(errNo)
}
开发者ID:hoffoo,项目名称:go-fuse,代码行数:13,代码来源:syscall_darwin.go

示例10: Linkat

func Linkat(fd1 int, n1 string, fd2 int, n2 string) int {
	b1 := syscall.StringBytePtr(n1)
	b2 := syscall.StringBytePtr(n2)

	_, _, errNo := syscall.Syscall6(
		syscall.SYS_LINKAT,
		uintptr(fd1),
		uintptr(unsafe.Pointer(b1)),
		uintptr(fd2),
		uintptr(unsafe.Pointer(b2)),
		0, 0)
	return int(errNo)
}
开发者ID:crazy2be,项目名称:go-fuse,代码行数:13,代码来源:misc.go

示例11: main

func main() {

	if len(os.Args) != 2 {
		fmt.Printf("Usage: gogo file.go\n")
		return
	}

	var r0 uintptr
	var e1 uintptr
	var e int
	var fd uint64
	var errno uint64
	r0, _, e1 = syscall.Syscall(syscall.SYS_OPEN, uintptr(unsafe.Pointer(syscall.StringBytePtr(os.Args[1]))), 0, 0)
	e = int(e1)
	fd = uint64(r0)

	if e == 0 {
		ScannerTest(fd)
		errno = libgogo.FileClose(fd)
		if errno != 0 {
			libgogo.ExitError("Error closing file", errno)
		}
	} else {
		fmt.Printf("Error opening file %s.\n", os.Args[1])
	}
}
开发者ID:mlippautz,项目名称:gogo,代码行数:26,代码来源:2010-03-21_gogo_fail.go

示例12: WglGetProcAddress

func WglGetProcAddress(szProc string) uintptr {
	ret, _, _ := procwglGetProcAddress.Call(
		uintptr(unsafe.Pointer(syscall.StringBytePtr(szProc))),
	)

	return ret
}
开发者ID:PagerDuty,项目名称:nomad,代码行数:7,代码来源:opengl32.go

示例13: Open

// Open opens an asynchronous communications port.
func Open(name string, options ...func(*Term) error) (*Term, error) {
	fd, e := syscall.Open(name, syscall.O_NOCTTY|syscall.O_CLOEXEC|syscall.O_NDELAY|syscall.O_RDWR, 0666)
	if e != nil {
		return nil, &os.PathError{"open", name, e}
	}

	modules := [2]string{"ptem", "ldterm"}
	for _, mod := range modules {
		err := unix.IoctlSetInt(fd, C.I_PUSH, int(uintptr(unsafe.Pointer(syscall.StringBytePtr(mod)))))
		if err != nil {
			return nil, err
		}
	}

	t := Term{name: name, fd: fd}
	termios.Tcgetattr(uintptr(t.fd), &t.orig)
	if err := termios.Tcgetattr(uintptr(t.fd), &t.orig); err != nil {
		return nil, err
	}

	if err := t.SetOption(options...); err != nil {
		return nil, err
	}

	return &t, syscall.SetNonblock(t.fd, false)
}
开发者ID:pkg,项目名称:term,代码行数:27,代码来源:term_solaris.go

示例14: lookupUser

func lookupUser(username string) (*User, error) {
	var pwd syscall.Passwd
	var result *syscall.Passwd
	p := syscall.StringBytePtr(username)

	buf := alloc(userBuffer)
	defer buf.free()

	err := retryWithBuffer(buf, func() syscall.Errno {
		syscall.Entersyscall()
		rv := libc_getpwnam_r(p,
			&pwd,
			buf.ptr,
			buf.size,
			&result)
		syscall.Exitsyscall()
		if rv != 0 {
			return syscall.GetErrno()
		}
		return 0
	})
	if err != nil {
		return nil, fmt.Errorf("user: lookup username %s: %v", username, err)
	}
	if result == nil {
		return nil, UnknownUserError(username)
	}
	return buildUser(&pwd), err
}
开发者ID:kraj,项目名称:gcc,代码行数:29,代码来源:lookup_unix.go

示例15: lookupGroup

func lookupGroup(groupname string) (*Group, error) {
	var grp syscall.Group
	var result *syscall.Group

	buf := alloc(groupBuffer)
	defer buf.free()
	p := syscall.StringBytePtr(groupname)

	err := retryWithBuffer(buf, func() syscall.Errno {
		syscall.Entersyscall()
		rv := libc_getgrnam_r(p,
			&grp,
			buf.ptr,
			buf.size,
			&result)
		syscall.Exitsyscall()
		if rv != 0 {
			return syscall.GetErrno()
		}
		return 0
	})
	if err != nil {
		return nil, fmt.Errorf("user: lookup groupname %s: %v", groupname, err)
	}
	if result == nil {
		return nil, UnknownGroupError(groupname)
	}
	return buildGroup(&grp), nil
}
开发者ID:kraj,项目名称:gcc,代码行数:29,代码来源:lookup_unix.go


注:本文中的syscall.StringBytePtr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。