2
* ===========================================================================
5
* National Center for Biotechnology Information
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.
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
22
* Please cite the author in any work or product based on this material.
24
* ===========================================================================
26
* File Name: objbibli.c
28
* Author: James Ostell
30
* Version Creation Date: 1/1/91
34
* File Description: Object manager for module NCBI-Biblio
37
* --------------------------------------------------------------------------
38
* Date Name Description of modification
39
* ------- ---------- -----------------------------------------------------
40
* 05-13-93 Schuler All public functions are now declared LIBCALL.
41
* 07-19-93 Ostell Support for ASN30 added
43
* $Log: objbibli.c,v $
44
* Revision 6.5 2001/10/09 15:57:38 kans
45
* AuthListMatch does StringICmp if both are structured last names, StringNICmp otherwise
47
* Revision 6.4 2000/01/18 19:40:51 ostell
48
* added support for PubStatusDate, ArticleIds
50
* Revision 6.3 2000/01/05 18:44:12 kans
51
* increased buffer size in AuthListMatch, which was overflowing
53
* Revision 6.2 1998/08/24 18:27:59 kans
54
* removed solaris -v -fd warnings
56
* Revision 6.1 1997/11/13 21:31:59 kans
57
* fixed endless loop in CitArtFree (Kuzio)
59
* Revision 6.0 1997/08/25 18:49:19 madden
60
* Revision changed to 6.0
62
* Revision 4.7 1997/08/20 19:16:53 madden
65
* Revision 4.6 1997/06/19 18:40:46 vakatov
66
* [WIN32,MSVC++] Adopted for the "NCBIOBJ.LIB" DLL'ization
68
* Revision 4.5 1997/03/18 15:30:07 ostell
69
* make IdPatMatch case insensitive
71
* Revision 4.4 1996/12/12 21:49:08 tatiana
72
* CiSubMatch changed to compare the dates from both ImpPrint.date and date
74
* Revision 4.3 1996/12/04 18:18:41 kans
75
* CitSubMatch calls ImprintMatch only if both imp fields not NULL, and
76
* calls DateMatch if date fields not NULL
78
* Revision 4.2 1996/07/30 15:50:50 epstein
79
* correct logic errors for different spec_versions
81
* Revision 4.1 1996/03/29 21:09:59 ostell
82
* added support for PubMedId
84
* Revision 4.0 1995/07/26 13:48:06 ostell
85
* force revision to 4.0
87
* Revision 3.6 1995/05/24 21:20:50 ostell
90
* Revision 3.5 1995/05/24 19:10:27 ostell
91
* added filtering (grep for "ASN3 strip") to conform to old version 3.0
94
* Revision 3.4 1995/05/15 21:22:00 ostell
99
* ==========================================================================
101
#include <asnbibli.h>
102
#include <objbibli.h>
105
static Boolean loaded = FALSE;
107
/*****************************************************************************
109
* Bibliographic Object routines
111
*****************************************************************************/
113
/*****************************************************************************
117
*****************************************************************************/
118
NLM_EXTERN Boolean LIBCALL BiblioAsnLoad (void)
124
if (! GeneralAsnLoad())
137
/*****************************************************************************
141
*****************************************************************************/
142
NLM_EXTERN AffilPtr LIBCALL AffilNew (void)
146
afp = (AffilPtr)MemNew(sizeof(Affil));
150
/*****************************************************************************
154
*****************************************************************************/
155
NLM_EXTERN AffilPtr LIBCALL AffilFree (AffilPtr afp)
163
MemFree(afp->country);
164
MemFree(afp->street);
168
MemFree(afp->postal_code);
169
return (AffilPtr)MemFree(afp);
172
/*****************************************************************************
174
* AffilAsnRead(aip, atp)
176
*****************************************************************************/
177
NLM_EXTERN AffilPtr LIBCALL AffilAsnRead (AsnIoPtr aip, AsnTypePtr orig)
185
if (! BiblioAsnLoad())
192
if (orig == NULL) /* Affil ::= */
193
atp = AsnReadId(aip, amp, AFFIL);
195
atp = AsnLinkType(orig, AFFIL);
203
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the CHOICE */
204
atp = AsnReadId(aip, amp, atp); /* read the CHOICE id */
208
if (atp == AFFIL_str) /* just the VisibleString */
210
afp->choice = 1; /* choice type is str */
211
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* get the string */
212
afp->affil = (CharPtr)av.ptrvalue; /* keep it */
214
else /* affiliation structure */
216
afp->choice = 2; /* choice type is std */
217
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the START_STRUCT */
219
while ((atp = AsnReadId(aip, amp, atp)) != AFFIL_std)
223
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
224
if (atp == AFFIL_std_affil)
225
afp->affil = (CharPtr)av.ptrvalue;
226
else if (atp == AFFIL_std_div)
227
afp->div = (CharPtr)av.ptrvalue;
228
else if (atp == AFFIL_std_city)
229
afp->city = (CharPtr)av.ptrvalue;
230
else if (atp == AFFIL_std_sub)
231
afp->sub = (CharPtr)av.ptrvalue;
232
else if (atp == AFFIL_std_country)
233
afp->country = (CharPtr)av.ptrvalue;
234
else if (atp == AFFIL_std_street)
235
afp->street = (CharPtr)av.ptrvalue;
236
else if (atp == AFFIL_std_email)
237
afp->email = (CharPtr)av.ptrvalue;
238
else if (atp == AFFIL_std_fax)
239
afp->fax = (CharPtr)av.ptrvalue;
240
else if (atp == AFFIL_std_phone)
241
afp->phone = (CharPtr)av.ptrvalue;
242
else if (atp == AFFIL_std_postal_code)
244
if (aip->spec_version == 3) /* ASN3 strip new value */
246
ErrPostEx(SEV_ERROR,0,0,"ASN3: postal_code stripped");
247
MemFree((CharPtr)(av.ptrvalue));
250
afp->postal_code = (CharPtr)av.ptrvalue;
253
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the END STRUCT */
259
afp = AffilFree(afp);
263
/*****************************************************************************
265
* AffilAsnWrite(afp, aip, atp)
267
*****************************************************************************/
268
NLM_EXTERN Boolean LIBCALL AffilAsnWrite (AffilPtr afp, AsnIoPtr aip, AsnTypePtr orig)
272
Boolean retval = FALSE;
276
if (! BiblioAsnLoad())
283
atp = AsnLinkType(orig, AFFIL);
287
if (afp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
289
if (! AsnWrite(aip, atp, &av)) /* write the tag */
292
if (afp->choice == 1) /* string */
294
av.ptrvalue = afp->affil;
295
if (! AsnWrite(aip, AFFIL_str, &av)) /* write the string */
300
if (! AsnOpenStruct(aip, AFFIL_std, (Pointer)afp))
302
if (afp->affil != NULL)
304
av.ptrvalue = afp->affil;
305
if (! AsnWrite(aip, AFFIL_std_affil, &av))
308
if (afp->div != NULL)
310
av.ptrvalue = afp->div;
311
if (! AsnWrite(aip, AFFIL_std_div, &av)) goto erret;
313
if (afp->city != NULL)
315
av.ptrvalue = afp->city;
316
if (! AsnWrite(aip, AFFIL_std_city, &av)) goto erret;
318
if (afp->sub != NULL)
320
av.ptrvalue = afp->sub;
321
if (! AsnWrite(aip, AFFIL_std_sub, &av)) goto erret;
323
if (afp->country != NULL)
325
av.ptrvalue = afp->country;
326
if (! AsnWrite(aip, AFFIL_std_country, &av)) goto erret;
328
if (afp->street != NULL)
330
av.ptrvalue = afp->street;
331
if (! AsnWrite(aip, AFFIL_std_street, &av)) goto erret;
333
if (afp->email != NULL)
335
av.ptrvalue = afp->email;
336
if (! AsnWrite(aip, AFFIL_std_email, &av)) goto erret;
338
if (afp->fax != NULL)
340
av.ptrvalue = afp->fax;
341
if (! AsnWrite(aip, AFFIL_std_fax, &av)) goto erret;
343
if (afp->phone != NULL)
345
av.ptrvalue = afp->phone;
346
if (! AsnWrite(aip, AFFIL_std_phone, &av)) goto erret;
348
if (afp->postal_code != NULL)
350
if (aip->spec_version == 3) /* ASN3 strip new value */
352
ErrPostEx(SEV_ERROR,0,0,"ASN3: postal_code stripped");
356
av.ptrvalue = afp->postal_code;
357
if (! AsnWrite(aip, AFFIL_std_postal_code, &av)) goto erret;
361
if (! AsnCloseStruct(aip, AFFIL_std, (Pointer)afp))
370
/*****************************************************************************
374
*****************************************************************************/
375
NLM_EXTERN AuthListPtr LIBCALL AuthListNew (void)
379
alp = (AuthListPtr)MemNew(sizeof(AuthList));
383
/*****************************************************************************
387
*****************************************************************************/
388
NLM_EXTERN AuthListPtr LIBCALL AuthListFree (AuthListPtr alp)
390
ValNodePtr curr, next;
398
if (alp->choice == 1) /* std type */
399
AuthorFree((AuthorPtr) curr->data.ptrvalue);
401
MemFree(curr->data.ptrvalue);
406
if (alp->affil != NULL)
407
AffilFree(alp->affil);
408
return (AuthListPtr)MemFree(alp);
411
/*****************************************************************************
413
* AuthListAsnRead(aip, atp)
415
*****************************************************************************/
416
NLM_EXTERN AuthListPtr LIBCALL AuthListAsnRead (AsnIoPtr aip, AsnTypePtr orig)
418
AuthListPtr alp=NULL;
420
AsnTypePtr atp, seqofptr;
426
if (! BiblioAsnLoad())
433
if (orig == NULL) /* AuthList ::= */
434
atp = AsnReadId(aip, amp, AUTH_LIST);
436
atp = AsnLinkType(orig, AUTH_LIST);
444
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the START STRUCT */
445
atp = AsnReadId(aip, amp, atp); /* read names id */
448
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the CHOICE */
449
atp = AsnReadId(aip, amp, atp); /* read the CHOICE id */
452
seqofptr = atp; /* keep to find end of loop */
453
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the START for SEQUENCE OF */
455
if (atp == AUTH_LIST_names_std) /* Authors */
456
choice = 1; /* choice type is str */
457
else if (atp == AUTH_LIST_names_ml) /* medline */
462
alp->choice = choice;
465
while ((atp = AsnReadId(aip, amp, atp)) != seqofptr)
469
anp = ValNodeNew(anp); /* add to linked list */
472
if (alp->names == NULL)
474
anp->choice = choice; /* not really necessary */
475
if (choice == 1) /* std */
476
anp->data.ptrvalue = (Pointer) AuthorAsnRead(aip, atp);
479
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* string types */
480
anp->data.ptrvalue = av.ptrvalue;
482
if (anp->data.ptrvalue == NULL)
485
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* SEQ OF end STRUCT */
487
atp = AsnReadId(aip, amp, atp);
490
if (atp == AUTH_LIST_affil) /* has an affiliation */
492
alp->affil = AffilAsnRead(aip, atp);
493
if (alp->affil == NULL)
495
atp = AsnReadId(aip, amp, atp);
499
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* END STRUCT */
504
alp = AuthListFree(alp);
508
/*****************************************************************************
510
* AuthListAsnWrite(alp, aip, atp)
512
*****************************************************************************/
513
NLM_EXTERN Boolean LIBCALL AuthListAsnWrite (AuthListPtr alp, AsnIoPtr aip, AsnTypePtr orig)
516
AsnTypePtr atp, seqofptr, elementptr;
519
Boolean retval = FALSE;
523
if (! BiblioAsnLoad())
530
atp = AsnLinkType(orig, AUTH_LIST);
534
if (alp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
536
if (! AsnOpenStruct(aip, atp, (Pointer)alp)) /* open AuthList SEQUENCE */
539
av.ptrvalue = alp->names;
540
if (! AsnWriteChoice(aip, AUTH_LIST_names, (Int2)alp->choice, &av)) goto erret;
542
/* write CHOICE for SEQUENCE OF */
543
choice = alp->choice;
544
if (choice == 1 ) /* std */
546
seqofptr = AUTH_LIST_names_std;
547
elementptr = AUTH_LIST_names_std_E;
549
else if (choice == 2) /* ml */
551
seqofptr = AUTH_LIST_names_ml;
552
elementptr = AUTH_LIST_names_ml_E;
556
seqofptr = AUTH_LIST_names_str;
557
elementptr = AUTH_LIST_names_str_E;
560
if (! AsnOpenStruct(aip, seqofptr, (Pointer)alp->names)) /* start SEQUENCE OF */
567
if (choice == 1) /* Author */
569
if (! AuthorAsnWrite((AuthorPtr) anp->data.ptrvalue, aip, elementptr))
572
else /* str or medline */
574
av.ptrvalue = anp->data.ptrvalue;
575
if (! AsnWrite(aip, elementptr, &av)) goto erret;
580
if (! AsnCloseStruct(aip, seqofptr, (Pointer)alp->names)) /* end SEQUENCE OF */
583
if (alp->affil != NULL) /* affiliation */
585
if (! AffilAsnWrite(alp->affil, aip, AUTH_LIST_affil))
589
if (! AsnCloseStruct(aip, atp, (Pointer)alp)) /* end AuthList SEQUENCE */
597
/*****************************************************************************
601
*****************************************************************************/
602
NLM_EXTERN AuthorPtr LIBCALL AuthorNew (void)
606
ap = (AuthorPtr)MemNew(sizeof(Author));
607
if (ap == NULL) return ap;
608
ap->is_corr = (Uint1)255;
612
/*****************************************************************************
616
*****************************************************************************/
617
NLM_EXTERN AuthorPtr LIBCALL AuthorFree (AuthorPtr ap)
622
PersonIdFree(ap->name);
623
if (ap->affil != NULL)
624
AffilFree(ap->affil);
625
return (AuthorPtr)MemFree(ap);
628
/*****************************************************************************
630
* AuthorAsnRead(aip, atp)
632
*****************************************************************************/
633
NLM_EXTERN AuthorPtr LIBCALL AuthorAsnRead (AsnIoPtr aip, AsnTypePtr orig)
637
AsnTypePtr atp, oldatp;
641
if (! BiblioAsnLoad())
648
if (orig == NULL) /* Author ::= */
649
atp = AsnReadId(aip, amp, AUTHOR);
651
atp = AsnLinkType(orig, AUTHOR);
652
oldatp = atp; /* points to start of SEQUENCE */
660
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the open SEQUENCE */
661
atp = AsnReadId(aip, amp, atp); /* read the name id */
664
ap->name = PersonIdAsnRead(aip, atp); /* read the PersonId */
665
if (ap->name == NULL)
668
while ((atp = AsnReadId(aip, amp, atp)) != oldatp) /* read SEQUENCE */
672
if (atp == AUTHOR_affil)
674
ap->affil = AffilAsnRead(aip, atp);
675
if (ap->affil == NULL)
680
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
681
if (atp == AUTHOR_level)
682
ap->lr[0] = (Uint1) av.intvalue;
683
else if (atp == AUTHOR_role)
684
ap->lr[1] = (Uint1) av.intvalue;
685
else if (atp == AUTHOR_is_corr)
695
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end of SEQUENCE */
704
/*****************************************************************************
706
* AuthorAsnWrite(ap, aip, atp)
708
*****************************************************************************/
709
NLM_EXTERN Boolean LIBCALL AuthorAsnWrite (AuthorPtr ap, AsnIoPtr aip, AsnTypePtr orig)
713
Boolean retval = FALSE;
717
if (! BiblioAsnLoad())
724
atp = AsnLinkType(orig, AUTHOR);
728
if (ap == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
730
if (! AsnOpenStruct(aip, atp, (Pointer)ap)) /* open the SEQUENCE */
733
if (! PersonIdAsnWrite(ap->name, aip, AUTHOR_name)) /* write the name */
736
if (ap->lr[0] != 0) /* level set */
738
av.intvalue = (Int4) ap->lr[0];
739
if (! AsnWrite(aip, AUTHOR_level, &av)) goto erret;
742
if (ap->lr[1] != 0) /* role set */
744
av.intvalue = (Int4) ap->lr[1];
745
if (! AsnWrite(aip, AUTHOR_role, &av)) goto erret;
748
if (ap->affil != NULL)
750
if (! AffilAsnWrite(ap->affil, aip, AUTHOR_affil))
754
if (ap->is_corr != 255)
756
av.boolvalue = (Boolean) ap->is_corr;
757
AsnWrite(aip, AUTHOR_is_corr, &av);
760
if (! AsnCloseStruct(aip, atp, (Pointer)ap)) /* end SEQUENCE */
768
/*****************************************************************************
772
*****************************************************************************/
773
NLM_EXTERN CitArtPtr LIBCALL CitArtNew (void)
777
cap = (CitArtPtr)MemNew(sizeof(CitArt));
781
/*****************************************************************************
785
*****************************************************************************/
786
NLM_EXTERN CitArtPtr LIBCALL CitArtFree (CitArtPtr cap)
788
ArticleIdPtr aip, aipnext;
793
TitleFree(cap->title);
794
AuthListFree(cap->authors);
795
if (cap->from == 1) /* journal */
796
CitJourFree((CitJourPtr) cap->fromptr);
797
else /* book or proceedings */
798
CitBookFree((CitBookPtr) cap->fromptr);
800
for (aip = cap->ids; aip != NULL; )
806
return (CitArtPtr)MemFree(cap);
809
/*****************************************************************************
811
* CitArtAsnRead(aip, atp)
813
*****************************************************************************/
814
NLM_EXTERN CitArtPtr LIBCALL CitArtAsnRead (AsnIoPtr aip, AsnTypePtr orig)
820
ArticleIdPtr PNTR aidp_add;
824
if (! BiblioAsnLoad())
831
if (orig == NULL) /* CitArt ::= */
832
atp = AsnReadId(aip, amp, CIT_ART);
834
atp = AsnLinkType(orig, CIT_ART);
842
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the open SEQUENCE */
844
atp = AsnReadId(aip, amp, atp); /* read title id */
845
if (atp == CIT_ART_title)
847
cap->title = TitleAsnRead(aip, atp); /* read the titles */
848
if (cap->title == NULL)
851
atp = AsnReadId(aip, amp, atp); /* read the authors id */
853
if (atp == CIT_ART_authors)
855
cap->authors = AuthListAsnRead(aip, atp);
856
if (cap->authors == NULL)
859
atp = AsnReadId(aip, amp, atp); /* read from tag */
863
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* balance from CHOICE */
865
atp = AsnReadId(aip, amp, atp); /* read the from CHOICE */
868
if (atp == CIT_ART_from_journal)
871
cap->fromptr = (Pointer) CitJourAsnRead(aip, atp);
873
else if (atp == CIT_ART_from_book)
876
cap->fromptr = (Pointer) CitBookAsnRead(aip, atp);
881
cap->fromptr = (Pointer) CitProcAsnRead(aip, atp);
884
if (cap->fromptr == NULL)
887
atp = AsnReadId(aip, amp, atp);
891
if (atp == CIT_ART_ids)
893
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
894
aidp_add = &(cap->ids);
895
while ((atp = AsnReadId(aip, amp, atp)) == ARTICLEIDSET_E)
897
aidp = ArticleIdAsnRead(aip, atp);
898
if (aidp == NULL) goto erret;
900
aidp_add = &(aidp->next);
902
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* END STRUCT */
903
atp = AsnReadId(aip, amp, atp);
906
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end of SEQUENCE */
911
cap = CitArtFree(cap);
915
/*****************************************************************************
917
* CitArtAsnWrite(cap, aip, atp)
919
*****************************************************************************/
920
NLM_EXTERN Boolean LIBCALL CitArtAsnWrite (CitArtPtr cap, AsnIoPtr aip, AsnTypePtr orig)
924
Boolean retval = FALSE;
929
if (! BiblioAsnLoad())
936
atp = AsnLinkType(orig, CIT_ART);
940
if (cap == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
942
if (! AsnOpenStruct(aip, atp, (Pointer)cap)) /* open the SEQUENCE */
945
if (cap->title != NULL)
947
if (! TitleAsnWrite(cap->title, aip, CIT_ART_title)) /* write the title(s) */
950
if (cap->authors != NULL)
952
if (! AuthListAsnWrite(cap->authors, aip, CIT_ART_authors)) /* authors */
956
av.ptrvalue = cap->fromptr;
957
if (! AsnWriteChoice(aip, CIT_ART_from, (Int2)cap->from, &av)) goto erret;
960
retval = CitJourAsnWrite((CitJourPtr) cap->fromptr, aip, CIT_ART_from_journal);
961
else if (cap->from == 2)
962
retval = CitBookAsnWrite((CitBookPtr) cap->fromptr, aip, CIT_ART_from_book);
964
retval = CitProcAsnWrite((CitBookPtr) cap->fromptr, aip, CIT_ART_from_proc);
970
if (cap->ids != NULL)
972
if (! AsnOpenStruct(aip, CIT_ART_ids, (Pointer)cap)) goto erret;
973
for (aidp = cap->ids; aidp != NULL; aidp = aidp->next)
975
if (! ArticleIdAsnWrite(aidp, aip, ARTICLEIDSET_E)) goto erret;
977
if (! AsnCloseStruct(aip, CIT_ART_ids, (Pointer)cap)) goto erret;
980
if (! AsnCloseStruct(aip, atp, (Pointer)cap)) /* close the SEQUENCE */
988
/*****************************************************************************
992
*****************************************************************************/
993
NLM_EXTERN ImprintPtr LIBCALL ImprintNew (void)
997
ip = (ImprintPtr)MemNew(sizeof(Imprint));
1001
/*****************************************************************************
1005
*****************************************************************************/
1006
NLM_EXTERN ImprintPtr LIBCALL ImprintFree (ImprintPtr ip)
1008
PubStatusDatePtr psdp, psdpnext;
1015
MemFree(ip->volume);
1018
MemFree(ip->section);
1019
MemFree(ip->part_sup);
1020
MemFree(ip->language);
1021
MemFree(ip->part_supi);
1023
CitRetractFree(ip->retract);
1024
for (psdp = ip->history; psdp != NULL; )
1026
psdpnext = psdp->next;
1027
PubStatusDateFree(psdp);
1030
return (ImprintPtr)MemFree(ip);
1033
/*****************************************************************************
1035
* ImprintAsnRead(aip, atp)
1037
*****************************************************************************/
1038
NLM_EXTERN ImprintPtr LIBCALL ImprintAsnRead (AsnIoPtr aip, AsnTypePtr orig)
1042
AsnTypePtr atp, oldatp;
1043
PubStatusDatePtr psdp;
1044
PubStatusDatePtr PNTR psdp_add;
1048
if (! BiblioAsnLoad())
1055
if (orig == NULL) /* Imprint ::= */
1056
atp = AsnReadId(aip, amp, IMPRINT);
1058
atp = AsnLinkType(orig, IMPRINT);
1067
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the SEQUENCE start */
1068
atp = AsnReadId(aip, amp, atp); /* read the date */
1071
ip->date = DateAsnRead(aip, atp);
1072
if (ip->date == NULL)
1075
psdp_add = &(ip->history);
1076
while ((atp = AsnReadId(aip, amp, atp)) != oldatp)
1080
if (atp == IMPRINT_pub)
1082
ip->pub = AffilAsnRead(aip, atp);
1083
if (ip->pub == NULL)
1086
else if (atp == IMPRINT_cprt)
1088
ip->cprt = DateAsnRead(aip, atp);
1089
if (ip->cprt == NULL)
1092
else if (atp == IMPRINT_retract)
1094
ip->retract = CitRetractAsnRead(aip, atp);
1095
if (ip->retract == NULL) goto erret;
1097
else if (atp == PUBSTATUSDATESET_E)
1099
psdp = PubStatusDateAsnRead(aip, atp);
1100
if (psdp == NULL) goto erret;
1102
psdp_add = &(psdp->next);
1106
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
1107
if (atp == IMPRINT_volume)
1108
ip->volume = (CharPtr)av.ptrvalue;
1109
else if (atp == IMPRINT_issue)
1110
ip->issue = (CharPtr)av.ptrvalue;
1111
else if (atp == IMPRINT_pages)
1112
ip->pages = (CharPtr)av.ptrvalue;
1113
else if (atp == IMPRINT_section)
1114
ip->section = (CharPtr)av.ptrvalue;
1115
else if (atp == IMPRINT_part_sup)
1116
ip->part_sup = (CharPtr)av.ptrvalue;
1117
else if (atp == IMPRINT_language)
1118
ip->language = (CharPtr)av.ptrvalue;
1119
else if (atp == IMPRINT_prepub)
1120
ip->prepub = (Uint1)av.intvalue;
1121
else if (atp == IMPRINT_part_supi)
1122
ip->part_supi = (CharPtr)av.ptrvalue;
1123
else if (atp == IMPRINT_pubstatus)
1124
ip->pubstatus = (Uint1)(av.intvalue);
1128
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end struct */
1130
AsnUnlinkType(orig);
1133
ip = ImprintFree(ip);
1137
/*****************************************************************************
1139
* ImprintAsnWrite(ip, aip, atp)
1141
*****************************************************************************/
1142
NLM_EXTERN Boolean LIBCALL ImprintAsnWrite (ImprintPtr ip, AsnIoPtr aip, AsnTypePtr orig)
1146
Boolean retval = FALSE;
1147
PubStatusDatePtr psdp;
1151
if (! BiblioAsnLoad())
1158
atp = AsnLinkType(orig, IMPRINT);
1162
if (ip == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1164
if (! AsnOpenStruct(aip, atp, (Pointer)ip))
1166
if (! DateAsnWrite(ip->date, aip, IMPRINT_date))
1168
if (ip->volume != NULL)
1170
av.ptrvalue = ip->volume;
1171
if (! AsnWrite(aip, IMPRINT_volume, &av)) goto erret;
1173
if (ip->issue != NULL)
1175
av.ptrvalue = ip->issue;
1176
if (! AsnWrite(aip, IMPRINT_issue, &av)) goto erret;
1178
if (ip->pages != NULL)
1180
av.ptrvalue = ip->pages;
1181
if (! AsnWrite(aip, IMPRINT_pages, &av)) goto erret;
1183
if (ip->section != NULL)
1185
av.ptrvalue = ip->section;
1186
if (! AsnWrite(aip, IMPRINT_section, &av)) goto erret;
1188
if (ip->pub != NULL)
1190
if (! AffilAsnWrite(ip->pub, aip, IMPRINT_pub))
1193
if (ip->cprt != NULL)
1195
if (! DateAsnWrite(ip->cprt, aip, IMPRINT_cprt))
1198
if (ip->part_sup != NULL)
1200
av.ptrvalue = ip->part_sup;
1201
if (! AsnWrite(aip, IMPRINT_part_sup, &av)) goto erret;
1203
if (ip->language != NULL)
1205
av.ptrvalue = ip->language;
1206
if (! AsnWrite(aip, IMPRINT_language, &av)) goto erret;
1208
if (ip->prepub != 0)
1210
av.intvalue = ip->prepub;
1211
if (! AsnWrite(aip, IMPRINT_prepub, &av)) goto erret;
1213
if (ip->part_supi != NULL)
1215
av.ptrvalue = ip->part_supi;
1216
if (! AsnWrite(aip, IMPRINT_part_supi, &av)) goto erret;
1218
if (ip->retract != NULL)
1220
if (! CitRetractAsnWrite(ip->retract, aip, IMPRINT_retract))
1225
av.intvalue = (Int4)(ip->pubstatus);
1226
if (! AsnWrite(aip, IMPRINT_pubstatus, &av)) goto erret;
1228
if (ip->history != NULL)
1230
if (! AsnOpenStruct(aip, IMPRINT_history, (Pointer)ip)) goto erret;
1231
for (psdp = ip->history; psdp != NULL; psdp = psdp->next)
1233
if (! PubStatusDateAsnWrite(psdp, aip, PUBSTATUSDATESET_E))
1236
if (! AsnCloseStruct(aip, IMPRINT_history, (Pointer)ip)) goto erret;
1238
if (! AsnCloseStruct(aip, atp, (Pointer)ip))
1242
AsnUnlinkType(orig);
1246
/*****************************************************************************
1250
*****************************************************************************/
1251
NLM_EXTERN CitRetractPtr LIBCALL CitRetractNew (void)
1255
crp = (CitRetractPtr)MemNew(sizeof(CitRetract));
1259
/*****************************************************************************
1263
*****************************************************************************/
1264
NLM_EXTERN CitRetractPtr LIBCALL CitRetractFree (CitRetractPtr crp)
1270
return (CitRetractPtr)MemFree(crp);
1273
/*****************************************************************************
1275
* CitRetractAsnRead(aip, atp)
1277
*****************************************************************************/
1278
NLM_EXTERN CitRetractPtr LIBCALL CitRetractAsnRead (AsnIoPtr aip, AsnTypePtr orig)
1280
CitRetractPtr crp=NULL;
1286
if (! BiblioAsnLoad())
1293
if (orig == NULL) /* CitRetract ::= */
1294
atp = AsnReadId(aip, amp, CITRETRACT);
1296
atp = AsnLinkType(orig, CITRETRACT);
1300
crp = CitRetractNew();
1304
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the SEQUENCE start */
1306
atp = AsnReadId(aip, amp, atp); /* read the type */
1309
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
1310
crp->type = (Uint1)av.intvalue;
1312
atp = AsnReadId(aip, amp, atp); /* read the exp? */
1313
if (atp == CITRETRACT_exp)
1315
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
1316
crp->exp = (CharPtr)av.ptrvalue;
1317
atp = AsnReadId(aip, amp, atp); /* read the CLOSE */
1320
if (atp == NULL) goto erret;
1321
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end struct */
1323
AsnUnlinkType(orig);
1326
crp = CitRetractFree(crp);
1330
/*****************************************************************************
1332
* CitRetractAsnWrite(ip, aip, atp)
1334
*****************************************************************************/
1335
NLM_EXTERN Boolean LIBCALL CitRetractAsnWrite (CitRetractPtr crp, AsnIoPtr aip, AsnTypePtr orig)
1339
Boolean retval = FALSE;
1343
if (! BiblioAsnLoad())
1350
atp = AsnLinkType(orig, CITRETRACT);
1354
if (crp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1356
if (! AsnOpenStruct(aip, atp, (Pointer)crp))
1359
av.intvalue = (Int4)crp->type;
1360
if (! AsnWrite(aip, CITRETRACT_type, &av)) goto erret;
1362
if (crp->exp != NULL)
1364
av.ptrvalue = (Pointer)crp->exp;
1365
if (! AsnWrite(aip, CITRETRACT_exp, &av)) goto erret;
1368
if (! AsnCloseStruct(aip, atp, (Pointer)crp))
1372
AsnUnlinkType(orig);
1376
/*****************************************************************************
1380
*****************************************************************************/
1381
NLM_EXTERN CitJourPtr LIBCALL CitJourNew (void)
1385
cjp = (CitJourPtr)MemNew(sizeof(CitJour));
1389
/*****************************************************************************
1393
*****************************************************************************/
1394
NLM_EXTERN CitJourPtr LIBCALL CitJourFree (CitJourPtr cjp)
1399
TitleFree(cjp->title);
1400
ImprintFree(cjp->imp);
1401
return (CitJourPtr)MemFree(cjp);
1404
/*****************************************************************************
1406
* CitJourAsnRead(aip, atp)
1408
*****************************************************************************/
1409
NLM_EXTERN CitJourPtr LIBCALL CitJourAsnRead (AsnIoPtr aip, AsnTypePtr orig)
1411
CitJourPtr cjp=NULL;
1417
if (! BiblioAsnLoad())
1424
if (orig == NULL) /* CitJour ::= */
1425
atp = AsnReadId(aip, amp, CIT_JOUR);
1427
atp = AsnLinkType(orig, CIT_JOUR);
1435
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the open SEQUENCE */
1436
atp = AsnReadId(aip, amp, atp); /* read title id */
1439
cjp->title = TitleAsnRead(aip, atp);
1440
if (cjp->title == NULL)
1442
atp = AsnReadId(aip, amp, atp); /* read imprint id */
1445
cjp->imp = ImprintAsnRead(aip, atp);
1446
if (cjp->imp == NULL)
1448
atp = AsnReadId(aip, amp, atp); /* read the close SEQUENCE id */
1451
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end of SEQUENCE */
1453
AsnUnlinkType(orig);
1456
cjp = CitJourFree(cjp);
1460
/*****************************************************************************
1462
* CitJourAsnWrite(cjp, aip, atp)
1464
*****************************************************************************/
1465
NLM_EXTERN Boolean LIBCALL CitJourAsnWrite (CitJourPtr cjp, AsnIoPtr aip, AsnTypePtr orig)
1468
Boolean retval = FALSE;
1472
if (! BiblioAsnLoad())
1479
atp = AsnLinkType(orig, CIT_JOUR);
1483
if (cjp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1485
if (! AsnOpenStruct(aip, atp, (Pointer)cjp)) /* open the SEQUENCE */
1487
if (! TitleAsnWrite(cjp->title, aip, CIT_JOUR_title))
1489
if (! ImprintAsnWrite(cjp->imp, aip, CIT_JOUR_imp))
1491
if (! AsnCloseStruct(aip, atp, (Pointer)cjp)) /* end SEQUENCE */
1495
AsnUnlinkType(orig);
1499
/*****************************************************************************
1503
*****************************************************************************/
1504
NLM_EXTERN CitBookPtr LIBCALL CitBookNew (void)
1508
cbp = (CitBookPtr)MemNew(sizeof(CitBook));
1512
/*****************************************************************************
1516
*****************************************************************************/
1517
NLM_EXTERN CitBookPtr LIBCALL CitBookFree (CitBookPtr cbp)
1519
ValNodePtr anp, nextp;
1524
TitleFree(cbp->title);
1525
TitleFree(cbp->coll);
1526
AuthListFree(cbp->authors);
1527
ImprintFree(cbp->imp);
1528
if (cbp->othertype == 1) /* Cit-proc */
1530
anp = (ValNodePtr)cbp->otherdata;
1533
switch (anp->choice)
1535
case 1: /* number ... a CharPtr */
1536
MemFree(anp->data.ptrvalue);
1538
case 2: /* date ... a DatePtr */
1539
DateFree((DatePtr)anp->data.ptrvalue);
1541
case 3: /* place ... an AffilPtr */
1542
AffilFree((AffilPtr)anp->data.ptrvalue);
1550
else if (cbp->othertype == 2) /* Cit-let */
1551
MemFree(cbp->otherdata); /* man-id ... a CharPtr */
1553
return (CitBookPtr)MemFree(cbp);
1556
/*****************************************************************************
1558
* CitBookAsnRead(aip, atp)
1560
*****************************************************************************/
1561
NLM_EXTERN CitBookPtr LIBCALL CitBookAsnRead (AsnIoPtr aip, AsnTypePtr orig)
1563
CitBookPtr cbp=NULL;
1569
if (! BiblioAsnLoad())
1576
if (orig == NULL) /* CitBook ::= */
1577
atp = AsnReadId(aip, amp, CIT_BOOK);
1579
atp = AsnLinkType(orig, CIT_BOOK);
1587
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the open SEQUENCE */
1588
atp = AsnReadId(aip, amp, atp); /* read title id */
1591
cbp->title = TitleAsnRead(aip, atp);
1592
if (cbp->title == NULL)
1594
atp = AsnReadId(aip, amp, atp); /* read coll or authors id */
1597
if (atp == CIT_BOOK_coll)
1599
cbp->coll = TitleAsnRead(aip, atp);
1600
if (cbp->coll == NULL)
1602
atp = AsnReadId(aip, amp, atp); /* read authors id */
1606
cbp->authors = AuthListAsnRead(aip, atp);
1607
if (cbp->authors == NULL)
1609
atp = AsnReadId(aip, amp, atp); /* read imprint id */
1612
cbp->imp = ImprintAsnRead(aip, atp);
1613
if (cbp->imp == NULL)
1616
atp = AsnReadId(aip, amp, atp); /* read the close SEQUENCE id */
1619
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end of SEQUENCE */
1621
AsnUnlinkType(orig);
1624
cbp = CitBookFree(cbp);
1628
/*****************************************************************************
1630
* CitBookAsnWrite(cbp, aip, atp)
1632
*****************************************************************************/
1633
NLM_EXTERN Boolean LIBCALL CitBookAsnWrite (CitBookPtr cbp, AsnIoPtr aip, AsnTypePtr orig)
1636
Boolean retval = FALSE;
1640
if (! BiblioAsnLoad())
1647
atp = AsnLinkType(orig, CIT_BOOK);
1651
if (cbp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1653
if (! AsnOpenStruct(aip, atp, (Pointer)cbp)) /* open the SEQUENCE */
1655
if (! TitleAsnWrite(cbp->title, aip, CIT_BOOK_title))
1657
if (cbp->coll != NULL)
1659
if (! TitleAsnWrite(cbp->coll, aip, CIT_BOOK_coll))
1662
if (! AuthListAsnWrite(cbp->authors, aip, CIT_BOOK_authors))
1664
if (! ImprintAsnWrite(cbp->imp, aip, CIT_BOOK_imp))
1666
if (! AsnCloseStruct(aip, atp, (Pointer)cbp)) /* end SEQUENCE */
1670
AsnUnlinkType(orig);
1674
/*****************************************************************************
1676
* CitProcAsnRead(aip, atp)
1678
*****************************************************************************/
1679
NLM_EXTERN CitBookPtr LIBCALL CitProcAsnRead (AsnIoPtr aip, AsnTypePtr orig)
1681
CitBookPtr cpp=NULL;
1688
if (! BiblioAsnLoad())
1695
if (orig == NULL) /* CitProc ::= */
1696
atp = AsnReadId(aip, amp, CIT_PROC);
1698
atp = AsnLinkType(orig, CIT_PROC);
1702
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the open SEQUENCE */
1703
atp = AsnReadId(aip, amp, atp); /* read book id */
1706
cpp = CitBookAsnRead(aip, atp); /* read the book */
1709
cpp->othertype = 1; /* mark as a Cit-proc */
1710
atp = AsnReadId(aip, amp, atp); /* read the meet id */
1713
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* open struct */
1714
atp = AsnReadId(aip, amp, atp); /* number id */
1717
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
1718
anp = ValNodeNew(NULL);
1721
cpp->otherdata = (Pointer)anp;
1723
anp->data.ptrvalue = av.ptrvalue;
1724
atp = AsnReadId(aip, amp, atp); /* date id */
1727
anp = ValNodeNew(anp);
1731
anp->data.ptrvalue = (Pointer)DateAsnRead(aip, atp);
1732
if (anp->data.ptrvalue == NULL)
1734
atp = AsnReadId(aip, amp, atp); /* place id */
1737
anp = ValNodeNew(anp);
1741
anp->data.ptrvalue = (Pointer)AffilAsnRead(aip, atp);
1742
if (anp->data.ptrvalue == NULL)
1744
atp = AsnReadId(aip, amp, atp); /* end meet struct */
1747
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
1749
atp = AsnReadId(aip, amp, atp); /* read the close SEQUENCE id */
1752
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end of SEQUENCE */
1754
AsnUnlinkType(orig);
1757
cpp = CitBookFree(cpp);
1761
/*****************************************************************************
1763
* CitProcAsnWrite(cpp, aip, atp)
1765
*****************************************************************************/
1766
NLM_EXTERN Boolean LIBCALL CitProcAsnWrite (CitBookPtr cpp, AsnIoPtr aip, AsnTypePtr orig)
1771
Boolean retval = FALSE;
1775
if (! BiblioAsnLoad())
1782
atp = AsnLinkType(orig, CIT_PROC);
1786
if (cpp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1788
if (! AsnOpenStruct(aip, atp, (Pointer)cpp)) /* open the SEQUENCE */
1790
if (! CitBookAsnWrite(cpp, aip, CIT_PROC_book)) /* write the book */
1792
if (! AsnOpenStruct(aip, CIT_PROC_meet, (Pointer)cpp->otherdata))
1794
anp = (ValNodePtr)cpp->otherdata;
1795
av.ptrvalue = anp->data.ptrvalue;
1796
if (! AsnWrite(aip, MEETING_number, &av)) goto erret;
1798
if (! DateAsnWrite((DatePtr)anp->data.ptrvalue, aip, MEETING_date))
1801
if (! AffilAsnWrite((AffilPtr)anp->data.ptrvalue, aip, MEETING_place))
1803
if (! AsnCloseStruct(aip, CIT_PROC_meet, (Pointer)cpp->otherdata))
1805
if (! AsnCloseStruct(aip, atp, (Pointer)cpp)) /* end SEQUENCE */
1809
AsnUnlinkType(orig);
1813
/*****************************************************************************
1815
* CitLetAsnRead(aip, atp)
1817
*****************************************************************************/
1818
NLM_EXTERN CitBookPtr LIBCALL CitLetAsnRead (AsnIoPtr aip, AsnTypePtr orig)
1820
CitBookPtr clp=NULL;
1826
if (! BiblioAsnLoad())
1833
if (orig == NULL) /* CitLet ::= */
1834
atp = AsnReadId(aip, amp, CIT_LET);
1836
atp = AsnLinkType(orig, CIT_LET);
1840
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the open SEQUENCE */
1841
atp = AsnReadId(aip, amp, atp); /* read book id */
1844
clp = CitBookAsnRead(aip, atp); /* read the book */
1847
clp->othertype = 2; /* mark as a Cit-let */
1848
atp = AsnReadId(aip, amp, atp); /* read the man-id if present */
1851
if (atp == CIT_LET_man_id)
1853
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
1854
clp->otherdata = av.ptrvalue;
1855
atp = AsnReadId(aip, amp, atp); /* end struct */
1859
if (atp == CIT_LET_type) /* read type if present */
1861
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
1862
clp->let_type = (Uint1) av.intvalue;
1863
atp = AsnReadId(aip, amp, atp);
1867
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end of SEQUENCE */
1869
AsnUnlinkType(orig);
1872
clp = CitBookFree(clp);
1876
/*****************************************************************************
1878
* CitLetAsnWrite(clp, aip, atp)
1880
*****************************************************************************/
1881
NLM_EXTERN Boolean LIBCALL CitLetAsnWrite (CitBookPtr clp, AsnIoPtr aip, AsnTypePtr orig)
1885
Boolean retval = FALSE;
1889
if (! BiblioAsnLoad())
1896
atp = AsnLinkType(orig, CIT_LET);
1900
if (clp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
1902
if (! AsnOpenStruct(aip, atp, (Pointer)clp)) /* open the SEQUENCE */
1904
if (! CitBookAsnWrite(clp, aip, CIT_LET_cit)) /* write the book */
1906
if (clp->otherdata != NULL) /* man-id */
1908
av.ptrvalue = clp->otherdata;
1909
if (! AsnWrite(aip, CIT_LET_man_id, &av)) goto erret;
1911
if (clp->let_type) /* type of Cit-let */
1913
av.intvalue = (Int4)clp->let_type;
1914
if (! AsnWrite(aip, CIT_LET_type, &av)) goto erret;
1916
if (! AsnCloseStruct(aip, atp, (Pointer)clp)) /* end SEQUENCE */
1920
AsnUnlinkType(orig);
1924
/*****************************************************************************
1928
*****************************************************************************/
1929
NLM_EXTERN CitPatPtr LIBCALL CitPatNew (void)
1933
cpp = (CitPatPtr)MemNew(sizeof(CitPat));
1937
/*****************************************************************************
1941
*****************************************************************************/
1942
NLM_EXTERN CitPatPtr LIBCALL CitPatFree (CitPatPtr cpp)
1947
MemFree(cpp->title);
1948
AuthListFree(cpp->authors);
1949
MemFree(cpp->country);
1950
MemFree(cpp->doc_type);
1951
MemFree(cpp->number);
1952
DateFree(cpp->date_issue);
1953
ValNodeFreeData(cpp->_class);
1954
MemFree(cpp->app_number);
1955
DateFree(cpp->app_date);
1957
AuthListFree(cpp->applicants);
1958
AuthListFree(cpp->assignees);
1959
PatPrioritySetFree(cpp->priority);
1960
MemFree(cpp->abstract);
1962
return (CitPatPtr)MemFree(cpp);
1965
/*****************************************************************************
1967
* CitPatAsnRead(aip, atp)
1969
*****************************************************************************/
1970
NLM_EXTERN CitPatPtr LIBCALL CitPatAsnRead (AsnIoPtr aip, AsnTypePtr orig)
1974
AsnTypePtr atp, oldatp;
1979
if (! BiblioAsnLoad())
1986
if (orig == NULL) /* CitPat ::= */
1987
atp = AsnReadId(aip, amp, CIT_PAT);
1989
atp = AsnLinkType(orig, CIT_PAT);
1998
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the open SEQUENCE */
1999
atp = AsnReadId(aip, amp, atp); /* read title id */
2002
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
2003
cpp->title = (CharPtr)av.ptrvalue;
2004
atp = AsnReadId(aip, amp, atp); /* read author list id */
2007
cpp->authors = AuthListAsnRead(aip, atp);
2008
if (cpp->authors == NULL)
2010
atp = AsnReadId(aip, amp, atp ); /* country */
2013
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
2014
cpp->country = (CharPtr)av.ptrvalue;
2015
atp = AsnReadId(aip, amp, atp ); /* doc_type */
2018
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
2019
cpp->doc_type = (CharPtr)av.ptrvalue;
2021
while ((atp = AsnReadId(aip, amp, atp)) != oldatp) /* read options */
2025
if (atp == CIT_PAT_date_issue)
2027
cpp->date_issue = DateAsnRead(aip, atp);
2028
if (cpp->date_issue == NULL)
2031
else if (atp == CIT_PAT_app_date)
2033
cpp->app_date = DateAsnRead(aip, atp);
2034
if (cpp->app_date == NULL)
2037
else if (atp == CIT_PAT_applicants)
2039
cpp->applicants = AuthListAsnRead(aip, atp);
2040
if (cpp->applicants == NULL)
2043
else if (atp == CIT_PAT_assignees)
2045
cpp->assignees = AuthListAsnRead(aip, atp);
2046
if (cpp->assignees == NULL)
2049
else if (atp == CIT_PAT_priority)
2051
cpp->priority = PatPrioritySetAsnRead(aip, atp, CIT_PAT_priority_E);
2052
if (cpp->priority == NULL)
2057
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
2058
if (atp == CIT_PAT_number)
2060
cpp->number = (CharPtr)av.ptrvalue;
2062
if (atp == CIT_PAT_class)
2064
while ((atp = AsnReadId(aip, amp, atp)) != CIT_PAT_class)
2066
if (atp == NULL) goto erret;
2067
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
2068
vnp = ValNodeNew(cpp->_class);
2069
if (vnp == NULL) goto erret;
2070
if (cpp->_class == NULL)
2072
vnp->data.ptrvalue = (CharPtr)av.ptrvalue;
2074
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
2076
else if (atp == CIT_PAT_app_number)
2077
cpp->app_number = (CharPtr)av.ptrvalue;
2078
else if (atp == CIT_PAT_abstract)
2079
cpp->abstract = (CharPtr)av.ptrvalue;
2082
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end of SEQUENCE */
2084
AsnUnlinkType(orig);
2087
cpp = CitPatFree(cpp);
2091
/*****************************************************************************
2093
* CitPatAsnWrite(cpp, aip, atp)
2095
*****************************************************************************/
2096
NLM_EXTERN Boolean LIBCALL CitPatAsnWrite (CitPatPtr cpp, AsnIoPtr aip, AsnTypePtr orig)
2100
Boolean retval = FALSE;
2105
if (! BiblioAsnLoad())
2112
atp = AsnLinkType(orig, CIT_PAT);
2116
if (cpp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
2118
if (! AsnOpenStruct(aip, atp, (Pointer)cpp)) /* open the SEQUENCE */
2120
av.ptrvalue = cpp->title;
2121
if (! AsnWrite(aip, CIT_PAT_title, &av)) goto erret;
2122
if (! AuthListAsnWrite(cpp->authors, aip, CIT_PAT_authors))
2124
av.ptrvalue = cpp->country;
2125
if (! AsnWrite(aip, CIT_PAT_country, &av)) goto erret;
2126
av.ptrvalue = cpp->doc_type;
2127
if (! AsnWrite(aip, CIT_PAT_doc_type, &av)) goto erret;
2128
if (cpp->number != NULL)
2130
av.ptrvalue = cpp->number;
2131
if (! AsnWrite(aip, CIT_PAT_number, &av)) goto erret;
2133
if (cpp->date_issue != NULL)
2135
if (! DateAsnWrite(cpp->date_issue, aip, CIT_PAT_date_issue))
2138
if (cpp->_class != NULL)
2140
if (! AsnOpenStruct(aip, CIT_PAT_class, (Pointer)(cpp->_class)))
2142
for (vnp = cpp->_class; vnp != NULL; vnp = vnp->next)
2144
av.ptrvalue = vnp->data.ptrvalue;
2145
if (! AsnWrite(aip, CIT_PAT_class_E, &av)) goto erret;
2147
if (! AsnCloseStruct(aip, CIT_PAT_class, (Pointer)(cpp->_class)))
2150
if (cpp->app_number != NULL)
2152
av.ptrvalue = cpp->app_number;
2153
if (! AsnWrite(aip, CIT_PAT_app_number, &av)) goto erret;
2155
if (cpp->app_date != NULL)
2157
if (! DateAsnWrite(cpp->app_date, aip, CIT_PAT_app_date))
2161
if (cpp->applicants != NULL)
2163
if (! AuthListAsnWrite(cpp->applicants, aip, CIT_PAT_applicants))
2166
if (cpp->assignees != NULL)
2168
if (! AuthListAsnWrite(cpp->assignees, aip, CIT_PAT_assignees))
2171
if (cpp->priority != NULL)
2173
if (! PatPrioritySetAsnWrite(cpp->priority, aip, CIT_PAT_priority, CIT_PAT_priority_E))
2176
if (cpp->abstract != NULL)
2178
av.ptrvalue = cpp->abstract;
2179
if (! AsnWrite(aip, CIT_PAT_abstract, &av)) goto erret;
2182
if (! AsnCloseStruct(aip, atp, (Pointer)cpp)) /* end SEQUENCE */
2186
AsnUnlinkType(orig);
2190
/*****************************************************************************
2194
*****************************************************************************/
2195
NLM_EXTERN IdPatPtr LIBCALL IdPatNew (void)
2199
idp = (IdPatPtr)MemNew(sizeof(IdPat));
2203
/*****************************************************************************
2207
*****************************************************************************/
2208
NLM_EXTERN IdPatPtr LIBCALL IdPatFree (IdPatPtr idp)
2213
MemFree(idp->country);
2214
MemFree(idp->number);
2215
MemFree(idp->app_number);
2216
MemFree(idp->doc_type);
2217
return (IdPatPtr)MemFree(idp);
2220
/*****************************************************************************
2222
* IdPatAsnRead(aip, atp)
2224
*****************************************************************************/
2225
NLM_EXTERN IdPatPtr LIBCALL IdPatAsnRead (AsnIoPtr aip, AsnTypePtr orig)
2233
if (! BiblioAsnLoad())
2240
if (orig == NULL) /* IdPat ::= */
2241
atp = AsnReadId(aip, amp, ID_PAT);
2243
atp = AsnLinkType(orig, ID_PAT);
2251
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the open SEQUENCE */
2252
atp = AsnReadId(aip, amp, atp ); /* country */
2255
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
2256
idp->country = (CharPtr)av.ptrvalue;
2257
atp = AsnReadId(aip, amp, atp ); /* CHOICE */
2260
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
2261
atp = AsnReadId(aip, amp, atp ); /* number or app_number */
2264
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
2265
if (atp == ID_PAT_id_number)
2266
idp->number = (CharPtr)av.ptrvalue;
2268
idp->app_number = (CharPtr)av.ptrvalue;
2269
atp = AsnReadId(aip, amp, atp); /* end or doc-type */
2272
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
2273
if (atp == ID_PAT_doc_type)
2275
idp->doc_type = av.ptrvalue;
2276
atp = AsnReadId(aip, amp, atp);
2277
if (atp == NULL) goto erret;
2278
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end of SEQUENCE */
2281
AsnUnlinkType(orig);
2284
idp = IdPatFree(idp);
2288
/*****************************************************************************
2290
* IdPatAsnWrite(idp, aip, atp)
2292
*****************************************************************************/
2293
NLM_EXTERN Boolean LIBCALL IdPatAsnWrite (IdPatPtr idp, AsnIoPtr aip, AsnTypePtr orig)
2296
AsnTypePtr atp, numtype;
2298
Boolean retval = FALSE;
2302
if (! BiblioAsnLoad())
2309
atp = AsnLinkType(orig, ID_PAT);
2313
if (idp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
2315
if (! AsnOpenStruct(aip, atp, (Pointer)idp)) /* open the SEQUENCE */
2317
av.ptrvalue = idp->country;
2318
if (! AsnWrite(aip, ID_PAT_country, &av)) goto erret;
2319
if (idp->number != NULL)
2321
choicenum = 0; /* number */
2322
av.ptrvalue = idp->number;
2323
numtype = ID_PAT_id_number;
2327
choicenum = 1; /* app_number */
2328
av.ptrvalue = idp->app_number;
2329
numtype = ID_PAT_id_app_number;
2332
if (! AsnWriteChoice(aip, ID_PAT_id, choicenum, &av)) goto erret;
2333
if (! AsnWrite(aip, numtype, &av)) goto erret;
2335
if (idp->doc_type != NULL)
2337
av.ptrvalue = idp->doc_type;
2338
if (! AsnWrite(aip, ID_PAT_doc_type, &av)) goto erret;
2341
if (! AsnCloseStruct(aip, atp, (Pointer)idp)) /* end SEQUENCE */
2345
AsnUnlinkType(orig);
2349
/*****************************************************************************
2351
* Boolean IdPatMatch(a,b)
2353
*****************************************************************************/
2354
NLM_EXTERN Boolean LIBCALL IdPatMatch (IdPatPtr a, IdPatPtr b)
2356
if ((a == NULL) || (b == NULL))
2359
if (StringICmp(a->country, b->country)) /* countries must match */
2362
if ((a->number != NULL) && (b->number != NULL))
2364
if (! StringICmp(a->number, b->number))
2371
if (! StringICmp(a->app_number, b->app_number))
2378
/*****************************************************************************
2382
*****************************************************************************/
2383
NLM_EXTERN CitGenPtr LIBCALL CitGenNew (void)
2387
cgp = (CitGenPtr)MemNew(sizeof(CitGen));
2388
if (cgp == NULL) return cgp;
2391
cgp->serial_number = -1; /* not set */
2395
/*****************************************************************************
2399
*****************************************************************************/
2400
NLM_EXTERN CitGenPtr LIBCALL CitGenFree (CitGenPtr cgp)
2406
AuthListFree(cgp->authors);
2407
TitleFree(cgp->journal);
2408
MemFree(cgp->volume);
2409
MemFree(cgp->issue);
2410
MemFree(cgp->pages);
2411
DateFree(cgp->date);
2412
MemFree(cgp->title);
2414
return (CitGenPtr)MemFree(cgp);
2417
/*****************************************************************************
2419
* CitGenAsnRead(aip, atp)
2421
*****************************************************************************/
2422
NLM_EXTERN CitGenPtr LIBCALL CitGenAsnRead (AsnIoPtr aip, AsnTypePtr orig)
2426
AsnTypePtr atp, oldatp;
2430
if (! BiblioAsnLoad())
2437
if (orig == NULL) /* CitGen ::= */
2438
atp = AsnReadId(aip, amp, CIT_GEN);
2440
atp = AsnLinkType(orig, CIT_GEN);
2449
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the open SEQUENCE */
2450
while ((atp = AsnReadId(aip, amp, atp)) != oldatp)
2454
if (atp == CIT_GEN_authors)
2456
cgp->authors = AuthListAsnRead(aip, atp);
2457
if (cgp->authors == NULL)
2460
else if (atp == CIT_GEN_journal)
2462
cgp->journal = TitleAsnRead(aip, atp);
2463
if (cgp->journal == NULL)
2466
else if (atp == CIT_GEN_date)
2468
cgp->date = DateAsnRead(aip, atp);
2469
if (cgp->date == NULL)
2474
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
2475
if (atp == CIT_GEN_cit)
2476
cgp->cit = (CharPtr)av.ptrvalue;
2477
else if (atp == CIT_GEN_volume)
2478
cgp->volume = (CharPtr)av.ptrvalue;
2479
else if (atp == CIT_GEN_issue)
2480
cgp->issue = (CharPtr)av.ptrvalue;
2481
else if (atp == CIT_GEN_pages)
2482
cgp->pages = (CharPtr)av.ptrvalue;
2483
else if (atp == CIT_GEN_serial_number)
2484
cgp->serial_number = (Int2) av.intvalue;
2485
else if (atp == CIT_GEN_title)
2486
cgp->title = (CharPtr)av.ptrvalue;
2487
else if (atp == CIT_GEN_muid)
2488
cgp->muid = av.intvalue;
2489
else if (atp == CIT_GEN_pmid)
2490
cgp->pmid = av.intvalue;
2493
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end of SEQUENCE */
2495
AsnUnlinkType(orig);
2498
cgp = CitGenFree(cgp);
2502
/*****************************************************************************
2504
* CitGenAsnWrite(cgp, aip, atp)
2506
*****************************************************************************/
2507
NLM_EXTERN Boolean LIBCALL CitGenAsnWrite (CitGenPtr cgp, AsnIoPtr aip, AsnTypePtr orig)
2511
Boolean retval = FALSE;
2515
if (! BiblioAsnLoad())
2522
atp = AsnLinkType(orig, CIT_GEN);
2526
if (cgp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
2528
if (! AsnOpenStruct(aip, atp, (Pointer)cgp)) /* open the SEQUENCE */
2530
if (cgp->cit != NULL)
2532
av.ptrvalue = cgp->cit;
2533
if (! AsnWrite(aip, CIT_GEN_cit, &av)) goto erret;
2535
if (cgp->authors != NULL)
2537
if (! AuthListAsnWrite(cgp->authors, aip, CIT_GEN_authors))
2542
av.intvalue = cgp->muid;
2543
if (! AsnWrite(aip, CIT_GEN_muid, &av)) goto erret;
2545
if (cgp->journal != NULL)
2547
if (! TitleAsnWrite(cgp->journal, aip, CIT_GEN_journal))
2550
if (cgp->volume != NULL)
2552
av.ptrvalue = cgp->volume;
2553
if (! AsnWrite(aip, CIT_GEN_volume, &av)) goto erret;
2555
if (cgp->issue != NULL)
2557
av.ptrvalue = cgp->issue;
2558
if (! AsnWrite(aip, CIT_GEN_issue, &av)) goto erret;
2560
if (cgp->pages != NULL)
2562
av.ptrvalue = cgp->pages;
2563
if (! AsnWrite(aip, CIT_GEN_pages, &av)) goto erret;
2565
if (cgp->date != NULL)
2567
if (! DateAsnWrite(cgp->date, aip, CIT_GEN_date))
2570
if (cgp->serial_number >= 0)
2572
av.intvalue = (Int4)cgp->serial_number;
2573
if (! AsnWrite(aip, CIT_GEN_serial_number, &av)) goto erret;
2575
if (cgp->title != NULL)
2577
av.ptrvalue = cgp->title;
2578
if (! AsnWrite(aip, CIT_GEN_title, &av)) goto erret;
2582
if (aip->spec_version > 0 && aip->spec_version < 5) /* ASN4 strip new value */
2584
ErrPostEx(SEV_ERROR,0,0,"ASN4: PubMedId stripped");
2588
av.intvalue = cgp->pmid;
2589
if (! AsnWrite(aip, CIT_GEN_pmid, &av)) goto erret;
2592
if (! AsnCloseStruct(aip, atp, (Pointer)cgp)) /* end SEQUENCE */
2596
AsnUnlinkType(orig);
2600
/*****************************************************************************
2604
*****************************************************************************/
2605
NLM_EXTERN ValNodePtr LIBCALL TitleFree (ValNodePtr tp)
2614
MemFree(tp->data.ptrvalue);
2623
/*****************************************************************************
2625
* TitleAsnRead(aip, atp)
2627
*****************************************************************************/
2628
NLM_EXTERN ValNodePtr LIBCALL TitleAsnRead (AsnIoPtr aip, AsnTypePtr orig)
2630
ValNodePtr first=NULL, tp;
2632
AsnTypePtr atp, oldatp;
2636
if (! BiblioAsnLoad())
2643
if (orig == NULL) /* Title ::= */
2644
atp = AsnReadId(aip, amp, TITLE);
2646
atp = AsnLinkType(orig, TITLE);
2651
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the open SET OF */
2652
while ((atp = AsnReadId(aip, amp, atp)) != oldatp)
2656
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the CHOICE */
2657
atp = AsnReadId(aip, amp, atp); /* type of CHOICE */
2660
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
2661
tp = ValNodeNew(first);
2664
tp->data.ptrvalue = av.ptrvalue;
2667
if (atp == TITLE_E_name)
2669
else if (atp == TITLE_E_tsub)
2671
else if (atp == TITLE_E_trans)
2673
else if (atp == TITLE_E_jta)
2675
else if (atp == TITLE_E_iso_jta)
2677
else if (atp == TITLE_E_ml_jta)
2679
else if (atp == TITLE_E_coden)
2681
else if (atp == TITLE_E_issn)
2683
else if (atp == TITLE_E_abr)
2685
else if (atp == TITLE_E_isbn)
2688
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end of SET OF */
2690
AsnUnlinkType(orig);
2693
first = TitleFree(first);
2697
/*****************************************************************************
2699
* TitleAsnWrite(tp, aip, atp)
2701
*****************************************************************************/
2702
NLM_EXTERN Boolean LIBCALL TitleAsnWrite (ValNodePtr tp, AsnIoPtr aip, AsnTypePtr orig)
2705
AsnTypePtr atp, atp2;
2707
Boolean retval = FALSE;
2711
if (! BiblioAsnLoad())
2718
atp = AsnLinkType(orig, TITLE);
2722
if (tp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
2725
if (! AsnOpenStruct(aip, atp, (Pointer)oldtp)) /* open the SET OF */
2729
av.ptrvalue = tp->data.ptrvalue;
2732
case Cit_title_name:
2733
atp2 = TITLE_E_name;
2735
case Cit_title_tsub:
2736
atp2 = TITLE_E_tsub;
2738
case Cit_title_trans:
2739
atp2 = TITLE_E_trans;
2744
case Cit_title_iso_jta:
2745
atp2 = TITLE_E_iso_jta;
2747
case Cit_title_ml_jta:
2748
atp2 = TITLE_E_ml_jta;
2750
case Cit_title_coden:
2751
atp2 = TITLE_E_coden;
2753
case Cit_title_issn:
2754
atp2 = TITLE_E_issn;
2759
case Cit_title_isbn:
2760
atp2 = TITLE_E_isbn;
2768
if (! AsnWriteChoice(aip, TITLE_E, (Int2)tp->choice, &av)) goto erret;
2769
if (! AsnWrite(aip, atp2, &av)) goto erret;
2773
if (! AsnCloseStruct(aip, atp, (Pointer)oldtp)) /* end SET OF */
2777
AsnUnlinkType(orig);
2781
/*****************************************************************************
2785
*****************************************************************************/
2786
NLM_EXTERN CitSubPtr LIBCALL CitSubNew (void)
2790
csp = (CitSubPtr)MemNew(sizeof(CitSub));
2794
/*****************************************************************************
2798
*****************************************************************************/
2799
NLM_EXTERN CitSubPtr LIBCALL CitSubFree (CitSubPtr csp)
2804
AuthListFree(csp->authors);
2805
ImprintFree(csp->imp);
2806
DateFree(csp->date);
2807
MemFree(csp->descr);
2808
return (CitSubPtr)MemFree(csp);
2811
/*****************************************************************************
2813
* CitSubAsnRead(aip, atp)
2815
*****************************************************************************/
2816
NLM_EXTERN CitSubPtr LIBCALL CitSubAsnRead (AsnIoPtr aip, AsnTypePtr orig)
2824
if (! BiblioAsnLoad())
2831
if (orig == NULL) /* CitSub ::= */
2832
atp = AsnReadId(aip, amp, CIT_SUB);
2834
atp = AsnLinkType(orig, CIT_SUB);
2842
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the open SEQUENCE */
2843
atp = AsnReadId(aip, amp, atp); /* read authors id */
2846
csp->authors = AuthListAsnRead(aip, atp);
2847
if (csp->authors == NULL)
2849
atp = AsnReadId(aip, amp, atp); /* read imprint id */
2853
if (atp == CIT_SUB_imp)
2855
csp->imp = ImprintAsnRead(aip, atp);
2856
if (csp->imp == NULL)
2859
atp = AsnReadId(aip, amp, atp);
2864
if (atp == CIT_SUB_medium) /* nope, got medium */
2866
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
2867
csp->medium = (Uint1) av.intvalue;
2868
atp = AsnReadId(aip, amp, atp);
2873
if (atp == CIT_SUB_date) /* nope, got date */
2875
csp->date = DateAsnRead(aip, atp);
2876
if (csp->date == NULL) goto erret;
2877
atp = AsnReadId(aip, amp, atp);
2882
if (atp == CIT_SUB_descr) /* nope, got descr */
2884
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
2885
csp->descr = (CharPtr) av.ptrvalue;
2886
atp = AsnReadId(aip, amp, atp);
2891
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end of SEQUENCE */
2893
AsnUnlinkType(orig);
2896
csp = CitSubFree(csp);
2900
/*****************************************************************************
2902
* CitSubAsnWrite(csp, aip, atp)
2904
*****************************************************************************/
2905
NLM_EXTERN Boolean LIBCALL CitSubAsnWrite (CitSubPtr csp, AsnIoPtr aip, AsnTypePtr orig)
2909
Boolean retval = FALSE;
2913
if (! BiblioAsnLoad())
2920
atp = AsnLinkType(orig, CIT_SUB);
2924
if (csp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
2926
if (! AsnOpenStruct(aip, atp, (Pointer)csp)) /* open the SEQUENCE */
2928
if (! AuthListAsnWrite(csp->authors, aip, CIT_SUB_authors))
2931
if (csp->imp != NULL)
2933
if (! ImprintAsnWrite(csp->imp, aip, CIT_SUB_imp))
2939
av.intvalue = (Int4)csp->medium;
2940
if (! AsnWrite(aip, CIT_SUB_medium, &av)) goto erret;
2943
if (csp->date != NULL)
2945
if (! DateAsnWrite(csp->date, aip, CIT_SUB_date)) goto erret;
2948
if (csp->descr != NULL)
2950
av.ptrvalue = (Pointer)csp->descr;
2951
if (! AsnWrite(aip, CIT_SUB_descr, &av)) goto erret;
2954
if (! AsnCloseStruct(aip, atp, (Pointer)csp)) /* end SEQUENCE */
2958
AsnUnlinkType(orig);
2962
/*****************************************************************************
2964
* Int2 CitArtMatch(a, b)
2965
* returns 0 = same article
2966
* 1,-1 = different article
2968
*****************************************************************************/
2969
NLM_EXTERN Int2 LIBCALL CitArtMatch(CitArtPtr a, CitArtPtr b)
2979
if (a->from != b->from) /* different types */
2981
if (a->from < b->from)
2988
if (a->from == 1) /* journal article */
2989
retval = CitJourMatch((CitJourPtr)a->fromptr, (CitJourPtr)b->fromptr);
2990
else /* book or proceedings */
2991
retval = CitBookMatch((CitBookPtr)a->fromptr, (CitBookPtr)b->fromptr);
2995
if (retval) /* different sources */
2999
/* check all authors */
3000
retval = AuthListMatch(a->authors, b->authors, TRUE);
3008
retval = TitleMatch(a->title, b->title, Cit_title_name);
3009
if ((retval > 1) || (retval < -1)) /* not same type or NULL */
3010
retval = 0; /* matched everything else ok */
3017
/*****************************************************************************
3019
* Int2 CitBookMatch(a, b)
3020
* returns 0 = same book
3021
* 1,-1 = different book
3022
* Also does Cit-proc and Cit-let
3024
*****************************************************************************/
3025
NLM_EXTERN Int2 LIBCALL CitBookMatch (CitBookPtr a, CitBookPtr b)
3036
if (a->othertype > b->othertype)
3038
else if (a->othertype < b->othertype)
3041
retval = AuthListMatch(a->authors, b->authors, TRUE);
3045
retval = ImprintMatch(a->imp, b->imp, FALSE);
3049
retval = TitleMatch(a->title, b->title, Cit_title_name);
3050
if (retval == 2) /* not same type, it fails */
3052
else if (retval == -2)
3057
/*****************************************************************************
3059
* Int2 CitGenMatch(a, b, all)
3060
* returns 0 = same Cit-gen
3061
* 1,-1 = different Cit-gen
3062
* if (all) then all fields must be shared
3063
* otherwise, match only shared fields
3065
*****************************************************************************/
3066
NLM_EXTERN Int2 LIBCALL CitGenMatch (CitGenPtr a, CitGenPtr b, Boolean all)
3076
for (i = 0; i < 5; i++)
3101
if ((ap != NULL) && (bp != NULL))
3103
retval = StringICmp(ap, bp);
3106
else if (retval < 0)
3111
if ((ap == NULL) && (bp != NULL))
3113
else if ((ap != NULL) && (bp == NULL))
3118
if (((a->authors != NULL) && (b->authors != NULL)) ||
3119
(((a->authors != NULL) || (b->authors != NULL)) && all))
3121
retval = AuthListMatch(a->authors, b->authors, TRUE);
3126
if (((a->muid != 0) && (b->muid != 0)) || all)
3128
if (a->muid > b->muid)
3130
else if (a->muid < b->muid)
3134
if (((a->serial_number != -1) && (b->serial_number != -1)) || all)
3136
if (a->serial_number > b->serial_number)
3138
else if (a->serial_number < b->serial_number)
3142
if (((a->journal != NULL) && (b->journal != NULL)) || all)
3144
for (i = 1; i <= 10; i++)
3146
if (a->journal == NULL && b->journal == NULL) /* JAK */
3148
retval = TitleMatch(a->journal, b->journal, (Uint1)i);
3149
if (! retval) /* match */
3151
if ((retval == -1) || (retval == 1)) /* same type, diff journal */
3154
if (retval == 2) /* couldn't match the journal names, fail */
3156
else if (retval == -2)
3160
if (((a->date != NULL) && (b->date != NULL)) ||
3161
(((a->date != NULL) || (b->date != NULL)) && all))
3163
retval = DateMatch(a->date, b->date, TRUE);
3166
else if (retval == -2)
3170
if (all) { /* JAK */
3171
if (a->volume == NULL && b->volume == NULL &&
3172
a->issue == NULL && b->issue == NULL &&
3173
a->pages == NULL && b->pages == NULL &&
3174
a->title == NULL && b->title == NULL &&
3175
a->cit == NULL && b->cit == NULL &&
3176
a->authors == NULL && b->authors == NULL &&
3177
a->muid == -1 && b->muid == -1 &&
3178
a->journal == NULL && b->journal == NULL &&
3179
a->date == NULL && b->date == NULL &&
3180
a->serial_number != -1 && b->serial_number != -1) {
3188
/*****************************************************************************
3190
* Int2 CitSubMatch(a, b)
3191
* returns 0 = same submission
3192
* 1,-1 = different submission
3194
*****************************************************************************/
3195
NLM_EXTERN Int2 LIBCALL CitSubMatch (CitSubPtr a, CitSubPtr b)
3198
DatePtr da = NULL, db = NULL;
3205
retval = AuthListMatch(a->authors, b->authors, TRUE);
3209
if (a->imp != NULL && b->imp != NULL) {
3210
retval = ImprintMatch(a->imp, b->imp, FALSE);
3214
if (a->imp != NULL) {
3217
if (b->imp != NULL) {
3221
if (da == NULL && a->date != NULL) {
3224
if (db == NULL && b->date != NULL) {
3227
if (da != NULL && db != NULL) {
3228
retval = DateMatch(a->date, b->date, TRUE);
3231
else if (retval == -2)
3238
/*****************************************************************************
3240
* Int2 CitJourMatch(a, b)
3241
* returns 0 = same journal
3242
* 1,-1 = different journal
3244
*****************************************************************************/
3245
NLM_EXTERN Int2 LIBCALL CitJourMatch (CitJourPtr a, CitJourPtr b)
3248
static Uint1 journals[6] = { /* precedence for matching journal names */
3250
6 , /* medline_jta */
3262
for (i = 0; i < 6; i++)
3264
retval = TitleMatch(a->title, b->title, journals[i]);
3265
if (! retval) /* match */
3267
if ((retval == -1) || (retval == 1)) /* same type, diff journal */
3270
if (retval == 2) /* couldn't match the journal names, fail */
3272
else if (retval == -2)
3275
retval = ImprintMatch(a->imp, b->imp, FALSE);
3281
/*****************************************************************************
3283
* Int2 AuthListMatch(a, b, all)
3284
* returns 0 = same first author
3285
* 1,-1 = different first author
3286
* if (all) all authors must match
3288
*****************************************************************************/
3289
NLM_EXTERN Int2 LIBCALL AuthListMatch(AuthListPtr a, AuthListPtr b, Boolean all)
3291
Int2 retval = 1, lastnames = 0, i;
3309
listtype[0] = a->choice;
3310
listtype[1] = b->choice;
3311
while ((vnp[0] != NULL) && (vnp[1] != NULL))
3314
for (i = 0; i < 2; i++)
3317
if (listtype[i] == 1) /* std */
3319
ap = (AuthorPtr)(vnp[i]->data.ptrvalue);
3321
if (pip->choice == 2) /* std */
3323
nsp = (NameStdPtr)pip->data;
3324
if (nsp->names[0] != NULL) { /* last name */
3325
StringMove(name[i], nsp->names[0]);
3327
} else if (nsp->names[3] != NULL) /* full name */
3328
StringMove(name[i], nsp->names[0]);
3330
else if (pip->choice > 2)
3331
StringMove(name[i], (CharPtr)pip->data);
3334
StringMove(name[i], (CharPtr)(vnp[i]->data.ptrvalue));
3335
tlen = StringLen(name[i]);
3338
vnp[i] = vnp[i]->next;
3340
if (len == 0) /* nothing in one or more names */
3342
if (StringLen(name[0]) < tlen)
3347
if (lastnames == 2) {
3348
retval = (Int2)StringICmp(name[0], name[1]);
3350
retval = (Int2)StringNICmp(name[0], name[1], tlen);
3354
else if (retval > 0)
3356
if (! all) /* first only */
3360
if (vnp[0] != NULL) /* more names in a */
3362
else if (vnp[1] != NULL) /* more names in b */
3368
/*****************************************************************************
3370
* Int2 TitleMatch(a,b,type)
3371
* if can find two titles of "type" returns
3373
* 1,-1 = they don't match
3374
* 2,-2 = couldn't find two of "type"
3376
*****************************************************************************/
3377
NLM_EXTERN Int2 LIBCALL TitleMatch( ValNodePtr a, ValNodePtr b, Uint1 type)
3381
CharPtr t1=NULL, t2=NULL;
3385
if ((a == NULL) || (b == NULL))
3390
if (a->choice == type)
3392
t1 = (CharPtr)(a->data.ptrvalue);
3396
else if (a->choice > ca)
3403
if (b->choice == type)
3405
t2 = (CharPtr)(b->data.ptrvalue);
3409
else if (b->choice > cb)
3419
if ((t1 == NULL) || (t2 == NULL))
3422
retval = StringICmp(t1, t2);
3425
else if (retval < 0)
3431
/*****************************************************************************
3433
* Int2 ImprintMatch(a, b, all)
3436
* if (all) then all fields in one must be in the other
3437
* else, matches only fields found in both
3438
* NOTE: does not match on Imprint.pub or Imprint.prepub
3440
*****************************************************************************/
3441
NLM_EXTERN Int2 LIBCALL ImprintMatch (ImprintPtr a, ImprintPtr b, Boolean all)
3448
if ((a == NULL) || (b == NULL))
3451
retval = DateMatch(a->date, b->date, all);
3454
else if (retval == -2)
3459
for (i = 0; i < 6; i++)
3489
if ((ap != NULL) && (bp != NULL))
3491
retval = StringICmp(ap, bp);
3494
else if (retval < 0)
3499
if ((ap == NULL) && (bp != NULL))
3501
else if ((ap != NULL) && (bp == NULL))
3506
if ((a->cprt != NULL) || (b->cprt != NULL))
3508
retval = DateMatch(a->cprt, b->cprt, all);
3511
else if (retval == -2)
3519
/*****************************************************************************
3523
*****************************************************************************/
3524
NLM_EXTERN PatPriorityPtr LIBCALL PatPriorityNew (void)
3528
ppp = (PatPriorityPtr)MemNew(sizeof(PatPriority));
3532
/*****************************************************************************
3534
* PatPrioritySetFree()
3536
*****************************************************************************/
3537
NLM_EXTERN PatPriorityPtr LIBCALL PatPrioritySetFree (PatPriorityPtr ppp)
3539
PatPriorityPtr next;
3544
MemFree(ppp->country);
3545
MemFree(ppp->number);
3546
DateFree(ppp->date);
3553
/*****************************************************************************
3555
* PatPrioritySetAsnRead(aip, atp)
3557
*****************************************************************************/
3558
NLM_EXTERN PatPriorityPtr LIBCALL PatPrioritySetAsnRead (AsnIoPtr aip, AsnTypePtr set, AsnTypePtr element)
3560
PatPriorityPtr ppp=NULL, head, last;
3566
if (! BiblioAsnLoad())
3570
if ((aip == NULL) || (set == NULL) || (element == NULL))
3574
if (! AsnReadVal(aip, set, &av)) goto erret; /* START_STRUCT */
3580
while ((atp = AsnReadId(aip, amp, atp)) != set)
3582
if (atp == NULL) goto erret;
3583
ppp = PatPriorityNew();
3593
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the open SEQUENCE */
3594
atp = AsnReadId(aip, amp, atp ); /* country */
3597
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
3598
ppp->country = av.ptrvalue;
3599
atp = AsnReadId(aip, amp, atp ); /* number */
3602
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
3603
ppp->number = av.ptrvalue;
3604
atp = AsnReadId(aip, amp, atp ); /* date */
3607
ppp->date = DateAsnRead(aip, atp);
3608
if (ppp->date == NULL) goto erret;
3609
atp = AsnReadId(aip, amp, atp); /* end struct */
3610
if (atp == NULL) goto erret;
3611
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
3613
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* end SEQUENCE OF */
3617
head = PatPrioritySetFree(head);
3621
/*****************************************************************************
3623
* PatPrioritySetAsnWrite(ppp, aip, atp)
3625
*****************************************************************************/
3626
NLM_EXTERN Boolean LIBCALL PatPrioritySetAsnWrite (PatPriorityPtr ppp, AsnIoPtr aip, AsnTypePtr set, AsnTypePtr element)
3629
Boolean retval = FALSE;
3634
if (! BiblioAsnLoad())
3638
if ((aip == NULL) || (set == NULL) || (element == NULL))
3641
if (ppp == NULL) { AsnNullValueMsg(aip, set); goto erret; }
3643
if (! AsnOpenStruct(aip, set, (Pointer)ppp)) /* open the SEQUENCE OF */
3646
for (tmp = ppp; tmp != NULL; tmp = tmp->next)
3648
if (! AsnOpenStruct(aip, element, (Pointer)tmp)) /* open the SEQUENCE */
3652
av.ptrvalue = tmp->country;
3653
if (! AsnWrite(aip, PATENT_PRIORITY_country, &av)) goto erret;
3654
av.ptrvalue = tmp->number;
3655
if (! AsnWrite(aip, PATENT_PRIORITY_number, &av)) goto erret;
3656
if (! DateAsnWrite(tmp->date, aip, PATENT_PRIORITY_date)) goto erret;
3658
if (! AsnCloseStruct(aip, element, (Pointer)tmp))
3662
if (! AsnCloseStruct(aip, set, (Pointer)ppp)) /* end SEQUENCE OF */
3670
/*****************************************************************************
3674
*****************************************************************************/
3675
NLM_EXTERN ArticleIdPtr LIBCALL ArticleIdNew (void)
3679
aidp = (ArticleIdPtr)MemNew(sizeof(ArticleId));
3683
/*****************************************************************************
3687
*****************************************************************************/
3688
NLM_EXTERN ArticleIdPtr LIBCALL ArticleIdFree (ArticleIdPtr aidp)
3693
switch (aidp->choice)
3695
case ARTICLEID_DOI: /* string types */
3697
case ARTICLEID_PMCPID:
3698
case ARTICLEID_PMPID:
3699
MemFree (aidp->data.ptrvalue);
3702
case ARTICLEID_OTHER: /* dbtag */
3703
DbtagFree ((DbtagPtr)(aidp->data.ptrvalue));
3705
default: /* integer types */
3709
return (ArticleIdPtr)MemFree(aidp);
3712
/*****************************************************************************
3714
* ArticleIdAsnRead(aip, atp)
3716
*****************************************************************************/
3717
NLM_EXTERN ArticleIdPtr LIBCALL ArticleIdAsnRead (AsnIoPtr aip, AsnTypePtr orig)
3719
ArticleIdPtr aidp=NULL;
3726
if (! BiblioAsnLoad())
3733
if (orig == NULL) /* ArticleId ::= */
3734
atp = AsnReadId(aip, amp, ARTICLEID);
3736
atp = AsnLinkType(orig, ARTICLEID);
3740
aidp = ArticleIdNew();
3744
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the CHOICE */
3745
atp = AsnReadId(aip, amp, atp); /* read the CHOICE id */
3749
if (atp == ARTICLEID_pubmed)
3751
else if (atp == ARTICLEID_medline)
3753
else if (atp == ARTICLEID_doi)
3755
else if (atp == ARTICLEID_pii)
3757
else if (atp == ARTICLEID_pmcid)
3759
else if (atp == ARTICLEID_pmcpid)
3761
else if (atp == ARTICLEID_pmpid)
3763
else if (atp == ARTICLEID_other)
3767
ErrPostEx(SEV_ERROR, 0,0, "Unrecognized ArticleId");
3771
aidp->choice = choice;
3772
if (choice == ARTICLEID_OTHER)
3774
aidp->data.ptrvalue = DbtagAsnRead(aip, atp);
3775
if (aidp->data.ptrvalue == NULL)
3780
if (AsnReadVal(aip, atp, &(aidp->data)) <= 0)
3785
AsnUnlinkType(orig);
3788
aidp = ArticleIdFree(aidp);
3792
/*****************************************************************************
3794
* ArticleIdAsnWrite(aidp, aip, atp)
3796
*****************************************************************************/
3797
NLM_EXTERN Boolean LIBCALL ArticleIdAsnWrite (ArticleIdPtr aidp, AsnIoPtr aip, AsnTypePtr orig)
3800
AsnTypePtr atp, atp2;
3801
Boolean retval = FALSE;
3805
if (! BiblioAsnLoad())
3812
atp = AsnLinkType(orig, ARTICLEID);
3816
if (aidp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
3821
if (! AsnWrite(aip, atp, &av)) /* write the tag */
3825
switch (aidp->choice)
3827
case ARTICLEID_PUBMED:
3828
atp2 = ARTICLEID_pubmed;
3830
case ARTICLEID_MEDLINE:
3831
atp2 = ARTICLEID_medline;
3834
atp2 = ARTICLEID_doi;
3837
atp2 = ARTICLEID_pii;
3839
case ARTICLEID_PMCID:
3840
atp2 = ARTICLEID_pmcid;
3842
case ARTICLEID_PMCPID:
3843
atp2 = ARTICLEID_pmcpid;
3845
case ARTICLEID_PMPID:
3846
atp2 = ARTICLEID_pmpid;
3848
case ARTICLEID_OTHER:
3849
atp2 = ARTICLEID_other;
3855
if (aidp->choice == ARTICLEID_OTHER)
3857
if (! DbtagAsnWrite((DbtagPtr)(aidp->data.ptrvalue), aip, atp2))
3860
else if (atp2 != NULL)
3862
if (! AsnWrite(aip, atp2, &(aidp->data)))
3870
AsnUnlinkType(orig);
3875
/*****************************************************************************
3877
* PubStatusDateNew()
3879
*****************************************************************************/
3880
NLM_EXTERN PubStatusDatePtr LIBCALL PubStatusDateNew (void)
3882
PubStatusDatePtr psdp;
3884
psdp = (PubStatusDatePtr)MemNew(sizeof(PubStatusDate));
3888
/*****************************************************************************
3890
* PubStatusDateFree()
3892
*****************************************************************************/
3893
NLM_EXTERN PubStatusDatePtr LIBCALL PubStatusDateFree (PubStatusDatePtr psdp)
3897
DateFree (psdp->date);
3898
return (PubStatusDatePtr)MemFree(psdp);
3901
/*****************************************************************************
3903
* PubStatusDateAsnRead(aip, atp)
3905
*****************************************************************************/
3906
NLM_EXTERN PubStatusDatePtr LIBCALL PubStatusDateAsnRead (AsnIoPtr aip, AsnTypePtr orig)
3908
PubStatusDatePtr psdp=NULL;
3910
AsnTypePtr atp, oldatp;
3914
if (! BiblioAsnLoad())
3921
if (orig == NULL) /* PubStatusDate ::= */
3922
atp = AsnReadId(aip, amp, PUBSTATUSDATE);
3924
atp = AsnLinkType(orig, PUBSTATUSDATE);
3928
psdp = PubStatusDateNew();
3933
if (AsnReadVal(aip, atp, &av) <= 0) goto erret; /* read the START STRUCT */
3934
atp = AsnReadId(aip, amp, atp); /* read the PubStatus */
3937
if (AsnReadVal(aip, atp, &av) <= 0) goto erret;
3938
psdp->pubstatus = (Uint1)(av.intvalue);
3939
atp = AsnReadId(aip, amp, atp);
3940
if (atp == NULL) goto erret;
3941
psdp->date = DateAsnRead(aip, atp);
3942
if (psdp->date == NULL)
3944
atp = AsnReadId(aip, amp, atp);
3945
if (atp == NULL) goto erret;
3946
if (AsnReadVal(aip, oldatp, &av) <= 0) goto erret; /* read the END STRUCT */
3949
AsnUnlinkType(orig);
3952
psdp = PubStatusDateFree(psdp);
3956
/*****************************************************************************
3958
* PubStatusDateAsnWrite(psdp, aip, atp)
3960
*****************************************************************************/
3961
NLM_EXTERN Boolean LIBCALL PubStatusDateAsnWrite (PubStatusDatePtr psdp, AsnIoPtr aip, AsnTypePtr orig)
3965
Boolean retval = FALSE;
3969
if (! BiblioAsnLoad())
3976
atp = AsnLinkType(orig, PUBSTATUSDATE);
3980
if (psdp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
3982
if (! AsnOpenStruct(aip, atp, (Pointer)psdp))
3985
av.intvalue = (Int4)(psdp->pubstatus);
3986
if (! AsnWrite(aip, PUBSTATUSDATE_pubstatus, &av)) goto erret;
3987
if (! DateAsnWrite(psdp->date, aip, PUBSTATUSDATE_date)) goto erret;
3989
if (! AsnCloseStruct(aip, atp, (Pointer)psdp)) goto erret;
3993
AsnUnlinkType(orig);