~ubuntu-branches/ubuntu/warty/ncbi-tools6/warty

« back to all changes in this revision

Viewing changes to object/objpubme.c

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2002-04-04 22:13:09 UTC
  • Revision ID: james.westby@ubuntu.com-20020404221309-vfze028rfnlrldct
Tags: upstream-6.1.20011220a
ImportĀ upstreamĀ versionĀ 6.1.20011220a

Show diffs side-by-side

added added

removed removed

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