const-ify strings as appropriate, and convert message 'numbers' from

ints to 'msg's.  'msg' is currently typedef'd as 'const char *', but it'll
become more complex eventually.
This commit is contained in:
cgd 1999-07-04 21:30:14 +00:00
parent 140b1ee075
commit a70b70f98d
3 changed files with 49 additions and 46 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg_sys.def,v 1.15 1999/07/04 10:39:40 cgd Exp $ */
/* $NetBSD: msg_sys.def,v 1.16 1999/07/04 21:30:14 cgd Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -44,9 +44,9 @@ static int last_i_was_nl, last_i_was_space;
static int last_o_was_punct, last_o_was_space;
static void _msg_beep(void);
static int _msg_vprintf(int auto_fill, char *fmt, va_list ap);
static void _msg_vprompt(char *msg, int do_echo, char *def, char *val,
int max_chars, va_list ap);
static int _msg_vprintf(int auto_fill, const char *fmt, va_list ap);
static void _msg_vprompt(const char *msg, int do_echo, const char *def,
char *val, int max_chars, va_list ap);
/* Routines */
@ -76,9 +76,9 @@ int msg_window(WINDOW *window)
return 0;
}
char *msg_string (int msg_no)
const char *msg_string (msg msg_no)
{
return msg_list[msg_no];
return msg_list[(long)msg_no];
}
void msg_clear(void)
@ -100,7 +100,7 @@ void msg_standend(void)
}
static int
_msg_vprintf(int auto_fill, char *fmt, va_list ap)
_msg_vprintf(int auto_fill, const char *fmt, va_list ap)
{
const char *wstart, *afterw;
int wordlen, nspaces;
@ -225,27 +225,27 @@ out:
return ret;
}
void msg_display(int msg_no, ...)
void msg_display(msg msg_no, ...)
{
va_list ap;
msg_clear();
va_start(ap, msg_no);
(void)_msg_vprintf(1, msg_list[msg_no], ap);
(void)_msg_vprintf(1, msg_string(msg_no), ap);
va_end(ap);
}
void msg_display_add(int msg_no, ...)
void msg_display_add(msg msg_no, ...)
{
va_list ap;
va_start (ap, msg_no);
(void)_msg_vprintf(1, msg_list[msg_no], ap);
(void)_msg_vprintf(1, msg_string(msg_no), ap);
va_end (ap);
}
int msg_printf (char *fmt, ...)
int msg_printf (const char *fmt, ...)
{
va_list ap;
int res;
@ -258,7 +258,7 @@ int msg_printf (char *fmt, ...)
return res;
}
int msg_printf_add (char *fmt, ...)
int msg_printf_add (const char *fmt, ...)
{
va_list ap;
int res;
@ -271,8 +271,8 @@ int msg_printf_add (char *fmt, ...)
static void
_msg_vprompt(char *msg, int do_echo, char *def, char *val, int max_chars,
va_list ap)
_msg_vprompt(const char *msg, int do_echo, const char *def, char *val,
int max_chars, va_list ap)
{
int ch;
int count = 0;
@ -360,45 +360,45 @@ _msg_vprompt(char *msg, int do_echo, char *def, char *val, int max_chars,
}
void
msg_prompt(int msg_no, char *def, char *val, int max_chars, ...)
msg_prompt(msg msg_no, const char *def, char *val, int max_chars, ...)
{
va_list ap;
msg_clear();
va_start (ap, max_chars);
_msg_vprompt(msg_list[msg_no], 1, def, val, max_chars, ap);
_msg_vprompt(msg_string(msg_no), 1, def, val, max_chars, ap);
va_end (ap);
}
void
msg_prompt_add(int msg_no, char *def, char *val, int max_chars, ...)
msg_prompt_add(msg msg_no, const char *def, char *val, int max_chars, ...)
{
va_list ap;
va_start (ap, max_chars);
_msg_vprompt(msg_list[msg_no], 1, def, val, max_chars, ap);
_msg_vprompt(msg_string(msg_no), 1, def, val, max_chars, ap);
va_end(ap);
}
void
msg_prompt_noecho(int msg_no, char *def, char *val, int max_chars, ...)
msg_prompt_noecho(msg msg_no, const char *def, char *val, int max_chars, ...)
{
va_list ap;
msg_clear();
va_start (ap, max_chars);
_msg_vprompt(msg_list[msg_no], 0, def, val, max_chars, ap);
_msg_vprompt(msg_string(msg_no), 0, def, val, max_chars, ap);
va_end (ap);
}
void msg_table_add(int msg_no, ...)
void msg_table_add(msg msg_no, ...)
{
va_list ap;
va_start (ap, msg_no);
(void)_msg_vprintf(0, msg_list[msg_no], ap);
(void)_msg_vprintf(0, msg_string(msg_no), ap);
va_end (ap);
}

View File

@ -1,4 +1,4 @@
.\" $NetBSD: msgc.1,v 1.8 1999/07/04 10:35:19 cgd Exp $
.\" $NetBSD: msgc.1,v 1.9 1999/07/04 21:30:14 cgd Exp $
.\"
.\" Copyright 1997 Piermont Information Systems Inc.
.\" All rights reserved.
@ -47,8 +47,8 @@ msgc
.Fd #include \b'"'msg_defs.h\b'"'
.Ft void
.Fn msg_window "WINDOW *window"
.Ft char *
.Fn msg_string "int msg_no"
.Ft const char *
.Fn msg_string "msg msg_no"
.Ft void
.Fn msg_clear "void"
.Ft void
@ -56,21 +56,21 @@ msgc
.Ft void
.Fn msg_standend "void"
.Ft void
.Fn msg_display "int msg_no" ...
.Fn msg_display "msg msg_no" ...
.Ft void
.Fn msg_display_add "int msg_no" ...
.Fn msg_display_add "msg msg_no" ...
.Ft int
.Fn msg_printf "char *fmt" ...
.Fn msg_printf "const char *fmt" ...
.Ft int
.Fn msg_printf_add "char *fmt" ...
.Fn msg_printf_add "const char *fmt" ...
.Ft void
.Fn msg_prompt "int msg_no" "char *def" "char *val" "int max_chars" ...
.Fn msg_prompt "msg msg_no" "const char *def" "char *val" "int max_chars" ...
.Ft void
.Fn msg_prompt_add "int msg_no" "char *def" "char *val" "int max_chars" ...
.Fn msg_prompt_add "msg msg_no" "const char *def" "char *val" "int max_chars" ...
.Ft void
.Fn msg_prompt_noecho "int msg_no" "char *def" "char *val" "int max_chars" ...
.Fn msg_prompt_noecho "msg msg_no" "const char *def" "char *val" "int max_chars" ...
.Ft void
.Fn msg_table_add "int msg_no" ...
.Fn msg_table_add "msg msg_no" ...
.Sh DESCRIPTION
This implements a curses based message display system. A source file that
lists messages with associated names is given to

View File

@ -1,4 +1,4 @@
/* $NetBSD: msgdb.c,v 1.9 1999/07/04 10:35:19 cgd Exp $ */
/* $NetBSD: msgdb.c,v 1.10 1999/07/04 21:30:15 cgd Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -141,28 +141,31 @@ write_msg_file ()
"#include <stdarg.h>\n"
"#include <curses.h>\n"
"\n"
"typedef const char *msg;\n"
"\n"
"/* Prototypes */\n"
"int msg_window(WINDOW *window);\n"
"char *msg_string (int msg_no);\n"
"const char *msg_string (msg msg_no);\n"
"void msg_clear(void);\n"
"void msg_standout(void);\n"
"void msg_standend(void);\n"
"void msg_display(int msg_no,...);\n"
"void msg_display_add(int msg_no,...);\n"
"int msg_printf (char *fmt, ...);\n"
"int msg_printf_add (char *fmt, ...);\n"
"void msg_prompt (int msg_no, char *def,"
"void msg_display(msg msg_no,...);\n"
"void msg_display_add(msg msg_no,...);\n"
"int msg_printf (const char *fmt, ...);\n"
"int msg_printf_add (const char *fmt, ...);\n"
"void msg_prompt (msg msg_no, const char *def,"
" char *val, int max_chars, ...);\n"
"void msg_prompt_add (int msg_no, char *def,"
"void msg_prompt_add (msg msg_no, const char *def,"
" char *val, int max_chars, ...);\n"
"void msg_prompt_noecho (int msg_no, char *def,"
"void msg_prompt_noecho (msg msg_no, const char *def,"
" char *val, int max_chars, ...);\n"
"void msg_table_add(int msg_no,...);\n"
"void msg_table_add(msg msg_no,...);\n"
"\n"
"/* Message names */\n"
);
(void) fprintf (out_file, "#define MSG_NONE\tNULL\n");
for (t=head; t != NULL; t = t->next) {
(void) fprintf (out_file, "#define MSG_%s\t%d\n",
(void) fprintf (out_file, "#define MSG_%s\t((msg)(long)%d)\n",
t->id, t->msg_no);
}
(void) fprintf (out_file, "\n#endif\n");
@ -181,7 +184,7 @@ write_msg_file ()
(void)fprintf (out_file, "#include \"%s\"\n", hname);
/* msg_list */
(void)fprintf (out_file, "char *msg_list[] = {\n");
(void)fprintf (out_file, "const char *msg_list[] = {\n");
for (t=head ; t != NULL; t = t->next)
write_str (out_file, t->msg);
(void)fprintf (out_file, "NULL};\n");