[Refdb-cvs] CVS: refdb/src refdba.c,1.45.2.4,1.45.2.5
Status: Beta
Brought to you by:
mhoenicka
From: Markus H. <mho...@us...> - 2005-05-21 23:48:24
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20376 Modified Files: Tag: Release_0_9_5_stable refdba.c Log Message: addstyle(): can now read from stdin Index: refdba.c =================================================================== RCS file: /cvsroot/refdb/refdb/src/refdba.c,v retrieving revision 1.45.2.4 retrieving revision 1.45.2.5 diff -u -U2 -r1.45.2.4 -r1.45.2.5 --- refdba.c 21 Apr 2005 21:13:16 -0000 1.45.2.4 +++ refdba.c 21 May 2005 23:48:11 -0000 1.45.2.5 @@ -1710,4 +1710,5 @@ int cs_status; int n_set_count = 0; + int numcycles; /* number of cycles reading input */ size_t byte_written = 0; FILE *pagerfp; @@ -1797,4 +1798,10 @@ n_pipe = 1; break; + case 'f': + /* printf("-f %s\n", optarg); */ + if (!strcmp(optarg, "stdin")) { + n_read_stdin = 1; + } + break; case 'h': printf("Adds bibliography styles\nSyntax: addstyle [-h] {file} [file1...]\nOptions: -h prints this mini-help\n All other arguments are interpreted as filenames with style specifications.\n"); @@ -1816,5 +1823,4 @@ case 'd': case 'e': - case 'f': case 'H': case 'i': @@ -1906,8 +1912,15 @@ } + if (n_read_stdin) { + infp = stdin; + numcycles = 1; + } + else { + numcycles = inargc-optind; + } /* reuse result */ result = 0; - for (k = optind; k < inargc; k++) { + for (k = 0; k < numcycles; k++) { char thebytes[20]; @@ -1915,8 +1928,11 @@ n_style_file_done = 0; /* try to open our target file */ - infp = fopen(inargv[k], "rb"); - - if (infp == NULL) { - continue; + if (!n_read_stdin) { + /* try to open our target file */ + infp = fopen(inargv[optind+k], "rb"); +/* printf("%s<<\n", inargv[optind+k]); */ + if (infp == NULL) { + continue; + } } @@ -1924,5 +1940,7 @@ n_xml_result = send_xml_data(infp, pagerfp, stderr, n_sockfd, &byte_written); - fclose(infp); + if (!n_read_stdin) { + fclose(infp); + } if (n_xml_result != 0 |