From: Phil Carmody <carmody@cpd.ntc.nokia.com>
To: axp-list@redhat.com
Subject: Re: Converting time (since 01-01-1970) to Epoch
Date: Wed, 19 May 1999 10:33:12 +0100 [thread overview]
Message-ID: <199905190933.KAA08264@mvagusta> (raw)
In-Reply-To: <9905190951.ZM11753@dns.rgn.it> (franco@dns.rgn.it)
>>>>> "Franco" == Franco Tassone <franco@dns.rgn.it> writes:
Franco> I have a binary file with record fixed lenght, it has been written on an SGI
Franco> box (Irix 6.2) using the following structure:
Franco> (/usr/include/rpcsvc/rusers.h)
Franco> struct rusers_utmp {
Franco> char ut_line[8]; /* tty name */
Franco> char ut_name[8]; /* user id */
Franco> char ut_host[16]; /* host name, if remote */
Franco> long ut_time; /* time on */
Franco> };
Franco> For the SGI box, sizeof(long) = 4.
Franco> So I've converted the file, rewriting all the records on an Alpha-Linux box
Franco> (kernel 2.2.7) using the following structure:
Franco> (/usr/include/rpcsvc/rusers.h)
Franco> struct ru_utmp {
Franco> char ut_line[8]; /* tty name */
Franco> char ut_name[8]; /* user id */
Franco> char ut_host[16]; /* host name, if remote */
Franco> long ut_time; /* time on */
Franco> };
Franco> For Alpha-Linux box, sizeof(long) = 8.
Franco> My conversion program does only a field's level assignments, and rewrites the
Franco> new file, due to different sizeof(long).
Franco> The resulting dates (ut_time in ru_utmp) are all garbled.
Franco> Any ideas ?
Any program which uses the above two structures will fail, because they are
the same structure, there is no conversion.
If you're running on the SGI, then you need to read structs rusers_utmp and
write
struct rusers_64out {
char ut_line[8]; /* tty name */
char ut_name[8]; /* user id */
char ut_host[16]; /* host name, if remote */
long padding; /* set to zero (the other 32 bits) */
long ut_time; /* time on (32 bits) */
};
I may have the ut_time and padding in the wrong order - I'm assuming
endianness.
If your're running on the Alpha, then you need to read
struct rusers_32in {
char ut_line[8]; /* tty name */
char ut_name[8]; /* user id */
char ut_host[16]; /* host name, if remote */
int ut_time; /* time on (32 bits) */
};
and write structs ru_utmp.
If your program doesn't work, pop up gdb, read in one record, check its
value in the input structure, check it's value in the output structure (erm
you could even use printf to help you do your debugging - blimey!) and
check it's written out to file. When you have it working for _one_ record,
then try the whole file. Learn to use the tools that come with the language
and the system.
Phil
next prev parent reply other threads:[~1999-05-19 10:12 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-05-18 12:20 Converting time (since 01-01-1970) to Epoch Franco Tassone
1999-05-18 16:13 ` Michal Jaegermann
[not found] ` <michal@ellpspace.math.ualberta.ca>
1996-12-26 4:38 ` xload Bryan W. Headley
1996-12-30 9:16 ` Troubles with X and S3 Zarmfab Software Development
1997-05-09 6:41 ` Alpha Perl POSIX bug? Zarmfab Software Development
1997-12-01 6:13 ` Printer port problem!? Bryan W. Headley
1998-01-18 23:23 ` Is it possible: 32 bit env and also Wine/Alpha jhohertz
1999-05-19 9:51 ` Converting time (since 01-01-1970) to Epoch Franco Tassone
1999-05-19 9:23 ` Dr . David Alan Gilbert
1999-05-19 9:33 ` Phil Carmody [this message]
1999-05-20 4:06 ` Huw Davies
-- strict thread matches above, loose matches on Subject: below --
1999-05-18 13:27 Paul Jakma
1999-05-18 14:16 Franco Tassone
1999-05-18 15:18 ` Phil Carmody
1999-05-19 8:57 Paul Jakma
1999-05-19 9:54 Wessels, Hans
1999-05-20 0:14 Tom King
2002-03-25 12:45 Linux 2.4.18 vs. alphas with symbios SCSI cards Heid Oliver
2002-03-25 14:56 ` Michal Jaegermann
2002-03-25 16:20 ` Mathieu MILLET
2002-03-25 16:25 ` Stephen Williams
2002-03-25 16:45 ` Mathieu MILLET
2002-03-25 19:49 ` Michal Jaegermann
2002-03-25 19:59 ` Stephen Williams
2002-03-25 20:16 ` Stephen Williams
2002-05-02 19:37 new stock symbol: HPQ Robert M. Riches Jr.
2002-05-02 19:41 ` Peter Petrakis
2002-05-02 20:46 ` dp264 disk or raid problem Mark Hansel
2002-05-02 21:22 ` Bob Lindell
2002-05-02 21:29 ` Peter Petrakis
2002-05-06 22:30 ` dp264 disk or raid problem (Solved) Mark Hansel
2002-05-07 1:32 ` Michal Jaegermann
2002-05-07 1:37 ` 'Bryce'
2002-05-07 3:29 ` Michal Jaegermann
2002-05-07 3:29 ` 'Bryce'
2002-05-07 2:13 ` Stephen Williams
2002-05-07 2:40 ` 'Bryce'
2002-05-03 21:29 2.4.18-0.26a kernel RPMS Bob Lindell
2002-05-03 22:35 ` Michal Jaegermann
2002-05-04 5:50 ` Bob Lindell
2002-05-03 23:25 ` Michal Jaegermann
2002-05-04 5:53 ` Bob Lindell
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox