NetBSD/usr.bin/msgc/msgc.1

169 lines
5.8 KiB
Groff

.\" $NetBSD: msgc.1,v 1.3 1999/03/22 18:16:40 garbled Exp $
.\"
.\" Copyright 1997 Piermont Information Systems Inc.
.\" All rights reserved.
.\"
.\" Written by Philip A. Nelson for Piermont Information Systems Inc.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software develooped for the NetBSD Project by
.\" Piermont Information Systems Inc.
.\" 4. The name of Piermont Information Systems Inc. may not be used to endorse
.\" or promote products derived from this software without specific prior
.\" written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
.\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
.\" THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd September 26, 1997
.Os
.Dt MSGC 1
.Sh NAME
.Nm msgc
.Nd simple message list compiler
.Sh SYNOPSIS
msgc
.Op Fl o Ar name
.Ar file
.Pp
.Fd #include \b'"'msg_defs.h\b'"'
.Ft void
.Fn msg_window "WINDOW *window"
.Ft void
.Fn beep "void"
.Ft char *
.Fn msg_string "int msg_no"
.Ft void
.Fn msg_clear "void"
.Ft void
.Fn msg_standout "void"
.Ft void
.Fn msg_standend "void"
.Ft void
.Fn msg_display "int msg_no" ...
.Ft void
.Fn msg_display_add "int msg_no" ...
.Ft int
.Fn msg_vprintf "char *fmt" "va_list ap"
.Ft int
.Fn msg_printf "char *fmt" ...
.Ft int
.Fn msg_printf_add "char *fmt" ...
.Ft void
.Fn msg_prompt_add "int msg_no" "char *def" "char *val" "int max_chars" ...
.Ft void
.Fn msg_prompt "int msg_no" "char *def" "char *val" "int max_chars" ...
.Ft void
.Fn msg_prompt_str "char *msg" "char *def" "char *val" "int max_chars" ...
.Ft void
.Fn msg_prompt_addstr "char *msg" "char *def" "char *val" "int max_chars" ...
.Ft void
.Fn msg_echo "void"
.Ft void
.Fn msg_noecho "void"
.Sh DESCRIPTION
This implements a curses based message display system. A source file that
lists messages with associated names is given to
.Nm
and produces both a .c and a .h file that implement the menu system.
The standard root name of the files is
.Pa msg_defs .
The
.Fl o Ar name
can be used to specify a different root name.
.Sh SOURCE DESCRIPTION
The format is very simple. Each message is started with the word
.Sq message
followed by the name of the message. The body of the message is
next and is started by a { and closed by a }. The braces are not
part of the message. Everything, including newlines between the
braces are part of the message.
.Sh MESSAGE FUNCTIONS
The defined messages are used through calls routines that manipulate
the messages. You first need to set the
.Xr curses 3
environment up and then tell the message system which window to use
for displaying message by calling the function
.Fn msg_window .
.Pp
All variable argument lists in the functions are used as
are arguments to sprintf. The messages
may have sprintf conversions in them and the corresponding parameters
should match. Messages are identified by name using the notation
.Sq MENU_name
where
.Dq name
is the name in the message source file. (The definitions are accessed
by including the genereated .h file into a source file wanting to use
the message routines.)
.Pp
The function
.Fn msg_string
just returns a pointer to the actual message string.
The functions
.Fn msg_clear ,
.Fn msg_standout
and
.Fn msg_standend
respectively clear the message window, set standout mode and clear standout
mode. The functions
.Fn msg_display
and
.Fn msg_display_add
cause a defined message to be displayed in the message window and does
the requested conversions before printing. The difference is that
.Fn msg_display
clears the window before displaying the message.
The functions
.Fn msg_printf and
.Fn msg_printf_add
print to the message window but take the format string from the function
call instead of the message directory. Again, the first version,
.Fn msg_printf ,
clears the window before printing.
.Pp
The remaining functions deal with a prompt facility. A prompt message
is either taken from the message directory or from a given string. The
message is processed with sprintf and then displayed. If the parameter
.Ar def
non-NULL or not a string of zero length, a default value is printed
in brackets. The user is allowed to type in a response. If the user
types just the newline character, the default is returned in the value.
the parameter
.Ar max_chars
is the length if the parameter
.Ar val ,
where the results are stored.
The parameters
.Ar def
and
.Ar val
may point to the same character array. If the default is chosen, the
character array is not changed.
The functions
.Fn msg_echo
and
.Fn msg_noecho
control whether the prompt routine echo or don't echo the input that
is typed by the user.
.Sh AUTHOR
Philip A. Nelson for Piermont Information Systems Inc.