Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

proper unpack template for the below structure

Status
Not open for further replies.

dotBomb

Programmer
May 10, 2005
2
US
Would anyone be able to give me a valid perl 'unpack()' function template ( like $template = "s i A12 A4 A32 A256 s s l i i A20"; ), based on the following definition:

struct utmp {
short ut_type; /* type of login */
pid_t ut_pid; /* pid of login process */
char ut_line[UT_LINESIZE]; /* device name of tty âË?â?? "/dev/" */
char ut_id[4]; /* init id or abbrev. ttyname */
char ut_user[UT_NAMESIZE]; /* user name */
char ut_host[UT_HOSTSIZE]; /* hostname for remote login */
struct exit_status ut_exit; /* The exit status of a process
marked as DEAD_PROCESS. */
long ut_session; /* session ID, used for windowing*/
struct timeval ut_tv; /* time entry was made. */
int32_t ut_addr_v6[4]; /* IP address of remote host. */
char pad[20]; /* Reserved for future use. */
};

where the exit_status struct is defined as such ...

struct exit_status {
short int e_termination; /* process termination status. */
short int e_exit; /* process exit status. */
};

??

I've tried a lot of different combinations, none of which have panned out yet.

Thanks for any and all help!

dotBomb
 
without knowing those constants UT_*, I'd guessing it's nigh on impossible
--Paul


cigless ...
 
PaulTEG,

You are correct, my last post was incomplete. Here is the information you, or another member would need. Furthermore, it seems the intuitive answer is not the correct one here but at last, here is the info:



#define DEAD_PROCESS 8
#define UT_LINESIZE 12
#define UT_NAMESIZE 32
#define UT_HOSTSIZE 256

Thanks for any help,

dotBomb
 
Code:
s||S  -signed||unsigned short   ut_type
(whatever ut_pid is)            ??
c12                             ut_line
c4                              ut_id
c32                             ut_user
c256                            ut_host
  l||L -signed||unsigned long   exit_status
  s||S -signed||unsigned short  exit_status

still too many unknown types, timeval, ut_addr v6 ...

Hope this gives you a starting point at least
--Paul

cigless ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top