summaryrefslogtreecommitdiff
path: root/support/texlab/crates/bibutils_sys/src/generic.c
blob: a75ed67377688e7662008c46d7cddaead6aa0b6d (plain)
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
103
104
105
106
/* generic.c
 *
 * Copyright (c) Chris Putnam 2016-2019
 *
 * 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 )
{
        if ( notes_add( bibout, invalue, level ) ) return BIBL_OK;
        else return BIBL_ERR_MEMERR;
}

int
generic_pages( fields *bibin, int n, str *intag, str *invalue, int level, param *pm, char *outtag, fields *bibout )
{
        if ( pages_add( bibout, outtag, invalue, level ) ) return BIBL_OK;
        else return BIBL_ERR_MEMERR;
}

int
generic_person( fields *bibin, int n, str *intag, str *invalue, int level, param *pm, char *outtag, fields *bibout )
{
        if ( name_add( bibout, outtag, str_cstr( invalue ), level, &(pm->asis), &(pm->corps) ) ) return BIBL_OK;
        else return BIBL_ERR_MEMERR;
}

int
generic_serialno( fields *bibin, int n, str *intag, str *invalue, int level, param *pm, char *outtag, fields *bibout )
{
	if ( addsn( bibout, str_cstr( invalue ), level ) ) return BIBL_OK;
	return BIBL_ERR_MEMERR;
}

/* 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_setused( bibin, n );
	return BIBL_OK;
}

int
generic_title( fields *bibin, int n, str *intag, str *invalue, int level, param *pm, char *outtag, fields *bibout )
{
        if ( title_process( bibout, outtag, str_cstr( invalue ), level, pm->nosplittitle ) ) return BIBL_OK;
        else return BIBL_ERR_MEMERR;
}

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 );
}