1/* 2 * Copyright (c) 1995 Wolfram Schneider <wosch@FreeBSD.org>. Berlin. 3 * Copyright (c) 1989, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * James A. Woods. 8 * --- 20 unchanged lines hidden (view full) --- 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * |
37 * $FreeBSD: head/usr.bin/locate/code/locate.code.c 209571 2010-06-28 12:04:55Z gavin $ |
38 */ 39 |
40#if 0 |
41#ifndef lint 42static char copyright[] = 43"@(#) Copyright (c) 1989, 1993\n\ 44 The Regents of the University of California. All rights reserved.\n"; 45#endif /* not lint */ 46 47#ifndef lint 48static char sccsid[] = "@(#)locate.code.c 8.1 (Berkeley) 6/6/93"; 49#endif /* not lint */ |
50#endif |
51 52/* 53 * PURPOSE: sorted list compressor (works with a modified 'find' 54 * to encode/decode a filename database) 55 * 56 * USAGE: bigram < list > bigrams 57 * process bigrams (see updatedb) > common_bigrams 58 * code common_bigrams < list > squozen_list --- 60 unchanged lines hidden (view full) --- 119typedef int bg_t; 120int bgindex(char *); 121#endif /* LOOKUP */ 122 123 124void usage(void); 125 126int |
127main(int argc, char *argv[]) |
128{ |
129 u_char *cp, *oldpath, *path; |
130 int ch, code, count, diffcount, oldcount; |
131 u_int i, j; |
132 FILE *fp; |
133 134 while ((ch = getopt(argc, argv, "")) != -1) 135 switch(ch) { 136 default: 137 usage(); 138 } 139 argc -= optind; 140 argv += optind; --- 110 unchanged lines hidden (view full) --- 251 /* Non-zero status if there were errors */ 252 if (fflush(stdout) != 0 || ferror(stdout)) 253 exit(1); 254 exit(0); 255} 256 257#ifndef LOOKUP 258int |
259bgindex(char *bg) /* Return location of bg in bigrams or -1. */ |
260{ |
261 char bg0, bg1, *p; |
262 263 bg0 = bg[0]; 264 bg1 = bg[1]; 265 for (p = bigrams; *p != NULL; p++) 266 if (*p++ == bg0 && *p == bg1) 267 break; 268 return (*p == NULL ? -1 : (--p - bigrams)); 269} 270#endif /* !LOOKUP */ 271 272void |
273usage(void) |
274{ 275 (void)fprintf(stderr, 276 "usage: locate.code common_bigrams < list > squozen_list\n"); 277 exit(1); 278} |