1 /* objmedli.c
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * File Name: objmedli.c
27 *
28 * Author: James Ostell
29 *
30 * Version Creation Date: 1/1/91
31 *
32 * $Revision: 6.6 $
33 *
34 * File Description: Object manager for module NCBI-Medline
35 *
36 * Modifications:
37 * --------------------------------------------------------------------------
38 * Date Name Description of modification
39 * ------- ---------- -----------------------------------------------------
40 * 05-13-93 Schuler All public functions are now declared LIBCALL.
41 *
42 *
43 * $Log: objmedli.c,v $
44 * Revision 6.6 2015/10/23 00:04:24 kans
45 * NOIJRA Clear av DataVal variable on AsnWrite, needed for supporting Int8 integers in ASN.1
46 *
47 * Revision 6.5 2009/10/02 19:44:49 kans
48 * address clang static analyzer warnings
49 *
50 * Revision 6.4 1998/08/26 17:43:17 kans
51 * fixed -v -fd warnings in label functions
52 *
53 * Revision 6.3 1998/08/24 18:28:06 kans
54 * removed solaris -v -fd warnings
55 *
56 * Revision 6.2 1997/10/28 16:09:11 grisha
57 * fixed bug in function MedlineEntryAsnRead() to load status
58 *
59 * Revision 6.1 1997/09/03 12:55:56 ostell
60 * added support for MedlineEntry.status
61 *
62 * Revision 6.0 1997/08/25 18:50:13 madden
63 * Revision changed to 6.0
64 *
65 * Revision 4.9 1997/08/20 19:17:08 madden
66 * Version 6 of ASN.1
67 *
68 * Revision 4.8 1997/06/19 18:41:35 vakatov
69 * [WIN32,MSVC++] Adopted for the "NCBIOBJ.LIB" DLL'ization
70 *
71 * Revision 4.7 1996/08/14 20:57:32 grisha
72 * Check ASN.1 version. Write pub_type if version set to 0
73 *
74 * Revision 4.6 1996/08/12 14:07:21 grisha
75 * Generate pub_type if ASN.1 spec version >= 5
76 *
77 * Revision 4.5 1996/07/30 15:23:01 epstein
78 * correct logic errors for different spec_versions
79 *
80 * Revision 4.4 1996/07/24 16:35:54 ostell
81 * corrected AsnRead putting pub_type in gene slot.
82 *
83 * Revision 4.3 1996/05/20 19:43:50 ostell
84 * added pub_type
85 *
86 * Revision 4.2 1996/03/29 21:09:59 ostell
87 * added support for PubMedId
88 *
89 * Revision 4.1 1995/12/22 17:16:07 grisha
90 * add function MedlineSiFree(), because new Client/Server
91 * library for MedArch server needs this function
92 *
93 * Revision 4.0 1995/07/26 13:48:06 ostell
94 * force revision to 4.0
95 *
96 * Revision 3.5 1995/05/15 21:22:00 ostell
97 * added Log line
98 *
99 *
100 *
101 * ==========================================================================
102 */
103
104 #include <objmedli.h>
105 #include <asnmedli.h>
106 #include <objmgr.h>
107
108 static Boolean loaded = FALSE;
109
110 /*****************************************************************************
111 *
112 * MedlineEntry ObjMgr Routines
113 *
114 *****************************************************************************/
115 static CharPtr typename = "MedlineEntry";
116
MedlineEntryNewFunc(void)117 static Pointer LIBCALLBACK MedlineEntryNewFunc (void)
118 {
119 return (Pointer) MedlineEntryNew();
120 }
121
MedlineEntryFreeFunc(Pointer data)122 static Pointer LIBCALLBACK MedlineEntryFreeFunc (Pointer data)
123 {
124 return (Pointer) MedlineEntryFree ((MedlineEntryPtr) data);
125 }
126
MedlineEntryAsnWriteFunc(Pointer data,AsnIoPtr aip,AsnTypePtr atp)127 static Boolean LIBCALLBACK MedlineEntryAsnWriteFunc (Pointer data, AsnIoPtr aip, AsnTypePtr atp)
128 {
129 return MedlineEntryAsnWrite((MedlineEntryPtr)data, aip, atp);
130 }
131
MedlineEntryAsnReadFunc(AsnIoPtr aip,AsnTypePtr atp)132 static Pointer LIBCALLBACK MedlineEntryAsnReadFunc (AsnIoPtr aip, AsnTypePtr atp)
133 {
134 return (Pointer) MedlineEntryAsnRead (aip, atp);
135 }
136
MedlineEntryLabelFunc(Pointer data,CharPtr buffer,Int2 buflen,Uint1 content)137 static Int2 LIBCALLBACK MedlineEntryLabelFunc ( Pointer data, CharPtr buffer, Int2 buflen, Uint1 content)
138 {
139 Int2 rsult = 0;
140
141 switch (content)
142 {
143 case OM_LABEL_BOTH:
144 case OM_LABEL_CONTENT:
145 case OM_LABEL_SUMMARY:
146 case OM_LABEL_TYPE:
147 default:
148 rsult = LabelCopy(buffer, typename, buflen);
149 }
150 return rsult;
151 }
152
153 /*****************************************************************************
154 *
155 * Medline Object routines
156 *
157 *****************************************************************************/
158
159 /*****************************************************************************
160 *
161 * MedlineAsnLoad()
162 *
163 *****************************************************************************/
MedlineAsnLoad(void)164 NLM_EXTERN Boolean LIBCALL MedlineAsnLoad (void)
165 {
166 if (loaded)
167 return TRUE;
168 loaded = TRUE;
169
170 if (! GeneralAsnLoad())
171 {
172 loaded = FALSE;
173 return FALSE;
174 }
175 if (! BiblioAsnLoad())
176 {
177 loaded = FALSE;
178 return FALSE;
179 }
180 if (! AsnLoad())
181 {
182 loaded = FALSE;
183 return FALSE;
184 }
185
186 ObjMgrTypeLoad(OBJ_MEDLINE_ENTRY, "Medline-entry", typename, "MEDLINE entry",
187 MEDLINE_ENTRY, MedlineEntryNewFunc, MedlineEntryAsnReadFunc, MedlineEntryAsnWriteFunc,
188 MedlineEntryFreeFunc, MedlineEntryLabelFunc, NULL);
189
190 return TRUE;
191 }
192
193 /*****************************************************************************
194 *
195 * MedlineMeshNew()
196 *
197 *****************************************************************************/
MedlineMeshNew(void)198 NLM_EXTERN MedlineMeshPtr LIBCALL MedlineMeshNew (void)
199 {
200 MedlineMeshPtr mmp;
201
202 mmp = (MedlineMeshPtr)MemNew(sizeof(MedlineMesh));
203 return mmp;
204 }
205
206 /*****************************************************************************
207 *
208 * MedlineMeshFree()
209 *
210 *****************************************************************************/
MedlineMeshFree(MedlineMeshPtr mmp)211 NLM_EXTERN MedlineMeshPtr LIBCALL MedlineMeshFree (MedlineMeshPtr mmp)
212 {
213 if (mmp == NULL)
214 return mmp;
215
216 MemFree(mmp->term);
217 ValNodeFreeData(mmp->qual);
218
219 return (MedlineMeshPtr)MemFree(mmp);
220 }
221
222 /*****************************************************************************
223 *
224 * MedlineMeshAsnRead(aip, atp)
225 *
226 *****************************************************************************/
MedlineMeshAsnRead(AsnIoPtr aip,AsnTypePtr orig)227 NLM_EXTERN MedlineMeshPtr LIBCALL MedlineMeshAsnRead (AsnIoPtr aip, AsnTypePtr orig)
228 {
229 MedlineMeshPtr mmp=NULL;
230 DataVal av;
231 AsnTypePtr atp, oldatp;
232 ValNodePtr first, anp = NULL;
233
234 if (! loaded)
235 {
236 if (! MedlineAsnLoad())
237 return mmp;
238 }
239
240 if (aip == NULL)
241 return mmp;
242
243 if (orig == NULL) /* MedlineMesh ::= */
244 atp = AsnReadId(aip, amp, MEDLINE_MESH);
245 else
246 atp = AsnLinkType(orig, MEDLINE_MESH);
247 oldatp = atp;
248 if (atp == NULL)
249 return mmp;
250
251 mmp = MedlineMeshNew();
252 if (mmp == NULL) goto erret;
253
254 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the SEQUENCE */
255 first = NULL;
256 while ((atp = AsnReadId(aip, amp, atp)) != oldatp)
257 {
258 if (atp == NULL) goto erret;
259 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
260 if (atp == MEDLINE_MESH_qual) /* SET OF medline-qual */
261 {
262 while ((atp = AsnReadId(aip, amp, atp)) != MEDLINE_MESH_qual)
263 {
264 if (atp == NULL) goto erret;
265 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
266 if ((atp == MEDLINE_MESH_qual_E) && (av.intvalue == START_STRUCT))
267 {
268 anp = ValNodeNew(first);
269 if (anp == NULL) goto erret;
270 if (first == NULL)
271 first = anp;
272 }
273 else if (atp == MEDLINE_QUAL_mp)
274 anp->choice = (Uint1)av.boolvalue;
275 else if (atp == MEDLINE_QUAL_subh)
276 anp->data.ptrvalue = av.ptrvalue;
277 }
278 mmp->qual = first;
279 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end of SET OF */
280 }
281 else if (atp == MEDLINE_MESH_mp)
282 mmp->mp = av.boolvalue;
283 else if (atp == MEDLINE_MESH_term)
284 mmp->term = (CharPtr)av.ptrvalue;
285 }
286
287 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the END STRUCT */
288 ret:
289 AsnUnlinkType(orig);
290 return mmp;
291 erret:
292 mmp = MedlineMeshFree(mmp);
293 goto ret;
294 }
295
296 /*****************************************************************************
297 *
298 * MedlineMeshAsnWrite(mmp, aip, atp)
299 *
300 *****************************************************************************/
MedlineMeshAsnWrite(MedlineMeshPtr mmp,AsnIoPtr aip,AsnTypePtr orig)301 NLM_EXTERN Boolean LIBCALL MedlineMeshAsnWrite (MedlineMeshPtr mmp, AsnIoPtr aip, AsnTypePtr orig)
302 {
303 DataVal av;
304 AsnTypePtr atp;
305 ValNodePtr anp;
306 Boolean retval = FALSE;
307
308 if (! loaded)
309 {
310 if (! MedlineAsnLoad())
311 return FALSE;
312 }
313
314 if (aip == NULL)
315 return FALSE;
316
317 atp = AsnLinkType(orig, MEDLINE_MESH);
318 if (atp == NULL) return FALSE;
319
320 if (mmp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
321
322 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
323
324 if (! AsnOpenStruct(aip, atp, (Pointer)mmp)) goto erret;
325 if (mmp->mp)
326 {
327 av.boolvalue = TRUE;
328 if (! AsnWrite(aip, MEDLINE_MESH_mp, &av)) goto erret;
329 }
330 av.ptrvalue = mmp->term;
331 if (! AsnWrite(aip, MEDLINE_MESH_term, &av)) goto erret;
332 if (mmp->qual != NULL)
333 { /* start SET OF */
334 if (! AsnOpenStruct(aip, MEDLINE_MESH_qual, (Pointer)mmp->qual))
335 goto erret;
336 anp = mmp->qual;
337 while (anp != NULL)
338 {
339 if (! AsnOpenStruct(aip, MEDLINE_MESH_qual_E, (Pointer)anp))
340 goto erret;
341 if (anp->choice != 0)
342 {
343 av.boolvalue = TRUE;
344 if (! AsnWrite(aip, MEDLINE_QUAL_mp, &av)) goto erret;
345 }
346 av.ptrvalue = anp->data.ptrvalue;
347 if (! AsnWrite(aip, MEDLINE_QUAL_subh, &av)) goto erret;
348 if (! AsnCloseStruct(aip, MEDLINE_MESH_qual_E, (Pointer)anp))
349 goto erret;
350 anp = anp->next;
351 }
352 if (! AsnCloseStruct(aip, MEDLINE_MESH_qual, (Pointer)mmp->qual))
353 goto erret;
354 }
355
356 if (! AsnCloseStruct(aip, atp, (Pointer)mmp)) goto erret;
357 retval = TRUE;
358 erret:
359 AsnUnlinkType(orig);
360 return retval;
361 }
362
363 /*****************************************************************************
364 *
365 * MedlineRnNew()
366 *
367 *****************************************************************************/
MedlineRnNew(void)368 NLM_EXTERN MedlineRnPtr LIBCALL MedlineRnNew (void)
369 {
370 MedlineRnPtr mrp;
371
372 mrp = (MedlineRnPtr)MemNew(sizeof(MedlineRn));
373 return mrp;
374 }
375
376 /*****************************************************************************
377 *
378 * MedlineRnFree()
379 *
380 *****************************************************************************/
MedlineRnFree(MedlineRnPtr mrp)381 NLM_EXTERN MedlineRnPtr LIBCALL MedlineRnFree (MedlineRnPtr mrp)
382 {
383 if (mrp == NULL)
384 return mrp;
385
386 MemFree(mrp->cit);
387 MemFree(mrp->name);
388
389 return (MedlineRnPtr)MemFree(mrp);
390 }
391
392 /*****************************************************************************
393 *
394 * MedlineRnAsnRead(aip, atp)
395 *
396 *****************************************************************************/
MedlineRnAsnRead(AsnIoPtr aip,AsnTypePtr orig)397 NLM_EXTERN MedlineRnPtr LIBCALL MedlineRnAsnRead (AsnIoPtr aip, AsnTypePtr orig)
398 {
399 MedlineRnPtr mrp=NULL;
400 DataVal av;
401 AsnTypePtr atp;
402
403 if (! loaded)
404 {
405 if (! MedlineAsnLoad())
406 return mrp;
407 }
408
409 if (aip == NULL)
410 return mrp;
411
412 if (orig == NULL) /* MedlineRn ::= */
413 atp = AsnReadId(aip, amp, MEDLINE_RN);
414 else
415 atp = AsnLinkType(orig, MEDLINE_RN);
416 if (atp == NULL) return mrp;
417
418 mrp = MedlineRnNew();
419 if (mrp == NULL) goto erret;
420
421 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the SEQUENCE */
422 atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret; /* type */
423 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
424 mrp->type = (Uint1)av.intvalue;
425 atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret;
426 if (atp == MEDLINE_RN_cit)
427 {
428 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
429 mrp->cit = (CharPtr)av.ptrvalue;
430 atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret;
431 }
432 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
433 mrp->name = (CharPtr)av.ptrvalue;
434
435 atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret;
436 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the END STRUCT */
437 ret:
438 AsnUnlinkType(orig);
439 return mrp;
440 erret:
441 mrp = MedlineRnFree(mrp);
442 goto ret;
443 }
444
445 /*****************************************************************************
446 *
447 * MedlineRnAsnWrite(mrp, aip, atp)
448 *
449 *****************************************************************************/
MedlineRnAsnWrite(MedlineRnPtr mrp,AsnIoPtr aip,AsnTypePtr orig)450 NLM_EXTERN Boolean LIBCALL MedlineRnAsnWrite (MedlineRnPtr mrp, AsnIoPtr aip, AsnTypePtr orig)
451 {
452 DataVal av;
453 AsnTypePtr atp;
454 Boolean retval = TRUE;
455
456 if (! loaded)
457 {
458 if (! MedlineAsnLoad())
459 return FALSE;
460 }
461
462 if (aip == NULL)
463 return FALSE;
464
465 atp = AsnLinkType(orig, MEDLINE_RN);
466 if (atp == NULL) return FALSE;
467
468 if (mrp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
469
470 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
471
472 if (! AsnOpenStruct(aip, atp, (Pointer)mrp)) goto erret;
473 av.intvalue = (Int4)mrp->type;
474 if (! AsnWrite(aip, MEDLINE_RN_type, &av)) goto erret;
475 if (mrp->cit != NULL)
476 {
477 av.ptrvalue = mrp->cit;
478 if (! AsnWrite(aip, MEDLINE_RN_cit, &av)) goto erret;
479 }
480 av.ptrvalue = mrp->name;
481 if (! AsnWrite(aip, MEDLINE_RN_name, &av)) goto erret;
482 if (! AsnCloseStruct(aip, atp, (Pointer)mrp)) goto erret;
483 retval = TRUE;
484 erret:
485 AsnUnlinkType(orig);
486 return retval;
487 }
488
489 /*****************************************************************************
490 *
491 * MedlineSiFree(msp)
492 *
493 *****************************************************************************/
MedlineSiFree(ValNodePtr msp)494 NLM_EXTERN ValNodePtr LIBCALL MedlineSiFree (ValNodePtr msp)
495 {
496 if (msp != NULL)
497 {
498 MemFree (msp->data.ptrvalue);
499 MemFree (msp);
500 }
501
502 return NULL;
503 }
504
505 /*****************************************************************************
506 *
507 * MedlineSiAsnRead(aip, atp)
508 *
509 *****************************************************************************/
MedlineSiAsnRead(AsnIoPtr aip,AsnTypePtr orig)510 NLM_EXTERN ValNodePtr LIBCALL MedlineSiAsnRead (AsnIoPtr aip, AsnTypePtr orig)
511 {
512 ValNodePtr msp=NULL;
513 DataVal av;
514 AsnTypePtr atp;
515
516 if (! loaded)
517 {
518 if (! MedlineAsnLoad())
519 return msp;
520 }
521
522 if (aip == NULL)
523 return msp;
524
525 if (orig == NULL) /* MedlineSi ::= */
526 atp = AsnReadId(aip, amp, MEDLINE_SI);
527 else
528 atp = AsnLinkType(orig, MEDLINE_SI);
529 if (atp == NULL) return msp;
530
531 msp = ValNodeNew(NULL);
532 if (msp == NULL) goto erret;
533
534 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the SEQUENCE */
535 atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret; /* type */
536 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
537 msp->choice = (Uint1)av.intvalue;
538 atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret;
539 if (atp == MEDLINE_SI_cit)
540 {
541 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
542 msp->data.ptrvalue = av.ptrvalue;
543 atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret;
544 }
545 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end struct */
546 ret:
547 AsnUnlinkType(orig);
548 return msp;
549 erret:
550 msp = ValNodeFreeData(msp);
551 goto ret;
552 }
553
554 /*****************************************************************************
555 *
556 * MedlineSiAsnWrite(msp, aip, atp)
557 *
558 *****************************************************************************/
MedlineSiAsnWrite(ValNodePtr msp,AsnIoPtr aip,AsnTypePtr orig)559 NLM_EXTERN Boolean LIBCALL MedlineSiAsnWrite (ValNodePtr msp, AsnIoPtr aip, AsnTypePtr orig)
560 {
561 DataVal av;
562 AsnTypePtr atp;
563 Boolean retval = FALSE;
564
565 if (! loaded)
566 {
567 if (! MedlineAsnLoad())
568 return FALSE;
569 }
570
571 if (aip == NULL)
572 return FALSE;
573
574 atp = AsnLinkType(orig, MEDLINE_SI);
575 if (atp == NULL) return FALSE;
576
577 if (msp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
578
579 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
580
581 if (! AsnOpenStruct(aip, atp, (Pointer)msp)) goto erret;
582 av.intvalue = (Int4)msp->choice;
583 if (! AsnWrite(aip, MEDLINE_SI_type, &av)) goto erret;
584 if (msp->data.ptrvalue != NULL)
585 {
586 av.ptrvalue = msp->data.ptrvalue;
587 if (! AsnWrite(aip, MEDLINE_SI_cit, &av)) goto erret;
588 }
589 if (! AsnCloseStruct(aip, atp, (Pointer)msp)) goto erret;
590 retval = TRUE;
591 erret:
592 AsnUnlinkType(orig);
593 return retval;
594 }
595
596 /*****************************************************************************
597 *
598 * MedlineEntryNew()
599 *
600 *****************************************************************************/
MedlineEntryNew(void)601 NLM_EXTERN MedlineEntryPtr LIBCALL MedlineEntryNew (void)
602 {
603 MedlineEntryPtr mep;
604
605 mep = (MedlineEntryPtr)MemNew(sizeof(MedlineEntry));
606 return mep;
607 }
608
609 /*****************************************************************************
610 *
611 * MedlineEntryFree()
612 *
613 *****************************************************************************/
MedlineEntryFree(MedlineEntryPtr mep)614 NLM_EXTERN MedlineEntryPtr LIBCALL MedlineEntryFree (MedlineEntryPtr mep)
615 {
616 MedlineMeshPtr mmp, mmpnext;
617 MedlineRnPtr mrp, mrpnext;
618 MedlineFieldPtr mfp, mfpnext;
619
620 if (mep == NULL)
621 return mep;
622
623 DateFree(mep->em);
624 CitArtFree(mep->cit);
625 MemFree(mep->abstract);
626 mmp = mep->mesh;
627 while (mmp != NULL)
628 {
629 mmpnext = mmp->next;
630 MedlineMeshFree(mmp);
631 mmp = mmpnext;
632 }
633 mrp = mep->substance;
634 while (mrp != NULL)
635 {
636 mrpnext = mrp->next;
637 MedlineRnFree(mrp);
638 mrp = mrpnext;
639 }
640 ValNodeFreeData(mep->xref);
641 ValNodeFreeData(mep->idnum);
642 ValNodeFreeData(mep->gene);
643 ValNodeFreeData(mep->pub_type);
644 for (mfp = mep->mlfield; mfp != NULL; mfp = mfpnext)
645 {
646 mfpnext = mfp->next;
647 MedlineFieldFree(mfp);
648 }
649
650 ObjMgrDelete(OBJ_MEDLINE_ENTRY, (Pointer)mep);
651
652 return (MedlineEntryPtr)MemFree(mep);
653 }
654
655 /*****************************************************************************
656 *
657 * MedlineEntryAsnRead(aip, atp)
658 *
659 *****************************************************************************/
MedlineEntryAsnRead(AsnIoPtr aip,AsnTypePtr orig)660 NLM_EXTERN MedlineEntryPtr LIBCALL MedlineEntryAsnRead (AsnIoPtr aip, AsnTypePtr orig)
661 {
662 MedlineEntryPtr mep=NULL;
663 DataVal av;
664 AsnTypePtr atp, oldatp;
665 MedlineMeshPtr mmp, mmplast;
666 MedlineRnPtr mrp, mrplast;
667 MedlineFieldPtr mfp, mfplast;
668 ValNodePtr anp, anplast;
669
670 if (! loaded)
671 {
672 if (! MedlineAsnLoad())
673 return mep;
674 }
675
676 if (aip == NULL)
677 return mep;
678
679 if (orig == NULL) /* MedlineEntry ::= */
680 atp = AsnReadId(aip, amp, MEDLINE_ENTRY);
681 else
682 atp = AsnLinkType(orig, MEDLINE_ENTRY);
683 oldatp = atp;
684 if (atp == NULL) return mep;
685
686 mep = MedlineEntryNew();
687 if (mep == NULL) goto erret;
688
689 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the SEQUENCE */
690 atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret; /* uid */
691 if (atp == MEDLINE_ENTRY_uid) /* but now its optional */
692 {
693 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
694 mep->uid = av.intvalue;
695 atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret; /* entry month */
696 }
697 mep->em = DateAsnRead(aip, atp);
698 if (mep->em == NULL) goto erret;
699 atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret; /* citation */
700 mep->cit = CitArtAsnRead(aip, atp);
701 if (mep->cit == NULL) goto erret;
702 while ((atp = AsnReadId(aip, amp, atp)) != oldatp)
703 {
704 if (atp == NULL) goto erret;
705 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
706 if (atp == MEDLINE_ENTRY_abstract)
707 {
708 mep->abstract = (CharPtr)av.ptrvalue;
709 }
710 else if (atp == MEDLINE_ENTRY_pmid)
711 {
712 mep->pmid = av.intvalue;
713 }
714 else if (atp == MEDLINE_ENTRY_mesh)
715 {
716 mmplast = NULL;
717 while ((atp = AsnReadId(aip, amp, atp)) != MEDLINE_ENTRY_mesh)
718 {
719 if (atp == NULL) goto erret;
720 mmp = MedlineMeshAsnRead(aip, atp);
721 if (mmp == NULL) goto erret;
722 if (mmplast == NULL)
723 mep->mesh = mmp;
724 else
725 mmplast->next = mmp;
726 mmplast = mmp;
727 }
728 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end of SET OF */
729 }
730 else if (atp == MEDLINE_ENTRY_substance)
731 {
732 mrplast = NULL;
733 while ((atp = AsnReadId(aip, amp, atp)) != MEDLINE_ENTRY_substance)
734 {
735 if (atp == NULL) goto erret;
736 mrp = MedlineRnAsnRead(aip, atp);
737 if (mrp == NULL) goto erret;
738 if (mrplast == NULL)
739 mep->substance = mrp;
740 else
741 mrplast->next = mrp;
742 mrplast = mrp;
743 }
744 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end SET OF */
745 }
746 else if (atp == MEDLINE_ENTRY_xref)
747 {
748 anplast = NULL;
749 while ((atp = AsnReadId(aip, amp, atp)) == MEDLINE_ENTRY_xref_E)
750 {
751 anp = MedlineSiAsnRead(aip, atp);
752 if (anp == NULL) goto erret;
753 if (mep->xref == NULL)
754 mep->xref = anp;
755 else if (anplast != NULL)
756 anplast->next = anp;
757 anplast = anp;
758 }
759 if (atp == NULL) goto erret;
760 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
761 }
762 else if (atp == MEDLINE_ENTRY_idnum)
763 {
764 anp = NULL;
765 while ((atp = AsnReadId(aip, amp, atp)) != MEDLINE_ENTRY_idnum)
766 {
767 if (atp == NULL) goto erret;
768 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
769 anp = ValNodeNew(anp);
770 if (anp == NULL) goto erret;
771 if (mep->idnum == NULL)
772 mep->idnum = anp;
773 anp->data.ptrvalue = av.ptrvalue; /* VisibleString */
774 }
775 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end SET OF */
776 }
777 else if (atp == MEDLINE_ENTRY_gene)
778 {
779 anp = NULL;
780 while ((atp = AsnReadId(aip, amp, atp)) != MEDLINE_ENTRY_gene)
781 {
782 if (atp == NULL) goto erret;
783 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
784 anp = ValNodeNew(anp);
785 if (anp == NULL) goto erret;
786 if (mep->gene == NULL)
787 mep->gene = anp;
788 anp->data.ptrvalue = av.ptrvalue; /* VisibleString */
789 }
790 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end SET OF */
791 }
792 else if (atp == MEDLINE_ENTRY_pub_type)
793 {
794 anp = NULL;
795 while ((atp = AsnReadId(aip, amp, atp)) != MEDLINE_ENTRY_pub_type)
796 {
797 if (atp == NULL) goto erret;
798 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
799 anp = ValNodeNew(anp);
800 if (anp == NULL) goto erret;
801 if (mep->pub_type == NULL)
802 mep->pub_type = anp;
803 anp->data.ptrvalue = av.ptrvalue; /* VisibleString */
804 }
805 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end SET OF */
806 }
807 else if (atp == MEDLINE_ENTRY_mlfield)
808 {
809 mfplast = NULL;
810 while ((atp = AsnReadId(aip, amp, atp)) != MEDLINE_ENTRY_mlfield)
811 {
812 if (atp == NULL) goto erret;
813 mfp = MedlineFieldAsnRead(aip, atp);
814 if (mfp == NULL) goto erret;
815 if (mfplast == NULL)
816 mep->mlfield = mfp;
817 else
818 mfplast->next = mfp;
819 mfplast = mfp;
820 }
821 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end of SET OF */
822 }
823 else if (atp == MEDLINE_ENTRY_status)
824 {
825 mep->status = (Uint1)(av.intvalue);
826 }
827 }
828
829 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the END STRUCT */
830 ret:
831 AsnUnlinkType(orig);
832 return mep;
833 erret:
834 mep = MedlineEntryFree(mep);
835 goto ret;
836 }
837
838 /*****************************************************************************
839 *
840 * MedlineEntryAsnWrite(mep, aip, atp)
841 *
842 *****************************************************************************/
MedlineEntryAsnWrite(MedlineEntryPtr mep,AsnIoPtr aip,AsnTypePtr orig)843 NLM_EXTERN Boolean LIBCALL MedlineEntryAsnWrite (MedlineEntryPtr mep, AsnIoPtr aip, AsnTypePtr orig)
844 {
845 DataVal av;
846 AsnTypePtr atp;
847 MedlineMeshPtr mmp;
848 MedlineRnPtr mrp;
849 MedlineFieldPtr mfp;
850 ValNodePtr anp;
851 Boolean retval = FALSE, writemuid = FALSE;
852
853 if (! loaded)
854 {
855 if (! MedlineAsnLoad())
856 return FALSE;
857 }
858
859 if (aip == NULL)
860 return FALSE;
861
862 atp = AsnLinkType(orig, MEDLINE_ENTRY);
863 if (atp == NULL) return FALSE;
864
865 if (mep == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
866
867 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
868
869 if (! AsnOpenStruct(aip, atp, (Pointer)mep)) goto erret;
870
871 if (mep->uid > 0) /* now it is optional */
872 {
873 writemuid = TRUE;
874 }
875 else if (aip->spec_version > 0 && aip->spec_version < 5)
876 {
877 ErrPostEx(SEV_ERROR,0,0,"ASN4: MUID=0 written");
878 writemuid = TRUE;
879 }
880
881 if (writemuid)
882 {
883 av.intvalue = mep->uid;
884 if (! AsnWrite(aip, MEDLINE_ENTRY_uid, &av)) goto erret;
885 }
886 if (! DateAsnWrite(mep->em, aip, MEDLINE_ENTRY_em)) goto erret;
887 if (! CitArtAsnWrite(mep->cit, aip, MEDLINE_ENTRY_cit)) goto erret;
888 if (mep->abstract != NULL)
889 {
890 av.ptrvalue = mep->abstract;
891 if (! AsnWrite(aip, MEDLINE_ENTRY_abstract, &av)) goto erret;
892 }
893 if (mep->mesh != NULL)
894 {
895 if (! AsnOpenStruct(aip, MEDLINE_ENTRY_mesh, (Pointer)mep->mesh))
896 goto erret;
897 mmp = mep->mesh;
898 while (mmp != NULL)
899 {
900 if (! MedlineMeshAsnWrite(mmp, aip, MEDLINE_ENTRY_mesh_E))
901 goto erret;
902 mmp = mmp->next;
903 }
904 if (! AsnCloseStruct(aip, MEDLINE_ENTRY_mesh, (Pointer)mep->mesh))
905 goto erret;
906 }
907 if (mep->substance != NULL)
908 {
909 if (! AsnOpenStruct(aip, MEDLINE_ENTRY_substance, (Pointer)mep->substance))
910 goto erret;
911 mrp = mep->substance;
912 while (mrp != NULL)
913 {
914 if (! MedlineRnAsnWrite(mrp, aip, MEDLINE_ENTRY_substance_E))
915 goto erret;
916 mrp = mrp->next;
917 }
918 if (! AsnCloseStruct(aip, MEDLINE_ENTRY_substance, (Pointer)mep->substance))
919 goto erret;
920 }
921 if (mep->xref != NULL)
922 {
923 if (! AsnOpenStruct(aip, MEDLINE_ENTRY_xref, (Pointer)mep->xref))
924 goto erret;
925 anp = mep->xref;
926 while (anp != NULL)
927 {
928 if (! MedlineSiAsnWrite(anp, aip, MEDLINE_ENTRY_xref_E))
929 goto erret;
930 anp = anp->next;
931 }
932 if (! AsnCloseStruct(aip, MEDLINE_ENTRY_xref, (Pointer)mep->xref))
933 goto erret;
934 }
935 if (mep->idnum != NULL)
936 {
937 if (! AsnOpenStruct(aip, MEDLINE_ENTRY_idnum, (Pointer)mep->idnum))
938 goto erret;
939 anp = mep->idnum;
940 while (anp != NULL)
941 {
942 av.ptrvalue = anp->data.ptrvalue;
943 if (! AsnWrite(aip, MEDLINE_ENTRY_idnum_E, &av)) goto erret;
944 anp = anp->next;
945 }
946 if (! AsnCloseStruct(aip, MEDLINE_ENTRY_idnum, (Pointer)mep->idnum))
947 goto erret;
948 }
949 if (mep->gene != NULL)
950 {
951 if (! AsnOpenStruct(aip, MEDLINE_ENTRY_gene, (Pointer)mep->gene))
952 goto erret;
953 anp = mep->gene;
954 while (anp != NULL)
955 {
956 av.ptrvalue = anp->data.ptrvalue;
957 if (! AsnWrite(aip, MEDLINE_ENTRY_gene_E, &av)) goto erret;
958 anp = anp->next;
959 }
960 if (! AsnCloseStruct(aip, MEDLINE_ENTRY_gene, (Pointer)mep->gene))
961 goto erret;
962 }
963 if (mep->pmid > 0) /* PubMedId */
964 {
965 if (aip->spec_version > 0 && aip->spec_version < 5) /* ASN4 strip new value */
966 {
967 ErrPostEx(SEV_ERROR,0,0,"ASN4: PubMedId stripped");
968 }
969 else
970 {
971 av.intvalue = mep->pmid;
972 if (! AsnWrite(aip, MEDLINE_ENTRY_pmid, &av)) goto erret;
973 }
974 }
975
976 if ( mep->pub_type != NULL
977 && (aip->spec_version >= 5 || aip->spec_version == 0) ) {
978 if (! AsnOpenStruct(aip, MEDLINE_ENTRY_pub_type, (Pointer)mep->pub_type))
979 goto erret;
980 anp = mep->pub_type;
981 while (anp != NULL)
982 {
983 av.ptrvalue = anp->data.ptrvalue;
984 if (! AsnWrite(aip, MEDLINE_ENTRY_pub_type_E, &av)) goto erret;
985 anp = anp->next;
986 }
987 if (! AsnCloseStruct(aip, MEDLINE_ENTRY_pub_type, (Pointer)mep->pub_type))
988 goto erret;
989 }
990
991 if ( mep->mlfield != NULL
992 && (aip->spec_version >= 6 || aip->spec_version == 0) ) {
993 if (! AsnOpenStruct(aip, MEDLINE_ENTRY_mlfield, (Pointer)mep->mlfield))
994 goto erret;
995 mfp = mep->mlfield;
996 while (mfp != NULL)
997 {
998 if (! MedlineFieldAsnWrite(mfp, aip, MEDLINE_ENTRY_mlfield_E))
999 goto erret;
1000 mfp = mfp->next;
1001 }
1002 if (! AsnCloseStruct(aip, MEDLINE_ENTRY_mlfield, (Pointer)mep->mlfield))
1003 goto erret;
1004 }
1005
1006 if (mep->status > 0) /* medline processing status level */
1007 {
1008 if ((aip->spec_version == 0) || (aip->spec_version >= 6))
1009 {
1010 av.intvalue = (Int4)(mep->status);
1011 if (! AsnWrite(aip, MEDLINE_ENTRY_status, &av)) goto erret;
1012 }
1013 }
1014
1015 if (! AsnCloseStruct(aip, atp, (Pointer)mep)) goto erret;
1016 retval = TRUE;
1017 erret:
1018 AsnUnlinkType(orig);
1019 return retval;
1020 }
1021
1022 /*****************************************************************************
1023 *
1024 * MedlineFieldNew()
1025 *
1026 *****************************************************************************/
MedlineFieldNew(void)1027 NLM_EXTERN MedlineFieldPtr LIBCALL MedlineFieldNew (void)
1028 {
1029 MedlineFieldPtr mfp;
1030
1031 mfp = (MedlineFieldPtr)MemNew(sizeof(MedlineField));
1032 return mfp;
1033 }
1034
1035 /*****************************************************************************
1036 *
1037 * MedlineFieldFree()
1038 *
1039 *****************************************************************************/
MedlineFieldFree(MedlineFieldPtr mfp)1040 NLM_EXTERN MedlineFieldPtr LIBCALL MedlineFieldFree (MedlineFieldPtr mfp)
1041 {
1042 DocRefPtr dfp, next;
1043 if (mfp == NULL)
1044 return mfp;
1045
1046 MemFree(mfp->str);
1047 for (dfp = mfp->ids; dfp != NULL; dfp = next)
1048 {
1049 next = dfp->next;
1050 DocRefFree(dfp);
1051 }
1052
1053 return (MedlineFieldPtr)MemFree(mfp);
1054 }
1055
1056 /*****************************************************************************
1057 *
1058 * MedlineFieldAsnRead(aip, atp)
1059 *
1060 *****************************************************************************/
MedlineFieldAsnRead(AsnIoPtr aip,AsnTypePtr orig)1061 NLM_EXTERN MedlineFieldPtr LIBCALL MedlineFieldAsnRead (AsnIoPtr aip, AsnTypePtr orig)
1062 {
1063 MedlineFieldPtr mfp=NULL;
1064 DataVal av;
1065 AsnTypePtr atp, oldatp;
1066 DocRefPtr drp, prev = NULL;
1067
1068 if (! loaded)
1069 {
1070 if (! MedlineAsnLoad())
1071 return mfp;
1072 }
1073
1074 if (aip == NULL)
1075 return mfp;
1076
1077 if (orig == NULL) /* MedlineField ::= */
1078 atp = AsnReadId(aip, amp, MEDLINE_FIELD);
1079 else
1080 atp = AsnLinkType(orig, MEDLINE_FIELD);
1081 if (atp == NULL) return mfp;
1082 oldatp = atp;
1083
1084 mfp = MedlineFieldNew();
1085 if (mfp == NULL) goto erret;
1086
1087 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the SEQUENCE */
1088 atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret; /* type */
1089 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
1090 mfp->type = (Uint1)av.intvalue;
1091 atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret;
1092 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
1093 mfp->str = (CharPtr)av.ptrvalue;
1094
1095 while ((atp = AsnReadId(aip, amp, atp)) != oldatp)
1096 {
1097 if (atp == NULL) goto erret;
1098 if (atp == MEDLINE_FIELD_ids_E)
1099 {
1100 drp = DocRefAsnRead(aip, atp);
1101 if (prev == NULL)
1102 mfp->ids = drp;
1103 else
1104 prev->next = drp;
1105 prev = drp;
1106 }
1107 else
1108 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
1109 }
1110 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the END STRUCT */
1111 ret:
1112 AsnUnlinkType(orig);
1113 return mfp;
1114 erret:
1115 mfp = MedlineFieldFree(mfp);
1116 goto ret;
1117 }
1118
1119 /*****************************************************************************
1120 *
1121 * MedlineFieldAsnWrite(mfp, aip, atp)
1122 *
1123 *****************************************************************************/
MedlineFieldAsnWrite(MedlineFieldPtr mfp,AsnIoPtr aip,AsnTypePtr orig)1124 NLM_EXTERN Boolean LIBCALL MedlineFieldAsnWrite (MedlineFieldPtr mfp, AsnIoPtr aip, AsnTypePtr orig)
1125 {
1126 DataVal av;
1127 AsnTypePtr atp;
1128 Boolean retval = TRUE;
1129 DocRefPtr drp;
1130
1131 if (! loaded)
1132 {
1133 if (! MedlineAsnLoad())
1134 return FALSE;
1135 }
1136
1137 if (aip == NULL)
1138 return FALSE;
1139
1140 atp = AsnLinkType(orig, MEDLINE_FIELD);
1141 if (atp == NULL) return FALSE;
1142
1143 if (mfp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1144
1145 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
1146
1147 if (! AsnOpenStruct(aip, atp, (Pointer)mfp)) goto erret;
1148 av.intvalue = (Int4)mfp->type;
1149 if (! AsnWrite(aip, MEDLINE_FIELD_type, &av)) goto erret;
1150 av.ptrvalue = mfp->str;
1151 if (! AsnWrite(aip, MEDLINE_FIELD_str, &av)) goto erret;
1152 if (mfp->ids != NULL)
1153 {
1154 if (! AsnOpenStruct(aip, MEDLINE_FIELD_ids, (Pointer)mfp->ids)) goto erret;
1155 for (drp = mfp->ids; drp != NULL; drp = drp->next)
1156 {
1157 if (! DocRefAsnWrite(drp, aip, MEDLINE_FIELD_ids_E))
1158 goto erret;
1159 }
1160 if (! AsnCloseStruct(aip, MEDLINE_FIELD_ids, (Pointer)mfp->ids)) goto erret;
1161 }
1162 if (! AsnCloseStruct(aip, atp, (Pointer)mfp)) goto erret;
1163 retval = TRUE;
1164 erret:
1165 AsnUnlinkType(orig);
1166 return retval;
1167 }
1168
1169
1170 /*****************************************************************************
1171 *
1172 * DocRefNew()
1173 *
1174 *****************************************************************************/
DocRefNew(void)1175 NLM_EXTERN DocRefPtr LIBCALL DocRefNew (void)
1176 {
1177 DocRefPtr drp;
1178
1179 drp = (DocRefPtr)MemNew(sizeof(DocRef));
1180 return drp;
1181 }
1182
1183 /*****************************************************************************
1184 *
1185 * DocRefFree()
1186 *
1187 *****************************************************************************/
DocRefFree(DocRefPtr drp)1188 NLM_EXTERN DocRefPtr LIBCALL DocRefFree (DocRefPtr drp)
1189 {
1190 if (drp == NULL)
1191 return drp;
1192
1193 return (DocRefPtr)MemFree(drp);
1194 }
1195
1196 /*****************************************************************************
1197 *
1198 * DocRefAsnRead(aip, atp)
1199 *
1200 *****************************************************************************/
DocRefAsnRead(AsnIoPtr aip,AsnTypePtr orig)1201 NLM_EXTERN DocRefPtr LIBCALL DocRefAsnRead (AsnIoPtr aip, AsnTypePtr orig)
1202 {
1203 DocRefPtr drp=NULL;
1204 DataVal av;
1205 AsnTypePtr atp;
1206
1207 if (! loaded)
1208 {
1209 if (! MedlineAsnLoad())
1210 return drp;
1211 }
1212
1213 if (aip == NULL)
1214 return drp;
1215
1216 if (orig == NULL) /* DocRef ::= */
1217 atp = AsnReadId(aip, amp, DOCREF);
1218 else
1219 atp = AsnLinkType(orig, DOCREF);
1220 if (atp == NULL) return drp;
1221
1222 drp = DocRefNew();
1223 if (drp == NULL) goto erret;
1224
1225 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the SEQUENCE */
1226 atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret; /* type */
1227 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
1228 drp->type = (Uint1)av.intvalue;
1229 atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret;
1230 if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
1231 drp->uid = av.intvalue;
1232
1233 atp = AsnReadId(aip, amp, atp); if (atp == NULL) goto erret;
1234 if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the END STRUCT */
1235 ret:
1236 AsnUnlinkType(orig);
1237 return drp;
1238 erret:
1239 drp = DocRefFree(drp);
1240 goto ret;
1241 }
1242
1243 /*****************************************************************************
1244 *
1245 * DocRefAsnWrite(drp, aip, atp)
1246 *
1247 *****************************************************************************/
DocRefAsnWrite(DocRefPtr drp,AsnIoPtr aip,AsnTypePtr orig)1248 NLM_EXTERN Boolean LIBCALL DocRefAsnWrite (DocRefPtr drp, AsnIoPtr aip, AsnTypePtr orig)
1249 {
1250 DataVal av;
1251 AsnTypePtr atp;
1252 Boolean retval = TRUE;
1253
1254 if (! loaded)
1255 {
1256 if (! MedlineAsnLoad())
1257 return FALSE;
1258 }
1259
1260 if (aip == NULL)
1261 return FALSE;
1262
1263 atp = AsnLinkType(orig, DOCREF);
1264 if (atp == NULL) return FALSE;
1265
1266 if (drp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1267
1268 MemSet ((Pointer) (&av), 0, sizeof (DataVal));
1269
1270 if (! AsnOpenStruct(aip, atp, (Pointer)drp)) goto erret;
1271 av.intvalue = (Int4)drp->type;
1272 if (! AsnWrite(aip, DOCREF_type, &av)) goto erret;
1273 av.intvalue = (Int4)drp->uid;
1274 if (! AsnWrite(aip, DOCREF_uid, &av)) goto erret;
1275 if (! AsnCloseStruct(aip, atp, (Pointer)drp)) goto erret;
1276 retval = TRUE;
1277 erret:
1278 AsnUnlinkType(orig);
1279 return retval;
1280 }
1281
1282
1283