1 #ifndef ARGSH
2 #define ARGSH
3 
4 /*
5  * $Id: args.h,v 1.4 2000/08/10 21:02:49 danny Exp $
6  * Copyright � 1993 Free Software Foundation, Inc.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this software; see the file COPYING.  If not, write to
20  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
21 
22 /* Interacting with command arguments. */
23 
24 /* See find_stub. */
25 enum command_arg_representation
26 {
27   cmd_char  = 'c',
28   cmd_float = 'd',
29   cmd_file  = 'f',
30   cmd_int   = 'i',
31   cmd_key   = 'k',
32   cmd_range = 'r',
33   cmd_string = 's',
34   cmd_none  = '0'
35 };
36 
37 struct command_arg;
38 
39 /* See comments in arg.c: */
40 
41 typedef char * (*arg_verifier) (char ** end_out, struct command_arg *);
42 typedef void (*arg_destroyer) (struct command_arg *);
43 
44 /* For every kind of prompt allowed in a FUNC_ARGS string,
45  * there exists a prompt_style that describes how that
46  * kind of argument should be editted/passed:
47  */
48 
49 struct prompt_style
50 {
51   arg_verifier verify;
52   arg_destroyer destroy;
53   enum command_arg_representation representation;
54   char * keymap;
55 };
56 
57 
58 
59 extern char * char_verify (char ** end, struct command_arg * arg);
60 extern char * symbol_verify (char ** end, struct command_arg * arg);
61 extern char * word_verify (char ** end, struct command_arg * arg);
62 extern void symbol_destroy (struct command_arg * arg);
63 extern char * command_verify (char ** end, struct command_arg * arg);
64 extern char * read_file_verify (char ** end, struct command_arg * arg);
65 extern void read_file_destroy (struct command_arg * arg);
66 extern char * write_file_verify (char ** end, struct command_arg * arg);
67 extern void write_file_destroy (struct command_arg * arg);
68 extern char * keyseq_verify (char ** end, struct command_arg * arg);
69 extern char * keymap_verify (char ** end, struct command_arg * arg);
70 extern char * number_verify (char ** end, struct command_arg * arg);
71 extern char * double_verify (char ** end, struct command_arg * arg);
72 extern char * range_verify (char ** end, struct command_arg * arg);
73 extern char * string_verify (char ** end, struct command_arg * arg);
74 extern char * yes_verify (char ** end, struct command_arg * arg);
75 extern char * incremental_cmd_verify (char ** end, struct command_arg * arg);
76 extern char * menu_verify (char ** end, struct command_arg * arg);
77 extern char * format_verify (char ** end, struct command_arg * arg);
78 extern char * noop_verify (char ** end, struct command_arg * arg);
79 
80 #ifdef DEFINE_STYLES
81 #define DEFSTYLE(NAME,VER,DEST,REP,KEYMAP) \
82 struct prompt_style NAME = \
83 { \
84   VER, \
85   DEST, \
86   REP, \
87   KEYMAP \
88 }
89 #else
90 #define DEFSTYLE(NAME,VER,DEST,REP,KEYMAP) extern struct prompt_style NAME
91 #endif
92 
93 DEFSTYLE(char_style, char_verify, 0, cmd_int, "read-char");
94 DEFSTYLE(double_style, double_verify, 0, cmd_float, "read-float");
95 DEFSTYLE(menu_style, menu_verify, 0, cmd_int, "read-menu");
96 DEFSTYLE(format_style, format_verify, 0, cmd_int, "read-format");
97 DEFSTYLE(symbol_style,
98 	 symbol_verify, symbol_destroy, cmd_string, "read-symbol");
99 DEFSTYLE(word_style,
100 	 word_verify, symbol_destroy, cmd_string, "read-word");
101 DEFSTYLE(command_style,
102 	 command_verify, symbol_destroy, cmd_string, "read-symbol");
103 DEFSTYLE(read_file_style,
104 	 read_file_verify, read_file_destroy, cmd_file, "read-filename");
105 DEFSTYLE(write_file_style,
106 	 write_file_verify, write_file_destroy, cmd_file, "read-filename");
107 DEFSTYLE(keyseq_style, keyseq_verify, 0, cmd_key, "read-keyseq");
108 DEFSTYLE(keymap_style,
109 	 keymap_verify, symbol_destroy, cmd_string, "read-symbol");
110 DEFSTYLE(number_style, number_verify, 0, cmd_int, "read-integer");
111 DEFSTYLE(range_style, range_verify, 0, cmd_range, "read-range");
112 DEFSTYLE(formula_style, string_verify, 0, cmd_string, "read-formula");
113 DEFSTYLE(string_style, string_verify, 0, cmd_string, "read-string");
114 DEFSTYLE(file_name_style, string_verify, 0, cmd_string, "read-filename");
115 DEFSTYLE(yes_style, yes_verify, 0, cmd_none, "read-string");
116 DEFSTYLE(int_constant_style, 0, 0, cmd_int, 0);
117 DEFSTYLE(range_constant_style, 0, 0, cmd_range, 0);
118 DEFSTYLE(inc_cmd_style, incremental_cmd_verify, 0, cmd_none, "direction");
119 DEFSTYLE(mode_style, noop_verify, 0, cmd_none, 0);
120 
121 #endif  /* ARGSH */
122