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
|
/*
* bibprog.c
*
* Copyright (c) Chris Putnam 2004-2021
*
* Source code released under the GPL version 2
*
*/
#include <stdio.h>
#include "bibutils.h"
#include "bibprog.h"
void
bibprog( int argc, char *argv[], param *p )
{
FILE *fp;
bibl b;
int err, i;
bibl_init( &b );
if ( argc<2 ) {
err = bibl_read( &b, stdin, "stdin", p );
if ( err ) bibl_reporterr( err );
} else {
for ( i=1; i<argc; ++i ) {
fp = fopen( argv[i], "r" );
if ( fp ) {
err = bibl_read( &b, fp, argv[i], p );
if ( err ) bibl_reporterr( err );
fclose( fp );
}
}
}
bibl_write( &b, stdout, p );
fflush( stdout );
if( p->progname ) fprintf( stderr, "%s: ", p->progname );
fprintf( stderr, "Processed %ld references.\n", b.n );
bibl_free( &b );
}
|