File: args.h

package info (click to toggle)
oleo 1.6-16
  • links: PTS
  • area: main
  • in suites: potato
  • size: 2,640 kB
  • ctags: 3,139
  • sloc: ansic: 39,221; yacc: 1,737; sh: 362; makefile: 88
file content (148 lines) | stat: -rw-r--r-- 5,290 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#ifndef ARGSH
#define ARGSH

/*	Copyright (C) 1993 Free Software Foundation, Inc.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this software; see the file COPYING.  If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
/*  t. lord	Wed Jan 27 15:46:24 1993	*/




/* Interacting with command arguments. */

/* See find_stub. */
enum command_arg_representation
{
  cmd_char  = 'c',
  cmd_float = 'd',
  cmd_file  = 'f',
  cmd_int   = 'i',
  cmd_key   = 'k',
  cmd_range = 'r',
  cmd_string = 's',
  cmd_none  = '0'
};

struct command_arg;

/* See comments in arg.c: */

typedef char * (*arg_verifier) (char ** end_out, struct command_arg *);
typedef void (*arg_destroyer) (struct command_arg *);

/* For every kind of prompt allowed in a FUNC_ARGS string, 
 * there exists a prompt_style that describes how that
 * kind of argument should be editted/passed:
 */

struct prompt_style
{
  arg_verifier verify;
  arg_destroyer destroy;
  enum command_arg_representation representation;
  char * keymap;
};



#if PROTOTYPES
extern char * char_verify (char ** end, struct command_arg * arg);
extern char * symbol_verify (char ** end, struct command_arg * arg);
extern char * word_verify (char ** end, struct command_arg * arg);
extern void symbol_destroy (struct command_arg * arg);
extern char * command_verify (char ** end, struct command_arg * arg);
extern char * read_file_verify (char ** end, struct command_arg * arg);
extern void read_file_destroy (struct command_arg * arg);
extern char * write_file_verify (char ** end, struct command_arg * arg);
extern void write_file_destroy (struct command_arg * arg);
extern char * keyseq_verify (char ** end, struct command_arg * arg);
extern char * keymap_verify (char ** end, struct command_arg * arg);
extern char * number_verify (char ** end, struct command_arg * arg);
extern char * double_verify (char ** end, struct command_arg * arg);
extern char * range_verify (char ** end, struct command_arg * arg);
extern char * string_verify (char ** end, struct command_arg * arg);
extern char * yes_verify (char ** end, struct command_arg * arg);
extern char * incremental_cmd_verify (char ** end, struct command_arg * arg);
extern char * menu_verify (char ** end, struct command_arg * arg);
extern char * format_verify (char ** end, struct command_arg * arg);
extern char * noop_verify (char ** end, struct command_arg * arg);
#else
extern char * char_verify ();
extern char * symbol_verify ();
extern char * word_verify ();
extern void symbol_destroy ();
extern char * command_verify ();
extern char * read_file_verify ();
extern void read_file_destroy ();
extern char * write_file_verify ();
extern void write_file_destroy ();
extern char * keyseq_verify ();
extern char * keymap_verify ();
extern char * number_verify ();
extern char * double_verify ();
extern char * range_verify ();
extern char * string_verify ();
extern char * yes_verify ();
extern char * incremental_cmd_verify ();
extern char * menu_verify ();
extern char * format_verify ();
extern char * noop_verify ();
#endif

#ifdef DEFINE_STYLES
#define DEFSTYLE(NAME,VER,DEST,REP,KEYMAP) \
struct prompt_style NAME = \
{ \
  VER, \
  DEST, \
  REP, \
  KEYMAP \
}
#else
#define DEFSTYLE(NAME,VER,DEST,REP,KEYMAP) extern struct prompt_style NAME
#endif

DEFSTYLE(char_style, char_verify, 0, cmd_int, "read-char");
DEFSTYLE(double_style, double_verify, 0, cmd_float, "read-float");
DEFSTYLE(menu_style, menu_verify, 0, cmd_int, "read-menu");
DEFSTYLE(format_style, format_verify, 0, cmd_int, "read-format");
DEFSTYLE(symbol_style,
	 symbol_verify, symbol_destroy, cmd_string, "read-symbol");
DEFSTYLE(word_style,
	 word_verify, symbol_destroy, cmd_string, "read-word");
DEFSTYLE(command_style,
	 command_verify, symbol_destroy, cmd_string, "read-symbol");
DEFSTYLE(read_file_style,
	 read_file_verify, read_file_destroy, cmd_file, "read-filename");
DEFSTYLE(write_file_style,
	 write_file_verify, write_file_destroy, cmd_file, "read-filename");
DEFSTYLE(keyseq_style, keyseq_verify, 0, cmd_key, "read-keyseq");
DEFSTYLE(keymap_style,
	 keymap_verify, symbol_destroy, cmd_string, "read-symbol"); 
DEFSTYLE(number_style, number_verify, 0, cmd_int, "read-integer");
DEFSTYLE(range_style, range_verify, 0, cmd_range, "read-range");
DEFSTYLE(formula_style, string_verify, 0, cmd_string, "read-formula");
DEFSTYLE(string_style, string_verify, 0, cmd_string, "read-string");
DEFSTYLE(file_name_style, string_verify, 0, cmd_string, "read-filename");
DEFSTYLE(yes_style, yes_verify, 0, cmd_none, "read-string");
DEFSTYLE(int_constant_style, 0, 0, cmd_int, 0);
DEFSTYLE(range_constant_style, 0, 0, cmd_range, 0);
DEFSTYLE(inc_cmd_style, incremental_cmd_verify, 0, cmd_none, "direction");
DEFSTYLE(mode_style, noop_verify, 0, cmd_none, 0);

#endif  /* ARGSH */