Computing.Net > Forums > Linux > need timezone value dynamically

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

need timezone value dynamically

Reply to Message Icon

Original Message
Name: Muthulakshmi
Date: April 19, 2007 at 03:56:32 Pacific
Subject: need timezone value dynamically
OS: redhat linux 8.0
CPU/Ram: i386
Model/Manufacturer: =
Comment:


Please tell me how to get the system time zone dynamically. Can I use dlopen () to get the timezone dynamically, If so, tell me how to do?

Regards,
Lakshmi



Report Offensive Message For Removal


Response Number 1
Name: akhen
Date: April 19, 2007 at 06:19:27 Pacific
Reply: (edit)

Are you trying to set your timezone dynamically, or just retrieve the timezone your computer already has?

technoguy


Report Offensive Follow Up For Removal

Response Number 2
Name: Muthulakshmi
Date: April 19, 2007 at 23:18:45 Pacific
Reply: (edit)

I am setting the time zone in linux, that change should be reflected in my application's show command. my code segment is like this

gettimezone()
{
int (*tzfile_read)(const char *, unsigned int, const char *);

while(1)
{
handle = dlopen ("libc.a", RTLD_LAZY);
tzfile_read = dlsym (handle, "tzfile_read");
if(error = dlerror())!=NULL)
(
printtf("\r\n error in openning tzfile"));
)
else
{
printf("%s", (*tzfile_read)("/etc/localtime", 0, NULL));
}
dclose(handle);
}
}
I am not getting the timezone dynamically.
Am I using dlopen(), dlsym() correctly


Report Offensive Follow Up For Removal

Response Number 3
Name: Guy
Date: April 20, 2007 at 16:37:53 Pacific
Reply: (edit)

One thing jumps out at me:

I would think the first parameter to 'dlopen' would be:

libc.so

and *not*

libc.a


Report Offensive Follow Up For Removal

Response Number 4
Name: Muthulakshmi
Date: April 23, 2007 at 21:42:55 Pacific
Reply: (edit)

great!! I could open libc.so using dlopen, I am getting the handle. but the dlsym() function says "undefined symbol __tzfile_read". my code segment is as follows. what could be the problem?

handle = dlopen ("libc.so", RTLD_LAZY);
if (!handle) {
fprintf (stderr, "%s\n", dlerror());
}
tzfile_read = dlsym (handle, "__tzfile_read");
if(error = dlerror())!=NULL)
(
fprintf (stderr, "%s\n", dlerror());
)


Report Offensive Follow Up For Removal

Response Number 5
Name: Guy
Date: May 13, 2007 at 09:13:00 Pacific
Reply: (edit)

Well, I hope you get back to this .....

libc.so is probably *really*:

/lib/libc.so.6

Knowing that, you can use:

nm --dynamic /lib/libc.so.6

to list the symbols exported by that .so (functions that can be called). On my system, I do not see what you are trying to call. Timezone stuff on my system:

gallard@oldpete:~$ nm --dynamic /lib/libc.so.6 | grep tz
0011c338 V tzname
0011c338 D __tzname
0007cfe0 W tzset


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Linux Forum Home








Do you own an iPhone?

Yes
No, but soon
No


View Results

Poll Finishes In 7 Days.
Discuss in The Lounge
Poll History




Data Recovery Software