1 #include <asn.h>
2
3 #define NLM_GENERATED_CODE_PROTO
4
5 #include <objmdrs.h>
6
7 static Boolean loaded = FALSE;
8
9 #include <asnmdrs.h>
10
11 #ifndef NLM_EXTERN_LOADS
12 #define NLM_EXTERN_LOADS {}
13 #endif
14
15 NLM_EXTERN Boolean LIBCALL
objmdrsAsnLoad(void)16 objmdrsAsnLoad(void)
17 {
18
19 if ( ! loaded) {
20 NLM_EXTERN_LOADS
21
22 if ( ! AsnLoad ())
23 return FALSE;
24 loaded = TRUE;
25 }
26
27 return TRUE;
28 }
29
30
31
32 /**************************************************
33 * Generated object loaders for Module NCBI-Medlars
34 * Generated using ASNCODE Revision: 5.2 at Jan 30, 1997 10:13 AM
35 *
36 **************************************************/
37
38
39 /**************************************************
40 *
41 * MedlarsEntryNew()
42 *
43 **************************************************/
44 NLM_EXTERN
45 MedlarsEntryPtr LIBCALL
MedlarsEntryNew(void)46 MedlarsEntryNew(void)
47 {
48 MedlarsEntryPtr ptr = MemNew((size_t) sizeof(MedlarsEntry));
49
50 return ptr;
51
52 }
53
54
55 /**************************************************
56 *
57 * MedlarsEntryFree()
58 *
59 **************************************************/
60 NLM_EXTERN
61 MedlarsEntryPtr LIBCALL
MedlarsEntryFree(MedlarsEntryPtr ptr)62 MedlarsEntryFree(MedlarsEntryPtr ptr)
63 {
64
65 if(ptr == NULL) {
66 return NULL;
67 }
68 AsnGenericUserSeqOfFree(ptr -> recs, (AsnOptFreeFunc) MedlarsRecordFree);
69 return MemFree(ptr);
70 }
71
72
73 /**************************************************
74 *
75 * MedlarsEntryAsnRead()
76 *
77 **************************************************/
78 NLM_EXTERN
79 MedlarsEntryPtr LIBCALL
MedlarsEntryAsnRead(AsnIoPtr aip,AsnTypePtr orig)80 MedlarsEntryAsnRead(AsnIoPtr aip, AsnTypePtr orig)
81 {
82 DataVal av;
83 AsnTypePtr atp;
84 Boolean isError = FALSE;
85 AsnReadFunc func;
86 MedlarsEntryPtr ptr;
87
88 if (! loaded)
89 {
90 if (! objmdrsAsnLoad()) {
91 return NULL;
92 }
93 }
94
95 if (aip == NULL) {
96 return NULL;
97 }
98
99 if (orig == NULL) { /* MedlarsEntry ::= (self contained) */
100 atp = AsnReadId(aip, amp, MEDLARS_ENTRY);
101 } else {
102 atp = AsnLinkType(orig, MEDLARS_ENTRY);
103 }
104 /* link in local tree */
105 if (atp == NULL) {
106 return NULL;
107 }
108
109 ptr = MedlarsEntryNew();
110 if (ptr == NULL) {
111 goto erret;
112 }
113 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
114 goto erret;
115 }
116
117 atp = AsnReadId(aip,amp, atp);
118 func = NULL;
119
120 if (atp == MEDLARS_ENTRY_pmid) {
121 if ( AsnReadVal(aip, atp, &av) <= 0) {
122 goto erret;
123 }
124 ptr -> pmid = av.intvalue;
125 atp = AsnReadId(aip,amp, atp);
126 }
127 if (atp == MEDLARS_ENTRY_muid) {
128 if ( AsnReadVal(aip, atp, &av) <= 0) {
129 goto erret;
130 }
131 ptr -> muid = av.intvalue;
132 atp = AsnReadId(aip,amp, atp);
133 }
134 if (atp == MEDLARS_ENTRY_recs) {
135 ptr -> recs = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) MedlarsRecordAsnRead, (AsnOptFreeFunc) MedlarsRecordFree);
136 if (isError && ptr -> recs == NULL) {
137 goto erret;
138 }
139 atp = AsnReadId(aip,amp, atp);
140 }
141
142 if (AsnReadVal(aip, atp, &av) <= 0) {
143 goto erret;
144 }
145 /* end struct */
146
147 ret:
148 AsnUnlinkType(orig); /* unlink local tree */
149 return ptr;
150
151 erret:
152 aip -> io_failure = TRUE;
153 ptr = MedlarsEntryFree(ptr);
154 goto ret;
155 }
156
157
158
159 /**************************************************
160 *
161 * MedlarsEntryAsnWrite()
162 *
163 **************************************************/
164 NLM_EXTERN Boolean LIBCALL
MedlarsEntryAsnWrite(MedlarsEntryPtr ptr,AsnIoPtr aip,AsnTypePtr orig)165 MedlarsEntryAsnWrite(MedlarsEntryPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
166 {
167 DataVal av;
168 AsnTypePtr atp;
169 Boolean retval = FALSE;
170
171 if (! loaded)
172 {
173 if (! objmdrsAsnLoad()) {
174 return FALSE;
175 }
176 }
177
178 if (aip == NULL) {
179 return FALSE;
180 }
181
182 atp = AsnLinkType(orig, MEDLARS_ENTRY); /* link local tree */
183 if (atp == NULL) {
184 return FALSE;
185 }
186
187 if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
188
189 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
190
191 if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
192 goto erret;
193 }
194
195 av.intvalue = ptr -> pmid;
196 retval = AsnWrite(aip, MEDLARS_ENTRY_pmid, &av);
197 av.intvalue = ptr -> muid;
198 retval = AsnWrite(aip, MEDLARS_ENTRY_muid, &av);
199 AsnGenericUserSeqOfAsnWrite(ptr -> recs, (AsnWriteFunc) MedlarsRecordAsnWrite, aip, MEDLARS_ENTRY_recs, MEDLARS_ENTRY_recs_E);
200 if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
201 goto erret;
202 }
203 retval = TRUE;
204
205 erret:
206 AsnUnlinkType(orig); /* unlink local tree */
207 return retval;
208 }
209
210
211
212 /**************************************************
213 *
214 * MedlarsRecordNew()
215 *
216 **************************************************/
217 NLM_EXTERN
218 MedlarsRecordPtr LIBCALL
MedlarsRecordNew(void)219 MedlarsRecordNew(void)
220 {
221 MedlarsRecordPtr ptr = MemNew((size_t) sizeof(MedlarsRecord));
222
223 return ptr;
224
225 }
226
227
228 /**************************************************
229 *
230 * MedlarsRecordFree()
231 *
232 **************************************************/
233 NLM_EXTERN
234 MedlarsRecordPtr LIBCALL
MedlarsRecordFree(MedlarsRecordPtr ptr)235 MedlarsRecordFree(MedlarsRecordPtr ptr)
236 {
237
238 if(ptr == NULL) {
239 return NULL;
240 }
241 MemFree(ptr -> abbr);
242 MemFree(ptr -> data);
243 return MemFree(ptr);
244 }
245
246
247 /**************************************************
248 *
249 * MedlarsRecordAsnRead()
250 *
251 **************************************************/
252 NLM_EXTERN
253 MedlarsRecordPtr LIBCALL
MedlarsRecordAsnRead(AsnIoPtr aip,AsnTypePtr orig)254 MedlarsRecordAsnRead(AsnIoPtr aip, AsnTypePtr orig)
255 {
256 DataVal av;
257 AsnTypePtr atp;
258 Boolean isError = FALSE;
259 AsnReadFunc func;
260 MedlarsRecordPtr ptr;
261
262 if (! loaded)
263 {
264 if (! objmdrsAsnLoad()) {
265 return NULL;
266 }
267 }
268
269 if (aip == NULL) {
270 return NULL;
271 }
272
273 if (orig == NULL) { /* MedlarsRecord ::= (self contained) */
274 atp = AsnReadId(aip, amp, MEDLARS_RECORD);
275 } else {
276 atp = AsnLinkType(orig, MEDLARS_RECORD);
277 }
278 /* link in local tree */
279 if (atp == NULL) {
280 return NULL;
281 }
282
283 ptr = MedlarsRecordNew();
284 if (ptr == NULL) {
285 goto erret;
286 }
287 if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
288 goto erret;
289 }
290
291 atp = AsnReadId(aip,amp, atp);
292 func = NULL;
293
294 if (atp == MEDLARS_RECORD_code) {
295 if ( AsnReadVal(aip, atp, &av) <= 0) {
296 goto erret;
297 }
298 ptr -> code = av.intvalue;
299 atp = AsnReadId(aip,amp, atp);
300 }
301 if (atp == MEDLARS_RECORD_abbr) {
302 if ( AsnReadVal(aip, atp, &av) <= 0) {
303 goto erret;
304 }
305 ptr -> abbr = av.ptrvalue;
306 atp = AsnReadId(aip,amp, atp);
307 }
308 if (atp == MEDLARS_RECORD_data) {
309 if ( AsnReadVal(aip, atp, &av) <= 0) {
310 goto erret;
311 }
312 ptr -> data = av.ptrvalue;
313 atp = AsnReadId(aip,amp, atp);
314 }
315
316 if (AsnReadVal(aip, atp, &av) <= 0) {
317 goto erret;
318 }
319 /* end struct */
320
321 ret:
322 AsnUnlinkType(orig); /* unlink local tree */
323 return ptr;
324
325 erret:
326 aip -> io_failure = TRUE;
327 ptr = MedlarsRecordFree(ptr);
328 goto ret;
329 }
330
331
332
333 /**************************************************
334 *
335 * MedlarsRecordAsnWrite()
336 *
337 **************************************************/
338 NLM_EXTERN Boolean LIBCALL
MedlarsRecordAsnWrite(MedlarsRecordPtr ptr,AsnIoPtr aip,AsnTypePtr orig)339 MedlarsRecordAsnWrite(MedlarsRecordPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
340 {
341 DataVal av;
342 AsnTypePtr atp;
343 Boolean retval = FALSE;
344
345 if (! loaded)
346 {
347 if (! objmdrsAsnLoad()) {
348 return FALSE;
349 }
350 }
351
352 if (aip == NULL) {
353 return FALSE;
354 }
355
356 atp = AsnLinkType(orig, MEDLARS_RECORD); /* link local tree */
357 if (atp == NULL) {
358 return FALSE;
359 }
360
361 if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
362
363 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
364
365 if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
366 goto erret;
367 }
368
369 av.intvalue = ptr -> code;
370 retval = AsnWrite(aip, MEDLARS_RECORD_code, &av);
371 if (ptr -> abbr != NULL) {
372 av.ptrvalue = ptr -> abbr;
373 retval = AsnWrite(aip, MEDLARS_RECORD_abbr, &av);
374 }
375 if (ptr -> data != NULL) {
376 av.ptrvalue = ptr -> data;
377 retval = AsnWrite(aip, MEDLARS_RECORD_data, &av);
378 }
379 if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
380 goto erret;
381 }
382 retval = TRUE;
383
384 erret:
385 AsnUnlinkType(orig); /* unlink local tree */
386 return retval;
387 }
388
389