host linux now use godefs.

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

@ -6,23 +6,23 @@
package host package host
const ( const (
sizeofPtr = 0x8 sizeofPtr = 0x8
sizeofShort = 0x2 sizeofShort = 0x2
sizeofInt = 0x4 sizeofInt = 0x4
sizeofLong = 0x8 sizeofLong = 0x8
sizeofLongLong = 0x8 sizeofLongLong = 0x8
) )
type ( type (
_C_short int16 _C_short int16
_C_int int32 _C_int int32
_C_long int64 _C_long int64
_C_long_long int64 _C_long_long int64
) )
type Utmp struct { type Utmp struct {
Line [8]int8 Line [8]int8
Name [16]int8 Name [16]int8
Host [16]int8 Host [16]int8
Time int32 Time int32
} }

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

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