added a clockconfig bin tool
it is only tested on R5, but should make its way on Haiku too git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10178 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,9 +1,12 @@
|
|||||||
SubDir OBOS_TOP src apps bin ;
|
SubDir OBOS_TOP src apps bin ;
|
||||||
|
|
||||||
|
UsePrivateHeaders kernel ;
|
||||||
|
|
||||||
# standard commands that don't need any additional library
|
# standard commands that don't need any additional library
|
||||||
StdBinCommands
|
StdBinCommands
|
||||||
chop.c
|
chop.c
|
||||||
clear.c
|
clear.c
|
||||||
|
clockconfig.c
|
||||||
# csplit.c
|
# csplit.c
|
||||||
driveinfo.c
|
driveinfo.c
|
||||||
# echo.c
|
# echo.c
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2004, Jérôme Duval, [email protected].
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <FindDirectory.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <OS.h>
|
||||||
|
|
||||||
|
//#define COMPILE_FOR_R5 1
|
||||||
|
|
||||||
|
#ifdef COMPILE_FOR_R5
|
||||||
|
void _kset_tzfilename_(const char* name, size_t length, bool unknown);
|
||||||
|
void _kset_tzspecs_(uint32 timezone_offset, bool dst_observed);
|
||||||
|
|
||||||
|
#define _kern_set_tzfilename _kset_tzfilename_
|
||||||
|
#define _kern_set_tzspecs _kset_tzspecs_
|
||||||
|
|
||||||
|
#else
|
||||||
|
#include <syscalls.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
char path[B_PATH_NAME_LENGTH];
|
||||||
|
char link[B_PATH_NAME_LENGTH];
|
||||||
|
FILE *file;
|
||||||
|
bool isGMT = true;
|
||||||
|
struct tm* tm = NULL;
|
||||||
|
time_t t;
|
||||||
|
|
||||||
|
printf("Looking for RTC settings file\n");
|
||||||
|
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]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
strcat(path, "/RTC_time_settings");
|
||||||
|
file = fopen(path, "r");
|
||||||
|
if (file != NULL) {
|
||||||
|
char string[10];
|
||||||
|
fscanf(file, "%s", string);
|
||||||
|
if (strncmp(string, "local", 5) == 0)
|
||||||
|
isGMT = false;
|
||||||
|
fclose(file);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "%s: can't read RTC settings\n", argv[0]);
|
||||||
|
printf("%s: No knowledge about contents of RTC\n", argv[0]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
fprintf(stderr, "can't find settings directory\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
strcat(path, "/timezone");
|
||||||
|
|
||||||
|
printf("Looking for %s file\n", path);
|
||||||
|
if (readlink(path, link, B_PATH_NAME_LENGTH) > 0) {
|
||||||
|
printf("%s: Setting timezone to '%s'\n", argv[0], link);
|
||||||
|
|
||||||
|
_kern_set_tzfilename(link, strlen(link), isGMT);
|
||||||
|
|
||||||
|
tzset();
|
||||||
|
|
||||||
|
time(&t);
|
||||||
|
tm = localtime(&t);
|
||||||
|
_kern_set_tzspecs(tm->tm_gmtoff, tm->tm_isdst);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "%s: can't read link for timezone\n", argv[0]);
|
||||||
|
printf("%s: No timezone setting.\n", argv[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user