static char *sccsid
= "@(#)lookbib.c 4.4 (Berkeley) 2/15/84";
main(argc
, argv
) /* look in biblio for record matching keywords */
FILE *fp
, *hfp
, *fopen(), *popen();
char s
[BUFSIZ
], hunt
[64], *sprintf();
if (strcmp(argv
[1],"-n") == 0)
if (argc
== 1 || argc
> 2)
fputs("Usage: lookbib database\n",
fputs("\tfinds citations specified on standard input\n",
if (!isatty(fileno(stdin
)))
else if ((fp
= fopen("/dev/tty", "r")) == NULL
)
perror("lookbib: /dev/tty");
sprintf(s
, "%s.ia", argv
[1]);
if (access(s
, 0) == -1) {
sprintf (s
, "%s", argv
[1]);
if (access(s
, 0) == -1) {
fprintf(stderr
, "\tNeither index file %s.ia ", s
);
fprintf(stderr
, "nor reference file %s found\n", s
);
sprintf(hunt
, "/usr/lib/refer/hunt %s", argv
[1]);
if (instructions
&& isatty(fileno(fp
)))
fprintf(stderr
, "Instructions? ");
if (fgets(s
, BUFSIZ
, fp
))
if ((hfp
= popen(hunt
, "w")) == NULL
)
perror("lookbib: /usr/lib/refer/hunt");
fprintf(stderr
, "EOT\n");
map_lower(s
) /* map string s to lower case */
fputs("\nType keywords (such as author and date) after the > prompt.\n",
fputs("References with those keywords are printed if they exist;\n",
fputs("\tif nothing matches you are given another prompt.\n",
fputs("To quit lookbib, press CTRL-d after the > prompt.\n\n",