summaryrefslogtreecommitdiff
path: root/src/tet3/tcc/dirtab.c
blob: abf338d082704ec82368178a87bf88d564d8f5f6 (plain)
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/*
 *	SCCS: @(#)dirtab.c	1.3 (98/03/05)
 *
 *	UniSoft Ltd., London, England
 *
 * (C) Copyright 1996 X/Open Company Limited
 *
 * All rights reserved.  No part of this source code may be reproduced,
 * stored in a retrieval system, or transmitted, in any form or by any
 * means, electronic, mechanical, photocopying, recording or otherwise,
 * except as stated in the end-user licence agreement, without the prior
 * permission of the copyright owners.
 * A copy of the end-user licence agreement is contained in the file
 * Licence which accompanies this distribution.
 * 
 * X/Open and the 'X' symbol are trademarks of X/Open Company Limited in
 * the UK and other countries.
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

/************************************************************************

SCCS:   	@(#)dirtab.c	1.3 98/03/05 TETware release 3.3
NAME:		dirtab.c
PRODUCT:	TETware
AUTHOR:		Andrew Dingwall, UniSoft Ltd.
DATE CREATED:	August 1996

DESCRIPTION:
	the scenario directive table and related functions

MODIFICATIONS:
	Andrew Dingwall, UniSoft Ltd., March 1998
	added support for number ranges in directive arguments

************************************************************************/

#include <string.h>
#include "dtmac.h"
#include "dirtab.h"

#ifndef NOTRACE
#include "ltoa.h"
#endif

/* number of entries in an array */
#define NUMENTRIES(x)	(sizeof x / sizeof x[0])


/*
**	valid enclosing directive lists
*/

/* all directives */
static int enc_all[] = {
#ifndef TET_LITE	/* -START-LITE-CUT- */
	SD_DISTRIBUTED, SD_REMOTE,
#endif /* !TET_LITE */	/* -END-LITE-CUT- */
	SD_PARALLEL, SD_RANDOM, SD_REPEAT, SD_SEQUENTIAL, SD_TIMED_LOOP,
	SD_VARIABLE
};

/* these directives may appear within the scope of random */
static int enc_random[] = {
#ifndef TET_LITE	/* -START-LITE-CUT- */
	SD_DISTRIBUTED, SD_REMOTE,
#endif /* !TET_LITE */	/* -END-LITE-CUT- */
	SD_SEQUENTIAL, SD_VARIABLE
};

/* these directives may appear within the scope of parallel */
static int enc_parallel[] = {
#ifndef TET_LITE	/* -START-LITE-CUT- */
	SD_DISTRIBUTED, SD_REMOTE,
#endif /* !TET_LITE */	/* -END-LITE-CUT- */
	SD_SEQUENTIAL
};


#ifndef TET_LITE	/* -START-LITE-CUT- */
/* these directives may appear within the scope of remote and distributed */
static int enc_remdist[] = {
	SD_PARALLEL, SD_RANDOM, SD_REPEAT, SD_SEQUENTIAL, SD_TIMED_LOOP,
	SD_VARIABLE
};
#endif /* !TET_LITE */	/* -END-LITE-CUT- */


/* the directives table itself */
static struct dirtab dirtab[] = {

	{
		"include", SD_INCLUDE, 0, SDF_NEED_ATTACH, (int *) 0, 0
	},

	{	
		"parallel", SD_PARALLEL, SD_END_PARALLEL,
		SDF_OPT_ARG | SDF_NUMERIC_ARGS | SDF_OPT_ATTACH | SDF_ENDDIR,
		enc_parallel, NUMENTRIES(enc_parallel)
	},

	{
		"endparallel", SD_END_PARALLEL, SD_PARALLEL, 0, (int *) 0, 0
	},

