|
|
1.1 root 1: /* ftamdocument.c - FTAM document database */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/ftam/RCS/ftamdocument.c,v 7.0 89/11/23 21:53:33 mrose Rel $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/ftam/RCS/ftamdocument.c,v 7.0 89/11/23 21:53:33 mrose Rel $
9: *
10: *
11: * $Log: ftamdocument.c,v $
12: * Revision 7.0 89/11/23 21:53:33 mrose
13: * Release 6.0
14: *
15: */
16:
17: /*
18: * NOTICE
19: *
20: * Acquisition, use, and distribution of this module and related
21: * materials are subject to the restrictions of a license agreement.
22: * Consult the Preface in the User's Manual for the full terms of
23: * this agreement.
24: *
25: */
26:
27:
28: /* LINTLIBRARY */
29:
30: #include <stdio.h>
31: #include "ftam.h"
32: #include "tailor.h"
33:
34: /* DATA */
35:
36: static char *isodocuments = "isodocuments";
37:
38: static FILE *servf = NULL;
39: static int stayopen = 0;
40:
41: static struct isodocument ids;
42:
43: /* */
44:
45: int setisodocument (f)
46: int f;
47: {
48: if (servf == NULL)
49: servf = fopen (isodefile (isodocuments, 0), "r");
50: else
51: rewind (servf);
52: stayopen |= f;
53:
54: return (servf != NULL);
55: }
56:
57:
58: int endisodocument () {
59: if (servf && !stayopen) {
60: (void) fclose (servf);
61: servf = NULL;
62: }
63:
64: return 1;
65: }
66:
67: /* */
68:
69: struct isodocument *getisodocument () {
70: register char *cp;
71: register struct isodocument *id = &ids;
72: static char buffer[BUFSIZ + 1];
73: static char *vec[NVEC + NSLACK + 1];
74:
75: if (servf == NULL
76: && (servf = fopen (isodefile (isodocuments, 0), "r")) == NULL)
77: return NULL;
78:
79: if (id -> id_type)
80: oid_free (id -> id_type);
81: if (id -> id_abstract)
82: oid_free (id -> id_abstract);
83: if (id -> id_transfer)
84: oid_free (id -> id_transfer);
85: if (id -> id_model)
86: oid_free (id -> id_model);
87: if (id -> id_constraint)
88: oid_free (id -> id_constraint);
89:
90: bzero ((char *) id, sizeof *id);
91:
92: while (fgets (buffer, sizeof buffer, servf) != NULL) {
93: if (*buffer == '#')
94: continue;
95: if (cp = index (buffer, '\n'))
96: *cp = NULL;
97: if (str2vec (buffer, vec) < 6)
98: continue;
99:
100: id -> id_entry = vec[0];
101:
102: if ((id -> id_type = str2oid (vec[1])) == NULLOID
103: || (id -> id_type = oid_cpy (id -> id_type)) == NULLOID)
104: continue;
105:
106: if ((id -> id_abstract = str2oid (vec[2])) == NULLOID
107: || (id -> id_abstract = oid_cpy (id -> id_abstract))
108: == NULLOID)
109: goto free1;
110:
111: if ((id -> id_transfer = str2oid (vec[3])) == NULLOID
112: || (id -> id_transfer = oid_cpy (id -> id_transfer))
113: == NULLOID)
114: goto free2;
115:
116: if ((id -> id_model = str2oid (vec[4])) == NULLOID
117: || (id -> id_model = oid_cpy (id -> id_model)) == NULLOID)
118: goto free3;
119:
120: if ((id -> id_constraint = str2oid (vec[5])) == NULLOID
121: || (id -> id_constraint = oid_cpy (id -> id_constraint))
122: == NULLOID) {
123: oid_free (id -> id_model);
124: id -> id_model = NULLOID;
125:
126: free3: ;
127: oid_free (id -> id_transfer);
128: id -> id_transfer = NULLOID;
129:
130: free2: ;
131: oid_free (id -> id_abstract);
132: id -> id_abstract = NULLOID;
133:
134: free1: ;
135: oid_free (id -> id_type);
136: id -> id_type = NULLOID;
137:
138: continue;
139: }
140:
141: return id;
142: }
143:
144: return NULL;
145: }
146:
147: /* */
148:
149: struct isodocument *getisodocumentbyentry (entry)
150: char *entry;
151: {
152: register struct isodocument *id;
153:
154: (void) setisodocument (0);
155: while (id = getisodocument ())
156: if (strcmp (id -> id_entry, entry) == 0)
157: break;
158: (void) endisodocument ();
159:
160: return id;
161: }
162:
163: /* */
164:
165: struct isodocument *getisodocumentbytype (type)
166: OID type;
167: {
168: register struct isodocument *id;
169:
170: (void) setisodocument (0);
171: while (id = getisodocument ())
172: if (oid_cmp (id -> id_type, type) == 0)
173: break;
174: (void) endisodocument ();
175:
176: return id;
177: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.