12698777wollman/*
22698777wollman * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
32698777wollman * unrestricted use provided that this legend is included on all tape
42698777wollman * media and as a part of the software program in whole or part.  Users
52698777wollman * may copy or modify Sun RPC without charge, but are not authorized
62698777wollman * to license or distribute it to anyone else except as part of a product or
72698777wollman * program developed by the user.
826ad533charnier *
92698777wollman * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
102698777wollman * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
112698777wollman * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
1226ad533charnier *
132698777wollman * Sun RPC is provided with no support and without any obligation on the
142698777wollman * part of Sun Microsystems, Inc. to assist in its use, correction,
152698777wollman * modification or enhancement.
1626ad533charnier *
172698777wollman * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
182698777wollman * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
192698777wollman * OR ANY PART THEREOF.
2026ad533charnier *
212698777wollman * In no event will Sun Microsystems, Inc. be liable for any lost revenue
222698777wollman * or profits or other special, indirect and consequential damages, even if
232698777wollman * Sun has been advised of the possibility of such damages.
2426ad533charnier *
252698777wollman * Sun Microsystems, Inc.
262698777wollman * 2550 Garcia Avenue
272698777wollman * Mountain View, California  94043
282698777wollman */
2915a1e09wpaul
30d95d8b8alfred#if 0
3126ad533charnier#ifndef lint
32e73616bstefanf#ident	"@(#)rpc_hout.c	1.16	94/04/25 SMI"
3315a1e09wpaulstatic char sccsid[] = "@(#)rpc_hout.c 1.12 89/02/22 (C) 1987 SMI";
342698777wollman#endif
35d95d8b8alfred#endif
362698777wollman
3726ad533charnier#include <sys/cdefs.h>
3826ad533charnier__FBSDID("$FreeBSD$");
3926ad533charnier
402698777wollman/*
41a14d555rgrimes * rpc_hout.c, Header file outputter for the RPC protocol compiler
42a14d555rgrimes * Copyright (C) 1987, Sun Microsystems, Inc.
432698777wollman */
442698777wollman#include <stdio.h>
450842b7ddelphij#include <ctype.h>
462698777wollman#include "rpc_parse.h"
47ed8baf6stefanf#include "rpc_scan.h"
4815a1e09wpaul#include "rpc_util.h"
4915a1e09wpaul
506a5a7b7dwmalonevoid storexdrfuncdecl(const char *, int );
511698cb2impstatic void pconstdef( definition * );
521698cb2impstatic void pstructdef( definition * );
531698cb2impstatic void puniondef( definition * );
54cd3615cstefanfstatic void pprogramdef( definition *, int );
551698cb2impstatic void penumdef( definition * );
561698cb2impstatic void ptypedef( definition * );
576a5a7b7dwmalonestatic void pdefine(const char *, const char *);
586a5a7b7dwmalonestatic int undefined2(const char *, const char *);
596a5a7b7dwmalonestatic void parglist(proc_list *, const char *);
606a5a7b7dwmalonestatic void pprocdef(proc_list *, version_list *, const char *, int);
6115a1e09wpaul
622698777wollman/*
63a14d555rgrimes * Print the C-version of an xdr definition
642698777wollman */
652698777wollmanvoid
66cd3615cstefanfprint_datadef(definition *def, int headeronly)
672698777wollman{
6815a1e09wpaul
6915a1e09wpaul	if (def->def_kind == DEF_PROGRAM)  /* handle data only */
7015a1e09wpaul		return;
7115a1e09wpaul
722698777wollman	if (def->def_kind != DEF_CONST) {
732698777wollman		f_print(fout, "\n");
742698777wollman	}
752698777wollman	switch (def->def_kind) {
762698777wollman	case DEF_STRUCT:
772698777wollman		pstructdef(def);
782698777wollman		break;
792698777wollman	case DEF_UNION:
802698777wollman		puniondef(def);
812698777wollman		break;
822698777wollman	case DEF_ENUM:
832698777wollman		penumdef(def);
842698777wollman		break;
852698777wollman	case DEF_TYPEDEF:
862698777wollman		ptypedef(def);
872698777wollman		break;
882698777wollman	case DEF_PROGRAM:
89cd3615cstefanf		pprogramdef(def, headeronly);
902698777wollman		break;
912698777wollman	case DEF_CONST:
922698777wollman		pconstdef(def);
932698777wollman		break;
942698777wollman	}
952698777wollman	if (def->def_kind != DEF_PROGRAM && def->def_kind != DEF_CONST) {
9615a1e09wpaul	    storexdrfuncdecl(def->def_name,
9715a1e09wpaul			     def->def_kind != DEF_TYPEDEF ||
9815a1e09wpaul			     !isvectordef(def->def.ty.old_type,
9915a1e09wpaul					  def->def.ty.rel));
1002698777wollman	}
10115a1e09wpaul}
10215a1e09wpaul
10315a1e09wpaul
10415a1e09wpaulvoid
105cd3615cstefanfprint_funcdef(definition *def, int headeronly)
10615a1e09wpaul{
10715a1e09wpaul	switch (def->def_kind) {
10815a1e09wpaul	case DEF_PROGRAM:
1092698777wollman		f_print(fout, "\n");
110cd3615cstefanf		pprogramdef(def, headeronly);
11115a1e09wpaul		break;
112730964ejkh	default:
113d95d8b8alfred		break;
114730964ejkh	}
11515a1e09wpaul}
11615a1e09wpaul
11715a1e09wpaul/* store away enough information to allow the XDR functions to be spat
11815a1e09wpaul    out at the end of the file */
11915a1e09wpaul
12015a1e09wpaulvoid
1216a5a7b7dwmalonestorexdrfuncdecl(const char *name, int pointerp)
12215a1e09wpaul{
12315a1e09wpaul	xdrfunc * xdrptr;
12415a1e09wpaul
12526ad533charnier	xdrptr = XALLOC(struct xdrfunc);
12615a1e09wpaul
12715a1e09wpaul	xdrptr->name = name;
12815a1e09wpaul	xdrptr->pointerp = pointerp;
12915a1e09wpaul	xdrptr->next = NULL;
13015a1e09wpaul
13115a1e09wpaul	if (xdrfunc_tail == NULL){
13215a1e09wpaul		xdrfunc_head = xdrptr;
13315a1e09wpaul		xdrfunc_tail = xdrptr;
13415a1e09wpaul	} else {
13515a1e09wpaul		xdrfunc_tail->next = xdrptr;
13615a1e09wpaul		xdrfunc_tail = xdrptr;
1372698777wollman	}
13815a1e09wpaul
13915a1e09wpaul
1402698777wollman}
1412698777wollman
14215a1e09wpaulvoid
1436a5a7b7dwmaloneprint_xdr_func_def(const char *name, int pointerp)
14415a1e09wpaul{
1457f349d2stefanf	f_print(fout, "extern  bool_t xdr_%s(XDR *, %s%s);\n", name,
1467f349d2stefanf		name, pointerp ? "*" : "");
14715a1e09wpaul}
14815a1e09wpaul
14915a1e09wpaul
150730964ejkhstatic void
151b2f1332edpconstdef(definition *def)
1522698777wollman{
1532698777wollman	pdefine(def->def_name, def->def.co);
1542698777wollman}
1552698777wollman
15615a1e09wpaul/* print out the definitions for the arguments of functions in the
15715a1e09wpaul    header file
15815a1e09wpaul*/
159730964ejkhstatic void
1606a5a7b7dwmalonepargdef(definition *def)
16115a1e09wpaul{
16215a1e09wpaul	decl_list *l;
16315a1e09wpaul	version_list *vers;
16415a1e09wpaul	char *name;
16515a1e09wpaul	proc_list *plist;
16615a1e09wpaul
16715a1e09wpaul
16815a1e09wpaul	for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
16915a1e09wpaul			for (plist = vers->procs; plist != NULL;
17015a1e09wpaul			    plist = plist->next) {
17115a1e09wpaul
17215a1e09wpaul				if (!newstyle || plist->arg_num < 2) {
17315a1e09wpaul					continue; /* old style or single args */
17415a1e09wpaul				}
17515a1e09wpaul				name = plist->args.argname;
17615a1e09wpaul				f_print(fout, "struct %s {\n", name);
17715a1e09wpaul				for (l = plist->args.decls;
17815a1e09wpaul				    l != NULL; l = l->next) {
17915a1e09wpaul					pdeclaration(name, &l->decl, 1,
18015a1e09wpaul						     ";\n");
18115a1e09wpaul				}
18215a1e09wpaul				f_print(fout, "};\n");
18315a1e09wpaul				f_print(fout, "typedef struct %s %s;\n",
18415a1e09wpaul					name, name);
18515a1e09wpaul				storexdrfuncdecl(name, 1);
18615a1e09wpaul				f_print(fout, "\n");
18715a1e09wpaul			}
18815a1e09wpaul		}
18915a1e09wpaul}
19015a1e09wpaul
19115a1e09wpaul
192730964ejkhstatic void
1936a5a7b7dwmalonepstructdef(definition *def)
1942698777wollman{
1952698777wollman	decl_list *l;
1966a5a7b7dwmalone	const char *name = def->def_name;
1972698777wollman
1982698777wollman	f_print(fout, "struct %s {\n", name);
1992698777wollman	for (l = def->def.st.decls; l != NULL; l = l->next) {
20015a1e09wpaul		pdeclaration(name, &l->decl, 1, ";\n");
2012698777wollman	}
2022698777wollman	f_print(fout, "};\n");
2032698777wollman	f_print(fout, "typedef struct %s %s;\n", name, name);
2042698777wollman}
2052698777wollman
206730964ejkhstatic void
207b2f1332edpuniondef(definition *def)
2082698777wollman{
2092698777wollman	case_list *l;
2106a5a7b7dwmalone	const char *name = def->def_name;
2112698777wollman	declaration *decl;
2122698777wollman
2132698777wollman	f_print(fout, "struct %s {\n", name);
2142698777wollman	decl = &def->def.un.enum_decl;
2152698777wollman	if (streq(decl->type, "bool")) {
2162698777wollman		f_print(fout, "\tbool_t %s;\n", decl->name);
2172698777wollman	} else {
2182698777wollman		f_print(fout, "\t%s %s;\n", decl->type, decl->name);
2192698777wollman	}
2202698777wollman	f_print(fout, "\tunion {\n");
2212698777wollman	for (l = def->def.un.cases; l != NULL; l = l->next) {
22215a1e09wpaul	    if (l->contflag == 0)
22315a1e09wpaul		pdeclaration(name, &l->case_decl, 2, ";\n");
2242698777wollman	}
2252698777wollman	decl = def->def.un.default_decl;
2262698777wollman	if (decl && !streq(decl->type, "void")) {
22715a1e09wpaul		pdeclaration(name, decl, 2, ";\n");
2282698777wollman	}
2292698777wollman	f_print(fout, "\t} %s_u;\n", name);
2302698777wollman	f_print(fout, "};\n");
2312698777wollman	f_print(fout, "typedef struct %s %s;\n", name, name);
2322698777wollman}
2332698777wollman
234730964ejkhstatic void
2356a5a7b7dwmalonepdefine(const char *name, const char *num)
2362698777wollman{
23715a1e09wpaul	f_print(fout, "#define\t%s %s\n", name, num);
2382698777wollman}
2392698777wollman
240730964ejkhstatic void
2416a5a7b7dwmalonepuldefine(const char *name, const char *num)
2422698777wollman{
24315a1e09wpaul	f_print(fout, "#define\t%s ((unsigned long)(%s))\n", name, num);
2442698777wollman}
2452698777wollman
246730964ejkhstatic int
2476a5a7b7dwmalonedefine_printed(proc_list *stop, version_list *start)
2482698777wollman{
2492698777wollman	version_list *vers;
2502698777wollman	proc_list *proc;
2512698777wollman
2522698777wollman	for (vers = start; vers != NULL; vers = vers->next) {
2532698777wollman		for (proc = vers->procs; proc != NULL; proc = proc->next) {
2542698777wollman			if (proc == stop) {
2552698777wollman				return (0);
2562698777wollman			} else if (streq(proc->proc_name, stop->proc_name)) {
2572698777wollman				return (1);
2582698777wollman			}
2592698777wollman		}
2602698777wollman	}
2612698777wollman	abort();
2622698777wollman	/* NOTREACHED */
2632698777wollman}
2642698777wollman
265730964ejkhstatic void
2666a5a7b7dwmalonepfreeprocdef(const char * name, const char *vers)
26715a1e09wpaul{
26815a1e09wpaul	f_print(fout, "extern int ");
26915a1e09wpaul	pvname(name, vers);
2707f349d2stefanf	f_print(fout, "_freeresult(SVCXPRT *, xdrproc_t, caddr_t);\n");
27115a1e09wpaul}
2722698777wollman
273730964ejkhstatic void
2746a5a7b7dwmalonepdispatch(const char * name, const char *vers)
275ae8c4c5alfred{
276ae8c4c5alfred
277ae8c4c5alfred	f_print(fout, "void ");
278ae8c4c5alfred	pvname(name, vers);
279da5c69fstefanf	f_print(fout, "(struct svc_req *rqstp, SVCXPRT *transp);\n");
280ae8c4c5alfred}
281ae8c4c5alfred
282ae8c4c5alfredstatic void
283cd3615cstefanfpprogramdef(definition *def, int headeronly)
2842698777wollman{
2852698777wollman	version_list *vers;
2862698777wollman	proc_list *proc;
2876a5a7b7dwmalone	const char *ext;
28815a1e09wpaul
28915a1e09wpaul	pargdef(def);
2902698777wollman
2912698777wollman	puldefine(def->def_name, def->def.pr.prog_num);
2922698777wollman	for (vers = def->def.pr.versions; vers != NULL; vers = vers->next) {
29315a1e09wpaul		if (tblflag) {
29415a1e09wpaul			f_print(fout,
29515a1e09wpaul				"extern struct rpcgen_table %s_%s_table[];\n",
29615a1e09wpaul				locase(def->def_name), vers->vers_num);
29715a1e09wpaul			f_print(fout,
29815a1e09wpaul				"extern %s_%s_nproc;\n",
29915a1e09wpaul				locase(def->def_name), vers->vers_num);
30015a1e09wpaul		}
3012698777wollman		puldefine(vers->vers_name, vers->vers_num);
30215a1e09wpaul
3037f349d2stefanf		f_print(fout, "\n");
3047f349d2stefanf		ext = "extern  ";
3057f349d2stefanf		if (headeronly) {
3067f349d2stefanf			f_print(fout, "%s", ext);
3077f349d2stefanf			pdispatch(def->def_name, vers->vers_num);
3087f349d2stefanf		}
3097f349d2stefanf		for (proc = vers->procs; proc != NULL; proc = proc->next) {
3107f349d2stefanf			if (!define_printed(proc, def->def.pr.versions)) {
3117f349d2stefanf				puldefine(proc->proc_name, proc->proc_num);
3122698777wollman			}
3137f349d2stefanf			f_print(fout, "%s", ext);
3147f349d2stefanf			pprocdef(proc, vers, "CLIENT *", 0);
3157f349d2stefanf			f_print(fout, "%s", ext);
3167f349d2stefanf			pprocdef(proc, vers, "struct svc_req *", 1);
3172698777wollman		}
3187f349d2stefanf		pfreeprocdef(def->def_name, vers->vers_num);
3192698777wollman	}
3202698777wollman}
3212698777wollman
322730964ejkhstatic void
3236a5a7b7dwmalonepprocdef(proc_list *proc, version_list *vp, const char *addargtype, int server_p)
3242698777wollman{
32515a1e09wpaul	if (mtflag) {/* Print MT style stubs */
32615a1e09wpaul		if (server_p)
32715a1e09wpaul			f_print(fout, "bool_t ");
32815a1e09wpaul		else
32915a1e09wpaul			f_print(fout, "enum clnt_stat ");
33015a1e09wpaul	} else {
33115a1e09wpaul		ptype(proc->res_prefix, proc->res_type, 1);
33215a1e09wpaul		f_print(fout, "* ");
33315a1e09wpaul	}
33415a1e09wpaul	if (server_p)
33515a1e09wpaul		pvname_svc(proc->proc_name, vp->vers_num);
33615a1e09wpaul	else
33715a1e09wpaul		pvname(proc->proc_name, vp->vers_num);
33815a1e09wpaul
3397f349d2stefanf	parglist(proc, addargtype);
34015a1e09wpaul}
34115a1e09wpaul
34215a1e09wpaul
34315a1e09wpaul
34415a1e09wpaul/* print out argument list of procedure */
345730964ejkhstatic void
3466a5a7b7dwmaloneparglist(proc_list *proc, const char *addargtype)
34715a1e09wpaul{
34815a1e09wpaul	decl_list *dl;
34915a1e09wpaul
35015a1e09wpaul	f_print(fout, "(");
35115a1e09wpaul	if (proc->arg_num < 2 && newstyle &&
35215a1e09wpaul	    streq(proc->args.decls->decl.type, "void")) {
35315a1e09wpaul		/* 0 argument in new style:  do nothing*/
35415a1e09wpaul	}
35515a1e09wpaul	else {
35615a1e09wpaul		for (dl = proc->args.decls; dl != NULL; dl = dl->next) {
35715a1e09wpaul			ptype(dl->decl.prefix, dl->decl.type, 1);
35815a1e09wpaul			if (!newstyle)
35915a1e09wpaul				f_print(fout, "*");
36015a1e09wpaul			/* old style passes by reference */
36115a1e09wpaul			f_print(fout, ", ");
3622698777wollman		}
3632698777wollman	}
36415a1e09wpaul
36515a1e09wpaul	if (mtflag)  {
36615a1e09wpaul		ptype(proc->res_prefix, proc->res_type, 1);
36715a1e09wpaul		f_print(fout, "*, ");
3682698777wollman	}
36915a1e09wpaul
37015a1e09wpaul	f_print(fout, "%s);\n", addargtype);
37115a1e09wpaul
3722698777wollman}
3732698777wollman
374730964ejkhstatic void
375b2f1332edpenumdef(definition *def)
3762698777wollman{
3776a5a7b7dwmalone	const char *name = def->def_name;
3782698777wollman	enumval_list *l;
3796a5a7b7dwmalone	const char *last = NULL;
3802698777wollman	int count = 0;
3812698777wollman
3822698777wollman	f_print(fout, "enum %s {\n", name);
3832698777wollman	for (l = def->def.en.vals; l != NULL; l = l->next) {
3842698777wollman		f_print(fout, "\t%s", l->name);
3852698777wollman		if (l->assignment) {
3862698777wollman			f_print(fout, " = %s", l->assignment);
3872698777wollman			last = l->assignment;
3882698777wollman			count = 1;
3892698777wollman		} else {
3902698777wollman			if (last == NULL) {
3912698777wollman				f_print(fout, " = %d", count++);
3922698777wollman			} else {
3932698777wollman				f_print(fout, " = %s + %d", last, count++);
3942698777wollman			}
3952698777wollman		}
39615a1e09wpaul		if (l->next)
39715a1e09wpaul			f_print(fout, ",\n");
39815a1e09wpaul		else
39915a1e09wpaul			f_print(fout, "\n");
4002698777wollman	}
4012698777wollman	f_print(fout, "};\n");
4022698777wollman	f_print(fout, "typedef enum %s %s;\n", name, name);
4032698777wollman}
4042698777wollman
405730964ejkhstatic void
406b2f1332edptypedef(definition *def)
4072698777wollman{
4086a5a7b7dwmalone	const char *name = def->def_name;
4096a5a7b7dwmalone	const char *old = def->def.ty.old_type;
4102698777wollman	char prefix[8];	/* enough to contain "struct ", including NUL */
4112698777wollman	relation rel = def->def.ty.rel;
4122698777wollman
4132698777wollman
4142698777wollman	if (!streq(name, old)) {
4152698777wollman		if (streq(old, "string")) {
4162698777wollman			old = "char";
4172698777wollman			rel = REL_POINTER;
4182698777wollman		} else if (streq(old, "opaque")) {
4192698777wollman			old = "char";
4202698777wollman		} else if (streq(old, "bool")) {
4212698777wollman			old = "bool_t";
4222698777wollman		}
4232698777wollman		if (undefined2(old, name) && def->def.ty.old_prefix) {
4242698777wollman			s_print(prefix, "%s ", def->def.ty.old_prefix);
4252698777wollman		} else {
4262698777wollman			prefix[0] = 0;
4272698777wollman		}
4282698777wollman		f_print(fout, "typedef ");
4292698777wollman		switch (rel) {
4302698777wollman		case REL_ARRAY:
4312698777wollman			f_print(fout, "struct {\n");
4322698777wollman			f_print(fout, "\tu_int %s_len;\n", name);
4332698777wollman			f_print(fout, "\t%s%s *%s_val;\n", prefix, old, name);
4342698777wollman			f_print(fout, "} %s", name);
4352698777wollman			break;
4362698777wollman		case REL_POINTER:
4372698777wollman			f_print(fout, "%s%s *%s", prefix, old, name);
4382698777wollman			break;
4392698777wollman		case REL_VECTOR:
4402698777wollman			f_print(fout, "%s%s %s[%s]", prefix, old, name,
4412698777wollman				def->def.ty.array_max);
4422698777wollman			break;
4432698777wollman		case REL_ALIAS:
44415a1e09wpaul			f_print(fout, "%s%s %s", prefix, old, name);
4452698777wollman			break;
4462698777wollman		}
4472698777wollman		f_print(fout, ";\n");
4482698777wollman	}
4492698777wollman}
4502698777wollman
451730964ejkhvoid
4526a5a7b7dwmalonepdeclaration(const char *name, declaration *dec, int tab, const char *separator)
4532698777wollman{
4542698777wollman	char buf[8];	/* enough to hold "struct ", include NUL */
4556a5a7b7dwmalone	const char *prefix;
4566a5a7b7dwmalone	const char *type;
4572698777wollman
4582698777wollman	if (streq(dec->type, "void")) {
4592698777wollman		return;
4602698777wollman	}
4612698777wollman	tabify(fout, tab);
4622698777wollman	if (streq(dec->type, name) && !dec->prefix) {
4632698777wollman		f_print(fout, "struct ");
4642698777wollman	}
4652698777wollman	if (streq(dec->type, "string")) {
4662698777wollman		f_print(fout, "char *%s", dec->name);
4672698777wollman	} else {
4682698777wollman		prefix = "";
4692698777wollman		if (streq(dec->type, "bool")) {
4702698777wollman			type = "bool_t";
4712698777wollman		} else if (streq(dec->type, "opaque")) {
4722698777wollman			type = "char";
4732698777wollman		} else {
4742698777wollman			if (dec->prefix) {
4752698777wollman				s_print(buf, "%s ", dec->prefix);
4762698777wollman				prefix = buf;
4772698777wollman			}
4782698777wollman			type = dec->type;
4792698777wollman		}
4802698777wollman		switch (dec->rel) {
4812698777wollman		case REL_ALIAS:
4822698777wollman			f_print(fout, "%s%s %s", prefix, type, dec->name);
4832698777wollman			break;
4842698777wollman		case REL_VECTOR:
4852698777wollman			f_print(fout, "%s%s %s[%s]", prefix, type, dec->name,
4862698777wollman				dec->array_max);
4872698777wollman			break;
4882698777wollman		case REL_POINTER:
4892698777wollman			f_print(fout, "%s%s *%s", prefix, type, dec->name);
4902698777wollman			break;
4912698777wollman		case REL_ARRAY:
4922698777wollman			f_print(fout, "struct {\n");
4932698777wollman			tabify(fout, tab);
4942698777wollman			f_print(fout, "\tu_int %s_len;\n", dec->name);
4952698777wollman			tabify(fout, tab);
49615a1e09wpaul			f_print(fout,
49715a1e09wpaul				"\t%s%s *%s_val;\n", prefix, type, dec->name);
4982698777wollman			tabify(fout, tab);
4992698777wollman			f_print(fout, "} %s", dec->name);
5002698777wollman			break;
5012698777wollman		}
5022698777wollman	}
5032f470acbenl	fputs(separator, fout);
5042698777wollman}
5052698777wollman
506730964ejkhstatic int
5076a5a7b7dwmaloneundefined2(const char *type, const char *stop)
5082698777wollman{
5092698777wollman	list *l;
5102698777wollman	definition *def;
5112698777wollman
5122698777wollman	for (l = defined; l != NULL; l = l->next) {
5132698777wollman		def = (definition *) l->val;
5142698777wollman		if (def->def_kind != DEF_PROGRAM) {
5152698777wollman			if (streq(def->def_name, stop)) {
5162698777wollman				return (1);
5172698777wollman			} else if (streq(def->def_name, type)) {
5182698777wollman				return (0);
5192698777wollman			}
5202698777wollman		}
5212698777wollman	}
5222698777wollman	return (1);
5232698777wollman}
524