	{
		"group", SD_PARALLEL, SD_END_PARALLEL,
		SDF_OPT_ARG | SDF_NUMERIC_ARGS | SDF_OPT_ATTACH | SDF_ENDDIR,
		enc_parallel, NUMENTRIES(enc_parallel)
	},

	{
		"endgroup", SD_END_PARALLEL, SD_PARALLEL, 0, (int *) 0, 0
	},

	{
		"repeat", SD_REPEAT, SD_END_REPEAT,
		SDF_OPT_ARG | SDF_NUMERIC_ARGS | SDF_OPT_ATTACH | SDF_ENDDIR,
		enc_all, NUMENTRIES(enc_all)
	},

	{
		"endrepeat", SD_END_REPEAT, SD_REPEAT, 0, (int *) 0, 0
	},

	{
		"random", SD_RANDOM, SD_END_RANDOM,
		SDF_OPT_ATTACH | SDF_ENDDIR,
		enc_random, NUMENTRIES(enc_random)
	},

	{
		"endrandom", SD_END_RANDOM, SD_RANDOM, 0, (int *) 0, 0
	},

	{
		"timed_loop", SD_TIMED_LOOP, SD_END_TIMED_LOOP,
		SDF_NEED_ARG | SDF_NUMERIC_ARGS | SDF_OPT_ATTACH | SDF_ENDDIR,
		enc_all, NUMENTRIES(enc_all)
	},

	{
		"endtimed_loop", SD_END_TIMED_LOOP, SD_TIMED_LOOP, 0,
		(int *) 0, 0
	},

#ifndef TET_LITE	/* -START-LITE-CUT- */

	{
		"remote", SD_REMOTE, SD_END_REMOTE,
		SDF_NEED_MARG | SDF_NRANGE_ARGS | SDF_OPT_ATTACH | SDF_ENDDIR,
		enc_remdist, NUMENTRIES(enc_remdist)
	},

	{
		"endremote", SD_END_REMOTE, SD_REMOTE, 0, (int *) 0, 0
	},

	{
		"distributed", SD_DISTRIBUTED, SD_END_DISTRIBUTED,
		SDF_NEED_MARG | SDF_NRANGE_ARGS | SDF_OPT_ATTACH | SDF_ENDDIR,
		enc_remdist, NUMENTRIES(enc_remdist)
	},

	{
		"enddistributed", SD_END_DISTRIBUTED, SD_DISTRIBUTED, 0,
		(int *) 0, 0
	},

#endif /* !TET_LITE */	/* -END-LITE-CUT- */

#if 0
	{
		"variable", SD_VARIABLE, SD_END_VARIABLE,
		SDF_NEED_MARG | SDF_VARFMT_ARGS | SDF_OPT_ATTACH | SDF_ENDDIR,
		enc_all, NUMENTRIES(enc_all)
	},

	{
		"endvariable", SD_END_VARIABLE, SD_VARIABLE, 0, (int *) 0, 0
	},
#endif

	{
		(char *) 0, SD_SEQUENTIAL, 0, 0, enc_all, NUMENTRIES(enc_all)
	}
};

/*
**	getdirbyname(), getdirbyvalue() - directive table lookup functions
*/

struct dirtab *getdirbyname(name)
char *name;
{
	register struct dirtab *dp;

	for (dp = dirtab; dp < &dirtab[NUMENTRIES(dirtab)]; dp++)
		if (dp->dt_name && !strcmp(name, dp->dt_name))
			return(dp);

	TRACE2(tet_Tscen, 6, "getdirbyname(%s) failed", name);
	return((struct dirtab *) 0);
}

struct dirtab *getdirbyvalue(directive)
int directive;
{
	register struct dirtab *dp;

	for (dp = dirtab; dp < &dirtab[NUMENTRIES(dirtab)]; dp++)
		if (directive == dp->dt_directive)
			return(dp);

	TRACE2(tet_Tscen, 6, "getdirbyvalue(%s) failed", tet_i2a(directive));
	return((struct dirtab *) 0);
}