/* process_cite() * */ static int process_cite( fields *bibin, char *p, char *filename, long nref ) { int fstatus, status = BIBL_OK; newstr tag, data; newstrs_init( &tag, &data, NULL ); p = process_bibtextype( p, &data ); if ( data.len ) { fstatus = fields_add( bibin, "INTERNAL_TYPE", data.data, 0 ); if ( fstatus!=FIELDS_OK ) { status = BIBL_ERR_MEMERR; goto out; } } p = process_bibtexid( p, &data ); if ( data.len ) { fstatus = fields_add( bibin, "REFNUM", data.data, 0 ); if ( fstatus!=FIELDS_OK ) { status = BIBL_ERR_MEMERR; goto out; } } while ( *p ) { p = process_bibtexline( p, &tag, &data, 1, bibin ); if ( p==NULL ) { status = BIBL_ERR_MEMERR; goto out; } /* no anonymous or empty fields allowed */ if ( tag.len && data.len ) { fstatus = fields_add( bibin, tag.data, data.data, 0 ); if ( fstatus!=FIELDS_OK ) { status = BIBL_ERR_MEMERR; goto out; } } newstrs_empty( &tag, &data, NULL ); } out: newstrs_free( &tag, &data, NULL ); return status; }
static int medin_doconvert( xml *node, fields *info, xml_convert *c, int nc, int *found ) { int i, fstatus; char *d; *found = 0; if ( !xml_hasdata( node ) ) return BIBL_OK; 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; fstatus = fields_add( info, c[i].out, d, c[i].level ); if ( fstatus!=FIELDS_OK ) return BIBL_ERR_MEMERR; } } else { if ( xml_tag_attrib( node, c[i].in, c[i].a, c[i].aval)){ *found = 1; fstatus = fields_add( info, c[i].out, d, c[i].level ); if ( fstatus!=FIELDS_OK ) return BIBL_ERR_MEMERR; } } } return BIBL_OK; }
static int medin_assembleref( xml *node, fields *info ) { int status = BIBL_OK; if ( node->down ) { if ( xml_tagexact( node, "PubmedArticle" ) ) status = medin_pubmedarticle( node->down, info ); else if ( xml_tagexact( node, "MedlineCitation" ) ) status = medin_medlinecitation( node->down, info ); else status = medin_assembleref( node->down, info ); } if ( status!=BIBL_OK ) return status; if ( node->next ) { status = medin_assembleref( node->next, info ); if ( status!=BIBL_OK ) return status; } /* assume everything is a journal article */ if ( fields_num( info ) ) { status = fields_add( info, "RESOURCE", "text", 0 ); if ( status!=FIELDS_OK ) return BIBL_ERR_MEMERR; status = fields_add( info, "ISSUANCE", "continuing", 1 ); if ( status!=FIELDS_OK ) return BIBL_ERR_MEMERR; status = fields_add( info, "GENRE", "periodical", 1 ); if ( status!=FIELDS_OK ) return BIBL_ERR_MEMERR; status = fields_add( info, "GENRE", "academic journal", 1 ); if ( status!=FIELDS_OK ) return BIBL_ERR_MEMERR; status = BIBL_OK; } return status; }
/* <MedlineDate>2003 Jan-Feb</MedlineDate> */ static int medin_medlinedate( fields *info, char *p, int level ) { int fstatus; newstr tmp; newstr_init( &tmp ); p = newstr_cpytodelim( &tmp, skip_ws( p ), " \t\n\r", 0 ); if ( newstr_memerr( &tmp ) ) return BIBL_ERR_MEMERR; if ( tmp.len > 0 ) { fstatus = fields_add( info, "PARTYEAR", tmp.data, level ); if ( fstatus!=FIELDS_OK ) return BIBL_ERR_MEMERR; } p = newstr_cpytodelim( &tmp, skip_ws( p ), " \t\n\r", 0 ); if ( newstr_memerr( &tmp ) ) return BIBL_ERR_MEMERR; if ( tmp.len > 0 ) { newstr_findreplace( &tmp, "-", "/" ); fstatus = fields_add( info, "PARTMONTH", tmp.data, level ); if ( fstatus!=FIELDS_OK ) return BIBL_ERR_MEMERR; } p = newstr_cpytodelim( &tmp, skip_ws( p ), " \t\n\r", 0 ); if ( newstr_memerr( &tmp ) ) return BIBL_ERR_MEMERR; if ( tmp.len > 0 ) { fstatus = fields_add( info, "PARTDAY", tmp.data, level ); if ( fstatus!=FIELDS_OK ) return BIBL_ERR_MEMERR; } newstr_free( &tmp ); return BIBL_OK; }
static void process_pages( fields *info, newstr *s, int level ) { char *p, *q; newstr sp, ep; newstr_init( &sp ); newstr_init( &ep ); newstr_findreplace( s, " ", "" ); p = q = s->data; while ( isdigit( *q ) ) q++; newstr_segcpy( &sp, p, q ); if ( sp.len>0 ) fields_add( info, "PAGESTART", sp.data, level ); p = q; while ( *p && !isdigit(*p) ) p++; q = p; while ( isdigit( *q ) ) q++; newstr_segcpy( &ep, p, q ); if ( ep.len>0 ) fields_add( info, "PAGEEND", ep.data, level ); newstr_free(&sp); newstr_free(&ep); }
int isiin_processf( fields *isiin, char *p, char *filename, long nref ) { newstr tag, data; int n; newstr_init( &tag ); newstr_init( &data ); while ( *p ) { newstr_empty( &tag ); newstr_empty( &data ); 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 ); } } } } newstr_free( &data ); newstr_free( &tag ); return 1; }
int endin_processf( fields *endin, char *p, char *filename, long nref ) { newstr tag, data; int n; newstr_init( &tag ); newstr_init( &data ); while ( *p ) { if ( endin_istag( p ) ) { p = process_endline( &tag, &data, p ); /* no empty fields allowed */ if ( data.len ) { fields_add( endin, tag.data, data.data, 0 ); } } else { p = process_endline2( &tag, &data, p ); /* endnote puts %K only on 1st line of keywords */ n = endin->nfields; if ( n>0 && data.len ) { if ( !strncmp( endin->tag[n-1].data, "%K", 2 ) ) { fields_add( endin, "%K", data.data, 0 ); } else { newstr_addchar( &(endin->data[n-1]), ' ' ); newstr_strcat( &(endin->data[n-1]), data.data ); } } } newstr_empty( &tag ); newstr_empty( &data ); } newstr_free( &tag ); newstr_free( &data ); return 1; }
int pages_add( fields *bibout, char *outtag, newstr *invalue, int level ) { int fstatus, status = 1; newstr start, stop; newstr_init( &start ); newstr_init( &stop ); extract_range( invalue, &start, &stop ); if ( newstr_memerr( &start ) || newstr_memerr( &stop ) ) { status = 0; goto out; } if ( start.len>0 ) { fstatus = fields_add( bibout, "PAGES:START", start.data, level ); if ( fstatus!=FIELDS_OK ) { status = 0; goto out; } } if ( stop.len>0 ) { fstatus = fields_add( bibout, "PAGES:STOP", stop.data, level ); if ( fstatus!=FIELDS_OK ) status = 0; } out: newstr_free( &start ); newstr_free( &stop ); return status; }
static int risin_linkedfile( fields *bibin, newstr *intag, newstr *invalue, int level, param *pm, char *outtag, fields *bibout ) { int fstatus, n; char *p; /* if URL is file:///path/to/xyz.pdf, only store "///path/to/xyz.pdf" */ n = is_uri_file_scheme( invalue->data ); if ( n ) { /* skip past "file:" and store only actual path */ p = invalue->data + n; fstatus = fields_add( bibout, outtag, p, level ); if ( fstatus==FIELDS_OK ) return BIBL_OK; else return BIBL_ERR_MEMERR; } /* if URL is http:, ftp:, etc. store as a URL */ n = is_uri_remote_scheme( invalue->data ); if ( n!=-1 ) { fstatus = fields_add( bibout, "URL", invalue->data, level ); if ( fstatus==FIELDS_OK ) return BIBL_OK; else return BIBL_ERR_MEMERR; } /* badly formed, RIS wants URI, but store value anyway */ fstatus = fields_add( bibout, outtag, invalue->data, level ); if ( fstatus==FIELDS_OK ) return BIBL_OK; else return BIBL_ERR_MEMERR; }
static void process_url( fields *info, char *p, int level ) { if ( !strncasecmp( p, "\\urllink", 8 ) ) fields_add( info, "URL", p+8, level ); else if ( !strncasecmp( p, "\\url", 4 ) ) fields_add( info, "URL", p+4, level ); else fields_add( info, "URL", p, level ); }
/* oxfordjournals hide the DOI in the NOTES N1 field */ static void notes_add( fields *info, char *tag, newstr *s, int level ) { int doi = is_doi( s->data ); if ( doi!=-1 ) fields_add( info, "DOI", &(s->data[doi]), level ); else fields_add( info, tag, s->data, level ); }
/* Wiley EndNote download has DOI's in "%1" tag */ static void addnotes( fields *info, char *tag, char *data, int level ) { int doi = is_doi( data ); if ( doi!=-1 ) fields_add( info, "DOI", &(data[doi]), level ); else fields_add( info, tag, data, level ); }
/* Wiley's EndNote download has DOI's in "%1" tag */ static int endin_addnotes( fields *info, char *tag, char *data, int level ) { int doi = is_doi( data ); if ( doi!=-1 ) return fields_add( info, "DOI", &(data[doi]), level ); else return fields_add( info, tag, data, level ); }
/* * BibTeX uses 'organization' in lieu of publisher if that field is missing. * Otherwise output as * <name type="corporate"> * <namePart>The organization</namePart> * <role> * <roleTerm authority="marcrelator" type="text">organizer of meeting</roleTerm> * </role> * </name> */ static int process_organization( fields *bibin, fields *info, newstr *d, int level ) { int n, fstatus; n = fields_find( bibin, "publisher", LEVEL_ANY ); if ( n==-1 ) fstatus = fields_add( info, "PUBLISHER", d->data, level ); else fstatus = fields_add( info, "ORGANIZER:CORP", d->data, level ); if ( fstatus==FIELDS_OK ) return BIBL_OK; else return BIBL_ERR_MEMERR; }
void endin_convertf( fields *endin, fields *info, int reftype, param *p, variants *all, int nall ) { newstr *d; int i, level, n, process; char *newtag, *t; for ( i=0; i<endin->nfields; ++i ) { /* Ensure that data exists */ d = &( endin->data[i] ); if ( !(d->data) || d->len==0 ) continue; /* * All refer format tags start with '%'. If we have one * that doesn't, assume that it comes from endx2xml * and just copy and paste to output */ t = endin->tag[i].data; if ( t[0]!='%' ) { fields_add( info, t, d->data, endin->level[i] ); continue; } n = process_findoldtag( t, reftype, all, nall ); if ( n==-1 ) { endin_notag( p, t, d->data ); continue; } process = ((all[reftype]).tags[n]).processingtype; if ( process == ALWAYS ) continue; /* add these later */ level = ((all[reftype]).tags[n]).level; newtag = ((all[reftype]).tags[n]).newstr; if ( process==SIMPLE ) fields_add( info, newtag, d->data, level ); else if ( process==TYPE ) addtype( info, d->data, level ); else if ( process==TITLE ) title_process( info, newtag, d->data, level ); else if ( process==PERSON ) name_add( info, newtag, d->data, level, &(p->asis), &(p->corps) ); else if ( process==DATE ) adddate( info, t, newtag,d->data,level); else if ( process==PAGES ) addpage( info, d->data, level ); else if ( process==SERIALNO ) addsn( info, d->data, level ); else if ( process==NOTES ) addnotes( info, newtag, d->data, level ); else { /* fprintf(stderr,"%s: internal error -- illegal process %d\n", r->progname, process ); */ } } }
static int wordin_pages( xml *node, fields *info ) { int i, status, ret = BIBL_OK; newstr sp, ep; char *p; newstrs_init( &sp, &ep, NULL ); p = xml_data( node ); while ( *p && *p!='-' ) newstr_addchar( &sp, *p++ ); if ( newstr_memerr( &sp ) ) { ret = BIBL_ERR_MEMERR; goto out; } if ( *p=='-' ) p++; while ( *p ) newstr_addchar( &ep, *p++ ); if ( newstr_memerr( &ep ) ) { ret = BIBL_ERR_MEMERR; goto out; } if ( sp.len ) { status = fields_add( info, "PAGES:START", sp.data, 1 ); if ( status!=FIELDS_OK ) { ret = BIBL_ERR_MEMERR; goto out; } } if ( ep.len ) { if ( sp.len > ep.len ) { for ( i=sp.len-ep.len; i<sp.len; ++i ) sp.data[i] = ep.data[i-sp.len+ep.len]; status = fields_add( info, "PAGES:STOP", sp.data, 1 ); } else status = fields_add( info, "PAGES:STOP", ep.data, 1 ); if ( status!=FIELDS_OK ) { ret = BIBL_ERR_MEMERR; goto out; } } out: newstrs_free( &sp, &ep, NULL ); return ret; }
/* <Langauge>eng</Language> */ static int medin_language( xml *node, fields *info, int level ) { char *code, *language; int fstatus; code = xml_data( node ); if ( !code ) return BIBL_OK; language = iso639_2_from_code( code ); if ( language ) fstatus = fields_add( info, "LANGUAGE", language, level ); else fstatus = fields_add( info, "LANGUAGE", code, level ); if ( fstatus==FIELDS_OK ) return BIBL_OK; else return BIBL_ERR_MEMERR; }
static int endin_addtype( fields *info, char *data, int level ) { lookups types[] = { { "GENERIC", "ARTICLE" }, { "BOOK", "BOOK" }, { "MANUSCRIPT", "MANUSCRIPT" }, { "CONFERENCE PROCEEDINGS", "INPROCEEDINGS"}, { "REPORT", "REPORT" }, { "COMPUTER PROGRAM", "BOOK" }, { "AUDIOVISUAL MATERIAL", "AUDIOVISUAL" }, { "ARTWORK", "BOOK" }, { "PATENT", "BOOK" }, { "BILL", "BILL" }, { "CASE", "CASE" }, { "JOURNAL ARTICLE", "ARTICLE" }, { "MAGAZINE ARTICLE", "ARTICLE" }, { "BOOK SECTION", "INBOOK" }, { "EDITED BOOK", "BOOK" }, { "NEWSPAPER ARTICLE", "NEWSARTICLE" }, { "THESIS", "PHDTHESIS" }, { "PERSONAL COMMUNICATION", "COMMUNICATION" }, { "ELECTRONIC SOURCE", "TEXT" }, { "FILM OR BROADCAST", "AUDIOVISUAL" }, { "MAP", "MAP" }, { "HEARING", "HEARING" }, { "STATUTE", "STATUTE" }, { "CHART OR TABLE", "CHART" }, { "WEB PAGE", "WEBPAGE" }, }; int ntypes = sizeof( types ) / sizeof( lookups ); int i, ok, found=0; for ( i=0; i<ntypes; ++i ) { if ( !strcasecmp( types[i].oldstr, data ) ) { found = 1; ok = fields_add( info, "INTERNAL_TYPE", types[i].newstr, level ); if ( !ok ) return 0; } } if ( !found ) { fprintf( stderr, "Did not identify reference type '%s'\n", data ); fprintf( stderr, "Defaulting to journal article type\n"); ok = fields_add( info, "INTERNAL_TYPE", types[0].newstr, level ); if ( !ok ) return 0; } return 1; }
static int bibtexin_crossref_oneref( fields *bibref, fields *bibcross ) { int j, n, nl, ntype, fstatus, status = BIBL_OK; char *type, *nt, *nv; ntype = fields_find( bibref, "INTERNAL_TYPE", -1 ); type = ( char * ) fields_value( bibref, ntype, FIELDS_CHRP_NOUSE ); n = fields_num( bibcross ); for ( j=0; j<n; ++j ) { nt = ( char * ) fields_tag( bibcross, j, FIELDS_CHRP_NOUSE ); if ( !strcasecmp( nt, "INTERNAL_TYPE" ) ) continue; if ( !strcasecmp( nt, "REFNUM" ) ) continue; if ( !strcasecmp( nt, "TITLE" ) ) { if ( !strcasecmp( type, "Inproceedings" ) || !strcasecmp( type, "Incollection" ) ) nt = "booktitle"; } nv = ( char * ) fields_value( bibcross, j, FIELDS_CHRP_NOUSE ); nl = fields_level( bibcross, j ) + 1; fstatus = fields_add( bibref, nt, nv, nl ); if ( fstatus!=FIELDS_OK ) { status = BIBL_ERR_MEMERR; goto out; } } out: return status; }
int risin_processf( fields *risin, char *p, char *filename, long nref ) { newstr tag, data; newstr_init( &tag ); newstr_init( &data ); while ( *p ) { if ( risin_istag( p ) ) { p = process_line( &tag, &data, p ); /* no anonymous fields allowed */ /* if ( tag.len && data.len )*/ if ( tag.len ) fields_add( risin, tag.data, data.data, 0 ); } else { p = process_line2( &tag, &data, p ); if ( data.len && risin->nfields>0 ) { newstr *od; od = &(risin->data[risin->nfields-1] ); newstr_addchar( od, ' ' ); newstr_strcat( od, data.data ); } } newstr_empty( &tag ); newstr_empty( &data ); } newstr_free( &tag ); newstr_free( &data ); return 1; }
static void addpage( fields *info, char *p, int level ) { newstr page; newstr_init( &page ); p = skip_ws( p ); while ( *p && !is_ws(*p) && *p!='-' && *p!='\r' && *p!='\n' ) newstr_addchar( &page, *p++ ); if ( page.len>0 ) fields_add( info, "PAGESTART", page.data, level ); newstr_empty( &page ); while ( *p && (is_ws(*p) || *p=='-' ) ) p++; while ( *p && !is_ws(*p) && *p!='-' && *p!='\r' && *p!='\n' ) newstr_addchar( &page, *p++ ); if ( page.len>0 ) fields_add( info, "PAGEEND", page.data, level ); newstr_free( &page ); }
static void bibtexin_crossref( bibl *bin, param *p ) { char booktitle[] = "booktitle"; long i, j, ncross; char *nt, *nd, *type; int n, ntype, nl; for ( i=0; i<bin->nrefs; ++i ) { n = fields_find( bin->ref[i], "CROSSREF", -1 ); if ( n==-1 ) continue; ncross = bibtexin_findref( bin, bin->ref[i]->data[n].data ); if ( ncross==-1 ) { bibtexin_nocrossref( bin, i, n, p ); continue; } ntype = fields_find( bin->ref[i], "TYPE", -1 ); type = bin->ref[i]->data[ntype].data; fields_setused( bin->ref[i], n ); /* bin->ref[i]->used[n] = 1; */ for ( j=0; j<bin->ref[ncross]->nfields; ++j ) { nt = bin->ref[ncross]->tag[j].data; if ( !strcasecmp( nt, "TYPE" ) ) continue; if ( !strcasecmp( nt, "REFNUM" ) ) continue; if ( !strcasecmp( nt, "TITLE" ) ) { if ( !strcasecmp( type, "Inproceedings" ) || !strcasecmp( type, "Incollection" ) ) nt = booktitle; } nd = bin->ref[ncross]->data[j].data; nl = bin->ref[ncross]->level[j] + 1; fields_add( bin->ref[i], nt, nd, nl ); } } }
int copacin_processf( fields *copacin, char *p, char *filename, long nref ) { newstr tag, data; int status; newstr_init( &tag ); newstr_init( &data ); while ( *p ) { p = skip_ws( p ); if ( copacin_istag( p ) ) { p = copacin_addtag2( p, &tag, &data ); /* don't add empty strings */ if ( tag.len && data.len ) { status = fields_add( copacin, tag.data, data.data, 0 ); if ( status!=FIELDS_OK ) return 0; } newstr_empty( &tag ); newstr_empty( &data ); } else p = copacin_nextline( p ); } newstr_free( &tag ); newstr_free( &data ); return 1; }
static int medin_authorlist( xml *node, fields *info ) { int fstatus, status; newstr name; char *tag; newstr_init( &name ); node = node->down; while ( node ) { if ( xml_tagexact( node, "Author" ) && node->down ) { status = medin_author( node->down, &name ); tag = "AUTHOR"; if ( !name.len ) { status = medin_corpauthor( node->down, &name ); tag = "AUTHOR:CORP"; } if ( newstr_memerr( &name ) || status!=BIBL_OK ) return BIBL_ERR_MEMERR; if ( name.len ) { fstatus = fields_add(info,tag,name.data,0); if ( fstatus!=FIELDS_OK ) return BIBL_ERR_MEMERR; } newstr_empty( &name ); } node = node->next; } newstr_free( &name ); return BIBL_OK; }
static int copacin_simple( fields *out, char *tag, char *value, int level ) { int fstatus = fields_add( out, tag, value, level ); if ( fstatus==FIELDS_OK ) return BIBL_OK; else return BIBL_ERR_MEMERR; }
/* Split keywords="" with semicolons. * Commas are also frequently used, but will break * entries like: * keywords="Microscopy, Confocal" * Returns BIBL_OK or BIBL_ERR_MEMERR */ static int process_keywords( fields *info, newstr *d, int level ) { int fstatus, status = BIBL_OK; newstr keyword; char *p; if ( !d || d->len==0 ) return BIBL_OK; p = d->data; newstr_init( &keyword ); while ( *p ) { p = newstr_cpytodelim( &keyword, skip_ws( p ), ";", 1 ); newstr_trimendingws( &keyword ); if ( newstr_memerr( &keyword ) ) { status = BIBL_ERR_MEMERR; goto out; } if ( keyword.len ) { fstatus = fields_add( info, "KEYWORD", keyword.data, level ); if ( fstatus!=FIELDS_OK ) { status = BIBL_ERR_MEMERR; goto out; } } } out: newstr_free( &keyword ); return status; }
/* bibl_copy() * * returns 1 on success, 0 on failure (memory error) */ int bibl_copy( bibl *bout, bibl *bin ) { fields *refin, *refout; int i, j, n, status, ok, level; char *tag, *value; for ( i=0; i<bin->nrefs; ++i ) { refin = bin->ref[i]; refout = fields_new(); if ( !refout ) return 0; n = fields_num( refin ); for ( j=0; j<n; ++j ) { tag = fields_tag( refin, j, FIELDS_CHRP ); value = fields_value( refin, j, FIELDS_CHRP ); level = fields_level( refin, j ); if ( tag && value ) { status = fields_add( refout, tag, value, level ); if ( status!=FIELDS_OK ) return 0; } } ok = bibl_addref( bout, refout ); if ( !ok ) return 0; } return 1; }
static int wordin_person( xml *node, fields *info, char *type ) { int status, ret = BIBL_OK; newstr name; newstr_init( &name ); status = wordin_person_last( node, &name ); if ( status!=BIBL_OK ) { ret = status; goto out; } status = wordin_person_first( node, &name ); if ( status!=BIBL_OK ) { ret = status; goto out; } status = fields_add( info, type, name.data, 0 ); if ( status != FIELDS_OK ) ret = BIBL_ERR_MEMERR; out: newstr_free( &name ); return ret; }
static int bibtex_addtitleurl( fields *info, newstr *in ) { int fstatus, status = BIBL_OK; newstr s; char *p; newstr_init( &s ); /* ...skip past "\href{" and copy to "}" */ p = newstr_cpytodelim( &s, in->data + 6, "}", 1 ); if ( newstr_memerr( &s ) ) { status = BIBL_ERR_MEMERR; goto out; } /* ...add to URL */ fstatus = fields_add( info, "URL", s.data, 0 ); if ( fstatus!=FIELDS_OK ) { status = BIBL_ERR_MEMERR; goto out; } /* ...return deleted fragment to newstr in */ p = newstr_cpytodelim( &s, p, "", 0 ); if ( newstr_memerr( &s ) ) { status = BIBL_ERR_MEMERR; goto out; } newstr_swapstrings( &s, in ); out: newstr_free( &s ); return status; }
static int bibtex_matches_list( fields *info, char *tag, char *suffix, newstr *data, int level, list *names, int *match ) { int i, fstatus, status = BIBL_OK; newstr newtag; *match = 0; if ( names->n==0 ) return status; newstr_init( &newtag ); for ( i=0; i<names->n; ++i ) { if ( strcmp( data->data, list_getc( names, i ) ) ) continue; newstr_initstr( &newtag, tag ); newstr_strcat( &newtag, suffix ); fstatus = fields_add( info, newtag.data, data->data, level ); if ( fstatus!=FIELDS_OK ) { status = BIBL_ERR_MEMERR; goto out; } *match = 1; goto out; } out: newstr_free( &newtag ); return status; }