當前位置: 首頁>>代碼示例>>Golang>>正文


Golang C.uname函數代碼示例

本文整理匯總了Golang中C.uname函數的典型用法代碼示例。如果您正苦於以下問題:Golang uname函數的具體用法?Golang uname怎麽用?Golang uname使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了uname函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: setScreen

//export setScreen
func setScreen(scale int) {
	C.uname(&C.sysInfo)
	name := C.GoString(&C.sysInfo.machine[0])

	var v float32

	switch {
	case strings.HasPrefix(name, "iPhone"):
		v = 163
	case strings.HasPrefix(name, "iPad"):
		// TODO: is there a better way to distinguish the iPad Mini?
		switch name {
		case "iPad2,5", "iPad2,6", "iPad2,7", "iPad4,4", "iPad4,5", "iPad4,6", "iPad4,7":
			v = 163 // iPad Mini
		default:
			v = 132
		}
	default:
		v = 163 // names like i386 and x86_64 are the simulator
	}

	if v == 0 {
		log.Printf("unknown machine: %s", name)
		v = 163 // emergency fallback
	}

	pixelsPerPt = v * float32(scale) / 72
	screenScale = scale
}
開發者ID:SpruceHealth,項目名稱:mobile,代碼行數:30,代碼來源:darwin_armx.go

示例2: getFromUname

func (self *SystemInfo) getFromUname() {
	var unameBuf C.struct_utsname
	C.uname(&unameBuf)

	self.Version = C.GoString(&unameBuf.release[0])
	self.VendorName = C.GoString(&unameBuf.sysname[0])
	self.Name = C.GoString(&unameBuf.sysname[0])
	self.Machine = C.GoString(&unameBuf.machine[0])
	self.Arch = C.GoString(&unameBuf.machine[0])
	self.PatchLevel = "unknown"
}
開發者ID:abimaelmartell,項目名稱:gosigar,代碼行數:11,代碼來源:sigar_unix.go

示例3: uname

// uname returns strings similar to the Unix uname command:
// sysname, nodename, release, version, machine
func uname() (string, string, string, string, string, error) {
	var name C.struct_utsname
	_, err := C.uname(&name)
	if err != nil {
		var errno syscall.Errno = err.(syscall.Errno)
		return "", "", "", "", "", fmt.Errorf("Failed to call uname: %s", errno)
	}

	return C.GoString(&name.sysname[0]), C.GoString(&name.nodename[0]),
		C.GoString(&name.release[0]), C.GoString(&name.version[0]),
		C.GoString(&name.machine[0]), nil
}
開發者ID:TechEdge01,項目名稱:cups-connector,代碼行數:14,代碼來源:cups.go

示例4: Uname

func Uname(utsname *Utsname) error {
	var cstruct C.struct_utsname
	if err := C.uname(&cstruct); err != 0 {
		return errors.New("utsname error")
	}

	// XXX: this may crash if any value is exactly 256 characters (no 0 terminator)
	utsname.Sysname = C.GoString(&cstruct.sysname[0])
	utsname.Nodename = C.GoString(&cstruct.nodename[0])
	utsname.Release = C.GoString(&cstruct.release[0])
	utsname.Version = C.GoString(&cstruct.version[0])
	utsname.Machine = C.GoString(&cstruct.machine[0])

	return nil
}
開發者ID:sjenning,項目名稱:gatt,代碼行數:15,代碼來源:xpc_darwin.go

示例5: OSRelease

func OSRelease() string {
	var utsname C.struct_utsname
	C.uname(&utsname)
	return C.GoString(&utsname.release[0])
}
開發者ID:narma,項目名稱:go-notifier,代碼行數:5,代碼來源:uname_unix.go


注:本文中的C.uname函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。