Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/sushi Change the scripting and logging functions to...
details: https://anonhg.NetBSD.org/src/rev/c0bff4b5586c
branches: trunk
changeset: 504460:c0bff4b5586c
user: garbled <garbled%NetBSD.org@localhost>
date: Sat Mar 03 13:54:22 2001 +0000
description:
Change the scripting and logging functions to flip the value, rather than
require an on/off argument. Change the little bottom-label so the user
can see what the current value of scripting and logging is at all times.
diffstat:
usr.sbin/sushi/C.msg | 6 +++++
usr.sbin/sushi/blabel.c | 32 ++++++++++++++++++++++-----
usr.sbin/sushi/functions.c | 53 ++++++++++++++++++++++++++-------------------
3 files changed, 62 insertions(+), 29 deletions(-)
diffs (202 lines):
diff -r cd83247dae13 -r c0bff4b5586c usr.sbin/sushi/C.msg
--- a/usr.sbin/sushi/C.msg Sat Mar 03 12:56:38 2001 +0000
+++ b/usr.sbin/sushi/C.msg Sat Mar 03 13:54:22 2001 +0000
@@ -33,6 +33,10 @@
10 F10=Exit
11 </5><OK><!5>
12 Help
+13 Script:
+14 Log:
+15 ON
+16 OFF
$set 3 run.c stuff
1 executing
2 Status
@@ -59,3 +63,5 @@
7 Data Entry:
8 Form Page:
9 PGUP/PGDN to change page, UP/DOWN switch field, ENTER=Do.
+10 Log ended at
+11 Script ended at
diff -r cd83247dae13 -r c0bff4b5586c usr.sbin/sushi/blabel.c
--- a/usr.sbin/sushi/blabel.c Sat Mar 03 12:56:38 2001 +0000
+++ b/usr.sbin/sushi/blabel.c Sat Mar 03 13:54:22 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: blabel.c,v 1.8 2001/01/14 21:23:23 garbled Exp $ */
+/* $NetBSD: blabel.c,v 1.9 2001/03/03 13:54:22 garbled Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -51,16 +51,21 @@
extern char **searchpaths;
extern char *keylabel[10];
extern chtype keybinding[10];
+extern int scripting;
+extern int logging;
WINDOW *labelwin;
+#define BLABEL_WIDTH 13
+#define BLABEL_SIZE 12
+
/* if type=1, only show basic.
2 = show additional for form manipulation
*/
void
bottom_help(int type)
{
- char *label[10];
+ char *label[BLABEL_SIZE];
int i, j;
label[0] = catgets(catalog, 2, 1, "F1=Help");
@@ -73,6 +78,8 @@
label[7] = catgets(catalog, 2, 8, "F8=Image");
label[8] = catgets(catalog, 2, 9, "F9=Shell");
label[9] = catgets(catalog, 2, 10, "F10=Exit");
+ label[10]= catgets(catalog, 2, 13, "Script:");
+ label[11]= catgets(catalog, 2, 14, "Log:");
/* check for key overrides from the config file */
for (i=0; i < 10; i++)
@@ -85,17 +92,30 @@
"failed to allocate bottomhelp window"));
wattron(labelwin, A_BOLD);
- for (i=0,j=0; i < 10; i+=2, j+=17)
+ for (i=0,j=0; i < BLABEL_SIZE; i+=2, j+=BLABEL_WIDTH)
if (i < 3 || i > 6 || type == 2) {
mvwaddstr(labelwin, 0, j, label[i]);
- wrefresh(labelwin);
}
- for (i=1,j=0; i < 10; i+=2, j+=17)
+ for (i=1,j=0; i < BLABEL_SIZE; i+=2, j+=BLABEL_WIDTH)
if (i < 3 || i > 6 || type == 2) {
mvwaddstr(labelwin, 1, j, label[i]);
- wrefresh(labelwin);
}
+ if (scripting)
+ mvwaddstr(labelwin, 0, ws.ws_col-4,
+ catgets(catalog, 2, 15, "ON "));
+ else
+ mvwaddstr(labelwin, 0, ws.ws_col-4,
+ catgets(catalog, 2, 16, "OFF"));
+
+ if (logging)
+ mvwaddstr(labelwin, 1, ws.ws_col-4,
+ catgets(catalog, 2, 15, "ON "));
+ else
+ mvwaddstr(labelwin, 1, ws.ws_col-4,
+ catgets(catalog, 2, 16, "OFF"));
+
+ wrefresh(labelwin);
wattroff(labelwin, A_BOLD);
}
diff -r cd83247dae13 -r c0bff4b5586c usr.sbin/sushi/functions.c
--- a/usr.sbin/sushi/functions.c Sat Mar 03 12:56:38 2001 +0000
+++ b/usr.sbin/sushi/functions.c Sat Mar 03 13:54:22 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: functions.c,v 1.2 2001/01/24 09:30:30 garbled Exp $ */
+/* $NetBSD: functions.c,v 1.3 2001/03/03 13:54:22 garbled Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -75,6 +75,7 @@
{(char *)NULL, (char **(*)(char *))NULL},
};
+/*ARGSUSED*/
char **
log_do(char *what)
{
@@ -83,19 +84,14 @@
i = logging;
- if (strcmp("off", what) == 0)
- logging = 0;
- else if (strcmp("on", what) == 0)
- logging = 1;
- else if (strcmp("OFF", what) == 0)
+ if (logging == 1)
logging = 0;
- else if (strcmp("ON", what) == 0)
+ else if (logging == 0)
logging = 1;
- else
- bailout(catgets(catalog, 1, 1,
- "log_do arguments must be on or off"));
- if (logging && i == 0) {
+ time(&tloc);
+
+ if (logging && i == 0) { /* open */
logfile = fopen(LOGFILE_NAME, "w");
if (logfile == NULL)
bailout("fopen %s: %s", LOGFILE_NAME, strerror(errno));
@@ -103,11 +99,19 @@
catgets(catalog, 4, 3, "Log started at"),
asctime(localtime(&tloc)));
fflush(logfile);
+ } else { /* close */
+ if (logfile == NULL)
+ bailout("fopen %s: %s", LOGFILE_NAME, strerror(errno));
+ fprintf(logfile, "%s: %s\n",
+ catgets(catalog, 4, 10, "Log ended at"),
+ asctime(localtime(&tloc)));
+ fflush(logfile);
+ fclose(logfile);
}
-
return(NULL); /* XXX */
}
+/*ARGSUSED*/
char **
script_do(char *what)
{
@@ -116,19 +120,14 @@
i = scripting;
- if (strcmp("off", what) == 0)
- scripting = 0;
- else if (strcmp("on", what) == 0)
+ if (scripting == 0)
scripting = 1;
- else if (strcmp("OFF", what) == 0)
+ else if (scripting == 1)
scripting = 0;
- else if (strcmp("ON", what) == 0)
- scripting = 1;
- else
- bailout(catgets(catalog, 1, 2,
- "script_do arguments must be on or off"));
- if (scripting && i == 0) {
+ time(&tloc);
+
+ if (scripting && i == 0) { /* open */
script = fopen(SCRIPTFILE_NAME, "w");
if (script == NULL)
bailout("fopen %s: %s", SCRIPTFILE_NAME,
@@ -138,8 +137,16 @@
catgets(catalog, 4, 4, "Script started at"),
asctime(localtime(&tloc)));
fflush(script);
+ } else { /* close */
+ if (script == NULL)
+ bailout("fopen %s: %s", SCRIPTFILE_NAME,
+ strerror(errno));
+ fprintf(script, "# %s: %s\n",
+ catgets(catalog, 4, 11, "Script ended at"),
+ asctime(localtime(&tloc)));
+ fflush(script);
+ fclose(script);
}
-
return(NULL); /* XXX */
}
Home |
Main Index |
Thread Index |
Old Index