]> git.saurik.com Git - apple/security.git/blob - SecuritySNACCRuntime/compiler/core/exports.c
Security-54.tar.gz
[apple/security.git] / SecuritySNACCRuntime / compiler / core / exports.c
1 /*
2 * compiler/core/exports.c
3 *
4 * ExportElmt list set up during parse.
5 * (not kept in Module data struct)
6 *
7 * SetExports runs through type, value & macro defs and sets the
8 * exported flag accordingly.
9 *
10 * The exportsParsed boolean means whether the symbol "EXPORTS"
11 * was parsed - since if EXPORTS was parsed and the export list
12 * is empty, NOTHING is exported, otherwise if the "EXPORTS"
13 * symbol was not parsed (export list is empty) then EVERYTHING
14 * is exported. If "EXPORTS" was parsed and the list is not
15 * empty, then mark each item is the list as exported and the
16 * rest (that are not in the list) as not exported.
17 *
18 * Mike Sample
19 * 91/09/04
20 * Copyright (C) 1991, 1992 Michael Sample
21 * and the University of British Columbia
22 *
23 * This program is free software; you can redistribute it and/or modify
24 * it under the terms of the GNU General Public License as published by
25 * the Free Software Foundation; either version 2 of the License, or
26 * (at your option) any later version.
27 *
28 * $Header: /cvs/Darwin/Security/SecuritySNACCRuntime/compiler/core/exports.c,v 1.1 2001/06/20 21:27:56 dmitch Exp $
29 * $Log: exports.c,v $
30 * Revision 1.1 2001/06/20 21:27:56 dmitch
31 * Adding missing snacc compiler files.
32 *
33 * Revision 1.1.1.1 1999/03/16 18:06:48 aram
34 * Originals from SMIME Free Library.
35 *
36 * Revision 1.3 1995/07/25 19:41:27 rj
37 * changed `_' to `-' in file names.
38 *
39 * Revision 1.2 1994/09/01 00:33:28 rj
40 * snacc_config.h removed.
41 *
42 * Revision 1.1 1994/08/28 09:49:08 rj
43 * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.
44 *
45 */
46
47 #include <stdio.h>
48
49 #include "asn-incl.h"
50 #include "asn1module.h"
51 #include "snacc-util.h"
52 #include "exports.h"
53
54 /*
55 * called from main in snacc.c to set exported flags for
56 * typeDefs and valueDefs in the given module
57 */
58 void
59 SetExports PARAMS ((m, e, exportsParsed),
60 Module *m _AND_
61 ExportElmt *e _AND_
62 int exportsParsed)
63 {
64 TypeDef *td;
65 ValueDef *vd;
66
67 if (!exportsParsed) /* export everything */
68 {
69 /*
70 * set all typedefs', valuedefs' and macrodefs' exported flag
71 */
72 m->exportStatus = EXPORTS_ALL;
73 FOR_EACH_LIST_ELMT (td, m->typeDefs)
74 {
75 td->exported = TRUE;
76 }
77
78 FOR_EACH_LIST_ELMT (vd, m->valueDefs)
79 {
80 vd->exported = TRUE;
81 }
82 }
83 else /* EXPORTS sym parsed */
84 {
85 /* init every exports flag to false */
86 FOR_EACH_LIST_ELMT (td, m->typeDefs)
87 {
88 td->exported = FALSE;
89 }
90 FOR_EACH_LIST_ELMT (vd, m->valueDefs)
91 {
92 vd->exported = FALSE;
93 }
94
95 if (e == NULL) /* export nothing */
96 {
97 m->exportStatus = EXPORTS_NOTHING;
98 }
99 else /* just export types/values in export list */
100 {
101 m->exportStatus = EXPORTS_SOME;
102 for (; e != NULL; e = e->next)
103 {
104 if ((td = LookupType (m->typeDefs, e->name)) != NULL)
105 td->exported = TRUE;
106
107 else if ((vd = LookupValue (m->valueDefs, e->name)) != NULL)
108 vd->exported = TRUE;
109 else
110 {
111 PrintErrLoc (m->asn1SrcFileName, e->lineNo);
112 fprintf (stderr, "ERROR - exporting undefined type/value \"%s\"\n", e->name);
113 }
114 }
115 }
116 }
117 } /* SetExports */