1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
/* generic.c
*
* Copyright (c) Chris Putnam 2016-2021
*
* Source code released under GPL version 2
*
* xxxx_convertf() stubs that can be shared.
*/
#include "bu_auth.h"
#include "marc_auth.h"
#include "name.h"
#include "notes.h"
#include "pages.h"
#include "serialno.h"
#include "title.h"
#include "url.h"
#include "utf8.h"
#include "generic.h"
/* stub for processtypes that aren't used, such as DEFAULT and ALWAYS handled by bibcore.c */
int
generic_null( fields *bibin, int n, str *intag, str *invalue, int level, param *pm, char *outtag, fields *bibout )
{
return BIBL_OK;
}
int
generic_url( fields *bibin, int n, str *intag, str *invalue, int level, param *pm, char *outtag, fields *bibout )
{
return urls_split_and_add( str_cstr( invalue ), bibout, level );
}
int
generic_notes( fields *bibin, int n, str *intag, str *invalue, int level, param *pm, char *outtag, fields *bibout )
{
return add_notes( bibout, invalue, level );
}
int
generic_pages( fields *bibin, int n, str *intag, str *invalue, int level, param *pm, char *outtag, fields *bibout )
{
if ( is_doi( str_cstr( invalue ) )!=-1 ) return generic_url( bibin, n, intag, invalue, level, pm, outtag, bibout );
else return add_pages( bibout, invalue, level );
}
int
generic_person( fields *bibin, int n, str *intag, str *invalue, int level, param *pm, char *outtag, fields *bibout )
{
return add_name( bibout, outtag, str_cstr( invalue ), level, &(pm->asis), &(pm->corps) );
}
int
generic_serialno( fields *bibin, int n, str *intag, str *invalue, int level, param *pm, char *outtag, fields *bibout )
{
return add_sn( bibout, str_cstr( invalue ), level );
}
/* SIMPLE = just copy */
int
generic_simple( fields *bibin, int n, str *intag, str *invalue, int level, param *pm, char *outtag, fields *bibout )
{
if ( fields_add( bibout, outtag, str_cstr( invalue ), level ) == FIELDS_OK ) return BIBL_OK;
else return BIBL_ERR_MEMERR;
}
/* just like generic_null(), but useful if we need one that isn't identical to generic_null() ala biblatexin.c */
int
generic_skip( fields *bibin, int n, str *intag, str *invalue, int level, param *pm, char *outtag, fields *bibout )
{
fields_set_used( bibin, n );
return BIBL_OK;
}
int
generic_title( fields *bibin, int n, str *intag, str *invalue, int level, param *pm, char *outtag, fields *bibout )
{
return add_title( bibout, outtag, str_cstr( invalue ), level, pm->nosplittitle );
}
int
generic_genre( fields *bibin, int n, str *intag, str *invalue, int level, param *pm, char *outtag, fields *bibout )
{
int status;
if ( is_marc_genre( str_cstr( invalue ) ) )
status = fields_add( bibout, "GENRE:MARC", str_cstr( invalue ), level );
else if ( is_bu_genre( str_cstr( invalue ) ) )
status = fields_add( bibout, "GENRE:BIBUTILS", str_cstr( invalue ), level );
else
status = fields_add( bibout, "GENRE:UNKNOWN", str_cstr( invalue ), level );
if ( status == FIELDS_OK ) return BIBL_OK;
else return BIBL_ERR_MEMERR;
}
void
generic_writeheader( FILE *outptr, param *pm )
{
if ( pm->utf8bom ) utf8_writebom( outptr );
}
|