summaryrefslogtreecommitdiff
path: root/usr.sbin/config
diff options
context:
space:
mode:
authorDavid Leonard <d@cvs.openbsd.org>2000-01-08 23:23:38 +0000
committerDavid Leonard <d@cvs.openbsd.org>2000-01-08 23:23:38 +0000
commit4dc30ea10149bdf88cbb716fedfc6385ee8413f1 (patch)
tree9d9e8e30a982fd13167586adbf966ec3db48e1e5 /usr.sbin/config
parent044607b6cf8a6b0f7d82eab78c63098e49c31e51 (diff)
Allow UKC to change tz with 'timezone' command.
Diffstat (limited to 'usr.sbin/config')
-rw-r--r--usr.sbin/config/cmd.c38
-rw-r--r--usr.sbin/config/cmd.h3
-rw-r--r--usr.sbin/config/ukc.h7
-rw-r--r--usr.sbin/config/ukcutil.c15
4 files changed, 56 insertions, 7 deletions
diff --git a/usr.sbin/config/cmd.c b/usr.sbin/config/cmd.c
index d822f71ea51..26a1ecd4ffa 100644
--- a/usr.sbin/config/cmd.c
+++ b/usr.sbin/config/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.1 1999/10/04 20:00:50 deraadt Exp $ */
+/* $OpenBSD: cmd.c,v 1.2 2000/01/08 23:23:37 d Exp $ */
/*
* Copyright (c) 1999 Mats O Jansson. All rights reserved.
@@ -30,13 +30,15 @@
*/
#ifndef LINT
-static char rcsid[] = "$OpenBSD: cmd.c,v 1.1 1999/10/04 20:00:50 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: cmd.c,v 1.2 2000/01/08 23:23:37 d Exp $";
#endif
+#include <ctype.h>
#include <stdio.h>
#include <limits.h>
#include <nlist.h>
#include <sys/device.h>
+#include <sys/time.h>
#include "misc.h"
#define CMD_NOEXTERN
#include "cmd.h"
@@ -56,6 +58,7 @@ cmd_table_t cmd_table[] = {
{"show", Xshow, "[attr [val]]\t", "Show attribute"},
{"exit", Xexit, "\t\t", "Exit, without saving changes"},
{"quit", Xquit, "\t\t", "Quit, saving current changes"},
+ {"timezone", Xtimezone, "[mins [dst]]\t", "Show/change timezone"},
{NULL, NULL, NULL, NULL}
};
@@ -254,3 +257,34 @@ Xexit(cmd)
/* Nothing to do here */
return (CMD_EXIT);
}
+
+int
+Xtimezone(cmd)
+ cmd_t *cmd;
+{
+ int num;
+ char *c;
+ struct timezone *tz =
+ (struct timezone *)adjust((caddr_t)nl[TZ_TZ].n_value);
+
+ if (strlen(cmd->args) == 0) {
+ printf("timezone = %d, dst = %d\n",
+ tz->tz_minuteswest, tz->tz_dsttime);
+ } else {
+ if (number(cmd->args, &num) == 0) {
+ tz->tz_minuteswest = num;
+ c = cmd->args;
+ while ((*c != '\0') && !isspace(*c))
+ c++;
+ while ((*c != '\0') && isspace(*c))
+ c++;
+ if (strlen(c) != 0 && number(c, &num) == 0)
+ tz->tz_dsttime = num;
+ printf("timezone = %d, dst = %d\n",
+ tz->tz_minuteswest, tz->tz_dsttime);
+ } else
+ printf("Unknown argument\n");
+ }
+
+ return (CMD_CONT);
+}
diff --git a/usr.sbin/config/cmd.h b/usr.sbin/config/cmd.h
index b6c972a5a87..032dfca605a 100644
--- a/usr.sbin/config/cmd.h
+++ b/usr.sbin/config/cmd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.h,v 1.1 1999/10/04 20:00:50 deraadt Exp $ */
+/* $OpenBSD: cmd.h,v 1.2 2000/01/08 23:23:37 d Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -71,6 +71,7 @@ int Xlist __P((cmd_t *));
int Xshow __P((cmd_t *));
int Xexit __P((cmd_t *));
int Xquit __P((cmd_t *));
+int Xtimezone __P((cmd_t *));
#endif _CMD_H
diff --git a/usr.sbin/config/ukc.h b/usr.sbin/config/ukc.h
index a042fddcd04..58883b20f3a 100644
--- a/usr.sbin/config/ukc.h
+++ b/usr.sbin/config/ukc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ukc.h,v 1.1 1999/10/04 20:00:52 deraadt Exp $ */
+/* $OpenBSD: ukc.h,v 1.2 2000/01/08 23:23:37 d Exp $ */
/*
* Copyright (c) 1999 Mats O Jansson. All rights reserved.
@@ -46,7 +46,8 @@
#define I_UEXTRALOC 11
#define I_HISTLEN 12
#define CA_HISTORY 13
-#define NLENTRIES 14
+#define TZ_TZ 14
+#define NLENTRIES 15
#ifdef UKC_MAIN
struct nlist nl[] = {
@@ -64,6 +65,7 @@ struct nlist nl[] = {
{ "_uextraloc" },
{ "_userconf_histlen" },
{ "_userconf_history" },
+ { "_tz" },
};
struct nlist knl[] = {
{ "_locnames" },
@@ -80,6 +82,7 @@ struct nlist knl[] = {
{ "_uextraloc" },
{ "_userconf_histlen" },
{ "_userconf_history" },
+ { "_tz" },
};
int maxdev = 0;
int totdev = 0;
diff --git a/usr.sbin/config/ukcutil.c b/usr.sbin/config/ukcutil.c
index 7c730194aab..456afbe04d3 100644
--- a/usr.sbin/config/ukcutil.c
+++ b/usr.sbin/config/ukcutil.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ukcutil.c,v 1.1 1999/10/04 20:00:52 deraadt Exp $ */
+/* $OpenBSD: ukcutil.c,v 1.2 2000/01/08 23:23:37 d Exp $ */
/*
* Copyright (c) 1999 Mats O Jansson. All rights reserved.
@@ -30,10 +30,11 @@
*/
#ifndef LINT
-static char rcsid[] = "$OpenBSD: ukcutil.c,v 1.1 1999/10/04 20:00:52 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: ukcutil.c,v 1.2 2000/01/08 23:23:37 d Exp $";
#endif
#include <sys/types.h>
+#include <sys/time.h>
#include <sys/device.h>
#include <limits.h>
#include <nlist.h>
@@ -1212,6 +1213,7 @@ process_history(len,buf)
char *c;
int devno,newno;
short unit,state;
+ struct timezone *tz;
if (len == 0) {
printf("History is empty\n");
@@ -1263,6 +1265,15 @@ process_history(len,buf)
enable(devno);
while (*c != '\n') c++; c++;
break;
+ case 't':
+ c++; c++;
+ tz = (struct timezone *)adjust((caddr_t)nl[TZ_TZ].
+ n_value);
+ tz->tz_minuteswest = atoi(c);
+ while (*c != ' ') c++; c++;
+ tz->tz_dsttime = atoi(c);
+ while (*c != '\n') c++; c++;
+ break;
case 'q':
while (*c != NULL) c++;
break;