Esempio n. 1
0
int
bibl_read( bibl *b, FILE *fp, char *filename, param *p )
{
	convert_rules r;
	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 );
	rules_init( &r, p->readformat );
	read_ref( fp, &bin, filename, &r, &lp );
	if ( !lp.output_raw || ( lp.output_raw & BIBL_RAW_WITHCHARCONVERT ) )
		bibl_fixcharsets( &bin, &lp );
	if ( !lp.output_raw )
		convert_ref( &bin, filename, b, &r, &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;
}
Esempio n. 2
0
int
bibl_write( bibl *b, FILE *fp, int mode, param *p )
{
	convert_rules r;
	param lp;
	if ( !b || bibl_illegaloutmode( mode ) ) return BIBL_ERR_BADINPUT;
	if ( !fp && ( !p || !p->singlerefperfile ) ) return BIBL_ERR_BADINPUT;
	rules_init( &r, mode );
	bibl_setwriteparams( &lp, p, mode );
	bibl_fixcharsets( b, &lp );
	output_bibl( fp, b, &r, &lp, mode );
	return BIBL_OK;
}