Renamed _kern_set_tzspecs() to _kern_set_timezone().
Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10255 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+15
-16
@@ -1,28 +1,28 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004, Jérôme Duval, [email protected].
|
* Copyright 2004, Jérôme Duval, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
|
||||||
//#define COMPILE_FOR_R5 1
|
|
||||||
|
|
||||||
#ifdef COMPILE_FOR_R5
|
#ifdef COMPILE_FOR_R5
|
||||||
void _kset_tzfilename_(const char* name, size_t length, bool unknown);
|
void _kset_tzfilename_(const char *name, size_t length, bool isGMT);
|
||||||
void _kset_tzspecs_(uint32 timezone_offset, bool dst_observed);
|
void _kset_tzspecs_(uint32 timezone_offset, bool dst_observed);
|
||||||
|
|
||||||
#define _kern_set_tzfilename _kset_tzfilename_
|
# define _kern_set_tzfilename _kset_tzfilename_
|
||||||
#define _kern_set_tzspecs _kset_tzspecs_
|
# define _kern_set_timezone _kset_tzspecs_
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#include <syscalls.h>
|
# include <syscalls.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char path[B_PATH_NAME_LENGTH];
|
char path[B_PATH_NAME_LENGTH];
|
||||||
char link[B_PATH_NAME_LENGTH];
|
char link[B_PATH_NAME_LENGTH];
|
||||||
@@ -32,7 +32,7 @@ int main(int argc, char **argv)
|
|||||||
time_t t;
|
time_t t;
|
||||||
|
|
||||||
printf("Looking for RTC settings file\n");
|
printf("Looking for RTC settings file\n");
|
||||||
if(find_directory(B_USER_SETTINGS_DIRECTORY, -1, true, path, B_PATH_NAME_LENGTH)!=B_OK) {
|
if (find_directory(B_USER_SETTINGS_DIRECTORY, -1, true, path, B_PATH_NAME_LENGTH) != B_OK) {
|
||||||
fprintf(stderr, "%s: can't find settings directory\n", argv[0]);
|
fprintf(stderr, "%s: can't find settings directory\n", argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -47,14 +47,13 @@ int main(int argc, char **argv)
|
|||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "%s: can't read RTC settings\n", argv[0]);
|
fprintf(stderr, "%s: can't read RTC settings\n", argv[0]);
|
||||||
printf("%s: No knowledge about contents of RTC\n", argv[0]);
|
printf("%s: No knowledge about contents of RTC\n", argv[0]);
|
||||||
|
|
||||||
// we don't care if not RTC settings is found, default is local
|
// we don't care if not RTC settings is found, default is local
|
||||||
//return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%s: RTC stores %s time.\n", argv[0], isGMT ? "GMT" : "local" );
|
printf("%s: RTC stores %s time.\n", argv[0], isGMT ? "GMT" : "local" );
|
||||||
|
|
||||||
if(find_directory(B_USER_SETTINGS_DIRECTORY, -1, true, path, B_PATH_NAME_LENGTH)!=B_OK) {
|
if (find_directory(B_USER_SETTINGS_DIRECTORY, -1, true, path, B_PATH_NAME_LENGTH) != B_OK) {
|
||||||
fprintf(stderr, "can't find settings directory\n");
|
fprintf(stderr, "can't find settings directory\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -64,14 +63,14 @@ int main(int argc, char **argv)
|
|||||||
printf("Looking for %s file\n", path);
|
printf("Looking for %s file\n", path);
|
||||||
if (readlink(path, link, B_PATH_NAME_LENGTH) > 0) {
|
if (readlink(path, link, B_PATH_NAME_LENGTH) > 0) {
|
||||||
printf("%s: Setting timezone to '%s'\n", argv[0], link);
|
printf("%s: Setting timezone to '%s'\n", argv[0], link);
|
||||||
|
|
||||||
_kern_set_tzfilename(link, strlen(link), isGMT);
|
_kern_set_tzfilename(link, strlen(link), isGMT);
|
||||||
|
|
||||||
tzset();
|
tzset();
|
||||||
|
|
||||||
time(&t);
|
time(&t);
|
||||||
tm = localtime(&t);
|
tm = localtime(&t);
|
||||||
_kern_set_tzspecs(tm->tm_gmtoff, tm->tm_isdst);
|
_kern_set_timezone(tm->tm_gmtoff, tm->tm_isdst);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "%s: can't read link for timezone\n", argv[0]);
|
fprintf(stderr, "%s: can't read link for timezone\n", argv[0]);
|
||||||
printf("%s: No timezone setting.\n", argv[0]);
|
printf("%s: No timezone setting.\n", argv[0]);
|
||||||
|
|||||||
Reference in New Issue
Block a user