| 1/* 2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 3 * Use is subject to license terms. 4 */ 5
|
1/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 2/* All Rights Reserved */ 3
| 6/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 7/* All Rights Reserved */ 8
|
4
| |
5/* 6 * Copyright (c) 1980 Regents of the University of California. 7 * All rights reserved. The Berkeley software License Agreement 8 * specifies the terms and conditions for redistribution. 9 */ 10
| 9/* 10 * Copyright (c) 1980 Regents of the University of California. 11 * All rights reserved. The Berkeley software License Agreement 12 * specifies the terms and conditions for redistribution. 13 */ 14
|
11/* 12 * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. 13 * All Rights Reserved. 14 */
| 15#pragma ident "%Z%%M% %I% %E% SMI"
|
15
| 16
|
16#pragma ident "%Z%%M% %I% %E% SMI" 17
| |
18#include <stdio.h> 19#include <ctype.h> 20#include <locale.h> 21
| 17#include <stdio.h> 18#include <ctype.h> 19#include <locale.h> 20
|
22main(argc, argv) /* look in biblio for record matching keywords */ 23int argc; 24char **argv;
| 21static void instruct(void); 22static void map_lower(char *); 23 24/* look in biblio for record matching keywords */ 25int 26main(int argc, char **argv)
|
25{ 26 FILE *hfp, *fopen(), *popen(); 27 char s[BUFSIZ], hunt[64]; 28 29 (void) setlocale(LC_ALL, ""); 30 31#if !defined(TEXT_DOMAIN)
| 27{ 28 FILE *hfp, *fopen(), *popen(); 29 char s[BUFSIZ], hunt[64]; 30 31 (void) setlocale(LC_ALL, ""); 32 33#if !defined(TEXT_DOMAIN)
|
32#define TEXT_DOMAIN "SYS_TEST"
| 34#define TEXT_DOMAIN "SYS_TEST"
|
33#endif 34 (void) textdomain(TEXT_DOMAIN); 35 36 if (argc == 1 || argc > 2) { 37 fputs(gettext("Usage: lookbib database\n\ 38\tfinds citations specified on standard input\n"), stderr); 39 exit(1); 40 } 41 sprintf(s, "%s.ia", argv[1]); 42 if (access(s, 0) == -1) {
| 35#endif 36 (void) textdomain(TEXT_DOMAIN); 37 38 if (argc == 1 || argc > 2) { 39 fputs(gettext("Usage: lookbib database\n\ 40\tfinds citations specified on standard input\n"), stderr); 41 exit(1); 42 } 43 sprintf(s, "%s.ia", argv[1]); 44 if (access(s, 0) == -1) {
|
43 sprintf (s, "%s", argv[1]);
| 45 sprintf(s, "%s", argv[1]);
|
44 if (access(s, 0) == -1) { 45 perror(s); 46 fprintf(stderr, gettext("\tNeither index file %s.ia \ 47nor reference file %s found\n"), s, s); 48 exit(1); 49 } 50 } 51 sprintf(hunt, "/usr/lib/refer/hunt %s", argv[1]); 52 if (isatty(fileno(stdin))) { 53 fprintf(stderr, gettext("Instructions? ")); 54 fgets(s, BUFSIZ, stdin); 55 if (*s == 'y') 56 instruct(); 57 }
| 46 if (access(s, 0) == -1) { 47 perror(s); 48 fprintf(stderr, gettext("\tNeither index file %s.ia \ 49nor reference file %s found\n"), s, s); 50 exit(1); 51 } 52 } 53 sprintf(hunt, "/usr/lib/refer/hunt %s", argv[1]); 54 if (isatty(fileno(stdin))) { 55 fprintf(stderr, gettext("Instructions? ")); 56 fgets(s, BUFSIZ, stdin); 57 if (*s == 'y') 58 instruct(); 59 }
|
58 again:
| 60again:
|
59 fprintf(stderr, "> "); 60 if (fgets(s, BUFSIZ, stdin)) { 61 if (*s == '\n') 62 goto again; 63 if (strlen(s) <= 3) 64 goto again; 65 if ((hfp = popen(hunt, "w")) == NULL) { 66 perror(gettext("lookbib: /usr/lib/refer/hunt")); 67 exit(1); 68 } 69 map_lower(s); 70 fputs(s, hfp); 71 pclose(hfp); 72 goto again; 73 } 74 fprintf(stderr, gettext("EOT\n"));
| 61 fprintf(stderr, "> "); 62 if (fgets(s, BUFSIZ, stdin)) { 63 if (*s == '\n') 64 goto again; 65 if (strlen(s) <= 3) 66 goto again; 67 if ((hfp = popen(hunt, "w")) == NULL) { 68 perror(gettext("lookbib: /usr/lib/refer/hunt")); 69 exit(1); 70 } 71 map_lower(s); 72 fputs(s, hfp); 73 pclose(hfp); 74 goto again; 75 } 76 fprintf(stderr, gettext("EOT\n"));
|
75 exit(0); 76 /* NOTREACHED */
| 77 return (0);
|
77} 78
| 78} 79
|
79map_lower(s) /* map string s to lower case */ 80char *s;
| 80static void 81map_lower(char *s) /* map string s to lower case */
|
81{
| 82{
|
82 for ( ; *s; ++s)
| 83 for (; *s; ++s)
|
83 if (isupper(*s)) 84 *s = tolower(*s); 85} 86
| 84 if (isupper(*s)) 85 *s = tolower(*s); 86} 87
|
87instruct()
| 88static void 89instruct(void)
|
88{ 89 fputs(gettext( 90"\nType keywords (such as author and date) after the > prompt.\n\ 91References with those keywords are printed if they exist;\n\ 92\tif nothing matches you are given another prompt.\n\ 93To quit lookbib, press CTRL-d after the > prompt.\n\n"), stderr); 94 95}
| 90{ 91 fputs(gettext( 92"\nType keywords (such as author and date) after the > prompt.\n\ 93References with those keywords are printed if they exist;\n\ 94\tif nothing matches you are given another prompt.\n\ 95To quit lookbib, press CTRL-d after the > prompt.\n\n"), stderr); 96 97}
|