-/*
- * Copyright 1987 by the Massachusetts Institute of Technology.
- * For copying and distribution information, see the file
- * "mit-copyright.h".
- *
- * $Source$
- * $Author$
- * $Header$
+/* $Id $
*
* Generic menu system module.
*
- * Basically, we define an enormous tree structure which represents the
- * menu. Some extra pieces (ml_command, ma_doc) get thrown in so we can
- * also use the structure for a command-based system.
- *
- * By making the menu descriptions so general, we can ease porting to just
- * about anything.
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, see the file
+ * <mit-copyright.h>.
*/
-#ifndef lint
-static char rcsid_menu_c[] = "$Header$";
-#endif
-
#include <mit-copyright.h>
-#include <sys/types.h>
+#include <moira.h>
+#include "menu.h"
+
+#include <ctype.h>
+#include <curses.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <signal.h>
-#include <curses.h>
#include <unistd.h>
-#include <termios.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <com_err.h>
-#include <moira.h>
-#include "menu.h"
+
+RCSID("$Header$");
#define MAX(A, B) ((A) > (B) ? (A) : (B))
#define MIN(A, B) ((A) < (B) ? (A) : (B))
int parsed_argc; /* used by extern routines to get additional */
char **parsed_argv; /* comand line input */
+int Parse_words(char *buf, char *argv[], int n);
+void refresh_ms(struct menu_screen *ms);
+void Put_line(char *msg);
+void menu_com_err_hook(const char *who, long code, const char *fmt, ...);
+struct menu_screen *make_ms(int length);
+void destroy_ms(struct menu_screen *ms);
+struct menu_line *find_command_from(char *c, struct menu *m, int d);
+struct menu_line *Find_command(Menu *m, char *command);
+int toggle_logging(int argc, char *argv[]);
+
/*
* Hook function to cause error messages to be printed through
* curses instead of around it. Takes at most 5 args to the
* printf string (crock...)
*/
-void menu_com_err_hook(const char *who, long code, const char *fmt,
- caddr_t arg1, caddr_t arg2, caddr_t arg3,
- caddr_t arg4, caddr_t arg5)
+void menu_com_err_hook(const char *who, long code, const char *fmt, ...)
{
char buf[BUFSIZ], *cp;
+ va_list ap;
strcpy(buf, who);
for (cp = buf; *cp; cp++)
while (*cp)
cp++;
}
- sprintf(cp, fmt, arg1, arg2, arg3, arg4, arg5);
+ va_start(ap, fmt);
+ vsprintf(cp, fmt, ap);
+ va_end(ap);
Put_message(buf);
}
* if user functions which run their own menus don't cooperate.)
* Start_menu should only be called once, at the start of the program.
*/
-int Start_menu(Menu *m)
+void Start_menu(Menu *m)
{
- struct menu_screen *make_ms();
void (*old_hook)(const char *, long, const char *, va_list) =
set_com_err_hook((void (*) (const char *, long, const char *, va_list))menu_com_err_hook);
Cleanup_menu();
}
-int Cleanup_menu(void)
+void Cleanup_menu(void)
{
if (cur_ms)
{
/* Like Start_menu, except it doesn't print menus and doesn't use curses */
-int Start_no_menu(Menu *m)
+void Start_no_menu(Menu *m)
{
cur_ms = NULLMS;
COLS = 80;
/*
* This routine destroys a menu_screen.
*/
-int destroy_ms(struct menu_screen *ms)
+void destroy_ms(struct menu_screen *ms)
{
delwin(ms->ms_title);
delwin(ms->ms_menu);
char *argv[MAX_ARGC];
int line;
int i;
- struct menu_line *command, *Find_command();
+ struct menu_line *command;
int argc;
int quitflag, is_topmenu = (margc < 0);
- int toggle_logging();
/* Entry function gets called with old menu_screen still current */
if (m->m_entry != NULLFUNC)
}
}
-int refresh_screen(void)
+void refresh_screen(void)
{
if (cur_ms != NULLMS)
{
/* Start paging */
/* This routine will cause the most recently put message to be the
one at the top of the screen when a ---More--- prompt is displayed */
-int Start_paging(void)
+void Start_paging(void)
{
if (cur_ms != NULLMS)
lines_left = LINES - cur_ms->ms_input_y - 1;
}
/* Turn off paging */
-int Stop_paging(void)
+void Stop_paging(void)
{
lines_left = -1;
}
/* Print a message in the input window of cur_ms. */
-int Put_message(char *msg)
+void Put_message(char *msg)
{
char *copy, *line, *s;
}
/* Will be truncated to COLS characters. */
-int Put_line(char *msg)
+void Put_line(char *msg)
{
int y, x, i;
char *msg1, chr;
}
/* Refresh a menu_screen onto the real screen */
-int refresh_ms(struct menu_screen *ms)
+void refresh_ms(struct menu_screen *ms)
{
wrefresh(ms->ms_title);
wrefresh(ms->ms_menu);