mirror of
https://gogs.blitter.com/RLabs/goutmp
synced 2024-08-14 19:26:41 +00:00
hiding C struct utmpx from Go APIs
This commit is contained in:
parent
5908b012fb
commit
3c44cdbe3b
1 changed files with 16 additions and 12 deletions
28
go_login.go
28
go_login.go
|
@ -19,7 +19,7 @@ package go_login
|
|||
//
|
||||
//
|
||||
//void pututmp(struct utmpx* entry, char* name, char* host) {
|
||||
// //int32_t stat = system("echo ---- pre ----;who");
|
||||
// int32_t stat = system("echo ---- pre ----;who");
|
||||
//
|
||||
// entry->ut_type = USER_PROCESS;
|
||||
// entry->ut_pid = getpid();
|
||||
|
@ -34,7 +34,7 @@ package go_login
|
|||
// setutxent();
|
||||
// pututxline(entry);
|
||||
//
|
||||
// //stat = system("echo ---- post ----;who");
|
||||
// stat = system("echo ---- post ----;who");
|
||||
//}
|
||||
//
|
||||
//void unpututmp(struct utmpx* entry) {
|
||||
|
@ -45,7 +45,7 @@ package go_login
|
|||
// setutxent();
|
||||
// pututxline(entry);
|
||||
//
|
||||
// //int32_t stat = system("echo ---- cleanup ----;who; lastlog");
|
||||
// int32_t stat = system("echo ---- cleanup ----;who; lastlog");
|
||||
//
|
||||
// endutxent();
|
||||
//}
|
||||
|
@ -61,7 +61,7 @@ package go_login
|
|||
// l.ll_host[UT_HOSTSIZE-1] = '\0';
|
||||
//
|
||||
// l.ll_time = (time_t)t;
|
||||
// //printf("l: ll_line '%s', ll_host '%s', ll_time %d\n", l.ll_line, l.ll_host, l.ll_time);
|
||||
// printf("l: ll_line '%s', ll_host '%s', ll_time %d\n", l.ll_line, l.ll_host, l.ll_time);
|
||||
//
|
||||
// /* Write lastlog entry at fixed offset (uid * sizeof(struct lastlog) */
|
||||
// if( NULL != (f = fopen("/var/log/lastlog", "rw+")) ) {
|
||||
|
@ -69,7 +69,7 @@ package go_login
|
|||
// int fd = fileno(f);
|
||||
// if( write(fd, &l, sizeof(l)) == sizeof(l) ) {
|
||||
// retval = 1;
|
||||
// //int32_t stat = system("echo ---- lastlog ----; lastlog");
|
||||
// int32_t stat = system("echo ---- lastlog ----; lastlog");
|
||||
// }
|
||||
// }
|
||||
// fclose(f);
|
||||
|
@ -84,15 +84,19 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
func Put_utmp(user string, host string) (*C.struct_utmpx) {
|
||||
var entry C.struct_utmpx
|
||||
|
||||
C.pututmp(&entry, C.CString(user), C.CString(host))
|
||||
return &entry
|
||||
type UtmpEntry struct {
|
||||
entry C.struct_utmpx
|
||||
}
|
||||
|
||||
func Unput_utmp(entry *C.struct_utmpx) {
|
||||
C.unpututmp(entry)
|
||||
func Put_utmp(user string, host string) (UtmpEntry) {
|
||||
var entry UtmpEntry
|
||||
|
||||
C.pututmp(&entry.entry, C.CString(user), C.CString(host))
|
||||
return entry
|
||||
}
|
||||
|
||||
func Unput_utmp(entry UtmpEntry) {
|
||||
C.unpututmp(&entry.entry)
|
||||
}
|
||||
|
||||
func Put_lastlog_entry(app string, usr string, host string) {
|
||||
|
|
Loading…
Reference in a new issue