File: bibprog.c

package info (click to toggle)
bibutils 7.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,040 kB
  • sloc: ansic: 112,579; sh: 462; makefile: 42
file content (40 lines) | stat: -rw-r--r-- 763 bytes parent folder | download | duplicates (2)
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 );
}