From owner-svn-src-user@FreeBSD.ORG Wed Sep 12 13:34:24 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2F1401065672; Wed, 12 Sep 2012 13:34:24 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1856F8FC08; Wed, 12 Sep 2012 13:34:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q8CDYNxw077373; Wed, 12 Sep 2012 13:34:23 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q8CDYNJb077367; Wed, 12 Sep 2012 13:34:23 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201209121334.q8CDYNJb077367@svn.freebsd.org> From: Dag-Erling Smørgrav Date: Wed, 12 Sep 2012 13:34:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r240395 - in user/des: bsddom election evilhttpd fetch grok X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Sep 2012 13:34:24 -0000 Author: des Date: Wed Sep 12 13:34:23 2012 New Revision: 240395 URL: http://svn.freebsd.org/changeset/base/240395 Log: Remove accidentally committed crap. Added: user/des/grok/Makefile user/des/grok/grok.c user/des/grok/grok.h user/des/grok/index.c user/des/grok/search.c user/des/grok/version.h Deleted: user/des/bsddom/ user/des/election/ user/des/evilhttpd/ user/des/fetch/ Added: user/des/grok/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/des/grok/Makefile Wed Sep 12 13:34:23 2012 (r240395) @@ -0,0 +1,11 @@ +# $Id$ + +PROG = grok +SRCS = grok.c +SRCS += index.c index_dir.c index_file.c +SRCS += search.c +MAN = + +WARNS ?= 6 + +.include Added: user/des/grok/grok.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/des/grok/grok.c Wed Sep 12 13:34:23 2012 (r240395) @@ -0,0 +1,104 @@ +/*- + * Copyright (c) 2011 Dag-Erling Smørgrav + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + */ + +#include + +#include +#include +#include +#include +#include +#include + +#include "grok.h" + +static char cwd[MAXPATHLEN]; + +const char *corpusdir; /* where the corpus is */ +const char *indexdir; /* where our index is */ +int verbose; /* verbosity level */ + +void +grok_version(void) +{ + + fprintf(stderr, "grok %8lu\n", GROK_VERSION); + fprintf(stderr, "%s\n", GROK_COPYRIGHT); +} + +void +grok_usage(void) +{ + + fprintf(stderr, "usage: %s [-Vv] [-c corpus] [-i index]\n", + getprogname()); +} + +int +grok_opt(int opt, const char *arg) +{ + + switch (opt) { + case 'c': + corpusdir = arg; + break; + case 'i': + indexdir = arg; + break; + case 'V': + grok_version(); + exit(0); + case 'v': + verbose++; + break; + default: + return (0); + } + return (1); +} + +int +main(int argc, char *argv[]) +{ + + setlocale(LC_CTYPE, ""); + + /* default corpus and index dir are cwd */ + if (getcwd(cwd, sizeof(cwd)) == NULL) + err(1, "getcwd()"); + corpusdir = indexdir = cwd; + + if (strstr(getprogname(), "index") != NULL) + index_main(argc, argv); + else + search_main(argc, argv); + + /* not reached */ + exit(1); +} Added: user/des/grok/grok.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/des/grok/grok.h Wed Sep 12 13:34:23 2012 (r240395) @@ -0,0 +1,63 @@ +/*- + * Copyright (c) 2011 Dag-Erling Smørgrav + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + */ + +#ifndef GROK_H_INCLUDED +#define GROK_H_INCLUDED + +#include + +#include "version.h" + +void grok_version(void); +void grok_usage(void); + +#define GROK_OPTS "c:i:Vv" +int grok_opt(int, const char *); + +extern const char *corpusdir; +extern const char *indexdir; +extern int verbose; + +int index_main(int, char **); +int search_main(int, char **); + +#ifdef WEOF /* we have */ + +#define WBOW ((wint_t)-3) /* beginning-of-word */ +#define WEOW ((wint_t)-2) /* end-of-word */ + +struct grok_node { + wint_t ch; /* can be a character, WBOW or WEOW */ + unsigned int child; /* first child, if any, or 0 */ + unsigned int sibling; /* next sibling, if any, or 0 */ + +}; +#endif + +#endif Added: user/des/grok/index.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/des/grok/index.c Wed Sep 12 13:34:23 2012 (r240395) @@ -0,0 +1,84 @@ +/*- + * Copyright (c) 2011 Dag-Erling Smørgrav + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + */ + +#include +#include +#include + +#include "grok.h" +#include "index.h" + +struct grok_filter *filter_list; +struct grok_filter default_filter_list[] = { + { .type = FILTER_EXCLUDE, .pattern = "*/.svn/*" }, + { .type = FILTER_EXCLUDE, .pattern = "*/CVS/*" }, + { .type = FILTER_EXCLUDE, .pattern = "*.uue" }, + { .type = FILTER_EXCLUDE, .pattern = "*.b64" }, + { .type = FILTER_EXCLUDE, .pattern = "*~" }, + { .type = FILTER_EXCLUDE, .pattern = "*.orig" }, + { .type = FILTER_EXCLUDE, .pattern = "*.rej" }, +}; + +int skip_comments; +int include_binary; + +static void +usage(void) +{ + + grok_usage(); + exit(1); +} + +int +index_main(int argc, char *argv[]) +{ + int opt; + + while ((opt = getopt(argc, argv, GROK_OPTS "C")) != -1) + switch (opt) { + case 'b': + include_binary = 1; + break; + case 'C': + skip_comments = 1; + break; + default: + if (!grok_opt(opt, optarg)) + usage(); + } + + argc -= optind; + argv += optind; + + while (argc--) + add_file_to_index(*argv++); + + exit(0); +} Added: user/des/grok/search.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/des/grok/search.c Wed Sep 12 13:34:23 2012 (r240395) @@ -0,0 +1,63 @@ +/*- + * Copyright (c) 2011 Dag-Erling Smørgrav + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + */ + +#include +#include +#include + +#include "grok.h" + +static void +usage(void) +{ + + grok_version(); + exit(1); +} + +int +search_main(int argc, char *argv[]) +{ + int opt; + + while ((opt = getopt(argc, argv, GROK_OPTS)) != -1) + switch (opt) { + default: + if (!grok_opt(opt, optarg)) + usage(); + } + + argc -= optind; + argv += optind; + + if (argc == 0) + usage(); + + exit(0); +} Added: user/des/grok/version.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/des/grok/version.h Wed Sep 12 13:34:23 2012 (r240395) @@ -0,0 +1,36 @@ +/*- + * Copyright (c) 2011 Dag-Erling Smørgrav + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + */ + +#ifndef VERSION_H_INCLUDED +#define VERSION_H_INCLUDED + +#define GROK_COPYRIGHT "Copyright (c) 2011 Dag-Erling Smørgrav" +#define GROK_VERSION 20111014LU + +#endif