1 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 2 /* All Rights Reserved */ 3 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 11 /* 12 * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. 13 * All Rights Reserved. 14 */ 15 16 /* from OpenSolaris "refer..c 1.3 05/06/02 SMI" */ 17 18 /* 19 * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany 20 * 21 * Sccsid @(#)refer..c 1.5 (gritter) 12/25/06 22 */ 23 24 #include <stdio.h> 25 #include <ctype.h> 26 #include <assert.h> 27 #include "global.h" 28 #ifndef EUC 29 #undef getw 30 #define getw(f) getc(f) 31 #undef putw 32 #define putw(c, f) putc(c, f) 33 #endif /* !EUC */ 34 35 #define FLAG 003 36 #define AFLAG 007 37 #define NRFTXT 10000 38 #define NRFTBL 500 39 #define NTFILE 20 40 #define QLEN 512 41 #define ANSLEN 4000 42 #define TAGLEN 400 43 #define NSERCH 20 44 #define MXSIG 200 /* max bytes in aggregate signal */ 45 46 extern FILE *in; 47 extern int endpush, sort, labels, keywant, bare; 48 extern int biblio, science, postpunct; 49 extern char *smallcaps; 50 extern char *comname; 51 extern char *keystr; 52 extern char *convert; 53 extern int authrev; 54 extern int nmlen, dtlen; 55 extern char *rdata[], **search; 56 extern int refnum; 57 extern char *reftable[]; 58 extern char *rtp, reftext[]; 59 extern int sep; 60 extern char tfile[]; 61 extern char gfile[]; 62 extern char ofile[]; 63 extern char hidenam[]; 64 extern char *Ifile; extern int Iline; 65 extern FILE *fo, *ftemp; 66 67 /* deliv2.c */ 68 int hash(const char *); 69 void err(const char *, ...); 70 int prefix(const char *, const char *); 71 char *mindex(const char *, int); 72 void *zalloc(int, int); 73 /* glue1.c */ 74 void huntmain(int, char **); 75 char *todir(char *); 76 int setfrom(int); 77 /* glue2.c */ 78 void savedir(void); 79 void restodir(void); 80 /* glue3.c */ 81 int corout(char *, char *, char *, char *, int); 82 int callhunt(char *, char *, char *, int); 83 int dodeliv(char *, char *, char *, int); 84 /* glue4.c */ 85 int grepcall(char *, char *, char *); 86 void clfgrep(void); 87 /* glue5.c */ 88 int fgrep(int, char **); 89 /* hunt1.c */ 90 char *todir(char *); 91 int setfrom(int); 92 /* hunt2.c */ 93 int doquery(long *, int, FILE *, int, char **, unsigned *); 94 long getl(FILE *); 95 void putl(long, FILE *); 96 int hcomp(int, int); 97 int hexch(int, int); 98 /* hunt3.c */ 99 int getq(char **); 100 /* hunt5.c */ 101 void result(unsigned *, int, FILE *); 102 long gdate(FILE *); 103 /* hunt6.c */ 104 int baddrop(unsigned *, int, FILE *, int, char **, char *, int); 105 int auxil(char *, char *); 106 /* hunt7.c */ 107 int findline(char *, char **, int, long); 108 /* hunt8.c */ 109 void runbib(const char *); 110 int makefgrep(char *); 111 int ckexist(const char *, const char *); 112 FILE *iopen(const char *, const char *); 113 /* hunt9.c */ 114 void remote(const char *, const char *); 115 /* inv2.c */ 116 int newkeys(FILE *, FILE *, FILE *, int, FILE *, int *); 117 char *trimnl(char *); 118 /* inv3.c */ 119 int getargs(char *, char **); 120 /* inv5.c */ 121 int recopy(FILE *, FILE *, FILE *, int); 122 /* inv6.c */ 123 void whash(FILE *, FILE *, FILE *, int, int, long *, int *); 124 void putl(long, FILE *); 125 long getl(FILE *); 126 /* mkey2.c */ 127 void dofile(FILE *, char *); 128 int outkey(char *, int, int); 129 long grec(char *, FILE *); 130 char *trimnl(char *); 131 void chkey(int, char *); 132 /* mkey3.c */ 133 int common(char *); 134 void cominit(void); 135 int c_look(char *, int); 136 /* refer2.c */ 137 void doref(char *); 138 int newline(const char *); 139 void choices(char *); 140 int control(int); 141 /* refer3.c */ 142 int corout(char *, char *, char *, char *, int); 143 /* refer4.c */ 144 void output(const char *); 145 void append(char *); 146 void flout(void); 147 char *trimnl(char *); 148 /* refer5.c */ 149 void putsig(int, char **, int, char *, char *, int); 150 char *fpar(int, char **, char *, size_t, int, int, int); 151 void putkey(int, char **, int, char *); 152 void tokeytab(const char *, int); 153 int keylet(char *, int); 154 void mycpy(char *, const char *); 155 void mycpy2(char *, const char *, int); 156 void initadd(char *, const char *, const char *); 157 char *artskp(char *); 158 /* refer6.c */ 159 void putref(int, char **); 160 int tabs(char **, char *); 161 char *class(int, char **); 162 int hastype(int, char **, int); 163 char *caps(char *, char *); 164 char *revauth(char *, char *); 165 int last(const char *); 166 /* refer7.c */ 167 int chkdup(const char *); 168 void dumpold(void); 169 void recopy1(char *); 170 void condense(int *, int, char *); 171 int wswap(const void *, const void *); 172 /* refer8.c */ 173 char *input(char *, size_t); 174 char *lookat(void); 175 void addch(char *, int); 176 /* shell.c */ 177 void shell(int, int (*)(int, int), int (*)(int, int)); 178 /* tick.c */ 179 void tick(void); 180 void tock(void); 181