2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
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.
15 #pragma ident "%Z%%M% %I% %E% SMI"
25 static char dr
[100] = "";
29 extern void dumpold();
41 static int newline(char *);
46 char buff
[QLEN
], dbuff
[3*QLEN
];
47 char answer
[ANSLEN
], temp
[TLEN
], line
[BUFSIZ
];
48 char *p
, **sr
, *flds
[NFLD
], *r
;
49 int stat
, nf
, nr
, query
= 0, alph
, digs
;
52 buff
[0] = dbuff
[0] = NULL
;
53 if (biblio
&& Iline
== 1 && line1
[0] == '%')
55 while (input(line
)) { /* get query */
57 if (prefix(".]", line
))
59 if (biblio
&& line
[0] == '\n')
61 if (biblio
&& line
[0] == '%' && line
[1] == *convert
)
65 strcat(query
? dbuff
: buff
, line
);
66 if (strlen(buff
) > QLEN
)
67 err(gettext("query too long (%d)"), strlen(buff
));
68 if (strlen(dbuff
) > 3 * QLEN
)
69 err(gettext("record at line %d too long"), Iline
-1);
71 if (biblio
&& line
[0] == '\n' && feof(in
))
73 if (strcmp(buff
, "$LIST$\n") == 0) {
74 assert(dbuff
[0] == 0);
79 for (p
= buff
; *p
; p
++) {
84 for (p
= buff
; *p
; p
++) {
92 if ((alph
+digs
< 3) || common(p
-alph
)) {
97 if (alph
== 0 && digs
> 0) {
99 if (digs
!= 4 || atoi(r
)/100 != 19) {
109 if (buff
[0]) { /* do not search if no query */
110 for (sr
= rdata
; sr
< search
; sr
++) {
112 corout(buff
, temp
, "hunt", *sr
, TLEN
);
113 assert(strlen(temp
) < TLEN
);
114 if (strlen(temp
)+strlen(answer
) > BUFSIZ
)
116 "Accumulated answers too large"), 0);
117 strcat(answer
, temp
);
118 if (strlen(answer
) > BUFSIZ
)
119 err(gettext("answer too long (%d)"),
121 if (newline(answer
) > 0)
125 assert(strlen(one
) < ANSLEN
);
126 assert(strlen(answer
) < ANSLEN
);
128 switch (newline(answer
)) {
130 fprintf(stderr
, gettext("No such paper: %s\n"), buff
);
133 fprintf(stderr
, gettext(
134 "Too many hits: %s\n"), trimnl(buff
));
142 if (nr
= chkdup(answer
)) {
144 nf
= tabs(flds
, one
);
145 nf
+= tabs(flds
+nf
, dbuff
);
147 putsig(nf
, flds
, nr
, line1
,
153 corout(answer
, one
, "deliv", dr
, QLEN
);
156 assert(strlen(buff
) < QLEN
);
157 assert(strlen(one
) < ANSLEN
);
158 nf
= tabs(flds
, one
);
159 nf
+= tabs(flds
+nf
, dbuff
);
163 putkey(nf
, flds
, refnum
, keystr
);
165 putsig(nf
, flds
, refnum
, line1
, line
, 1);
169 if (biblio
&& line
[0] == '\n')
171 if (biblio
&& line
[0] == '%' && line
[1] == *convert
)
172 fprintf(fo
, "%s%c%s", convert
+1, sep
, line
+3);
189 char ob
[BUFSIZ
], *p
, *r
, *q
, *t
;
192 for (r
= p
= buff
; *p
; p
++) {
195 corout(r
, ob
, "deliv", dr
, BUFSIZ
);
197 for (q
= ob
; *q
; q
++) {
198 if (nl
&& (q
[0] == '.' || q
[0] == '%') &&
201 for (t
= q
; *t
&& *t
!= '\n'; t
++)
204 fprintf(stderr
, "%.70s\n", q
);
211 fprintf(stderr
, gettext("??? at %s\n"), r
);