host linux now use godefs.

tags/1.0.0^2
Shirou WAKAYAMA 11 years ago
parent 64f1a93c00
commit cfb473f810

@ -91,10 +91,10 @@ func Users() ([]UserStat, error) {
continue
}
user := UserStat{
User: common.ByteToString(u.UtUser[:]),
Terminal: common.ByteToString(u.UtLine[:]),
Host: common.ByteToString(u.UtHost[:]),
Started: int(u.UtTv.TvSec),
User: common.IntToString(u.User[:]),
Terminal: common.IntToString(u.Line[:]),
Host: common.IntToString(u.Host[:]),
Started: int(u.Tv.TvSec),
}
ret = append(ret, user)
}

@ -1,27 +1,42 @@
// +build linux
// +build amd64
// Created by cgo -godefs - DO NOT EDIT
// cgo -godefs types_linux.go
package host
type exitStatus struct {
Etermination int16 // Process termination status.
Eexit int16 // Process exit status.
}
type timeval struct {
TvSec uint32 // Seconds.
TvUsec uint32 // Microseconds.
}
const (
sizeofPtr = 0x8
sizeofShort = 0x2
sizeofInt = 0x4
sizeofLong = 0x8
sizeofLongLong = 0x8
)
type (
_C_short int16
_C_int int32
_C_long int64
_C_long_long int64
)
type utmp struct {
UtType int16 // Type of login.
UtPid int32 // Process ID of login process.
UtLine [32]byte // Devicename.
UtID [4]byte // Inittab ID.
UtUser [32]byte // Username.
UtHost [256]byte // Hostname for remote login.
UtExit exitStatus // Exit status of a process marked
UtSession int32 // Session ID, used for windowing.
UtTv timeval // Time entry was made.
UtAddrV6 [16]byte // Internet address of remote host.
Unused [20]byte // Reserved for future use. // original is 20
Type int16
Pad_cgo_0 [2]byte
Pid int32
Line [32]int8
Id [4]int8
User [32]int8
Host [256]int8
Exit exit_status
Session int32
Tv UtTv
Addr_v6 [4]int32
X__glibc_reserved [20]int8
}
type exit_status struct {
Termination int16
Exit int16
}
type UtTv struct {
TvSec int32
TvUsec int32
}

@ -13,15 +13,15 @@ type timeval struct {
}
type utmp struct {
UtType int16 // Type of login.
UtPid int32 // Process ID of login process.
UtLine [32]byte // Devicename.
UtID [4]byte // Inittab ID.
UtUser [32]byte // Username.
UtHost [256]byte // Hostname for remote login.
UtExit exitStatus // Exit status of a process marked
UtSession int32 // Session ID, used for windowing.
UtTv timeval // Time entry was made.
UtAddrV6 [16]byte // Internet address of remote host.
Type int16 // Type of login.
Pid int32 // Process ID of login process.
Line [32]byte // Devicename.
ID [4]byte // Inittab ID.
User [32]byte // Username.
Host [256]byte // Hostname for remote login.
Exit exitStatus // Exit status of a process marked
Session int32 // Session ID, used for windowing.
Tv timeval // Time entry was made.
AddrV6 [16]byte // Internet address of remote host.
Unused [20]byte // Reserved for future use. // original is 20
}

@ -0,0 +1,45 @@
// +build ignore
/*
Input to cgo -godefs.
*/
package host
/*
#define KERNEL
#include <sys/types.h>
#include <utmp.h>
enum {
sizeofPtr = sizeof(void*),
};
*/
import "C"
// Machine characteristics; for internal use.
const (
sizeofPtr = C.sizeofPtr
sizeofShort = C.sizeof_short
sizeofInt = C.sizeof_int
sizeofLong = C.sizeof_long
sizeofLongLong = C.sizeof_longlong
)
// Basic types
type (
_C_short C.short
_C_int C.int
_C_long C.long
_C_long_long C.longlong
)
type utmp C.struct_utmp
type exit_status C.struct_exit_status
type UtTv struct {
TvSec int32
TvUsec int32
}
Loading…
Cancel
Save