11#!/usr/bin/env python
22
3- from cstruct import parse , getdef , typedef , MemCStruct , NATIVE_ORDER
3+ from cstruct import parse , getdef , MemCStruct , NATIVE_ORDER
44from pathlib import Path
55import argparse
66import sys
3030#define UT_LINESIZE 32
3131#define UT_NAMESIZE 32
3232#define UT_HOSTSIZE 256
33+
34+ typedef int pid_t;
35+ typedef long time_t;
3336"""
3437)
3538
36- typedef ("int" , "pid_t" )
37- typedef ("long" , "time_t" )
38-
3939
4040class ExitStatus (MemCStruct ):
41- __struct__ = """
42- short e_termination; /* Process termination status. */
43- short e_exit; /* Process exit status. */
41+ __def__ = """
42+ struct ExitStatus {
43+ short e_termination; /* Process termination status. */
44+ short e_exit; /* Process exit status. */
45+ }
4446 """
4547
4648
4749class Timeval (MemCStruct ):
48- __struct__ = """
49- int32_t tv_sec; /* Seconds. */
50- int32_t tv_usec; /* Microseconds. */
50+ __def__ = """
51+ struct {
52+ int32_t tv_sec; /* Seconds. */
53+ int32_t tv_usec; /* Microseconds. */
54+ }
5155 """
5256
5357
@@ -57,21 +61,25 @@ def str_from_c(string):
5761
5862class Utmp (MemCStruct ):
5963 __byte_order__ = NATIVE_ORDER
60- __struct__ = """
61- short ut_type; /* Type of record */
62- pid_t ut_pid; /* PID of login process */
63- char ut_line[UT_LINESIZE]; /* Device name of tty - "/dev/" */
64- char ut_id[4]; /* Terminal name suffix, or inittab(5) ID */
65- char ut_user[UT_NAMESIZE]; /* Username */
66- char ut_host[UT_HOSTSIZE]; /* Hostname for remote login, or kernel version for run-level messages */
67- struct ExitStatus ut_exit; /* Exit status of a process marked as DEAD_PROCESS; not used by Linux init (1 */
68- int32_t ut_session; /* Session ID (getsid(2)), used for windowing */
64+ __def__ = """
65+ typedef struct ExitStatus ExitStatus;
66+
6967 struct {
70- int32_t tv_sec; /* Seconds */
71- int32_t tv_usec; /* Microseconds */
72- } ut_tv; /* Time entry was made */
73- int32_t ut_addr_v6[4]; /* Internet address of remote host; IPv4 address uses just ut_addr_v6[0] */
74- char __unused[20]; /* Reserved for future use */
68+ short ut_type; /* Type of record */
69+ pid_t ut_pid; /* PID of login process */
70+ char ut_line[UT_LINESIZE]; /* Device name of tty - "/dev/" */
71+ char ut_id[4]; /* Terminal name suffix, or inittab(5) ID */
72+ char ut_user[UT_NAMESIZE]; /* Username */
73+ char ut_host[UT_HOSTSIZE]; /* Hostname for remote login, or kernel version for run-level messages */
74+ ExitStatus ut_exit; /* Exit status of a process marked as DEAD_PROCESS; not used by Linux init (1 */
75+ int32_t ut_session; /* Session ID (getsid(2)), used for windowing */
76+ struct {
77+ int32_t tv_sec; /* Seconds */
78+ int32_t tv_usec; /* Microseconds */
79+ } ut_tv; /* Time entry was made */
80+ int32_t ut_addr_v6[4]; /* Internet address of remote host; IPv4 address uses just ut_addr_v6[0] */
81+ char __unused[20]; /* Reserved for future use */
82+ }
7583 """
7684
7785 @property
0 commit comments