bibutils_4.12/0000775000076400007640000000000011475753014013570 5ustar cdputnamcdputnambibutils_4.12/bibutils.dbk0000644000076400007640000005107211444072056016066 0ustar cdputnamcdputnam David"> Bremner"> February 10, 2008"> 1"> bremner@unb.ca"> BIBUTILS"> Debian"> GNU"> GPL"> ]>
&dhemail;
2008 &dhusername; (Manual) 2008 Christopher Putnam (Software and Manual) This manual page is distributed under the terms of version 2 of the GNU General Public License. &dhdate;
&dhucpackage; &dhsection; &dhpackage; &version; User Commands bibutils bibliography conversion utilities format2xml OPTIONS file.format xml2format OPTIONS file.xml DESCRIPTION The bibutils program set inter-converts between various bibliography formats using Library of Congress's Metadata Object Description Schema (MODS)version 3.1. For example, one can convert RIS-format files to Bibtex by doing two transformations: RIS->MODS->Bibtex. Converting to MODS Overview Command Description convert bibtex to MODS convert COPACformat references to MODS convert EndNote (Refer format) to MODS convert EndNote XML to MODS convert ISI web of science to MODS med2xml convert Pubmed XML references to MODS modscleana MODS to MODS converter convert RIS format to MODS Common Options Converting to MODS Several flags available for the end2xml, endx2xml, bib2xml, ris2xml, med2xml, and copac2xml programs. Most options have both a short and a long version. -h --help display help -v--version display version -a--add-refcount add "_#", where # is reference count to reference id -s--single-refperfile put one reference per file name by the reference number -i --input-encoding interpret the input file as using the requested character set (use w/o argument for current list derived from character sets at www.kostis.net) unicode is now a character set option -u --unicode-characters encode unicode characters directly in the file rather than as XML entities -un --unicode-no-bom as -u, but don't include a byte order mark -d --drop-key don't put citation key in the mods id field -c --corporation-file with argument specifying a file containing a list of corporation names to be placed in <name type="corporate"></name> instead of type="personal" and eliminate name mangling --verbose verbose output --debug very verbose output (mostly for debugging) bib2xml bib2xml converts a bibtex-formatted reference file to an XML-intermediate bibliography file. Specify file(s) to be converted on the command line. Files containing bibtex substitutions strings should be specified before the files where substitutions are specified (or in the same file before their use). If no files are specified, then bibtex information will be read from standard input. bib2xml bibtex_file.bib > output_file.xml copac2xml copac2xmlconverts a COPAC formatted reference file to a MODS XML-intermediate bibliography file. end2xml end2xml converts a text endnote-formatted reference file to an XML-intermediate bibliography file. This program will not work on the binary library; the file needs to be exported first. Endnote tagged formats ("Refer" format export) look like . There are very nice instructions for making sure that you are properly exporting this at http://www.sonnysoftware.com/endnoteimport.html Usage for end2xml is the same as bib2xml. end2xml endnote_file.end > output_file.xml endx2xml endx2xml converts a EndNote-XML exported reference file to a MODS XML-intermediate bibliography file. This program will not work on the binary library; the file needs to be exported first. isi2xml isi2xml converts an ISI-web-of-science-formatted reference file to an XML-intermediate bibliography file. Usage for isi2xml is the same as bib2xml. isi2xml input_file.isi > output_file.xml ris2xml ris2xml converts a RIS-formatted reference file to an XML-intermediate bibliography file. ris2xml usage is as end2xml and bib2xml ris2xml ris_file.ris > output_file.xml Converting from MODS Overview Command Description convert MODS into the SAO/NASA ADS format convert MODS into bibtex convert MODS into format for EndNote xml2isi convert MODS to ISI format convert MODS into RIS format convert MODS into Word 2007 bibliography format Common Options Converting from MODS Note that --output-encoding refers to the input file -h --help display help -v--version display version -o--output-encodinginterpret the input file as using the requested character set (use w/o argument for current list derived from character sets at www.kostis.net) unicode is now a character set option -s--single-refperfile put one reference per file name by the reference number xml2bib xml2bib converts the MODS XML bibliography into a bibtex-formatted reference file. xml2bib usage is as for other tools xml2bib xml_file.xml > output_file.bib Since the BibTeX reference format is fairly flexible and seems to have the greatest number of personal preferences, it has also accumulated a number of specific options that are not available for other formats. Starting with 3.24, xml2bib output uses lowercase tags and mixed case reference types for better interaction with other software. The older behavior with all uppercase tags/reference types can still be generated using the command-line switch -U/--uppercase. xml2bib-specific Options: -fc --finalcomma add final comma in the bibtex output for those that want it -sd --singledash use one dash instead of two (longer dash in latex) between numbers in page output -b --brackets use brackets instead of quotation marks around field data -w --whitespace add beautifying whitespace to output -U --uppercase use all uppercase for tags (field names) and reference types (pre-3.24 behavior) -sk --strictkey only use alphanumeric characters for bibtex citation keys xml2ads xml2ads converts the MODS XML bibliography to the Smithsonian Astrophysical Observatory (SAO)/National Aeronautics and Space Administration (NASA) Astrophyics Data System or ADS reference format (which is very similar to the tagged Endnote style). xml2ads usage is as for other tools xml2ads xml_file.xml > output_file.ads xml2ris xml2ris converts the MODS XML bibliography to RIS-formatted bibliography file. xml2ris usage is as for other tools xml2ris xml_file.xml > output_file.ris xml2end xml2end converts the MODS XML bibliography to tagged Endnote (refer-format) bibliography file. xml2end usage is as for other tools xml2end xml_file.xml > output_file.end xml2wordbib xml2wordbib converts the MODS XML bibliography to Word 2007-formatted XML bibliography file. xml2wordbib usage is as for other tools xml2wordbib xml_file.xml > output_file.word.xml xml2wordbib was called xml2word in versions of bibutils prior to 3.40. It was renamed to avoid confusion with other tools. Hopefully this will not break too many scripts already in use. Examples Example <command>refer</command> format file %0 Journal Article %A C. D. Putnam %A C. S. Pikaard %D 1992 %T Cooperative binding of the Xenopus RNA polymerase I transcription factor xUBF to repetitive ribosomal gene enhancers %J Mol Cell Biol %V 12 %P 4970-4980 %F Putnam1992 <command>xml2bib</command> Output Variations Default @Article{Putnam1992, author="C. D. Putnam and C. S. Pikaard", year="1992", month="Nov", title="Cooperative binding of the Xenopus RNA polymerase I transcription factor xUBF to repetitive ribosomal gene enhancers", journal="Mol Cell Biol", volume="12", pages="4970--4980", number="11"} Final Comma @Article{Putnam1992, author="C. D. Putnam and C. S. Pikaard", year="1992", month="Nov", title="Cooperative binding of the Xenopus RNA polymerase I transcription factor xUBF to repetitive ribosomal gene enhancers", journal="Mol Cell Biol", volume="12", pages="4970--4980", number="11",} Single Dash @Article{Putnam1992, author="C. D. Putnam and C. S. Pikaard", year="1992", month="Nov", title="Cooperative binding of the Xenopus RNA polymerase I transcription factor xUBF to repetitive ribosomal gene enhancers", journal="Mol Cell Biol", volume="12", pages="4970-4980", number="11"} Whitespace @Article{Putnam1992, author = "C. D. Putnam and C. S. Pikaard", year = "1992", month = "Jan", title = "Cooperative binding of the Xenopus RNA polymerase I transcription factor xUBF to repetitive ribosomal gene enhancers", journal = "Mol Cell Biol", volume = "12", pages = "4970--4980" } Brackets @Article{Putnam1992, author={Putnam, C. D. and Pikaard, C. S.}, title={Cooperative binding of the Xenopus RNA polymerase I transcription factor xUBF to repetitive ribosomal gene enhancers}, journal={Mol Cell Biol}, year={1992}, month={Nov}, volume={12}, number={11}, pages={4970--4980} } Uppercase @ARTICLE{Putnam1992, AUTHOR="Putnam, C. D. and Pikaard, C. S.", TITLE="Cooperative binding of the Xenopus RNA polymerase I transcription factor xUBF to repetitive ribosomal gene enhancers", JOURNAL="Mol Cell Biol", YEAR="1992", MONTH="Nov", VOLUME="12", NUMBER="11", PAGES="4970--4980" } License All versions of bibutils are relased under the GNU Public License (GPL). In a nutshell, feel free to download, run, and modify these programs as required. If you re-release these, you need to release the modified version of the source. (And I'd appreciate patches as well...if you care enough to make the change, then I'd like to see what you're adding or fixing.) Chris Putnam, Ludwig Institute for Cancer Research
bibutils_4.12/maketgz.csh0000644000076400007640000000115311444072056015723 0ustar cdputnamcdputnam#!/bin/csh -f # # $1 = version number # $2 = postfix # # set programs = ( biblatex2xml bib2xml copac2xml ebi2xml end2xml endx2xml ebi2xml isi2xml med2xml wordbib2xml modsclean ris2xml xml2ads xml2bib xml2end xml2isi xml2ris xml2wordbib ) set VERSION = $1 set POSTFIX = $2 if ( ! (-e update) ) mkdir update if ( -e update/bibutils_${VERSION} ) /bin/rm -r update/bibutils_${VERSION} mkdir update/bibutils_${VERSION} foreach p ( $programs ) cp bin/${p} update/bibutils_${VERSION}/${p} end cd update tar cvf - bibutils_${VERSION} | gzip - > bibutils_${VERSION}${POSTFIX}.tgz cd .. rm -r update/bibutils_${VERSION} bibutils_4.12/configure0000755000076400007640000001363211454375030015475 0ustar cdputnamcdputnam#!/bin/csh -f set INPUT_FILE = Makefile_start set OUTPUT_FILE = Makefile set LIBTYPE = static set INSTALLDIR = /usr/local/bin set LIBINSTALLDIR = /usr/local/lib while ( ${#argv} > 0 ) if ( $1 == "--install-dir" ) then if ( ${#argv} < 2 ) then echo "--install-dir requires a directory" exit else shift set INSTALLDIR = $1 shift endif else if ( $1 == "--install-lib" ) then if ( ${#argv} < 2 ) then echo "--install-lib requires a directory" exit else shift set LIBINSTALLDIR = $1 shift endif else if ( $1 == "--dynamic" ) then set LIBTYPE = dynamic shift else if ( $1 == "--static" ) then set LIBTYPE = static shift else echo "Unidentified argument $1" exit endif end if ( "$LIBTYPE" == "dynamic" ) then cp lib/Makefile.dynamic lib/Makefile cp bin/Makefile.dynamic bin/Makefile else cp lib/Makefile.static lib/Makefile cp bin/Makefile.static bin/Makefile endif set type = "Unknown" set universal_binary = "FALSE" set UNAME = `uname -a` if ( ` echo $UNAME | grep Linux | wc | awk '{print $1;}' ` == 1 ) then if ( ` echo $UNAME | grep 'i[3456]86' | wc | awk '{print $1};'` == 1 ) then set type = "Linux_x86" else if ( ` echo $UNAME | grep 'x86_64' | wc | awk '{print $1};'` == 1 ) then set type = "Linux_x86_64" else set type = "Linux_Unknown" endif endif if ( ` echo $UNAME | grep Darwin | wc | awk '{print $1;}' ` == 1 ) then set type = "MacOSX_Unknown" if ( ` echo $UNAME | grep -E 'powerpc|Power Macintosh' | wc | awk '{print $1};'` == 1 ) then set type = "MacOSX_ppc" endif if ( ` echo $UNAME | grep 'i386' | wc | awk '{print $1}'` == 1 ) then set type = "MacOSX_intel" endif endif if ( ` echo $UNAME | grep SunOS | wc | awk '{print $1;}' ` == 1 ) then set type = "SunOS5" endif if ( ` echo $UNAME | grep IRIX | wc | awk '{print $1;}' ` == 1 ) then set type = "IRIX" endif if ( ` echo $UNAME | grep NetBSD | wc | awk '{print $1;}' ` == 1 ) then set type = "NetBSD" endif if ( ` echo $UNAME | grep FreeBSD | wc | awk '{print $1;}' ` == 1 ) then set type = "FreeBSD" endif if ( ` echo $UNAME | grep Cygwin | wc | awk '{print $1;}' ` == 1 ) then set type = "Cygwin" endif # # Support universal binaries for MacOSX's (gcc version 4 and higher) # # restrict to intel Mac's only because ppc Mac's I have access to # just don't have the i386 libraries... # #if ( $type == "MacOSX_ppc" || $type == "MacOSX_intel" ) then if ( $type == "MacOSX_intel" ) then gcc -v >& tmp.$$ set gcc_version = ` grep version tmp.$$ | awk '{print $3;}' ` set gcc_major = ` echo $gcc_version | awk -v FS="." '{print $1;}' ` if ( $gcc_major > 3 ) then set universal_binary = "TRUE" endif /bin/rm -f tmp.$$ endif if ( $type == "Linux_x86" ) then set CC = '"cc -Wall"' set RANLIB = '"ranlib"' set POSTFIX = '"_i386"' else if ( $type == "Linux_x86_64" ) then set CC = '"cc -Wall"' set RANLIB = '"ranlib"' set POSTFIX = '"_amd64"' else if ( $type == "Linux_Unknown" ) then set CC = '"cc -Wall"' set RANLIB = '"ranlib"' set POSTFIX = '""' else if ( $type == "MacOSX_ppc" && $universal_binary == "TRUE" ) then set CC = '"cc -arch i386 -arch ppc -Wall"' set RANLIB = '"ranlib -s"' set POSTFIX = '"_osx_universal"' else if ( $type == "MacOSX_intel" && $universal_binary == "TRUE" ) then set CC = '"cc -arch i386 -arch ppc -Wall"' set RANLIB = '"ranlib -s"' set POSTFIX = '"_osx_universal"' else if ( $type == "MacOSX_ppc" || $type == "MacOSX_intel" || \ $type == "MacOSX_Unknown" ) then set CC = '"cc -Wall"' set RANLIB = '"ranlib -s"' set POSTFIX = '"_osx"' else if ( $type == "SunOS5" ) then set CC = '"gcc -Wall"' set RANLIB = '"echo Skipping ranlib"' set POSTFIX = '"_sunos5"' else if ( $type == "IRIX" ) then set CC = '"gcc -Wall"' set RANLIB = '"echo Skipping ranlib"' echo POSTFIX = '"_irix"' else if ( $type == "NetBSD" ) then set CC = '"cc -Wall"' set RANLIB = '"ranlib"' set POSTFIX = '"_netbsd"' else if ( $type == "FreeBSD" ) then set CC = '"cc -Wall"' set RANLIB = '"ranlib"' set POSTFIX = '"_freebsd"' else if ( $type == "Cygwin" ) then set CC = '"cc -Wall"' set RANLIB = '"echo Skipping ranlib"' set POSTFIX = '"_cygwin"' else # Unknown operating system set CC = '"cc"' set RANLIB = '"echo Skipping ranlib"' set POSTFIX = '""' endif cat $INPUT_FILE | \ sed "s/REPLACE_CC/CC=${CC}/" | \ sed "s/REPLACE_RANLIB/RANLIB=${RANLIB}/" | \ sed "s|REPLACE_INSTALLDIR|${INSTALLDIR}|" | \ sed "s|REPLACE_LIBINSTALLDIR|${LIBINSTALLDIR}|" | \ sed "s/REPLACE_POSTFIX/${POSTFIX}/" > $OUTPUT_FILE echo echo echo "Bibutils Configuration" echo "----------------------" echo echo "Operating system: $type" echo "Library and binary type: $LIBTYPE" echo "Binary installation directory: $INSTALLDIR" echo "Library installation directory: $LIBINSTALLDIR" echo echo " - If auto-identification of operating system failed, e-mail cdputnam@ucsd.edu" echo " with the output of the command: uname -a" echo echo " - Use --static or --dynamic to specify library and binary type;" echo " the --static option is the default" echo echo " - Set binary installation directory with: --install-dir DIR" echo echo " - Set library installation directory with: --install-lib DIR" echo echo if ( $OUTPUT_FILE == "Makefile" ) then echo "To compile, type: make" echo "To install, type: make install" echo "To make tgz package, type: make package" echo "To make deb package, type: make deb" echo echo "To clean up temporary files, type: make clean" echo "To clean up all files, type: make realclean" else echo "To compile, type: make -f $OUTPUT_FILE" echo "To install, type: make -f $OUTPUT_FILE install" echo "To make tgz package, type: make -f $OUTPUT_FILE package" echo "To make deb package, type: make -f $OUTPUT_FILE deb" echo echo "To clean up temporary files, type: make -f $OUTPUT_FILE clean" echo "To clean up all files, type: make -f $OUTPUT_FILE realclean" endif echo echo bibutils_4.12/lib/0000755000076400007640000000000011477220252014327 5ustar cdputnamcdputnambibutils_4.12/lib/is_ws.h0000644000076400007640000000036511444072056015631 0ustar cdputnamcdputnam/* * is_ws.h * * Copyright (c) Chris Putnam 2003-2009 * * Source code released under the GPL * */ #ifndef IS_WS_H #define IS_WS_H extern int is_ws( char ch ); extern char *skip_ws( char *p ); extern char *skip_notws( char *p ); #endif bibutils_4.12/lib/wordout.c0000644000076400007640000003726111477220220016202 0ustar cdputnamcdputnam/* * wordout.c * * (Word 2007 format) * * Copyright (c) Chris Putnam 2007-2010 * * Source code released under the GPL * */ #include #include #include #include "newstr.h" #include "fields.h" #include "utf8.h" #include "wordout.h" void wordout_initparams( param *p, const char *progname ) { p->writeformat = BIBL_WORD2007OUT; p->format_opts = 0; p->charsetout = BIBL_CHARSET_UNICODE; p->charsetout_src = BIBL_SRC_DEFAULT; p->latexout = 0; p->utf8out = 0; p->utf8bom = 0; if ( !p->utf8out ) p->xmlout = 3; else p->xmlout = 1; p->nosplittitle = 0; p->verbose = 0; p->addcount = 0; p->singlerefperfile = 0; p->headerf = wordout_writeheader; p->footerf = wordout_writefooter; p->writef = wordout_write; } typedef struct convert { char oldtag[25]; char newtag[25]; int code; } convert; typedef struct outtype { int value; char *out; } outtype; /* At the moment 17 unique types of sources are defined: {code} Art ArticleInAPeriodical Book BookSection Case Conference DocumentFromInternetSite ElectronicSource Film InternetSite Interview JournalArticle Report Misc Patent Performance Proceedings SoundRecording {code} */ enum { TYPE_UNKNOWN = 0, TYPE_ART, TYPE_ARTICLEINAPERIODICAL, TYPE_BOOK, TYPE_BOOKSECTION, TYPE_CASE, TYPE_CONFERENCE, TYPE_DOCUMENTFROMINTERNETSITE, TYPE_ELECTRONICSOURCE, TYPE_FILM, TYPE_INTERNETSITE, TYPE_INTERVIEW, TYPE_JOURNALARTICLE, TYPE_MISC, TYPE_PATENT, TYPE_PERFORMANCE, TYPE_PROCEEDINGS, TYPE_REPORT, TYPE_SOUNDRECORDING, TYPE_THESIS, TYPE_MASTERSTHESIS, TYPE_PHDTHESIS, }; /* * fixed output */ static void output_fixed( FILE *outptr, char *tag, char *data, int level ) { int i; for ( i=0; i%s\n", tag, data, tag ); } /* detail output * */ static void output_item( fields *info, FILE *outptr, char *tag, int item, int level ) { int i; if ( item==-1 ) return; for ( i=0; i%s\n", tag, info->data[item].data, tag ); fields_setused( info, item ); } /* range output * * start-end * */ static void output_range( fields *info, FILE *outptr, char *tag, int start, int end, int level ) { int i; if ( start==-1 && end==-1 ) return; if ( start==-1 ) output_item( info, outptr, tag, end, 0 ); else if ( end==-1 ) output_item( info, outptr, tag, start, 0 ); else { for ( i=0; i%s-%s\n", tag, info->data[start].data, info->data[end].data, tag ); fields_setused( info, start ); fields_setused( info, end ); } } static void output_list( fields *info, FILE *outptr, convert *c, int nc ) { int i, n; for ( i=0; infields; ++i ) { if ( strcasecmp( info->tag[i].data, "GENRE" ) && strcasecmp( info->tag[i].data, "NGENRE" ) ) continue; genre = info->data[i].data; for ( j=0; jlevel[i]; if ( !strcasecmp( genre, "academic journal" ) ) { type = TYPE_JOURNALARTICLE; } else if ( !strcasecmp( genre, "periodical" ) ) { if ( type == TYPE_UNKNOWN ) type = TYPE_ARTICLEINAPERIODICAL; } else if ( !strcasecmp( genre, "book" ) || !strcasecmp( genre, "collection" ) ) { if ( info->level[i]==0 ) type = TYPE_BOOK; else type = TYPE_BOOKSECTION; } else if ( !strcasecmp( genre, "conference publication" ) ) { if ( level==0 ) type=TYPE_CONFERENCE; type = TYPE_PROCEEDINGS; } else if ( !strcasecmp( genre, "thesis" ) ) { if ( type==TYPE_UNKNOWN ) type=TYPE_THESIS; } else if ( !strcasecmp( genre, "Ph.D. thesis" ) ) { type = TYPE_PHDTHESIS; } else if ( !strcasecmp( genre, "Masters thesis" ) ) { type = TYPE_MASTERSTHESIS; } } } return type; } static int get_type_from_resource( fields *info ) { int type = TYPE_UNKNOWN, i; char *resource; for ( i=0; infields; ++i ) { if ( strcasecmp( info->tag[i].data, "GENRE" )!=0 && strcasecmp( info->tag[i].data, "NGENRE" )!=0 ) continue; resource = info->data[i].data; if ( !strcasecmp( resource, "moving image" ) ) type = TYPE_FILM; } return type; } static int get_type( fields *info ) { int type; type = get_type_from_genre( info ); if ( type==TYPE_UNKNOWN ) type = get_type_from_resource( info ); return type; } static void output_titleinfo( fields *info, FILE *outptr, char *tag, int level ) { char *p; int ttl, subttl; ttl = fields_find( info, "TITLE", level ); subttl = fields_find( info, "SUBTITLE", level ); if ( ttl!=-1 || subttl!=-1 ) { fprintf( outptr, "<%s>", tag ); if ( ttl!=-1 ) { fprintf( outptr, "%s", info->data[ttl].data ); fields_setused( info, ttl ); } if ( subttl!=-1 ) { if ( ttl!=-1 ) { p = info->data[ttl].data; if ( p[info->data[ttl].len-1]!='?' ) fprintf( outptr, ":" ); fprintf( outptr, " " ); } fprintf( outptr, "%s", info->data[subttl].data ); fields_setused( info, subttl ); } fprintf( outptr, "\n", tag ); } } static void output_title( fields *info, FILE *outptr, int level ) { int ttl = fields_find( info, "TITLE", level ); int subttl = fields_find( info, "SUBTITLE", level ); int shrttl = fields_find( info, "SHORTTITLE", level ); output_titleinfo( info, outptr, "b:Title", 0 ); /* output shorttitle if it's different from normal title */ if ( shrttl!=-1 ) { if ( ttl==-1 || subttl!=-1 || strcmp(info->data[ttl].data,info->data[shrttl].data) ) { fprintf( outptr, " " ); fprintf( outptr, "%s", info->data[shrttl].data ); fprintf( outptr, "\n" ); } fields_setused( info, shrttl ); } } static void output_name_nomangle( FILE *outptr, char *p ) { fprintf( outptr, "" ); fprintf( outptr, "%s", p ); fprintf( outptr, "\n" ); } static void output_name( FILE *outptr, char *p ) { newstr family, part; int n=0, npart=0; newstr_init( &family ); while ( *p && *p!='|' ) newstr_addchar( &family, *p++ ); if ( *p=='|' ) p++; if ( family.len ) { fprintf( outptr, "" ); fprintf( outptr, "%s",family.data ); n++; } newstr_free( &family ); newstr_init( &part ); while ( *p ) { while ( *p && *p!='|' ) newstr_addchar( &part, *p++ ); if ( part.len ) { if ( n==0 ) fprintf( outptr, "" ); if ( npart==0 ) fprintf( outptr, "%s", part.data ); else fprintf( outptr, "%s", part.data ); n++; npart++; } if ( *p=='|' ) { p++; newstr_empty( &part ); } } if ( n ) fprintf( outptr, "\n" ); newstr_free( &part ); } #define NAME (1) #define NAME_ASIS (2) #define NAME_CORP (4) static int extract_name_and_info( newstr *outtag, newstr *intag ) { int code = NAME; newstr_newstrcpy( outtag, intag ); if ( newstr_findreplace( outtag, ":ASIS", "" ) ) code = NAME_ASIS; if ( newstr_findreplace( outtag, ":CORP", "" ) ) code = NAME_CORP; return code; } static void output_name_type( fields *info, FILE *outptr, int level, char *map[], int nmap, char *tag ) { newstr ntag; int i, j, n=0, code; newstr_init( &ntag ); for ( j=0; jnfields; ++i ) { code = extract_name_and_info( &ntag, &(info->tag[i]) ); if ( strcasecmp( ntag.data, map[j] ) ) continue; if ( n==0 ) fprintf( outptr, "<%s>\n", tag ); if ( code != NAME ) output_name_nomangle( outptr, info->data[i].data ); else output_name( outptr, info->data[i].data ); fields_setused( info, i ); n++; } } newstr_free( &ntag ); if ( n ) fprintf( outptr, "\n", tag ); } static void output_names( fields *info, FILE *outptr, int level, int type ) { char *authors[] = { "AUTHOR", "WRITER", "ASSIGNEE", "ARTIST", "CARTOGRAPHER", "INVENTOR", "ORGANIZER", "DIRECTOR", "PERFORMER", "REPORTER", "TRANSLATOR", "RECIPIENT", "2ND_AUTHOR", "3RD_AUTHOR", "SUB_AUTHOR", "COMMITTEE", "COURT", "LEGISLATIVEBODY" }; int nauthors = sizeof( authors ) / sizeof( authors[0] ); char *editors[] = { "EDITOR" }; int neditors = sizeof( editors ) / sizeof( editors[0] ); char author_default[] = "b:Author", inventor[] = "b:Inventor"; char *author_type = author_default; if ( type == TYPE_PATENT ) author_type = inventor; fprintf( outptr, "\n" ); output_name_type( info, outptr, level, authors, nauthors, author_type ); output_name_type( info, outptr, level, editors, neditors, "b:Editor" ); fprintf( outptr, "\n" ); } static void output_date( fields *info, FILE *outptr, int level ) { convert parts[3] = { { "PARTYEAR", "b:Year", -1 }, { "PARTMONTH", "b:Month", -1 }, { "PARTDAY", "b:Day", -1 } }; convert fulls[3] = { { "YEAR", "", -1 }, { "MONTH", "", -1 }, { "DAY", "", -1 } }; int i, np, nf; for ( i=0; i<3; ++i ) { np = fields_find( info, parts[i].oldtag, level ); nf = fields_find( info, fulls[i].oldtag, level ); if ( np!=-1 ) output_item( info, outptr, parts[i].newtag, np, 0 ); else if ( nf!=-1 ) output_item( info, outptr, parts[i].newtag, nf, 0 ); } } static void output_pages( fields *info, FILE *outptr, int level ) { int start = fields_find( info, "PAGESTART", -1 ); int end = fields_find( info, "PAGEEND", -1 ); int ar = fields_find( info, "ARTICLENUMBER", -1 ); if ( start!=-1 || end!=-1 ) output_range( info, outptr, "b:Pages", start, end, level ); else if ( ar!=-1 ) output_range( info, outptr, "b:Pages", ar, -1, level ); } static void output_includedin( fields *info, FILE *outptr, int type ) { if ( type==TYPE_JOURNALARTICLE ) { output_titleinfo( info, outptr, "b:JournalName", 1 ); } else if ( type==TYPE_ARTICLEINAPERIODICAL ) { output_titleinfo( info, outptr, "b:PeriodicalName", 1 ); } else if ( type==TYPE_BOOKSECTION ) { output_titleinfo( info, outptr, "b:ConferenceName", 1 ); /*??*/ } else if ( type==TYPE_PROCEEDINGS ) { output_titleinfo( info, outptr, "b:ConferenceName", 1 ); } } static int type_is_thesis( int type ) { if ( type==TYPE_THESIS || type==TYPE_PHDTHESIS || type==TYPE_MASTERSTHESIS ) return 1; else return 0; } static void output_thesisdetails( fields *info, FILE *outptr, int type ) { int i; if ( type==TYPE_PHDTHESIS ) output_fixed( outptr, "b:ThesisType", "Ph.D. Thesis", 0 ); else if ( type==TYPE_MASTERSTHESIS ) output_fixed( outptr, "b:ThesisType", "Masters Thesis", 0 ); for ( i=0; infields; ++i ) { if ( strcasecmp( info->tag[i].data, "DEGREEGRANTOR" ) && strcasecmp( info->tag[i].data, "DEGREEGRANTOR:ASIS") && strcasecmp( info->tag[i].data, "DEGREEGRANTOR:CORP")) continue; output_item( info, outptr, "b:Institution", i, 0 ); } } static outtype types[] = { { TYPE_UNKNOWN, "Misc" }, { TYPE_MISC, "Misc" }, { TYPE_BOOK, "Book" }, { TYPE_BOOKSECTION, "BookSection" }, { TYPE_CASE, "Case" }, { TYPE_CONFERENCE, "Conference" }, { TYPE_ELECTRONICSOURCE, "ElectronicSource" }, { TYPE_FILM, "Film" }, { TYPE_INTERNETSITE, "InternetSite" }, { TYPE_INTERVIEW, "Interview" }, { TYPE_SOUNDRECORDING, "SoundRecording" }, { TYPE_ARTICLEINAPERIODICAL, "ArticleInAPeriodical" }, { TYPE_DOCUMENTFROMINTERNETSITE, "DocumentFromInternetSite" }, { TYPE_JOURNALARTICLE, "JournalArticle" }, { TYPE_REPORT, "Report" }, { TYPE_PATENT, "Patent" }, { TYPE_PERFORMANCE, "Performance" }, { TYPE_PROCEEDINGS, "Proceedings" }, }; static int ntypes = sizeof( types ) / sizeof( types[0] ); static void output_type( fields *info, FILE *outptr, int type ) { int i, found = 0; fprintf( outptr, "" ); for ( i=0; i\n" ); if ( type_is_thesis( type ) ) output_thesisdetails( info, outptr, type ); } static void output_comments( fields *info, FILE *outptr, int level ) { int i, written=0; int nabs = fields_find( info, "ABSTRACT", level ); if ( nabs!=-1 ) { fprintf( outptr, "" ); fprintf( outptr, "%s", info->data[nabs].data ); written = 1; } for ( i=0; infields; ++i ) { if ( info->level[i]!=level ) continue; if ( strcasecmp( info->tag[i].data, "NOTES" ) ) continue; if ( !written ) { fprintf( outptr, "" ); written = 1; } fprintf( outptr, "%s", info->data[i].data ); } if ( written ) fprintf( outptr, "\n" ); } static void output_bibkey( fields *info, FILE *outptr ) { int n = fields_find( info, "REFNUM", -1 ); if ( n==-1 ) n = fields_find( info, "BIBKEY", -1 ); output_item( info, outptr, "b:Tag", n, 0 ); } static void output_citeparts( fields *info, FILE *outptr, int level, int max, int type ) { convert origin[] = { { "ADDRESS", "b:City", -1 }, { "PUBLISHER", "b:Publisher", -1 }, { "EDITION", "b:Edition", -1 } }; int norigin = sizeof( origin ) / sizeof ( convert ); convert parts[] = { { "VOLUME", "b:Volume", -1 }, { "SECTION", "b:Section", -1 }, { "ISSUE", "b:Issue", -1 }, { "NUMBER", "b:Issue", -1 }, { "PUBLICLAWNUMBER", "b:Volume", -1 }, { "SESSION", "b:Issue", -1 }, }; int nparts=sizeof(parts)/sizeof(convert); output_bibkey( info, outptr ); output_type( info, outptr, type ); output_list( info, outptr, origin, norigin ); output_date( info, outptr, level ); output_includedin( info, outptr, type ); output_list( info, outptr, parts, nparts ); output_pages( info, outptr, level ); output_names( info, outptr, level, type ); output_title( info, outptr, level ); output_comments( info, outptr, level ); } void wordout_write( fields *info, FILE *outptr, param *p, unsigned long numrefs ) { int max = fields_maxlevel( info ); int type = get_type( info ); fprintf( outptr, "\n" ); output_citeparts( info, outptr, -1, max, type ); fprintf( outptr, "\n" ); fflush( outptr ); } void wordout_writeheader( FILE *outptr, param *p ) { if ( p->utf8bom ) utf8_writebom( outptr ); fprintf(outptr,"\n"); fprintf(outptr,"\n"); } void wordout_writefooter( FILE *outptr ) { fprintf(outptr,"\n"); fflush( outptr ); } bibutils_4.12/lib/fields.h0000644000076400007640000000207511444072056015753 0ustar cdputnamcdputnam/* * fields.h * * Copyright (c) Chris Putnam 2003-2009 * * Source code released under the GPL * */ #ifndef FIELDS_H #define FIELDS_H #define LEVEL_MAIN (0) #define LEVEL_HOST (1) #define LEVEL_SERIES (2) #define LEVEL_ORIG (-2) #include "newstr.h" typedef struct { newstr *tag; newstr *data; int *used; int *level; int nfields; int maxfields; } fields; extern int fields_add( fields *info, char *tag, char *data, int level ); extern int fields_add_tagsuffix( fields *info, char *tag, char *suffix, char *data, int level ); extern void fields_free( fields *info ); extern void fields_init( fields *info ); extern fields *fields_new( void ); extern int fields_find( fields *info, char *searchtag, int level ); extern int fields_find_firstof( fields *info, char *tags[], int ntags, int level ); extern int fields_maxlevel( fields *info ); extern void fields_clearused( fields *info ); extern void fields_setused( fields *info, int n ); extern void fields_replace_or_add( fields *info, char *tag, char *data, int level ); #endif bibutils_4.12/lib/entities.h0000644000076400007640000000036511444072056016331 0ustar cdputnamcdputnam/* * entities.h * * Copyright (c) Chris Putnam 2003-2009 * * Source code released under the GPL */ #ifndef ENTITIES_H #define ENTITIES_H extern unsigned int decode_entity( char *s, unsigned int *pi, int *unicode, int *err ); #endif bibutils_4.12/lib/Makefile.dynamic0000644000076400007640000000255111454375517017427 0ustar cdputnamcdputnam#CC = gcc -Wall SIMPLE_OBJS = is_ws.o strsearch.o charsets.o NEWSTR_OBJS = newstr.o newstr_conv.o entities.o latex.o utf8.o gb18030.o CONTAIN_OBJS = fields.o list.o xml.o xml_encoding.o BIBL_OBJS = name.o title.o doi.o bibl.o serialno.o marc.o reftypes.o bibl.o INPUT_OBJS = bibtexin.o bibtextypes.o \ biblatexin.o bltypes.o \ copacin.o copactypes.o \ endin.o endtypes.o \ endxmlin.o \ isiin.o isitypes.o \ medin.o \ modsin.o modstypes.o marc.o \ risin.o ristypes.o \ ebiin.o wordin.o OUTPUT_OBJS = bibtexout.o endout.o isiout.o modsout.o risout.o wordout.o \ adsout.o BIBCORE_OBJS = $(SIMPLE_OBJS) $(NEWSTR_OBJS) $(CONTAIN_OBJS) $(BIBL_OBJS) \ bibcore.o BIBUTILS_OBJS = $(INPUT_OBJS) $(OUTPUT_OBJS) bibutils.o all: libbibutils.so .c.o: $(CC) -fPIC -c $(CFLAGS) -o $@ $< libbibutils.so: $(BIBCORE_OBJS) $(BIBUTILS_OBJS) $(CC) -shared -Wl,-soname,libbibutils.so.4 -o libbibutils.so.4.12 $^ ln -s libbibutils.so.4.12 libbibutils.so.4 ln -s libbibutils.so.4.12 libbibutils.so install: echo INSTALLING LIBRARIES TO $(LIBINSTALLDIR) cp libbibutils.so.4.12 $(LIBINSTALLDIR) ln -sf $(LIBINSTALLDIR)/libbibutils.so.4.12 $(LIBINSTALLDIR)/libbibutils.so ln -sf $(LIBINSTALLDIR)/libbibutils.so.4.12 $(LIBINSTALLDIR)/libbibutils.so.4 clean: /bin/rm -f *.o core realclean: /bin/rm -f *.o *.so *.so.4 *.so.4.12 core test: bibutils_4.12/lib/marc.h0000644000076400007640000000035711444072056015430 0ustar cdputnamcdputnam/* * marc.h * * Copyright (c) Chris Putnam 2008-9 * * Program and source code released under the GPL * */ #ifndef MARC_H #define MARC_H extern int marc_findgenre( char *query ); extern int marc_findresource( char *query ); #endif bibutils_4.12/lib/name.c0000644000076400007640000002237211444072056015422 0ustar cdputnamcdputnam/* * name.c * * mangle names w/ and w/o commas * * Copyright (c) Chris Putnam 2004-2010 * * Source code released under the GPL * */ #include #include #include #include "is_ws.h" #include "newstr.h" #include "fields.h" #include "list.h" #include "name.h" static void check_case( char *start, char *end, int *upper, int *lower ) { int u = 0, l = 0; char *p = start; while ( p < end ) { if ( islower( *p ) ) l = 1; else if ( isupper( *p ) ) u = 1; p++; } *upper = u; *lower = l; } static int should_split( char *last_start, char *last_end, char *first_start, char *first_end ) { int upperlast, lowerlast, upperfirst, lowerfirst; check_case( first_start, first_end, &upperfirst, &lowerfirst ); check_case( last_start, last_end, &upperlast, &lowerlast ); if ( ( upperlast && lowerlast ) && ( upperfirst && !lowerfirst ) ) return 1; else return 0; } /* name_addmultibytechar * * Add character to newstring s starting at pointer p. * * Handles the case for multibyte Unicode chars (with high bits * set). Do not progress past the lastp barrier. * * Since we can progress more than one byte in the string, * return the properly updated pointer p. */ static char * name_addmultibytechar( newstr *s, char *p, char *lastp ) { if ( ! ((*p) & 128) ) { newstr_addchar( s, *p ); p++; } else { while ( p!=lastp && ((*p) & 128) ) { newstr_addchar( s, *p ); p++; } } return p; } static void name_givennames_nosplit( char *start_first, char *end_first, newstr *outname ) { char *p; p = start_first; while ( p!=end_first ) { if ( !is_ws( *p ) && *p!='.' ) { p = name_addmultibytechar( outname, p, end_first ); } else { if ( *p=='.' ) p++; while ( p!=end_first && is_ws( *p ) ) p++; if ( p!=end_first ) newstr_addchar( outname, '|' ); } } } static void name_givennames_split( char *start_first, char *end_first, newstr *outname ) { int n = 0; char *p; p = start_first; while ( p!=end_first ) { if ( !is_ws( *p ) ) { if ( *p=='.' && *(p+1)=='-' ) { newstr_strcat( outname, ".-" ); p++; p++; p = skip_ws( p ); p = name_addmultibytechar( outname, p, end_first ); newstr_addchar( outname, '.' ); n++; } else if ( *p=='.' ) { p++; } else if ( *p=='-' ) { newstr_strcat( outname, ".-" ); p++; p = skip_ws( p ); p = name_addmultibytechar( outname, p, end_first ); newstr_addchar( outname, '.' ); n++; } else { if ( n ) newstr_addchar( outname, '|' ); p = name_addmultibytechar( outname, p, end_first ); n++; } } else { while ( p!=end_first && is_ws( *p ) ) p++; } } } static void name_givennames( char *first_start, char *first_end, char *last_start, char *last_end, newstr *outname ) { int splitfirst; newstr_addchar( outname, '|' ); splitfirst = should_split( last_start, last_end, first_start, first_end ); if ( !splitfirst ) name_givennames_nosplit( first_start, first_end, outname ); else name_givennames_split( first_start, first_end, outname ); } static char * string_end( char *p ) { while ( *p ) p++; return p; } /* name_nocomma() * * names in the format "H. F. Author" */ void name_nocomma( char *start, newstr *outname ) { char *p, *last_start, *last_end, *first_start, *first_end; /** Last name **/ p = last_end = string_end( start ); while ( p!=start && !is_ws( *p ) ) p--; if ( !strcasecmp( p+1, "Jr." ) || !strcasecmp( p+1, "III" ) ) { while ( p!=start && is_ws( *p ) ) p--; while ( p!=start && !is_ws( *p ) ) p--; } last_start = p = skip_ws( p ); while ( p!=last_end ) newstr_addchar( outname, *p++ ); /** Given names **/ if ( start!=last_start ) { first_start = skip_ws( start ); first_end = last_start; while ( first_end!=first_start && !is_ws( *first_end ) ) first_end--; name_givennames( first_start, last_start, last_start, last_end, outname ); } } /* * name_comma() * * names in the format "Author, H.F.", w/comma */ void name_comma( char *p, newstr *outname ) { char *start_first, *end_first, *start_last, *end_last; /** Last name **/ start_last = end_last = skip_ws( p ); while ( *p && ( *p!=',' ) ) { newstr_addchar( outname, *p++ ); end_last = p; } /** Given names **/ if ( *p==',' ) p++; start_first = skip_ws( p ); if ( *start_first ) { end_first = string_end( start_first ); name_givennames( start_first, end_first, start_last, end_last, outname ); } } /* Determine if name is of type "corporate" or if it * should be added "as-is"; both should not be mangled. * * First check tag for prefixes ":CORP" and ":ASIS", * then optionally check lists, bailing if "corporate" * type can be identified. * * "corporate" is the same as "as-is" plus getting * special MODS treatment, so "corporate" type takes * priority */ static void name_determine_flags( int *ctf, int *clf, int *atf, int *alf, char *tag, char *data, list *asis, list *corps ) { int corp_tag_flag = 0, corp_list_flag = 0; int asis_tag_flag = 0, asis_list_flag = 0; if ( strstr( tag, ":CORP" ) ) corp_tag_flag = 1; else if ( list_find( corps, data ) != -1 ) corp_list_flag = 1; if ( strstr( tag, ":ASIS" ) ) { asis_tag_flag = 1; if ( list_find( corps, data ) != -1 ) corp_list_flag = 1; } else { if ( list_find( corps, data ) != -1 ) corp_list_flag = 1; else if ( list_find( asis, data ) != -1 ) asis_list_flag = 1; } *ctf = corp_tag_flag; *clf = corp_list_flag; *atf = asis_tag_flag; *alf = asis_list_flag; } /* * return 1 on a nomangle with a newtag value * return 0 on a name to mangle */ static int name_nomangle( char *tag, char *data, newstr *newtag, list *asis, list *corps ) { int corp_tag_flag, corp_list_flag; int asis_tag_flag, asis_list_flag; name_determine_flags( &corp_tag_flag, &corp_list_flag, &asis_tag_flag, &asis_list_flag, tag, data, asis, corps ); if ( corp_tag_flag || corp_list_flag || asis_tag_flag || asis_list_flag ) { newstr_strcpy( newtag, tag ); if ( corp_tag_flag ) { /* do nothing else */ } else if ( corp_list_flag && !asis_tag_flag ) { newstr_strcat( newtag, ":CORP" ); } else if ( corp_list_flag && asis_tag_flag ) { newstr_findreplace( newtag, ":ASIS", ":CORP" ); } else if ( asis_tag_flag ) { /* do nothing else */ } else if ( asis_list_flag ) { newstr_strcat( newtag, ":ASIS" ); } return 1; } else return 0; } static void name_person( fields *info, char *tag, int level, newstr *inname ) { newstr outname; newstr_init( &outname ); if ( strchr( inname->data, ',' ) ) name_comma( inname->data, &outname ); else name_nocomma( inname->data, &outname ); if ( outname.len!=0 ) fields_add( info, tag, outname.data, level ); newstr_free( &outname ); } /* * name_process * * returns 1 if "et al." needs to be added to the list globally */ static int name_process( fields *info, char *tag, int level, newstr *inname, list *asis, list *corps ) { newstr newtag; int add_etal = 0; /* keep "names" like " , " from coredumping program */ if ( !inname->len ) return 0; /* identify and process asis or corps names */ newstr_init( &newtag ); if ( name_nomangle( tag, inname->data, &newtag, asis, corps ) ) { fields_add( info, newtag.data, inname->data, level ); } else { if ( strstr( inname->data, "et al." ) ) { add_etal = 1; newstr_findreplace( inname, "et al.", "" ); } if ( inname->len ) { name_person( info, tag, level, inname ); } } newstr_free( &newtag ); return add_etal; } /* * name_add( info, newtag, data, level ) * * take name(s) in data, multiple names should be separated by * '|' characters and divide into individual name, e.g. * "H. F. Author|W. G. Author|Q. X. Author" * * for each name, compare to names in the "as is" or "corporation" * lists...these are not personal names and should be added to the * bibliography fields directly and should not be mangled * * for each personal name, send to appropriate algorithm depending * on if the author name is in the format "H. F. Author" or * "Author, H. F." */ void name_add( fields *info, char *tag, char *q, int level, list *asis, list *corps ) { newstr inname, newtag; char *p, *start, *end; int add_etal = 0; if ( !q ) return; newstr_init( &inname ); newstr_init( &newtag ); while ( *q ) { start = q = skip_ws( q ); /* strip tailing whitespace and commas */ while ( *q && *q!='|' ) q++; end = q; while ( is_ws( *end ) || *end==',' || *end=='|' || *end=='\0' ) end--; for ( p=start; p<=end; p++ ) newstr_addchar( &inname, *p ); add_etal += name_process( info, tag, level, &inname, asis, corps ); #if 0 /* keep "names" like " , " from coredumping program */ if ( inname.len ) { if ( name_nomangle( tag, inname.data, &newtag, asis, corps ) ) { fields_add( info, newtag.data, inname.data, level ); newstr_empty( &newtag ); } else { if ( strstr( inname.data, "et al." ) ) { add_etal=1; newstr_findreplace( &inname, "et al.", "" ); } if ( inname.len ) name_person( info, tag, level, &inname, asis, corps ); } newstr_empty( &inname ); } #endif newstr_empty( &inname ); if ( *q=='|' ) q++; } if ( add_etal ) { newstr_strcpy( &newtag, tag ); newstr_strcat( &newtag, ":ASIS" ); fields_add( info, newtag.data, "et al.", level ); } newstr_free( &inname ); newstr_free( &newtag ); } bibutils_4.12/lib/biblatexin.h0000644000076400007640000000163411445517561016634 0ustar cdputnamcdputnam/* * biblatexin.h * * Copyright (c) Chris Putnam 2008-2010 * * Program and source code released under the GPL * */ #ifndef BIBLATEXIN_H #define BIBLATEXIN_H #include "newstr.h" #include "list.h" #include "fields.h" #include "bibl.h" #include "bibutils.h" #include "reftypes.h" extern void biblatexin_convertf( fields *bibin, fields *info, int reftype, param *p, variants *all, int nall ); extern int biblatexin_processf( fields *bibin, char *data, char *filename, long nref ); extern void biblatexin_cleanf( bibl *bin, param *p ); extern int biblatexin_readf( FILE *fp, char *buf, int bufsize, int *bufpos, newstr *line, newstr *reference, int *fcharset ); extern int biblatexin_typef( fields *bibin, char *filename, int nrefs, param *p, variants *all, int nall ); extern void biblatexin_initparams( param *p, const char *progname ); extern variants biblatex_all[]; extern int biblatex_nall; #endif bibutils_4.12/lib/bibl.c0000644000076400007640000000300111444072056015376 0ustar cdputnamcdputnam/* * bibl.c * * Copyright (c) Chris Putnam 2005-2010 * * Source code released under the GPL * */ #include #include #include "bibl.h" void bibl_init( bibl *b ) { b->nrefs = b->maxrefs = 0L; b->ref = NULL; } static void bibl_malloc( bibl * b ) { int alloc = 50; b->nrefs = 0; b->ref = ( fields ** ) malloc( sizeof( fields* ) * alloc ); if ( b->ref ) { b->maxrefs = alloc; } else { fprintf( stderr, "bibl_malloc: allocation error\n" ); exit( EXIT_FAILURE ); } } static void bibl_realloc( bibl * b ) { int alloc = b->maxrefs * 2; fields **more; more = ( fields ** ) realloc( b->ref, sizeof( fields* ) * alloc ); if ( more ) { b->ref = more; b->maxrefs = alloc; } else { fprintf( stderr, "bibl_realloc: allocation error\n" ); exit( EXIT_FAILURE ); } } void bibl_addref( bibl *b, fields *ref ) { if ( b->maxrefs==0 ) bibl_malloc( b ); else if ( b->nrefs >= b->maxrefs ) bibl_realloc( b ); b->ref[ b->nrefs ] = ref; b->nrefs++; } void bibl_free( bibl *b ) { long i; for ( i=0; inrefs; ++i ) fields_free( b->ref[i] ); free( b->ref ); b->ref = NULL; b->nrefs = b->maxrefs = 0; } void bibl_copy( bibl *bout, bibl *bin ) { fields *refin; fields *refout; int i, j; for ( i=0; inrefs; ++i ) { refin = bin->ref[i]; refout = fields_new(); for ( j=0; jnfields; ++j ) { if ( refin->tag[j].data && refin->data[j].data ) fields_add( refout, refin->tag[j].data, refin->data[j].data, refin->level[j] ); } bibl_addref( bout, refout ); } } bibutils_4.12/lib/title.c0000644000076400007640000000227511444072056015623 0ustar cdputnamcdputnam/* * title.c * * process titles into title/subtitle pairs for MODS * * Copyright (c) Chris Putnam 2004-2010 * * Source code released under the GPL * */ #include #include #include #include "newstr.h" #include "fields.h" #include "title.h" #include "is_ws.h" void title_process( fields *info, char *tag, char *data, int level, unsigned char nosplittitle ) { newstr title, subtitle; char *p, *q; newstr_init( &title ); newstr_init( &subtitle ); if ( nosplittitle ) q = NULL; else { q = strstr( data, ": " ); if ( !q ) q = strstr( data, "? " ); } if ( !q ) newstr_strcpy( &title, data ); else { p = data; while ( p!=q ) newstr_addchar( &title, *p++ ); if ( *q=='?' ) newstr_addchar( &title, '?' ); q++; q = skip_ws( q ); while ( *q ) newstr_addchar( &subtitle, *q++ ); } if ( strncasecmp( "SHORT", tag, 5 ) ) { if ( title.len>0 ) fields_add( info, "TITLE", title.data, level ); if ( subtitle.len>0 ) fields_add( info, "SUBTITLE", subtitle.data, level ); } else { if ( title.len>0 ) fields_add( info, "SHORTTITLE", title.data, level ); /* no SHORT-SUBTITLE! */ } newstr_free( &subtitle ); newstr_free( &title ); } bibutils_4.12/lib/entities.c0000644000076400007640000003360311444072056016325 0ustar cdputnamcdputnam/* * entities.c * * Copyright (c) Chris Putnam 2003-2010 * * Source code released under the GPL */ #include #include #include #include "entities.h" /* HTML 4.0 entities */ typedef struct entities { char html[20]; unsigned int unicode; } entities; entities html_entities[] = { /* Special Entities */ { """, 34 }, /* quotation mark */ { "&", 38 }, /* ampersand */ { "'", 39 }, /* apostrophe */ { "(", 40 }, /* left parenthesis */ { ")", 41 }, /* right parenthesis */ { "‐", 45 }, /* hyphen */ { "<", 60 }, /* less-than sign */ { ">", 62 }, /* greater-than sign */ { "?", 63 }, /* question mark */ { "Œ", 338 }, /* Latin cap ligature OE */ { "œ", 339 }, /* Latin small ligature OE */ { "Š", 352 }, /* Latin cap S with caron */ { "š", 353 }, /* Latin cap S with caron */ { "Ÿ", 376 }, /* Latin cap y with diaeresis */ { "ˆ", 710 }, /* modifier letter circumflex */ { "˜", 732 }, /* small tilde */ { " ", 8194 }, /* en space */ { " ", 8195 }, /* em space */ { " ", 8201 }, /* thin space */ { "‌", 8204 }, /* zero width non-joiner */ { "‍", 8205 }, /* zero width joiner */ { "‎", 8206 }, /* left-to-right mark */ { "‏", 8207 }, /* right-to-left mark */ { "–", 8211 }, /* en dash */ { "—", 8212 }, /* em dash */ { "‘", 8216 }, /* left single quotation mark */ { "’", 8217 }, /* right single quot. mark */ { "‚", 8218 }, /* single low-9 quot. mark */ { "“", 8220 }, /* left double quot. mark */ { "”", 8221 }, /* right double quot. mark */ { "„", 8222 }, /* double low-9 quot. mark */ { "†", 8224 }, /* dagger */ { "‡", 8225 }, /* double dagger */ { "‰", 8240 }, /* per mille sign */ { "‹", 8249 }, /* sin. left angle quot mark */ { "›", 8250 }, /* sin. right angle quot mark */ { "€", 8364 }, /* euro sign */ /* Symbols and Greek characters */ { "ƒ", 402 }, /* small f with hook = function */ { "Α", 913 }, /* capital alpha */ { "Β", 914 }, /* capital beta */ { "Γ", 915 }, /* capital gamma */ { "Δ", 916 }, /* capital delta */ { "Ε", 917 }, /* capital epsilon */ { "Ζ", 918 }, /* capital zeta */ { "Η", 919 }, /* capital eta */ { "Θ", 920 }, /* capital theta */ { "Ι", 921 }, /* capital iota */ { "Κ", 922 }, /* capital kappa */ { "Λ", 923 }, /* capital lambda */ { "Μ", 924 }, /* capital mu */ { "Ν", 925 }, /* capital nu */ { "Ξ", 926 }, /* capital xi */ { "Ο", 927 }, /* capital omicron */ { "Π", 928 }, /* capital pi */ { "Ρ", 929 }, /* capital rho */ { "Σ", 931 }, /* capital sigma */ { "Τ", 932 }, /* capital tau */ { "Υ", 933 }, /* capital upsilon */ { "Φ", 934 }, /* capital phi */ { "Χ", 935 }, /* capital chi */ { "Ψ", 936 }, /* capital psi */ { "Ω", 937 }, /* capital omega */ { "α", 945 }, /* small alpha */ { "β", 946 }, /* small beta */ { "γ", 947 }, /* small gamma */ { "δ", 948 }, /* small delta */ { "ε", 949 }, /* small epsilon */ { "ζ", 950 }, /* small zeta */ { "η", 951 }, /* small eta */ { "θ", 952 }, /* small theta */ { "ι", 953 }, /* small iota */ { "κ", 954 }, /* small kappa */ { "λ", 955 }, /* small lambda */ { "μ", 956 }, /* small mu */ { "ν", 957 }, /* small nu */ { "ξ", 958 }, /* small xi */ { "ο", 959 }, /* small omicron */ { "π", 960 }, /* small pi */ { "ρ", 961 }, /* small rho */ { "ς", 962 }, /* small final sigma */ { "σ", 963 }, /* small simga */ { "τ", 964 }, /* small tau */ { "υ", 965 }, /* small upsilon */ { "φ", 966 }, /* small phi */ { "χ", 967 }, /* small chi */ { "ψ", 968 }, /* small psi */ { "ω", 969 }, /* small omega */ { "ϑ",977 }, /* small theta symbol */ { "ϒ", 978 }, /* small upsilon with hook */ { "ϖ", 982 }, /* pi symbol */ { "•", 8226 }, /* bullet = small blk circle */ { "…", 8230 }, /* horizontal ellipsis */ { "′", 8242 }, /* prime = minutes = feet */ { "″", 8243 }, /* double prime */ { "‾", 8254 }, /* overline */ { "⁄", 8260 }, /* fraction slash */ { "℘", 8472 }, /* Weierstrass p = power set */ { "ℑ", 8465 }, /* imaginary part-black cap I */ { "ℜ", 8476 }, /* real part-black cap R */ { "™", 8482 }, /* trademark sign */ { "ℵ",8501 }, /* alef symbol */ { "←", 8592 }, /* left arrow */ { "↑", 8593 }, /* up arrow */ { "→", 8594 }, /* right arrow */ { "↓", 8595 }, /* down arrow */ { "↔", 8596 }, /* left/right arrow */ { "↵", 8629 }, /* down arrow with corner left */ { "⇐", 8656 }, /* left double arrow */ { "⇑", 8657 }, /* up double arrow */ { "⇒", 8658 }, /* up double arrow */ { "⇓", 8659 }, /* up double arrow */ { "⇔", 8660 }, /* up double arrow */ { "∀", 8704}, /* for all */ { "∂", 8706}, /* partial differential */ { "∃", 8707}, /* there exists */ { "∅", 8709}, /* empty set */ { "∇", 8711}, /* nabla=backwards difference */ { "∈", 8712}, /* element of */ { "∉", 8713}, /* not an element of */ { "∋", 8715}, /* contains as member */ { "∏", 8719}, /* n-ary product */ { "∑", 8721}, /* n-ary summation */ { "−", 8722}, /* minuss sign */ { "∗", 8727}, /* asterisk operator */ { "√", 8730}, /* square root */ { "∝", 8733}, /* proportional to */ { "∞", 8734}, /* infinity */ { "∠", 8736}, /* angle */ { "∧", 8743}, /* logical and */ { "∨", 8744}, /* logical or */ { "∩", 8745}, /* intersection */ { "∪", 8746}, /* union */ { "∫", 8747}, /* integral */ { "∴", 8756}, /* therefore */ { "∼", 8764}, /* tilde operator */ { "≅", 8773}, /* approximately equal to */ { "≈", 8776}, /* asymptotic to */ { "≠", 8800}, /* not equal to */ { "≡", 8801}, /* identical to */ { "≤", 8804}, /* less-than or equal to */ { "≥", 8805}, /* greater-than or equal to */ { "⊂", 8834}, /* subset of */ { "⊃", 8835}, /* superset of */ { "⊄", 8836}, /* not a subset of */ { "⊆", 8838}, /* subset of or equal to */ { "⊇", 8839}, /* superset of or equal to */ { "⊕", 8853}, /* circled plus = direct sum */ { "⊗", 8855}, /* circled times = vec prod */ { "⊥", 8869}, /* perpendicular */ { "⋅", 8901}, /* dot operator */ { "⌈", 8968}, /* left ceiling */ { "⌉", 8969}, /* right ceiling */ { "⌊", 8970}, /* left floor */ { "⌋", 8971}, /* right floor */ { "⟨", 9001}, /* left angle bracket */ { "⟩", 9002}, /* right angle bracket */ { "◊", 9674}, /* lozenge */ { "♠", 9824}, /* spades */ { "♣", 9827}, /* clubs */ { "♥", 9829}, /* hearts */ { "♦", 9830}, /* diamonds */ /* Latin-1 */ { " ", 32 }, /* non-breaking space */ { "¡", 161 }, /* inverted exclamation mark */ { "¢", 162 }, /* cent sign */ { "£", 163 }, /* pound sign */ { "¤", 164 }, /* currency sign */ { "¥", 165 }, /* yen sign */ { "¦", 166 }, /* broken vertical bar */ { "§", 167 }, /* section sign */ { "¨", 168 }, /* diaeresis - spacing diaeresis */ { "©", 169 }, /* copyright sign */ { "ª", 170 }, /* feminine ordinal indicator */ { "«", 171 }, /* left-pointing guillemet */ { "¬", 172 }, /* not sign */ { "­", 173 }, /* soft (discretionary) hyphen */ { "®", 174 }, /* registered sign */ { "¯", 175 }, /* macron = overline */ { "°", 176 }, /* degree sign */ { "±", 177 }, /* plus-minus sign */ { "²", 178 }, /* superscript two */ { "³", 179 }, /* superscript three */ { "´", 180 }, /* acute accent = spacing acute */ { "µ", 181 }, /* micro sign */ { "¶", 182 }, /* pilcrow (paragraph) sign */ { "·", 183 }, /* middle dot (georgian comma) */ { "¸", 184 }, /* cedilla = spacing cedilla */ { "¹", 185 }, /* superscript one */ { "º", 186 }, /* masculine ordinal indicator */ { "»", 187 }, /* right pointing guillemet */ { "¼", 188 }, /* 1/4 */ { "½", 189 }, /* 1/2 */ { "¾", 190 }, /* 3/4 */ { "¿", 191 }, /* inverted question mark */ { "À", 192 }, /* cap A with grave */ { "Á", 193 }, /* cap A with acute */ { "Â", 194 }, /* cap A with circumflex */ { "Ã", 195 }, /* cap A with tilde */ { "Ä", 196 }, /* cap A with diaeresis */ { "Å", 197 }, /* cap A with ring */ { "Æ", 198 }, /* cap AE ligature */ { "Ç", 199 }, /* cap C with cedilla */ { "È", 200 }, /* cap E with grave */ { "É", 201 }, /* cap E with acute */ { "Ê", 202 }, /* cap E with circumflex */ { "Ë", 203 }, /* cap E with diaeresis */ { "Ì", 204 }, /* cap I with grave */ { "Í", 205 }, /* cap I with acute */ { "Î", 206 }, /* cap I with circumflex */ { "Ï", 207 }, /* cap I with diaeresis */ { "Ð", 208 }, /* cap letter ETH */ { "Ñ", 209 }, /* cap N with tilde */ { "Ò", 210 }, /* cap O with grave */ { "Ó", 211 }, /* cap O with acute */ { "Ô", 212 }, /* cap O with circumflex */ { "Õ", 213 }, /* cap O with tilde */ { "Ö", 214 }, /* cap O with diaeresis */ { "×", 215 }, /* multiplication sign */ { "Ø", 216 }, /* cap O with stroke */ { "Ù", 217 }, /* cap U with grave */ { "Ú", 218 }, /* cap U with acute */ { "Û", 219 }, /* cap U with circumflex */ { "Ü", 220 }, /* cap U with diaeresis */ { "Ý", 221 }, /* cap Y with acute */ { "Þ", 222 }, /* cap letter THORN */ { "ß", 223 }, /* small sharp s = ess-zed */ { "à", 224 }, /* small a with grave */ { "á", 225 }, /* small a with acute */ { "â", 226 }, /* small a with cirucmflex */ { "ã", 227 }, /* small a with tilde */ { "&amul;", 228 }, /* small a with diaeresis */ { "å", 229 }, /* small a with ring */ { "æ", 230 }, /* small ligature ae */ { "ç", 231 }, /* small c with cedilla */ { "è", 232 }, /* small e with grave */ { "é", 233 }, /* small e with acute */ { "ê", 234 }, /* small e with circumflex */ { "&emul;", 235 }, /* small e with diaeresis */ { "ì", 236 }, /* small i with grave */ { "í", 237 }, /* small i with acute */ { "î", 238 }, /* small i with circumflex */ { "ï", 239 }, /* small i with diaeresis */ { "ð", 240 }, /* latin small letter eth */ { "ñ", 241 }, /* small n with tilde */ { "ò", 242 }, /* small o with grave */ { "ó", 243 }, /* small o with acute */ { "ô", 244 }, /* small o with circumflex */ { "õ", 245 }, /* small o with tilde */ { "ö", 246 }, /* small o with diaeresis */ { "÷", 247 }, /* division sign */ { "ø", 248 }, /* small o with slash */ { "ù", 249 }, /* small u with grave */ { "ú", 250 }, /* small u with acute */ { "û", 251 }, /* small u with circumflex */ { "ü", 252 }, /* small u with diaeresis */ { "ý", 253 }, /* small y with acute */ { "þ", 254 }, /* latin small letter thorn */ { "ÿ", 255 }, /* small y with diaeresis */ }; static unsigned int decode_html_entity( char *s, unsigned int *pi, int *err ) { int nhtml_entities = sizeof( html_entities ) / sizeof( entities ); char *e; int i, n=-1, len; for ( i=0; i #include #include #include "fields.h" #include "reftypes.h" static lookups generic[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "A1", "AUTHOR", PERSON, LEVEL_MAIN }, { "A2", "AUTHOR", PERSON, LEVEL_HOST }, { "A3", "AUTHOR", PERSON, LEVEL_SERIES }, { "ED", "EDITOR", PERSON, LEVEL_MAIN }, { "PY", "YEAR", DATE, LEVEL_MAIN }, { "Y1", "YEAR", DATE, LEVEL_MAIN }, { "Y2", "MONTH", SIMPLE, LEVEL_MAIN }, { "SN", "SERIALNUMBER", SERIALNO,LEVEL_MAIN }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "T1", "TITLE", TITLE, LEVEL_MAIN }, { "T2", "SHORTTITLE", SIMPLE, LEVEL_HOST }, { "T3", "TITLE", SIMPLE, LEVEL_SERIES }, { "JO", "TITLE", SIMPLE, LEVEL_HOST }, /* JOURNAL */ { "JA", "TITLE", SIMPLE, LEVEL_HOST }, { "JF", "TITLE", SIMPLE, LEVEL_HOST }, { "J1", "TITLE", SIMPLE, LEVEL_HOST }, { "J2", "TITLE", SIMPLE, LEVEL_HOST }, { "VL", "VOLUME", SIMPLE, LEVEL_MAIN }, { "VO", "VOLUME", SIMPLE, LEVEL_MAIN }, { "IS", "ISSUE", SIMPLE, LEVEL_MAIN }, { "CP", "ISSUE", SIMPLE, LEVEL_MAIN }, { "SP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "N1", "NOTES", NOTES, LEVEL_MAIN }, { "N2", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "KW", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "PB", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "BT", "TITLE", SIMPLE, LEVEL_HOST }, { "CT", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "AD", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "CY", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "RP", "REPRINTSTATUS",SIMPLE, LEVEL_MAIN }, { "UR", "URL", SIMPLE, LEVEL_MAIN }, { "DO", "DOI", DOI, LEVEL_MAIN }, { "DI", "DOI", DOI, LEVEL_MAIN }, { "L1", "FILEATTACH", SIMPLE, LEVEL_MAIN }, { "ID", "REFNUM", SIMPLE, LEVEL_MAIN }, { "U1", "NOTES", NOTES, LEVEL_MAIN }, /*user defined */ { "U2", "NOTES", NOTES, LEVEL_MAIN }, /* put in "notes" */ { "U3", "NOTES", NOTES, LEVEL_MAIN }, { "U4", "NOTES", NOTES, LEVEL_MAIN }, { "U5", "NOTES", NOTES, LEVEL_MAIN }, { "M1", "NOTES", NOTES, LEVEL_MAIN }, /*misc */ { "M2", "NOTES", NOTES, LEVEL_MAIN }, /* put in "notes" */ { "M3", "NOTES", NOTES, LEVEL_MAIN }, }; static lookups article[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "A1", "AUTHOR", PERSON, LEVEL_MAIN }, { "A2", "AUTHOR", PERSON, LEVEL_HOST }, { "A3", "AUTHOR", PERSON, LEVEL_SERIES }, { "ED", "EDITOR", PERSON, LEVEL_HOST }, { "PY", "PARTYEAR", DATE, LEVEL_MAIN }, { "Y1", "PARTYEAR", DATE, LEVEL_MAIN }, { "Y2", "PARTMONTH", SIMPLE, LEVEL_MAIN }, { "SN", "SERIALNUMBER", SERIALNO,LEVEL_HOST }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "T1", "TITLE", TITLE, LEVEL_MAIN }, { "T2", "SHORTTITLE", SIMPLE, LEVEL_HOST }, { "T3", "TITLE", SIMPLE, LEVEL_SERIES }, { "JO", "TITLE", SIMPLE, LEVEL_HOST }, /* JOURNAL */ { "JA", "TITLE", SIMPLE, LEVEL_HOST }, { "JF", "TITLE", SIMPLE, LEVEL_HOST }, { "J1", "TITLE", SIMPLE, LEVEL_HOST }, { "J2", "TITLE", SIMPLE, LEVEL_SERIES }, { "VL", "VOLUME", SIMPLE, LEVEL_MAIN }, { "VO", "VOLUME", SIMPLE, LEVEL_MAIN }, { "IS", "ISSUE", SIMPLE, LEVEL_MAIN }, { "CP", "ISSUE", SIMPLE, LEVEL_MAIN }, { "SP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "N1", "NOTES", NOTES, LEVEL_MAIN }, { "N2", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "KW", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "PB", "PUBLISHER", SIMPLE, LEVEL_HOST }, { "CT", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "AD", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "CY", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "RP", "REPRINTSTATUS",SIMPLE, LEVEL_MAIN }, { "UR", "URL", SIMPLE, LEVEL_MAIN }, { "DO", "DOI", DOI, LEVEL_MAIN }, { "DI", "DOI", DOI, LEVEL_MAIN }, { "L1", "FILEATTACH", SIMPLE, LEVEL_MAIN }, { "ID", "REFNUM", SIMPLE, LEVEL_MAIN }, { "U1", "NOTES", NOTES, LEVEL_MAIN }, { "U2", "NOTES", NOTES, LEVEL_MAIN }, { "U3", "NOTES", NOTES, LEVEL_MAIN }, { "U4", "NOTES", NOTES, LEVEL_MAIN }, { "U5", "NOTES", NOTES, LEVEL_MAIN }, { "M1", "NOTES", NOTES, LEVEL_MAIN }, { "M2", "NOTES", NOTES, LEVEL_MAIN }, { "M3", "NOTES", NOTES, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|ARTICLE", ALWAYS, LEVEL_MAIN }, { " ", "ISSUANCE|continuing", ALWAYS, LEVEL_HOST }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|periodical", ALWAYS, LEVEL_HOST }, { " ", "GENRE|academic journal", ALWAYS, LEVEL_HOST } }; /* magazine article */ static lookups magarticle[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "A1", "AUTHOR", PERSON, LEVEL_MAIN }, { "A2", "AUTHOR", PERSON, LEVEL_HOST }, { "A3", "AUTHOR", PERSON, LEVEL_SERIES }, { "ED", "EDITOR", PERSON, LEVEL_HOST }, { "PY", "PARTYEAR", DATE, LEVEL_MAIN }, { "Y1", "PARTYEAR", DATE, LEVEL_MAIN }, { "Y2", "PARTMONTH", SIMPLE, LEVEL_MAIN }, { "SN", "SERIALNUMBER", SERIALNO,LEVEL_HOST }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "T1", "TITLE", TITLE, LEVEL_MAIN }, { "T2", "SHORTTITLE", SIMPLE, LEVEL_HOST }, { "T3", "TITLE", SIMPLE, LEVEL_SERIES }, { "JO", "TITLE", SIMPLE, LEVEL_HOST }, /* JOURNAL */ { "JA", "TITLE", SIMPLE, LEVEL_HOST }, { "JF", "TITLE", SIMPLE, LEVEL_HOST }, { "J1", "TITLE", SIMPLE, LEVEL_HOST }, { "J2", "TITLE", SIMPLE, LEVEL_SERIES }, { "VL", "VOLUME", SIMPLE, LEVEL_MAIN }, { "VO", "VOLUME", SIMPLE, LEVEL_MAIN }, { "IS", "ISSUE", SIMPLE, LEVEL_MAIN }, { "CP", "ISSUE", SIMPLE, LEVEL_MAIN }, { "SP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "N1", "NOTES", NOTES, LEVEL_MAIN }, { "N2", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "KW", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "PB", "PUBLISHER", SIMPLE, LEVEL_HOST }, { "CT", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "AD", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "CY", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "RP", "REPRINTSTATUS",SIMPLE, LEVEL_MAIN }, { "UR", "URL", SIMPLE, LEVEL_MAIN }, { "L1", "FILEATTACH", SIMPLE, LEVEL_MAIN }, { "ID", "REFNUM", SIMPLE, LEVEL_MAIN }, { "U1", "NOTES", NOTES, LEVEL_MAIN }, { "U2", "NOTES", NOTES, LEVEL_MAIN }, { "U3", "NOTES", NOTES, LEVEL_MAIN }, { "U4", "NOTES", NOTES, LEVEL_MAIN }, { "U5", "NOTES", NOTES, LEVEL_MAIN }, { "M1", "NOTES", NOTES, LEVEL_MAIN }, { "M2", "NOTES", NOTES, LEVEL_MAIN }, { "M3", "NOTES", NOTES, LEVEL_MAIN }, { " ", "ISSUANCE|continuing", ALWAYS, LEVEL_HOST }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|periodical", ALWAYS, LEVEL_HOST }, { " ", "GENRE|magazine", ALWAYS, LEVEL_HOST } }; static lookups newsarticle[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "A1", "AUTHOR", PERSON, LEVEL_MAIN }, { "A2", "AUTHOR", PERSON, LEVEL_HOST }, { "A3", "AUTHOR", PERSON, LEVEL_SERIES }, { "ED", "EDITOR", PERSON, LEVEL_HOST }, { "PY", "PARTYEAR", DATE, LEVEL_MAIN }, { "Y1", "PARTYEAR", DATE, LEVEL_MAIN }, { "Y2", "PARTMONTH", SIMPLE, LEVEL_MAIN }, { "SN", "SERIALNUMBER", SERIALNO,LEVEL_HOST }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "T1", "TITLE", TITLE, LEVEL_MAIN }, { "T2", "SHORTTITLE", SIMPLE, LEVEL_HOST }, { "T3", "TITLE", SIMPLE, LEVEL_SERIES }, { "JO", "TITLE", SIMPLE, LEVEL_HOST }, /* JOURNAL */ { "JA", "TITLE", SIMPLE, LEVEL_HOST }, { "JF", "TITLE", SIMPLE, LEVEL_HOST }, { "J1", "TITLE", SIMPLE, LEVEL_HOST }, { "J2", "TITLE", SIMPLE, LEVEL_SERIES }, { "VL", "VOLUME", SIMPLE, LEVEL_MAIN }, { "VO", "VOLUME", SIMPLE, LEVEL_MAIN }, { "IS", "ISSUE", SIMPLE, LEVEL_MAIN }, { "CP", "ISSUE", SIMPLE, LEVEL_MAIN }, { "SP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "N1", "NOTES", NOTES, LEVEL_MAIN }, { "N2", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "KW", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "PB", "PUBLISHER", SIMPLE, LEVEL_HOST }, { "CT", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "AD", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "CY", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "RP", "REPRINTSTATUS",SIMPLE, LEVEL_MAIN }, { "UR", "URL", SIMPLE, LEVEL_MAIN }, { "L1", "FILEATTACH", SIMPLE, LEVEL_MAIN }, { "ID", "REFNUM", SIMPLE, LEVEL_MAIN }, { "U1", "NOTES", NOTES, LEVEL_MAIN }, { "U2", "NOTES", NOTES, LEVEL_MAIN }, { "U3", "NOTES", NOTES, LEVEL_MAIN }, { "U4", "NOTES", NOTES, LEVEL_MAIN }, { "U5", "NOTES", NOTES, LEVEL_MAIN }, { "M1", "NOTES", NOTES, LEVEL_MAIN }, { "M2", "NOTES", NOTES, LEVEL_MAIN }, { "M3", "NOTES", NOTES, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|NEWSARTICLE", ALWAYS, LEVEL_MAIN }, { " ", "ISSUANCE|continuing", ALWAYS, LEVEL_HOST }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|newspaper", ALWAYS, LEVEL_HOST } }; static lookups book[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "A1", "AUTHOR", PERSON, LEVEL_MAIN }, { "A2", "AUTHOR", PERSON, LEVEL_HOST }, { "A3", "AUTHOR", PERSON, LEVEL_SERIES }, { "ED", "EDITOR", PERSON, LEVEL_MAIN }, { "PY", "YEAR", DATE, LEVEL_MAIN }, { "Y1", "YEAR", DATE, LEVEL_MAIN }, { "Y2", "MONTH", SIMPLE, LEVEL_MAIN }, { "SN", "SERIALNUMBER", SERIALNO,LEVEL_MAIN }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "T1", "TITLE", TITLE, LEVEL_MAIN }, { "T2", "SHORTTITLE", SIMPLE, LEVEL_HOST }, { "T3", "TITLE", SIMPLE, LEVEL_SERIES }, { "JO", "TITLE", SIMPLE, LEVEL_HOST }, { "JA", "TITLE", SIMPLE, LEVEL_HOST }, { "JF", "TITLE", SIMPLE, LEVEL_HOST }, { "J1", "TITLE", SIMPLE, LEVEL_HOST }, { "J2", "TITLE", SIMPLE, LEVEL_HOST }, { "VL", "VOLUME", SIMPLE, LEVEL_MAIN }, { "VO", "VOLUME", SIMPLE, LEVEL_MAIN }, { "IS", "ISSUE", SIMPLE, LEVEL_MAIN }, { "CP", "ISSUE", SIMPLE, LEVEL_MAIN }, { "SP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "N1", "NOTES", NOTES, LEVEL_MAIN }, { "N2", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "KW", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "PB", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "BT", "TITLE", SIMPLE, LEVEL_MAIN }, /* BOOKTITLE */ { "CT", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "AD", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "CY", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "RP", "REPRINTSTATUS",SIMPLE, LEVEL_MAIN }, { "UR", "URL", SIMPLE, LEVEL_MAIN }, { "L1", "FILEATTACH", SIMPLE, LEVEL_MAIN }, { "ID", "REFNUM", SIMPLE, LEVEL_MAIN }, { "U1", "NOTES", NOTES, LEVEL_MAIN }, { "U2", "NOTES", NOTES, LEVEL_MAIN }, { "U3", "NOTES", NOTES, LEVEL_MAIN }, { "U4", "NOTES", NOTES, LEVEL_MAIN }, { "U5", "NOTES", NOTES, LEVEL_MAIN }, { "M1", "NOTES", NOTES, LEVEL_MAIN }, { "M2", "NOTES", NOTES, LEVEL_MAIN }, { "M3", "NOTES", NOTES, LEVEL_MAIN }, { " ", "ISSUANCE|monographic", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|book", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN } }; static lookups inbook[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "A1", "AUTHOR", PERSON, LEVEL_MAIN }, { "A2", "AUTHOR", PERSON, LEVEL_HOST }, { "A3", "AUTHOR", PERSON, LEVEL_SERIES }, { "ED", "EDITOR", PERSON, LEVEL_HOST }, { "PY", "YEAR", DATE, LEVEL_HOST }, { "Y1", "YEAR", DATE, LEVEL_HOST }, { "Y2", "MONTH", SIMPLE, LEVEL_HOST }, { "SN", "SERIALNUMBER", SERIALNO,LEVEL_HOST }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "T1", "TITLE", TITLE, LEVEL_MAIN }, { "T2", "SHORTTITLE", SIMPLE, LEVEL_HOST }, { "T3", "TITLE", SIMPLE, LEVEL_SERIES }, { "VL", "VOLUME", SIMPLE, LEVEL_HOST }, { "VO", "VOLUME", SIMPLE, LEVEL_HOST }, { "IS", "ISSUE", SIMPLE, LEVEL_HOST }, { "CP", "ISSUE", SIMPLE, LEVEL_HOST }, { "SP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "N1", "NOTES", NOTES, LEVEL_MAIN }, { "N2", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "KW", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "PB", "PUBLISHER", SIMPLE, LEVEL_HOST }, { "BT", "TITLE", SIMPLE, LEVEL_HOST }, /* BOOKTITLE */ { "CT", "ADDRESS", SIMPLE, LEVEL_HOST }, { "AD", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "CY", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "RP", "REPRINTSTATUS",SIMPLE, LEVEL_MAIN }, { "UR", "URL", SIMPLE, LEVEL_MAIN }, { "L1", "FILEATTACH", SIMPLE, LEVEL_MAIN }, { "ID", "REFNUM", SIMPLE, LEVEL_MAIN }, { "U1", "NOTES", NOTES, LEVEL_MAIN }, { "U2", "NOTES", NOTES, LEVEL_MAIN }, { "U3", "NOTES", NOTES, LEVEL_MAIN }, { "U4", "NOTES", NOTES, LEVEL_MAIN }, { "U5", "NOTES", NOTES, LEVEL_MAIN }, { "M1", "NOTES", NOTES, LEVEL_MAIN }, { "M2", "NOTES", NOTES, LEVEL_MAIN }, { "M3", "NOTES", NOTES, LEVEL_MAIN }, { " ", "GENRE|book", ALWAYS, LEVEL_HOST }, { " ", "ISSUANCE|monographic", ALWAYS, LEVEL_HOST }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN } }; static lookups conference[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "A1", "AUTHOR", PERSON, LEVEL_MAIN }, { "A2", "AUTHOR", PERSON, LEVEL_HOST }, { "A3", "AUTHOR", PERSON, LEVEL_SERIES }, { "ED", "EDITOR", PERSON, LEVEL_MAIN }, { "PY", "YEAR", DATE, LEVEL_HOST }, { "Y1", "YEAR", DATE, LEVEL_HOST }, { "Y2", "MONTH", SIMPLE, LEVEL_HOST }, { "SN", "SERIALNUMBER", SERIALNO,LEVEL_MAIN }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "T1", "TITLE", TITLE, LEVEL_MAIN }, { "T2", "SHORTTITLE", SIMPLE, LEVEL_HOST }, { "T3", "TITLE", SIMPLE, LEVEL_SERIES }, { "JO", "TITLE", SIMPLE, LEVEL_HOST }, /* JOURNAL */ { "JA", "TITLE", SIMPLE, LEVEL_HOST }, { "JF", "TITLE", SIMPLE, LEVEL_HOST }, { "J1", "TITLE", SIMPLE, LEVEL_HOST }, { "J2", "TITLE", SIMPLE, LEVEL_HOST }, { "VL", "VOLUME", SIMPLE, LEVEL_MAIN }, { "VO", "VOLUME", SIMPLE, LEVEL_MAIN }, { "IS", "ISSUE", SIMPLE, LEVEL_MAIN }, { "CP", "ISSUE", SIMPLE, LEVEL_MAIN }, { "SP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "N1", "NOTES", NOTES, LEVEL_MAIN }, { "N2", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "KW", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "PB", "PUBLISHER", SIMPLE, LEVEL_HOST }, { "BT", "TITLE", SIMPLE, LEVEL_HOST }, { "CT", "ADDRESS", SIMPLE, LEVEL_HOST }, { "AD", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "CY", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "RP", "REPRINTSTATUS",SIMPLE, LEVEL_MAIN }, { "UR", "URL", SIMPLE, LEVEL_MAIN }, { "L1", "FILEATTACH", SIMPLE, LEVEL_MAIN }, { "ID", "REFNUM", SIMPLE, LEVEL_MAIN }, { "U1", "NOTES", NOTES, LEVEL_MAIN }, { "U2", "NOTES", NOTES, LEVEL_MAIN }, { "U3", "NOTES", NOTES, LEVEL_MAIN }, { "U4", "NOTES", NOTES, LEVEL_MAIN }, { "U5", "NOTES", NOTES, LEVEL_MAIN }, { "M1", "NOTES", NOTES, LEVEL_MAIN }, { "M2", "NOTES", NOTES, LEVEL_MAIN }, { "M3", "NOTES", NOTES, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|CONFERENCE", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|conference publication", ALWAYS, LEVEL_HOST } }; static lookups statute[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "A1", "AUTHOR", PERSON, LEVEL_MAIN }, { "A2", "AUTHOR", PERSON, LEVEL_HOST }, { "A3", "AUTHOR", PERSON, LEVEL_SERIES }, { "ED", "EDITOR", PERSON, LEVEL_MAIN }, { "PY", "YEAR", DATE, LEVEL_MAIN }, { "Y1", "YEAR", DATE, LEVEL_MAIN }, { "Y2", "MONTH", SIMPLE, LEVEL_MAIN }, { "SN", "SERIALNUMBER", SERIALNO,LEVEL_MAIN }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "T1", "TITLE", TITLE, LEVEL_MAIN }, { "T2", "SHORTTITLE", SIMPLE, LEVEL_HOST }, { "T3", "TITLE", SIMPLE, LEVEL_SERIES }, { "JO", "TITLE", SIMPLE, LEVEL_HOST }, /* JOURNAL */ { "JA", "TITLE", SIMPLE, LEVEL_HOST }, { "JF", "TITLE", SIMPLE, LEVEL_HOST }, { "J1", "TITLE", SIMPLE, LEVEL_HOST }, { "J2", "TITLE", SIMPLE, LEVEL_HOST }, { "VL", "VOLUME", SIMPLE, LEVEL_MAIN }, { "VO", "VOLUME", SIMPLE, LEVEL_MAIN }, { "IS", "ISSUE", SIMPLE, LEVEL_MAIN }, { "CP", "ISSUE", SIMPLE, LEVEL_MAIN }, { "SP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "N1", "NOTES", NOTES, LEVEL_MAIN }, { "N2", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "KW", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "PB", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "BT", "TITLE", SIMPLE, LEVEL_HOST }, /* book title */ { "CT", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "AD", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "CY", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "RP", "REPRINTSTATUS",SIMPLE, LEVEL_MAIN }, { "UR", "URL", SIMPLE, LEVEL_MAIN }, { "L1", "FILEATTACH", SIMPLE, LEVEL_MAIN }, { "ID", "REFNUM", SIMPLE, LEVEL_MAIN }, { "U1", "NOTES", NOTES, LEVEL_MAIN }, { "U2", "NOTES", NOTES, LEVEL_MAIN }, { "U3", "NOTES", NOTES, LEVEL_MAIN }, { "U4", "NOTES", NOTES, LEVEL_MAIN }, { "U5", "NOTES", NOTES, LEVEL_MAIN }, { "M1", "NOTES", NOTES, LEVEL_MAIN }, { "M2", "NOTES", NOTES, LEVEL_MAIN }, { "M3", "NOTES", NOTES, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|STATUTE", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|legislation", ALWAYS, LEVEL_MAIN } }; static lookups hearing[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "A1", "AUTHOR", PERSON, LEVEL_MAIN }, { "A2", "AUTHOR", PERSON, LEVEL_HOST }, { "A3", "AUTHOR", PERSON, LEVEL_SERIES }, { "ED", "EDITOR", PERSON, LEVEL_MAIN }, { "PY", "YEAR", DATE, LEVEL_MAIN }, { "Y1", "YEAR", DATE, LEVEL_MAIN }, { "Y2", "MONTH", SIMPLE, LEVEL_MAIN }, { "SN", "SERIALNUMBER", SERIALNO,LEVEL_MAIN }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "T1", "TITLE", TITLE, LEVEL_MAIN }, { "T2", "SHORTTITLE", SIMPLE, LEVEL_HOST }, { "T3", "TITLE", SIMPLE, LEVEL_SERIES }, /* series title */ { "JO", "TITLE", SIMPLE, LEVEL_HOST }, /* JOURNAL */ { "JA", "TITLE", SIMPLE, LEVEL_HOST }, { "JF", "TITLE", SIMPLE, LEVEL_HOST }, { "J1", "TITLE", SIMPLE, LEVEL_HOST }, { "J2", "TITLE", SIMPLE, LEVEL_HOST }, { "VL", "VOLUME", SIMPLE, LEVEL_MAIN }, { "VO", "VOLUME", SIMPLE, LEVEL_MAIN }, { "IS", "ISSUE", SIMPLE, LEVEL_MAIN }, { "CP", "ISSUE", SIMPLE, LEVEL_MAIN }, { "SP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "N1", "NOTES", NOTES, LEVEL_MAIN }, { "N2", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "KW", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "PB", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "BT", "TITLE", SIMPLE, LEVEL_MAIN }, { "CT", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "AD", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "CY", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "RP", "REPRINTSTATUS",SIMPLE, LEVEL_MAIN }, { "UR", "URL", SIMPLE, LEVEL_MAIN }, { "L1", "FILEATTACH", SIMPLE, LEVEL_MAIN }, { "ID", "REFNUM", SIMPLE, LEVEL_MAIN }, { "U1", "NOTES", NOTES, LEVEL_MAIN }, { "U2", "NOTES", NOTES, LEVEL_MAIN }, { "U3", "NOTES", NOTES, LEVEL_MAIN }, { "U4", "NOTES", NOTES, LEVEL_MAIN }, { "U5", "NOTES", NOTES, LEVEL_MAIN }, { "M1", "NOTES", NOTES, LEVEL_MAIN }, { "M2", "NOTES", NOTES, LEVEL_MAIN }, { "M3", "NOTES", NOTES, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|HEARING", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|hearing", ALWAYS, LEVEL_MAIN } }; static lookups cases[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "A1", "AUTHOR", PERSON, LEVEL_MAIN }, { "A2", "AUTHOR", PERSON, LEVEL_HOST }, { "A3", "AUTHOR", PERSON, LEVEL_SERIES }, { "ED", "EDITOR", PERSON, LEVEL_MAIN }, { "PY", "YEAR", DATE, LEVEL_MAIN }, { "Y1", "YEAR", DATE, LEVEL_MAIN }, { "Y2", "MONTH", SIMPLE, LEVEL_MAIN }, { "SN", "SERIALNUMBER", SERIALNO,LEVEL_MAIN }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "T1", "TITLE", TITLE, LEVEL_MAIN }, { "T2", "SHORTTITLE", SIMPLE, LEVEL_HOST }, { "T3", "TITLE", SIMPLE, LEVEL_SERIES }, { "JO", "TITLE", SIMPLE, LEVEL_HOST }, /* JOURNAL */ { "JA", "TITLE", SIMPLE, LEVEL_HOST }, { "JF", "TITLE", SIMPLE, LEVEL_HOST }, { "J1", "TITLE", SIMPLE, LEVEL_HOST }, { "J2", "TITLE", SIMPLE, LEVEL_HOST }, { "VL", "VOLUME", SIMPLE, LEVEL_MAIN }, { "VO", "VOLUME", SIMPLE, LEVEL_MAIN }, { "IS", "ISSUE", SIMPLE, LEVEL_MAIN }, { "CP", "ISSUE", SIMPLE, LEVEL_MAIN }, { "SP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "N1", "NOTES", NOTES, LEVEL_MAIN }, { "N2", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "KW", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "PB", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "BT", "TITLE", SIMPLE, LEVEL_MAIN }, { "CT", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "AD", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "CY", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "RP", "REPRINTSTATUS",SIMPLE, LEVEL_MAIN }, { "UR", "URL", SIMPLE, LEVEL_MAIN }, { "L1", "FILEATTACH", SIMPLE, LEVEL_MAIN }, { "ID", "REFNUM", SIMPLE, LEVEL_MAIN }, { "U1", "NOTES", NOTES, LEVEL_MAIN }, { "U2", "NOTES", NOTES, LEVEL_MAIN }, { "U3", "NOTES", NOTES, LEVEL_MAIN }, { "U4", "NOTES", NOTES, LEVEL_MAIN }, { "U5", "NOTES", NOTES, LEVEL_MAIN }, { "M1", "NOTES", NOTES, LEVEL_MAIN }, { "M2", "NOTES", NOTES, LEVEL_MAIN }, { "M3", "NOTES", NOTES, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|CASE", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|legal case and case notes", ALWAYS, LEVEL_MAIN } }; static lookups communication[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "A1", "AUTHOR", PERSON, LEVEL_MAIN }, { "A2", "RECIPIENT", PERSON, LEVEL_MAIN }, { "A3", "AUTHOR", PERSON, LEVEL_HOST }, { "ED", "EDITOR", PERSON, LEVEL_MAIN }, { "PY", "YEAR", DATE, LEVEL_MAIN }, { "Y1", "YEAR", DATE, LEVEL_MAIN }, { "Y2", "MONTH", SIMPLE, LEVEL_MAIN }, { "SN", "SERIALNUMBER", SERIALNO,LEVEL_MAIN }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "T1", "TITLE", TITLE, LEVEL_MAIN }, { "T2", "SHORTTITLE", SIMPLE, LEVEL_HOST }, { "T3", "TITLE", SIMPLE, LEVEL_SERIES }, { "JO", "TITLE", SIMPLE, LEVEL_HOST }, /* JOURNAL */ { "JA", "TITLE", SIMPLE, LEVEL_HOST }, { "JF", "TITLE", SIMPLE, LEVEL_HOST }, { "J1", "TITLE", SIMPLE, LEVEL_HOST }, { "J2", "TITLE", SIMPLE, LEVEL_HOST }, { "VL", "VOLUME", SIMPLE, LEVEL_MAIN }, { "VO", "VOLUME", SIMPLE, LEVEL_MAIN }, { "IS", "ISSUE", SIMPLE, LEVEL_MAIN }, { "CP", "ISSUE", SIMPLE, LEVEL_MAIN }, { "SP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "N1", "NOTES", NOTES, LEVEL_MAIN }, { "N2", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "KW", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "PB", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "BT", "TITLE", SIMPLE, LEVEL_MAIN }, { "CT", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "AD", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "CY", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "RP", "REPRINTSTATUS",SIMPLE, LEVEL_MAIN }, { "UR", "URL", SIMPLE, LEVEL_MAIN }, { "L1", "FILEATTACH", SIMPLE, LEVEL_MAIN }, { "ID", "REFNUM", SIMPLE, LEVEL_MAIN }, { "U1", "NOTES", NOTES, LEVEL_MAIN }, { "U2", "NOTES", NOTES, LEVEL_MAIN }, { "U3", "NOTES", NOTES, LEVEL_MAIN }, { "U4", "NOTES", NOTES, LEVEL_MAIN }, { "U5", "NOTES", NOTES, LEVEL_MAIN }, { "M1", "GENRE", SIMPLE, LEVEL_MAIN }, { "M2", "NOTES", NOTES, LEVEL_MAIN }, { "M3", "NOTES", NOTES, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|ARTICLE", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|communication", ALWAYS, LEVEL_MAIN } }; static lookups thesis[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "A1", "AUTHOR", PERSON, LEVEL_MAIN }, { "A2", "AUTHOR", PERSON, LEVEL_HOST }, { "A3", "AUTHOR", PERSON, LEVEL_SERIES }, { "ED", "EDITOR", PERSON, LEVEL_MAIN }, { "PY", "YEAR", DATE, LEVEL_MAIN }, { "Y1", "YEAR", DATE, LEVEL_MAIN }, { "Y2", "MONTH", SIMPLE, LEVEL_MAIN }, { "SN", "SERIALNUMBER", SERIALNO,LEVEL_MAIN }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "T1", "TITLE", TITLE, LEVEL_MAIN }, { "T2", "SHORTTITLE", SIMPLE, LEVEL_HOST }, { "T3", "TITLE", SIMPLE, LEVEL_SERIES }, { "JO", "TITLE", SIMPLE, LEVEL_HOST }, /* JOURNAL */ { "JA", "TITLE", SIMPLE, LEVEL_HOST }, { "JF", "TITLE", SIMPLE, LEVEL_HOST }, { "J1", "TITLE", SIMPLE, LEVEL_HOST }, { "J2", "TITLE", SIMPLE, LEVEL_HOST }, { "VL", "VOLUME", SIMPLE, LEVEL_MAIN }, { "VO", "VOLUME", SIMPLE, LEVEL_MAIN }, { "IS", "ISSUE", SIMPLE, LEVEL_MAIN }, { "CP", "ISSUE", SIMPLE, LEVEL_MAIN }, { "SP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "N1", "NOTES", NOTES, LEVEL_MAIN }, { "N2", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "KW", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "PB", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "BT", "TITLE", SIMPLE, LEVEL_HOST }, { "CT", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "AD", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "CY", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "RP", "REPRINTSTATUS",SIMPLE, LEVEL_MAIN }, { "UR", "URL", SIMPLE, LEVEL_MAIN }, { "L1", "FILEATTACH", SIMPLE, LEVEL_MAIN }, { "ID", "REFNUM", SIMPLE, LEVEL_MAIN }, { "U1", "NOTES", NOTES, LEVEL_MAIN }, /*user defined */ { "U2", "NOTES", NOTES, LEVEL_MAIN }, /* put in "notes" */ { "U3", "NOTES", NOTES, LEVEL_MAIN }, { "U4", "NOTES", NOTES, LEVEL_MAIN }, { "U5", "NOTES", NOTES, LEVEL_MAIN }, { "M1", "NOTES", NOTES, LEVEL_MAIN }, /*misc */ { "M2", "NOTES", NOTES, LEVEL_MAIN }, /* put in "notes" */ { "M3", "NOTES", NOTES, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|THESIS", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text",ALWAYS, LEVEL_MAIN }, { " ", "GENRE|thesis", ALWAYS, LEVEL_MAIN }, }; static lookups report[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "A1", "AUTHOR", PERSON, LEVEL_MAIN }, { "A2", "AUTHOR", PERSON, LEVEL_HOST }, { "A3", "AUTHOR", PERSON, LEVEL_SERIES }, { "ED", "EDITOR", PERSON, LEVEL_MAIN }, { "PY", "YEAR", DATE, LEVEL_MAIN }, { "Y1", "YEAR", DATE, LEVEL_MAIN }, { "Y2", "MONTH", SIMPLE, LEVEL_MAIN }, { "SN", "SERIALNUMBER", SERIALNO,LEVEL_MAIN }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "T1", "TITLE", TITLE, LEVEL_MAIN }, { "T2", "SHORTTITLE", SIMPLE, LEVEL_HOST }, { "T3", "TITLE", SIMPLE, LEVEL_SERIES }, { "JO", "TITLE", SIMPLE, LEVEL_HOST }, /* JOURNAL */ { "JA", "TITLE", SIMPLE, LEVEL_HOST }, { "JF", "TITLE", SIMPLE, LEVEL_HOST }, { "J1", "TITLE", SIMPLE, LEVEL_HOST }, { "J2", "TITLE", SIMPLE, LEVEL_HOST }, { "VL", "VOLUME", SIMPLE, LEVEL_MAIN }, { "VO", "VOLUME", SIMPLE, LEVEL_MAIN }, { "IS", "ISSUE", SIMPLE, LEVEL_MAIN }, { "CP", "ISSUE", SIMPLE, LEVEL_MAIN }, { "SP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "N1", "NOTES", NOTES, LEVEL_MAIN }, { "N2", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "KW", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "PB", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "BT", "TITLE", SIMPLE, LEVEL_HOST }, { "CT", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "AD", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "CY", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "RP", "REPRINTSTATUS",SIMPLE, LEVEL_MAIN }, { "UR", "URL", SIMPLE, LEVEL_MAIN }, { "L1", "FILEATTACH", SIMPLE, LEVEL_MAIN }, { "ID", "REFNUM", SIMPLE, LEVEL_MAIN }, { "U1", "NOTES", NOTES, LEVEL_MAIN }, /*user defined */ { "U2", "NOTES", NOTES, LEVEL_MAIN }, /* put in "notes" */ { "U3", "NOTES", NOTES, LEVEL_MAIN }, { "U4", "NOTES", NOTES, LEVEL_MAIN }, { "U5", "NOTES", NOTES, LEVEL_MAIN }, { "M1", "NOTES", NOTES, LEVEL_MAIN }, /*misc */ { "M2", "NOTES", NOTES, LEVEL_MAIN }, /* put in "notes" */ { "M3", "NOTES", NOTES, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|REPORT", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text",ALWAYS, LEVEL_MAIN }, { " ", "GENRE|report", ALWAYS, LEVEL_MAIN } }; static lookups abstract[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "A1", "AUTHOR", PERSON, LEVEL_MAIN }, { "A2", "AUTHOR", PERSON, LEVEL_HOST }, { "A3", "AUTHOR", PERSON, LEVEL_SERIES }, { "ED", "EDITOR", PERSON, LEVEL_MAIN }, { "PY", "YEAR", DATE, LEVEL_MAIN }, { "Y1", "YEAR", DATE, LEVEL_MAIN }, { "Y2", "MONTH", SIMPLE, LEVEL_MAIN }, { "SN", "SERIALNUMBER", SERIALNO,LEVEL_MAIN }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "T1", "TITLE", TITLE, LEVEL_MAIN }, { "T2", "SHORTTITLE", SIMPLE, LEVEL_HOST }, { "T3", "TITLE", SIMPLE, LEVEL_SERIES }, { "JO", "TITLE", SIMPLE, LEVEL_HOST }, /* JOURNAL */ { "JA", "TITLE", SIMPLE, LEVEL_HOST }, { "JF", "TITLE", SIMPLE, LEVEL_HOST }, { "J1", "TITLE", SIMPLE, LEVEL_HOST }, { "J2", "TITLE", SIMPLE, LEVEL_HOST }, { "VL", "VOLUME", SIMPLE, LEVEL_MAIN }, { "VO", "VOLUME", SIMPLE, LEVEL_MAIN }, { "IS", "ISSUE", SIMPLE, LEVEL_MAIN }, { "CP", "ISSUE", SIMPLE, LEVEL_MAIN }, { "SP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "N1", "NOTES", NOTES, LEVEL_MAIN }, { "N2", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "KW", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "PB", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "BT", "TITLE", SIMPLE, LEVEL_HOST }, { "CT", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "AD", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "CY", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "RP", "REPRINTSTATUS",SIMPLE, LEVEL_MAIN }, { "UR", "URL", SIMPLE, LEVEL_MAIN }, { "L1", "FILEATTACH", SIMPLE, LEVEL_MAIN }, { "ID", "REFNUM", SIMPLE, LEVEL_MAIN }, { "U1", "NOTES", NOTES, LEVEL_MAIN }, /*user defined */ { "U2", "NOTES", NOTES, LEVEL_MAIN }, /* put in "notes" */ { "U3", "NOTES", NOTES, LEVEL_MAIN }, { "U4", "NOTES", NOTES, LEVEL_MAIN }, { "U5", "NOTES", NOTES, LEVEL_MAIN }, { "M1", "NOTES", NOTES, LEVEL_MAIN }, /*misc */ { "M2", "NOTES", NOTES, LEVEL_MAIN }, /* put in "notes" */ { "M3", "NOTES", NOTES, LEVEL_MAIN }, { " ", "GENRE|abstract or summary", ALWAYS, LEVEL_MAIN } }; static lookups program[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "A1", "AUTHOR", PERSON, LEVEL_MAIN }, { "A2", "AUTHOR", PERSON, LEVEL_HOST }, { "A3", "AUTHOR", PERSON, LEVEL_SERIES }, { "ED", "EDITOR", PERSON, LEVEL_MAIN }, { "PY", "YEAR", DATE, LEVEL_MAIN }, { "Y1", "YEAR", DATE, LEVEL_MAIN }, { "Y2", "MONTH", SIMPLE, LEVEL_MAIN }, { "SN", "SERIALNUMBER", SERIALNO,LEVEL_MAIN }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "T1", "TITLE", TITLE, LEVEL_MAIN }, { "T2", "SHORTTITLE", SIMPLE, LEVEL_HOST }, { "T3", "TITLE", SIMPLE, LEVEL_SERIES }, { "JO", "TITLE", SIMPLE, LEVEL_HOST }, /* JOURNAL */ { "JA", "TITLE", SIMPLE, LEVEL_HOST }, { "JF", "TITLE", SIMPLE, LEVEL_HOST }, { "J1", "TITLE", SIMPLE, LEVEL_HOST }, { "J2", "TITLE", SIMPLE, LEVEL_HOST }, { "VL", "VOLUME", SIMPLE, LEVEL_MAIN }, { "VO", "VOLUME", SIMPLE, LEVEL_MAIN }, { "IS", "ISSUE", SIMPLE, LEVEL_MAIN }, { "CP", "ISSUE", SIMPLE, LEVEL_MAIN }, { "SP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "N1", "NOTES", NOTES, LEVEL_MAIN }, { "N2", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "KW", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "PB", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "BT", "TITLE", SIMPLE, LEVEL_HOST }, { "CT", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "AD", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "CY", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "RP", "REPRINTSTATUS",SIMPLE, LEVEL_MAIN }, { "UR", "URL", SIMPLE, LEVEL_MAIN }, { "L1", "FILEATTACH", SIMPLE, LEVEL_MAIN }, { "ID", "REFNUM", SIMPLE, LEVEL_MAIN }, { "U1", "NOTES", NOTES, LEVEL_MAIN }, /*user defined */ { "U2", "NOTES", NOTES, LEVEL_MAIN }, /* put in "notes" */ { "U3", "NOTES", NOTES, LEVEL_MAIN }, { "U4", "NOTES", NOTES, LEVEL_MAIN }, { "U5", "NOTES", NOTES, LEVEL_MAIN }, { "M1", "NOTES", NOTES, LEVEL_MAIN }, /*misc */ { "M2", "NOTES", NOTES, LEVEL_MAIN }, /* put in "notes" */ { "M3", "NOTES", NOTES, LEVEL_MAIN }, { " ", "RESOURCE|software, multimedia", ALWAYS, LEVEL_MAIN } }; static lookups patent[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "A1", "AUTHOR", PERSON, LEVEL_MAIN }, { "A2", "AUTHOR", PERSON, LEVEL_HOST }, { "A3", "AUTHOR", PERSON, LEVEL_SERIES }, { "ED", "EDITOR", PERSON, LEVEL_MAIN }, { "PY", "YEAR", DATE, LEVEL_MAIN }, { "Y1", "YEAR", DATE, LEVEL_MAIN }, { "Y2", "MONTH", SIMPLE, LEVEL_MAIN }, { "SN", "SERIALNUMBER", SERIALNO,LEVEL_MAIN }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "T1", "TITLE", TITLE, LEVEL_MAIN }, { "T2", "SHORTTITLE", SIMPLE, LEVEL_HOST }, { "T3", "TITLE", SIMPLE, LEVEL_SERIES }, { "JO", "TITLE", SIMPLE, LEVEL_HOST }, /* JOURNAL */ { "JA", "TITLE", SIMPLE, LEVEL_HOST }, { "JF", "TITLE", SIMPLE, LEVEL_HOST }, { "J1", "TITLE", SIMPLE, LEVEL_HOST }, { "J2", "TITLE", SIMPLE, LEVEL_HOST }, { "VL", "VOLUME", SIMPLE, LEVEL_MAIN }, { "VO", "VOLUME", SIMPLE, LEVEL_MAIN }, { "IS", "ISSUE", SIMPLE, LEVEL_MAIN }, { "CP", "ISSUE", SIMPLE, LEVEL_MAIN }, { "SP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "N1", "NOTES", NOTES, LEVEL_MAIN }, { "N2", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "KW", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "PB", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "BT", "TITLE", SIMPLE, LEVEL_HOST }, { "CT", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "AD", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "CY", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "RP", "REPRINTSTATUS",SIMPLE, LEVEL_MAIN }, { "UR", "URL", SIMPLE, LEVEL_MAIN }, { "ID", "REFNUM", SIMPLE, LEVEL_MAIN }, { "U1", "NOTES", NOTES, LEVEL_MAIN }, /*user defined */ { "L1", "FILEATTACH", SIMPLE, LEVEL_MAIN }, { "U2", "NOTES", NOTES, LEVEL_MAIN }, /* put in "notes" */ { "U3", "NOTES", NOTES, LEVEL_MAIN }, { "U4", "NOTES", NOTES, LEVEL_MAIN }, { "U5", "NOTES", NOTES, LEVEL_MAIN }, { "M1", "NOTES", NOTES, LEVEL_MAIN }, /*misc */ { "M2", "NOTES", NOTES, LEVEL_MAIN }, /* put in "notes" */ { "M3", "NOTES", NOTES, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|patent", ALWAYS, LEVEL_MAIN } }; static lookups electric[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "A1", "AUTHOR", PERSON, LEVEL_MAIN }, { "A2", "AUTHOR", PERSON, LEVEL_HOST }, { "A3", "AUTHOR", PERSON, LEVEL_SERIES }, { "ED", "EDITOR", PERSON, LEVEL_MAIN }, { "PY", "YEAR", DATE, LEVEL_MAIN }, { "Y1", "YEAR", DATE, LEVEL_MAIN }, { "Y2", "MONTH", SIMPLE, LEVEL_MAIN }, { "SN", "SERIALNUMBER", SERIALNO,LEVEL_MAIN }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "T1", "TITLE", TITLE, LEVEL_MAIN }, { "T2", "SHORTTITLE", SIMPLE, LEVEL_HOST }, { "T3", "TITLE", SIMPLE, LEVEL_SERIES }, { "JO", "TITLE", SIMPLE, LEVEL_HOST }, /* JOURNAL */ { "JA", "TITLE", SIMPLE, LEVEL_HOST }, { "JF", "TITLE", SIMPLE, LEVEL_HOST }, { "J1", "TITLE", SIMPLE, LEVEL_HOST }, { "J2", "TITLE", SIMPLE, LEVEL_HOST }, { "VL", "VOLUME", SIMPLE, LEVEL_MAIN }, { "VO", "VOLUME", SIMPLE, LEVEL_MAIN }, { "IS", "ISSUE", SIMPLE, LEVEL_MAIN }, { "CP", "ISSUE", SIMPLE, LEVEL_MAIN }, { "SP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "N1", "NOTES", NOTES, LEVEL_MAIN }, { "N2", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "KW", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "PB", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "BT", "TITLE", SIMPLE, LEVEL_HOST }, { "CT", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "AD", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "CY", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "RP", "REPRINTSTATUS",SIMPLE, LEVEL_MAIN }, { "UR", "URL", SIMPLE, LEVEL_MAIN }, { "L1", "FILEATTACH", SIMPLE, LEVEL_MAIN }, { "ID", "REFNUM", SIMPLE, LEVEL_MAIN }, { "U1", "NOTES", NOTES, LEVEL_MAIN }, /*user defined */ { "U2", "NOTES", NOTES, LEVEL_MAIN }, /* put in "notes" */ { "U3", "NOTES", NOTES, LEVEL_MAIN }, { "U4", "NOTES", NOTES, LEVEL_MAIN }, { "U5", "NOTES", NOTES, LEVEL_MAIN }, { "M1", "NOTES", NOTES, LEVEL_MAIN }, /*misc */ { "M2", "NOTES", NOTES, LEVEL_MAIN }, /* put in "notes" */ { "M3", "NOTES", NOTES, LEVEL_MAIN }, { " ", "RESOURCE|software, multimedia", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|electronic", ALWAYS, LEVEL_MAIN }, }; static lookups pamphlet[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "A1", "AUTHOR", PERSON, LEVEL_MAIN }, { "A2", "AUTHOR", PERSON, LEVEL_HOST }, { "A3", "AUTHOR", PERSON, LEVEL_SERIES }, { "ED", "EDITOR", PERSON, LEVEL_MAIN }, { "PY", "YEAR", DATE, LEVEL_MAIN }, { "Y1", "YEAR", DATE, LEVEL_MAIN }, { "Y2", "MONTH", SIMPLE, LEVEL_MAIN }, { "SN", "SERIALNUMBER", SERIALNO,LEVEL_MAIN }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "T1", "TITLE", TITLE, LEVEL_MAIN }, { "T2", "SHORTTITLE", SIMPLE, LEVEL_HOST }, { "T3", "TITLE", SIMPLE, LEVEL_SERIES }, { "JO", "TITLE", SIMPLE, LEVEL_HOST }, /* JOURNAL */ { "JA", "TITLE", SIMPLE, LEVEL_HOST }, { "JF", "TITLE", SIMPLE, LEVEL_HOST }, { "J1", "TITLE", SIMPLE, LEVEL_HOST }, { "J2", "TITLE", SIMPLE, LEVEL_HOST }, { "VL", "VOLUME", SIMPLE, LEVEL_MAIN }, { "VO", "VOLUME", SIMPLE, LEVEL_MAIN }, { "IS", "ISSUE", SIMPLE, LEVEL_MAIN }, { "CP", "ISSUE", SIMPLE, LEVEL_MAIN }, { "SP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "N1", "NOTES", NOTES, LEVEL_MAIN }, { "N2", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "KW", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "PB", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "BT", "TITLE", SIMPLE, LEVEL_HOST }, { "CT", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "AD", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "CY", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "RP", "REPRINTSTATUS",SIMPLE, LEVEL_MAIN }, { "UR", "URL", SIMPLE, LEVEL_MAIN }, { "L1", "FILEATTACH", SIMPLE, LEVEL_MAIN }, { "ID", "REFNUM", SIMPLE, LEVEL_MAIN }, { "U1", "NOTES", NOTES, LEVEL_MAIN }, /*user defined */ { "U2", "NOTES", NOTES, LEVEL_MAIN }, /* put in "notes" */ { "U3", "NOTES", NOTES, LEVEL_MAIN }, { "U4", "NOTES", NOTES, LEVEL_MAIN }, { "U5", "NOTES", NOTES, LEVEL_MAIN }, { "M1", "NOTES", NOTES, LEVEL_MAIN }, /*misc */ { "M2", "NOTES", NOTES, LEVEL_MAIN }, /* put in "notes" */ { "M3", "NOTES", NOTES, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|pamphlet", ALWAYS, LEVEL_MAIN }, }; static lookups unpublished[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "A1", "AUTHOR", PERSON, LEVEL_MAIN }, { "A2", "AUTHOR", PERSON, LEVEL_HOST }, { "A3", "AUTHOR", PERSON, LEVEL_SERIES }, { "ED", "EDITOR", PERSON, LEVEL_MAIN }, { "PY", "YEAR", DATE, LEVEL_MAIN }, { "Y1", "YEAR", DATE, LEVEL_MAIN }, { "Y2", "MONTH", SIMPLE, LEVEL_MAIN }, { "SN", "SERIALNUMBER", SERIALNO,LEVEL_MAIN }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "T1", "TITLE", TITLE, LEVEL_MAIN }, { "T2", "SHORTTITLE", SIMPLE, LEVEL_HOST }, { "T3", "TITLE", SIMPLE, LEVEL_SERIES }, { "JO", "TITLE", SIMPLE, LEVEL_HOST }, /* JOURNAL */ { "JA", "TITLE", SIMPLE, LEVEL_HOST }, { "JF", "TITLE", SIMPLE, LEVEL_HOST }, { "J1", "TITLE", SIMPLE, LEVEL_HOST }, { "J2", "TITLE", SIMPLE, LEVEL_HOST }, { "VL", "VOLUME", SIMPLE, LEVEL_MAIN }, { "VO", "VOLUME", SIMPLE, LEVEL_MAIN }, { "IS", "ISSUE", SIMPLE, LEVEL_MAIN }, { "CP", "ISSUE", SIMPLE, LEVEL_MAIN }, { "SP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "N1", "NOTES", NOTES, LEVEL_MAIN }, { "N2", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "KW", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "PB", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "BT", "TITLE", SIMPLE, LEVEL_HOST }, { "CT", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "AD", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "CY", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "RP", "REPRINTSTATUS",SIMPLE, LEVEL_MAIN }, { "UR", "URL", SIMPLE, LEVEL_MAIN }, { "L1", "FILEATTACH", SIMPLE, LEVEL_MAIN }, { "ID", "REFNUM", SIMPLE, LEVEL_MAIN }, { "U1", "NOTES", NOTES, LEVEL_MAIN }, /*user defined */ { "U2", "NOTES", NOTES, LEVEL_MAIN }, /* put in "notes" */ { "U3", "NOTES", NOTES, LEVEL_MAIN }, { "U4", "NOTES", NOTES, LEVEL_MAIN }, { "U5", "NOTES", NOTES, LEVEL_MAIN }, { "M1", "NOTES", NOTES, LEVEL_MAIN }, /*misc */ { "M2", "NOTES", NOTES, LEVEL_MAIN }, /* put in "notes" */ { "M3", "NOTES", NOTES, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|unpublished", ALWAYS, LEVEL_MAIN } }; #define ORIG(a) ( &(a[0]) ) #define SIZE(a) ( sizeof( a ) / sizeof( lookups ) ) #define REFTYPE(a,b) { a, ORIG(b), SIZE(b) } variants ris_all[] = { REFTYPE( "STD", generic ), REFTYPE( "GEN", generic ), REFTYPE( "JOUR", article ), REFTYPE( "MGZN", magarticle ), REFTYPE( "BOOK", book ), REFTYPE( "CHAP", inbook ), REFTYPE( "CONF", conference ), REFTYPE( "STAT", statute ), REFTYPE( "HEAR", hearing ), REFTYPE( "CASE", cases ), REFTYPE( "NEWS", newsarticle ), REFTYPE( "MPCT", generic ), REFTYPE( "PCOMM", communication ), REFTYPE( "PAMP", pamphlet ), REFTYPE( "ELEC", electric ), REFTYPE( "THES", thesis ), REFTYPE( "RPRT", report ), REFTYPE( "ABST", abstract ), REFTYPE( "COMP", program ), REFTYPE( "PAT", patent ), REFTYPE( "UNPB", unpublished ), }; int ris_nall = sizeof( ris_all ) / sizeof( variants ); bibutils_4.12/lib/marc.c0000644000076400007640000000370411444072056015422 0ustar cdputnamcdputnam#include "marc.h" #include int marc_findgenre( char *query ) { char *marc[] = { "abstract or summary", "art original", "art reproduction", "article", "atlas", "autobiography", "bibliography", "biography", "book", "catalog", "chart", "comic strip", "conference publication", "database", "dictionary", "diorama", "directory", "discography", "drama", "encyclopedia", "essay", "festschrift", "fiction", "filmography", "filmstrip", "finding aid", "flash card", "folktale", "font", "game", "government publication", "graphic", "globe", "handbook", "history", "humor, satire", "index", "instruction", "interview", "kit", "language instruction", "law report or digest", "legal article", "legal case and case notes", "legislation", "letter", "loose-leaf", "map", "memoir", "microscope slide", "model", "motion picture", "multivolume monograph", "newspaper", "novel", "numeric data", "offprint", "online system or service", "patent", "periodical", "picture", "poetry", "programmed text", "realia", "rehearsal", "remote sensing image", "reporting", "review", "series", "short story", "slide", "sound", "speech", "statistics", "survey of literature", "technical drawing", "technical report", "thesis", "toy", "transparency", "treaty", "videorecording", "web site" }; int nmarc = sizeof( marc ) / sizeof( char* ); int i; for ( i=0; i #include #include #include #include #include #include "newstr.h" #include "is_ws.h" #include #define newstr_initlen (64) #ifndef NEWSTR_PARANOIA static void newstr_realloc( newstr *s, unsigned long minsize ) { char *newptr; unsigned long size; assert( s ); size = 2 * s->dim; if (size < minsize) size = minsize; newptr = (char *) realloc( s->data, sizeof( *(s->data) )*size ); if ( !newptr ) { fprintf(stderr,"Error. Cannot reallocate memory (%ld bytes) in newstr_realloc.\n", sizeof(*(s->data))*size); exit( EXIT_FAILURE ); } s->data = newptr; s->dim = size; } /* define as no-op */ static inline void newstr_nullify( newstr *s ) { } #else static void newstr_realloc( newstr *s, unsigned long minsize ) { char *newptr; unsigned long size; assert( s ); size = 2 * s->dim; if ( size < minsize ) size = minsize; newptr = (char *) malloc( sizeof( *(s->data) ) * size ); if ( !newptr ) { fprintf( stderr, "Error. Cannot reallocate memory (%d bytes)" " in newstr_realloc.\n", sizeof(*(s->data))*size ); exit( EXIT_FAILURE ); } if ( s->data ) { newstr_nullify( s ); free( s->data ); } s->data = newptr; s->dim = size; } static inline void newstr_nullify( newstr *s ) { memset( s->data, 0, s->dim ); } #endif void newstr_init( newstr *s ) { assert( s ); s->dim = 0; s->len = 0; s->data = NULL; } void newstrs_init( newstr *s, ... ) { newstr *s2; va_list ap; newstr_init( s ); va_start( ap, s ); do { s2 = va_arg( ap, newstr * ); if ( s2 ) newstr_init( s2 ); } while ( s2 ); va_end( ap ); } static void newstr_initalloc( newstr *s, unsigned long minsize ) { unsigned long size = newstr_initlen; assert( s ); if ( minsize > newstr_initlen ) size = minsize; s->data = (char *) malloc (sizeof( *(s->data) ) * size); if ( !s->data ) { fprintf(stderr,"Error. Cannot allocate memory in newstr_initalloc.\n"); exit( EXIT_FAILURE ); } s->data[0]='\0'; s->dim=size; s->len=0; } newstr * newstr_new( void ) { newstr *s = (newstr *) malloc( sizeof( *s ) ); if ( s ) newstr_initalloc( s, newstr_initlen ); return s; } void newstr_free( newstr *s ) { assert( s ); if ( s->data ) { newstr_nullify( s ); free( s->data ); } s->dim = 0; s->len = 0; s->data = NULL; } void newstrs_free( newstr *s, ... ) { newstr *s2; va_list ap; newstr_free( s ); va_start( ap, s ); do { s2 = va_arg( ap, newstr * ); if ( s2 ) newstr_free( s2 ); } while ( s2 ); va_end( ap ); } void newstr_empty( newstr *s ) { assert( s ); if ( s->data ) { newstr_nullify( s ); s->data[0] = '\0'; } s->len = 0; } void newstrs_empty( newstr *s, ... ) { newstr *s2; va_list ap; newstr_empty( s ); va_start( ap, s ); do { s2 = va_arg( ap, newstr * ); if ( s2 ) newstr_empty( s2 ); } while ( s2 ); va_end( ap ); } void newstr_addchar( newstr *s, char newchar ) { assert( s ); if ( !s->data || s->dim==0 ) newstr_initalloc( s, newstr_initlen ); if ( s->len + 2 > s->dim ) newstr_realloc( s, s->len+2 ); s->data[s->len++] = newchar; s->data[s->len] = '\0'; } void newstr_fprintf( FILE *fp, newstr *s ) { assert( s ); if ( s->data ) fprintf( fp, "%s", s->data ); } void newstr_prepend( newstr *s, char *addstr ) { unsigned long lenaddstr, i; assert( s && addstr ); lenaddstr = strlen( addstr ); if ( !s->data || !s->dim ) newstr_initalloc( s, lenaddstr+1 ); else { if ( s->len + lenaddstr + 1 > s->dim ) newstr_realloc( s, s->len + lenaddstr + 1 ); for ( i=s->len+lenaddstr-1; i>=lenaddstr; i-- ) s->data[i] = s->data[i-lenaddstr]; } strncpy( s->data, addstr, lenaddstr ); s->len += lenaddstr; s->data[ s->len ] = '\0'; } static inline void newstr_strcat_ensurespace( newstr *s, unsigned long n ) { unsigned long m = s->len + n + 1; if ( !s->data || !s->dim ) newstr_initalloc( s, m ); else if ( s->len + n + 1 > s->dim ) newstr_realloc( s, m ); } static inline void newstr_strcat_internal( newstr *s, char *addstr, unsigned long n ) { newstr_strcat_ensurespace( s, n ); strncat( &(s->data[s->len]), addstr, n ); s->len += n; s->data[s->len]='\0'; } void newstr_newstrcat( newstr *s, newstr *old ) { assert ( s && old ); if ( !old->data ) return; else newstr_strcat_internal( s, old->data, old->len ); } void newstr_strcat( newstr *s, char *addstr ) { unsigned long n; assert( s && addstr ); n = strlen( addstr ); newstr_strcat_internal( s, addstr, n ); } void newstr_segcat( newstr *s, char *startat, char *endat ) { size_t seglength; char *p, *q; assert( s && startat && endat ); assert( (size_t) startat < (size_t) endat ); seglength=(size_t) endat - (size_t) startat; if ( !s->data || !s->dim ) newstr_initalloc( s, seglength+1 ); else { if ( s->len + seglength + 1 > s->dim ) newstr_realloc( s, s->len + seglength+1 ); } q = &(s->data[s->len]); p = startat; while ( *p && p!=endat ) *q++ = *p++; *q = '\0'; s->len += seglength; } static inline void newstr_strcpy_ensurespace( newstr *s, unsigned long n ) { unsigned long m = n + 1; if ( !s->data || !s->dim ) newstr_initalloc( s, m ); else if ( n+1 > s->dim ) newstr_realloc( s, m ); } static inline void newstr_strcpy_internal( newstr *s, char *p, unsigned long n ) { newstr_strcpy_ensurespace( s, n ); strcpy( s->data, p ); s->len = n; } void newstr_newstrcpy( newstr *s, newstr *old ) { assert( s && old ); if ( s==old ) return; if ( !old->data || !old->dim ) newstr_empty( s ); else newstr_strcpy_internal( s, old->data, old->len ); } void newstr_strcpy( newstr *s, char *addstr ) { unsigned long n; assert( s && addstr ); n = strlen( addstr ); newstr_strcpy_internal( s, addstr, n ); } newstr * newstr_strdup( char *s1 ) { newstr *s2 = newstr_new(); if ( s2 ) newstr_strcpy( s2, s1 ); return s2; } /* newstr_segcpy( s, start, end ); * * copies [start,end) into s */ void newstr_segcpy( newstr *s, char *startat, char *endat ) { size_t n; char *p, *q; assert( s && startat && endat ); assert( ((size_t) startat) <= ((size_t) endat) ); n = (size_t) endat - (size_t) startat; newstr_strcpy_ensurespace( s, n ); q = s->data; p = startat; while ( *p && p!=endat ) *q++ = *p++; *q = '\0'; s->len = n; } void newstr_segdel( newstr *s, char *p, char *q ) { newstr tmp1, tmp2; char *r; assert( s ); r = &(s->data[s->len]); newstr_init( &tmp1 ); newstr_init( &tmp2 ); newstr_segcpy( &tmp1, s->data, p ); newstr_segcpy( &tmp2, q, r ); newstr_empty( s ); if ( tmp1.data ) newstr_strcat( s, tmp1.data ); if ( tmp2.data ) newstr_strcat( s, tmp2.data ); newstr_free( &tmp2 ); newstr_free( &tmp1 ); } /* * newstr_findreplace() * * if replace is "" or NULL, then delete find */ int newstr_findreplace( newstr *s, char *find, char *replace ) { long diff; size_t findstart, searchstart; size_t p1, p2; size_t find_len, rep_len, curr_len; char empty[2] = ""; unsigned long minsize; char *p; int n = 0; assert( s && find ); if ( !s->data || !s->dim ) return n; if ( !replace ) replace = empty; find_len = strlen( find ); rep_len = strlen( replace ); diff = rep_len - find_len; if ( diff < 0 ) diff = 0; searchstart=0; while ((p=strstr(s->data + searchstart,find))!=NULL) { curr_len = strlen(s->data); findstart=(size_t) p - (size_t) s->data; minsize = curr_len + diff + 1; if (s->dim <= minsize) newstr_realloc( s, minsize ); if ( find_len > rep_len ) { p1 = findstart + rep_len; p2 = findstart + find_len; while( s->data[p2] ) s->data[p1++]=s->data[p2++]; s->data[p1]='\0'; n++; } else if ( find_len < rep_len ) { for ( p1=curr_len; p1>=findstart+find_len; p1-- ) s->data[p1+diff] = s->data[p1]; n++; } for (p1=0; p1data[findstart+p1]=replace[p1]; searchstart = findstart + rep_len; s->len += rep_len - find_len; } return n; } /* newstr_fget() * returns 0 if we're done, 1 if we're not done * extracts line by line (regardless of end characters) * and feeds from buf.... */ int newstr_fget( FILE *fp, char *buf, int bufsize, int *pbufpos, newstr *outs ) { int bufpos = *pbufpos, done = 0; char *ok; newstr_empty( outs ); while ( !done ) { while ( buf[bufpos] && buf[bufpos]!='\r' && buf[bufpos]!='\n' ) newstr_addchar( outs, buf[bufpos++] ); if ( buf[bufpos]=='\0' ) { ok = fgets( buf, bufsize, fp ); bufpos=*pbufpos=0; if ( !ok && feof(fp) ) { /* end-of-file */ buf[bufpos] = 0; if ( outs->len==0 ) return 0; /*nothing in out*/ else return 1; /*one last out */ } } else if ( buf[bufpos]=='\r' || buf[bufpos]=='\n' ) done=1; } if ( ( buf[bufpos]=='\n' && buf[bufpos+1]=='\r') || ( buf[bufpos]=='\r' && buf[bufpos+1]=='\n') ) bufpos+=2; else if ( buf[bufpos]=='\n' || buf[bufpos]=='\r' ) bufpos+=1; *pbufpos = bufpos; return 1; } void newstr_toupper( newstr *s ) { unsigned long i; assert( s ); for ( i=0; ilen; ++i ) s->data[i] = toupper( s->data[i] ); } /* newstr_swapstrings( s1, s2 ) * be sneaky and swap internal newstring data from one * string to another */ void newstr_swapstrings( newstr *s1, newstr *s2 ) { char *tmpp; int tmp; assert( s1 && s2 ); /* swap dimensioning info */ tmp = s1->dim; s1->dim = s2->dim; s2->dim = tmp; /* swap length info */ tmp = s1->len; s1->len = s2->len; s2->len = tmp; /* swap data */ tmpp = s1->data; s1->data = s2->data; s2->data = tmpp; } void newstr_trimendingws( newstr *s ) { assert( s ); while ( s->len > 0 && is_ws( s->data[s->len-1] ) ) { s->data[s->len-1] = '\0'; s->len--; } } bibutils_4.12/lib/utf8.h0000644000076400007640000000052211444072056015366 0ustar cdputnamcdputnam/* * utf8.h * * Copyright (c) Chris Putnam 2004-2010 * * Source code released under the GPL * */ #ifndef UTF8_H #define UTF8_H #include extern int utf8_encode( unsigned int value, unsigned char out[6] ); extern unsigned int utf8_decode( char *s, unsigned int *pi ); extern void utf8_writebom( FILE *outptr ); #endif bibutils_4.12/lib/gb18030.h0000644000076400007640000000045611444072056015472 0ustar cdputnamcdputnam/* * gb18030.h * * Copyright (c) Chris Putnam 2008-2009 * * Program and source code released under the GPL * */ #ifndef GB18030_H #define GB18030_H extern int gb18030_encode( unsigned int unicode, unsigned char out[4] ); extern unsigned int gb18030_decode( char *s, unsigned int *pi ); #endif bibutils_4.12/lib/bibtexout.h0000644000076400007640000000125611453453567016524 0ustar cdputnamcdputnam/* * bibtexout.h * * Copyright (c) Chris Putnam 2005-2010 * */ #ifndef BIBTEXOUT_H #define BIBTEXOUT_H #include #include "fields.h" #include "bibutils.h" /* bibtexout output options */ #define BIBOUT_FINALCOMMA (2) #define BIBOUT_SINGLEDASH (4) #define BIBOUT_WHITESPACE (8) #define BIBOUT_BRACKETS (16) #define BIBOUT_UPPERCASE (32) #define BIBOUT_STRICTKEY (64) #define BIBOUT_SHORTTITLE (128) #define BIBOUT_DROPKEY (256) extern void bibtexout_write( fields *info, FILE *fp, param *p, unsigned long refnum ); extern void bibtexout_writeheader( FILE *outptr, param *p ); extern void bibtexout_initparams( param *p, const char *progname ); #endif bibutils_4.12/lib/adsout.c0000644000076400007640000002625511477220225016004 0ustar cdputnamcdputnam/* * adsout.c * * Copyright (c) Richard Mathar 2007-2010 * Copyright (c) Chris Putnam 2007-2010 * * Program and source code released under the GPL * */ #include #include #include #include #include "utf8.h" #include "newstr.h" #include "strsearch.h" #include "fields.h" #include "adsout.h" void adsout_initparams( param *p, const char *progname ) { p->writeformat = BIBL_ADSABSOUT; p->format_opts = 0; p->charsetout = BIBL_CHARSET_DEFAULT; p->charsetout_src = BIBL_SRC_DEFAULT; p->latexout = 0; p->utf8out = 0; p->utf8bom = 0; p->xmlout = 0; p->nosplittitle = 0; p->verbose = 0; p->addcount = 0; p->singlerefperfile = 0; p->headerf = adsout_writeheader; p->footerf = NULL; p->writef = adsout_write; } enum { TYPE_UNKNOWN = 0, TYPE_GENERIC, TYPE_ARTICLE, TYPE_MAGARTICLE, TYPE_BOOK, TYPE_INBOOK, TYPE_INPROCEEDINGS, TYPE_HEARING, TYPE_BILL, TYPE_CASE, TYPE_NEWSPAPER, TYPE_COMMUNICATION, TYPE_BROADCAST, TYPE_MANUSCRIPT, TYPE_REPORT, TYPE_THESIS, TYPE_MASTERSTHESIS, TYPE_PHDTHESIS, TYPE_DIPLOMATHESIS, TYPE_DOCTORALTHESIS, TYPE_HABILITATIONTHESIS, TYPE_PATENT, TYPE_PROGRAM }; typedef struct match_type { char *name; int type; } match_type; static int get_type( fields *info ) { match_type match_genres[] = { { "academic journal", TYPE_ARTICLE }, { "magazine", TYPE_MAGARTICLE }, { "conference publication", TYPE_INPROCEEDINGS }, { "hearing", TYPE_HEARING }, { "Ph.D. thesis", TYPE_PHDTHESIS }, { "Masters thesis", TYPE_MASTERSTHESIS }, { "Diploma thesis", TYPE_DIPLOMATHESIS }, { "Doctoral thesis", TYPE_DOCTORALTHESIS }, { "Habilitation thesis", TYPE_HABILITATIONTHESIS }, { "legislation", TYPE_BILL }, { "newspaper", TYPE_NEWSPAPER }, { "communication", TYPE_COMMUNICATION }, { "manuscript", TYPE_MANUSCRIPT }, { "report", TYPE_REPORT }, { "legal case and case notes", TYPE_CASE }, { "patent", TYPE_PATENT }, }; int nmatch_genres = sizeof( match_genres ) / sizeof( match_genres[0] ); char *tag, *data; int i, j, type = TYPE_UNKNOWN; for ( i=0; infields; ++i ) { tag = info->tag[i].data; if ( strcasecmp( tag, "GENRE" )!=0 && strcasecmp( tag, "NGENRE" )!=0 ) continue; data = info->data[i].data; for ( j=0; jlevel[i]==0 ) type = TYPE_BOOK; else type = TYPE_INBOOK; } else if ( !strcasecmp( data, "collection" ) ) { if ( info->level[i]==0 ) type = TYPE_BOOK; else type = TYPE_INBOOK; } if ( type!=TYPE_UNKNOWN ) fields_setused( info, i ); } } if ( type==TYPE_UNKNOWN ) { for ( i=0; infields; ++i ) { if ( strcasecmp( info->tag[i].data, "RESOURCE" ) ) continue; data = info->data[i].data; if ( !strcasecmp( data, "moving image" ) ) type = TYPE_BROADCAST; else if ( !strcasecmp( data, "software, multimedia" ) ) type = TYPE_PROGRAM; if ( type!=TYPE_UNKNOWN ) fields_setused( info, i ); } } /* default to generic */ if ( type==TYPE_UNKNOWN ) type = TYPE_GENERIC; return type; } static void output_title( FILE *fp, fields *info, char * full, char *sub, char *endtag, int level ) { int n1 = fields_find( info, full, level ); int n2 = fields_find( info, sub, level ); int sn = fields_find( info, "PAGESTART", -1 ); int en = fields_find( info, "PAGEEND", -1 ); int ar = fields_find( info, "ARTICLENUMBER", -1 ); if ( n1!=-1 ) { fprintf( fp, "%s %s", endtag, info->data[n1].data ); fields_setused( info, n1 ); if ( n2!=-1 ) { if ( info->data[n1].data[info->data[n1].len]!='?' ) fprintf( fp, ": " ); else fprintf( fp, " " ); fprintf( fp, "%s", info->data[n2].data ); fields_setused( info, n2 ); } n1 = fields_find( info, "VOLUME", -1 ); if ( n1!=-1 ) fprintf( fp, ", vol. %s", info->data[n1].data ); n1 = fields_find( info, "ISSUE", -1 ); if ( n1 == -1 ) n1 = fields_find( info, "NUMBER", -1 ); if ( n1!=-1 ) fprintf( fp, ", no. %s", info->data[n1].data ); if ( sn!=-1 ) { if ( en != -1) fprintf( fp, ", pp."); else fprintf( fp, ", p."); fprintf( fp, " %s", info->data[sn].data); } else if ( ar!=-1 ) { fprintf( fp, " p. %s", info->data[ar].data ); } if ( en!=-1 ) { fprintf( fp, "-%s", info->data[en].data ); } fprintf( fp, "\n" ); } } static void output_person( FILE *fp, char *p ) { int nseps = 0, nch; while ( *p ) { nch = 0; if ( nseps==1 ) fprintf( fp, "," ); if ( nseps ) fprintf( fp, " " ); while ( *p && *p!='|' ) { fprintf( fp, "%c", *p++ ); nch++; } if ( *p=='|' ) p++; if ( nseps!=0 && nch==1 ) fprintf( fp, "." ); nseps++; } } static void output_people( FILE *fp, fields *info, char *tag, char *entag, int level ) { int i, cnt=0; for ( i=0; infields; ++i ) { if ( level!=-1 && info->level[i]!=level ) continue; if ( !strcasecmp( info->tag[i].data, tag ) ) { if ( cnt ) fprintf( fp, "; " ); else fprintf( fp, "%s ", entag ); output_person( fp, info->data[i].data ); cnt++; } } if ( cnt ) fprintf( fp, "\n" ); } static void output_pages( FILE *fp, fields *info ) { int sn = fields_find( info, "PAGESTART", -1 ); int en = fields_find( info, "PAGEEND", -1 ); int ar = fields_find( info, "ARTICLENUMBER", -1 ); if ( sn!=-1 ) { fprintf( fp, "%%P %s\n", info->data[sn].data); } else if ( ar!=-1 ) { fprintf( fp, "%%P %s\n", info->data[ar].data ); } if ( en!=-1 ) { fprintf( fp, "%%L %s\n", info->data[en].data ); } } static int get_year( fields *info, int level ) { int year = fields_find( info, "YEAR", level ); if ( year==-1 ) year = fields_find( info, "PARTYEAR", level ); return year; } static int mont2mont( const char *m ) { static char *monNames[]= { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec" }; int i; if ( isdigit( m[0] ) ) return atoi( m ); else { for ( i=0; i<12; i++ ) { if ( !strncasecmp( m, monNames[i], 3 ) ) return i+1; } } return 0; } static int get_month( fields *info, int level ) { int n; n = fields_find( info, "MONTH", level ); if ( n==-1 ) n = fields_find( info, "PARTMONTH", level ); if ( n==-1 ) return 0; else return mont2mont( info->data[n].data ); } static void output_date( FILE *fp, fields *info, char *entag, int level ) { int year, month; year = get_year( info, level ); if ( year!=-1 ) { month = get_month( info, level ); fprintf( fp, "%s %02d/%s\n", entag, month, info->data[year].data ); } } #include "adsout_journals.c" static void output_4digit_value( char *pos, long long n ) { char buf[6]; n = n % 10000; /* truncate to 0->9999, will fit in buf[6] */ sprintf( buf, "%lld", n ); if ( n < 10 ) strncpy( pos+3, buf, 1 ); else if ( n < 100 ) strncpy( pos+2, buf, 2 ); else if ( n < 1000 ) strncpy( pos+1, buf, 3 ); else strncpy( pos, buf, 4 ); } static char get_firstinitial( fields *info ) { int n = fields_find( info, "AUTHOR", 0 ); if ( n==-1 ) n = fields_find( info, "AUTHOR", -1 ); if ( n!=-1 ) return info->data[n].data[0]; else return '\0'; } static int min( int a, int b ) { if ( a < b ) return a; else return b; } static int get_journalabbr( fields *info ) { char *jrnl; int ljrnl, ltmp, len, n, j; n = fields_find( info, "TITLE", LEVEL_HOST ); if ( n!=-1 ) { jrnl = info->data[n].data; ljrnl = strlen( jrnl ); for ( j=0; jdata[n].data ) ); /** JJJJ */ n = get_journalabbr( info ); if ( n!=-1 ) strncpy( out+4, journals[n], 5 ); /** VVVV */ n = fields_find( info, "VOLUME", -1 ); if ( n!=-1 ) output_4digit_value( out+9, atoi( info->data[n].data ) ); /** MPPPP */ n = fields_find( info, "PAGESTART", -1 ); if ( n==-1 ) n = fields_find( info, "ARTICLENUMBER", -1 ); if ( n!=-1 ) { page = atoll( info->data[n].data ); output_4digit_value( out+14, page ); if ( page>=10000 ) { ch = 'a' + (page/10000); out[13] = ch; } } /** A */ ch = toupper( get_firstinitial( info ) ); if ( ch!='\0' ) out[18] = ch; fprintf( fp, "%s %s\n", entag, out ); } static void output_easyall( FILE *fp, fields *info, char *tag, char *entag, int level ) { int i; for ( i=0; infields; ++i ) { if ( level!=-1 && info->level[i]!=level ) continue; if ( !strcmp( info->tag[i].data, tag ) ) fprintf( fp, "%s %s\n", entag, info->data[i].data ); } } static void output_easy( FILE *fp, fields *info, char *tag, char *entag, int level ) { int n = fields_find( info, tag, level ); if ( n!=-1 ) fprintf( fp, "%s %s\n", entag, info->data[n].data ); } static void output_keys( FILE *fp, fields *info, char *tag, char *entag, int level ) { int i, n, nkeys = 0; n = fields_find( info, tag, level ); if ( n!=-1 ) { fprintf( fp, "%s ", entag ); for ( i=0; infields; ++i ) { if ( level!=-1 && info->level[i]!=level ) continue; if ( !strcmp( info->tag[i].data, tag ) ) { if ( nkeys ) fprintf( fp, ", " ); fprintf( fp, "%s", info->data[i].data ); nkeys++; } } fprintf( fp, "\n" ); } } void adsout_write( fields *info, FILE *fp, param *p, unsigned long refnum ) { int type; fields_clearused( info ); type = get_type( info ); output_people( fp, info, "AUTHOR", "%A", 0 ); output_easyall( fp, info, "AUTHOR:ASIS", "%A", 0 ); output_easyall( fp, info, "AUTHOR:CORP", "%A", 0 ); output_people( fp, info, "EDITOR", "%E", -1 ); output_easyall( fp, info, "EDITOR:ASIS", "%E", -1 ); output_easyall( fp, info, "EDITOR:CORP", "%E", -1 ); output_easy( fp, info, "TITLE", "%T", -1 ); if ( type==TYPE_ARTICLE || type==TYPE_MAGARTICLE ) output_title( fp, info, "TITLE", "SUBTITLE", "%J", 1 ); output_date( fp, info, "%D", -1 ); output_easy( fp, info, "VOLUME", "%V", -1 ); output_easy( fp, info, "ISSUE", "%N", -1 ); output_easy( fp, info, "NUMBER", "%N", -1 ); output_easy( fp, info, "LANGUAGE", "%M", -1 ); output_easyall( fp, info, "NOTES", "%X", -1 ); output_easy( fp, info, "ABSTRACT", "%B", -1 ); output_keys( fp, info, "KEYWORD", "%K", -1 ); output_easyall( fp, info, "URL", "%U", -1 ); output_easyall( fp, info, "FILEATTACH", "%U", -1 ); output_pages( fp, info ); output_easyall( fp, info, "DOI", "%Y", -1 ); fprintf( fp, "%%W PHY\n%%G AUTHOR\n" ); output_Rtag( fp, info, "%R", type ); fprintf( fp, "\n" ); fflush( fp ); } void adsout_writeheader( FILE *outptr, param *p ) { if ( p->utf8bom ) utf8_writebom( outptr ); } bibutils_4.12/lib/wordin.c0000644000076400007640000003644411445506334016013 0ustar cdputnamcdputnam/* * wordin.c * * Copyright (c) Chris Putnam 2010 * * Program and source code released under the GPL * */ #include #include #include "is_ws.h" #include "newstr.h" #include "newstr_conv.h" #include "fields.h" #include "xml.h" #include "xml_encoding.h" #include "wordin.h" void wordin_initparams( param *p, const char *progname ) { p->readformat = BIBL_WORDIN; p->charsetin = BIBL_CHARSET_DEFAULT; p->charsetin_src = BIBL_SRC_DEFAULT; p->latexin = 0; p->xmlin = 1; p->utf8in = 1; p->nosplittitle = 0; p->verbose = 0; p->addcount = 0; p->output_raw = BIBL_RAW_WITHMAKEREFID | BIBL_RAW_WITHCHARCONVERT; p->readf = wordin_readf; p->processf = wordin_processf; p->cleanf = NULL; p->typef = NULL; /* p->convertf = wordin_convertf;*/ p->convertf = NULL; p->all = NULL; p->nall = 0; list_init( &(p->asis) ); list_init( &(p->corps) ); if ( !progname ) p->progname = NULL; else p->progname = strdup( progname ); } static char * wordin_findstartwrapper( char *buf, int *ntype ) { char *startptr = xml_findstart( buf, "b:Source" ); return startptr; } static char * wordin_findendwrapper( char *buf, int ntype ) { char *endptr = xml_findend( buf, "b:Source" ); return endptr; } int wordin_readf( FILE *fp, char *buf, int bufsize, int *bufpos, newstr *line, newstr *reference, int *fcharset ) { newstr tmp; char *startptr = NULL, *endptr; int haveref = 0, inref = 0, file_charset = CHARSET_UNKNOWN, m, type = 1; newstr_init( &tmp ); while ( !haveref && newstr_fget( fp, buf, bufsize, bufpos, line ) ) { if ( line->data ) { m = xml_getencoding( line ); if ( m!=CHARSET_UNKNOWN ) file_charset = m; } if ( line->data ) { startptr = wordin_findstartwrapper( line->data, &type ); } if ( startptr || inref ) { if ( inref ) newstr_strcat( &tmp, line->data ); else { newstr_strcat( &tmp, startptr ); inref = 1; } endptr = wordin_findendwrapper( tmp.data, type ); if ( endptr ) { newstr_segcpy( reference, tmp.data, endptr ); haveref = 1; fprintf(stderr,"reference='%s'\n",reference->data); } } } newstr_free( &tmp ); *fcharset = file_charset; return haveref; } static inline int xml_hasdata( xml *node ) { if ( node && node->value && node->value->data ) return 1; return 0; } static inline char * xml_data( xml *node ) { return node->value->data; } static inline int xml_tagwithdata( xml *node, char *tag ) { if ( !xml_hasdata( node ) ) return 0; return xml_tagexact( node, tag ); } typedef struct xml_convert { char *in; /* The input tag */ char *a, *aval; /* The attribute="attribute_value" pair, if nec. */ char *out; /* The output tag */ int level; } xml_convert; #if 0 static int medin_doconvert( xml *node, fields *info, xml_convert *c, int nc ) { int i, found = 0; char *d; if ( !xml_hasdata( node ) ) return 0; d = xml_data( node ); for ( i=0; iMechanism and..... */ static void medin_articletitle( xml *node, fields *info ) { if ( xml_hasdata( node ) ) fields_add( info, "TITLE", xml_data( node ), 0 ); } /* 2003 Jan-Feb */ static void medin_medlinedate( fields *info, char *string, int level ) { newstr tmp; char *p, *q; newstr_init( &tmp ); /* extract year */ p = string; q = skip_notws( string ); /* p = q = string;*/ /* while ( *q && !is_ws(*q) ) q++;*/ newstr_segcpy( &tmp, p, q ); fields_add( info, "PARTYEAR", tmp.data, level ); q = skip_ws( q ); /* extract month */ if ( q ) { p = q; newstr_empty( &tmp ); q = skip_notws( q ); /* while ( *q && !is_ws(*q) ) q++;*/ newstr_segcpy( &tmp, p, q ); newstr_findreplace( &tmp, "-", "/" ); fields_add( info, "PARTMONTH", tmp.data, level ); q = skip_ws( q ); } /* extract day */ if ( q ) { p = q; newstr_empty( &tmp ); q = skip_notws( q ); /* while ( *q && !is_ws(*q) ) q++;*/ newstr_segcpy( &tmp, p, q ); fields_add( info, "PARTDAY", tmp.data, level ); } newstr_free( &tmp ); } /* * 0027-8424 * * 100 * 21 * * 2003 * Oct * 14 * * * * * or.... * * * 0735-0414 * * 38 * 1 * * 2003 Jan-Feb * * * Alcohol and alcoholism (Oxford, Oxfordshire) * Alcohol Alcohol. * */ static void medin_journal1( xml *node, fields *info ) { xml_convert c[] = { { "ISSN", NULL, NULL, "ISSN", 1 }, { "Volume", NULL, NULL, "VOLUME", 1 }, { "Issue", NULL, NULL, "ISSUE", 1 }, { "Year", NULL, NULL, "PARTYEAR", 1 }, { "Month", NULL, NULL, "PARTMONTH", 1 }, { "Day", NULL, NULL, "PARTDAY", 1 }, { "Language", NULL, NULL, "LANGUAGE", 1 }, }; int nc = sizeof( c ) / sizeof( c[0] );; if ( xml_hasdata( node ) && !medin_doconvert( node, info, c, nc ) ) { if ( xml_tagexact( node, "MedlineDate" ) ) medin_medlinedate( info, xml_data( node ), 1 ); } if ( node->down ) medin_journal1( node->down, info ); if ( node->next ) medin_journal1( node->next, info ); } /* * 12111-6 * */ static void medin_pagination( xml *node, fields *info ) { newstr sp, ep; char *p; int i; if ( xml_tagexact( node, "MedlinePgn" ) && node->value ) { newstrs_init( &sp, &ep, NULL ); p = xml_data( node ); while ( *p && *p!='-' ) newstr_addchar( &sp, *p++ ); if ( *p=='-' ) p++; while ( *p ) newstr_addchar( &ep, *p++ ); if ( sp.len ) fields_add( info, "PAGESTART", sp.data, 1 ); if ( ep.len ) { if ( sp.len > ep.len ) { for ( i=sp.len-ep.len; idown ) medin_pagination( node->down, info ); if ( node->next ) medin_pagination( node->next, info ); } /* * ljwejrelr * */ static void medin_abstract( xml *node, fields *info ) { if ( xml_tagwithdata( node, "AbstractText" ) ) fields_add( info, "ABSTRACT", xml_data( node ), 0 ); else if ( node->next ) medin_abstract( node->next, info ); } /* * * Barondeau * David P * ( or David P ) * DP * * */ static void medin_author( xml *node, newstr *name ) { char *p; if ( xml_tagexact( node, "LastName" ) ) { if ( name->len ) { newstr_prepend( name, "|" ); newstr_prepend( name, xml_data( node ) ); } else newstr_strcat( name, xml_data( node ) ); } else if ( xml_tagexact( node, "ForeName" ) || xml_tagexact( node, "FirstName" ) ) { p = xml_data( node ); while ( p && *p ) { if ( name->len ) newstr_addchar( name, '|' ); while ( *p && *p==' ' ) p++; while ( *p && *p!=' ' ) newstr_addchar( name, *p++ ); } } else if ( xml_tagexact( node, "Initials" ) && !strchr( name->data, '|' )) { p = xml_data( node ); while ( p && *p ) { if ( name->len ) newstr_addchar( name, '|' ); if ( !is_ws(*p) ) newstr_addchar( name, *p++ ); } } if ( node->down ) medin_author( node->down, name ); if ( node->next ) medin_author( node->next, name ); } static void medin_authorlist( xml *node, fields *info ) { newstr name; newstr_init( &name ); node = node->down; while ( node ) { if ( xml_tagexact( node, "Author" ) && node->down ) { medin_author( node->down, &name ); if ( name.len ) fields_add(info,"AUTHOR",name.data,0); newstr_empty( &name ); } node = node->next; } newstr_free( &name ); } /* * Journal Article * */ /* * United States * Proc Natl Acad Sci U S A * 7507876 * */ static void medin_journal2( xml *node, fields *info ) { if ( xml_tagwithdata( node, "MedlineTA" ) ) fields_add( info, "TITLE", xml_data( node ), 1 ); if ( node->down ) medin_journal2( node->down, info ); if ( node->next ) medin_journal2( node->next, info ); } /* Biophysics Crystallography, X-Ray */ static void medin_meshheading( xml *node, fields *info ) { if ( xml_tagwithdata( node, "DescriptorName" ) ) fields_add( info, "KEYWORD", xml_data( node ), 0 ); if ( node->next ) medin_meshheading( node->next, info ); } static void medin_meshheadinglist( xml *node, fields *info ) { if ( xml_tagexact( node, "MeshHeading" ) && node->down ) medin_meshheading( node->down, info ); if ( node->next ) medin_meshheadinglist( node->next, info ); } /* * .... * * 14523232 * 10.1073/pnas.2133463100 * 2133463100 * 22922082 * * * * I think "pii" is "Publisher Item Identifier" */ static void medin_pubmeddata( xml *node, fields *info ) { xml_convert c[] = { { "ArticleId", "IdType", "doi", "DOI", 0 }, { "ArticleId", "IdType", "pubmed", "PMID", 0 }, { "ArticleId", "IdType", "medline", "MEDLINE", 0 }, { "ArticleId", "IdType", "pii", "PII", 0 }, }; int nc = sizeof( c ) / sizeof( c[0] ); medin_doconvert( node, info, c, nc ); if ( node->next ) medin_pubmeddata( node->next, info ); if ( node->down ) medin_pubmeddata( node->down, info ); } static void medin_article( xml *node, fields *info ) { if ( xml_tagexact( node, "Journal" ) ) medin_journal1( node, info ); else if ( xml_tagexact( node, "ArticleTitle" ) ) medin_articletitle( node, info ); else if ( xml_tagexact( node, "Pagination" ) && node->down ) medin_pagination( node->down, info ); else if ( xml_tagexact( node, "Abstract" ) && node->down ) medin_abstract( node->down, info ); else if ( xml_tagexact( node, "AuthorList" ) ) medin_authorlist( node, info ); if ( node->next ) medin_article( node->next, info ); } static void medin_medlinecitation( xml *node, fields *info ) { if ( node->down ) { if ( xml_tagexact( node, "Article" ) ) medin_article( node->down, info ); else if ( xml_tagexact( node, "MedlineJournalInfo" ) ) medin_journal2( node->down, info ); else if ( xml_tagexact( node, "MeshHeadingList" ) ) medin_meshheadinglist( node->down, info ); } if ( node->next ) medin_medlinecitation( node->next, info ); } static void medin_pubmedarticle( xml *node, fields *info ) { if ( node->down ) { if ( xml_tagexact( node, "MedlineCitation" ) ) medin_medlinecitation( node->down, info ); else if ( xml_tagexact( node, "PubmedData" ) ) medin_pubmeddata( node->down, info ); } if ( node->next ) medin_pubmedarticle( node->next, info ); } #endif static void wordin_person( xml *node, fields *info, char *type ) { xml *last, *first; newstr name; newstr_init( &name ); last = node; while ( last && !xml_tagexact( last, "b:Last" ) ) last = last->next; if ( last ) newstr_strcpy( &name, last->value->data ); first = node; while ( first ) { if ( xml_tagexact( first, "b:First" ) ) { if ( name.len ) newstr_addchar( &name, '|' ); newstr_strcat( &name, first->value->data ); } first = first->next; } fields_add( info, type, name.data, 0 ); newstr_free( &name ); } static void wordin_people( xml *node, fields *info, char *type ) { if ( xml_tagexact( node, "b:Author" ) && node->down ) { wordin_people( node->down, info, type ); } else if ( xml_tagexact( node, "b:NameList" ) && node->down ) { wordin_people( node->down, info, type ); } else if ( xml_tagexact( node, "b:Person" ) ) { if ( node->down ) wordin_person( node->down, info, type ); if ( node->next ) wordin_people( node->next, info, type ); } } static void wordin_pages( xml *node, fields *info ) { newstr sp, ep; char *p; int i; newstrs_init( &sp, &ep, NULL ); /* newstr_init( &sp ); newstr_init( &ep ); */ p = xml_data( node ); while ( *p && *p!='-' ) newstr_addchar( &sp, *p++ ); if ( *p=='-' ) p++; while ( *p ) newstr_addchar( &ep, *p++ ); if ( sp.len ) fields_add( info, "PAGESTART", sp.data, 1 ); if ( ep.len ) { if ( sp.len > ep.len ) { for ( i=sp.len-ep.len; idown ) { wordin_people( node->down, info, "AUTHOR" ); } else if ( xml_tagexact( node, "b:Editor" ) && node->down ) { wordin_people( node->down, info, "EDITOR" ); } } if ( node->next ) wordin_reference( node->next, info ); } static void wordin_assembleref( xml *node, fields *info ) { if ( xml_tagexact( node, "b:Source" ) ) { if ( node->down ) wordin_reference( node->down, info ); } else if ( node->tag->len==0 && node->down ) { wordin_assembleref( node->down, info ); } } int wordin_processf( fields *wordin, char *data, char *filename, long nref ) { xml top; xml_init( &top ); xml_tree( data, &top ); wordin_assembleref( &top, wordin ); xml_free( &top ); return 1; } void wordin_convertf( fields *wordin, fields *info, int reftype, int verbose, variants *all, int nall ) { int i; for ( i=0; infields; ++i ) fields_add( info, wordin->tag[i].data, wordin->data[i].data, wordin->level[i] ); } bibutils_4.12/lib/modsout.c0000644000076400007640000006204711477200607016200 0ustar cdputnamcdputnam/* * modsout.c * * Copyright (c) Chris Putnam 2003-2010 * * Source code released under the GPL * */ #include #include #include #include "is_ws.h" #include "newstr.h" #include "newstr_conv.h" #include "fields.h" #include "utf8.h" #include "modsout.h" #include "modstypes.h" #include "marc.h" void modsout_initparams( param *p, const char *progname ) { p->writeformat = BIBL_MODSOUT; p->format_opts = 0; p->charsetout = BIBL_CHARSET_UNICODE; p->charsetout_src = BIBL_SRC_DEFAULT; p->latexout = 0; p->utf8out = 1; p->utf8bom = 1; p->xmlout = 1; p->nosplittitle = 0; p->verbose = 0; p->addcount = 0; p->singlerefperfile = 0; p->headerf = modsout_writeheader; p->footerf = modsout_writefooter; p->writef = modsout_write; } static int increment_level( int level, int amt ) { if ( level > -1 ) return level+amt; else return level-amt; } static void output_tab0( FILE *outptr, int level ) { int i; level = abs( level ); for ( i=0; i<=level; ++i ) fprintf( outptr, " " ); } static void output_tab1( FILE *outptr, int level, char *tag ) { output_tab0( outptr, level ); fprintf( outptr, "%s", tag ); } static void output_tab2_attrib( FILE *outptr, int level, char *tag, char *data, char *attrib, char *type, int cr ) { output_tab0( outptr, level ); fprintf( outptr, "<%s", tag ); if ( attrib && type ) fprintf( outptr, " %s=\"%s\"", attrib, type ); fprintf( outptr, ">%s", data, tag ); if ( cr ) fprintf( outptr, "\n" ); } static void output_tab4( FILE *outptr, int level, char *tag, char *aname, char *avalue, char *data, int cr ) { output_tab0( outptr, level ); fprintf( outptr, "<%s %s=\"%s\">%s", tag,aname,avalue,data,tag); if ( cr ) fprintf( outptr, "\n" ); } static void output_fill2( FILE *outptr, int level, char *tag, fields *info, int n, int cr ) { if ( n!=-1 ) { output_tab2_attrib( outptr, level, tag, info->data[n].data, NULL, NULL, cr ); fields_setused( info, n ); } } static void output_fill4( FILE *outptr, int level, char *tag, char *aname, char *avalue, fields *info, int n, int cr ) { if ( n!=-1 ) { output_tab4( outptr, level, tag, aname, avalue, info->data[n].data, cr ); fields_setused( info, n ); } } /* * Find the positions of all convert.internal tags and store the * locations in convert.code. * * Return number of the tags found */ static int find_alltags( fields *info, convert *parts, int nparts, int level ) { int i, n=0; for ( i=0; i\n" ); output_fill2( outptr, increment_level(level,1), "title", info, ttl, 1); output_fill2( outptr, increment_level(level,1), "subTitle", info, subttl, 1 ); if ( ttl==-1 && subttl==-1 ) output_tab1( outptr, increment_level(level,1), "\n" ); output_tab1( outptr, level, "</titleInfo>\n" ); /* output shorttitle if it's different from normal title */ if ( shrttl!=-1 ) { if ( ttl==-1 || subttl!=-1 || strcmp(info->data[ttl].data,info->data[shrttl].data) ) { output_tab1( outptr, level, "<titleInfo type=\"abbreviated\">\n" ); output_fill2( outptr, level+1, "title", info, shrttl,1); output_tab1( outptr, level, "</titleInfo>\n" ); } fields_setused( info, shrttl ); } } static void output_personalstart( FILE *outptr, int level ) { int j; for ( j=0; j<=level; ++j ) fprintf( outptr, " " ); fprintf( outptr, "<name type=\"personal\">\n" ); } static void output_name( FILE *outptr, char *p, int level ) { newstr family, part; int n=0; newstrs_init( &family, &part, NULL ); while ( *p && *p!='|' ) newstr_addchar( &family, *p++ ); if ( *p=='|' ) p++; while ( *p ) { while ( *p && *p!='|' ) newstr_addchar( &part, *p++ ); /* truncate periods from "A. B. Jones" names */ if ( part.len ) { if ( part.len==2 && part.data[1]=='.' ) { part.len=1; part.data[1]='\0'; } if ( n==0 ) output_personalstart( outptr, level ); output_tab4( outptr, increment_level(level,1), "namePart", "type", "given", part.data, 1 ); n++; } if ( *p=='|' ) { p++; newstr_empty( &part ); } } if ( family.len ) { if ( n==0 ) output_personalstart( outptr, level ); output_tab4( outptr, increment_level(level,1), "namePart", "type", "family", family.data, 1 ); } newstrs_free( &part, &family, NULL ); } #define NO_AUTHORITY (0) #define MARC_AUTHORITY (1) static void output_names( fields *info, FILE *outptr, int level ) { convert names[] = { { "author", "AUTHOR", MARC_AUTHORITY }, { "writer", "WRITER", MARC_AUTHORITY }, { "artist", "ARTIST", MARC_AUTHORITY }, { "cartographer", "CARTOGRAPHER", MARC_AUTHORITY }, { "commentator", "COMMENTATOR", NO_AUTHORITY }, { "degree grantor","DEGREEGRANTOR", MARC_AUTHORITY }, { "director", "DIRECTOR", MARC_AUTHORITY }, { "editor", "EDITOR", MARC_AUTHORITY }, { "inventor", "INVENTOR", MARC_AUTHORITY }, { "organizer of meeting","ORGANIZER", MARC_AUTHORITY }, { "patent holder", "ASSIGNEE", MARC_AUTHORITY }, { "performer", "PERFORMER", MARC_AUTHORITY }, { "recipient", "RECIPIENT", MARC_AUTHORITY }, { "redactor", "REDACTOR", NO_AUTHORITY }, { "reporter", "REPORTER", NO_AUTHORITY }, { "translator", "TRANSLATOR", MARC_AUTHORITY }, { "event", "EVENT", NO_AUTHORITY }, { "author", "2ND_AUTHOR", MARC_AUTHORITY }, { "author", "3RD_AUTHOR", MARC_AUTHORITY }, { "author", "SUB_AUTHOR", MARC_AUTHORITY }, { "author", "COMMITTEE", MARC_AUTHORITY }, { "author", "COURT", MARC_AUTHORITY }, { "author", "LEGISLATIVEBODY", MARC_AUTHORITY } }; int i, n, ntypes = sizeof( names ) / sizeof( convert ); newstr role; int f_asis, f_corp, f_conf; newstr_init( &role ); for ( n=0; n<ntypes; ++n ) { for ( i=0; i<info->nfields; ++i ) { if ( info->level[i]!=level ) continue; f_asis = f_corp = f_conf = 0; newstr_strcpy( &role, info->tag[i].data ); if ( newstr_findreplace( &role, ":ASIS", "" )) f_asis=1; if ( newstr_findreplace( &role, ":CORP", "" )) f_corp=1; if ( newstr_findreplace( &role, ":CONF", "" )) f_conf=1; if ( strcasecmp( role.data, names[n].internal ) ) continue; if ( f_asis ) { output_tab0( outptr, level ); fprintf( outptr, "<name>\n" ); output_fill2( outptr, increment_level(level,1), "namePart", info, i, 1 ); } else if ( f_corp ) { output_tab0( outptr, level ); fprintf( outptr, "<name type=\"corporate\">\n" ); output_fill2( outptr, increment_level(level,1), "namePart", info, i, 1 ); } else if ( f_conf ) { output_tab0( outptr, level ); fprintf( outptr, "<name type=\"conference\">\n" ); output_fill2( outptr, increment_level(level,1), "namePart", info, i, 1 ); } else { output_name(outptr, info->data[i].data, level); } output_tab1( outptr, increment_level(level,1), "<role>\n" ); output_tab1( outptr, increment_level(level,2), "<roleTerm" ); if ( names[n].code & MARC_AUTHORITY ) fprintf( outptr, " authority=\"marcrelator\""); fprintf( outptr, " type=\"text\">"); fprintf( outptr, "%s", names[n].mods ); fprintf( outptr, "</roleTerm>\n"); output_tab1( outptr, increment_level(level,1), "</role>\n" ); output_tab1( outptr, level, "</name>\n" ); fields_setused( info, i ); } } newstr_free( &role ); } static int output_finddateissued( fields *info, int level, int pos[3] ) { char *src_names[] = { "YEAR", "MONTH", "DAY", "DATE" }; char *alt_names[] = { "PARTYEAR", "PARTMONTH", "PARTDAY", "PARTDATE" }; int i, found = -1, ntypes = 4; for ( i=0; i<ntypes; ++i ) { pos[i] = fields_find( info, src_names[i], level ); if ( pos[i]!=-1 ) found = pos[i]; } /* for LEVEL_MAIN, do what it takes to find a date */ if ( found==-1 && level==0 ) { for ( i=0; i<ntypes; ++i ) { pos[i] = fields_find( info, src_names[i], -1 ); if ( pos[i]!=-1 ) found = pos[i]; } } if ( found==-1 && level==0 ) { for ( i=0; i<ntypes; ++i ) { pos[i] = fields_find( info, alt_names[i], -1 ); if ( pos[i]!=-1 ) found = pos[i]; } } return found; } static void output_datepieces( fields *info, FILE *outptr, int pos[4] ) { int nprinted = 0, i; for ( i=0; i<3 && pos[i]!=-1; ++i ) { if ( nprinted>0 ) fprintf( outptr, "-" ); if ( i>0 && info->data[pos[i]].len==1 ) fprintf( outptr, "0" ); /*zero pad Jan,Feb,etc*/ fprintf( outptr,"%s",info->data[pos[i]].data ); nprinted++; fields_setused( info, pos[i] ); } } static void output_dateall( fields *info, FILE *outptr, int pos ) { fprintf( outptr, "%s", info->data[pos].data ); fields_setused( info, pos ); } static void output_dateissued( fields *info, FILE *outptr, int level, int pos[4] ) { output_tab1( outptr, increment_level(level,1), "<dateIssued>" ); if ( pos[0]!=-1 || pos[1]!=-1 || pos[2]!=-1 ) { output_datepieces( info, outptr, pos ); } else { output_dateall( info, outptr, pos[3] ); } fprintf( outptr, "</dateIssued>\n" ); } static void output_origin( fields *info, FILE *outptr, int level ) { convert origin[] = { { "issuance", "ISSUANCE", 0 }, { "publisher", "PUBLISHER", 0 }, { "place", "ADDRESS", 1 }, { "edition", "EDITION", 0 }, { "dateCaptured", "URLDATE", 0 } }; int n, ntypes = sizeof( origin ) / sizeof ( convert ); int found, datefound, pos[5], date[4]; /* find all information to be outputted */ found = -1; for ( n=0; n<ntypes; ++n ) { pos[n] = fields_find( info, origin[n].internal, level ); if ( pos[n]!=-1 ) found = pos[n]; } datefound = output_finddateissued( info, level, date ); if ( found==-1 && datefound==-1 ) return; output_tab1( outptr, level, "<originInfo>\n" ); output_fill2( outptr, increment_level(level,1), "issuance", info, pos[0], 1 ); if ( datefound!=-1 ) output_dateissued( info, outptr, level, date ); for ( n=1; n<ntypes; n++ ) { if ( pos[n]==-1 ) continue; output_tab0( outptr, increment_level(level,1) ); fprintf( outptr, "<%s", origin[n].mods ); fprintf( outptr, ">" ); if ( origin[n].code ) { fprintf( outptr, "\n" ); output_fill4( outptr, increment_level(level,2), "placeTerm", "type", "text", info, pos[n], 1 ); output_tab0( outptr, increment_level(level,1) ); } else { fprintf( outptr, "%s", info->data[pos[n]].data ); fields_setused( info, pos[n] ); } fprintf( outptr, "</%s>\n", origin[n].mods ); } output_tab1( outptr, level, "</originInfo>\n" ); } static void output_language( fields *info, FILE *outptr, int level ) { int n = fields_find( info, "LANGUAGE", level ); output_fill2( outptr, level, "language", info, n, 1 ); } static void output_description( fields *info, FILE *outptr, int level ) { int n = fields_find( info, "DESCRIPTION", level ); if (n != -1) { output_tab1( outptr, level, "<physicalDescription>\n" ); output_fill2( outptr, increment_level(level,1), "note", info, n, 1 ); output_tab1( outptr, level, "</physicalDescription>\n" ); } } static void output_toc( fields *info, FILE *outptr, int level ) { int n = fields_find( info, "CONTENTS", level ); output_fill2( outptr, level, "tableOfContents", info, n, 1 ); } /* detail output * * for example: * * <detail type="volume"><number>xxx</number></detail */ static void mods_output_detail( fields *info, FILE *outptr, int item, char *item_name, int level ) { if ( item==-1 ) return; output_tab0( outptr, increment_level( level, 1 ) ); fprintf( outptr, "<detail type=\"%s\"><number>%s</number></detail>\n", item_name, info->data[item].data ); fields_setused( info, item ); } /* extents output * * <extent unit="page"> * <start>xxx</start> * <end>xxx</end> * </extent> */ static void mods_output_extents( fields *info, FILE *outptr, int start, int end, int total, char *extype, int level ) { output_tab0( outptr, increment_level(level,1) ); fprintf( outptr, "<extent unit=\"%s\">\n", extype); output_fill2( outptr, increment_level(level,2), "start", info, start, 1 ); output_fill2( outptr, increment_level(level,2), "end", info, end, 1 ); output_fill2( outptr, increment_level(level,2), "total", info, total, 1 ); output_tab1 ( outptr, increment_level(level,1), "</extent>\n" ); } static void try_output_partheader( FILE *outptr, int wrote_header, int level ) { if ( !wrote_header ) output_tab1( outptr, level, "<part>\n" ); } static void try_output_partfooter( FILE *outptr, int wrote_header, int level ) { if ( wrote_header ) output_tab1( outptr, level, "</part>\n" ); } /* part date output * * <date>xxxx-xx-xx</date> * */ static int output_partdate( fields *info, FILE *outptr, int level, int wrote_header ) { convert parts[3] = { { "", "PARTYEAR", -1 }, { "", "PARTMONTH", -1 }, { "", "PARTDAY", -1 }, }; int nparts = sizeof(parts)/sizeof(parts[0]); if ( !find_alltags( info, parts, nparts, level ) ) return 0; try_output_partheader( outptr, wrote_header, level ); output_tab1( outptr, increment_level(level,1), "<date>" ); if ( parts[0].code!=-1 ) { fprintf( outptr, "%s", info->data[ parts[0].code ].data); fields_setused( info, parts[0].code ); } else fprintf( outptr, "XXXX" ); if ( parts[1].code!=-1 ) { fprintf( outptr, "-%s", info->data[parts[1].code].data ); fields_setused( info, parts[1].code ); } if ( parts[2].code!=-1 ) { if ( parts[1].code!=-1 ) fprintf( outptr, "-" ); else fprintf( outptr, "-XX-" ); fprintf( outptr, "%s", info->data[parts[2].code].data ); fields_setused( info, parts[2].code ); } fprintf( outptr,"</date>\n"); return 1; } static int output_partpages( fields *info, FILE *outptr, int level, int wrote_header ) { convert parts[3] = { { "", "PAGESTART", -1 }, { "", "PAGEEND", -1 }, { "", "TOTALPAGES", -1 } }; int nparts = sizeof(parts)/sizeof(parts[0]); if ( !find_alltags( info, parts, nparts, level ) ) return 0; try_output_partheader( outptr, wrote_header, level ); /* If PAGESTART or PAGEEND are undefined */ if ( parts[0].code==-1 || parts[1].code==-1 ) { if ( parts[0].code!=-1 ) mods_output_detail( info, outptr, parts[0].code, "page", level ); if ( parts[1].code!=-1 ) mods_output_detail( info, outptr, parts[1].code, "page", level ); if ( parts[2].code!=-1 ) mods_output_extents( info, outptr, -1, -1, parts[2].code, "page", level ); } /* If both PAGESTART and PAGEEND are defined */ else { mods_output_extents( info, outptr, parts[0].code, parts[1].code, parts[2].code, "page", level ); } return 1; } static int output_partelement( fields *info, FILE *outptr, int level, int wrote_header ) { convert parts[] = { { "volume", "VOLUME", -1 }, { "section", "SECTION", -1 }, { "issue", "ISSUE", -1 }, { "number", "NUMBER", -1 }, { "publiclawnumber", "PUBLICLAWNUMBER", -1 }, { "session", "SESSION", -1 }, { "articlenumber", "ARTICLENUMBER", -1 }, { "part", "PART", -1 }, { "chapter", "CHAPTER", -1 } }; int i, nparts = sizeof( parts ) / sizeof( convert ), n; n = fields_find( info, "NUMVOLUMES", level ); if ( !find_alltags( info, parts, nparts, level ) && n==-1 ) return 0; try_output_partheader( outptr, wrote_header, level ); for ( i=0; i<nparts; ++i ) { if ( parts[i].code==-1 ) continue; mods_output_detail( info, outptr, parts[i].code, parts[i].mods, level ); } if ( n!=-1 ) { output_tab1( outptr, level, "<extent unit=\"volumes\">\n" ); output_fill2( outptr, increment_level(level,1), "total", info, n, 1 ); output_tab1( outptr, level, "</extent>\n" ); } return 1; } static void output_part( fields *info, FILE *outptr, int level ) { int wrote_hdr; wrote_hdr = output_partdate( info, outptr, level, 0 ); wrote_hdr += output_partelement( info, outptr, level, wrote_hdr ); wrote_hdr += output_partpages( info, outptr, level, wrote_hdr ); try_output_partfooter( outptr, wrote_hdr, level ); } static void output_genre( fields *info, FILE *outptr, int level ) { int i, ismarc; for ( i=0; i<info->nfields; ++i ) { if ( info->level[i]!=level ) continue; if ( strcasecmp( info->tag[i].data, "GENRE" ) ) continue; if ( marc_findgenre( info->data[i].data )!=-1 ) ismarc = 1; else ismarc = 0; output_tab1( outptr, level, "<genre" ); if ( ismarc ) fprintf( outptr, " authority=\"marcgt\"" ); fprintf( outptr, ">%s</genre>\n", info->data[i].data ); fields_setused( info, i ); } } static void output_typeresource( fields *info, FILE *outptr, int level ) { int n, ismarc = 0; n = fields_find( info, "RESOURCE", level ); if ( n!=-1 ) { if ( marc_findresource( info->data[n].data )!=-1 ) ismarc = 1; if ( !ismarc ) { fprintf( stderr, "Illegal typeofResource = '%s'\n", info->data[n].data ); } else { output_fill2( outptr, level, "typeOfResource", info, n, 1 ); } fields_setused( info, n ); } } static void output_type( fields *info, FILE *outptr, int level ) { int n = fields_find( info, "INTERNAL_TYPE", 0 ); if ( n!=-1 ) fields_setused( info, n ); output_typeresource( info, outptr, level ); output_genre( info, outptr, level ); } static void output_abs( fields *info, FILE *outptr, int level ) { int i; int nabs = fields_find( info, "ABSTRACT", level ); output_fill2( outptr, level, "abstract", info, nabs, 1 ); for ( i=0; i<info->nfields; ++i ) { if ( info->level[i]!=level ) continue; if ( !strcasecmp( info->tag[i].data, "NOTES" ) ) output_fill2( outptr, level, "note", info, i, 1 ); if ( !strcasecmp( info->tag[i].data, "ANNOTE" ) ) output_fill2( outptr, level, "bibtex-annote", info, i, 1 ); } } static void output_timescited( fields *info, FILE *outptr, int level ) { int n = fields_find( info, "TIMESCITED", level ); if ( n!=-1 ) { output_tab0( outptr, level ); fprintf( outptr, "<note>Times Cited: %s</note>\n", info->data[n].data ); fields_setused( info, n ); } } static void output_indexkey( fields *info, FILE *outptr, int level ) { int n = fields_find( info, "BIBKEY", level ); if ( n!=-1 ) { output_tab0( outptr, level ); fprintf( outptr, "<note>Key: %s</note>\n", info->data[n].data ); fields_setused( info, n ); } } static void output_key( fields *info, FILE *outptr, int level ) { int i; for ( i=0; i<info->nfields; ++i ) { if ( info->level[i]!=level ) continue; if ( !strcasecmp( info->tag[i].data, "KEYWORD" ) ) { output_tab1( outptr, level, "<subject>\n" ); output_fill2( outptr, increment_level(level,1), "topic", info, i, 1 ); output_tab1( outptr, level, "</subject>\n" ); } } } static void output_sn( fields *info, FILE *outptr, int level ) { convert sn_types[] = { { "isbn", "ISBN", 0 }, { "lccn", "LCCN", 0 }, { "issn", "ISSN", 0 }, { "citekey", "REFNUM", 0 }, { "doi", "DOI", 0 }, { "eid", "EID", 0 }, { "eprint", "EPRINT", 0 }, { "eprinttype","EPRINTTYPE",0 }, { "pubmed", "PMID", 0 }, { "medline", "MEDLINE", 0 }, { "pii", "PII", 0 }, { "arXiv", "ARXIV", 0 }, { "isi", "ISIREFNUM", 0 }, { "accessnum", "ACCESSNUM", 0 }, { "jstor", "JSTOR", 0 }, }; int n, ntypes = sizeof( sn_types ) / sizeof( sn_types[0] ); int found, i; found = fields_find ( info, "CALLNUMBER", level ); output_fill2( outptr, level, "classification", info, found, 1 ); for ( n=0; n<ntypes; ++n ) { found = fields_find( info, sn_types[n].internal, level ); if ( found==-1 ) continue; output_tab0( outptr, level ); fprintf( outptr, "<identifier type=\"%s\">%s</identifier>\n", sn_types[n].mods, info->data[found].data ); fields_setused( info, found ); } for ( i=0; i<info->nfields;++i ) { if ( info->level[i]!=level ) continue; if ( !strcasecmp( info->tag[i].data, "SERIALNUMBER" ) ) { output_tab0( outptr, level ); fprintf( outptr, "<identifier type=\"%s\">%s</identifier>\n", "serial number", info->data[i].data ); fields_setused( info, i ); } } } static void output_url( fields *info, FILE *outptr, int level ) { int location = fields_find( info, "LOCATION", level ); int url = fields_find( info, "URL", level ); int fileattach = fields_find( info, "FILEATTACH", level ); int pdflink = fields_find( info, "PDFLINK", level ); int i; if ( url==-1 && location==-1 && pdflink==-1 && fileattach==-1) return; output_tab1( outptr, level, "<location>\n" ); for ( i=0; i<info->nfields; ++i ) { if ( info->level[i]!=level ) continue; if ( !strcasecmp( info->tag[i].data, "URL" ) ) { output_fill2( outptr, increment_level(level,1), "url", info, i, 1 ); } else if ( !strcasecmp( info->tag[i].data, "PDFLINK" ) ) { output_fill2( outptr, increment_level(level,1), "url", /*"urlType", "pdf",*/ info, i, 1 ); } else if ( !strcasecmp( info->tag[i].data, "FILEATTACH" ) ){ output_tab0( outptr, increment_level(level,1) ); fprintf( outptr, "<url displayLabel=\"Electronic full text\" access=\"raw object\">" ); fprintf( outptr, " %s</url>\n", info->data[i].data ); fields_setused( info, i ); } } if ( location!=-1 ) output_fill2( outptr, increment_level(level,1), "physicalLocation", info, location, 1 ); output_tab1( outptr, level, "</location>\n" ); } /* refnum should start with a non-number and not include spaces */ static void output_refnum( fields *info, int n, FILE *outptr ) { char *p = info->data[n].data; if ( p && ((*p>='0' && *p<='9') || *p=='-' || *p=='_' )) fprintf( outptr, "ref" ); while ( p && *p ) { if ( !is_ws(*p) ) fprintf( outptr, "%c", *p ); /* if ( (*p>='A' && *p<='Z') || (*p>='a' && *p<='z') || (*p>='0' && *p<='9') || (*p=='-') || (*p==' (*p=='_') ) fprintf( outptr, "%c", *p );*/ p++; } } static void output_head( fields *info, FILE *outptr, int dropkey, unsigned long numrefs ) { int n; fprintf( outptr, "<mods"); if ( !dropkey ) { n = fields_find( info, "REFNUM", 0 ); if ( n!=-1 ) { fprintf( outptr, " ID=\""); output_refnum( info, n, outptr ); fprintf( outptr, "\""); } } fprintf( outptr, ">\n" ); } static int original_items( fields *info, int level ) { int i, targetlevel; if ( level < 0 ) return 0; targetlevel = -( level + 2 ); for ( i=0; i<info->nfields; ++i ) if ( info->level[i]==targetlevel ) return targetlevel; return 0; } static void output_citeparts( fields *info, FILE *outptr, int level, int max ) { int orig_level; output_title( info, outptr, level ); output_names( info, outptr, level); output_origin( info, outptr, level ); output_type( info, outptr, level ); output_language( info, outptr, level ); output_description( info, outptr, level ); if ( level>=0 && level < max ) { output_tab0( outptr, level ); fprintf( outptr, "<relatedItem type=\"host\">\n" ); output_citeparts(info, outptr, increment_level(level,1), max ); output_tab0( outptr, level ); fprintf( outptr, "</relatedItem>\n"); } /* Look for original item things */ orig_level = original_items( info, level ); if ( orig_level ) { output_tab0( outptr, level ); fprintf( outptr, "<relatedItem type=\"original\">\n" ); output_citeparts( info, outptr, orig_level, max ); output_tab0( outptr, level ); fprintf( outptr, "</relatedItem>\n" ); } output_abs( info, outptr, level ); output_timescited( info, outptr, level ); output_indexkey( info, outptr, level ); output_toc( info, outptr, level ); output_key( info, outptr, level ); output_sn( info, outptr, level ); output_url( info, outptr, level ); /* as of MODS 3.1, <part> tags can be in the main items */ /*if ( level>0 ) */ output_part( info, outptr, level ); } static void modsout_report_unused_tag( fields *info, int i, param *p, unsigned long numrefs ) { if ( p->progname ) fprintf( stderr, "%s: ", p->progname ); fprintf( stderr, "Ref %lu unused tag: '%s' value: '%s' level: %d\n", numrefs+1, info->tag[i].data, info->data[i].data, info->level[i] ); } static void modsout_report_unused_tags( fields *info, param *p, unsigned long numrefs ) { int i; for ( i=0; i<info->nfields; ++i ) { if ( info->used[i] ) continue; modsout_report_unused_tag( info, i, p, numrefs ); } } void modsout_write( fields *info, FILE *outptr, param *p, unsigned long numrefs ) { int max, dropkey; max = fields_maxlevel( info ); dropkey = ( p->format_opts & MODSOUT_DROPKEY ); output_head( info, outptr, dropkey, numrefs ); output_citeparts( info, outptr, 0, max ); modsout_report_unused_tags( info, p, numrefs ); fprintf( outptr, "</mods>\n" ); fflush( outptr ); } void modsout_writeheader( FILE *outptr, param *p ) { if ( p->utf8bom ) utf8_writebom( outptr ); fprintf(outptr,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); fprintf(outptr,"<modsCollection xmlns=\"http://www.loc.gov/mods/v3\">\n"); } void modsout_writefooter( FILE *outptr ) { fprintf(outptr,"</modsCollection>\n"); fflush( outptr ); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bibutils_4.12/lib/reftypes.h������������������������������������������������������������������������0000644�0000764�0000764�00000001707�11444072056�016347� 0����������������������������������������������������������������������������������������������������ustar �cdputnam������������������������cdputnam���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * reftypes.h * * Copyright (c) Chris Putnam 2003-2009 * * Source code released under the GPL * */ #ifndef REFTYPES_H #define REFTYPES_H #define SIMPLE (0) #define TYPE (1) #define PERSON (2) #define DATE (3) #define PAGES (4) #define SERIALNO (5) #define TITLE (6) #define ALWAYS (7) #define NOTES (8) #define DOI (9) #define HOWPUBLISHED (10) #define BIBTEX_URL (11) #define BIBTEX_SENTE (12) #define BIBTEX_FILE (13) #define BIBTEX_GENRE (14) #define BIBTEX_EPRINT (15) #define ISI_KEYWORD (16) typedef struct { char *oldstr; char *newstr; int processingtype; int level; } lookups; typedef struct { char type[25]; lookups *tags; int ntags; } variants; extern int get_reftype( char *q, long refnum, char *progname, variants *all, int nall, char *tag ); extern int process_findoldtag( char *oldtag, int reftype, variants all[], int nall ); #endif ���������������������������������������������������������bibutils_4.12/lib/endtypes.c������������������������������������������������������������������������0000644�0000764�0000764�00000157352�11444072056�016344� 0����������������������������������������������������������������������������������������������������ustar �cdputnam������������������������cdputnam���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * endtypes.c * * Copyright (c) Chris Putnam 2003-2010 * * Program and source code released under the GPL * */ #include <stdio.h> #include <string.h> #include "is_ws.h" #include "fields.h" #include "reftypes.h" /* if no specific type can be identified */ static lookups generic[] = { { "%0", "INTERNAL_TYPE", TYPE, LEVEL_MAIN }, { "%A", "AUTHOR", PERSON, LEVEL_MAIN }, { "%H", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE, LEVEL_MAIN }, { "%T", "TITLE" , TITLE, LEVEL_MAIN }, { "%J", "TITLE", TITLE, LEVEL_HOST }, /* for refer formats */ { "%E", "2ND_AUTHOR",PERSON, LEVEL_MAIN }, { "%B", "2ND_TITLE", SIMPLE, LEVEL_MAIN }, { "%C", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "%I", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "%V", "VOLUME" , SIMPLE, LEVEL_MAIN }, { "%6", "NUMVOLUMES",SIMPLE, LEVEL_HOST }, { "%N", "NUMBER", SIMPLE, LEVEL_MAIN }, { "%P", "PAGES", PAGES, LEVEL_MAIN }, { "%&", "SECTION", SIMPLE, LEVEL_MAIN }, { "%Y", "3RD_AUTHOR", PERSON, LEVEL_MAIN }, { "%S", "3RD_TITLE", SIMPLE, LEVEL_MAIN }, { "%7", "EDITION", SIMPLE, LEVEL_MAIN }, { "%8", "MONTH", DATE, LEVEL_MAIN }, { "%9", "GENRE", SIMPLE, LEVEL_MAIN }, { "%?", "SUB_AUTHOR", PERSON, LEVEL_MAIN }, /* subsidiary-authors */ { "%!", "SHORTTITLE", TITLE, LEVEL_MAIN }, { "%@", "SERIALNUMBER", SERIALNO, LEVEL_MAIN }, { "%(", "TITLE", SIMPLE, LEVEL_ORIG }, /* original pub */ { "%)", "REPRINTEDITION",SIMPLE,LEVEL_MAIN }, { "%*", "REVIEWEDITEM", SIMPLE, LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%L", "CALLNUMBER", SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", NOTES, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%Z", "NOTES", SIMPLE, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%+", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN } }; static lookups journalarticle[] = { { "%0", "INTERNAL_TYPE", TYPE, LEVEL_MAIN }, { "%A", "AUTHOR", PERSON, LEVEL_MAIN }, { "%H", "TRANSLATOR", PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE",SIMPLE, LEVEL_MAIN }, { "%D", "PARTYEAR", SIMPLE, LEVEL_MAIN }, { "%T", "TITLE" , TITLE, LEVEL_MAIN }, { "%J", "TITLE", TITLE, LEVEL_HOST }, /* journal title */ { "%B", "TITLE", TITLE, LEVEL_HOST }, /* journal title */ { "%C", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "%V", "VOLUME" , SIMPLE, LEVEL_MAIN }, { "%N", "ISSUE", SIMPLE, LEVEL_MAIN }, { "%P", "PAGES", PAGES, LEVEL_MAIN }, { "%I", "PUBLISHER", SIMPLE, LEVEL_HOST }, { "%8", "PARTMONTH", DATE, LEVEL_MAIN }, { "%9", "GENRE", SIMPLE, LEVEL_MAIN }, { "%!", "SHORTTITLE", TITLE, LEVEL_MAIN }, { "%@", "SERIALNUMBER", SERIALNO, LEVEL_HOST }, { "%(", "TITLE", SIMPLE, LEVEL_ORIG }, /* original pub */ { "%)", "REPRINTEDITION",SIMPLE, LEVEL_MAIN }, { "%*", "REVIEWEDITEM", SIMPLE, LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%L", "CALLNUMBER", SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", NOTES, LEVEL_MAIN }, { "%Z", "NOTES", NOTES, LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%+", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "ISSUANCE|continuing", ALWAYS, LEVEL_HOST }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|periodical", ALWAYS, LEVEL_HOST }, { " ", "GENRE|academic journal", ALWAYS, LEVEL_HOST } }; static lookups magazinearticle[] = { { "%0", "INTERNAL_TYPE", TYPE, LEVEL_MAIN }, { "%A", "AUTHOR", PERSON, LEVEL_MAIN }, { "%H", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%D", "PARTYEAR", SIMPLE, LEVEL_MAIN }, { "%T", "TITLE", TITLE, LEVEL_MAIN }, { "%J", "TITLE", TITLE, LEVEL_HOST }, /* magazine name */ { "%B", "TITLE", TITLE, LEVEL_HOST }, /* magazine name */ { "%C", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "%V", "VOLUME", SIMPLE, LEVEL_MAIN }, { "%N", "ISSUE", SIMPLE, LEVEL_MAIN }, { "%P", "PAGES", PAGES, LEVEL_MAIN }, { "%I", "PUBLISHER", SIMPLE, LEVEL_HOST }, { "%8", "PARTMONTH", DATE, LEVEL_MAIN }, { "%!", "SHORTTITLE",TITLE, LEVEL_MAIN }, { "%@", "SERIALNUMBER", SERIALNO,LEVEL_HOST }, { "%(", "TITLE", SIMPLE, LEVEL_ORIG }, /* original pub */ { "%)", "REPRINTEDITION",SIMPLE,LEVEL_MAIN }, { "%*", "REVIEWEDITEM",SIMPLE,LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%L", "CALLNUMBER",SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", SIMPLE, LEVEL_MAIN }, { "%Z", "NOTES", SIMPLE, LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%+", "AUTHORADDRESS",SIMPLE,LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "ISSUANCE|continuing", ALWAYS, LEVEL_HOST }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|periodical", ALWAYS, LEVEL_HOST }, { " ", "GENRE|magazine", ALWAYS, LEVEL_HOST } }; static lookups newspaperarticle[] = { { "%0", "INTERNAL_TYPE", TYPE, LEVEL_MAIN }, { "%A", "REPORTER", PERSON, LEVEL_MAIN }, { "%H", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%D", "PARTYEAR", SIMPLE, LEVEL_MAIN }, { "%T", "TITLE" , TITLE, LEVEL_MAIN }, { "%J", "TITLE", TITLE, LEVEL_HOST }, /* newspaper name */ { "%B", "TITLE", TITLE, LEVEL_HOST }, /* newspaper name */ { "%V", "VOLUME" , SIMPLE, LEVEL_MAIN }, { "%C", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "%N", "ISSUE", SIMPLE, LEVEL_MAIN }, { "%P", "PAGES", PAGES, LEVEL_MAIN }, { "%7", "EDITION", SIMPLE, LEVEL_MAIN }, { "%8", "PARTMONTH", DATE, LEVEL_MAIN }, { "%!", "SHORTTITLE",TITLE, LEVEL_MAIN }, { "%@", "SERIALNUMBER", SERIALNO, LEVEL_MAIN }, { "%(", "TITLE", SIMPLE, LEVEL_ORIG }, /* original pub */ { "%)", "REPRINTEDITION",SIMPLE, LEVEL_MAIN }, { "%*", "REVIEWEDITEM",SIMPLE,LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%L", "CALLNUMBER",SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", SIMPLE, LEVEL_MAIN }, { "%Z", "NOTES", SIMPLE, LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%+", "AUTHORADDRESS",SIMPLE,LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "ISSUANCE|continuing", ALWAYS, LEVEL_HOST }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|newspaper", ALWAYS, LEVEL_HOST } }; static lookups book[] = { { "%0", "INTERNAL_TYPE", TYPE, LEVEL_MAIN }, { "%A", "AUTHOR", PERSON, LEVEL_MAIN }, { "%H", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE, LEVEL_MAIN }, { "%T", "TITLE" , TITLE, LEVEL_MAIN }, { "%E", "AUTHOR", PERSON, LEVEL_HOST }, /* SERIES_AUTHOR */ { "%B", "TITLE", TITLE, LEVEL_HOST }, /* SERIES_TITLE */ { "%S", "TITLE", TITLE, LEVEL_SERIES }, { "%C", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "%I", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "%V", "VOLUME" , SIMPLE, LEVEL_MAIN }, { "%N", "NUMBER", SIMPLE, LEVEL_MAIN }, { "%6", "NUMVOLUMES",SIMPLE, LEVEL_MAIN }, { "%P", "TOTALPAGES", SIMPLE,LEVEL_MAIN }, { "%7", "EDITION", SIMPLE, LEVEL_MAIN }, { "%?", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%!", "SHORTTITLE",TITLE, LEVEL_MAIN }, { "%@", "SERIALNUMBER", SERIALNO, LEVEL_MAIN }, { "%(", "TITLE", SIMPLE, LEVEL_ORIG }, /* original pub */ { "%)", "REPRINTEDITION",SIMPLE,LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%L", "CALLNUMBER",SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", NOTES, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%Z", "NOTES", SIMPLE, LEVEL_MAIN }, { "%+", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "GENRE|book", ALWAYS, LEVEL_MAIN }, { " ", "ISSUANCE|monographic", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN } }; static lookups booksection[] = { { "%0", "INTERNAL_TYPE", TYPE, LEVEL_MAIN }, { "%A", "AUTHOR", PERSON, LEVEL_MAIN }, { "%H", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE, LEVEL_HOST }, { "%T", "TITLE" , TITLE, LEVEL_MAIN }, { "%E", "EDITOR", PERSON, LEVEL_HOST }, /* editor for book */ { "%B", "TITLE", TITLE, LEVEL_HOST }, /* book title */ { "%C", "ADDRESS", SIMPLE, LEVEL_HOST }, { "%I", "PUBLISHER", SIMPLE, LEVEL_HOST }, { "%N", "NUMBER", SIMPLE, LEVEL_HOST }, { "%V", "VOLUME" , SIMPLE, LEVEL_MAIN }, { "%6", "NUMVOLUMES",SIMPLE, LEVEL_HOST }, { "%P", "PAGES", PAGES, LEVEL_MAIN }, { "%Y", "EDITOR", PERSON, LEVEL_SERIES }, { "%S", "TITLE", TITLE, LEVEL_SERIES }, { "%7", "EDITION", SIMPLE, LEVEL_HOST }, { "%?", "TRANSLATOR",PERSON, LEVEL_HOST }, { "%!", "SHORTTITLE",TITLE, LEVEL_MAIN }, { "%@", "SERIALNUMBER", SERIALNO, LEVEL_HOST }, { "%(", "TITLE", SIMPLE, LEVEL_ORIG }, /* original pub */ { "%)", "REPRINTEDITION",SIMPLE,LEVEL_HOST }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%L", "CALLNUMBER",SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", NOTES, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%Z", "NOTES", SIMPLE, LEVEL_MAIN }, { "%+", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "GENRE|book", ALWAYS, LEVEL_HOST }, { " ", "ISSUANCE|monographic", ALWAYS, LEVEL_HOST }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN } }; static lookups editedbook[] = { { "%0", "INTERNAL_TYPE", TYPE, LEVEL_MAIN }, { "%A", "EDITOR", PERSON, LEVEL_MAIN }, { "%H", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE, LEVEL_MAIN }, { "%T", "TITLE" , TITLE, LEVEL_MAIN }, { "%E", "EDITOR", PERSON, LEVEL_HOST }, /* SERIES_EDITOR */ { "%B", "TITLE", TITLE, LEVEL_HOST }, /* SERIES_TITLE */ { "%C", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "%I", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "%N", "NUMBER", SIMPLE, LEVEL_MAIN }, { "%V", "VOLUME" , SIMPLE, LEVEL_MAIN }, { "%6", "NUMVOLUMES",SIMPLE, LEVEL_HOST }, { "%P", "TOTALPAGES", SIMPLE,LEVEL_MAIN }, { "%7", "EDITION", SIMPLE, LEVEL_MAIN }, { "%?", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%!", "SHORTTITLE",TITLE, LEVEL_MAIN }, { "%@", "SERIALNUMBER", SERIALNO, LEVEL_MAIN }, { "%(", "TITLE", SIMPLE, LEVEL_ORIG }, /* original pub */ { "%)", "REPRINTEDITION",SIMPLE,LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%L", "CALLNUMBER",SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", NOTES, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%Z", "NOTES", NOTES, LEVEL_MAIN }, { "%+", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "GENRE|book", ALWAYS, LEVEL_MAIN }, { " ", "ISSUANCE|monographic", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN } }; static lookups manuscript[] = { { "%0", "INTERNAL_TYPE", TYPE, LEVEL_MAIN }, { "%A", "AUTHOR", PERSON, LEVEL_MAIN }, { "%H", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE, LEVEL_MAIN }, { "%T", "TITLE", TITLE, LEVEL_MAIN }, { "%B", "TITLE", TITLE, LEVEL_HOST }, /* COLLECTION_TITLE */ { "%C", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "%N", "NUMBER", SIMPLE, LEVEL_MAIN }, { "%P", "PAGES", PAGES, LEVEL_MAIN }, { "%8", "MONTH", DATE, LEVEL_MAIN }, { "%9", "GENRE", SIMPLE, LEVEL_MAIN }, { "%!", "SHORTTITLE",TITLE, LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%L", "CALLNUMBER",SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", NOTES, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%Z", "NOTES", NOTES, LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%+", "AUTHORADDRESS",SIMPLE,LEVEL_MAIN}, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|manuscript", ALWAYS, LEVEL_MAIN } }; static lookups communication[] = { { "%0", "INTERNAL_TYPE", TYPE, LEVEL_MAIN }, { "%A", "AUTHOR", PERSON, LEVEL_MAIN }, { "%H", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE, LEVEL_MAIN }, { "%T", "TITLE" , TITLE, LEVEL_MAIN }, { "%E", "RECIPIENT", PERSON, LEVEL_MAIN }, { "%C", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "%V", "VOLUME", SIMPLE, LEVEL_MAIN }, { "%I", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "%8", "MONTH", DATE, LEVEL_MAIN }, { "%9", "GENRE", SIMPLE, LEVEL_MAIN }, { "%!", "SHORTTITLE",TITLE, LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%L", "CALLNUMBER",SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", NOTES, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%Z", "NOTES", NOTES, LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%+", "AUTHORADDRESS",SIMPLE,LEVEL_MAIN}, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "GENRE|communication", ALWAYS, LEVEL_MAIN} }; static lookups proceedings[] = { { "%0", "INTERNAL_TYPE", TYPE, LEVEL_MAIN }, { "%A", "AUTHOR", PERSON, LEVEL_MAIN }, { "%H", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE, LEVEL_HOST }, { "%T", "TITLE" , TITLE, LEVEL_MAIN }, { "%E", "EDITOR", PERSON, LEVEL_MAIN }, { "%B", "TITLE", SIMPLE, LEVEL_HOST }, { "%C", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "%I", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "%V", "VOLUME" , SIMPLE, LEVEL_MAIN }, { "%6", "NUMVOLUMES",SIMPLE, LEVEL_HOST }, { "%N", "NUMBER", SIMPLE, LEVEL_MAIN }, { "%P", "PAGES", PAGES, LEVEL_MAIN }, { "%Y", "EDITOR", PERSON, LEVEL_HOST }, /* SERIES_EDITOR */ { "%S", "TITLE", TITLE, LEVEL_HOST+1 }, /* SERIES_TITLE */ { "%7", "EDITION", SIMPLE, LEVEL_HOST }, { "%8", "MONTH", DATE, LEVEL_MAIN }, { "%!", "SHORTTITLE",TITLE, LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%L", "CALLNUMBER",SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", NOTES, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%Z", "NOTES", NOTES, LEVEL_MAIN }, { "%+", "AUTHORADDRESS",SIMPLE,LEVEL_MAIN}, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|conference publication", ALWAYS, LEVEL_MAIN } }; static lookups conferencepaper[] = { { "%0", "INTERNAL_TYPE", TYPE, LEVEL_MAIN }, { "%A", "AUTHOR", PERSON, LEVEL_MAIN }, { "%H", "TRANSLATOR", PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE",SIMPLE, LEVEL_MAIN }, { "%D", "PARTYEAR", SIMPLE, LEVEL_MAIN }, { "%T", "TITLE" , TITLE, LEVEL_MAIN }, { "%J", "TITLE", TITLE, LEVEL_HOST }, /* journal title */ { "%B", "TITLE", TITLE, LEVEL_HOST }, /* journal title */ { "%C", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "%V", "VOLUME" , SIMPLE, LEVEL_MAIN }, { "%N", "ISSUE", SIMPLE, LEVEL_MAIN }, { "%P", "PAGES", PAGES, LEVEL_MAIN }, { "%I", "PUBLISHER", SIMPLE, LEVEL_HOST }, { "%8", "PARTMONTH", DATE, LEVEL_MAIN }, { "%9", "GENRE", SIMPLE, LEVEL_MAIN }, { "%!", "SHORTTITLE", TITLE, LEVEL_MAIN }, { "%@", "SERIALNUMBER", SERIALNO, LEVEL_HOST }, { "%(", "TITLE", SIMPLE, LEVEL_ORIG }, /* original pub */ { "%)", "REPRINTEDITION",SIMPLE, LEVEL_MAIN }, { "%*", "REVIEWEDITEM", SIMPLE, LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%L", "CALLNUMBER", SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", NOTES, LEVEL_MAIN }, { "%Z", "NOTES", NOTES, LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%+", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|conference publication", ALWAYS, LEVEL_HOST } }; static lookups thesis[] = { { "%0", "INTERNAL_TYPE", TYPE, LEVEL_MAIN }, { "%A", "AUTHOR", PERSON, LEVEL_MAIN }, { "%H", "TRANSLATOR", PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE, LEVEL_MAIN }, { "%T", "TITLE" , TITLE, LEVEL_MAIN }, { "%B", "ACADEMIC_DEPARTMENT", SIMPLE, LEVEL_MAIN }, { "%C", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "%I", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "%V", "VOLUME", SIMPLE, LEVEL_MAIN }, { "%P", "NUMPAGES", PAGES, LEVEL_MAIN }, { "%9", "GENRE", SIMPLE, LEVEL_MAIN }, /* thesis type */ { "%8", "MONTH", DATE, LEVEL_MAIN }, { "%!", "SHORTTITLE", TITLE, LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%L", "CALLNUMBER", SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", NOTES, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%Z", "NOTES", NOTES, LEVEL_MAIN }, { "%+", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "RESOURCE|text",ALWAYS, LEVEL_MAIN }, { " ", "GENRE|thesis", ALWAYS, LEVEL_MAIN } }; static lookups program[] = { { "%0", "INTERNAL_TYPE", TYPE, LEVEL_MAIN }, { "%A", "AUTHOR", PERSON , LEVEL_MAIN }, { "%H", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE , LEVEL_MAIN }, { "%T", "TITLE" , TITLE , LEVEL_MAIN }, { "%C", "ADDRESS", SIMPLE , LEVEL_MAIN }, { "%I", "PUBLISHER", SIMPLE , LEVEL_MAIN }, { "%7", "VERSION", SIMPLE , LEVEL_MAIN }, { "%9", "GENRE", SIMPLE , LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE , LEVEL_MAIN }, { "%L", "CALLNUMBER",SIMPLE , LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE , LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE , LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE , LEVEL_MAIN }, { "%O", "NOTES", SIMPLE , LEVEL_MAIN }, { "%U", "URL", SIMPLE , LEVEL_MAIN }, { "%Z", "NOTES", SIMPLE , LEVEL_MAIN }, { "%1", "COMPUTER", SIMPLE , LEVEL_MAIN }, { "%2", "CUSTOM2", SIMPLE , LEVEL_MAIN }, { "%3", "CUSTOM3", SIMPLE , LEVEL_MAIN }, { "%4", "CUSTOM4", SIMPLE , LEVEL_MAIN }, { "%#", "CUSTOM5", SIMPLE , LEVEL_MAIN }, { "%$", "CUSTOM6", SIMPLE , LEVEL_MAIN }, { "%!", "SHORTTITLE",TITLE , LEVEL_MAIN }, { "%+", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "RESOURCE|software, multimedia", ALWAYS, LEVEL_MAIN } }; static lookups audiovisual[] = { { "%0", "INTERNAL_TYPE", TYPE , LEVEL_MAIN }, { "%A", "WRITER", PERSON , LEVEL_MAIN }, { "%H", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE , LEVEL_MAIN }, { "%T", "TITLE" , TITLE , LEVEL_MAIN }, { "%B", "TITLE", TITLE , LEVEL_HOST }, /* COLLECTION_TITLE */ { "%C", "ADDRESS", SIMPLE , LEVEL_MAIN }, { "%I", "PUBLISHER", SIMPLE , LEVEL_MAIN }, { "%V", "EXTENTOFWORK", SIMPLE , LEVEL_MAIN }, { "%N", "NUMBER", SIMPLE , LEVEL_MAIN }, { "%8", "MONTH", DATE , LEVEL_MAIN }, { "%9", "GENRE", SIMPLE , LEVEL_MAIN }, { "%?", "PERFORMER", PERSON , LEVEL_MAIN }, { "%!", "SHORTTITLE",TITLE , LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE , LEVEL_MAIN }, { "%L", "CALLNUMBER",SIMPLE , LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE , LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE , LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE , LEVEL_MAIN }, { "%O", "NOTES", NOTES, LEVEL_MAIN }, { "%U", "URL", SIMPLE , LEVEL_MAIN }, { "%Z", "NOTES", NOTES, LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%+", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "RESOURCE|mixed material", ALWAYS, LEVEL_MAIN } }; static lookups broadcast[] = { { "%0", "INTERNAL_TYPE", TYPE, LEVEL_MAIN }, { "%A", "AUTHOR", PERSON, LEVEL_MAIN }, { "%H", "TRANSLATOR", PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE, LEVEL_MAIN }, { "%T", "TITLE" , TITLE, LEVEL_MAIN }, { "%E", "DIRECTOR", PERSON, LEVEL_MAIN }, { "%B", "TITLE", TITLE, LEVEL_HOST }, /* SERIES_TITLE */ { "%C", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "%I", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "%Y", "PRODUCER", PERSON, LEVEL_MAIN }, { "%8", "MONTH", DATE, LEVEL_MAIN }, { "%9", "GENRE", SIMPLE, LEVEL_MAIN }, { "%!", "SHORTTITLE", TITLE, LEVEL_MAIN }, { "%@", "SERIALNUMBER", SERIALNO, LEVEL_MAIN }, { "%?", "PERFORMER", PERSON, LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%L", "CALLNUMBER", SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", NOTES, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%Z", "NOTES", SIMPLE, LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%+", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "RESOURCE|moving image", ALWAYS, LEVEL_MAIN } }; static lookups electronic[] = { { "%0", "INTERNAL_TYPE", TYPE , LEVEL_MAIN }, { "%A", "AUTHOR", PERSON , LEVEL_MAIN }, { "%H", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE , LEVEL_MAIN }, { "%T", "TITLE" , TITLE , LEVEL_MAIN }, { "%C", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "%I", "PUBLISHER", SIMPLE , LEVEL_MAIN }, { "%V", "ACCESS_YEAR", SIMPLE , LEVEL_MAIN }, { "%N", "ACCESS_DATE", DATE , LEVEL_MAIN }, { "%7", "EDITION", SIMPLE, LEVEL_MAIN }, { "%8", "UPDATE_DATE", DATE, LEVEL_MAIN }, { "%9", "GENRE", SIMPLE, LEVEL_MAIN }, { "%!", "SHORTTITLE",TITLE, LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", NOTES, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%V", "VOLUME", SIMPLE, LEVEL_MAIN }, { "%Z", "NOTES", NOTES, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%+", "AUTHORADDRESS",SIMPLE , LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "RESOURCE|software, multimedia", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|electronic", ALWAYS, LEVEL_MAIN }, }; static lookups webpage[] = { { "%0", "INTERNAL_TYPE", TYPE , LEVEL_MAIN }, { "%A", "AUTHOR", PERSON , LEVEL_MAIN }, { "%H", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE , LEVEL_MAIN }, { "%T", "TITLE" , TITLE , LEVEL_MAIN }, { "%C", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "%I", "PUBLISHER", SIMPLE , LEVEL_MAIN }, { "%V", "ACCESS_YEAR", SIMPLE , LEVEL_MAIN }, { "%N", "ACCESS_DATE", DATE , LEVEL_MAIN }, { "%7", "EDITION", SIMPLE, LEVEL_MAIN }, { "%8", "UPDATE_DATE", DATE, LEVEL_MAIN }, { "%9", "GENRE", SIMPLE, LEVEL_MAIN }, { "%!", "SHORTTITLE",TITLE, LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", NOTES, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%V", "VOLUME", SIMPLE, LEVEL_MAIN }, { "%Z", "NOTES", NOTES, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%+", "AUTHORADDRESS",SIMPLE , LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "RESOURCE|software, multimedia", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|web page", ALWAYS, LEVEL_MAIN }, }; static lookups artwork[] = { { "%0", "INTERNAL_TYPE", TYPE , LEVEL_MAIN }, { "%A", "ARTIST", PERSON , LEVEL_MAIN }, { "%H", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE , LEVEL_MAIN }, { "%T", "TITLE" , TITLE , LEVEL_MAIN }, { "%C", "ADDRESS", SIMPLE , LEVEL_MAIN }, { "%I", "PUBLISHER", SIMPLE , LEVEL_MAIN }, { "%8", "MONTH", DATE, LEVEL_MAIN }, { "%9", "GENRE", SIMPLE, LEVEL_MAIN }, { "%!", "SHORTTITLE", TITLE, LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%L", "CALLNUMBER", SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", NOTES, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%Z", "NOTES", NOTES, LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%+", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "GENRE|art original", ALWAYS, LEVEL_MAIN } }; static lookups report[] = { { "%0", "INTERNAL_TYPE", TYPE , LEVEL_MAIN }, { "%A", "AUTHOR", PERSON , LEVEL_MAIN }, { "%H", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE , LEVEL_MAIN }, { "%T", "TITLE" , TITLE , LEVEL_MAIN }, { "%C", "ADDRESS", SIMPLE , LEVEL_MAIN }, { "%I", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "%P", "PAGES", PAGES, LEVEL_MAIN }, { "%8", "MONTH", DATE, LEVEL_MAIN }, { "%9", "GENRE", SIMPLE, LEVEL_MAIN }, { "%N", "NUMBER", SIMPLE, LEVEL_MAIN }, { "%@", "SERIALNUMBER", SERIALNO, LEVEL_MAIN }, { "%!", "SHORTTITLE",TITLE, LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%L", "CALLNUMBER",SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", NOTES, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%Z", "NOTES", NOTES, LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%+", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|report", ALWAYS, LEVEL_MAIN } }; static lookups map[] = { { "%0", "INTERNAL_TYPE", TYPE , LEVEL_MAIN }, { "%A", "CARTOGRAPHER", PERSON , LEVEL_MAIN }, { "%H", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE , LEVEL_MAIN }, { "%T", "TITLE" , TITLE , LEVEL_MAIN }, { "%C", "ADDRESS", SIMPLE , LEVEL_MAIN }, { "%I", "PUBLISHER", SIMPLE , LEVEL_MAIN }, { "%7", "EDITION", SIMPLE , LEVEL_MAIN }, { "%9", "GENRE", SIMPLE , LEVEL_MAIN }, { "%!", "SHORTTITLE",TITLE , LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE , LEVEL_MAIN }, { "%L", "CALLNUMBER",SIMPLE , LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE , LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE , LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE , LEVEL_MAIN }, { "%O", "NOTES", SIMPLE , LEVEL_MAIN }, { "%U", "URL", SIMPLE , LEVEL_MAIN }, { "%Z", "NOTES", SIMPLE , LEVEL_MAIN }, { "%1", "SCALE", SIMPLE , LEVEL_MAIN }, { "%2", "CUSTOM2", SIMPLE , LEVEL_MAIN }, { "%3", "CUSTOM3", SIMPLE , LEVEL_MAIN }, { "%4", "CUSTOM4", SIMPLE , LEVEL_MAIN }, { "%#", "CUSTOM5", SIMPLE , LEVEL_MAIN }, { "%$", "CUSTOM6", SIMPLE , LEVEL_MAIN }, { "%+", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "RESOURCE|cartographic", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|map", ALWAYS, LEVEL_MAIN } }; static lookups patent[] = { { "%0", "INTERNAL_TYPE", TYPE, LEVEL_MAIN }, { "%A", "AUTHOR", PERSON, LEVEL_MAIN }, { "%H", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE, LEVEL_MAIN }, { "%T", "TITLE" , TITLE, LEVEL_MAIN }, { "%B", "PUBLISHED_SOURCE", SIMPLE, LEVEL_MAIN}, { "%C", "COUNTRY", SIMPLE, LEVEL_MAIN }, { "%I", "ASSIGNEE", SIMPLE, LEVEL_MAIN }, { "%V", "VOLUME", SIMPLE, LEVEL_MAIN }, { "%N", "ISSUE", SIMPLE, LEVEL_MAIN }, { "%P", "PAGES", SIMPLE, LEVEL_MAIN }, { "%@", "NUMBER", SIMPLE, LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%L", "CALLNUMBER",SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", SIMPLE, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%Z", "NOTES", SIMPLE, LEVEL_MAIN }, { "%1", "SCALE", SIMPLE, LEVEL_MAIN }, { "%2", "CUSTOM2", SIMPLE, LEVEL_MAIN }, { "%3", "CUSTOM3", SIMPLE, LEVEL_MAIN }, { "%4", "CUSTOM4", SIMPLE, LEVEL_MAIN }, { "%#", "CUSTOM5", SIMPLE, LEVEL_MAIN }, { "%$", "CUSTOM6", SIMPLE, LEVEL_MAIN }, { "%+", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|patent", ALWAYS, LEVEL_MAIN } }; static lookups hearing[] = { { "%0", "INTERNAL_TYPE", TYPE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE, LEVEL_MAIN }, { "%H", "TRANSLATOR", PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%T", "TITLE" , TITLE, LEVEL_MAIN }, { "%B", "COMMITTEE:CORP", SIMPLE, LEVEL_MAIN }, { "%C", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "%I", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "%6", "NUMVOLUMES", SIMPLE, LEVEL_MAIN }, { "%N", "NUMBER", SIMPLE, LEVEL_MAIN }, { "%P", "NUMPAGES", PAGES, LEVEL_MAIN }, { "%S", "LEGISLATIVEBODY:CORP", SIMPLE, LEVEL_MAIN }, { "%7", "SESSION", SIMPLE, LEVEL_MAIN }, { "%8", "MONTH", DATE, LEVEL_MAIN }, { "%!", "SHORTTITLE", TITLE, LEVEL_MAIN }, { "%(", "TITLE", SIMPLE, LEVEL_ORIG }, /* orig publication */ { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%L", "CALLNUMBER", SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", NOTES, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%Z", "NOTES", NOTES, LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%9", "GENRE", SIMPLE, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "GENRE|hearing", ALWAYS, LEVEL_MAIN } }; static lookups bill[] = { { "%0", "INTERNAL_TYPE", TYPE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE, LEVEL_MAIN }, { "%H", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%T", "TITLE" , TITLE, LEVEL_MAIN }, { "%B", "CODE", SIMPLE, LEVEL_MAIN }, { "%V", "CODEVOLUME",SIMPLE, LEVEL_MAIN }, { "%N", "BILLNUMBER",SIMPLE, LEVEL_MAIN }, { "%P", "CODEPAGES", SIMPLE, LEVEL_MAIN }, { "%&", "CODESECTION",SIMPLE, LEVEL_MAIN }, { "%S", "LEGISLATIVEBODY:CORP", SIMPLE, LEVEL_MAIN }, { "%7", "SESSION", SIMPLE, LEVEL_MAIN }, { "%8", "MONTH", DATE, LEVEL_MAIN }, { "%?", "SPONSOR", PERSON, LEVEL_MAIN }, { "%!", "SHORTTITLE",TITLE, LEVEL_MAIN }, { "%(", "TITLE", SIMPLE, LEVEL_ORIG }, /* original pub */ { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%L", "CALLNUMBER",SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", NOTES, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%Z", "NOTES", NOTES, LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|legislation", ALWAYS, LEVEL_MAIN } }; static lookups statute[] = { { "%0", "INTERNAL_TYPE", TYPE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE, LEVEL_MAIN }, { "%H", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%T", "TITLE" , TITLE, LEVEL_MAIN }, { "%B", "CODE", SIMPLE, LEVEL_MAIN }, { "%V", "CODENUMBER",SIMPLE, LEVEL_MAIN }, { "%N", "PUBLICLAWNUMBER", SIMPLE, LEVEL_MAIN }, { "%P", "PAGES", PAGES, LEVEL_MAIN }, { "%&", "SECTION", SIMPLE, LEVEL_MAIN }, { "%7", "SESSION", SIMPLE, LEVEL_MAIN }, { "%8", "MONTH", DATE, LEVEL_MAIN }, { "%!", "SHORTTITLE",TITLE, LEVEL_MAIN }, { "%(", "TITLE", SIMPLE, LEVEL_ORIG }, /* original pub */ { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%L", "CALLNUMBER",SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", NOTES, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%Z", "NOTES", NOTES, LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|legislation", ALWAYS, LEVEL_MAIN } }; static lookups lawcase[] = { { "%0", "INTERNAL_TYPE", TYPE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE, LEVEL_MAIN }, { "%H", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%T", "TITLE" , TITLE, LEVEL_MAIN }, { "%E", "REPORTER", TITLE, LEVEL_HOST }, /*Reporter is name of book*/ { "%B", "CODE", SIMPLE, LEVEL_MAIN }, { "%I", "COURT:CORP", SIMPLE, LEVEL_MAIN }, { "%V", "VOLUME", SIMPLE, LEVEL_MAIN }, { "%N", "PUBLICLAWNUMBER", SIMPLE, LEVEL_MAIN }, { "%P", "STARTPAGE", SIMPLE, LEVEL_MAIN }, { "%8", "MONTH", DATE, LEVEL_MAIN }, { "%?", "COUNSEL", PERSON, LEVEL_MAIN }, { "%!", "SHORTTITLE",TITLE, LEVEL_MAIN }, { "%(", "TITLE", SIMPLE, LEVEL_ORIG }, /* original pub */ { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%L", "CALLNUMBER",SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", NOTES, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%Z", "NOTES", NOTES, LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|legal case and case notes", ALWAYS, LEVEL_MAIN } }; static lookups chart[] = { { "%0", "INTERNAL_TYPE", TYPE, LEVEL_MAIN }, { "%A", "AUTHOR", PERSON, LEVEL_MAIN }, { "%H", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE, LEVEL_MAIN }, { "%T", "TITLE" , TITLE, LEVEL_MAIN }, { "%J", "TITLE", TITLE, LEVEL_HOST }, /* for refer formats */ { "%E", "2ND_AUTHOR",PERSON, LEVEL_MAIN }, { "%B", "2ND_TITLE", SIMPLE, LEVEL_MAIN }, { "%C", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "%I", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "%V", "VOLUME" , SIMPLE, LEVEL_MAIN }, { "%6", "NUMVOLUMES",SIMPLE, LEVEL_HOST }, { "%N", "NUMBER", SIMPLE, LEVEL_MAIN }, { "%P", "PAGES", PAGES, LEVEL_MAIN }, { "%&", "SECTION", SIMPLE, LEVEL_MAIN }, { "%Y", "3RD_AUTHOR", PERSON, LEVEL_MAIN }, { "%S", "3RD_TITLE", SIMPLE, LEVEL_MAIN }, { "%7", "EDITION", SIMPLE, LEVEL_MAIN }, { "%8", "MONTH", DATE, LEVEL_MAIN }, { "%9", "GENRE", SIMPLE, LEVEL_MAIN }, { "%?", "SUB_AUTHOR", PERSON, LEVEL_MAIN }, /* subsidiary-authors */ { "%!", "SHORTTITLE", TITLE, LEVEL_MAIN }, { "%@", "SERIALNUMBER", SERIALNO, LEVEL_MAIN }, { "%(", "TITLE", SIMPLE, LEVEL_ORIG }, /* original pub */ { "%)", "REPRINTEDITION",SIMPLE,LEVEL_MAIN }, { "%*", "REVIEWEDITEM", SIMPLE, LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%L", "CALLNUMBER", SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", NOTES, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%Z", "NOTES", NOTES, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%+", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { " ", "GENRE|chart", ALWAYS, LEVEL_MAIN } }; static lookups unpublished[] = { { "%0", "INTERNAL_TYPE", TYPE, LEVEL_MAIN }, { "%A", "AUTHOR", PERSON, LEVEL_MAIN }, { "%H", "TRANSLATOR",PERSON, LEVEL_MAIN }, { "%Q", "TRANSLATEDTITLE", SIMPLE, LEVEL_MAIN }, { "%D", "YEAR", SIMPLE, LEVEL_MAIN }, { "%T", "TITLE" , TITLE, LEVEL_MAIN }, { "%J", "TITLE", TITLE, LEVEL_HOST }, /* for refer formats */ { "%E", "2ND_AUTHOR",PERSON, LEVEL_MAIN }, { "%B", "2ND_TITLE", SIMPLE, LEVEL_MAIN }, { "%C", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "%I", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "%V", "VOLUME" , SIMPLE, LEVEL_MAIN }, { "%6", "NUMVOLUMES",SIMPLE, LEVEL_HOST }, { "%N", "NUMBER", SIMPLE, LEVEL_MAIN }, { "%P", "PAGES", PAGES, LEVEL_MAIN }, { "%&", "SECTION", SIMPLE, LEVEL_MAIN }, { "%Y", "3RD_AUTHOR", PERSON, LEVEL_MAIN }, { "%S", "3RD_TITLE", SIMPLE, LEVEL_MAIN }, { "%7", "EDITION", SIMPLE, LEVEL_MAIN }, { "%8", "MONTH", DATE, LEVEL_MAIN }, { "%9", "GENRE", SIMPLE, LEVEL_MAIN }, { "%?", "SUB_AUTHOR", PERSON, LEVEL_MAIN }, /* subsidiary-authors */ { "%!", "SHORTTITLE", TITLE, LEVEL_MAIN }, { "%@", "SERIALNUMBER", SERIALNO, LEVEL_MAIN }, { "%(", "TITLE", SIMPLE, LEVEL_ORIG }, /* original pub */ { "%)", "REPRINTEDITION",SIMPLE,LEVEL_MAIN }, { "%*", "REVIEWEDITEM", SIMPLE, LEVEL_MAIN }, { "%1", "CUSTOM1", NOTES, LEVEL_MAIN }, { "%2", "CUSTOM2", NOTES, LEVEL_MAIN }, { "%3", "CUSTOM3", NOTES, LEVEL_MAIN }, { "%4", "CUSTOM4", NOTES, LEVEL_MAIN }, { "%#", "CUSTOM5", NOTES, LEVEL_MAIN }, { "%$", "CUSTOM6", NOTES, LEVEL_MAIN }, { "%M", "ACCESSNUM", SIMPLE, LEVEL_MAIN }, { "%L", "CALLNUMBER", SIMPLE, LEVEL_MAIN }, { "%F", "REFNUM", SIMPLE, LEVEL_MAIN }, { "%K", "KEYWORD", SIMPLE, LEVEL_MAIN }, { "%X", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "%O", "NOTES", NOTES, LEVEL_MAIN }, { "%U", "URL", SIMPLE, LEVEL_MAIN }, { "%>", "PDFLINK", SIMPLE, LEVEL_MAIN }, { "%Z", "NOTES", NOTES, LEVEL_MAIN }, { "%W", "PHYSICALLOC", SIMPLE, LEVEL_MAIN }, /* physical location */ { "%G", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "%+", "AUTHORADDRESS",SIMPLE, LEVEL_MAIN }, { "%^", "CAPTION", SIMPLE, LEVEL_MAIN }, { "%[", "ACCESSDATE", SIMPLE, LEVEL_MAIN }, { "%=", "LASTMODDATE", SIMPLE, LEVEL_MAIN }, { "%~", "DATABASE", SIMPLE, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|BOOK", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|unpublished", ALWAYS, LEVEL_MAIN }, }; /* order is important....."Book" matches "Book" and "Book Section", hence * "Book Section must come first */ #define ORIG(a) ( &(a[0]) ) #define SIZE(a) ( sizeof( a ) / sizeof( lookups ) ) #define REFTYPE(a,b) { a, ORIG(b), SIZE(b) } variants end_all[] = { REFTYPE( "Generic", generic ), REFTYPE( "Artwork", artwork ), REFTYPE( "Audiovisual Material", audiovisual ), REFTYPE( "Bill", bill ), REFTYPE( "Book Section", booksection ), REFTYPE( "Book", book ), REFTYPE( "Case", lawcase ), REFTYPE( "Chart or Table", chart ), REFTYPE( "Classical Work", generic ), REFTYPE( "Computer Program", program ), REFTYPE( "Conference Paper", conferencepaper ), REFTYPE( "Conference Proceeding", proceedings ), REFTYPE( "Edited Book", editedbook ), /* REFTYPE( "Equation", equation ), */ /* REFTYPE( "Electronic Article", electronicarticle ), */ /* REFTYPE( "Electronic Book", electronicbook ), */ /* REFTYPE( "Figure", figure ), */ REFTYPE( "Film or Broadcast", broadcast ), REFTYPE( "Electronic Source", electronic ), /* REFTYPE( "Government Document", governmentdocument ), */ REFTYPE( "Hearing", hearing ), REFTYPE( "Journal Article", journalarticle ), /* REFTYPE( "Legal Rule/Regulation", legalrule ), */ REFTYPE( "Magazine Article", magazinearticle ), REFTYPE( "Manuscript", manuscript ), REFTYPE( "Map", map ), REFTYPE( "Newspaper Article", newspaperarticle ), /* REFTYPE( "Online Database", onlinedatabase ), */ /* REFTYPE( "Online Multimedia", onlinemultimedia ), */ REFTYPE( "Patent", patent ), REFTYPE( "Personal Communication", communication ), REFTYPE( "Report", report ), REFTYPE( "Statute", statute ), REFTYPE( "Thesis", thesis ), REFTYPE( "Unpublished Work", unpublished ), REFTYPE( "Web Page", webpage ), }; int end_nall = sizeof( end_all ) / sizeof( variants ); ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������bibutils_4.12/lib/medin.c���������������������������������������������������������������������������0000644�0000764�0000764�00000033507�11454160215�015574� 0����������������������������������������������������������������������������������������������������ustar �cdputnam������������������������cdputnam���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * medin.c * * Copyright (c) Chris Putnam 2004-2010 * * Program and source code released under the GPL * */ #include <stdio.h> #include <stdlib.h> #include "is_ws.h" #include "newstr.h" #include "newstr_conv.h" #include "fields.h" #include "xml.h" #include "xml_encoding.h" #include "medin.h" #include "bibutils.h" void medin_initparams( param *p, const char *progname ) { p->readformat = BIBL_MEDLINEIN; p->charsetin = BIBL_CHARSET_UNICODE; p->charsetin_src = BIBL_SRC_DEFAULT; p->latexin = 0; p->xmlin = 1; p->utf8in = 1; p->nosplittitle = 0; p->verbose = 0; p->addcount = 0; p->output_raw = BIBL_RAW_WITHMAKEREFID | BIBL_RAW_WITHCHARCONVERT; p->readf = medin_readf; p->processf = medin_processf; p->cleanf = NULL; p->typef = NULL; /* p->convertf = medin_convertf;*/ p->convertf = NULL; p->all = NULL; p->nall = 0; list_init( &(p->asis) ); list_init( &(p->corps) ); if ( !progname ) p->progname = NULL; else p->progname = strdup( progname ); } /* * The only difference between MEDLINE and PUBMED in format is * that the entire library is wrapped in <MedlineCitationSet> * or <PubmedArticle> tags... */ static char *wrapper[] = { "PubmedArticle", "MedlineCitation" }; static int nwrapper = sizeof( wrapper ) / sizeof( wrapper[0] ); static char * medin_findstartwrapper( char *buf, int *ntype ) { char *startptr=NULL; int i; for ( i=0; i<nwrapper && startptr==NULL; ++i ) { startptr = xml_findstart( buf, wrapper[ i ] ); if ( startptr && *ntype==-1 ) *ntype = i; } return startptr; } static char * medin_findendwrapper( char *buf, int ntype ) { char *endptr = xml_findend( buf, wrapper[ ntype ] ); return endptr; } int medin_readf( FILE *fp, char *buf, int bufsize, int *bufpos, newstr *line, newstr *reference, int *fcharset ) { newstr tmp; char *startptr = NULL, *endptr; int haveref = 0, inref = 0, file_charset = CHARSET_UNKNOWN, m, type = -1; newstr_init( &tmp ); while ( !haveref && newstr_fget( fp, buf, bufsize, bufpos, line ) ) { if ( line->data ) { m = xml_getencoding( line ); if ( m!=CHARSET_UNKNOWN ) file_charset = m; } if ( line->data ) { startptr = medin_findstartwrapper( line->data, &type ); } if ( startptr || inref ) { if ( inref ) newstr_strcat( &tmp, line->data ); else { newstr_strcat( &tmp, startptr ); inref = 1; } endptr = medin_findendwrapper( tmp.data, type ); if ( endptr ) { newstr_segcpy( reference, tmp.data, endptr ); haveref = 1; } } } newstr_free( &tmp ); *fcharset = file_charset; return haveref; } static inline int xml_hasdata( xml *node ) { if ( node && node->value && node->value->data ) return 1; return 0; } static inline char * xml_data( xml *node ) { return node->value->data; } static inline int xml_tagwithdata( xml *node, char *tag ) { if ( !xml_hasdata( node ) ) return 0; return xml_tagexact( node, tag ); } typedef struct xml_convert { char *in; /* The input tag */ char *a, *aval; /* The attribute="attribute_value" pair, if nec. */ char *out; /* The output tag */ int level; } xml_convert; static int medin_doconvert( xml *node, fields *info, xml_convert *c, int nc ) { int i, found = 0; char *d; if ( !xml_hasdata( node ) ) return 0; d = xml_data( node ); for ( i=0; i<nc && found==0; ++i ) { if ( c[i].a==NULL ) { if ( xml_tagexact( node, c[i].in ) ) { found = 1; fields_add( info, c[i].out, d, c[i].level ); } } else { if ( xml_tag_attrib( node, c[i].in, c[i].a, c[i].aval)){ found = 1; fields_add( info, c[i].out, d, c[i].level ); } } } return found; } /* <ArticleTitle>Mechanism and.....</ArticleTitle> */ static void medin_articletitle( xml *node, fields *info ) { if ( xml_hasdata( node ) ) fields_add( info, "TITLE", xml_data( node ), 0 ); } /* <MedlineDate>2003 Jan-Feb</MedlineDate> */ static void medin_medlinedate( fields *info, char *string, int level ) { newstr tmp; char *p, *q; newstr_init( &tmp ); /* extract year */ p = string; q = skip_notws( string ); newstr_segcpy( &tmp, p, q ); fields_add( info, "PARTYEAR", tmp.data, level ); q = skip_ws( q ); /* extract month */ if ( q ) { p = q; newstr_empty( &tmp ); q = skip_notws( q ); newstr_segcpy( &tmp, p, q ); newstr_findreplace( &tmp, "-", "/" ); fields_add( info, "PARTMONTH", tmp.data, level ); q = skip_ws( q ); } /* extract day */ if ( q ) { p = q; newstr_empty( &tmp ); q = skip_notws( q ); newstr_segcpy( &tmp, p, q ); fields_add( info, "PARTDAY", tmp.data, level ); } newstr_free( &tmp ); } /* <Journal> * <ISSN>0027-8424</ISSN> * <JournalIssue PrintYN="Y"> * <Volume>100</Volume> * <Issue>21</Issue> * <PubDate> * <Year>2003</Year> * <Month>Oct</Month> * <Day>14</Day> * </PubDate> * </Journal Issue> * </Journal> * * or.... * * <Journal> * <ISSN IssnType="Print">0735-0414</ISSN> * <JournalIssue CitedMedium="Print"> * <Volume>38</Volume> * <Issue>1</Issue> * <PubDate> * <MedlineDate>2003 Jan-Feb</MedlineDate> * </PubDate> * </JournalIssue> * <Title>Alcohol and alcoholism (Oxford, Oxfordshire) * Alcohol Alcohol. * */ static void medin_journal1( xml *node, fields *info ) { xml_convert c[] = { { "Title", NULL, NULL, "TITLE", 1 }, { "ISOAbbreviation", NULL, NULL, "SHORTTITLE", 1 }, { "ISSN", NULL, NULL, "ISSN", 1 }, { "Volume", NULL, NULL, "VOLUME", 1 }, { "Issue", NULL, NULL, "ISSUE", 1 }, { "Year", NULL, NULL, "PARTYEAR", 1 }, { "Month", NULL, NULL, "PARTMONTH", 1 }, { "Day", NULL, NULL, "PARTDAY", 1 }, { "Language", NULL, NULL, "LANGUAGE", 1 }, }; int nc = sizeof( c ) / sizeof( c[0] );; if ( xml_hasdata( node ) && !medin_doconvert( node, info, c, nc ) ) { if ( xml_tagexact( node, "MedlineDate" ) ) medin_medlinedate( info, xml_data( node ), 1 ); } if ( node->down ) medin_journal1( node->down, info ); if ( node->next ) medin_journal1( node->next, info ); } /* * 12111-6 * */ static void medin_pagination( xml *node, fields *info ) { newstr sp, ep; char *p; int i; if ( xml_tagexact( node, "MedlinePgn" ) && node->value ) { newstrs_init( &sp, &ep, NULL ); p = xml_data( node ); while ( *p && *p!='-' ) newstr_addchar( &sp, *p++ ); if ( *p=='-' ) p++; while ( *p ) newstr_addchar( &ep, *p++ ); if ( sp.len ) fields_add( info, "PAGESTART", sp.data, 1 ); if ( ep.len ) { if ( sp.len > ep.len ) { for ( i=sp.len-ep.len; idown ) medin_pagination( node->down, info ); if ( node->next ) medin_pagination( node->next, info ); } /* * ljwejrelr * */ static void medin_abstract( xml *node, fields *info ) { if ( xml_tagwithdata( node, "AbstractText" ) ) fields_add( info, "ABSTRACT", xml_data( node ), 0 ); else if ( node->next ) medin_abstract( node->next, info ); } /* * * Barondeau * David P * ( or David P ) * DP * * * Organization * * */ static void medin_author( xml *node, newstr *name ) { char *p; if ( xml_tagexact( node, "LastName" ) ) { if ( name->len ) { newstr_prepend( name, "|" ); newstr_prepend( name, xml_data( node ) ); } else newstr_strcat( name, xml_data( node ) ); } else if ( xml_tagexact( node, "ForeName" ) || xml_tagexact( node, "FirstName" ) ) { p = xml_data( node ); while ( p && *p ) { if ( name->len ) newstr_addchar( name, '|' ); while ( *p && *p==' ' ) p++; while ( *p && *p!=' ' ) newstr_addchar( name, *p++ ); } } else if ( xml_tagexact( node, "Initials" ) && !strchr( name->data, '|' )) { p = xml_data( node ); while ( p && *p ) { if ( name->len ) newstr_addchar( name, '|' ); if ( !is_ws(*p) ) newstr_addchar( name, *p++ ); } } if ( node->next ) medin_author( node->next, name ); } static void medin_corpauthor( xml *node, newstr *name ) { if ( xml_tagexact( node, "CollectiveName" ) ) { newstr_strcpy( name, xml_data( node ) ); } else if ( node->next ) medin_corpauthor( node->next, name ); } static void medin_authorlist( xml *node, fields *info ) { newstr name; newstr_init( &name ); node = node->down; while ( node ) { if ( xml_tagexact( node, "Author" ) && node->down ) { medin_author( node->down, &name ); if ( name.len ) { fields_add(info,"AUTHOR",name.data,0); } else { medin_corpauthor( node->down, &name ); if ( name.len ) fields_add(info,"AUTHOR:CORP",name.data,0); } newstr_empty( &name ); } node = node->next; } newstr_free( &name ); } /* * Journal Article * */ /* * United States * Proc Natl Acad Sci U S A * 7507876 * */ static void medin_journal2( xml *node, fields *info ) { if ( xml_tagwithdata( node, "MedlineTA" ) && fields_find( info, "TITLE", 1 )==-1 ) fields_add( info, "TITLE", xml_data( node ), 1 ); if ( node->down ) medin_journal2( node->down, info ); if ( node->next ) medin_journal2( node->next, info ); } /* Biophysics Crystallography, X-Ray */ static void medin_meshheading( xml *node, fields *info ) { if ( xml_tagwithdata( node, "DescriptorName" ) ) fields_add( info, "KEYWORD", xml_data( node ), 0 ); if ( node->next ) medin_meshheading( node->next, info ); } static void medin_meshheadinglist( xml *node, fields *info ) { if ( xml_tagexact( node, "MeshHeading" ) && node->down ) medin_meshheading( node->down, info ); if ( node->next ) medin_meshheadinglist( node->next, info ); } /* * .... * * 14523232 * 10.1073/pnas.2133463100 * 2133463100 * 22922082 * * * * I think "pii" is "Publisher Item Identifier" */ static void medin_pubmeddata( xml *node, fields *info ) { xml_convert c[] = { { "ArticleId", "IdType", "doi", "DOI", 0 }, { "ArticleId", "IdType", "pubmed", "PMID", 0 }, { "ArticleId", "IdType", "medline", "MEDLINE", 0 }, { "ArticleId", "IdType", "pii", "PII", 0 }, }; int nc = sizeof( c ) / sizeof( c[0] ); medin_doconvert( node, info, c, nc ); if ( node->next ) medin_pubmeddata( node->next, info ); if ( node->down ) medin_pubmeddata( node->down, info ); } static void medin_article( xml *node, fields *info ) { if ( xml_tagexact( node, "Journal" ) ) medin_journal1( node, info ); else if ( xml_tagexact( node, "ArticleTitle" ) ) medin_articletitle( node, info ); else if ( xml_tagexact( node, "Pagination" ) && node->down ) medin_pagination( node->down, info ); else if ( xml_tagexact( node, "Abstract" ) && node->down ) medin_abstract( node->down, info ); else if ( xml_tagexact( node, "AuthorList" ) ) medin_authorlist( node, info ); else if ( xml_tagexact( node, "Affiliation" ) ) fields_add( info, "ADDRESS", xml_data( node ), 0 ); if ( node->next ) medin_article( node->next, info ); } static void medin_medlinecitation( xml *node, fields *info ) { if ( xml_tagexact( node, "PMID" ) && node->value->data ) fields_add( info, "PMID", node->value->data, 0 ); if ( node->down ) { if ( xml_tagexact( node, "Article" ) ) medin_article( node->down, info ); else if ( xml_tagexact( node, "MedlineJournalInfo" ) ) medin_journal2( node->down, info ); else if ( xml_tagexact( node, "MeshHeadingList" ) ) medin_meshheadinglist( node->down, info ); } if ( node->next ) medin_medlinecitation( node->next, info ); } static void medin_pubmedarticle( xml *node, fields *info ) { if ( node->down ) { if ( xml_tagexact( node, "MedlineCitation" ) ) medin_medlinecitation( node->down, info ); else if ( xml_tagexact( node, "PubmedData" ) ) medin_pubmeddata( node->down, info ); } if ( node->next ) medin_pubmedarticle( node->next, info ); } static void medin_assembleref( xml *node, fields *info ) { if ( node->down ) { if ( xml_tagexact( node, "PubmedArticle" ) ) medin_pubmedarticle( node->down, info ); else if ( xml_tagexact( node, "MedlineCitation" ) ) medin_medlinecitation( node->down, info ); else medin_assembleref( node->down, info ); } if ( node->next ) medin_assembleref( node->next, info ); /* assume everything is a journal article */ if ( info->nfields ) { fields_add( info, "RESOURCE", "text", 0 ); fields_add( info, "ISSUANCE", "continuing", 1 ); fields_add( info, "GENRE", "periodical", 1 ); fields_add( info, "GENRE", "academic journal", 1 ); } } int medin_processf( fields *medin, char *data, char *filename, long nref ) { xml top; xml_init( &top ); xml_tree( data, &top ); medin_assembleref( &top, medin ); xml_free( &top ); return 1; } void medin_convertf( fields *medin, fields *info, int reftype, int verbose, variants *all, int nall ) { int i; for ( i=0; infields; ++i ) fields_add( info, medin->tag[i].data, medin->data[i].data, medin->level[i] ); } bibutils_4.12/lib/bibtexin.h0000644000076400007640000000160611445514475016317 0ustar cdputnamcdputnam/* * bibtexin.h * * Copyright (c) Chris Putnam 2003-2010 * * Program and source code released under the GPL * */ #ifndef BIBTEXIN_H #define BIBTEXIN_H #include "newstr.h" #include "list.h" #include "fields.h" #include "bibl.h" #include "bibutils.h" #include "reftypes.h" extern void bibtexin_convertf( fields *bibin, fields *info, int reftype, param *p, variants *all, int nall ); extern int bibtexin_processf( fields *bibin, char *data, char *filename, long nref ); extern void bibtexin_cleanf( bibl *bin, param *p ); extern int bibtexin_readf( FILE *fp, char *buf, int bufsize, int *bufpos, newstr *line, newstr *reference, int *fcharset ); extern int bibtexin_typef( fields *bibin, char *filename, int nrefs, param *p, variants *all, int nall ); extern void bibtexin_initparams( param *p, const char *progname ); extern variants bibtex_all[]; extern int bibtex_nall; #endif bibutils_4.12/lib/endxmlin.c0000644000076400007640000003232511445517032016316 0ustar cdputnamcdputnam/* * endxmlin.c * * Copyright (c) Chris Putnam 2006-2010 * * Program and source code released under the GPL */ #include #include #include "newstr.h" #include "newstr_conv.h" #include "fields.h" #include "name.h" #include "xml.h" #include "xml_encoding.h" #include "reftypes.h" #include "endxmlin.h" #include "endin.h" typedef struct { char *attrib; char *internal; } attribs; void endxmlin_initparams( param *p, const char *progname ) { p->readformat = BIBL_ENDNOTEXMLIN; p->charsetin = BIBL_CHARSET_DEFAULT; p->charsetin_src = BIBL_SRC_DEFAULT; p->latexin = 0; p->xmlin = 1; p->utf8in = 1; p->nosplittitle = 0; p->verbose = 0; p->addcount = 0; p->output_raw = 0; p->readf = endxmlin_readf; p->processf = endxmlin_processf; p->cleanf = NULL; p->typef = endin_typef; p->convertf = endin_convertf; p->all = end_all; p->nall = end_nall; list_init( &(p->asis) ); list_init( &(p->corps) ); if ( !progname ) p->progname = NULL; else p->progname = strdup( progname ); } static int xml_readmore( FILE *fp, char *buf, int bufsize, int *bufpos ) { if ( !feof( fp ) && fgets( buf, bufsize, fp ) ) return 0; return 1; } int endxmlin_readf( FILE *fp, char *buf, int bufsize, int *bufpos, newstr *line, newstr *reference, int *fcharset ) { newstr tmp; char *startptr = NULL, *endptr = NULL; int haveref = 0, inref = 0, done = 0, file_charset = CHARSET_UNKNOWN, m; newstr_init( &tmp ); while ( !haveref && !done ) { if ( line->data ) { if ( !inref ) { startptr = xml_findstart( line->data, "RECORD" ); if ( startptr ) inref = 1; } else endptr = xml_findend( line->data, "RECORD" ); } /* If no tag, we can trim up to last 8 bytes */ /* Emptying string can lose fragments of tag */ if ( !startptr ) { if ( line->len > 8 ) { int n = 8; char *p = &(line->data[line->len-1]); while ( *p && n ) { p--; n--; } newstr_segdel( line, line->data, p ); } } if ( !startptr || !endptr ) { done = xml_readmore( fp, buf, bufsize, bufpos ); newstr_strcat( line, buf ); } else { /* we can reallocate in the newstr_strcat, so re-find */ startptr = xml_findstart( line->data, "RECORD" ); endptr = xml_findend( line->data, "RECORD" ); newstr_segcpy( reference, startptr, endptr ); /* clear out information in line */ newstr_strcpy( &tmp, endptr ); newstr_newstrcpy( line, &tmp ); haveref = 1; } if ( line->data ) { m = xml_getencoding( line ); if ( m!=CHARSET_UNKNOWN ) file_charset = m; } } newstr_free( &tmp ); *fcharset = file_charset; return haveref; } /* * add data to fields */ /* * handle fields with (potentially) several style pieces * * * * * * aaaaaa * * * * */ void endxmlin_datar( xml *node, newstr *s ) { if ( node->value && node->value->len ) newstr_strcat( s, node->value->data ); if ( node->down && xml_tagexact( node->down, "style" ) ) endxmlin_datar( node->down, s ); if ( xml_tagexact( node, "style" ) && node->next ) endxmlin_datar( node->next, s ); } void endxmlin_data( xml *node, char *inttag, fields *info, int level ) { newstr s; newstr_init( &s ); endxmlin_datar( node, &s ); if ( s.len ) fields_add( info, inttag, s.data, level ); newstr_free( &s ); } /* * * <style>ACTUAL TITLE HERE</style><style>MORE TITLE</style> * * */ void endxmlin_titles( xml *node, fields *info ) { attribs a[] = { { "title", "%T" }, { "secondary-title", "%B" }, { "tertiary-title", "%S" }, { "alt-title", "%!" }, { "short-title", "SHORTTITLE" }, }; int i, n = sizeof( a ) / sizeof ( a[0] ); newstr title; newstr_init( &title ); for ( i=0; idown ) { newstr_empty( &title ); endxmlin_datar( node, &title ); fields_add( info, a[i].internal, title.data, 0); } } if ( node->next ) endxmlin_titles( node->next, info ); newstr_free( &title ); } /* * * * * * * */ /* * */ void endxmlin_contributor( xml *node, fields *info, char *int_tag, int level ) { endxmlin_data( node, int_tag, info, level ); if ( node->next ) endxmlin_contributor( node->next, info, int_tag, level ); } static void endxmlin_contributors( xml *node, fields *info ) { attribs contrib[] = { { "authors", "%A" }, { "secondary-authors", "%E" }, { "tertiary-authors", "%Y" }, { "subsidiary-authors", "%?" }, { "translated-authors", "%?" }, }; int i, n = sizeof( contrib ) / sizeof ( contrib[0] ); for ( i=0; idown ) endxmlin_contributor( node->down, info, contrib[i].internal, 0 ); } if ( node->next ) endxmlin_contributors( node->next, info ); } static void endxmlin_keyword( xml *node, fields *info ) { if ( xml_tagexact( node, "keyword" ) ) endxmlin_data( node, "%K", info, 0 ); if ( node->next ) endxmlin_keyword( node->next, info ); } static void endxmlin_keywords( xml *node, fields *info ) { if ( node->down && xml_tagexact( node->down, "keyword" ) ) endxmlin_keyword( node->down, info ); } /* * */ static void endxmlin_ern( xml *node, fields *info ) { if ( xml_tagexact( node, "electronic-resource-num" ) ) endxmlin_data( node, "DOI", info, 0 ); } static void endxmlin_language( xml *node, fields *info ) { if ( xml_tagexact( node, "language" ) ) endxmlin_data( node, "%G", info, 0 ); } /* * * * internal-pdf://Zukin_1995_The_Cultures_of_Cities-0000551425/Zukin_1995_The_Cultures_of_Cities.pdf * * */ static void endxmlin_fileattach( xml *node, fields *info ) { if ( xml_tagexact( node, "url" ) ) endxmlin_data( node, "FILEATTACH", info, 0 ); if ( node->down ) endxmlin_fileattach( node->down, info ); if ( node->next ) endxmlin_fileattach( node->next, info ); } static void endxmlin_urls( xml *node, fields *info ) { if ( xml_tagexact( node, "pdf-urls" ) && node->down ) endxmlin_fileattach( node->down, info ); else if ( xml_tagexact( node, "url" ) ) endxmlin_data( node, "%U", info, 0 ); else { if ( node->down ) { if ( xml_tagexact( node->down, "related-urls" ) || xml_tagexact( node->down, "pdf-urls" ) || xml_tagexact( node->down, "url" ) ) endxmlin_urls( node->down, info ); } } if ( node->next ) endxmlin_urls( node->next, info ); } static void endxmlin_pubdates( xml *node, fields *info ) { if ( xml_tagexact( node, "date" ) ) endxmlin_data( node, "%8", info, 0 ); else { if ( node->down && xml_tagexact( node->down, "date" ) ) endxmlin_pubdates( node->down, info ); } } static void endxmlin_dates( xml *node, fields *info ) { if ( xml_tagexact( node, "year" ) ) endxmlin_data( node, "%D", info, 0 ); else { if ( node->down ) { if ( xml_tagexact( node->down, "year" ) ) endxmlin_dates( node->down, info ); if ( xml_tagexact( node->down, "pub-dates" ) ) endxmlin_pubdates( node->down, info ); } } if ( node->next ) endxmlin_dates( node->next, info ); } #ifdef NOCOMPILE /* * There are a lot of elements in the end2xml stuff buried in element * attributes for which it's not clear where they should get stuck * -- for now put into notes */ static void endxmlin_makeattribnotes( xml *node, fields *info, int level, attribs *a, int na ) { newstr *attrib, note; int i; newstr_init( ¬e ); for ( i=0; idata ); fields_add( info, "%O", note.data, level ); newstr_empty( ¬e ); } } newstr_free( ¬e ); } #endif #ifdef NOCOMPILE /* * */ static void endxmlin_sourceapp( xml *node, fields *info ) { attribs a[] = { { "name", "SOURCE APPLICATION NAME" }, { "version", "SOURCE APPLICATION VERSION" } }; int na = sizeof( a ) / sizeof( a[0] ); endxmlin_makeattribnotes( node, info, 0, a, na ); } /* * */ static void endxmlin_database( xml *node, fields *info ) { attribs a[] = { { "name", "DATABASE NAME" }, { "path", "DATABASE PATH" } }; int na = sizeof( a ) / sizeof( a[0] ); endxmlin_makeattribnotes( node, info, 0, a, na ); } #endif /* * 17 */ static void endxmlin_reftype( xml *node, fields *info ) { newstr *s; s = xml_getattrib( node, "name" ); if ( s && s->dim ) { fields_add( info, "%0", s->data, 0 ); newstr_free( s ); } } static void endxmlin_record( xml *node, fields *info ) { attribs a[] = { { "volume", "%V" }, { "num-vol", "%6" }, { "pages", "%P" }, { "number", "%N" }, { "issue", "%N" }, { "label", "%F" }, { "auth-address", "%C" }, { "auth-affiliation", "%C" }, { "pub-location", "%C" }, { "publisher", "%I" }, { "abstract", "%X" }, { "edition", "%7" }, { "reprint-edition", "%)" }, { "section", "%&" }, { "accession-num", "%M" }, { "call-num", "%L" }, { "isbn", "%@" }, { "notes", "%O" }, { "custom1", "%1" }, { "custom2", "%2" }, { "custom3", "%3" }, { "custom4", "%4" }, { "custom5", "%#" }, { "custom6", "%$" }, }; int i, n = sizeof ( a ) / sizeof( a[0] ); if ( xml_tagexact( node, "DATABASE" ) ) { /* endxmlin_database( node, info );*/ } else if ( xml_tagexact( node, "SOURCE-APP" ) ) { /* endxmlin_sourceapp( node, info );*/ } else if ( xml_tagexact( node, "REC-NUMBER" ) ) { } else if ( xml_tagexact( node, "ref-type" ) ) { endxmlin_reftype( node, info ); } else if ( xml_tagexact( node, "contributors" ) ) { if ( node->down ) endxmlin_contributors( node->down, info ); } else if ( xml_tagexact( node, "titles" ) ) { if ( node->down ) endxmlin_titles( node->down, info ); } else if ( xml_tagexact( node, "keywords" ) ) { endxmlin_keywords( node, info ); } else if ( xml_tagexact( node, "urls" ) ) { endxmlin_urls( node, info ); } else if ( xml_tagexact( node, "electronic-resource-num" ) ) { endxmlin_ern( node, info ); } else if ( xml_tagexact( node, "dates" ) ) { endxmlin_dates( node, info ); } else if ( xml_tagexact( node, "language" ) ) { endxmlin_language( node, info ); } else if ( xml_tagexact( node, "periodical" ) ) { } else if ( xml_tagexact( node, "secondary-volume" ) ) { } else if ( xml_tagexact( node, "secondary-issue" ) ) { } else if ( xml_tagexact( node, "reprint-status" ) ) { } else if ( xml_tagexact( node, "orig-pub" ) ) { } else if ( xml_tagexact( node, "report-id" ) ) { } else if ( xml_tagexact( node, "coden" ) ) { } else if ( xml_tagexact( node, "caption" ) ) { } else if ( xml_tagexact( node, "research-notes" ) ) { } else if ( xml_tagexact( node, "work-type" ) ) { } else if ( xml_tagexact( node, "reviewed-item" ) ) { } else if ( xml_tagexact( node, "availability" ) ) { } else if ( xml_tagexact( node, "remote-source" ) ) { } else if ( xml_tagexact( node, "meeting-place" ) ) { } else if ( xml_tagexact( node, "work-location" ) ) { } else if ( xml_tagexact( node, "work-extent" ) ) { } else if ( xml_tagexact( node, "pack-method" ) ) { } else if ( xml_tagexact( node, "size" ) ) { } else if ( xml_tagexact( node, "repro-ratio" ) ) { } else if ( xml_tagexact( node, "remote-database-name" ) ) { } else if ( xml_tagexact( node, "remote-database-provider" ) ) { } else if ( xml_tagexact( node, "access-date" ) ) { } else if ( xml_tagexact( node, "modified-data" ) ) { } else if ( xml_tagexact( node, "misc1" ) ) { } else if ( xml_tagexact( node, "misc2" ) ) { } else if ( xml_tagexact( node, "misc3" ) ) { } else { for ( i=0; inext ) endxmlin_record( node->next, info ); } static void endxmlin_assembleref( xml *node, fields *info ) { if ( node->tag->len==0 ) { if ( node->down ) endxmlin_assembleref( node->down, info ); return; } else if ( xml_tagexact( node, "RECORD" ) ) { if ( node->down ) endxmlin_record( node->down, info ); } } /* endxmlin_processf first operates by converting to endnote input * the endnote->mods conversion happens in convertf. * * this is necessary as the xml format is as nasty and as overloaded * as the tags used in the Refer format output */ int endxmlin_processf( fields *fin, char *data, char *filename, long nref ) { xml top; xml_init( &top ); xml_tree( data, &top ); endxmlin_assembleref( &top, fin ); xml_free( &top ); return 1; } bibutils_4.12/lib/isiin.c0000644000076400007640000001642511445517003015614 0ustar cdputnamcdputnam/* * isiin.c * * Copyright (c) Chris Putnam 2004-2010 * * Program and source code released under the GPL * */ #include #include #include #include "is_ws.h" #include "newstr.h" #include "newstr_conv.h" #include "fields.h" #include "name.h" #include "title.h" #include "serialno.h" #include "reftypes.h" #include "isiin.h" void isiin_initparams( param *p, const char *progname ) { p->readformat = BIBL_ISIIN; p->charsetin = BIBL_CHARSET_DEFAULT; p->charsetin_src = BIBL_SRC_DEFAULT; p->latexin = 0; p->xmlin = 0; p->utf8in = 0; p->nosplittitle = 0; p->verbose = 0; p->addcount = 0; p->output_raw = 0; p->readf = isiin_readf; p->processf = isiin_processf; p->cleanf = NULL; p->typef = isiin_typef; p->convertf = isiin_convertf; p->all = isi_all; p->nall = isi_nall; list_init( &(p->asis) ); list_init( &(p->corps) ); if ( !progname ) p->progname = NULL; else p->progname = strdup( progname ); } /* ISI definition of a tag is strict: * char 1 = uppercase alphabetic character * char 2 = uppercase alphabetic character or digit */ static int isiin_istag( char *buf ) { if ( ! (buf[0]>='A' && buf[0]<='Z') ) return 0; if ( ! (((buf[1]>='A' && buf[1]<='Z'))||(buf[1]>='0'&&buf[1]<='9'))) return 0; return 1; } static int readmore( FILE *fp, char *buf, int bufsize, int *bufpos, newstr *line ) { if ( line->len ) return 1; else return newstr_fget( fp, buf, bufsize, bufpos, line ); } int isiin_readf( FILE *fp, char *buf, int bufsize, int *bufpos, newstr *line, newstr *reference, int *fcharset ) { int haveref = 0, inref = 0; char *p; *fcharset = CHARSET_UNKNOWN; while ( !haveref && readmore( fp, buf, bufsize, bufpos, line ) ) { if ( !line->data ) continue; p = &(line->data[0]); /* Recognize UTF8 BOM */ if ( line->len > 2 && (unsigned char)(p[0])==0xEF && (unsigned char)(p[1])==0xBB && (unsigned char)(p[2])==0xBF ) { *fcharset = CHARSET_UNICODE; p += 3; } /* Each reference ends with 'ER ' */ if ( isiin_istag( p ) ) { if ( !strncmp( p, "FN ", 3 ) ) { if (strncasecmp( p, "FN ISI Export Format",20)){ fprintf( stderr, ": warning file FN type not '%s' not recognized.\n", /*r->progname,*/ p ); } } else if ( !strncmp( p, "VR ", 3 ) ) { if ( strncasecmp( p, "VR 1.0", 6 ) ) { fprintf(stderr,": warning file version number '%s' not recognized, expected 'VR 1.0'\n", /*r->progname,*/ p ); } } else if ( !strncmp( p, "ER", 2 ) ) haveref = 1; else { newstr_addchar( reference, '\n' ); newstr_strcat( reference, p ); inref = 1; } newstr_empty( line ); } /* not a tag, but we'll append to the last values */ else if ( inref ) { newstr_addchar( reference, '\n' ); newstr_strcat( reference, p ); newstr_empty( line ); } else { newstr_empty( line ); } } return haveref; } static char * process_isiline( newstr *tag, newstr *data, char *p ) { int i; /* collect tag and skip past it */ i = 0; while ( i<2 && *p && *p!='\r' && *p!='\n') { newstr_addchar( tag, *p++ ); i++; } while ( *p==' ' || *p=='\t' ) p++; while ( *p && *p!='\r' && *p!='\n' ) newstr_addchar( data, *p++ ); newstr_trimendingws( data ); while ( *p=='\r' || *p=='\n' ) p++; return p; } int isiin_processf( fields *isiin, char *p, char *filename, long nref ) { newstr tag, data; int n; newstrs_init( &tag, &data, NULL ); while ( *p ) { newstrs_empty( &tag, &data, NULL ); p = process_isiline( &tag, &data, p ); if ( !data.len ) continue; if ( (tag.len>1) && isiin_istag( tag.data ) ) { fields_add( isiin, tag.data, data.data, 0 ); } else { n = isiin->nfields; if ( n>0 ) { /* only one AU or AF for list of authors */ if ( !strcmp( isiin->tag[n-1].data,"AU") ){ fields_add( isiin, "AU", data.data, 0); } else if ( !strcmp( isiin->tag[n-1].data,"AF") ){ fields_add( isiin, "AF", data.data, 0); } /* otherwise append multiline data */ else { newstr_addchar( &(isiin->data[n-1]),' '); newstr_strcat( &(isiin->data[n-1]), data.data ); } } } } newstrs_free( &data, &tag, NULL ); return 1; } static void keyword_process( fields *info, char *newtag, char *p, int level ) { newstr keyword; newstr_init( &keyword ); while ( *p ) { p = skip_ws( p ); while ( *p && *p!=';' ) newstr_addchar( &keyword, *p++ ); if ( keyword.len ) { fields_add( info, newtag, keyword.data, level ); newstr_empty( &keyword ); } if ( *p==';' ) p++; } newstr_free( &keyword ); } int isiin_typef( fields *isiin, char *filename, int nref, param *p, variants *all, int nall ) { char *refnum = ""; int n, reftype, nrefnum; n = fields_find( isiin, "PT", 0 ); nrefnum = fields_find ( isiin, "UT", 0 ); if ( nrefnum!=-1 ) refnum = isiin->data[nrefnum].data; if ( n!=-1 ) reftype = get_reftype( (isiin->data[n]).data, nref, p->progname, all, nall, refnum ); else reftype = get_reftype( "", nref, p->progname, all, nall, refnum ); /* default */ return reftype; } /* pull off authors first--use AF before AU */ static void isiin_addauthors( fields *isiin, fields *info, int reftype, variants *all, int nall, list *asis, list *corps ) { newstr *t, *d; char *newtag, *authortype, use_af[]="AF", use_au[]="AU"; int level, i, n, has_af=0, has_au=0; for ( i=0; infields && has_af==0; ++i ) { t = &( isiin->tag[i] ); if ( !strcasecmp( t->data, "AU" ) ) has_au++; if ( !strcasecmp( t->data, "AF" ) ) has_af++; } if ( has_af ) authortype = use_af; else authortype = use_au; for ( i=0; infields; ++i ) { t = &( isiin->tag[i] ); if ( !strcasecmp( t->data, "AU" ) ) has_au++; if ( strcasecmp( t->data, authortype ) ) continue; d = &( isiin->data[i] ); n = process_findoldtag( authortype, reftype, all, nall ); level = ((all[reftype]).tags[n]).level; newtag = all[reftype].tags[n].newstr; name_add( info, newtag, d->data, level, asis, corps ); } } static void isiin_report_notag( param *p, char *tag ) { if ( p->verbose && strcmp( tag, "PT" ) ) { if ( p->progname ) fprintf( stderr, "%s: ", p->progname ); fprintf( stderr, "Did not identify ISI tag '%s'\n", tag ); } } void isiin_convertf( fields *isiin, fields *info, int reftype, param *p, variants *all, int nall ) { newstr *t, *d; int process, level, i, n; char *newtag; isiin_addauthors( isiin, info, reftype, all, nall, &(p->asis), &(p->corps) ); for ( i=0; infields; ++i ) { t = &( isiin->tag[i] ); if ( !strcasecmp( t->data, "AU" ) || !strcasecmp( t->data, "AF" ) ) continue; d = &( isiin->data[i] ); n = process_findoldtag( t->data, reftype, all, nall ); if ( n==-1 ) { isiin_report_notag( p, t->data ); continue; } process = ((all[reftype]).tags[n]).processingtype; level = ((all[reftype]).tags[n]).level; newtag = all[reftype].tags[n].newstr; if ( process == SIMPLE || process == DATE ) fields_add( info, newtag, d->data, level ); else if ( process == PERSON ) name_add( info, newtag, d->data, level, &(p->asis), &(p->corps) ); else if ( process == TITLE ) title_process( info, newtag, d->data, level, p->nosplittitle ); else if ( process == ISI_KEYWORD ) keyword_process( info, newtag, d->data, level ); else if ( process == SERIALNO ) addsn( info, d->data, level ); /* do nothing if process==TYPE || process==ALWAYS */ } } bibutils_4.12/lib/serialno.c0000644000076400007640000000155011444072056016311 0ustar cdputnamcdputnam/* * serialno.c * * Copyright (c) Chris Putnam 2005-2010 * * Source code released under the GPL * */ #include #include "serialno.h" void addsn( fields *info, char *buf, int level ) { int ndigits=0, issn=0, isbn=0; char *p = buf; if ( !strncasecmp( p, "ISSN", 4 ) ) issn=1; else if ( !strncasecmp( p, "ISBN", 4 ) ) isbn=1; if ( !issn && !isbn ) { /* a lot have semicolons between multiple ISBN's for paperbacks and hardbacks with different numbers */ while ( *p && !(ndigits && (*p==';'||*p==':')) ) { if ( ( *p>='0' && *p<='9' ) || *p=='x' || *p=='X' ) ndigits++; p++; } if ( ndigits==8 ) issn = 1; else if ( ndigits==10 || ndigits==13 ) isbn = 1; } if ( issn ) fields_add( info, "ISSN", buf, level ); else if ( isbn ) fields_add( info, "ISBN", buf, level ); else fields_add( info, "SERIALNUMBER", buf, level ); } bibutils_4.12/lib/endout.h0000644000076400007640000000055211445514233016000 0ustar cdputnamcdputnam/* * endout.h * * Copyright (c) Chris Putnam 2005-2010 * */ #ifndef ENDOUT_H #define ENDOUT_H #include #include "bibutils.h" extern void endout_write( fields *info, FILE *fp, param *p, unsigned long refnum ); extern void endout_writeheader( FILE *outptr, param *p ); extern void endout_initparams( param *p, const char *progname ); #endif bibutils_4.12/lib/bibtexout.c0000644000076400007640000004315711453453711016514 0ustar cdputnamcdputnam/* * bibtexout.c * * Copyright (c) Chris Putnam 2003-2010 * * Program and source code released under the GPL * */ #include #include #include #include #include "newstr.h" #include "strsearch.h" #include "utf8.h" #include "xml.h" #include "fields.h" #include "bibl.h" #include "doi.h" #include "bibtexout.h" void bibtexout_initparams( param *p, const char *progname ) { p->writeformat = BIBL_BIBTEXOUT; p->format_opts = 0; p->charsetout = BIBL_CHARSET_DEFAULT; p->charsetout_src = BIBL_SRC_DEFAULT; p->latexout = 1; p->utf8out = 0; p->utf8bom = 0; p->xmlout = 0; p->nosplittitle = 0; p->verbose = 0; p->addcount = 0; p->singlerefperfile = 0; p->headerf = bibtexout_writeheader; p->footerf = NULL; p->writef = bibtexout_write; if ( !p->progname && progname ) p->progname = strdup( progname ); } enum { TYPE_UNKNOWN = 0, TYPE_ARTICLE, TYPE_INBOOK, TYPE_INPROCEEDINGS, TYPE_PROCEEDINGS, TYPE_INCOLLECTION, TYPE_COLLECTION, TYPE_BOOK, TYPE_PHDTHESIS, TYPE_MASTERSTHESIS, TYPE_REPORT, TYPE_MANUAL, TYPE_UNPUBLISHED, TYPE_ELECTRONIC, TYPE_MISC }; static void output_citekey( FILE *fp, fields *info, unsigned long refnum, int format_opts ) { int n = fields_find( info, "REFNUM", -1 ); char *p; if ( n!=-1 ) { p = info->data[n].data; while ( p && *p && *p!='|' ) { if ( format_opts & BIBOUT_STRICTKEY ) { if ( isdigit(*p) || (*p>='A' && *p<='Z') || (*p>='a' && *p<='z' ) ) fprintf( fp, "%c", *p ); } else { if ( *p!=' ' && *p!='\t' ) { fprintf( fp, "%c", *p ); } } p++; } } } static int bibtexout_type( fields *info, char *filename, int refnum, param *p ) { char *genre; int type = TYPE_UNKNOWN, i, maxlevel, n, level; /* determine bibliography type */ for ( i=0; infields; ++i ) { if ( strcasecmp( info->tag[i].data, "GENRE" ) && strcasecmp( info->tag[i].data, "NGENRE" ) ) continue; genre = info->data[i].data; level = info->level[i]; if ( !strcasecmp( genre, "periodical" ) || !strcasecmp( genre, "academic journal" ) || !strcasecmp( genre, "magazine" ) || !strcasecmp( genre, "newspaper" ) || !strcasecmp( genre, "article" ) ) type = TYPE_ARTICLE; else if ( !strcasecmp( genre, "instruction" ) ) type = TYPE_MANUAL; else if ( !strcasecmp( genre, "unpublished" ) ) type = TYPE_UNPUBLISHED; else if ( !strcasecmp( genre, "conference publication" ) ) { if ( level==0 ) type=TYPE_PROCEEDINGS; else type = TYPE_INPROCEEDINGS; } else if ( !strcasecmp( genre, "collection" ) ) { if ( level==0 ) type=TYPE_COLLECTION; else type = TYPE_INCOLLECTION; } else if ( !strcasecmp( genre, "report" ) ) type = TYPE_REPORT; else if ( !strcasecmp( genre, "book" ) ) { if ( level==0 ) type=TYPE_BOOK; else type=TYPE_INBOOK; } else if ( !strcasecmp( genre, "thesis" ) ) { if ( type==TYPE_UNKNOWN ) type=TYPE_PHDTHESIS; } else if ( !strcasecmp( genre, "Ph.D. thesis" ) ) type = TYPE_PHDTHESIS; else if ( !strcasecmp( genre, "Masters thesis" ) ) type = TYPE_MASTERSTHESIS; else if ( !strcasecmp( genre, "electronic" ) ) type = TYPE_ELECTRONIC; } if ( type==TYPE_UNKNOWN ) { for ( i=0; infields; ++i ) { if ( strcasecmp( info->tag[i].data, "ISSUANCE" ) ) continue; if ( !strcasecmp( info->data[i].data, "monographic" ) ) { if ( info->level[i]==0 ) type = TYPE_BOOK; else if ( info->level[i]==1 ) type=TYPE_INBOOK; } } } /* default to BOOK type */ if ( type==TYPE_UNKNOWN ) { maxlevel = fields_maxlevel( info ); if ( maxlevel > 0 ) type = TYPE_INBOOK; else { if ( p->progname ) fprintf( stderr, "%s: ", p->progname ); fprintf( stderr, "Cannot identify TYPE " "in reference %d ", refnum+1 ); n = fields_find( info, "REFNUM", -1 ); if ( n!=-1 ) fprintf( stderr, " %s", info->data[n].data); fprintf( stderr, " (defaulting to @Misc)\n" ); type = TYPE_MISC; } } return type; } static void output_type( FILE *fp, int type, int format_opts ) { typedef struct { int bib_type; char *type_name; } typenames; typenames types[] = { { TYPE_ARTICLE, "Article" }, { TYPE_INBOOK, "Inbook" }, { TYPE_PROCEEDINGS, "Proceedings" }, { TYPE_INPROCEEDINGS, "InProceedings" }, { TYPE_BOOK, "Book" }, { TYPE_PHDTHESIS, "PhdThesis" }, { TYPE_MASTERSTHESIS, "MastersThesis" }, { TYPE_REPORT, "TechReport" }, { TYPE_MANUAL, "Manual" }, { TYPE_COLLECTION, "Collection" }, { TYPE_INCOLLECTION, "InCollection" }, { TYPE_UNPUBLISHED, "Unpublished" }, { TYPE_ELECTRONIC, "Electronic" }, { TYPE_MISC, "Misc" } }; int i, len, ntypes = sizeof( types ) / sizeof( types[0] ); char *s = NULL; for ( i=0; i0 && data[i-1]=='\\' ) ) fprintf( fp, "\"" ); else { if ( nquotes % 2 == 0 ) fprintf( fp, "``" ); else fprintf( fp, "\'\'" ); nquotes++; } } } if ( format_opts & BIBOUT_BRACKETS ) fprintf( fp, "}" ); else fprintf( fp, "\"" ); } static void output_and_use( FILE *fp, fields *info, int n, char *outtag, int format_opts ) { output_element( fp, outtag, info->data[n].data, format_opts ); fields_setused( info, n ); } static void output_simple( FILE *fp, fields *info, char *intag, char *outtag, int format_opts ) { int n = fields_find( info, intag, -1 ); if ( n!=-1 ) { output_and_use( fp, info, n, outtag, format_opts ); } } static void output_simpleall( FILE *fp, fields *info, char *intag, char *outtag, int format_opts ) { int i; for ( i=0; infields; ++i ) { if ( strcasecmp( info->tag[i].data, intag ) ) continue; output_and_use( fp, info, i, outtag, format_opts ); } } static void output_fileattach( FILE *fp, fields *info, int format_opts ) { newstr data; int i; newstr_init( &data ); for ( i=0; infields; ++i ) { if ( strcasecmp( info->tag[i].data, "FILEATTACH" ) ) continue; newstr_strcpy( &data, ":" ); newstr_newstrcat( &data, &(info->data[i]) ); if ( strsearch( info->data[i].data, ".pdf" ) ) newstr_strcat( &data, ":PDF" ); else if ( strsearch( info->data[i].data, ".html" ) ) newstr_strcat( &data, ":HTML" ); else newstr_strcat( &data, ":TYPE" ); output_element( fp, "file", data.data, format_opts ); fields_setused( info, i ); newstr_empty( &data ); } newstr_free( &data ); } static void add_person( newstr *s, char *p ) { int nseps = 0, nch; while ( *p ) { nch = 0; if ( nseps==1 ) newstr_addchar( s, ',' ); if ( nseps ) newstr_addchar( s, ' ' ); while ( *p && *p!='|' ) { newstr_addchar( s, *p++ ); nch++; } if ( *p=='|' ) p++; if ( nseps!=0 && nch==1 ) newstr_addchar( s, '.' ); nseps++; } } static void output_people( FILE *fp, fields *info, unsigned long refnum, char *tag, char *ctag, char *atag, char *bibtag, int level, int format_opts ) { newstr allpeople; int i, npeople, person, corp, asis; /* primary citation authors */ npeople = 0; for ( i=0; infields; ++i ) { if ( level!=-1 && info->level[i]!=level ) continue; person = ( strcasecmp( info->tag[i].data, tag ) == 0 ); corp = ( strcasecmp( info->tag[i].data, ctag ) == 0 ); asis = ( strcasecmp( info->tag[i].data, atag ) == 0 ); if ( person || corp || asis ) { if ( npeople==0 ) newstr_init( &allpeople ); else { if ( format_opts & BIBOUT_WHITESPACE ) newstr_strcat(&allpeople,"\n\t\tand "); else newstr_strcat( &allpeople, "\nand " ); } if ( corp ) { newstr_addchar( &allpeople, '{' ); newstr_strcat( &allpeople, info->data[i].data ); newstr_addchar( &allpeople, '}' ); } else if ( asis ) { newstr_addchar( &allpeople, '{' ); newstr_strcat( &allpeople, info->data[i].data ); newstr_addchar( &allpeople, '}' ); } else add_person( &allpeople, info->data[i].data ); fields_setused( info, i ); npeople++; } } if ( npeople ) { output_element( fp, bibtag, allpeople.data, format_opts ); newstr_free( &allpeople ); } } static void output_title( FILE *fp, fields *info, unsigned long refnum, char *bibtag, int level, int format_opts ) { newstr title; int n1 = -1, n2 = -1; /* Option is for short titles of journals */ if ( ( format_opts & BIBOUT_SHORTTITLE ) && level==1 ) { n1 = fields_find( info, "SHORTTITLE", level ); n2 = fields_find( info, "SHORTSUBTITLE", level ); } if ( n1==-1 ) { n1 = fields_find( info, "TITLE", level ); n2 = fields_find( info, "SUBTITLE", level ); } if ( n1!=-1 ) { newstr_init( &title ); newstr_newstrcpy( &title, &(info->data[n1]) ); fields_setused( info, n1 ); if ( n2!=-1 ) { if ( info->data[n1].data[info->data[n1].len]!='?' ) newstr_strcat( &title, ": " ); else newstr_addchar( &title, ' ' ); newstr_strcat( &title, info->data[n2].data ); fields_setused( info, n2 ); } output_element( fp, bibtag, title.data, format_opts ); newstr_free( &title ); } } static void output_date( FILE *fp, fields *info, unsigned long refnum, int format_opts ) { char *months[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; int n, month; n = fields_find( info, "YEAR", -1 ); if ( n==-1 ) n = fields_find( info, "PARTYEAR", -1 ); if ( n!=-1 ) { output_element( fp, "year", info->data[n].data, format_opts ); fields_setused( info, n ); } n = fields_find( info, "MONTH", -1 ); if ( n==-1 ) n = fields_find( info, "PARTMONTH", -1 ); if ( n!=-1 ) { month = atoi( info->data[n].data ); if ( month>0 && month<13 ) output_element( fp, "month", months[month-1], format_opts ); else output_element( fp, "month", info->data[n].data, format_opts ); fields_setused( info, n ); } n = fields_find( info, "DAY", -1 ); if ( n==-1 ) n = fields_find( info, "PARTDAY", -1 ); if ( n!=-1 ) { output_element( fp, "day", info->data[n].data, format_opts ); fields_setused( info, n ); } } /* output article number as pages if true pages aren't found */ static void output_articlenumber( FILE *fp, fields *info, unsigned long refnum, int format_opts ) { int ar = fields_find( info, "ARTICLENUMBER", -1 ); if ( ar!=-1 ) { newstr pages; newstr_init( &pages ); newstr_strcat( &pages, info->data[ar].data ); output_element( fp, "pages", pages.data, format_opts ); fields_setused( info, ar ); newstr_free( &pages ); } } static void output_arxiv( FILE *fp, fields *info, int format_opts ) { int ar = fields_find( info, "ARXIV", -1 ); if ( ar!=-1 ) { newstr arxiv; newstr_init( &arxiv ); arxiv_to_url( info, ar, "URL", &arxiv ); if ( arxiv.len ) output_element( fp, "url", arxiv.data, format_opts ); newstr_free( &arxiv ); } } static void output_pmid( FILE *fp, fields *info, int format_opts ) { int pm = fields_find( info, "PMID", -1 ); if ( pm!=-1 ) { newstr pmid; newstr_init( &pmid ); pmid_to_url( info, pm, "URL", &pmid ); if ( pmid.len ) output_element( fp, "url", pmid.data, format_opts ); newstr_free( &pmid ); } } static void output_jstor( FILE *fp, fields *info, int format_opts ) { int js = fields_find( info, "JSTOR", -1 ); if ( js!=-1 ) { newstr jstor; newstr_init( &jstor ); jstor_to_url( info, js, "URL", &jstor ); if ( jstor.len ) output_element( fp, "url", jstor.data, format_opts ); newstr_free( &jstor ); } } static void output_pages( FILE *fp, fields *info, unsigned long refnum, int format_opts ) { newstr pages; int sn, en; sn = fields_find( info, "PAGESTART", -1 ); en = fields_find( info, "PAGEEND", -1 ); if ( sn==-1 && en==-1 ) { output_articlenumber( fp, info, refnum, format_opts ); return; } newstr_init( &pages ); if ( sn!=-1 ) { newstr_strcat( &pages, info->data[sn].data ); fields_setused( info, sn ); } if ( sn!=-1 && en!=-1 ) { if ( format_opts & BIBOUT_SINGLEDASH ) newstr_strcat( &pages, "-" ); else newstr_strcat( &pages, "--" ); } if ( en!=-1 ) { newstr_strcat( &pages, info->data[en].data ); fields_setused( info, en ); } output_element( fp, "pages", pages.data, format_opts ); newstr_free( &pages ); } /* * from Tim Hicks: * I'm no expert on bibtex, but those who know more than I on our mailing * list suggest that 'issue' isn't a recognised key for bibtex and * therefore that bibutils should be aliasing IS to number at some point in * the conversion. * * Therefore prefer outputting issue/number as number and only keep * a distinction if both issue and number are present for a particular * reference. */ static void output_issue_number( FILE *fp, fields *info, int format_opts ) { int nissue = fields_find( info, "ISSUE", -1 ); int nnumber = fields_find( info, "NUMBER", -1 ); if ( nissue!=-1 && nnumber!=-1 ) { output_and_use( fp, info, nissue, "issue", format_opts ); output_and_use( fp, info, nnumber, "number", format_opts ); /* output_element( fp, "issue", info->data[nissue].data, format_opts ); fields_setused( info, nissue ); output_element( fp, "number", info->data[nnumber].data, format_opts ); fields_setused( info, nnumber );*/ } else if ( nissue!=-1 ) { output_and_use( fp, info, nissue, "number", format_opts ); /* output_element( fp, "number", info->data[nissue].data, format_opts ); fields_setused( info, nissue );*/ } else if ( nnumber!=-1 ) { output_and_use( fp, info, nnumber, "number", format_opts ); /* output_element( fp, "number", info->data[nnumber].data, format_opts ); fields_setused( info, nnumber ); */ } } void bibtexout_write( fields *info, FILE *fp, param *p, unsigned long refnum ) { int type; fields_clearused( info ); type = bibtexout_type( info, "", refnum, p ); output_type( fp, type, p->format_opts ); if ( !( p->format_opts & BIBOUT_DROPKEY ) ) output_citekey( fp, info, refnum, p->format_opts ); output_people( fp, info, refnum, "AUTHOR", "AUTHOR:CORP", "AUTHOR:ASIS", "author", 0, p->format_opts ); output_people( fp, info, refnum, "EDITOR", "EDITOR:CORP", "EDITOR:ASIS", "editor", -1, p->format_opts ); output_people( fp, info, refnum, "TRANSLATOR", "TRANSLATOR:CORP", "TRANSLATOR:ASIS", "translator", -1, p->format_opts ); /* item=main level title */ if ( type==TYPE_INBOOK ) output_title( fp, info, refnum, "chapter", 0, p->format_opts ); else output_title( fp, info, refnum, "title", 0, p->format_opts ); /* item=host level title */ if ( type==TYPE_ARTICLE ) output_title( fp, info, refnum, "journal", 1, p->format_opts ); else if ( type==TYPE_INBOOK ) { output_title( fp, info, refnum, "title", 1, p->format_opts ); output_title( fp, info, refnum, "series", 2, p->format_opts ); } else if ( type==TYPE_INPROCEEDINGS || type==TYPE_INCOLLECTION ) { output_title( fp, info, refnum, "booktitle", 1, p->format_opts ); output_title( fp, info, refnum, "series", 2, p->format_opts ); } else if ( type==TYPE_PHDTHESIS || type==TYPE_MASTERSTHESIS ) { output_title( fp, info, refnum, "series", 1, p->format_opts ); } else if ( type==TYPE_BOOK || type==TYPE_COLLECTION || type==TYPE_PROCEEDINGS ) output_title( fp, info, refnum, "series", 1, p->format_opts ); output_date( fp, info, refnum, p->format_opts ); output_simple( fp, info, "EDITION", "edition", p->format_opts ); output_simple( fp, info, "PUBLISHER", "publisher", p->format_opts ); output_simple( fp, info, "ADDRESS", "address", p->format_opts ); output_simple( fp, info, "VOLUME", "volume", p->format_opts ); output_issue_number( fp, info, p->format_opts ); /* output_simple( fp, info, "ISSUE", "issue", p->format_opts ); output_simple( fp, info, "NUMBER", "number", p->format_opts );s*/ output_pages( fp, info, refnum, p->format_opts ); output_simpleall( fp, info, "KEYWORD", "keywords", p->format_opts ); output_simple( fp, info, "CONTENTS", "contents", p->format_opts ); output_simple( fp, info, "ABSTRACT", "abstract", p->format_opts ); output_simple( fp, info, "LOCATION", "location", p->format_opts ); output_simple( fp, info, "DEGREEGRANTOR", "school", p->format_opts ); output_simple( fp, info, "DEGREEGRANTOR:ASIS", "school", p->format_opts ); output_simple( fp, info, "DEGREEGRANTOR:CORP", "school", p->format_opts ); output_simpleall( fp, info, "NOTES", "note", p->format_opts ); output_simpleall( fp, info, "ANNOTE", "annote", p->format_opts ); output_simple( fp, info, "ISBN", "isbn", p->format_opts ); output_simple( fp, info, "ISSN", "issn", p->format_opts ); output_simple( fp, info, "DOI", "doi", p->format_opts ); output_simpleall( fp, info, "URL", "url", p->format_opts ); output_fileattach( fp, info, p->format_opts ); output_arxiv( fp, info, p->format_opts ); output_pmid( fp, info, p->format_opts ); output_jstor( fp, info, p->format_opts ); output_simple( fp, info, "LANGUAGE", "language", p->format_opts ); if ( p->format_opts & BIBOUT_FINALCOMMA ) fprintf( fp, "," ); fprintf( fp, "\n}\n\n" ); fflush( fp ); } void bibtexout_writeheader( FILE *outptr, param *p ) { if ( p->utf8bom ) utf8_writebom( outptr ); } bibutils_4.12/lib/modsin.c0000644000076400007640000005440211445516074015776 0ustar cdputnamcdputnam/* * modsin.c * * Copyright (c) Chris Putnam 2004-2010 * * Source code released under the GPL * */ #include #include #include #include #include "newstr.h" #include "newstr_conv.h" #include "xml.h" #include "xml_encoding.h" #include "fields.h" #include "name.h" #include "reftypes.h" #include "modstypes.h" #include "marc.h" #include "bibutils.h" #include "modsin.h" void modsin_initparams( param *p, const char *progname ) { p->readformat = BIBL_MODSIN; p->format_opts = 0; p->charsetin = BIBL_CHARSET_UNICODE; p->charsetin_src = BIBL_SRC_DEFAULT; p->latexin = 0; p->utf8in = 1; p->xmlin = 1; p->nosplittitle = 0; p->verbose = 0; p->addcount = 0; p->singlerefperfile = 0; p->output_raw = BIBL_RAW_WITHMAKEREFID | BIBL_RAW_WITHCHARCONVERT; p->readf = modsin_readf; p->processf = modsin_processf; p->cleanf = NULL; p->typef = NULL; p->convertf = NULL; p->all = NULL; p->nall = 0; list_init( &(p->asis) ); list_init( &(p->corps) ); if ( !progname ) p->progname = NULL; else p->progname = strdup( progname ); } static char modsns[]="mods"; static void modsin_detailr( xml *node, newstr *value ) { if ( node->value && node->value->len ) { if ( value->len ) newstr_addchar( value, ' ' ); newstr_newstrcat( value, node->value ); } if ( node->down ) modsin_detailr( node->down, value ); if ( node->next ) modsin_detailr( node->next, value ); } static void modsin_detail( xml *node, fields *info, int level ) { newstr type, value, *tp; if ( node->down ) { newstrs_init( &type, &value, NULL ); tp = xml_getattrib( node, "type" ); if ( tp ) { newstr_newstrcpy( &type, tp ); newstr_toupper( &type ); } modsin_detailr( node->down, &value ); if ( type.data && !strcasecmp( type.data, "PAGE" ) ) { fields_add( info, "PAGESTART", value.data, level ); } else fields_add( info, type.data, value.data, level ); newstrs_free( &type, &value, NULL ); /* newstr_free( &type ); newstr_free( &value ); */ } } static void modsin_date( xml *node, fields *info, int level, int part ) { /* char *month[12] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };*/ newstr s; char *p = NULL; /* int m;*/ if ( node->value ) p = node->value->data; if ( p ) { newstr_init( &s ); while ( *p && *p!='-' ) newstr_addchar( &s, *p++ ); if ( !part ) fields_add( info, "YEAR", s.data, level ); else fields_add( info, "PARTYEAR", s.data, level ); if ( *p=='-' ) p++; newstr_empty( &s ); while ( *p && *p!='-' ) newstr_addchar( &s, *p++ ); /* m = atoi( s.data );*/ /* if ( m > 0 && m < 13 ) { if ( !part ) fields_add( info, "MONTH", month[m-1], level ); else fields_add( info, "PARTMONTH", month[m-1], level ); } else {*/ if ( !part ) fields_add( info, "MONTH", s.data, level ); else fields_add( info, "PARTMONTH", s.data, level ); /* }*/ if ( *p=='-' ) p++; newstr_empty( &s ); while ( *p ) newstr_addchar( &s, *p++ ); if ( !part ) fields_add( info, "DAY", s.data, level ); else fields_add( info, "PARTDAY", s.data, level ); newstr_free( &s ); } } static void modsin_pager( xml *node, newstr *sp, newstr *ep, newstr *tp, newstr *lp ) { if ( xml_tagexact( node, "start" ) ) { newstr_newstrcpy( sp, node->value ); } else if ( xml_tagexact( node, "end" ) ) { newstr_newstrcpy( ep, node->value ); } else if ( xml_tagexact( node, "total" ) ) { newstr_newstrcpy( tp, node->value ); } else if ( xml_tagexact( node, "list" ) ) { newstr_newstrcpy( lp, node->value ); } if ( node->down ) modsin_pager( node->down, sp, ep, tp, lp ); if ( node->next ) modsin_pager( node->next, sp, ep, tp, lp ); } static void modsin_page( xml *node, fields *info, int level ) { newstr sp, ep, tp, lp; if ( node->down ) { newstrs_init( &sp, &ep, &tp, &lp, NULL ); modsin_pager( node->down, &sp, &ep, &tp, &lp ); if ( sp.len || ep.len ) { if ( sp.len ) fields_add( info, "PAGESTART", sp.data, level ); if ( ep.len ) fields_add( info, "PAGEEND", ep.data, level ); } else if ( lp.len ) { fields_add( info, "PAGESTART", lp.data, level ); } if ( tp.len ) fields_add( info, "TOTALPAGES", tp.data, level ); newstrs_free( &sp, &ep, &tp, &lp, NULL ); } } static void modsin_titler( xml *node, newstr *title, newstr *subtitle ) { if ( xml_tagexact( node, "title" ) ) { if ( title->len ) { newstr_strcat( title, " : " ); newstr_newstrcat( title, node->value ); } else { newstr_newstrcat( title, node->value ); } } else if ( xml_tagexact( node, "subTitle" ) ) newstr_newstrcat( subtitle, node->value ); if ( node->down ) modsin_titler( node->down, title, subtitle ); if ( node->next ) modsin_titler( node->next, title, subtitle ); } static void modsin_title( xml *node, fields *info, int level ) { newstr title, subtitle; int abbr = xml_tag_attrib( node, "titleInfo", "type", "abbreviated" ); if ( node->down ) { newstrs_init( &title, &subtitle, NULL ); modsin_titler( node->down, &title, &subtitle ); if ( title.len ) { if ( abbr ) fields_add( info, "SHORTTITLE", title.data, level ); else fields_add( info, "TITLE", title.data, level ); } if ( subtitle.len ) { if ( abbr ) fields_add( info, "SHORTSUBTITLE", subtitle.data, level ); else fields_add( info, "SUBTITLE", subtitle.data, level ); } newstrs_free( &title, &subtitle, NULL ); } } /* * find match in roles if newstr has the format of * * creator|cre */ static int modsin_rolesmatch( convert *roles_convert, int nroles, newstr *s ) { char *p, *q; int i, nmismatch; for ( i=0; idata; while ( *p ) { q = roles_convert[i].mods; nmismatch = 0; while ( *p && *p!='|' && nmismatch == 0) { if ( toupper( *p ) != toupper( *q ) ) nmismatch++; p++; q++; } if ( !nmismatch && !(*(q++))) return i; if ( *p=='|' ) p++; } } return -1; } static void modsin_asis_corp_r( xml *node, newstr *name, newstr *role ) { if ( xml_tagexact( node, "namePart" ) ) newstr_newstrcpy( name, node->value ); else if ( xml_tagexact( node, "roleTerm" ) ) { if ( role->len ) newstr_addchar( role, '|' ); newstr_newstrcat( role, node->value ); } if ( node->down ) modsin_asis_corp_r( node->down, name, role ); if ( node->next ) modsin_asis_corp_r( node->next, name, role ); } static void modsin_personr( xml *node, newstr *name, newstr *roles ) { if ( xml_tagexact( node, "namePart" ) ) { if ( xml_tag_attrib( node, "namePart", "type", "family" ) ) { if ( name->len ) newstr_prepend( name, "|" ); newstr_prepend( name, node->value->data ); } else if (xml_tag_attrib( node, "namePart", "type", "date")){ } else { if ( name->len ) newstr_addchar( name, '|' ); if ( strchr( node->value->data, ',' ) ) name_comma( node->value->data, name ); else name_nocomma( node->value->data, name ); } } else if ( xml_tagexact( node, "roleTerm" ) ) { if ( roles->len ) newstr_addchar( roles, '|' ); newstr_newstrcat( roles, node->value ); } if ( node->down ) modsin_personr( node->down, name, roles ); if ( node->next ) modsin_personr( node->next, name, roles ); } static void modsin_asis_corp( xml *node, fields *info, int level, convert *roles_convert, int nroles ) { newstr name, roles; int n; xml *dnode = node->down; if ( dnode ) { newstrs_init( &name, &roles, NULL ); modsin_asis_corp_r( dnode, &name, &roles ); if ( roles.len ) { n = modsin_rolesmatch( roles_convert, nroles, &roles ); if ( n!=-1 ) { fields_add( info, roles_convert[n].internal, name.data, level ); } else { fields_add( info, roles.data, name.data, level); } } else fields_add( info, roles_convert[0].internal, name.data, level ); newstrs_free( &name, &roles, NULL ); } } static void modsin_asis( xml *node, fields *info, int level ) { convert roles_convert[] = { { "author", "AUTHOR:ASIS" }, { "creator", "AUTHOR:ASIS" }, { "editor", "EDITOR:ASIS" }, { "degree grantor", "DEGREEGRANTOR:ASIS" }, { "organizer of meeting","ORGANIZER:ASIS" }, { "patent holder", "ASSIGNEE:ASIS" } }; int nroles = sizeof( roles_convert ) / sizeof( roles_convert[0] ); modsin_asis_corp( node, info, level, roles_convert, nroles ); } static void modsin_corp( xml *node, fields *info, int level ) { convert roles_convert[] = { { "author", "AUTHOR:CORP" }, { "creator", "AUTHOR:CORP" }, { "editor", "EDITOR:CORP" }, { "degree grantor", "DEGREEGRANTOR:CORP" }, { "organizer of meeting","ORGANIZER:CORP" }, { "patent holder", "ASSIGNEE:CORP" } }; int nroles = sizeof( roles_convert ) / sizeof( roles_convert[0] ); modsin_asis_corp( node, info, level, roles_convert, nroles ); } static void modsin_person( xml *node, fields *info, int level ) { newstr name, roles, role; char *p; xml *dnode = node->down; if ( dnode ) { newstrs_init( &name, &role, &roles, NULL ); modsin_personr( dnode, &name, &roles ); /* no defined role, default to author */ if ( !roles.len ) newstr_strcpy( &roles, "author" ); p = roles.data; while ( p && *p ) { while ( p && *p && *p!='|' ) newstr_addchar(&role,*p++); if ( !strcasecmp( role.data, "author" ) || !strcasecmp( role.data, "creator" ) ) fields_add( info, "AUTHOR", name.data, level ); else if ( !strcasecmp( role.data, "editor" ) ) fields_add( info, "EDITOR", name.data, level ); else fields_add( info, role.data, name.data, level ); if ( *p=='|' ) p++; newstr_empty( &role ); } newstrs_free( &name, &role, &roles, NULL ); } } static void modsin_placeterm( xml *node, fields *info, int level, int school ) { char address_tag[] = "ADDRESS", addresscode_tag[] = "CODEDADDRESS", school_tag[] = "SCHOOL", *newtag; newstr *type, s; newtag = ( school ) ? school_tag : address_tag; type = xml_getattrib( node, "type" ); if ( type && type->len ) { if ( !strcmp( type->data, "text" ) ) { fields_add( info, newtag, node->value->data, level ); } else if ( !strcmp( type->data, "code" ) ) { newstr_init( &s ); type = xml_getattrib( node, "authority" ); if ( type && type->len ) newstr_newstrcpy(&s, type); newstr_addchar( &s, '|' ); newstr_newstrcat( &s, node->value ); fields_add( info, addresscode_tag, s.data, level ); newstr_free( &s ); } } } static void modsin_placer( xml *node, fields *info, int level, int school ) { if ( xml_tag_attrib( node, "place", "type", "school" ) ) { school = 1; } else if ( xml_tagexact( node, "placeTerm" ) ) { modsin_placeterm( node, info, level, school ); } if ( node->down ) modsin_placer( node->down, info, level, school ); if ( node->next ) modsin_placer( node->next, info, level, school ); } static void modsin_origininfor( xml *node, fields *info, int level, newstr *pub, newstr *add, newstr *addc, newstr *ed, newstr *iss ) { if ( xml_tagexact( node, "dateIssued" ) ) modsin_date( node, info, level, 0 ); else if ( xml_tagexact( node, "publisher" ) ) newstr_newstrcat( pub, node->value ); else if ( xml_tagexact( node, "edition" ) ) newstr_newstrcat( ed, node->value ); else if ( xml_tagexact( node, "issuance" ) ) newstr_newstrcat( iss, node->value ); else if ( xml_tagexact( node, "place" ) ) modsin_placer( node, info, level, 0 ); if ( node->down ) modsin_origininfor( node->down, info, level, pub, add, addc, ed, iss ); if ( node->next ) modsin_origininfor( node->next, info, level, pub, add, addc, ed, iss ); } static void modsin_origininfo( xml *node, fields *info, int level ) { newstr publisher, address, addcode, edition, issuance; if ( node->down ) { newstrs_init( &publisher, &address, &addcode, &edition, &issuance, NULL ); modsin_origininfor( node->down, info, level, &publisher, &address, &addcode, &edition, &issuance ); if ( publisher.len ) fields_add( info, "PUBLISHER", publisher.data, level ); if ( address.len ) fields_add( info, "ADDRESS", address.data, level ); if ( addcode.len ) fields_add( info, "CODEDADDRESS", addcode.data, level ); if ( edition.len ) fields_add( info, "EDITION", edition.data, level ); if ( issuance.len ) fields_add( info, "ISSUANCE", issuance.data, level ); newstrs_free( &publisher, &address, &addcode, &edition, &issuance, NULL ); } } static void modsin_subjectr( xml *node, fields *info, int level ) { if ( xml_tagexact( node, "topic" ) || xml_tagexact( node, "geographic" )) { fields_add( info, "KEYWORD", node->value->data, level ); } if ( node->down ) modsin_subjectr( node->down, info, level ); if ( node->next ) modsin_subjectr( node->next, info, level ); } static void modsin_subject( xml *node, fields *info, int level ) { if ( node->down ) modsin_subjectr( node->down, info, level ); } static void modsin_id1( xml *node, fields *info, int level ) { newstr *ns; ns = xml_getattrib( node, "ID" ); if ( ns ) { fields_add( info, "REFNUM", ns->data, level ); } } static void modsin_genre( xml *node, fields *info, int level ) { char *added[] = { "manuscript", "academic journal", "magazine", "hearing", "report", "Ph.D. thesis", "Masters thesis", "Diploma thesis", "Doctoral thesis", "Habilitation thesis", "collection", "handwritten note", "communication", "teletype", "airtel", "memo", "e-mail communication", "press release", "television broadcast", "electronic" }; int nadded = sizeof( added ) /sizeof( char *); int j, ismarc = 0, isadded = 0; if ( node->value && node->value->len ) { if ( marc_findgenre( node->value->data )!=-1 ) ismarc = 1; for ( j=0; jvalue->data, added[j] ) ) isadded = 1; } if ( ismarc || isadded ) fields_add( info, "GENRE", node->value->data, level ); else fields_add( info, "NGENRE", node->value->data, level ); } } static void modsin_resource( xml *node, fields *info, int level ) { if ( node->value && node->value->len ) fields_add( info, "RESOURCE", node->value->data, level ); } static void modsin_language( xml *node, fields *info, int level ) { if ( node->value && node->value->len ) fields_add( info, "LANGUAGE", node->value->data, level ); } static void modsin_toc( xml *node, fields *info, int level ) { if ( node->value && node->value->len ) fields_add( info, "CONTENTS", node->value->data, level ); } static void modsin_note( xml *node, fields *info, int level ) { if ( node->value && node->value->len ) fields_add( info, "NOTES", node->value->data, level ); } static void modsin_annote( xml *node, fields *info, int level ) { if ( node->value && node->value->len ) fields_add( info, "ANNOTE", node->value->data, level ); } static void modsin_abstract( xml *node, fields *info, int level ) { if ( node->value && node->value->len ) fields_add( info, "ABSTRACT", node->value->data, level ); } static void modsin_locationr( xml *node, fields *info, int level ) { char url[]="URL", school[]="SCHOOL", loc[]="LOCATION"; char fileattach[]="FILEATTACH", *tag=NULL; if ( xml_tag_attrib( node, "url", "access", "raw object" ) ) { tag = fileattach; } else if ( xml_tagexact( node, "url" ) ) { tag = url; } if ( xml_tag_attrib( node, "physicalLocation", "type", "school" ) ) { tag = school; } else if ( xml_tagexact( node, "physicalLocation" ) ) { tag = loc; } if ( tag ) fields_add( info, tag, node->value->data, level ); if ( node->down ) modsin_locationr( node->down, info, level ); if ( node->next ) modsin_locationr( node->next, info, level ); } static void modsin_location( xml *node, fields *info, int level ) { if ( node->down ) modsin_locationr( node->down, info, level ); } static void modsin_descriptionr( xml *node, newstr *s ) { if ( xml_tagexact( node, "extent" ) ) newstr_newstrcpy( s, node->value ); if ( node->down ) modsin_descriptionr( node->down, s ); if ( node->next ) modsin_descriptionr( node->next, s ); } static void modsin_description( xml *node, fields *info, int level ) { newstr s; newstr_init( &s ); if ( node->down ) modsin_descriptionr( node->down, &s ); else { if ( node->value && node->value->data ); newstr_newstrcpy( &s, node->value ); } if ( s.len ) fields_add( info, "DESCRIPTION", s.data, level ); newstr_free( &s ); } static void modsin_partr( xml *node, fields *info, int level ) { if ( xml_tagexact( node, "detail" ) ) modsin_detail( node, info, level ); else if ( xml_tag_attrib( node, "extent", "unit", "page" ) ) modsin_page( node, info, level ); else if ( xml_tag_attrib( node, "extent", "unit", "pages" ) ) modsin_page( node, info, level ); else if ( xml_tagexact( node, "date" ) ) modsin_date( node, info, level, 1 ); if ( node->next ) modsin_partr( node->next, info, level ); } static void modsin_part( xml *node, fields *info, int level ) { if ( node->down ) modsin_partr( node->down, info, level ); } /* Q3 .A65 */ static void modsin_classification( xml *node, fields *info, int level ) { if ( node->value && node->value->len ) { if (xml_tag_attrib(node, "classification", "authority", "lcc")){ fields_add( info, "LCC", node->value->data, level ); } else fields_add( info, "CLASSIFICATION", node->value->data, level ); } if ( node->down ) modsin_classification( node->down, info, level ); } static void modsin_recordinfo( xml *node, fields *info, int level ) { xml *curr; /* extract recordIdentifier */ curr = node; while ( curr ) { if ( xml_tagexact( curr, "recordIdentifier" ) ) { fields_add( info, "REFNUM", curr->value->data, level ); } curr = curr->next; } } static void modsin_identifier( xml *node, fields *info, int level ) { convert ids[] = { { "citekey", "REFNUM" }, { "issn", "ISSN" }, { "isbn", "ISBN" }, { "doi", "DOI" }, { "url", "URL" }, { "uri", "URL" }, { "pmid", "PMID" }, { "pubmed", "PMID" }, { "medline", "MEDLINE" }, { "arXiv", "ARXIV" }, { "pii", "PII" }, { "isi", "ISIREFNUM" }, { "serial number", "SERIALNUMBER" }, { "accessnum", "ACCESSNUM" }, { "jstor", "JSTOR" }, }; int i , n = sizeof( ids ) / sizeof( ids[0] ); if ( !node->value || !node->value->data ) return; for ( i=0; ivalue->data, level ); } } static void modsin_mods( xml *node, fields *info, int level ) { if ( xml_tagexact( node, "titleInfo" ) ) modsin_title( node, info, level ); else if ( xml_tag_attrib( node, "name", "type", "personal" ) ) modsin_person( node, info, level ); else if ( xml_tag_attrib( node, "name", "type", "corporate" ) ) modsin_corp( node, info, level ); else if ( xml_tagexact( node, "name" ) ) modsin_asis( node, info, level ); else if ( xml_tagexact( node, "recordInfo" ) && node->down ) modsin_recordinfo( node->down, info, level ); else if ( xml_tagexact( node, "part" ) ) modsin_part( node, info, level ); else if ( xml_tagexact( node, "identifier" ) ) modsin_identifier( node, info, level ); else if ( xml_tagexact( node, "originInfo" ) ) modsin_origininfo( node, info, level ); else if ( xml_tagexact( node, "typeOfResource" ) ) modsin_resource( node, info, level ); else if ( xml_tagexact( node, "language" ) ) modsin_language( node, info, level ); else if ( xml_tagexact( node, "tableOfContents" ) ) modsin_toc( node, info, level ); else if ( xml_tagexact( node, "genre" ) ) modsin_genre( node, info, level ); else if ( xml_tagexact( node, "date" ) ) modsin_date( node, info, level, 0 ); else if ( xml_tagexact( node, "note" ) ) modsin_note( node, info, level ); else if ( xml_tagexact( node, "bibtex-annote" ) ) modsin_annote( node, info, level ); else if ( xml_tagexact( node, "abstract" ) ) modsin_abstract( node, info, level ); else if ( xml_tagexact( node, "subject" ) ) modsin_subject( node, info, level ); else if ( xml_tagexact( node, "classification" ) ) modsin_classification( node, info, level ); else if ( xml_tagexact( node, "location" ) ) modsin_location( node, info, level ); else if ( xml_tagexact( node, "physicalDescription" ) ) modsin_description( node, info, level ); else if ( xml_tag_attrib( node, "relatedItem", "type", "host" ) || xml_tag_attrib( node, "relatedItem", "type", "series" ) ) { if ( node->down ) modsin_mods( node->down, info, level+1 ); } if ( node->next ) modsin_mods( node->next, info, level ); } static void modsin_assembleref( xml *node, fields *info ) { if ( xml_tagexact( node, "mods" ) ) { modsin_id1( node, info, 0 ); if ( node->down ) modsin_mods( node->down, info, 0 ); } else if ( node->down ) modsin_assembleref( node->down, info ); if ( node->next ) modsin_assembleref( node->next, info ); } void modsin_convertf( fields *modsin, fields *info, int reftype, int verbose, variants *all, int nall ) { int i; for ( i=0; infields; ++i ) fields_add( info, modsin->tag[i].data, modsin->data[i].data, modsin->level[i] ); } int modsin_processf( fields *modsin, char *data, char *filename, long nref ) { xml top; xml_init( &top ); xml_tree( data, &top ); modsin_assembleref( &top, modsin ); xml_free( &top ); return 1; } static char * modsin_startptr( char *p ) { char *startptr; startptr = xml_findstart( p, "mods:mods" ); if ( startptr ) { /* set namespace if found */ xml_pns = modsns; } else { startptr = xml_findstart( p, "mods" ); if ( startptr ) xml_pns = NULL; } return startptr; } static char * modsin_endptr( char *p ) { return xml_findend( p, "mods" ); } int modsin_readf( FILE *fp, char *buf, int bufsize, int *bufpos, newstr *line, newstr *reference, int *fcharset ) { newstr tmp; int m, file_charset = CHARSET_UNKNOWN; char *startptr = NULL, *endptr = NULL; newstr_init( &tmp ); do { if ( line->data ) newstr_newstrcat( &tmp, line ); if ( tmp.data ) { m = xml_getencoding( &tmp ); if ( m!=CHARSET_UNKNOWN ) file_charset = m; startptr = modsin_startptr( tmp.data ); endptr = modsin_endptr( tmp.data ); } else startptr = endptr = NULL; newstr_empty( line ); if ( startptr && endptr ) { newstr_segcpy( reference, startptr, endptr ); newstr_strcpy( line, endptr ); } } while ( !endptr && newstr_fget( fp, buf, bufsize, bufpos, line ) ); newstr_free( &tmp ); *fcharset = file_charset; return ( reference->len > 0 ); } bibutils_4.12/lib/isitypes.c0000644000076400007640000002210711444072056016347 0ustar cdputnamcdputnam/* * isitypes.c * * Copyright (c) Chris Putnam 2004-2010 * * Program and source code released under the GPL * */ #include #include #include "is_ws.h" #include "fields.h" #include "reftypes.h" static lookups article[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "AF", "AUTHOR", PERSON, LEVEL_MAIN }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "SO", "TITLE", TITLE, LEVEL_HOST }, /* full journal name */ { "JI", "SHORTTITLE",TITLE, LEVEL_HOST }, /* abbr journal name */ { "J9", "SHORTTITLE",TITLE, LEVEL_HOST }, /* 29char journal name */ { "PU", "PUBLISHER", SIMPLE, LEVEL_HOST }, { "PI", "ADDRESS", SIMPLE, LEVEL_HOST }, /* publisher city */ { "C1", "ADDRESS", SIMPLE, LEVEL_MAIN }, /* author address */ { "PA", "ADDRESS", SIMPLE, LEVEL_HOST }, /* publisher address */ { "RP", "REPRINTADDRESS", SIMPLE, LEVEL_MAIN }, { "PY", "PARTYEAR", SIMPLE, LEVEL_MAIN }, { "PD", "PARTMONTH", SIMPLE, LEVEL_MAIN }, { "VL", "VOLUME", SIMPLE, LEVEL_MAIN }, { "AR", "ARTICLENUMBER", SIMPLE, LEVEL_MAIN }, /* AR=article number that Phys. Rev. B uses instead of page numbers */ { "BP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "PG", "TOTALPAGES", SIMPLE, LEVEL_MAIN }, { "IS", "ISSUE", SIMPLE, LEVEL_MAIN }, { "SN", "SERIALNUMBER", SERIALNO, LEVEL_HOST }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "NF", "NOTES", SIMPLE, LEVEL_MAIN }, { "DE", "KEYWORD", ISI_KEYWORD, LEVEL_MAIN }, /* author keywords */ { "ID", "KEYWORD", ISI_KEYWORD, LEVEL_MAIN }, /* new ISI keywords */ { "LA", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "TC", "TIMESCITED", SIMPLE, LEVEL_MAIN }, { "NR", "NUMBERREFS", SIMPLE, LEVEL_MAIN }, { "CR", "CITEDREFS", SIMPLE, LEVEL_MAIN }, { "PT", " ", TYPE, LEVEL_HOST }, { "DT", "DOCUMENTTYPE", TYPE, LEVEL_MAIN }, { "GA", "ISIDELIVERNUM", SIMPLE, LEVEL_MAIN}, /*ISI document delivery number */ { "UT", "ISIREFNUM", SIMPLE, LEVEL_MAIN }, /* ISI unique article identifer */ { "DI", "DOI", SIMPLE, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|ARTICLE", ALWAYS, LEVEL_MAIN }, { " ", "ISSUANCE|continuing", ALWAYS, LEVEL_HOST }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|periodical", ALWAYS, LEVEL_HOST }, { " ", "GENRE|academic journal", ALWAYS, LEVEL_HOST } }; static lookups book[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "AF", "AUTHOR", PERSON, LEVEL_MAIN }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "SO", "TITLE", TITLE, LEVEL_HOST }, /* full journal name */ { "JI", "SHORTTITLE",TITLE, LEVEL_HOST }, /* abbr journal name */ { "J9", "SHORTTITLE",TITLE, LEVEL_HOST }, /* 29char journal name */ { "PU", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "PI", "ADDRESS", SIMPLE, LEVEL_MAIN }, /* publisher city */ { "C1", "ADDRESS", SIMPLE, LEVEL_MAIN }, /* author address */ { "PA", "ADDRESS", SIMPLE, LEVEL_MAIN }, /* publisher address */ { "RP", "REPRINTADDRESS", SIMPLE, LEVEL_MAIN }, { "PY", "YEAR", SIMPLE, LEVEL_MAIN }, { "PD", "MONTH", SIMPLE, LEVEL_MAIN }, { "VL", "VOLUME", SIMPLE, LEVEL_MAIN }, { "BP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "PG", "TOTALPAGES", SIMPLE, LEVEL_MAIN }, { "IS", "ISSUE", SIMPLE, LEVEL_MAIN }, { "SN", "SERIALNUMBER", SERIALNO, LEVEL_HOST }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "NF", "NOTES", SIMPLE, LEVEL_MAIN }, { "DE", "KEYWORD", ISI_KEYWORD, LEVEL_MAIN }, /* author keywords */ { "ID", "KEYWORD", ISI_KEYWORD, LEVEL_MAIN }, /* new ISI keywords */ { "LA", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "TC", "TIMESCITED", SIMPLE, LEVEL_MAIN }, { "NR", "NUMBERREFS", SIMPLE, LEVEL_MAIN }, { "CR", "CITEDREFS", SIMPLE, LEVEL_MAIN }, { "PT", " ", TYPE, LEVEL_MAIN }, { "DT", "DOCUMENTTYPE", TYPE, LEVEL_MAIN }, { "GA", "ISIDELIVERNUM", SIMPLE, LEVEL_MAIN}, /*ISI document delivery number */ { "UT", "ISIREFNUM", SIMPLE, LEVEL_MAIN }, /* ISI unique article identifer */ { "PT", " ", TYPE, LEVEL_HOST }, { "DI", "DOI", SIMPLE, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|BOOK", ALWAYS, LEVEL_MAIN }, { " ", "ISSUANCE|monographic", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|book", ALWAYS, LEVEL_MAIN } }; static lookups inbook[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "AF", "AUTHOR", PERSON, LEVEL_MAIN }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "SO", "TITLE", TITLE, LEVEL_HOST }, /* full journal name */ { "JI", "SHORTTITLE",TITLE, LEVEL_HOST }, /* abbr journal name */ { "J9", "SHORTTITLE",TITLE, LEVEL_HOST }, /* 29char journal name */ { "PU", "PUBLISHER", SIMPLE, LEVEL_HOST }, { "PI", "ADDRESS", SIMPLE, LEVEL_HOST }, /* publisher city */ { "C1", "ADDRESS", SIMPLE, LEVEL_MAIN }, /* author address */ { "PA", "ADDRESS", SIMPLE, LEVEL_HOST }, /* publisher address */ { "RP", "REPRINTADDRESS", SIMPLE, LEVEL_MAIN }, { "PY", "PARTYEAR", SIMPLE, LEVEL_MAIN }, { "PD", "PARTMONTH", SIMPLE, LEVEL_MAIN }, { "VL", "VOLUME", SIMPLE, LEVEL_MAIN }, { "BP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "PG", "TOTALPAGES", SIMPLE, LEVEL_HOST }, { "IS", "ISSUE", SIMPLE, LEVEL_MAIN }, { "SN", "SERIALNUMBER", SERIALNO, LEVEL_HOST }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "NF", "NOTES", SIMPLE, LEVEL_MAIN }, { "DE", "KEYWORD", ISI_KEYWORD, LEVEL_MAIN }, /* author keywords */ { "ID", "KEYWORD", ISI_KEYWORD, LEVEL_MAIN }, /* new ISI keywords */ { "LA", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "TC", "TIMESCITED", SIMPLE, LEVEL_MAIN }, { "NR", "NUMBERREFS", SIMPLE, LEVEL_MAIN }, { "CR", "CITEDREFS", SIMPLE, LEVEL_MAIN }, { "PT", " ", TYPE, LEVEL_HOST }, { "DT", "DOCUMENTTYPE", TYPE, LEVEL_MAIN }, { "GA", "ISIDELIVERNUM", SIMPLE, LEVEL_MAIN}, /*ISI document delivery number */ { "UT", "ISIREFNUM", SIMPLE, LEVEL_MAIN }, /* ISI unique article identifer */ { "DI", "DOI", SIMPLE, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|INBOOK", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "ISSUANCE|monographic", ALWAYS, LEVEL_HOST }, { " ", "GENRE|book", ALWAYS, LEVEL_HOST } }; static lookups bookinseries[] = { { "AU", "AUTHOR", PERSON, LEVEL_MAIN }, { "AF", "AUTHOR", PERSON, LEVEL_MAIN }, { "TI", "TITLE", TITLE, LEVEL_MAIN }, { "SO", "TITLE", TITLE, LEVEL_MAIN }, { "SE", "TITLE", TITLE, LEVEL_HOST }, { "BS", "SUBTITLE", TITLE, LEVEL_HOST }, { "JI", "SHORTTITLE",TITLE, LEVEL_HOST }, /* abbr journal name */ { "J9", "SHORTTITLE",TITLE, LEVEL_HOST }, /* 29char journal name */ { "PU", "PUBLISHER", SIMPLE, LEVEL_HOST }, { "PI", "ADDRESS", SIMPLE, LEVEL_HOST }, /* publisher city */ { "C1", "ADDRESS", SIMPLE, LEVEL_MAIN }, /* author address */ { "PA", "ADDRESS", SIMPLE, LEVEL_HOST }, /* publisher address */ { "RP", "REPRINTADDRESS", SIMPLE, LEVEL_MAIN }, { "PY", "PARTYEAR", SIMPLE, LEVEL_MAIN }, { "PD", "PARTMONTH", SIMPLE, LEVEL_MAIN }, { "VL", "VOLUME", SIMPLE, LEVEL_MAIN }, { "BP", "PAGESTART", SIMPLE, LEVEL_MAIN }, { "EP", "PAGEEND", SIMPLE, LEVEL_MAIN }, { "PG", "TOTALPAGES", SIMPLE, LEVEL_MAIN }, { "IS", "ISSUE", SIMPLE, LEVEL_MAIN }, { "SN", "SERIALNUMBER", SERIALNO, LEVEL_HOST }, { "AB", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "NF", "NOTES", SIMPLE, LEVEL_MAIN }, { "DE", "KEYWORD", ISI_KEYWORD, LEVEL_MAIN }, /* author keywords */ { "ID", "KEYWORD", ISI_KEYWORD, LEVEL_MAIN }, /* new ISI keywords */ { "LA", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "TC", "TIMESCITED", SIMPLE, LEVEL_MAIN }, { "NR", "NUMBERREFS", SIMPLE, LEVEL_MAIN }, { "CR", "CITEDREFS", SIMPLE, LEVEL_MAIN }, { "PT", " ", TYPE, LEVEL_HOST }, { "DT", "DOCUMENTTYPE", TYPE, LEVEL_MAIN }, { "GA", "ISIDELIVERNUM", SIMPLE, LEVEL_MAIN}, /*ISI document delivery number */ { "UT", "ISIREFNUM", SIMPLE, LEVEL_MAIN }, /* ISI unique article identifer */ { "DI", "DOI", SIMPLE, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|INCOLLECTION", ALWAYS, LEVEL_MAIN }, { " ", "ISSUANCE|monographic", ALWAYS, LEVEL_HOST }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|collection", ALWAYS, LEVEL_MAIN } }; #define ORIG(a) ( &(a[0]) ) #define SIZE(a) ( sizeof( a ) / sizeof( lookups ) ) #define REFTYPE(a,b) { a, ORIG(b), SIZE(b) } variants isi_all[] = { REFTYPE( "Journal", article ), REFTYPE( "J", article ), REFTYPE( "Book", book ), REFTYPE( "B", book ), REFTYPE( "Chapter", inbook ), REFTYPE( "S", bookinseries ), }; int isi_nall = sizeof( isi_all ) / sizeof( variants ); bibutils_4.12/lib/isiout.c0000644000076400007640000002031011445514201015776 0ustar cdputnamcdputnam/* * isiout.c * * Copyright (c) Chris Putnam 2008-2010 * * Source code released under the GPL */ #include #include #include #include #include "utf8.h" #include "newstr.h" #include "strsearch.h" #include "fields.h" #include "bibutils.h" #include "isiout.h" void isiout_initparams( param *p, const char *progname ) { p->writeformat = BIBL_ISIOUT; p->format_opts = 0; p->charsetout = BIBL_CHARSET_DEFAULT; p->charsetout_src = BIBL_SRC_DEFAULT; p->latexout = 0; p->utf8out = 0; p->utf8bom = 0; p->xmlout = 0; p->nosplittitle = 0; p->verbose = 0; p->addcount = 0; p->singlerefperfile = 0; p->headerf = isiout_writeheader; p->footerf = NULL; p->writef = isiout_write; } enum { TYPE_UNKNOWN = 0, TYPE_ARTICLE = 1, TYPE_INBOOK = 2, TYPE_BOOK = 3, }; static void output_type( FILE *fp, int type ) { fprintf( fp, "PT " ); if ( type==TYPE_ARTICLE ) fprintf( fp, "Journal" ); else if ( type==TYPE_INBOOK ) fprintf( fp, "Chapter" ); else if ( type==TYPE_BOOK ) fprintf( fp, "Book" ); else fprintf( fp, "Unknown" ); fprintf( fp, "\n" ); } static int get_type( fields *info ) { char *tag, *data; int type = TYPE_UNKNOWN, i; for ( i=0; infields; ++i ) { tag = info->tag[i].data; if ( strcasecmp( tag, "GENRE" ) && strcasecmp( tag, "NGENRE") ) continue; data = info->data[i].data; if ( !strcasecmp( data, "periodical" ) || !strcasecmp( data, "academic journal" ) ) type = TYPE_ARTICLE; else if ( !strcasecmp( data, "book" ) ) { if ( info->level[i]==0 ) type=TYPE_BOOK; else type=TYPE_INBOOK; } } return type; } static void output_title( FILE *fp, fields *info, char *isitag, int level ) { int n1 = fields_find( info, "TITLE", level ); int n2 = fields_find( info, "SUBTITLE", level ); if ( n1!=-1 ) { fprintf( fp, "%s %s", isitag, info->data[n1].data ); if ( n2!=-1 ) { if ( info->data[n1].data[info->data[n1].len]!='?' ) fprintf( fp, ": " ); else fprintf( fp, " " ); fprintf( fp, "%s", info->data[n2].data ); } fprintf( fp, "\n" ); } } static void output_abbrtitle( FILE *fp, fields *info, char *isitag, int level ) { int n1 = fields_find( info, "SHORTTITLE", level ); int n2 = fields_find( info, "SHORTSUBTITLE", level ); if ( n1!=-1 ) { fprintf( fp, "%s %s", isitag, info->data[n1].data ); if ( n2!=-1 ){ if ( info->data[n1].data[info->data[n1].len]!='?' ) fprintf( fp, ": " ); else fprintf( fp, " " ); fprintf( fp, "%s", info->data[n2].data ); } fprintf( fp, "\n" ); } } static void output_person( FILE *fp, char *name ) { int n = 0, nchars = 0; char *p = name; while ( *p ) { if ( *p=='|' ) { n++; nchars=0; } else { if ( n==1 && nchars<2 ) fprintf( fp, ", " ); if ( n==0 || (n>0 && nchars<2) ) { fprintf( fp, "%c", *p ); } } nchars++; p++; } } static void output_keywords( FILE *fp, fields *info ) { int n = 0, i; for ( i=0; infields; ++i ) { if ( strcasecmp( info->tag[i].data, "KEYWORD" ) ) continue; if ( n==0 ) fprintf( fp, "DE " ); if ( n>0 ) fprintf( fp, "; " ); fprintf( fp, "%s", info->data[i].data ); n++; } if ( n ) fprintf( fp, "\n" ); } static void output_people( FILE *fp, fields *info, char *tag, char *isitag, int level ) { int n = 0, i; for ( i=0; infields; ++i ) { if ( strcasecmp( info->tag[i].data, tag ) ) continue; if ( level!=-1 && info->level[i]!=level ) continue; if ( n==0 ) { fprintf( fp, "%s ", isitag ); } else { fprintf( fp, " " ); } output_person( fp, info->data[i].data ); fprintf( fp, "\n" ); n++; } } static void output_easy( FILE *fp, fields *info, char *tag, char *isitag, int level ) { int n = fields_find( info, tag, level ); if ( n!=-1 ) fprintf( fp, "%s %s\n", isitag, info->data[n].data ); } static void output_easyall( FILE *fp, fields *info, char *tag, char *isitag, int level ) { int i; for ( i=0; infields; ++i ) { if ( level!=-1 && info->level[i]!=level ) continue; if ( strcasecmp( info->tag[i].data, tag ) ) continue; fprintf( fp, "%s %s\n", isitag, info->data[i].data ); } } static void output_date( FILE *fp, fields *info ) { int n; n = fields_find( info, "PARTMONTH", -1 ); if ( n==-1 ) n = fields_find( info, "MONTH", -1 ); if ( n!=-1 ) fprintf( fp, "%s %s\n", "PD", info->data[n].data ); n = fields_find( info, "PARTYEAR", -1 ); if ( n==-1 ) n = fields_find( info, "YEAR", -1 ); if ( n!=-1 ) fprintf( fp, "%s %s\n", "PY", info->data[n].data ); } static void output_verbose( fields *info, unsigned long refnum ) { int i; fprintf( stderr, "REF #%lu----\n", refnum+1 ); for ( i=0; infields; ++i ) { fprintf( stderr, "\t'%s'\t'%s'\t%d\n", info->tag[i].data, info->data[i].data, info->level[i]); } } void isiout_write( fields *info, FILE *fp, param *p, unsigned long refnum ) { int type = get_type( info ); if ( p->format_opts & BIBL_FORMAT_VERBOSE ) output_verbose( info, refnum ); output_type( fp, type ); output_people( fp, info, "AUTHOR", "AU", 0 ); output_easyall( fp, info, "AUTHOR:CORP", "AU", 0 ); output_easyall( fp, info, "AUTHOR:ASIS", "AU", 0 ); /* output_people( fp, info, "AUTHOR", "A2", 1 ); output_people( fp, info, "AUTHOR:CORP", "A2", 1 ); output_people( fp, info, "AUTHOR:ASIS", "A2", 1 ); output_people( fp, info, "AUTHOR", "A3", 2 ); output_people( fp, info, "AUTHOR:CORP", "A3", 2 ); output_people( fp, info, "AUTHOR:ASIS", "A3", 2 ); output_people( fp, info, "EDITOR", "ED", -1 ); output_people( fp, info, "EDITOR:CORP", "ED", -1 ); output_people( fp, info, "EDITOR:ASIS", "ED", -1 );*/ /* output_date( fp, info, refnum );*/ output_title( fp, info, "TI", 0 ); if ( type==TYPE_ARTICLE ) { output_title( fp, info, "SO", 1 ); output_abbrtitle( fp, info, "JI", 1 ); } else output_title( fp, info, "BT", 1 ); output_date( fp, info ); /* output_easy( fp, info, "PARTMONTH", "PD", -1 ); output_easy( fp, info, "PARTYEAR", "PY", -1 );*/ output_easy( fp, info, "PAGESTART", "BP", -1 ); output_easy( fp, info, "PAGEEND", "EP", -1 ); output_easy( fp, info, "ARTICLENUMBER", "AR", -1 ); /* output article number as pages */ output_easy( fp, info, "TOTALPAGES","PG", -1 ); output_easy( fp, info, "VOLUME", "VL", -1 ); output_easy( fp, info, "ISSUE", "IS", -1 ); output_easy( fp, info, "NUMBER", "IS", -1 ); output_easy( fp, info, "DOI", "DI", -1 ); output_easy( fp, info, "ISIREFNUM", "UT", -1 ); output_easy( fp, info, "LANGUAGE", "LA", -1 ); output_easy( fp, info, "ISIDELIVERNUM", "GA", -1 ); output_keywords( fp, info ); output_easy( fp, info, "ABSTRACT", "AB", -1 ); output_easy( fp, info, "TIMESCITED", "TC", -1 ); output_easy( fp, info, "NUMBERREFS", "NR", -1 ); output_easy( fp, info, "CITEDREFS", "CR", -1 ); output_easy( fp, info, "ADDRESS", "PI", -1 ); /* output_easy( fp, info, "PUBLISHER", "PB", -1 ); output_easy( fp, info, "DEGREEGRANTOR", "PB", -1 ); output_easy( fp, info, "ADDRESS", "CY", -1 ); output_easy( fp, info, "ABSTRACT", "AB", -1 ); output_easy( fp, info, "ISSN", "SN", -1 ); output_easy( fp, info, "ISBN", "SN", -1 ); output_easyall( fp, info, "URL", "UR", -1 ); output_easyall( fp, info, "FILEATTACH", "UR", -1 ); output_pubmed( fp, info, refnum ); output_easyall( fp, info, "NOTES", "N1", -1 ); output_easyall( fp, info, "REFNUM", "ID", -1 );*/ fprintf( fp, "ER\n\n" ); fflush( fp ); } void isiout_writeheader( FILE *outptr, param *p ) { if ( p->utf8bom ) utf8_writebom( outptr ); } bibutils_4.12/lib/doi.c0000644000076400007640000000602011444072056015245 0ustar cdputnamcdputnam/* * doi.c * * doi_to_url() * Handle outputing DOI as a URL (Endnote and RIS formats) * 1) Append http://dx.doi.org as necessary * 2) Check for overlap with pre-existing URL for the DOI * * is_doi() * Check for DOI buried in another field. * * Copyright (c) Chris Putnam 2008-2010 * * Source code released under the GPL */ #include #include #include #include #include "newstr.h" #include "fields.h" static void construct_url( char *prefix, newstr *id, newstr *id_url ) { if ( !strncasecmp( id->data, "http:", 5 ) ) newstr_newstrcpy( id_url, id ); else { newstr_strcpy( id_url, prefix ); if ( id->data[0]!='/' ) newstr_addchar( id_url, '/' ); newstr_newstrcat( id_url, id ); } } static int url_exists( fields *info, char *urltag, newstr *doi_url ) { int i, found = 0; if ( urltag ) { for ( i=0; infields && !found; ++i ) { if ( strcmp( info->tag[i].data, urltag ) ) continue; if ( !strcmp( info->data[i].data, doi_url->data ) ) found=1; } } return found; } void doi_to_url( fields *info, int n, char *urltag, newstr *doi_url ) { newstr_empty( doi_url ); construct_url( "http://dx.doi.org", &(info->data[n]), doi_url ); if ( url_exists( info, urltag, doi_url ) ) newstr_empty( doi_url ); } void jstor_to_url( fields *info, int n, char *urltag, newstr *jstor_url ) { newstr_empty( jstor_url ); construct_url( "http://www.jstor.org/stable", &(info->data[n]), jstor_url ); if ( url_exists( info, urltag, jstor_url ) ) newstr_empty( jstor_url ); } void pmid_to_url( fields *info, int n, char *urltag, newstr *pmid_url ) { newstr_empty( pmid_url ); construct_url( "http://www.ncbi.nlm.nih.gov/pubmed", &(info->data[n]), pmid_url ); if ( url_exists( info, urltag, pmid_url ) ) newstr_empty( pmid_url ); } void arxiv_to_url( fields *info, int n, char *urltag, newstr *arxiv_url ) { newstr_empty( arxiv_url ); construct_url( "http://arxiv.org/abs", &(info->data[n]), arxiv_url ); if ( url_exists( info, urltag, arxiv_url ) ) newstr_empty( arxiv_url ); } /* Rules for the pattern: * '#' = number * isalpha() = match precisely (matchcase==1) or match regardless of case * (matchcase==0) * all others must match precisely */ static int string_pattern( char *s, char *pattern, int matchcase ) { int patlen, match, i; patlen = strlen( pattern ); if ( strlen( s ) < patlen ) return 0; /* too short */ for ( i=0; i #include "bibutils.h" extern void adsout_write( fields *info, FILE *fp, param *p, unsigned long refnum ); extern void adsout_writeheader( FILE *outptr, param *p ); extern void adsout_initparams( param *p, const char *progname ); #endif bibutils_4.12/lib/latex.c0000644000076400007640000005024311444072056015615 0ustar cdputnamcdputnam/* * latex.c * * convert between latex special chars and unicode * * Copyright (c) Chris Putnam 2004-2010 * * Source code released under the GPL * */ #include #include #include "latex.h" struct latex_chars { unsigned int unicode; char *bib1, *bib2, *bib3; }; static struct latex_chars latex_chars[] = { { 35, "\\#", "", "" }, /* Number/pound/hash sign */ { 36, "\\$", "", "" }, /* Dollar Sign */ { 37, "\\%", "", "" }, /* Percent Sign */ { 38, "\\&", "", "" }, /* Ampersand */ { 92, "{\\backslash}", "\\backslash", "" }, /* Backslash */ { 123, "\\{", "{\\textbraceleft}", "\\textbraceleft" }, /* Left Curly Bracket */ { 125, "\\}", "{\\textbraceright}", "\\textbraceright" }, /* Right Curly Bracket */ { 95, "\\_", "", "" }, /* Underscore alone indicates subscript */ { 176, "{\\textdegree}", "\\textdegree", "^\\circ" }, /* Degree sign */ { 32, "~", "\\ ", "" }, /* Tilde is a sticky space */ { 126, "{\\textasciitilde}", "\\textasciitilde", "\\~{}" }, /* How to get a tilde in latex */ /* This is a cheat, should use "\verb" */ /* Need same for ^ character */ /* Latin Capital A */ { 192, "{\\`A}", "\\`{A}", "\\`A" }, /* with grave */ { 193, "{\\'A}", "\\'{A}", "\\'A" }, /* with acute */ { 194, "{\\^A}", "\\^{A}", "\\^A" }, /* with circumflex */ { 195, "{\\~A}", "\\~{A}", "\\~A" }, /* with tilde */ { 196, "{\\\"A}", "\\\"{A}", "\\\"A" }, /* with diuresis */ { 197, "{\\AA}", "", "" }, /* with ring above */ /* Latin Small a */ { 224, "{\\`a}", "\\`{a}", "\\`a" }, /* with grave */ { 225, "{\\'a}", "\\'{a}", "\\'a" }, /* with acute */ { 226, "{\\^a}", "\\^{a}", "\\^a" }, /* with circumflex */ { 227, "{\\~a}", "\\~{a}", "\\~a" }, /* with tilde */ { 228, "{\\\"a}", "\\\"{a}", "\\\"a" }, /* with diuresis */ { 229, "{\\aa}", "", "" }, /* with ring above */ { 198, "{\\AE}", "\\AE", "" }, /* Latin Capital AE */ { 230, "{\\ae}", "\\ae", "" }, /* Latin Small ae */ { 199, "{\\c{C}}","\\c{C}", "" }, /* Latin Capital C with cedilla */ { 231, "{\\c{c}}","\\c{c}", "" }, /* Latin small c with cedilla*/ { 262, "{\\'C}", "\\'{C}", "\\'C" }, /* Latin Capital C with acute */ { 263, "{\\'c}", "\\'{c}", "\\'c" }, /* Latin small c with acute */ /* Latin Capital E */ { 200, "{\\`E}", "\\`{E}", "\\`E" }, /* with grave */ { 201, "{\\'E}", "\\'{E}", "\\'E" }, /* with acute */ { 202, "{\\^E}", "\\^{E}", "\\^E" }, /* with circumflex */ { 203, "{\\\"E}", "\\\"{E}", "\\\"E" }, /* with diuresis */ /* Latin Small e */ { 232, "{\\`e}", "\\`{e}", "\\`e" }, /* with grave */ { 233, "{\\'e}", "\\'{e}", "\\'e" }, /* with acute */ { 234, "{\\^e}", "\\^{e}", "\\^e" }, /* with circumflex */ { 235, "{\\\"e}", "\\\"{e}", "\\\"e" }, /* with diuresis */ /* Latin Capital i */ { 204, "{\\`I}", "\\`{I}", "\\`I" }, /* with grave */ { 205, "{\\'I}", "\\'{I}", "\\'I" }, /* with acute */ { 206, "{\\^I}", "\\^{I}", "\\^I" }, /* with circumflex */ { 207, "{\\\"I}", "\\\"{I}", "\\\"I" }, /* with diuresis */ /* Latin Small i */ { 236, "{\\`i}", "\\`{i}", "\\`i" }, /* with grave */ { 237, "{\\'i}", "\\'{i}", "\\'i" }, /* with acute */ { 238, "{\\^i}", "\\^{i}", "\\^i" }, /* with circumflex */ { 239, "{\\\"i}", "\\\"{i}", "\\\"i" }, /* with diuresis */ /* Latex \i has no dot on "i"*/ { 236, "{\\`\\i}", "\\`{\\i}", "\\`\\i" }, /* with grave */ { 237, "{\\'\\i}", "\\'{\\i}", "\\'\\i" }, /* with acute */ { 238, "{\\^\\i}", "\\^{\\i}", "\\^\\i" }, /* with circumflex */ { 239, "{\\\"\\i}", "\\\"{\\i}", "\\\"\\i" }, /* with diuresis */ { 209, "{\\~N}", "\\~{N}", "\\~N" }, /* Latin Capital N with tilde */ { 327, "{\\vN}", "\\v{N}", "\\vN" }, /* Latin Capital N with caron */ { 241, "{\\~n}", "\\~{n}", "\\~n" }, /* Latin Small n with tilde */ { 328, "{\\vn}", "\\v{n}", "\\vn" }, /* Latin Small n with caron */ /* Latin Capital O */ { 210, "{\\`O}", "\\`{O}", "\\`O" }, /* with grave */ { 211, "{\\'O}", "\\'{O}", "\\'O" }, /* with acute */ { 212, "{\\^O}", "\\^{O}", "\\^O" }, /* with circumflex */ { 213, "{\\~O}", "\\~{O}", "\\~O" }, /* with tilde */ { 214, "{\\\"O}", "\\\"{O}", "\\\"O" }, /* with diaeresis */ { 216, "{\\O}", "\\O", "" }, /* with stroke */ /* Latin Small o */ { 242, "{\\`o}", "\\`{o}", "\\`o" }, /* with grave */ { 243, "{\\'o}", "\\'{o}", "\\'o" }, /* with acute */ { 244, "{\\^o}", "\\^{o}", "\\^o" }, /* with circumflex */ { 245, "{\\~o}", "\\~{o}", "\\~o" }, /* with tilde */ { 246, "{\\\"o}", "\\\"{o}", "\\\"o" }, /* with diaeresis */ { 248, "{\\o}", "\\o", "" }, /* with stroke */ { 338, "{\\OE}", "\\OE", "" }, /* Latin Capital OE */ { 339, "{\\oe}", "\\oe", "" }, /* Latin Small oe */ { 341, "{\\vR}", "\\v{R}", "\\vR" }, /* Latin Capital R with caron */ { 342, "{\\vr}", "\\v{r}", "\\vr" }, /* Latin Small r with caron */ { 352, "{\\vS}", "\\v{S}", "\\vS" }, /* Latin Capital S with caron */ { 353, "{\\vs}", "\\v{s}", "\\vs" }, /* Latin Small s with caron */ { 223, "{\\ss}", "\\ss", "" }, /* German sz ligature, "sharp s" */ /* Latin Capital U */ { 217, "{\\`U}", "\\`{U}", "\\`U" }, /* with grave */ { 218, "{\\'U}", "\\'{U}", "\\'U" }, /* with acute */ { 219, "{\\^U}", "\\^{U}", "\\^U" }, /* with circumflex */ { 220, "{\\\"U}", "\\\"{U}", "\\\"U" }, /* with diaeresis */ /* Latin Small u */ { 249, "{\\`u}", "\\`{u}", "\\`u" }, /* with grave */ { 250, "{\\'u}", "\\'{u}", "\\'u" }, /* with acute */ { 251, "{\\^u}", "\\^{u}", "\\^u" }, /* with circumflex */ { 252, "{\\\"u}", "\\\"{u}", "\\\"u" }, /* with diaeresis */ /* Latin Capital Y */ { 221, "{\\'Y}", "\\'{Y}", "\\'Y" }, /* with acute */ { 376, "{\\\"Y}", "\\\"{Y}", "\\\"Y" }, /* with diaeresis */ /* Latin Small y */ { 253, "{\\'y}", "\\'{y}", "\\'y" }, /* with acute */ { 255, "{\\\"y}", "\\\"{y}", "\\\"y" }, /* with diaeresis */ /* Hacek-containing */ { 269, "{\\v c}", "{\\v{c}}", "\\v{c}" }, /* c with a hacek */ /* Needs to be before \nu */ { 8203, "$\\null$", "\\null", "" }, /* No space ​ */ { 913, "$\\Alpha$", "\\Alpha", "" }, /*GREEKCAPITALLETTERALPHA*/ /* 902 = GREEKCAPITALLETTERALPHAWITHTONOS*/ { 914, "$\\Beta$", "\\Beta", "" }, /*GREEKCAPITALLETTERBETA*/ { 915, "$\\Gamma$", "\\Gamma", "" }, /*GREEKCAPITALLETTERGAMMA*/ { 916, "$\\Delta$", "\\Delta", "" }, /*GREEKCAPITALLETTERDELTA*/ { 917, "$\\Epsilon$", "\\Epsilon", "" }, /*GREEKCAPITALLETTEREPSILON*/ /* 904 = GREEKCAPITALLETTEREPSILONWITHTONOS*/ { 918, "$\\Zeta$", "\\Zeta", "" }, /*GREEKCAPITALLETTERZETA*/ { 919, "$\\Eta$", "\\Eta", "" }, /*GREEKCAPITALLETTERETA*/ /* 905 = GREEKCAPITALLETTERETAWITHTONOS*/ { 920, "$\\Theta$", "\\Theta", "" }, /*GREEKCAPITALLETTERTHETA*/ { 921, "$\\Iota$", "\\Iota", "" }, /*GREEKCAPITALLETTERIOTA*/ /* 938 = GREEKCAPITALLETTERIOTAWITHDIALYTIKA*/ /* 906 = GREEKCAPITALLETTERIOTAWITHTONOS*/ { 922, "$\\Kappa$", "\\Kappa", "" }, /*GREEKCAPITALLETTERKAPPA*/ { 923, "$\\Lambda$", "\\Lambda", "" }, /*GREEKCAPITALLETTERLAMDA*/ { 924, "$\\Mu$", "\\Mu", "" }, /*GREEKCAPITALLETTERMU*/ { 925, "$\\Nu$", "\\Nu", "" }, /*GREEKCAPITALLETTERNU*/ { 926, "$\\Xi$", "\\Xi", "" }, /*GREEKCAPITALLETTERXI*/ { 927, "$\\Omicron$", "\\Omicron", "" }, /*GREEKCAPITALLETTEROMICRON*/ /* 908 = GREEKCAPITALLETTEROMICRONWITHTONOS*/ { 928, "$\\Pi$", "\\Pi", "" }, /*GREEKCAPITALLETTERPI*/ { 929, "$\\Rho$", "\\Rho", "" }, /*GREEKCAPITALLETTERRHO*/ { 931, "$\\Sigma$", "\\Sigma", "" }, /*GREEKCAPITALLETTERSIGMA*/ { 932, "$\\Tau$", "\\Tau", "" }, /*GREEKCAPITALLETTERTAU*/ { 933, "$\\Upsilon$", "\\Upsilon", "" }, /*GREEKCAPITALLETTERUPSILON*/ /* 939 = GREEKCAPITALLETTERUPSILONWITHDIALYTIKA*/ /* 910 = GREEKCAPITALLETTERUPSILONWITHTONOS*/ { 934, "$\\Phi$", "\\Phi", "" }, /*GREEKCAPITALLETTERPHI*/ { 935, "$\\Chi$", "\\Chi", "" }, /*GREEKCAPITALLETTERCHI*/ { 936, "$\\Psi$", "\\Psi", "" }, /*GREEKCAPITALLETTERPSI*/ { 937, "$\\Omega$", "\\Omega", "" }, /*GREEKCAPITALLETTEROMEGA*/ /* 911, = GREEKCAPITALLETTEROMEGAWITHTONOS*/ { 945, "$\\alpha$", "\\alpha", "" }, /*GREEKSMALLLETTERALPHA*/ /* 940 = GREEKSMALLLETTERALPHAWITHTONOS*/ { 946, "$\\beta$", "\\beta", "" }, /*GREEKSMALLLETTERBETA*/ { 968, "$\\psi$", "\\psi", "" }, /*GREEKSMALLLETTERPSI*/ { 948, "$\\delta$", "\\delta", "" }, /*GREEKSMALLLETTERDELTA*/ { 949, "$\\epsilon$", "\\epsilon", "" }, /*GREEKSMALLLETTEREPSILON*/ /* 941 = GREEKSMALLLETTEREPSILONWITHTONOS*/ { 966, "$\\phi$", "\\phi", "" }, /*GREEKSMALLLETTERPHI*/ { 947, "$\\gamma$", "\\gamma", "" }, /*GREEKSMALLLETTERGAMMA*/ { 951, "$\\eta$", "\\eta", "" }, /*GREEKSMALLLETTERETA*/ /* 942 = GREEKSMALLLETTERETAWITHTONOS */ { 953, "$\\iota$", "\\iota", "" }, /*GREEKSMALLLETTERIOTA*/ /* 912 = GREEKSMALLLETTERIOTAWITHDIALYTIKAANDTONOS*/ /* 943 = GREEKSMALLLETTERIOTAWITHTONOS */ /* 970 = GREEKSMALLLETTERIOTAWITHDIALYTIKA */ { 958, "$\\xi$", "\\xi", "" }, /*GREEKSMALLLETTERXI*/ { 954, "$\\kappa$", "\\kappa" , "" }, /*GREEKSMALLLETTERKAPPA*/ { 955, "$\\lambda$", "\\lambda", "" }, /*GREEKSMALLLETTERLAMDA*/ { 956, "$\\mu$", "\\mu", "" }, /*GREEKSMALLLETTERMU*/ { 957, "$\\nu$", "\\nu", "" }, /*GREEKSMALLLETTERNU*/ { 959, "$\\omicron$", "\\omicron", "" }, /*GREEKSMALLLETTEROMICRON*/ /* 972 = GREEKSMALLLETTEROMICRONWITHTONOS*/ { 960, "$\\pi$", "\\pi", "" }, /*GREEKSMALLLETTERPI*/ { 961, "$\\rho$", "\\rho", "" }, /*GREEKSMALLLETTERRHO*/ { 963, "$\\sigma$", "\\sigma", "" }, /*GREEKSMALLLETTERSIGMA*/ { 964, "$\\tau$", "\\tau", "" }, /*GREEKSMALLLETTERTAU*/ { 952, "$\\theta$", "\\theta", "" }, /*GREEKSMALLLETTERTHETA*/ { 969, "$\\omega$", "\\omega", "" }, /*GREEKSMALLLETTEROMEGA*/ /* 974 = GREEKSMALLLETTEROMEGAWITHTONOS*/ { 967, "$\\chi$", "\\chi", "" }, /*GREEKSMALLLETTERCHI*/ { 965, "$\\upsilon$", "\\upsilon", "" }, /*GREEKSMALLLETTERUPSILON*/ /* 973 = GREEKSMALLLETTERUPSILONWITHTONOS*/ /* 971 = GREEKSMALLLETTERUPSILONWITHDIALYTIKA*/ /* 944 = GREEKSMALLLETTERUPSILONWITHDIALYTIKAANDTONOS*/ { 950, "$\\zeta$", "\\zeta", "" }, /*GREEKSMALLLETTERZETA*/ { 181, "{\\textmu}", "\\textmu", "$\\mu$" }, /* 181=micro sign, techically µ */ /* Make sure that these don't stomp on other latex things above */ { 8242, "{\\textasciiacutex}", "\\textasciiacutex", "$'$" }, /* Prime symbol ′ */ { 180, "{\\textasciiacute}", "\\textasciiacute", "\\'" }, /* acute accent ´ */ /* { 769, "\\'", "", "" },*/ /* Acute accent ́--apply to next char */ { 8243, "{\\textacutedbl}", "\\textacutedbl", "$''$" }, /* Double prime ″ */ { 8245, "{\\textasciigrave}", "\\textasciigrave", "\\`" }, /* Grave accent ‵ */ /* { 768, "\\`", "", "" },*/ /* Grave accent ̀--apply to next char */ { 8963, "{\\textasciicircum}", "\\textasciicircum", ""} , /* ⌃ */ { 184, "{\\textasciicedilla}", "\\textasciicedilla", "" }, /* cedilla ¸ */ { 168, "{\\textasciidieresis}", "\\textasciidieresis", "" }, /* dieresis ¨ */ { 175, "{\\textasciimacron}", "\\textasciimacron", "" }, /* macron ¯ */ { 8593, "{\\textuparrow}", "\\textuparrow", "" }, /* Up arrow ↑ */ { 8595, "{\\textdownarrow}", "\\textdownarrow", "" }, /* Down arrow ↓ */ { 8594, "{\\textrightarrow}", "\\textrightarrow", "" }, /* Right arrow → */ { 8592, "{\\textleftarrow}", "\\textleftarrow", "" }, /* Left arrow ← */ { 12296, "{\\textlangle}", "\\textlangle", "" } , /* L-angle 〈 */ { 12297, "{\\textrangle}", "\\textrangle", "" } , /* L-angle 〉 */ { 166, "{\\textbrokenbar}", "\\textbrokenbar", "" }, /* Broken vertical bar ¦ */ { 167, "{\\textsection}", "\\textsection", "" }, /* Section sign, § */ { 170, "{\\textordfeminine}", "\\textordfeminine", "" }, /* ª */ { 172, "{\\textlnot}", "\\textlnot", "" }, /* Lnot ¬ */ { 182, "{\\textparagraph}", "\\textparagraph", "" }, /* Paragraph sign ¶ */ { 183, "{\\textperiodcentered}", "\\textperiodcentered", "" }, /* Period-centered · */ { 186, "{\\textordmasculine}", "\\textordmasculine", "" }, /* º */ { 8214, "{\\textbardbl}", "\\textbardbl", "" }, /* Double vertical bar ‖ */ { 8224, "{\\textdagger}", "\\textdagger", "" }, /* Dagger † */ { 8225, "{\\textdaggerdbl}", "\\textdaggerdbl", "" },/* Double dagger &x2021; */ { 8226, "{\\textbullet}", "\\textbullet", "" }, /* Bullet • */ { 8494, "{\\textestimated}", "\\textestimated", "" },/* Estimated ℮ */ { 9526, "{\\textopenbullet}", "\\textopenbullet", "" },/* ┶ */ { 8220, "``", "{\\textquotedblleft}", "\\textquotedblleft" }, /* Opening double quote “ */ { 8221, "''", "{\\textquotedblright}","\\textquotedblright" }, /* Closing double quote ” */ { 8216, "`", "{\\textquoteleft}", "\\textquoteleft" }, /* Opening single quote ‘ */ { 8217, "'", "{\\textquoteright}", "\\textquoteright" }, /* Closing single quote ’ */ { 8261, "{\\textlquill}", "\\textlquill", "" }, /* Left quill ⁅ */ { 8262, "{\\textrquill}", "\\textrquill", "" }, /* Right quill ⁆ */ { 8212, "---", "{\\textemdash}", "\\textemdash" }, /* Em-dash — */ { 8211, "--", "{\\textendash}", "\\textendash" }, /* En-dash – */ { 8230, "\\ldots", "{\\textellipsis}", "\\textellipsis" }, /* Ellipsis … */ { 8194, "\\enspace", "\\hspace{.5em}", "" }, /* En-space   */ { 8195, "\\emspace", "\\hspace{1em}", "" }, /* Em-space   */ { 8201, "\\thinspace", "", ""}, /* Thin space   */ { 8203, "{\\textnospace}", "\\textnospace", "" }, /* No space ​ */ { 9251, "{\\textvisiblespace}", "\\textvisiblespace", "" }, /* Visible space ␣ */ { 215, "{\\texttimes}", "\\texttimes", "" }, /* Multiplication symbol × */ { 247, "{\\textdiv}", "\\textdiv", "" }, /* Division symbol ÷ */ { 177, "{\\textpm}", "\\textpm", "" }, /* Plus-minus character &#B1; */ { 189, "{\\textonehalf}", "\\textonehalf", "" }, /* Vulgar fraction one half ½ */ { 188, "{\\textonequarter}", "\\textonequarter", "" }, /* Vulgar fraction one quarter ½ */ { 190, "{\\textthreequarters}", "\\textthreequarters", "" }, /* Vulgar fraction three quarters ¾ */ { 8240, "{\\texttenthousand}", "\\texttenthousand", "" }, /* Per thousand sign ‰ */ { 8241, "{\\textpertenthousand}", "\\textpertenthousand", "" }, /* Per ten thousand sign ‱*/ { 8260, "{\\textfractionsolidus}", "\\textfractionsolidus", "" }, /* &x8260; */ { 8451, "{\\textcelcius}", "\\textcelcius", "" }, /* Celcicus ℃ */ { 8470, "{\\textnumero}", "\\textnumero", "" }, /* Numero symbol № */ { 8486, "{\\textohm}", "\\textohm", "" }, /* Ohm symbol Ω */ { 8487, "{\\textmho}", "\\textmho", "" }, /* Mho symbol ℧ */ { 8730, "{\\textsurd}", "\\textsurd", "" }, /* √ */ { 185, "{\\textonesuperior}", "\\textonesuperior", "" }, /*Superscript 1 ¹ */ { 178, "{\\texttwosuperior}", "\\texttwosuperior", "" }, /*Superscript 2 ² */ { 179, "{\\textthreesuperior}", "\\textthreesuperior", "" }, /*Superscript 3 ³ */ { 161, "{\\textexclamdown}", "\\textexclamdown", "" }, /* Inverted exclamation mark ¡*/ { 191, "{\\textquestiondown}", "\\textquestiondown", "" }, /* Inverted question mark ¿ */ { 162, "{\\textcent}", "\\textcent", "" }, /* Cent sign ¢ */ { 163, "{\\textsterling}", "\\textsterling", "\\pounds" }, /* Pound sign £ */ { 165, "{\\textyen}", "\\textyen", "" }, /* Yen sign ¥ */ { 402, "{\\textflorin}", "\\textflorin", "" }, /* Florin sign ƒ */ { 3647, "{\\textbaht}", "\\textbaht", "" }, /* Thai currency ฿ */ { 8355, "{\\textfrenchfranc}", "\\textfrenchfranc", "" }, /* French franc ₣ */ { 8356, "{\\textlira}", "\\textlira", "" }, /* Lira ₤ */ { 8358, "{\\textnaira}", "\\textnaria", "" }, /* Naira ₦ */ { 8361, "{\\textwon}", "\\textwon", "" }, /* ₩ */ { 8363, "{\\textdong}", "\\textdong", "" }, /* Vietnamese currency ₫ */ { 8364, "{\\texteuro}", "\\texteuro", "" }, /* Euro sign */ { 169, "{\\textcopyright}", "\\textcopyright", "" }, /* Copyright (C) © */ { 175, "{\\textregistered}", "\\textregistered", "" }, /* Registered sign (R) ¯*/ { 8482, "{\\texttrademark}", "\\texttrademark", "$^{TM}$" }, /* Trademark (TM) ™ */ { 8480, "{\\textservicemark}", "\\textservicemark", "$^{SM}$" }, /* Servicemark (SM) ℠*/ { 8471, "{\\textcircledP}", "\\textcircledP", "" }, /* Circled P ࡅ */ }; static int nlatex_chars = sizeof(latex_chars)/sizeof(struct latex_chars); /* latex2char() * * Use the latex_chars[] lookup table to determine if any character * is a special LaTeX code. Note that if it is, then the equivalency * is a Unicode character and we need to flag (by setting *unicode to 1) * that we know the output is Unicode. Otherwise, we set *unicode to 0, * meaning that the output is whatever character set was given to us * (which could be Unicode, but is not necessarily Unicode). * */ unsigned int latex2char( char *s, unsigned int *pos, int *unicode ) { unsigned int value; char *p, *q[3]; int i, j, l[3]; p = &( s[*pos] ); value = (unsigned char) *p; if ( value=='{' || value=='\\' || value=='~' || value=='$' || value=='\'' || value=='`' || value=='-' || value=='^' ) { for ( i=0; i #include #include #include #include #include "newstr.h" #include "latex.h" #include "entities.h" #include "utf8.h" #include "gb18030.h" #include "newstr_conv.h" #include "charsets.h" int get_charset( char *name ) { int i; if ( name==NULL ) return CHARSET_UNKNOWN; for ( i=0; i0 && i%5==0) || (i==nallcharconvert-1) ) fprintf( fp, "\n"); } } static void addentity( newstr *s, unsigned int ch ) { char buf[512]; sprintf( buf, "&#%d;", ch ); newstr_strcat( s, buf ); } /* These are the five minimal predefined entites in XML */ static int minimalxmlchars( newstr *s, unsigned int ch ) { if ( ch==34 ) { newstr_strcat( s, """ ); return 1; } else if ( ch==38 ) { newstr_strcat( s, "&" ); return 1; } else if ( ch==39 ) { newstr_strcat( s, "'" ); return 1; } else if ( ch==60 ) { newstr_strcat( s, "<" ); return 1; } else if ( ch==62 ) { newstr_strcat( s, ">" ); return 1; } return 0; } static void addxmlchar( newstr *s, unsigned int ch ) { if ( minimalxmlchars( s, ch ) ) return; if ( ch > 127 ) addentity( s, ch ); else newstr_addchar( s, ch ); } static void addutf8char( newstr *s, unsigned int ch, int xmlout, int utf8out ) { unsigned char code[6]; int nc, i; if ( xmlout ) { if ( minimalxmlchars( s, ch ) ) return; if ( ch > 127 && xmlout > 1 ) { addentity( s, ch ); return; } } nc = utf8_encode( ch, code ); for ( i=0; i 127 && xmlout > 1 ) { addentity( s, ch ); return; } } nc = gb18030_encode( ch, code ); for ( i=0; i 128 or by numeric xml entities such as "Ȗ" * then the output of decode_entity() and utf8_decode will necessarily * be in the charsetin character set. On the other hand, if it's a * fancy latex expression, such as "\alpha", or a non-numeric xml entity * like "&", then we'll get the Unicode value (because our lists only * keep the Unicode equivalent). * * The unicode variable indicates whether or not a Unicode-based listing * was used to convert the character (remember that charsetin could be * Unicode independently). * * The charset variable is used to keep track of what character set * the character is in prior to conversion. * */ static unsigned int get_unicode( newstr *s, unsigned int *pi, int charsetin, int latexin, int utf8in, int xmlin ) { unsigned int ch; int unicode = 0, err = 0; if ( xmlin && s->data[*pi]=='&' ) { ch = decode_entity( s->data, pi, &unicode, &err ); } else if ( charsetin==CHARSET_GB18030 ) { ch = gb18030_decode( s->data, pi ); unicode = 1; } else if ( latexin ) { /* Must handle bibtex files in UTF8/Unicode */ if ( utf8in && ( s->data[*pi] & 128 ) ) { ch = utf8_decode( s->data, pi ); unicode = 1; } else ch = latex2char( s->data, pi, &unicode ); } else if ( utf8in ) ch = utf8_decode( s->data, pi ); else { ch = (unsigned int) s->data[*pi]; *pi = *pi + 1; } if ( !unicode && charsetin!=CHARSET_UNICODE ) ch = lookupchar( charsetin, ch ); return ch; } static void write_unicode( newstr *s, unsigned int ch, int charsetout, int latexout, int utf8out, int xmlout ) { unsigned int c; if ( latexout ) { addlatexchar( s, ch, xmlout, utf8out ); } else if ( utf8out ) { addutf8char( s, ch, xmlout, utf8out ); } else if ( charsetout==CHARSET_GB18030 ) { addgb18030char( s, ch, xmlout, utf8out ); } else { c = lookupuni( charsetout, ch ); if ( xmlout ) addxmlchar( s, c ); else newstr_addchar( s, c ); } } void newstr_convert( newstr *s, int charsetin, int latexin, int utf8in, int xmlin, int charsetout, int latexout, int utf8out, int xmlout ) { unsigned int ch; newstr ns; unsigned int pos = 0; if ( s->len==0 ) return; newstr_init( &ns ); if ( charsetin==CHARSET_UNKNOWN ) charsetin = CHARSET_DEFAULT; if ( charsetout==CHARSET_UNKNOWN ) charsetout = CHARSET_DEFAULT; while ( s->data[pos] ) { ch = get_unicode( s, &pos, charsetin, latexin, utf8in, xmlin ); write_unicode( &ns, ch, charsetout, latexout, utf8out, xmlout ); } newstr_swapstrings( s, &ns ); newstr_free( &ns ); } bibutils_4.12/lib/bibutils.c0000644000076400007640000000354611445515667016334 0ustar cdputnamcdputnam/* * bibutils.c * * Copyright (c) Chris Putnam 2005-2010 * * Source code released under the GPL * */ #include #include #include "bibutils.h" /* bibl format includes */ #include "adsout.h" #include "biblatexin.h" #include "bibtexin.h" #include "bibtexout.h" #include "copacin.h" #include "ebiin.h" #include "endin.h" #include "endxmlin.h" #include "endout.h" #include "isiin.h" #include "isiout.h" #include "medin.h" #include "modsin.h" #include "modsout.h" #include "risin.h" #include "risout.h" #include "wordin.h" #include "wordout.h" void bibl_initparams( param *p, int readmode, int writemode, char *progname ) { switch ( readmode ) { case BIBL_BIBTEXIN: bibtexin_initparams( p, progname ); break; case BIBL_BIBLATEXIN: biblatexin_initparams( p, progname ); break; case BIBL_COPACIN: copacin_initparams( p, progname ); break; case BIBL_EBIIN: ebiin_initparams( p, progname ); break; case BIBL_ENDNOTEIN: endin_initparams( p, progname ); break; case BIBL_ENDNOTEXMLIN: endxmlin_initparams( p, progname ); break; case BIBL_MEDLINEIN: medin_initparams( p, progname ); break; case BIBL_MODSIN: modsin_initparams( p, progname ); break; case BIBL_RISIN: risin_initparams( p, progname ); break; case BIBL_WORDIN: wordin_initparams( p, progname ); break; default: /* internal error */; } switch ( writemode ) { case BIBL_ADSABSOUT: adsout_initparams( p, progname ); break; case BIBL_BIBTEXOUT: bibtexout_initparams( p, progname ); break; case BIBL_ENDNOTEOUT: endout_initparams( p, progname ); break; case BIBL_ISIOUT: isiout_initparams( p, progname ); break; case BIBL_MODSOUT: modsout_initparams( p, progname ); break; case BIBL_RISOUT: risout_initparams( p, progname ); break; case BIBL_WORD2007OUT: wordout_initparams( p, progname ); break; default: /* internal error */; } } bibutils_4.12/lib/title.h0000644000076400007640000000053611444072056015626 0ustar cdputnamcdputnam/* * title.h * * process titles into title/subtitle pairs for MODS * * Copyright (c) Chris Putnam 2004-2009 * * Source code released under the GPL * */ #ifndef TITLE_H #define TITLE_H #include "newstr.h" #include "fields.h" extern void title_process( fields *info, char *tag, char *data, int level, unsigned char nosplittitle ); #endif bibutils_4.12/lib/bltypes.c0000644000076400007640000013014511444072056016162 0ustar cdputnamcdputnam/* * bltypes.c * * Copyright (c) Chris Putnam 2008-2010 * Copyright (c) Johannes Wilm 2010 * * Program and source code released under the GPL * */ #include #include "fields.h" #include "reftypes.h" /* Entry types for biblatex formatted bibliographies */ /* * Article in a journal, newspaper, other periodical */ static lookups article[] = { { "author", "AUTHOR", PERSON, LEVEL_MAIN }, { "editor", "EDITOR", PERSON, LEVEL_MAIN }, { "redactor", "REDACTOR", PERSON, LEVEL_MAIN }, { "annotator", "ANNOTATOR", PERSON, LEVEL_MAIN }, { "commentator", "COMMENTATOR", PERSON, LEVEL_MAIN }, { "translator", "TRANSLATOR", PERSON, LEVEL_MAIN }, { "title", "TITLE", SIMPLE, LEVEL_MAIN }, { "subtitle", "SUBTITLE", SIMPLE, LEVEL_MAIN }, { "titleaddon", "?titleaddon?", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "journal", "TITLE", SIMPLE, LEVEL_HOST }, { "journaltitle", "TITLE", SIMPLE, LEVEL_HOST }, { "journalsubtitle", "SUBTITLE", SIMPLE, LEVEL_HOST }, { "shortjournal", "SHORTTITLE", SIMPLE, LEVEL_HOST }, { "issuetitle", "TITLE", SIMPLE, LEVEL_SERIES }, /*WRONG*/ { "issuesubtitle", "SUBTITLE", SIMPLE, LEVEL_SERIES }, /*WRONG*/ { "language", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "origlanguage", "LANGUAGE", SIMPLE, LEVEL_ORIG }, { "origyear", "YEAR", SIMPLE, LEVEL_ORIG }, { "origtitle", "TITLE", SIMPLE, LEVEL_ORIG }, { "origlocation", "LOCATION", SIMPLE, LEVEL_ORIG }, { "origpublisher", "PUBLISHER", SIMPLE, LEVEL_ORIG }, { "series", "TITLE", SIMPLE, LEVEL_SERIES }, { "volume", "VOLUME", SIMPLE, LEVEL_MAIN }, { "number", "NUMBER", SIMPLE, LEVEL_MAIN }, { "eid", "EID", SIMPLE, LEVEL_MAIN }, { "issue", "ISSUE", SIMPLE, LEVEL_MAIN }, { "date", "DATE", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "day", "PARTDAY", SIMPLE, LEVEL_MAIN }, { "month", "PARTMONTH", SIMPLE, LEVEL_MAIN }, { "year", "PARTYEAR", SIMPLE, LEVEL_MAIN }, { "pages", "PAGES", PAGES, LEVEL_MAIN }, { "version", "VERSION", SIMPLE, LEVEL_MAIN }, { "note", "NOTES", SIMPLE, LEVEL_MAIN }, { "annote", "NOTES", SIMPLE, LEVEL_MAIN }, { "annotation", "NOTES", SIMPLE, LEVEL_MAIN }, { "issn", "ISSN", SIMPLE, LEVEL_HOST }, { "abstract", "ABSTRACT", SIMPLE, LEVEL_MAIN }, { "addendum", "?addendum?", SIMPLE, LEVEL_MAIN }, { "doi", "DOI", SIMPLE, LEVEL_MAIN }, { "eprint", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "eprinttype", "",BIBTEX_EPRINT, LEVEL_MAIN }, { "url", "", BIBTEX_URL, LEVEL_MAIN }, { "urldate", "URLDATE", SIMPLE, LEVEL_MAIN }, { "urlday", "?urlday?", SIMPLE, LEVEL_MAIN }, /* WRONG */ { "urlmonth", "?urlmonth?", SIMPLE, LEVEL_MAIN }, /* WRONG */ { "urlyear", "?urlyear?", SIMPLE, LEVEL_MAIN }, /* WRONG */ { "address", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "refnum", "REFNUM", SIMPLE, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|ARTICLE", ALWAYS, LEVEL_MAIN }, { " ", "ISSUANCE|continuing", ALWAYS, LEVEL_HOST }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|periodical", ALWAYS, LEVEL_HOST } }; /* Book */ static lookups book[] = { { "author", "AUTHOR", PERSON, LEVEL_MAIN }, { "editor", "EDITOR", PERSON, LEVEL_MAIN }, { "redactor", "REDACTOR", PERSON, LEVEL_MAIN }, { "annotator", "ANNOTATOR", PERSON, LEVEL_MAIN }, { "commentator", "COMMENTATOR", PERSON, LEVEL_MAIN }, { "translator", "TRANSLATOR", PERSON, LEVEL_MAIN }, { "introduction", "?introduction?",SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "foreward", "?foreward?", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "afterward", "?afterward?", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "title", "TITLE", SIMPLE, LEVEL_MAIN }, { "subtitle", "SUBTITLE", SIMPLE, LEVEL_MAIN }, { "titleaddon", "?titleaddon?", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "maintitle", "TITLE", SIMPLE, LEVEL_HOST }, { "mainsubtitle", "SUBTITLE", SIMPLE, LEVEL_HOST }, { "maintitleaddon", "?maintitleaddon?",SIMPLE, LEVEL_HOST }, /*WRONG*/ { "language", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "year", "YEAR", SIMPLE, LEVEL_MAIN }, { "origlanguage", "LANGUAGE", SIMPLE, LEVEL_ORIG }, { "origyear", "YEAR", SIMPLE, LEVEL_ORIG }, { "origtitle", "TITLE", SIMPLE, LEVEL_ORIG }, { "origlocation", "LOCATION", SIMPLE, LEVEL_ORIG }, { "origpublisher", "PUBLISHER", SIMPLE, LEVEL_ORIG }, { "volume", "VOLUME", SIMPLE, LEVEL_HOST }, { "part", "PART", SIMPLE, LEVEL_HOST }, { "edition", "EDITION", SIMPLE, LEVEL_MAIN }, { "volumes", "NUMVOLUMES", SIMPLE, LEVEL_HOST }, { "series", "TITLE", SIMPLE, LEVEL_HOST }, /* WRONG */ { "number", "NUMBER", SIMPLE, LEVEL_MAIN }, { "note", "NOTES", SIMPLE, LEVEL_MAIN }, { "annote", "NOTES", SIMPLE, LEVEL_MAIN }, { "annotation", "NOTES", SIMPLE, LEVEL_MAIN }, { "publisher", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "location", "LOCATION", SIMPLE, LEVEL_MAIN }, { "isbn", "ISBN", SIMPLE, LEVEL_MAIN }, { "chapter", "CHAPTER", SIMPLE, LEVEL_MAIN }, { "pages", "?pages?", SIMPLE, LEVEL_MAIN }, /* WRONG */ { "pagetotal", "?pagetotal?", SIMPLE, LEVEL_MAIN }, { "addendum", "?addendum?", SIMPLE, LEVEL_MAIN }, { "doi", "DOI", SIMPLE, LEVEL_MAIN }, { "eprint", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "eprinttype", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "url", "", BIBTEX_URL, LEVEL_MAIN }, { "urldate", "URLDATE", SIMPLE, LEVEL_MAIN }, { "urlday", "?urlday?", SIMPLE, LEVEL_MAIN }, { "urlmonth", "?urlmonth?", SIMPLE, LEVEL_MAIN }, { "urlyear", "?urlyear?", SIMPLE, LEVEL_MAIN }, { "address", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "refnum", "REFNUM", SIMPLE, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|BOOK", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text",ALWAYS, LEVEL_MAIN }, { " ", "ISSUANCE|monographic", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|book", ALWAYS, LEVEL_MAIN } }; /* Booklet */ static lookups booklet[] = { { "author", "AUTHOR", PERSON, LEVEL_MAIN }, { "editor", "EDITOR", PERSON, LEVEL_MAIN }, { "title", "TITLE", SIMPLE, LEVEL_MAIN }, { "subtitle", "SUBTITLE", SIMPLE, LEVEL_MAIN }, { "titleaddon", "?titleaddon?", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "howpublished", "", HOWPUBLISHED, LEVEL_MAIN }, { "year", "YEAR", SIMPLE, LEVEL_MAIN }, { "language", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "type", "GENRE", BIBTEX_GENRE, LEVEL_MAIN }, { "note", "NOTES", SIMPLE, LEVEL_MAIN }, { "annote", "NOTES", SIMPLE, LEVEL_MAIN }, { "annotation", "NOTES", SIMPLE, LEVEL_MAIN }, { "publisher", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "location", "LOCATION", SIMPLE, LEVEL_MAIN }, { "chapter", "CHAPTER", SIMPLE, LEVEL_MAIN }, { "pages", "?pages?", SIMPLE, LEVEL_MAIN }, /* WRONG */ { "pagetotal", "?pagetotal?", SIMPLE, LEVEL_MAIN }, { "addendum", "?addendum?", SIMPLE, LEVEL_MAIN }, { "doi", "DOI", SIMPLE, LEVEL_MAIN }, { "eprint", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "eprinttype", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "url", "", BIBTEX_URL, LEVEL_MAIN }, { "urldate", "URLDATE", SIMPLE, LEVEL_MAIN }, { "urlday", "?urlday?", SIMPLE, LEVEL_MAIN }, { "urlmonth", "?urlmonth?", SIMPLE, LEVEL_MAIN }, { "urlyear", "?urlyear?", SIMPLE, LEVEL_MAIN }, { "address", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "refnum", "REFNUM", SIMPLE, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|BOOK", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text",ALWAYS, LEVEL_MAIN }, { " ", "ISSUANCE|monographic", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|book", ALWAYS, LEVEL_MAIN } }; static lookups collection[] = { { "editor", "EDITOR", PERSON, LEVEL_MAIN }, { "redactor", "REDACTOR", PERSON, LEVEL_MAIN }, { "annotator", "ANNOTATOR", PERSON, LEVEL_MAIN }, { "commentator", "COMMENTATOR", PERSON, LEVEL_MAIN }, { "translator", "TRANSLATOR", PERSON, LEVEL_MAIN }, { "year", "YEAR", SIMPLE, LEVEL_MAIN }, { "introduction", "?introduction?", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "foreward", "?foreward?", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "afterward", "?afterward?", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "title", "TITLE", SIMPLE, LEVEL_MAIN }, { "subtitle", "SUBTITLE", SIMPLE, LEVEL_MAIN }, { "titleaddon", "?titleaddon?", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "maintitle", "TITLE", SIMPLE, LEVEL_HOST }, { "mainsubtitle", "SUBTITLE", SIMPLE, LEVEL_HOST }, { "maintitleaddon", "?maintitleaddon?", SIMPLE, LEVEL_HOST }, /*WRONG*/ { "language", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "origlanguage", "LANGUAGE", SIMPLE, LEVEL_ORIG }, { "origyear", "YEAR", SIMPLE, LEVEL_ORIG }, { "origtitle", "TITLE", SIMPLE, LEVEL_ORIG }, { "origlocation", "LOCATION", SIMPLE, LEVEL_ORIG }, { "origpublisher", "PUBLISHER", SIMPLE, LEVEL_ORIG }, { "volume", "VOLUME", SIMPLE, LEVEL_HOST }, { "part", "PART", SIMPLE, LEVEL_HOST }, { "edition", "EDITION", SIMPLE, LEVEL_MAIN }, { "volumes", "NUMVOLUMES", SIMPLE, LEVEL_HOST }, { "series", "?series?", SIMPLE, LEVEL_HOST }, /* WRONG */ { "number", "NUMBER", SIMPLE, LEVEL_MAIN }, { "note", "NOTES", SIMPLE, LEVEL_MAIN }, { "annote", "NOTES", SIMPLE, LEVEL_MAIN }, { "annotation", "NOTES", SIMPLE, LEVEL_MAIN }, { "publisher", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "location", "LOCATION", SIMPLE, LEVEL_MAIN }, { "isbn", "ISBN", SIMPLE, LEVEL_MAIN }, { "chapter", "CHAPTER", SIMPLE, LEVEL_MAIN }, { "pages", "?pages?", SIMPLE, LEVEL_MAIN }, /* WRONG */ { "pagetotal", "?pagetotal?", SIMPLE, LEVEL_MAIN }, { "addendum", "?addendum?", SIMPLE, LEVEL_MAIN }, { "doi", "DOI", SIMPLE, LEVEL_MAIN }, { "eprint", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "eprinttype", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "url", "", BIBTEX_URL, LEVEL_MAIN }, { "urldate", "URLDATE", SIMPLE, LEVEL_MAIN }, { "urlday", "?urlday?", SIMPLE, LEVEL_MAIN }, { "urlmonth", "?urlmonth?", SIMPLE, LEVEL_MAIN }, { "urlyear", "?urlyear?", SIMPLE, LEVEL_MAIN }, { "address", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "refnum", "REFNUM", SIMPLE, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|BOOK", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text",ALWAYS, LEVEL_MAIN }, { " ", "ISSUANCE|monographic", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|book", ALWAYS, LEVEL_MAIN } }; /* Part of a book (e.g. chapter or section) */ static lookups inbook[] = { { "author", "AUTHOR", PERSON, LEVEL_MAIN }, { "editor", "EDITOR", PERSON, LEVEL_HOST }, { "redactor", "REDACTOR", PERSON, LEVEL_HOST }, { "annotator", "ANNOTATOR", PERSON, LEVEL_HOST }, { "commentator", "COMMENTATOR", PERSON, LEVEL_HOST }, { "translator", "TRANSLATOR", PERSON, LEVEL_HOST }, { "year", "YEAR", SIMPLE, LEVEL_MAIN }, { "introduction", "?introduction?", SIMPLE, LEVEL_HOST }, /*WRONG*/ { "foreward", "?foreward?", SIMPLE, LEVEL_HOST }, /*WRONG*/ { "afterward", "?afterward?", SIMPLE, LEVEL_HOST }, /*WRONG*/ { "title", "TITLE", SIMPLE, LEVEL_MAIN }, { "subtitle", "SUBTITLE", SIMPLE, LEVEL_MAIN }, { "titleaddon", "?titleaddon?", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "maintitle", "TITLE", SIMPLE, LEVEL_MAIN }, { "mainsubtitle", "SUBTITLE", SIMPLE, LEVEL_MAIN }, { "maintitleaddon", "?maintitleaddon?", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "booktitle", "TITLE", SIMPLE, LEVEL_HOST }, { "booksubtitle", "SUBTITLE", SIMPLE, LEVEL_HOST }, { "booktitleaddon", "?booktitleaddon?", SIMPLE, LEVEL_HOST }, { "bookauthor", "AUTHOR", PERSON, LEVEL_HOST }, { "language", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "origlanguage", "LANGUAGE", SIMPLE, LEVEL_ORIG }, { "origyear", "YEAR", SIMPLE, LEVEL_ORIG }, { "origtitle", "TITLE", SIMPLE, LEVEL_ORIG }, { "origlocation", "LOCATION", SIMPLE, LEVEL_ORIG }, { "origpublisher", "PUBLISHER", SIMPLE, LEVEL_ORIG }, { "volume", "VOLUME", SIMPLE, LEVEL_MAIN }, { "pages", "PAGES", PAGES, LEVEL_MAIN }, { "part", "PART", SIMPLE, LEVEL_HOST }, { "edition", "EDITION", SIMPLE, LEVEL_MAIN }, { "volumes", "NUMVOLUMES", SIMPLE, LEVEL_HOST }, { "series", "?series?", SIMPLE, LEVEL_HOST }, /* WRONG */ { "number", "NUMBER", SIMPLE, LEVEL_MAIN }, { "note", "NOTES", SIMPLE, LEVEL_MAIN }, { "annote", "NOTES", SIMPLE, LEVEL_MAIN }, { "annotation", "NOTES", SIMPLE, LEVEL_MAIN }, { "publisher", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "location", "LOCATION", SIMPLE, LEVEL_MAIN }, { "isbn", "ISBN", SIMPLE, LEVEL_HOST }, { "chapter", "CHAPTER", SIMPLE, LEVEL_MAIN }, { "addendum", "?addendum?", SIMPLE, LEVEL_MAIN }, { "doi", "DOI", SIMPLE, LEVEL_MAIN }, { "eprint", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "eprinttype", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "url", "", BIBTEX_URL, LEVEL_MAIN }, { "urldate", "URLDATE", SIMPLE, LEVEL_MAIN }, { "urlday", "?urlday?", SIMPLE, LEVEL_MAIN }, { "urlmonth", "?urlmonth?", SIMPLE, LEVEL_MAIN }, { "urlyear", "?urlyear?", SIMPLE, LEVEL_MAIN }, { "address", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "refnum", "REFNUM", SIMPLE, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|INBOOK", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text",ALWAYS, LEVEL_MAIN }, { " ", "ISSUANCE|monographic", ALWAYS, LEVEL_HOST }, { " ", "GENRE|book", ALWAYS, LEVEL_HOST } }; /* incollection */ static lookups incollection[] = { { "author", "AUTHOR", PERSON, LEVEL_MAIN }, { "year", "YEAR", SIMPLE, LEVEL_MAIN }, { "title", "TITLE", SIMPLE, LEVEL_MAIN }, { "subtitle", "SUBTITLE", SIMPLE, LEVEL_MAIN }, { "titleaddon", "?titleaddon?", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "language", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "edition", "EDITION", SIMPLE, LEVEL_MAIN }, { "number", "NUMBER", SIMPLE, LEVEL_MAIN }, { "note", "NOTES", SIMPLE, LEVEL_MAIN }, { "annote", "NOTES", SIMPLE, LEVEL_MAIN }, { "annotation", "NOTES", SIMPLE, LEVEL_MAIN }, { "introduction", "?introduction?",SIMPLE, LEVEL_HOST }, /*WRONG*/ { "foreward", "?foreward?", SIMPLE, LEVEL_HOST }, /*WRONG*/ { "afterward", "?afterward?", SIMPLE, LEVEL_HOST }, /*WRONG*/ { "bookauthor", "AUTHOR", PERSON, LEVEL_HOST }, { "booktitle", "TITLE", SIMPLE, LEVEL_HOST }, { "booksubtitle", "SUBTITLE", SIMPLE, LEVEL_HOST }, { "booktitleaddon", "?booktitleaddon?",SIMPLE, LEVEL_HOST }, { "editor", "EDITOR", PERSON, LEVEL_HOST }, { "redactor", "REDACTOR", PERSON, LEVEL_HOST }, { "annotator", "ANNOTATOR", PERSON, LEVEL_HOST }, { "commentator", "COMMENTATOR", PERSON, LEVEL_HOST }, { "translator", "TRANSLATOR", PERSON, LEVEL_HOST }, { "volume", "VOLUME", SIMPLE, LEVEL_HOST }, { "part", "PART", SIMPLE, LEVEL_HOST }, { "volumes", "NUMVOLUMES", SIMPLE, LEVEL_HOST }, { "maintitle", "TITLE", SIMPLE, LEVEL_HOST+1 }, { "mainsubtitle", "SUBTITLE", SIMPLE, LEVEL_HOST+1 }, { "maintitleaddon", "?maintitleaddon?", SIMPLE, LEVEL_HOST+1 }, /*WRONG*/ { "series", "TITLE", SIMPLE, LEVEL_HOST+2 }, /* WRONG */ { "origlanguage", "LANGUAGE", SIMPLE, LEVEL_ORIG }, { "origyear", "YEAR", SIMPLE, LEVEL_ORIG }, { "origtitle", "TITLE", SIMPLE, LEVEL_ORIG }, { "origlocation", "LOCATION", SIMPLE, LEVEL_ORIG }, { "origpublisher", "PUBLISHER", SIMPLE, LEVEL_ORIG }, { "publisher", "PUBLISHER", SIMPLE, LEVEL_HOST }, { "location", "LOCATION", SIMPLE, LEVEL_HOST }, { "isbn", "ISBN", SIMPLE, LEVEL_MAIN }, { "chapter", "CHAPTER", SIMPLE, LEVEL_MAIN }, { "pages", "PAGES", PAGES, LEVEL_MAIN }, /* WRONG */ { "addendum", "?addendum?", SIMPLE, LEVEL_MAIN }, { "doi", "DOI", SIMPLE, LEVEL_MAIN }, { "eprint", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "eprinttype", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "url", "", BIBTEX_URL, LEVEL_MAIN }, { "urldate", "URLDATE", SIMPLE, LEVEL_MAIN }, { "urlday", "?urlday?", SIMPLE, LEVEL_MAIN }, { "urlmonth", "?urlmonth?", SIMPLE, LEVEL_MAIN }, { "urlyear", "?urlyear?", SIMPLE, LEVEL_MAIN }, { "address", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "refnum", "REFNUM", SIMPLE, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|INCOLLECTION", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text",ALWAYS, LEVEL_MAIN }, { " ", "ISSUANCE|monographic", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|collection", ALWAYS, LEVEL_HOST } }; /* inproceedings */ static lookups inproceedings[] = { { "author", "AUTHOR", PERSON, LEVEL_MAIN }, { "editor", "EDITOR", PERSON, LEVEL_HOST }, { "redactor", "REDACTOR", PERSON, LEVEL_HOST }, { "annotator", "ANNOTATOR", PERSON, LEVEL_HOST }, { "commentator", "COMMENTATOR", PERSON, LEVEL_HOST }, { "translator", "TRANSLATOR", PERSON, LEVEL_HOST }, { "eventtitle", "EVENT:CONF", SIMPLE, LEVEL_MAIN }, { "year", "YEAR", SIMPLE, LEVEL_MAIN }, { "introduction", "?introduction?",SIMPLE, LEVEL_HOST }, /*WRONG*/ { "foreward", "?foreward?", SIMPLE, LEVEL_HOST }, /*WRONG*/ { "afterward", "?afterward?", SIMPLE, LEVEL_HOST }, /*WRONG*/ { "title", "TITLE", SIMPLE, LEVEL_MAIN }, { "subtitle", "SUBTITLE", SIMPLE, LEVEL_MAIN }, { "titleaddon", "?titleaddon?", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "booktitle", "TITLE", SIMPLE, LEVEL_HOST }, { "booksubtitle", "SUBTITLE", SIMPLE, LEVEL_HOST }, { "booktitleaddon", "?booktitleaddon?", SIMPLE, LEVEL_HOST }, /*WRONG*/ { "maintitle", "TITLE", SIMPLE, LEVEL_HOST+1 }, { "mainsubtitle", "SUBTITLE", SIMPLE, LEVEL_HOST+1 }, { "maintitleaddon", "?maintitleaddon?", SIMPLE, LEVEL_HOST+1 }, /*WRONG*/ { "series", "TITLE", SIMPLE, LEVEL_HOST+2 }, { "venue", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "organization", "ORGANIZER:CORP", SIMPLE, LEVEL_MAIN }, { "language", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "origlanguage", "LANGUAGE", SIMPLE, LEVEL_ORIG }, { "volume", "VOLUME", SIMPLE, LEVEL_HOST }, { "part", "PART", SIMPLE, LEVEL_HOST }, { "edition", "EDITION", SIMPLE, LEVEL_MAIN }, { "volumes", "NUMVOLUMES", SIMPLE, LEVEL_HOST }, { "number", "NUMBER", SIMPLE, LEVEL_MAIN }, { "note", "NOTES", SIMPLE, LEVEL_MAIN }, { "annote", "NOTES", SIMPLE, LEVEL_MAIN }, { "annotation", "NOTES", SIMPLE, LEVEL_MAIN }, { "publisher", "PUBLISHER", SIMPLE, LEVEL_HOST }, { "location", "LOCATION", SIMPLE, LEVEL_HOST }, { "isbn", "ISBN", SIMPLE, LEVEL_MAIN }, { "chapter", "CHAPTER", SIMPLE, LEVEL_MAIN }, { "pages", "PAGES", PAGES, LEVEL_MAIN }, /* WRONG */ { "addendum", "?addendnum?", SIMPLE, LEVEL_MAIN }, { "doi", "DOI", SIMPLE, LEVEL_MAIN }, { "eprint", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "eprinttype", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "url", "", BIBTEX_URL, LEVEL_MAIN }, { "urldate", "URLDATE", SIMPLE, LEVEL_MAIN }, { "urlday", "?urlday?", SIMPLE, LEVEL_MAIN }, { "urlmonth", "?urlmonth?", SIMPLE, LEVEL_MAIN }, { "urlyear", "?urlyear?", SIMPLE, LEVEL_MAIN }, { "address", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "refnum", "REFNUM", SIMPLE, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|INPROCEEDINGS", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text",ALWAYS, LEVEL_MAIN }, { " ", "ISSUANCE|monographic", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|conference publication", ALWAYS, LEVEL_HOST } }; static lookups manual[] = { { "author", "AUTHOR", PERSON, LEVEL_MAIN }, { "editor", "EDITOR", PERSON, LEVEL_MAIN }, { "redactor", "REDACTOR", PERSON, LEVEL_MAIN }, { "annotator", "ANNOTATOR", PERSON, LEVEL_MAIN }, { "commentator", "COMMENTATOR", PERSON, LEVEL_MAIN }, { "translator", "TRANSLATOR", PERSON, LEVEL_MAIN }, { "year", "YEAR", SIMPLE, LEVEL_MAIN }, { "introduction", "?????", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "foreward", "?????", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "afterward", "?????", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "title", "TITLE", SIMPLE, LEVEL_MAIN }, { "subtitle", "SUBTITLE", SIMPLE, LEVEL_MAIN }, { "titleaddon", "?????", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "language", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "edition", "EDITION", SIMPLE, LEVEL_MAIN }, { "version", "???????", SIMPLE, LEVEL_MAIN }, { "type", "GENRE", BIBTEX_GENRE, LEVEL_MAIN }, { "series", "?????", SIMPLE, LEVEL_HOST }, /* WRONG */ { "number", "NUMBER", SIMPLE, LEVEL_MAIN }, { "note", "NOTES", SIMPLE, LEVEL_MAIN }, { "annote", "NOTES", SIMPLE, LEVEL_MAIN }, { "annotation", "NOTES", SIMPLE, LEVEL_MAIN }, { "organization", "ORGANIZER:CORP", SIMPLE, LEVEL_MAIN }, { "publisher", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "location", "LOCATION", SIMPLE, LEVEL_MAIN }, { "isbn", "ISBN", SIMPLE, LEVEL_MAIN }, { "chapter", "CHAPTER", SIMPLE, LEVEL_MAIN }, { "pages", "?????????", SIMPLE, LEVEL_MAIN }, /* WRONG */ { "pagetotal", "?????????", SIMPLE, LEVEL_MAIN }, { "addendum", "?????????", SIMPLE, LEVEL_MAIN }, { "doi", "DOI", SIMPLE, LEVEL_MAIN }, { "eprint", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "eprinttype", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "url", "", BIBTEX_URL, LEVEL_MAIN }, { "urldate", "URLDATE", SIMPLE, LEVEL_MAIN }, { "urlday", "?????????", SIMPLE, LEVEL_MAIN }, { "urlmonth", "?????????", SIMPLE, LEVEL_MAIN }, { "urlyear", "?????????", SIMPLE, LEVEL_MAIN }, { "address", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "refnum", "REFNUM", SIMPLE, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|REPORT", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|instruction", ALWAYS, LEVEL_MAIN } }; static lookups misc[] = { { "author", "AUTHOR", PERSON, LEVEL_MAIN }, { "editor", "EDITOR", PERSON, LEVEL_MAIN }, { "title", "TITLE", SIMPLE, LEVEL_MAIN }, { "subtitle", "SUBTITLE", SIMPLE, LEVEL_MAIN }, { "titleaddon", "?????", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "day", "DAY", SIMPLE, LEVEL_MAIN }, { "month", "MONTH", SIMPLE, LEVEL_MAIN }, { "year", "YEAR", SIMPLE, LEVEL_MAIN }, { "language", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "howpublished", "", HOWPUBLISHED, LEVEL_MAIN }, { "version", "???????", SIMPLE, LEVEL_MAIN }, { "type", "GENRE", BIBTEX_GENRE, LEVEL_MAIN }, { "note", "NOTES", SIMPLE, LEVEL_MAIN }, { "annote", "NOTES", SIMPLE, LEVEL_MAIN }, { "annotation", "NOTES", SIMPLE, LEVEL_MAIN }, { "organization", "ORGANIZER:CORP",SIMPLE, LEVEL_MAIN }, { "publisher", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "location", "LOCATION", SIMPLE, LEVEL_MAIN }, { "addendum", "?????????", SIMPLE, LEVEL_MAIN }, { "address", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "doi", "DOI", SIMPLE, LEVEL_MAIN }, { "eprint", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "eprinttype", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "url", "", BIBTEX_URL, LEVEL_MAIN }, { "urldate", "URLDATE", SIMPLE, LEVEL_MAIN }, { "urlday", "?????????", SIMPLE, LEVEL_MAIN }, { "urlmonth", "?????????", SIMPLE, LEVEL_MAIN }, { "urlyear", "?????????", SIMPLE, LEVEL_MAIN }, { "refnum", "REFNUM", SIMPLE, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|MISC", ALWAYS, LEVEL_MAIN }, }; static lookups online[] = { { "author", "AUTHOR", PERSON, LEVEL_MAIN }, { "editor", "EDITOR", PERSON, LEVEL_MAIN }, { "title", "TITLE", SIMPLE, LEVEL_MAIN }, { "subtitle", "SUBTITLE", SIMPLE, LEVEL_MAIN }, { "titleaddon", "?????", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "date", "DATE", SIMPLE, LEVEL_MAIN }, { "day", "DAY", SIMPLE, LEVEL_MAIN }, { "month", "MONTH", SIMPLE, LEVEL_MAIN }, { "year", "YEAR", SIMPLE, LEVEL_MAIN }, { "language", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "version", "???????", SIMPLE, LEVEL_MAIN }, { "type", "GENRE", BIBTEX_GENRE, LEVEL_MAIN }, { "note", "NOTES", SIMPLE, LEVEL_MAIN }, { "annote", "NOTES", SIMPLE, LEVEL_MAIN }, { "annotation", "NOTES", SIMPLE, LEVEL_MAIN }, { "organization", "ORGANIZER:CORP", SIMPLE, LEVEL_MAIN }, { "publisher", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "location", "LOCATION", SIMPLE, LEVEL_MAIN }, { "addendum", "?????????", SIMPLE, LEVEL_MAIN }, { "doi", "DOI", SIMPLE, LEVEL_MAIN }, { "eprint", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "eprinttype", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "url", "", BIBTEX_URL, LEVEL_MAIN }, { "urldate", "URLDATE", SIMPLE, LEVEL_MAIN }, { "urlday", "?????????", SIMPLE, LEVEL_MAIN }, { "urlmonth", "?????????", SIMPLE, LEVEL_MAIN }, { "urlyear", "?????????", SIMPLE, LEVEL_MAIN }, { "address", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "refnum", "REFNUM", SIMPLE, LEVEL_MAIN }, { " ", "RESOURCE|software, multimedia", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|web page", ALWAYS, LEVEL_MAIN }, }; static lookups patent[] = { { "author", "AUTHOR", PERSON, LEVEL_MAIN }, { "holder", "ASSIGNEE", PERSON, LEVEL_MAIN }, { "title", "TITLE", SIMPLE, LEVEL_MAIN }, { "subtitle", "SUBTITLE", SIMPLE, LEVEL_MAIN }, { "titleaddon", "?????", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "date", "DATE", SIMPLE, LEVEL_MAIN }, { "day", "DAY", SIMPLE, LEVEL_MAIN }, { "month", "MONTH", SIMPLE, LEVEL_MAIN }, { "year", "YEAR", SIMPLE, LEVEL_MAIN }, { "version", "???????", SIMPLE, LEVEL_MAIN }, { "type", "GENRE", BIBTEX_GENRE, LEVEL_MAIN }, { "note", "NOTES", SIMPLE, LEVEL_MAIN }, { "annote", "NOTES", SIMPLE, LEVEL_MAIN }, { "annotation", "NOTES", SIMPLE, LEVEL_MAIN }, { "organization", "ORGANIZER:CORP", SIMPLE, LEVEL_MAIN }, { "location", "LOCATION", SIMPLE, LEVEL_MAIN }, { "number", "NUMBER", SIMPLE, LEVEL_MAIN }, { "addendum", "?????????", SIMPLE, LEVEL_MAIN }, { "url", "", BIBTEX_URL, LEVEL_MAIN }, { "urldate", "URLDATE", SIMPLE, LEVEL_MAIN }, { "urlday", "?????????", SIMPLE, LEVEL_MAIN }, { "urlmonth", "?????????", SIMPLE, LEVEL_MAIN }, { "urlyear", "?????????", SIMPLE, LEVEL_MAIN }, { "address", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "refnum", "REFNUM", SIMPLE, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|PATENT", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|patent", ALWAYS, LEVEL_MAIN }, }; /* * An entire issue of a periodical */ static lookups periodical[] = { { "editor", "EDITOR", PERSON, LEVEL_MAIN }, { "title", "TITLE", SIMPLE, LEVEL_MAIN }, { "subtitle", "SUBTITLE", SIMPLE, LEVEL_MAIN }, { "titleaddon", "?????", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "issuetitle", "TITLE", SIMPLE, LEVEL_SERIES }, /*WRONG*/ { "issuesubtitle", "SUBTITLE", SIMPLE, LEVEL_SERIES }, /*WRONG*/ { "series", "TITLE", SIMPLE, LEVEL_SERIES }, { "volume", "VOLUME", SIMPLE, LEVEL_MAIN }, { "number", "NUMBER", SIMPLE, LEVEL_MAIN }, { "issue", "ISSUE", SIMPLE, LEVEL_MAIN }, { "date", "DATE", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "day", "PARTDAY", SIMPLE, LEVEL_MAIN }, { "month", "PARTMONTH", SIMPLE, LEVEL_MAIN }, { "year", "PARTYEAR", SIMPLE, LEVEL_MAIN }, { "pages", "PAGES", PAGES, LEVEL_MAIN }, { "note", "NOTES", SIMPLE, LEVEL_MAIN }, { "annote", "NOTES", SIMPLE, LEVEL_MAIN }, { "annotation", "NOTES", SIMPLE, LEVEL_MAIN }, { "issn", "ISSN", SIMPLE, LEVEL_HOST }, { "addendum", "?????", SIMPLE, LEVEL_MAIN }, { "doi", "DOI", SIMPLE, LEVEL_MAIN }, { "eprint", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "eprinttype", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "url", "", BIBTEX_URL, LEVEL_MAIN }, { "urldate", "URLDATE", SIMPLE, LEVEL_MAIN }, { "urlday", "?????", SIMPLE, LEVEL_MAIN }, /* WRONG */ { "urlmonth", "?????", SIMPLE, LEVEL_MAIN }, /* WRONG */ { "urlyear", "?????", SIMPLE, LEVEL_MAIN }, /* WRONG */ { "address", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "refnum", "REFNUM", SIMPLE, LEVEL_MAIN }, { " ", "ISSUANCE|continuing", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|periodical", ALWAYS, LEVEL_MAIN } }; static lookups proceedings[] = { { "editor", "EDITOR", PERSON, LEVEL_MAIN }, { "redactor", "REDACTOR", PERSON, LEVEL_MAIN }, { "annotator", "ANNOTATOR", PERSON, LEVEL_MAIN }, { "commentator", "COMMENTATOR", PERSON, LEVEL_MAIN }, { "translator", "TRANSLATOR", PERSON, LEVEL_MAIN }, { "eventtitle", "EVENT:CONF", SIMPLE, LEVEL_MAIN }, { "year", "YEAR", SIMPLE, LEVEL_MAIN }, { "introduction", "?????", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "foreward", "?????", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "afterward", "?????", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "title", "TITLE", SIMPLE, LEVEL_MAIN }, { "subtitle", "SUBTITLE", SIMPLE, LEVEL_MAIN }, { "titleaddon", "?????", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "maintitle", "TITLE", SIMPLE, LEVEL_HOST }, { "mainsubtitle", "SUBTITLE", SIMPLE, LEVEL_HOST }, { "maintitleaddon", "?????", SIMPLE, LEVEL_HOST }, /*WRONG*/ { "language", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "origlanguage", "LANGUAGE", SIMPLE, LEVEL_ORIG }, { "volume", "VOLUME", SIMPLE, LEVEL_HOST }, { "part", "PART", SIMPLE, LEVEL_HOST }, { "edition", "EDITION", SIMPLE, LEVEL_MAIN }, { "volumes", "NUMVOLUMES", SIMPLE, LEVEL_HOST }, { "series", "?????", SIMPLE, LEVEL_HOST }, /* WRONG */ { "number", "NUMBER", SIMPLE, LEVEL_MAIN }, { "note", "NOTES", SIMPLE, LEVEL_MAIN }, { "annote", "NOTES", SIMPLE, LEVEL_MAIN }, { "annotation", "NOTES", SIMPLE, LEVEL_MAIN }, { "organization", "ORGANIZER:CORP",SIMPLE, LEVEL_MAIN }, { "publisher", "PUBLISHER", SIMPLE, LEVEL_MAIN }, { "location", "LOCATION", SIMPLE, LEVEL_MAIN }, { "isbn", "ISBN", SIMPLE, LEVEL_MAIN }, { "chapter", "CHAPTER", SIMPLE, LEVEL_MAIN }, { "pages", "?????????", SIMPLE, LEVEL_MAIN }, /* WRONG */ { "pagetotal", "?????????", SIMPLE, LEVEL_MAIN }, { "addendum", "?????????", SIMPLE, LEVEL_MAIN }, { "doi", "DOI", SIMPLE, LEVEL_MAIN }, { "eprint", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "eprinttype", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "url", "", BIBTEX_URL, LEVEL_MAIN }, { "urldate", "URLDATE", SIMPLE, LEVEL_MAIN }, { "urlday", "?????????", SIMPLE, LEVEL_MAIN }, { "urlmonth", "?????????", SIMPLE, LEVEL_MAIN }, { "urlyear", "?????????", SIMPLE, LEVEL_MAIN }, { "address", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "refnum", "REFNUM", SIMPLE, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|BOOK", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|conference publication", ALWAYS, LEVEL_MAIN } }; /* Technical reports */ static lookups report[] = { { "author", "AUTHOR", PERSON, LEVEL_MAIN }, { "title", "TITLE", SIMPLE, LEVEL_MAIN }, { "subtitle", "SUBTITLE", SIMPLE, LEVEL_MAIN }, { "titleaddon", "?????", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "year", "YEAR", SIMPLE, LEVEL_MAIN }, { "language", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "number", "NUMBER", SIMPLE, LEVEL_MAIN }, { "note", "NOTES", SIMPLE, LEVEL_MAIN }, { "annote", "NOTES", SIMPLE, LEVEL_MAIN }, { "annotation", "NOTES", SIMPLE, LEVEL_MAIN }, { "version", "?????????", SIMPLE, LEVEL_MAIN }, { "location", "LOCATION", SIMPLE, LEVEL_MAIN }, { "isrn", "ISRN", SIMPLE, LEVEL_MAIN }, { "chapter", "CHAPTER", SIMPLE, LEVEL_MAIN }, { "pages", "?????????", SIMPLE, LEVEL_MAIN }, /* WRONG */ { "pagetotal", "?????????", SIMPLE, LEVEL_MAIN }, { "addendum", "?????????", SIMPLE, LEVEL_MAIN }, { "doi", "DOI", SIMPLE, LEVEL_MAIN }, { "eprint", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "eprinttype", "", BIBTEX_EPRINT, LEVEL_MAIN }, { "url", "", BIBTEX_URL, LEVEL_MAIN }, { "urldate", "URLDATE", SIMPLE, LEVEL_MAIN }, { "urlday", "?????????", SIMPLE, LEVEL_MAIN }, { "urlmonth", "?????????", SIMPLE, LEVEL_MAIN }, { "urlyear", "?????????", SIMPLE, LEVEL_MAIN }, { "address", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "refnum", "REFNUM", SIMPLE, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|REPORT", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|report", ALWAYS, LEVEL_MAIN } }; static lookups thesis[] = { { "author", "AUTHOR", PERSON, LEVEL_MAIN }, { "title", "TITLE", SIMPLE, LEVEL_MAIN }, { "subtitle", "SUBTITLE", SIMPLE, LEVEL_MAIN }, { "titleaddon","?????", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "year", "YEAR", SIMPLE, LEVEL_MAIN }, { "month", "MONTH", SIMPLE, LEVEL_MAIN }, { "day", "DAY", SIMPLE, LEVEL_MAIN }, { "type", "GENRE", BIBTEX_GENRE, LEVEL_MAIN }, { "institution","DEGREEGRANTOR:ASIS",SIMPLE, LEVEL_MAIN }, { "school", "DEGREEGRANTOR:ASIS",SIMPLE, LEVEL_MAIN }, { "doi", "DOI", SIMPLE, LEVEL_MAIN }, { "howpublished", "", HOWPUBLISHED, LEVEL_MAIN }, { "url", "", BIBTEX_URL, LEVEL_MAIN }, { "urldate", "URLDATE", SIMPLE, LEVEL_MAIN }, { "urlday", "?urlday?", SIMPLE, LEVEL_MAIN }, { "urlmonth", "?urlmonth?", SIMPLE, LEVEL_MAIN }, { "urlyear", "?urlyear?", SIMPLE, LEVEL_MAIN }, { "language", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "location", "LOCATION", SIMPLE, LEVEL_MAIN }, { "note", "NOTES", SIMPLE, LEVEL_MAIN }, { "annote", "NOTES", SIMPLE, LEVEL_MAIN }, { "annotation", "NOTES", SIMPLE, LEVEL_MAIN }, { "address", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "refnum", "REFNUM", SIMPLE, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|THESIS", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|thesis", ALWAYS, LEVEL_MAIN }, }; /* Unpublished */ static lookups unpublished[] = { { "author", "AUTHOR", PERSON, LEVEL_MAIN }, { "title", "TITLE", SIMPLE, LEVEL_MAIN }, { "subtitle", "SUBTITLE", SIMPLE, LEVEL_MAIN }, { "titleaddon", "?????", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "howpublished", "", HOWPUBLISHED, LEVEL_MAIN }, { "year", "YEAR", SIMPLE, LEVEL_MAIN }, { "month", "MONTH", SIMPLE, LEVEL_MAIN }, { "day", "DAY", SIMPLE, LEVEL_MAIN }, { "date", "DATE", SIMPLE, LEVEL_MAIN }, { "url", "", BIBTEX_URL, LEVEL_MAIN }, { "urlday", "?????????", SIMPLE, LEVEL_MAIN }, { "urlmonth", "?????????", SIMPLE, LEVEL_MAIN }, { "urlyear", "?????????", SIMPLE, LEVEL_MAIN }, { "language", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "note", "NOTES", SIMPLE, LEVEL_MAIN }, { "annote", "NOTES", SIMPLE, LEVEL_MAIN }, { "annotation", "NOTES", SIMPLE, LEVEL_MAIN }, { "addendum", "?????????", SIMPLE, LEVEL_MAIN }, { "address", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "refnum", "REFNUM", SIMPLE, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|BOOK", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text",ALWAYS, LEVEL_MAIN }, { " ", "GENRE|unpublished",ALWAYS, LEVEL_MAIN } }; static lookups phdthesis[] = { { "author", "AUTHOR", PERSON, LEVEL_MAIN }, { "title", "TITLE", SIMPLE, LEVEL_MAIN }, { "subtitle", "SUBTITLE", SIMPLE, LEVEL_MAIN }, { "titleaddon", "?titleadon?", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "year", "YEAR", SIMPLE, LEVEL_MAIN }, { "month", "MONTH", SIMPLE, LEVEL_MAIN }, { "day", "DAY", SIMPLE, LEVEL_MAIN }, { "type", "GENRE", BIBTEX_GENRE, LEVEL_MAIN }, { "institution","DEGREEGRANTOR:ASIS",SIMPLE, LEVEL_MAIN }, { "school", "DEGREEGRANTOR:ASIS",SIMPLE, LEVEL_MAIN }, { "doi", "DOI", SIMPLE, LEVEL_MAIN }, { "howpublished", "", HOWPUBLISHED, LEVEL_MAIN }, { "url", "", BIBTEX_URL, LEVEL_MAIN }, { "urldate", "URLDATE", SIMPLE, LEVEL_MAIN }, { "urlday", "?urlday?", SIMPLE, LEVEL_MAIN }, { "urlmonth", "?urlmonth?", SIMPLE, LEVEL_MAIN }, { "urlyear", "?urlyear?", SIMPLE, LEVEL_MAIN }, { "language", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "location", "LOCATION", SIMPLE, LEVEL_MAIN }, { "note", "NOTES", SIMPLE, LEVEL_MAIN }, { "annote", "NOTES", SIMPLE, LEVEL_MAIN }, { "annotation", "NOTES", SIMPLE, LEVEL_MAIN }, { "address", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "refnum", "REFNUM", SIMPLE, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|THESIS", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|Ph.D. thesis", ALWAYS, LEVEL_MAIN } }; static lookups mastersthesis[] = { { "author", "AUTHOR", PERSON, LEVEL_MAIN }, { "title", "TITLE", SIMPLE, LEVEL_MAIN }, { "subtitle", "SUBTITLE", SIMPLE, LEVEL_MAIN }, { "titleaddon", "?titleaddon?", SIMPLE, LEVEL_MAIN }, /*WRONG*/ { "year", "YEAR", SIMPLE, LEVEL_MAIN }, { "month", "MONTH", SIMPLE, LEVEL_MAIN }, { "day", "DAY", SIMPLE, LEVEL_MAIN }, { "type", "GENRE", BIBTEX_GENRE, LEVEL_MAIN }, { "institution","DEGREEGRANTOR:ASIS",SIMPLE, LEVEL_MAIN }, { "school", "DEGREEGRANTOR:ASIS",SIMPLE, LEVEL_MAIN }, { "doi", "DOI", SIMPLE, LEVEL_MAIN }, { "howpublished", "", HOWPUBLISHED, LEVEL_MAIN }, { "url", "", BIBTEX_URL, LEVEL_MAIN }, { "urldate", "URLDATE", SIMPLE, LEVEL_MAIN }, { "urlday", "?urlday?", SIMPLE, LEVEL_MAIN }, { "urlmonth", "?urlmonth?", SIMPLE, LEVEL_MAIN }, { "urlyear", "?urlyear?", SIMPLE, LEVEL_MAIN }, { "language", "LANGUAGE", SIMPLE, LEVEL_MAIN }, { "location", "LOCATION", SIMPLE, LEVEL_MAIN }, { "note", "NOTES", SIMPLE, LEVEL_MAIN }, { "annote", "NOTES", SIMPLE, LEVEL_MAIN }, { "annotation", "NOTES", SIMPLE, LEVEL_MAIN }, { "address", "ADDRESS", SIMPLE, LEVEL_MAIN }, { "refnum", "REFNUM", SIMPLE, LEVEL_MAIN }, { " ", "INTERNAL_TYPE|THESIS", ALWAYS, LEVEL_MAIN }, { " ", "RESOURCE|text", ALWAYS, LEVEL_MAIN }, { " ", "GENRE|Masters thesis", ALWAYS, LEVEL_MAIN }, }; #define ORIG(a) ( &(a[0]) ) #define SIZE(a) ( sizeof( a ) / sizeof( lookups ) ) #define REFTYPE(a,b) { a, ORIG(b), SIZE(b) } variants biblatex_all[] = { REFTYPE( "article", article ), REFTYPE( "booklet", booklet ), REFTYPE( "book", book ), REFTYPE( "collection", collection ), REFTYPE( "inbook", inbook ), REFTYPE( "incollection", incollection ), REFTYPE( "inproceedings", inproceedings ), REFTYPE( "conference", inproceedings ), /* legacy */ REFTYPE( "manual", manual ), REFTYPE( "misc", misc ), REFTYPE( "online", online ), REFTYPE( "electronic", online ), /* legacy */ REFTYPE( "www", online ), /* jurabib compatibility */ REFTYPE( "patent", patent ), REFTYPE( "periodical", periodical ), REFTYPE( "proceedings", proceedings ), REFTYPE( "report", report ), REFTYPE( "techreport", report ), /* REFTYPE( "set", set ), */ REFTYPE( "thesis", thesis ), REFTYPE( "phdthesis", phdthesis ), /* legacy */ REFTYPE( "mastersthesis", mastersthesis ), /* legacy */ REFTYPE( "unpublished", unpublished ), }; int biblatex_nall = sizeof( biblatex_all ) / sizeof( variants ); bibutils_4.12/lib/bibcore.c0000644000076400007640000003356311445455722016121 0ustar cdputnamcdputnam/* * bibcore.c * * Copyright (c) Chris Putnam 2005-2010 * * Source code released under the GPL * */ #include #include #include "bibutils.h" /* internal includes */ #include "reftypes.h" #include "newstr_conv.h" #include "is_ws.h" static void bibl_duplicateparams( param *np, param *op ) { list_init( &(np->asis) ); list_init( &(np->corps) ); list_copy( &(np->asis), &(op->asis ) ); list_copy( &(np->corps), &(op->corps ) ); if ( !op->progname ) np->progname = NULL; else np->progname = strdup( op->progname ); np->readformat = op->readformat; np->writeformat = op->writeformat; np->charsetin = op->charsetin; np->charsetin_src = op->charsetin_src; np->utf8in = op->utf8in; np->latexin = op->latexin; np->xmlin = op->xmlin; np->charsetout = op->charsetout; np->charsetout_src = op->charsetout_src; np->utf8out = op->utf8out; np->utf8bom = op->utf8bom; np->latexout = op->latexout; np->xmlout = op->xmlout; np->nosplittitle = op->nosplittitle; np->verbose = op->verbose; np->format_opts = op->format_opts; np->addcount = op->addcount; np->output_raw = op->output_raw; np->singlerefperfile = op->singlerefperfile; np->readf = op->readf; np->processf = op->processf; np->cleanf = op->cleanf; np->typef = op->typef; np->convertf = op->convertf; np->headerf = op->headerf; np->footerf = op->footerf; np->writef = op->writef; np->all = op->all; np->nall = op->nall; } static void bibl_setreadparams( param *np, param *op ) { bibl_duplicateparams( np, op ); np->utf8out = 1; np->charsetout = BIBL_CHARSET_UNICODE; np->charsetout_src = BIBL_SRC_DEFAULT; np->xmlout = 0; np->latexout = 0; } static void bibl_setwriteparams( param *np, param *op ) { bibl_duplicateparams( np, op ); np->xmlin = 0; np->latexin = 0; np->utf8in = 1; np->charsetin = BIBL_CHARSET_UNICODE; np->charsetin_src = BIBL_SRC_DEFAULT; } void bibl_freeparams( param *p ) { list_free( &(p->asis) ); list_free( &(p->corps) ); if ( p->progname ) free( p->progname ); } static void bibl_readlist( list *pl, char *progname, char *filename ) { if ( !list_fill( pl, filename ) ) { fprintf( stderr, "%s: warning problems reading '%s' " "obtained %d elements\n", progname, filename, pl->n ); } } void bibl_readasis( param *p, char *filename ) { bibl_readlist( &(p->asis), p->progname, filename ); } void bibl_readcorps( param *p, char *filename ) { bibl_readlist( &(p->corps), p->progname, filename ); } static void bibl_addtolist( list *pl, char *entry ) { list_add( pl, entry ); } void bibl_addtoasis( param *p, char *entry ) { bibl_addtolist( &(p->asis), entry ); } void bibl_addtocorps( param *p, char *entry ) { bibl_addtolist( &(p->corps), entry ); } void bibl_reporterr( int err ) { fprintf( stderr, "Bibutils: " ); switch( err ) { case BIBL_OK: fprintf( stderr, "No error." ); break; case BIBL_ERR_BADINPUT: fprintf( stderr, "Bad input." ); break; case BIBL_ERR_MEMERR: fprintf( stderr, "Memory error." ); break; case BIBL_ERR_CANTOPEN: fprintf( stderr, "Can't open." ); break; default: fprintf( stderr, "Cannot identify error code."); break; } fprintf( stderr, "\n" ); } static int bibl_illegalinmode( int mode ) { if ( mode < BIBL_FIRSTIN || mode > BIBL_LASTIN ) return 1; else return 0; } static int bibl_illegaloutmode( int mode ) { if ( mode < BIBL_FIRSTOUT || mode > BIBL_LASTOUT ) return 1; else return 0; } void bibl_verbose2( fields *info, char *filename, long nrefs ) { int i; fprintf( stderr, "======== %s %ld : converted\n", filename, nrefs ); for ( i=0; infields; ++i ) { fprintf( stderr, "'%s'='%s' level=%d\n", info->tag[i].data, info->data[i].data , info->level[i]); } fprintf( stderr, "\n" ); fflush( stderr ); } void bibl_verbose1( fields *info, fields *orig, char *filename, long nrefs ) { int i; fprintf( stderr, "======== %s %ld : processed\n", filename, nrefs ); for ( i=0; infields; ++i ) { fprintf( stderr, "'%s'='%s' level=%d\n", orig->tag[i].data, orig->data[i].data , orig->level[i]); } if ( info ) bibl_verbose2( info, filename, nrefs ); } void bibl_verbose0( bibl *bin ) { int i; for ( i=0; inrefs; ++i ) bibl_verbose2( bin->ref[i], "", i+1 ); } static void process_alwaysadd( fields *info, int reftype, param *r ) { char tag[512], data[512], *p, *q; int i, process, level; for ( i=0; iall[reftype].ntags; ++i ) { process = ((r->all[reftype]).tags[i]).processingtype; if ( process!=ALWAYS ) continue; level = ((r->all[reftype]).tags[i]).level; p = ((r->all[reftype]).tags[i]).newstr; q = tag; while ( p && *p && *p!='|' ) { *q = *p; q++; p++; } *q = '\0'; q = data; if ( p && *p=='|' ) p++; while ( p && *p ) { *q = *p; q++; p++; } *q = '\0'; fields_add( info, tag, data, level ); } } static int read_ref( FILE *fp, bibl *bin, char *filename, param *p ) { newstr reference, line; fields *ref; char buf[256]=""; int nrefs = 0, bufpos = 0, fcharset;/* = CHARSET_UNKNOWN;*/ newstr_init( &reference ); newstr_init( &line ); while ( p->readf( fp, buf, sizeof(buf), &bufpos, &line, &reference, &fcharset ) ) { if ( reference.len==0 ) continue; ref = fields_new(); if ( !ref ) return BIBL_ERR_MEMERR; if ( p->processf( ref, reference.data, filename, nrefs+1 )){ bibl_addref( bin, ref ); } else { fields_free( ref ); free( ref ); } newstr_empty( &reference ); if ( fcharset!=CHARSET_UNKNOWN ) { /* charset from file takes priority over default, but * not user-specified */ if ( p->charsetin_src!=BIBL_SRC_USER ) { p->charsetin_src = BIBL_SRC_FILE; p->charsetin = fcharset; if ( fcharset!=CHARSET_UNICODE ) p->utf8in = 0; } } } if ( p->charsetin==CHARSET_UNICODE ) p->utf8in = 1; newstr_free( &line ); newstr_free( &reference ); return BIBL_OK; } static void bibl_fixcharsets( bibl *b, param *p ) { fields *ref; long i, j; int swap = 0; int latexout = p->latexout; int latexin = p->latexin; for ( i=0; inrefs; ++i ) { ref = b->ref[i]; for ( j=0; jnfields; ++j ) { if ( latexin || latexout ) { /* don't texify/detexify URL's and the like */ if ( !strcasecmp( ref->tag[j].data, "DOI" ) || !strcasecmp( ref->tag[j].data, "URL" ) || !strcasecmp( ref->tag[j].data, "REFNUM" )){ latexin = 0; latexout = 0; swap = 1; } } newstr_convert( &(ref->data[j]), p->charsetin, latexin, p->utf8in, p->xmlin, p->charsetout, latexout, p->utf8out, p->xmlout ); if ( swap ) { swap = 0; latexin = p->latexin; latexout = p->latexout; } } } } static int build_refnum( fields *info, long nrefs ) { newstr refnum; char *p, num[512]; int y, a; newstr_init( &refnum ); y = fields_find( info, "YEAR", 0 ); if ( y==-1 ) y = fields_find( info, "YEAR", -1 ); if ( y==-1 ) y = fields_find( info, "PARTYEAR", -1 ); a = fields_find( info, "AUTHOR", 0 ); if ( a==-1 ) a = fields_find( info, "AUTHOR", -1 ); if ( a==-1 ) a = fields_find( info, "AUTHOR:CORP", -1 ); if ( a==-1 ) a = fields_find( info, "AUTHOR:ASIS", -1 ); if ( a!=-1 && y!=-1 ) { p = info->data[a].data; while ( p && *p && *p!='|' ) newstr_addchar( &refnum, *p++ ); p = info->data[y].data; while ( p && *p && *p!=' ' && *p!='\t' ) newstr_addchar( &refnum, *p++ ); } else { sprintf( num, "%ld", nrefs ); newstr_strcpy( &refnum, "ref" ); newstr_strcat( &refnum, num ); } fields_add( info, "REFNUM", refnum.data, 0 ); newstr_free( &refnum ); return fields_find( info, "REFNUM", 0 ); } static void bibl_checkrefid( bibl *b, param *p ) { fields *ref; long i; char buf[512]; int n; for ( i=0; inrefs; ++i ) { ref = b->ref[i]; n = fields_find( ref, "REFNUM", 0 ); if ( n==-1 ) n = build_refnum( ref, i+1 ); if ( p->addcount ) { sprintf( buf, "_%ld", i+1 ); newstr_strcat( &(ref->data[n]), buf ); } } } static int generate_citekey( fields *info, int nref ) { newstr citekey; int n1, n2; char *p, buf[100]; newstr_init( &citekey ); n1 = fields_find( info, "AUTHOR", 0 ); if ( n1==-1 ) n1 = fields_find( info, "AUTHOR", -1 ); n2 = fields_find( info, "YEAR", 0 ); if ( n2==-1 ) n2 = fields_find( info, "YEAR", -1 ); if ( n2==-1 ) n2 = fields_find( info, "PARTYEAR", 0 ); if ( n2==-1 ) n2 = fields_find( info, "PARTYEAR", -1 ); if ( n1!=-1 && n2!=-1 ) { p = info->data[n1].data; while ( p && *p && *p!='|' ) { if ( !is_ws( *p ) ) newstr_addchar( &citekey, *p ); p++; } p = info->data[n2].data; while ( p && *p ) { if ( !is_ws( *p ) ) newstr_addchar( &citekey, *p ); p++; } fields_add( info, "REFNUM", citekey.data, 0 ); } else { sprintf( buf, "ref%d\n", nref ); newstr_strcpy( &citekey, buf ); } newstr_free( &citekey ); return fields_find( info, "REFNUM", -1 ); } static void resolve_citekeys( bibl *b, list *citekeys, int *dup ) { char abc[]="abcdefghijklmnopqrstuvwxyz"; newstr tmp; int nsame, ntmp, n, i, j; newstr_init( &tmp ); for ( i=0; in; ++i ) { if ( dup[i]==-1 ) continue; nsame = 0; for ( j=i; jn; ++j ) { if ( dup[j]!=i ) continue; newstr_newstrcpy( &tmp, &(citekeys->str[j]) ); ntmp = nsame; while ( ntmp >= 26 ) { newstr_addchar( &tmp, 'a' ); ntmp -= 26; } if ( ntmp<26 && ntmp>=0 ) newstr_addchar( &tmp, abc[ntmp] ); nsame++; dup[j] = -1; n = fields_find( b->ref[j], "REFNUM", -1 ); if ( n!=-1 ) newstr_newstrcpy(&((b->ref[j])->data[n]),&tmp); } } newstr_free( &tmp ); } static void get_citekeys( bibl *b, list *citekeys ) { fields *info; int i, n; for ( i=0; inrefs; ++i ) { info = b->ref[i]; n = fields_find( info, "REFNUM", -1 ); if ( n==-1 ) n = generate_citekey( info, i ); if ( n!=-1 && info->data[n].data ) list_add( citekeys, info->data[n].data ); else list_add( citekeys, "" ); } } static int dup_citekeys( bibl *b, list *citekeys ) { int i, j, *dup, ndup=0; dup = ( int * ) malloc( sizeof( int ) * citekeys->n ); if ( !dup ) return 0; for ( i=0; in; ++i ) dup[i] = -1; for ( i=0; in-1; ++i ) { if ( dup[i]!=-1 ) continue; for ( j=i+1; jn; ++j ) { if ( !strcmp( citekeys->str[i].data, citekeys->str[j].data ) ) { dup[i] = i; dup[j] = i; ndup++; } } } if ( ndup ) resolve_citekeys( b, citekeys, dup ); free( dup ); return ndup; } static void uniqueify_citekeys( bibl *b ) { list citekeys; list_init( &citekeys ); get_citekeys( b, &citekeys ); dup_citekeys( b, &citekeys ); list_free( &citekeys ); } static int convert_ref( bibl *bin, char *fname, bibl *bout, param *p ) { fields *rin, *rout; long i; int reftype; if ( p->cleanf ) p->cleanf( bin, p ); for ( i=0; inrefs; ++i ) { rin = bin->ref[i]; rout = fields_new(); if ( !rout ) return BIBL_ERR_MEMERR; if ( p->typef ) reftype = p->typef( rin, fname, i+1, p, p->all, p->nall ); else reftype = 0; if ( p->all ) process_alwaysadd( rout, reftype, p ); p->convertf( rin, rout, reftype, p, p->all, p->nall ); if ( p->verbose ) bibl_verbose1( rout, rin, fname, i+1 ); bibl_addref( bout, rout ); } uniqueify_citekeys( bout ); return BIBL_OK; } int bibl_read( bibl *b, FILE *fp, char *filename, param *p ) { param lp; bibl bin; if ( !b ) return BIBL_ERR_BADINPUT; if ( !fp ) return BIBL_ERR_BADINPUT; if ( !p ) return BIBL_ERR_BADINPUT; if ( bibl_illegalinmode( p->readformat ) ) return BIBL_ERR_BADINPUT; bibl_setreadparams( &lp, p ); bibl_init( &bin ); read_ref( fp, &bin, filename, &lp ); if ( !lp.output_raw || ( lp.output_raw & BIBL_RAW_WITHCHARCONVERT ) ) bibl_fixcharsets( &bin, &lp ); if ( !lp.output_raw ) convert_ref( &bin, filename, b, &lp ); else { if ( p->verbose > 1 ) bibl_verbose0( &bin ); bibl_copy( b, &bin ); } if ( !lp.output_raw || ( lp.output_raw & BIBL_RAW_WITHMAKEREFID ) ) bibl_checkrefid( b, &lp ); bibl_free( &bin ); return BIBL_OK; } static FILE * singlerefname( fields *reffields, long nref, int mode ) { char outfile[2048]; char suffix[5] = "xml"; FILE *fp; long count; int found; if ( mode==BIBL_BIBTEXOUT ) strcpy( suffix, "bib" ); else if ( mode==BIBL_RISOUT ) strcpy( suffix, "ris" ); else if ( mode==BIBL_ENDNOTEOUT ) strcpy( suffix, "end" ); else if ( mode==BIBL_ADSABSOUT ) strcpy( suffix, "ads" ); found = fields_find( reffields, "REFNUM", 0 ); /* find new filename based on reference */ if ( found!=-1 ) { sprintf( outfile,"%s.%s",reffields->data[found].data, suffix ); } else sprintf( outfile,"%ld.%s",nref, suffix ); count = 0; fp = fopen( outfile, "r" ); while ( fp ) { fclose(fp); count++; if ( count==60000 ) return NULL; if ( found!=-1 ) sprintf( outfile, "%s_%ld.%s", reffields->data[found].data, count, suffix ); else sprintf( outfile,"%ld_%ld.%s",nref, count, suffix ); fp = fopen( outfile, "r" ); } return fopen( outfile, "w" ); } static int output_bibl( FILE *fp, bibl *b, param *p ) { long i; if ( !p->singlerefperfile && p->headerf ) p->headerf( fp, p ); for ( i=0; inrefs; ++i ) { if ( p->singlerefperfile ) { fp = singlerefname( b->ref[i], i, p->writeformat ); if ( fp ) { if ( p->headerf ) p->headerf( fp, p ); } else return BIBL_ERR_CANTOPEN; } p->writef( b->ref[i], fp, p, i ); if ( p->singlerefperfile ) { if ( p->footerf ) p->footerf( fp ); fclose( fp ); } } if ( !p->singlerefperfile && p->footerf ) p->footerf( fp ); return 1; } int bibl_write( bibl *b, FILE *fp, param *p ) { param lp; if ( !b ) return BIBL_ERR_BADINPUT; if ( !p ) return BIBL_ERR_BADINPUT; if ( bibl_illegaloutmode( p->writeformat ) ) return BIBL_ERR_BADINPUT; if ( !fp && ( !p || !p->singlerefperfile ) ) return BIBL_ERR_BADINPUT; bibl_setwriteparams( &lp, p ); bibl_fixcharsets( b, &lp ); output_bibl( fp, b, &lp ); return BIBL_OK; } bibutils_4.12/lib/xml_encoding.h0000644000076400007640000000033111444072056017144 0ustar cdputnamcdputnam/* * xml_getencoding.h * * Copyright (c) Chris Putnam 2007-2009 * * Source code released under the GPL * */ #ifndef XML_GETENCODING_H #define XML_GETENCODING_H extern int xml_getencoding( newstr *s ); #endif bibutils_4.12/lib/xml.c0000644000076400007640000001711511444072056015301 0ustar cdputnamcdputnam/* * xml.c * * Copyright (c) Chris Putnam 2004-2010 * * Source code released under the GPL * */ #include #include #include #include "is_ws.h" #include "strsearch.h" #include "newstr.h" #include "xml.h" char *xml_pns = NULL; static xml_attrib * xmlattrib_new( void ) { xml_attrib *a = (xml_attrib *) malloc( sizeof( xml_attrib ) ); if ( a ) { list_init( &(a->attrib) ); list_init( &(a->value) ); } return a; } static void xmlattrib_add( xml_attrib *a, char *attrib, char *value ) { if ( attrib ) list_add( &(a->attrib), attrib ); else list_add( &(a->attrib), "" ); if ( value ) list_add( &(a->value), value ); else list_add( &(a->value), "" ); } static void xmlattrib_free( xml_attrib *a ) { list_free( &(a->attrib) ); list_free( &(a->value ) ); } static xml * xml_new( void ) { xml *x = ( xml * ) malloc( sizeof( xml ) ); if ( x ) xml_init( x ); return x; } void xml_free( xml *x ) { if ( x->tag ) { newstr_free( x->tag ); free( x->tag ); } if ( x->value ) { newstr_free( x->value ); free( x->value ); } if ( x->a ) { xmlattrib_free( x->a ); free( x->a ); } if ( x->down ) xml_free( x->down ); if ( x->next ) xml_free( x->next ); } void xml_init( xml *x ) { x->tag = newstr_new(); x->value = newstr_new(); x->a = NULL; x->down = NULL; x->next = NULL; if ( !(x->tag) || !(x->value) ) { fprintf(stderr,"xml_init: memory error.\n"); exit( EXIT_FAILURE ); } } enum { XML_DESCRIPTOR, XML_COMMENT, XML_OPEN, XML_CLOSE, XML_OPENCLOSE }; static int xml_terminator( char *p, int *type ) { if ( *p=='>' ) { return 1; } else if ( *p=='/' && *(p+1)=='>' ) { if ( *type==XML_OPENCLOSE ) return 1; else if ( *type==XML_OPEN ) { *type = XML_OPENCLOSE; return 1; } } else if ( *p=='?' && *(p+1)=='>' && *type==XML_DESCRIPTOR ) { return 1; } else if ( *p=='!' && *(p+1)=='>' && *type==XML_COMMENT ) { return 1; } return 0; } static char * xml_processattrib( char *p, xml_attrib **ap, int *type ) { xml_attrib *a = NULL; char quote_character = '\"'; int inquotes = 0; newstr aname, aval; newstr_init( &aname ); newstr_init( &aval ); while ( *p && !xml_terminator(p,type) ) { /* get attribute name */ while ( *p==' ' || *p=='\t' ) p++; while ( *p && !strchr( "= \t", *p ) && !xml_terminator(p,type)){ newstr_addchar( &aname, *p ); p++; } while ( *p==' ' || *p=='\t' ) p++; if ( *p=='=' ) p++; /* get attribute value */ while ( *p==' ' || *p=='\t' ) p++; if ( *p=='\"' || *p=='\'' ) { if ( *p=='\'' ) quote_character = *p; inquotes=1; p++; } while ( *p && ((!xml_terminator(p,type) && !strchr("= \t", *p ))||inquotes)){ if ( *p==quote_character ) inquotes=0; else newstr_addchar( &aval, *p ); p++; } if ( aname.len ) { if ( !a ) a = xmlattrib_new(); xmlattrib_add( a, aname.data, aval.data ); } newstr_empty( &aname ); newstr_empty( &aval ); } newstr_free( &aname ); newstr_free( &aval ); *ap = a; return p; } /* * xml_processtag * * XML_COMMENT * XML_DESCRIPTOR * XML_OPEN * XML_CLOSE * XML_OPENCLOSE */ static char * xml_processtag( char *p, newstr *tag, xml_attrib **attrib, int *type ) { *attrib = NULL; if ( *p=='<' ) p++; if ( *p=='!' ) { while ( *p && *p!='>' ) newstr_addchar( tag, *p++ ); *type = XML_COMMENT; } else if ( *p=='?' ) { *type = XML_DESCRIPTOR; p++; /* skip '?' */ while ( *p && !strchr( " \t", *p ) && !xml_terminator(p,type) ) newstr_addchar( tag, *p++ ); if ( *p==' ' || *p=='\t' ) p = xml_processattrib( p, attrib, type ); } else if ( *p=='/' ) { while ( *p && !strchr( " \t", *p ) && !xml_terminator(p,type) ) newstr_addchar( tag, *p++ ); *type = XML_CLOSE; if ( *p==' ' || *p=='\t' ) p = xml_processattrib( p, attrib, type ); } else { *type = XML_OPEN; while ( *p && !strchr( " \t", *p ) && !xml_terminator(p,type) ) newstr_addchar( tag, *p++ ); if ( *p==' ' || *p=='\t' ) p = xml_processattrib( p, attrib, type ); } while ( *p && *p!='>' ) p++; if ( *p=='>' ) p++; return p; } static void xml_appendnode( xml *onode, xml *nnode ) { if ( !onode->down ) onode->down = nnode; else { xml *p = onode->down; while ( p->next ) p = p->next; p->next = nnode; } } char * xml_tree( char *p, xml *onode ) { newstr tag; xml_attrib *attrib; int type, is_style = 0; newstr_init( &tag ); while ( *p ) { /* retain white space for