| 1 |
/**************************************************************************/ |
| 2 |
/* */ |
| 3 |
/* This file is part of Frama-C. */ |
| 4 |
/* */ |
| 5 |
/* Copyright (C) 2007-2022 */ |
| 6 |
/* CEA (Commissariat à l'énergie atomique et aux énergies */ |
| 7 |
/* alternatives) */ |
| 8 |
/* */ |
| 9 |
/* you can redistribute it and/or modify it under the terms of the GNU */ |
| 10 |
/* Lesser General Public License as published by the Free Software */ |
| 11 |
/* Foundation, version 2.1. */ |
| 12 |
/* */ |
| 13 |
/* It is distributed in the hope that it will be useful, */ |
| 14 |
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ |
| 15 |
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ |
| 16 |
/* GNU Lesser General Public License for more details. */ |
| 17 |
/* */ |
| 18 |
/* See the GNU Lesser General Public License version 2.1 */ |
| 19 |
/* for more details (enclosed in the file licenses/LGPLv2.1). */ |
| 20 |
/* */ |
| 21 |
/**************************************************************************/ |
| 22 |
|
| 23 |
// Note: this file is non-POSIX, but used by some coreutils. |
| 24 |
|
| 25 |
#ifndef __FC_UTMP |
| 26 |
#define __FC_UTMP |
| 27 |
#include "features.h" |
| 28 |
__PUSH_FC_STDLIB |
| 29 |
|
| 30 |
#include "__fc_define_pid_t.h" |
| 31 |
#include "sys/time.h" |
| 32 |
#include "stdint.h" |
| 33 |
|
| 34 |
__BEGIN_DECLS |
| 35 |
|
| 36 |
#define _PATH_UTMP "/var/run/utmp" |
| 37 |
#define UTMP_FILE _PATH_UTMP |
| 38 |
#define UTMP_FILENAME _PATH_UTMP |
| 39 |
#define _PATH_WTMP "/var/log/wtmp" |
| 40 |
#define WTMP_FILE _PATH_WTMP |
| 41 |
#define WTMP_FILENAME _PATH_WTMP |
| 42 |
|
| 43 |
#define UT_LINESIZE 32 |
| 44 |
#define UT_NAMESIZE 32 |
| 45 |
#define UT_HOSTSIZE 256 |
| 46 |
|
| 47 |
struct lastlog |
| 48 |
{ |
| 49 |
time_t ll_time; |
| 50 |
char ll_line[UT_LINESIZE]; |
| 51 |
char ll_host[UT_HOSTSIZE]; |
| 52 |
}; |
| 53 |
|
| 54 |
struct exit_status |
| 55 |
{ |
| 56 |
short int e_termination; |
| 57 |
short int e_exit; |
| 58 |
}; |
| 59 |
|
| 60 |
struct utmp |
| 61 |
{ |
| 62 |
short int ut_type; |
| 63 |
pid_t ut_pid; |
| 64 |
char ut_line[UT_LINESIZE]; |
| 65 |
char ut_id[4]; |
| 66 |
char ut_user[UT_NAMESIZE]; |
| 67 |
char ut_host[UT_HOSTSIZE]; |
| 68 |
struct exit_status ut_exit; |
| 69 |
long int ut_session; |
| 70 |
struct timeval ut_tv; |
| 71 |
int32_t ut_addr_v6[4]; |
| 72 |
char __glibc_reserved[20]; // used by who.c |
| 73 |
}; |
| 74 |
|
| 75 |
#define ut_name ut_user |
| 76 |
#define ut_time ut_tv.tv_sec |
| 77 |
|
| 78 |
extern int login_tty (int fd); |
| 79 |
extern void login (const struct utmp *entry); |
| 80 |
extern int logout (const char *ut_line); |
| 81 |
extern void logwtmp (const char *ut_line, const char *ut_name, |
| 82 |
const char *ut_host); |
| 83 |
|
| 84 |
extern void updwtmp (const char *wtmp_file, const struct utmp *utmp); |
| 85 |
|
| 86 |
extern int utmpname (const char *file); |
| 87 |
|
| 88 |
extern struct utmp *getutent (void); |
| 89 |
|
| 90 |
extern void setutent (void); |
| 91 |
|
| 92 |
extern void endutent (void); |
| 93 |
|
| 94 |
extern struct utmp *getutid (const struct utmp *id); |
| 95 |
|
| 96 |
extern struct utmp *getutline (const struct utmp *line); |
| 97 |
|
| 98 |
extern struct utmp *pututline (const struct utmp *utmp_ptr); |
| 99 |
|
| 100 |
extern int getutent_r (struct utmp *buffer, struct utmp **result); |
| 101 |
|
| 102 |
extern int getutid_r (const struct utmp *id, struct utmp *buffer, |
| 103 |
struct utmp **result); |
| 104 |
|
| 105 |
extern int getutline_r (const struct utmp *line, |
| 106 |
struct utmp *buffer, struct utmp **result); |
| 107 |
|
| 108 |
|
| 109 |
__END_DECLS |
| 110 |
__POP_FC_STDLIB |
| 111 |
#endif |