-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | Makefile.am | 22 | ||||
-rw-r--r-- | README-hacking | 35 | ||||
-rw-r--r-- | bootstrap.conf | 7 | ||||
-rw-r--r-- | configure.ac | 46 | ||||
-rw-r--r-- | gconf/.gitignore | 4 | ||||
-rw-r--r-- | gconf/Makefile.am | 17 | ||||
-rw-r--r-- | gconf/gconf-format.c | 200 | ||||
-rw-r--r-- | gconf/gconf-gram.y | 891 | ||||
-rw-r--r-- | gconf/gconf-lex.l | 476 | ||||
-rw-r--r-- | gconf/gconf-preproc.c | 728 | ||||
-rw-r--r-- | gconf/gconf-text.c | 73 | ||||
-rw-r--r-- | gconf/gconf.h | 163 | ||||
-rw-r--r-- | gconf/gnulib.modules | 14 | ||||
-rw-r--r-- | gconf/wordsplit.c | 568 | ||||
-rw-r--r-- | gconf/wordsplit.h | 88 | ||||
m--------- | grecs | 0 | ||||
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/cmdline.opt | 18 | ||||
-rw-r--r-- | src/config.c | 476 | ||||
-rw-r--r-- | src/diskio.c | 8 | ||||
-rw-r--r-- | src/tcpwrap.c | 22 | ||||
-rw-r--r-- | src/wydawca.c | 10 | ||||
-rw-r--r-- | src/wydawca.h | 14 | ||||
-rw-r--r-- | tests/Makefile.am | 4 |
26 files changed, 320 insertions, 3575 deletions
@@ -1,7 +1,7 @@ +*.a +*.o *.tar.* *~ -*.o -*.a .bootstrap .deps .emacs.desktop diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..fea8f96 --- a/dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "grecs"] + path = grecs + url = git://git.gnu.org.ua/grecs.git diff --git a/Makefile.am b/Makefile.am index 1eac948..743b2be 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,34 +14,16 @@ # You should have received a copy of the GNU General Public License # along with wydawca. If not, see <http://www.gnu.org/licenses/>. -ACLOCAL_AMFLAGS = -I m4 +ACLOCAL_AMFLAGS = -I m4 -I grecs/am AUTOMAKE_OPTIONS = gnu 1.8.5 -SUBDIRS=gnu gconf src doc etc tests +SUBDIRS=gnu grecs src doc etc tests # We never remove files from the configuration directory distuninstallcheck_listfiles = \ find $(prefix) -type f -not -path '$(sysconfdir)/*' gen_start_date = 2009-01-25 -.PHONY: make-ChangeLog -make-ChangeLog: - if test -d .git; then \ - $(top_srcdir)/build-aux/gitlog-to-changelog \ - --since=$(gen_start_date) | \ - sed '/<unknown>$$/d' | fmt -s > $(distdir)/cl-t; \ - cat ChangeLog.svn | sed '/^Local Variables:/,/^End:/d' \ - >> $(distdir)/cl-t; \ - echo "Local Variables:" >> $(distdir)/cl-t; \ - echo "mode: change-log" >> $(distdir)/cl-t; \ - echo "version-control: never" >> $(distdir)/cl-t; \ - echo "buffer-read-only: t" >> $(distdir)/cl-t; \ - echo "End:" >> $(distdir)/cl-t; \ - rm -f $(distdir)/ChangeLog; \ - mv $(distdir)/cl-t $(distdir)/ChangeLog; \ - fi - -dist-hook: make-ChangeLog .PHONY: ChangeLog ChangeLog: diff --git a/README-hacking b/README-hacking index 19b957a..a746607 100644 --- a/README-hacking +++ b/README-hacking @@ -1,44 +1,59 @@ -These notes intend to help people working on the SVN version of +These notes intend to help people working on the Git version of this package. See end of this file for the copying conditions. * Requirements -You need the following packages to build the SVN version of Wydawca. I do +You need the following packages to build the Git version of Wydawca. I do not make any efforts to accommodate older versions of these packages, so please make sure that you have the latest stable version. - Automake <http://www.gnu.org/software/automake/> - Autoconf <http://www.gnu.org/software/autoconf/> - Bison <http://www.gnu.org/software/bison/> +- Git <http://git.or.cz> - Gnulib <http://www.gnu.org/software/gnulib/> +- Grecs <http://puszcza.gnu.org.ua/projects/grecs> - Flex <http://flex.sourceforge.net/> - M4 <http://www.gnu.org/software/m4/> - Mailutils <http://www.gnu.org/software/mailutils/> -- Subversion <http://subversion.tigris.org/> - Texinfo <http://www.gnu.org/software/texinfo> * Bootstrapping -Obviously, if you are reading these notes, you did manage to check out -the source tree from SVN. The next step is to create the configuration -framework: +Obviously, if you are reading these notes, you did manage to clone +the source tree from the Git repository. The next step is to create +the configuration framework: 1. Change to the source tree directory $ cd wydawca -2. Run `bootstrap' pointing the --gnulib-srcdir option to the location -of the local directory where gnulib sources reside, e.g.: +2. Run `bootstrap': - ./bootstrap --gnulib-srcdir=/usr/src/gnulib + ./bootstrap Once done, proceed as described in the file README (section `Installation'). +Normally you will have to run bootstrap only once. However, if you +intend to hack on Wydawca, you might need to run it again later. In +this case, you will probably want to save some time and bandwidth by +avoiding downloading the same files again. If so, create in the Wydawca +root directory the file named `.bootstrap' with the following +contents: + + --gnulib-srcdir=$HOME/gnulib + +Replace `$HOME/gnulib' with the actual directory where the Gnulib +sources reside. + +For more information about `bootstrap', run `bootstrap --help'. + + * Copyright information - Copyright (C) 2007 Sergey Poznyakoff + Copyright (C) 2007, 2009 Sergey Poznyakoff Permission is granted to anyone to make or distribute verbatim copies of this document as received, in any medium, provided that the diff --git a/bootstrap.conf b/bootstrap.conf index 6119189..fde2671 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -21,6 +21,11 @@ gnulib_mk=Makefile.am test -d $source_base || mkdir -p $source_base +if git config submodule.grecs.url >/dev/null; then : ; else + git submodule init || exit $? + git submodule update || exit $? +fi + # We don't need these modules, even though gnulib-tool mistakenly # includes them because of gettext dependencies. avoided_gnulib_modules=' @@ -29,7 +34,7 @@ avoided_gnulib_modules=' ' # gnulib modules used by this package. -gnulib_modules="`grep -h '^[^#]' gnulib.modules gconf/gnulib.modules | sort | uniq`" +gnulib_modules="`grep -h '^[^#]' gnulib.modules grecs/gnulib.modules | sort | uniq`" # Additional xgettext options to use. Use "\\\newline" to break lines. XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\ diff --git a/configure.ac b/configure.ac index 604ccc4..48e1252 100644 --- a/configure.ac +++ b/configure.ac @@ -106,48 +106,9 @@ fi if test "$status_tcpwrap" = yes; then AC_DEFINE_UNQUOTED([WITH_LIBWRAP],1,[Defined if compiling with libwrap]) fi - -# ********************** -# Preprocessor -# ********************** -AC_ARG_WITH([preprocessor], - AC_HELP_STRING([--without-preprocessor], - [do not use external preprocessor]), - [ -case "${withval}" in -yes) use_ext_pp=yes ;; -no) use_ext_pp=no ;; -*) AC_MSG_ERROR(bad value ${withval} for --with-preprocessor) ;; -esac],[use_ext_pp=yes]) - -if test $use_ext_pp != no; then - # Check for default preprocessor - AC_ARG_VAR([DEFAULT_PREPROCESSOR], - [Set default preprocessor name]) - if test -z "$DEFAULT_PREPROCESSOR" ; then - DEFAULT_PREPROCESSOR="m4 -s" - fi - - save_PATH=$PATH - PREPROC_OPTIONS=`echo $DEFAULT_PREPROCESSOR | sed -n 's/[[^ ]][[^ ]]* //p'` - case "$DEFAULT_PREPROCESSOR" in - /*) PATH=`expr $DEFAULT_PREPROCESSOR : '\(.*\)/.*'`:$PATH - DEFAULT_PREPROCESSOR=`expr $DEFAULT_PREPROCESSOR : '.*/\(.*\)'`;; - esac - AC_PATH_PROG(PPBIN, $DEFAULT_PREPROCESSOR) - DEFAULT_PREPROCESSOR=$PPBIN - if test -n "$DEFAULT_PREPROCESSOR"; then - DEFAULT_PREPROCESSOR="$DEFAULT_PREPROCESSOR $PREPROC_OPTIONS" - case $PPBIN in - *m4) AC_SUBST(PP_SETUP_FILE,'pp-setup');; # Install default pp-setup - esac - fi - PATH=$save_PATH - DEFAULT_PREPROCESSOR="\\\"$DEFAULT_PREPROCESSOR\\\"" -else - DEFAULT_PREPROCESSOR=NULL -fi +# Grecs subsystem +GRECS_SETUP AH_BOTTOM([ #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) @@ -172,7 +133,8 @@ fi AC_CONFIG_FILES([Makefile doc/Makefile gnu/Makefile - gconf/Makefile + grecs/Makefile + grecs/src/Makefile src/Makefile etc/Makefile]) diff --git a/gconf/.gitignore b/gconf/.gitignore deleted file mode 100644 index 42c88b2..0000000 --- a/gconf/.gitignore +++ b/dev/null @@ -1,4 +0,0 @@ -gconf-gram.c -gconf-gram.h -gconf-gram.output -gconf-lex.c diff --git a/gconf/Makefile.am b/gconf/Makefile.am deleted file mode 100644 index afe06b0..0000000 --- a/gconf/Makefile.am +++ b/dev/null @@ -1,17 +0,0 @@ -noinst_LIBRARIES=libgconf.a -libgconf_a_SOURCES = \ - gconf-format.c\ - gconf-gram.y\ - gconf-lex.l\ - gconf-preproc.c\ - gconf-text.c\ - gconf.h\ - wordsplit.c\ - wordsplit.h - -EXTRA_DIST=gconf-gram.h - -INCLUDES = -I$(top_srcdir)/gnu -I../gnu -AM_YFLAGS = -dtv -AM_LFLAGS = -dvp - diff --git a/gconf/gconf-format.c b/gconf/gconf-format.c deleted file mode 100644 index ea8a808..0000000 --- a/gconf/gconf-format.c +++ b/dev/null @@ -1,200 +0,0 @@ -/* gconf - General purpose configuration parser. - Copyright (C) 2007, 2008, 2009 Sergey Poznyakoff - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 3 of the License, or (at your - option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif -#include <gconf.h> -#include <stdio.h> -#include <stdlib.h> -#include <ctype.h> -#include <string.h> - -#if ENABLE_NLS -# include "gettext.h" -#else -# define gettext(s) s -#endif - -#define _(s) gettext (s) -#define N_(s) s - -const char * -gconf_data_type_string (enum gconf_data_type type) -{ - switch (type) - { - case gconf_type_void: - return "void"; - - case gconf_type_string: - return "string"; - - case gconf_type_short: - case gconf_type_ushort: - case gconf_type_int: - case gconf_type_uint: - case gconf_type_long: - case gconf_type_ulong: - case gconf_type_size: -/* case gconf_type_off:*/ - case gconf_type_uintmax: - case gconf_type_intmax: - return "number"; - - case gconf_type_time: - return "time"; - - case gconf_type_bool: - return "boolean"; - - case gconf_type_ipv4: - return "IPv4"; - - case gconf_type_cidr: - return "CIDR"; - - case gconf_type_host: - return "hostname"; - - case gconf_type_sockaddr: - return "sock-addr"; - - case gconf_type_section: - return "section"; - } - return "UNKNOWN?"; -} - -static void -format_level (FILE *stream, unsigned level) -{ - while (level--) - fprintf (stream, " "); -} - -void -gconf_format_docstring (FILE *stream, const char *docstring, unsigned level) -{ - size_t len = strlen (docstring); - int width = 78 - level * 2; - - if (width < 0) - { - width = 78; - level = 0; - } - - while (len) - { - size_t seglen; - const char *p; - - for (seglen = 0, p = docstring; p < docstring + width && *p; p++) - { - if (*p == '\n') - { - seglen = p - docstring; - break; - } - if (isspace (*p)) - seglen = p - docstring; - } - if (seglen == 0 || *p == 0) - seglen = p - docstring; - - format_level (stream, level); - fprintf (stream, "# "); - fwrite (docstring, seglen, 1, stream); - fputc ('\n', stream); - len -= seglen; - docstring += seglen; - if (*docstring == '\n') - { - docstring++; - len--; - } - else - while (*docstring && isspace (*docstring)) - { - docstring++; - len--; - } - } -} - -void -gconf_format_simple_statement (FILE *stream, struct gconf_keyword *kwp, - unsigned level) -{ - const char *argstr; - - if (kwp->docstring) - gconf_format_docstring (stream, kwp->docstring, level); - format_level (stream, level); - - if (kwp->argname) - argstr = kwp->argname; - else - argstr = N_("arg"); - - if (strchr ("<[", argstr[0])) - fprintf (stream, "%s %s;\n", kwp->ident, gettext (argstr)); - else if (strchr (argstr, ':')) - fprintf (stream, "%s <%s>;\n", kwp->ident, gettext (argstr)); - else - { - fprintf (stream, "%s <%s: ", kwp->ident, gettext (argstr)); - if (GCONF_IS_LIST (kwp->type)) - fprintf (stream, "list of %s", - gettext (gconf_data_type_string (GCONF_TYPE (kwp->type)))); - else - fprintf (stream, "%s", gettext (gconf_data_type_string (kwp->type))); - fprintf (stream, ">;\n"); - } -} - -void -gconf_format_block_statement (FILE *stream, struct gconf_keyword *kwp, - unsigned level) -{ - if (kwp->docstring) - gconf_format_docstring (stream, kwp->docstring, level); - format_level (stream, level); - fprintf (stream, "%s", kwp->ident); - if (kwp->argname) - fprintf (stream, " <%s>", gettext (kwp->argname)); - fprintf (stream, " {\n"); - gconf_format_statement_array (stream, kwp->kwd, 0, level + 1); - format_level (stream, level); - fprintf (stream, "}\n"); -} - -void -gconf_format_statement_array (FILE *stream, struct gconf_keyword *kwp, - unsigned n, - unsigned level) -{ - for (; kwp->ident; kwp++, n++) - { - if (n) - fputc ('\n', stream); - if (kwp->type == gconf_type_section) - gconf_format_block_statement (stream, kwp, level); - else - gconf_format_simple_statement (stream, kwp, level); - } -} diff --git a/gconf/gconf-gram.y b/gconf/gconf-gram.y deleted file mode 100644 index c2d833b..0000000 --- a/gconf/gconf-gram.y +++ b/dev/null @@ -1,891 +0,0 @@ -%{ -/* gconf - General purpose configuration parser. - Copyright (C) 2007, 2008, 2009 Sergey Poznyakoff - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 3 of the License, or (at your - option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif -#include <gconf.h> -#include <gconf-gram.h> -#include <stdlib.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/time.h> -#include <sys/un.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netdb.h> - -#include <xalloc.h> -#include <inttypes.h> - -#if ENABLE_NLS -# include "gettext.h" -# define _(msgid) gettext (msgid) -#else -# define _(msgid) msgid -#endif - -typedef union -{ - struct sockaddr s; - struct sockaddr_in s_in; - struct sockaddr_un s_un; -} sockaddr_union_t; - -static struct gconf_keyword config_keywords; -static struct gconf_keyword *cursect; -static gl_list_t sections; -int gconf_error_count; - -int gconf_default_port = 0; - -static void *target_ptr(struct gconf_keyword *kwp); -static void stmt_begin(struct gconf_keyword *kwp, gconf_value_t tag); -static void stmt_end(struct gconf_keyword *kwp); -static struct gconf_keyword *find_keyword(const char *ident); - -static void process_ident(struct gconf_keyword *kwp, gconf_value_t *value); -static gl_list_t simple_list_create (bool dispose); -%} - -%union { - char *string; - gconf_value_t value; - gl_list_t list; - struct gconf_keyword *kw; -} - -%token <string> IDENT STRING QSTRING MSTRING -%type <string> string slist -%type <list> slist0 -%type <value> value tag vallist -%type <list> values list vlist -%type <kw> ident - -%% - -input : stmtlist - ; - -stmtlist: stmt - | stmtlist stmt - ; - -stmt : simple - | block - ; - -simple : ident vallist ';' - { - process_ident($1, &$2); - } - ; - -block : ident tag { stmt_begin($<kw>1, $<value>2); } '{' stmtlist '}' opt_sc - { - stmt_end($1); - } - ; - -ident : IDENT - { - $$ = find_keyword($1); - if (!$$) - gconf_error(&gconf_current_locus, 0, _("Unknown keyword")); - } - ; - -tag : /* empty */ - { - $$.type = GCONF_TYPE_STRING; - $$.v.string = NULL; - } - | value - ; - -vallist : vlist - { - size_t n; - - if ((n = gl_list_size ($1)) == 1) - { - $$ = *(gconf_value_t *)gl_list_get_at ($1, 0); - } - else - { - size_t i; - - $$.type = GCONF_TYPE_ARRAY; - $$.v.arg.c = n; - $$.v.arg.v = xcalloc (n, sizeof ($$.v.arg.v[0])); - for (i = 0; i < n; i++) - $$.v.arg.v[i] = *(gconf_value_t *)gl_list_get_at ($1, i); - } - gl_list_free ($1); - } - ; - -vlist : value - { - $$ = simple_list_create (false); - gl_list_add_last ($$, gconf_value_dup (&$1)); - } - | vlist value - { - gl_list_add_last ($1, gconf_value_dup (&$2)); - } - ; - -value : string - { - $$.type = GCONF_TYPE_STRING; - $$.v.string = $1; - } - | list - { - $$.type = GCONF_TYPE_LIST; - $$.v.list = $1; - } - | MSTRING - { - $$.type = GCONF_TYPE_STRING; - $$.v.string = $1; - } - ; - -string : STRING - | IDENT - | slist - ; - -slist : slist0 - { - const void *p; - gl_list_iterator_t itr = gl_list_iterator ($1); - - gconf_line_begin (); - while (gl_list_iterator_next (&itr, &p, NULL)) - gconf_line_add (p, strlen (p)); - $$ = gconf_line_finish (); - gl_list_iterator_free (&itr); - gl_list_free ($1); - } - ; - -slist0 : QSTRING - { - $$ = simple_list_create (false); - gl_list_add_last ($$, $1); - } - | slist0 QSTRING - { - gl_list_add_last ($1, $2); - $$ = $1; - } - ; - -list : '(' ')' - { - $$ = NULL; - } - | '(' values ')' - { - $$ = $2; - } - | '(' values ',' ')' - { - $$ = $2; - } - ; - -values : value - { - $$ = simple_list_create (true); - gl_list_add_last ($$, gconf_value_dup (&$1)); - } - | values ',' value - { - gl_list_add_last ($1, gconf_value_dup (&$3)); - $$ = $1; - } - ; - -opt_sc : /* empty */ - | ';' - ; - -%% - -int -yyerror(char *s) -{ - gconf_error (&gconf_current_locus, 0, "%s", s); - return 0; -} - -static void -listel_dispose(const void *el) -{ - free((void*)el); -} - -static gl_list_t -simple_list_create (bool dispose) -{ - return gl_list_create_empty(&gl_linked_list_implementation, - NULL, - NULL, - dispose ? listel_dispose : NULL, - false); -} - - -void -gconf_warning(gconf_locus_t *locus, int errcode, const char *fmt, ...) -{ - va_list ap; - char *buf = NULL; - - va_start (ap, fmt); - vasprintf (&buf, fmt, ap); - va_end (ap); - gconf_print_diag (locus, 0, errcode, buf); - free(buf); -} - -void -gconf_error (gconf_locus_t *locus, int errcode, const char *fmt, ...) -{ - va_list ap; - char *buf = NULL; - - va_start (ap, fmt); - vasprintf (&buf, fmt, ap); - va_end (ap); - gconf_print_diag (locus, 1, errcode, buf); - free (buf); - gconf_error_count++; -} - -void -gconf_set_keywords (struct gconf_keyword *kwd) -{ - config_keywords.kwd = kwd; -} - -int -gconf_parse (const char *name) -{ - int rc; - if (gconf_lex_begin (name)) - return 1; - cursect = &config_keywords; - if (sections) - { - gl_list_free (sections); - sections = NULL; - } - rc = yyparse (); - gconf_lex_end (); - if (gconf_error_count) - rc = 1; - return rc; -} - -void -gconf_gram_trace (int n) -{ - yydebug = n; -} - - - -static void * -target_ptr (struct gconf_keyword *kwp) -{ - char *base; - - if (kwp->varptr) - base = (char*) kwp->varptr + kwp->offset; - else if (cursect && cursect->callback_data) - base = (char*) cursect->callback_data + kwp->offset; - else - base = NULL; - return base; -} - -static int -fake_callback (enum gconf_callback_command cmd, - gconf_locus_t *locus, - void *varptr, - gconf_value_t *value, - void *cb_data) -{ - return 0; -} - -static struct gconf_keyword fake = { - "*", - NULL, - NULL, - gconf_type_void, - NULL, - 0, - fake_callback, - NULL, - &fake -}; - -static void -stmt_begin (struct gconf_keyword *kwp, gconf_value_t tag) -{ - void *target; - - if (!sections) - sections = simple_list_create (false); - gl_list_add_first (sections, cursect); - if (kwp) - { - target = target_ptr (kwp); - cursect = kwp; - if (kwp->callback && kwp->callback (gconf_callback_section_begin, - &gconf_current_locus, /* FIXME */ - target, - &tag, - &kwp->callback_data)) - cursect = &fake; - } - else - /* install "ignore-all" section */ - cursect = kwp; -} - -static void -stmt_end (struct gconf_keyword *kwp) -{ - gconf_callback_fn callback = NULL; - void *dataptr = NULL; - - if (cursect && cursect->callback) - { - callback = cursect->callback; - dataptr = &cursect->callback_data; - } - - if (gl_list_size (sections) == 0) - abort (); - cursect = (struct gconf_keyword *) gl_list_get_at (sections, 0); - gl_list_remove_at (sections, 0); - if (callback) - callback (gconf_callback_section_end, - &gconf_current_locus, /* FIXME */ - kwp ? target_ptr(kwp) : NULL, - NULL, - dataptr); - -} - -static struct gconf_keyword * -find_keyword (const char *ident) -{ - struct gconf_keyword *kwp; - - if (cursect && cursect != &fake) - { - for (kwp = cursect->kwd; kwp->ident; kwp++) - if (strcmp (kwp->ident, ident) == 0) - return kwp; - } - else - { - return &fake; - } - return NULL; -} - -static int -string_to_signed (intmax_t *sval, const char *string, - intmax_t minval, intmax_t maxval) -{ - intmax_t t; - char *p; - - t = strtoimax (string, &p, 0); - if (*p) - { - gconf_error (&gconf_current_locus, 0, _("cannot convert `%s' to number"), - string); - return 1; - } - else if (t < minval || t > maxval) - { - gconf_error (&gconf_current_locus, 0, - _("%s: value out of allowed range %"PRIiMAX"..%"PRIiMAX), - string, minval, maxval); - return 1; - } - *sval = t; - return 0; -} - -static int -string_to_unsigned (uintmax_t *sval, const char *string, uintmax_t maxval, - gconf_locus_t *loc) -{ - uintmax_t t; - char *p; - - t = strtoumax (string, &p, 0); - if (*p) - { - gconf_error (loc, 0, _("cannot convert `%s' to number"), - string); - return 1; - } - else if (t > maxval) - { - gconf_error (loc, 0, - _("%s: value out of allowed range 0..%"PRIuMAX), - string, maxval); - return 1; - } - *sval = t; - return 0; -} - -static int -string_to_bool (const char *string, int *pval) -{ - if (strcmp (string, "yes") == 0 - || strcmp (string, "true") == 0 - || strcmp (string, "t") == 0 - || strcmp (string, "1") == 0) - *pval = 1; - else if (strcmp (string, "no") == 0 - || strcmp (string, "false") == 0 - || strcmp (string, "nil") == 0 - || strcmp (string, "0") == 0) - *pval = 0; - else - { - gconf_error (&gconf_current_locus, 0, - _("%s: not a valid boolean value"), - string); - return 1; - } - return 0; -} - -static int -string_to_host (struct in_addr *in, const char *string) -{ - if (inet_aton (string, in) == 0) - { - struct hostent *hp; - - hp = gethostbyname (string); - if (hp == NULL) - return 1; - memcpy (in, hp->h_addr, sizeof (struct in_addr)); - } - return 0; -} - -static int -string_to_sockaddr (struct gconf_sockaddr *sp, const char *string) -{ - if (string[0] == '/') - { - struct sockaddr_un s_un; - if (strlen (string) >= sizeof (s_un.sun_path)) - { - gconf_error (&gconf_current_locus, 0, - _("%s: UNIX socket name too long"), - string); - return 1; - } - s_un.sun_family = AF_UNIX; - strcpy (s_un.sun_path, string); - sp->len = sizeof (s_un); - sp->sa = xmalloc (sp->len); - memcpy (sp->sa, &s_un, sp->len); - } - else - { - char *p = strchr (string, ':'); - size_t len; - struct sockaddr_in sa; - - sa.sin_family = AF_INET; - if (p) - len = p - string; - else - len = strlen (string); - - if (len == 0) - sa.sin_addr.s_addr = INADDR_ANY; - else - { - char *host = xmalloc (len + 1); - memcpy (host, string, len); - host[len] = 0; - - if (string_to_host (&sa.sin_addr, host)) - { - gconf_error (&gconf_current_locus, 0, - _("%s: not a valid IP address or hostname"), - host); - free (host); - return 1; - } - free (host); - } - - if (p) - { - struct servent *serv; - - p++; - serv = getservbyname (p, "tcp"); - if (serv != NULL) - sa.sin_port = serv->s_port; - else - { - unsigned long l; - char *q; - - /* Not in services, maybe a number? */ - l = strtoul (p, &q, 0); - - if (*q || l > USHRT_MAX) - { - gconf_error (&gconf_current_locus, 0, - _("%s: not a valid port number"), p); - return 1; - } - sa.sin_port = htons (l); - } - } - else if (gconf_default_port) - sa.sin_port = gconf_default_port; - else - { - gconf_error (&gconf_current_locus, 0, _("missing port number")); - return 1; - } - sp->len = sizeof (sa); - sp->sa = xmalloc (sp->len); - memcpy (sp->sa, &sa, sp->len); - } - return 0; -} - -int -gconf_string_convert (void *target, enum gconf_data_type type, - const char *string) -{ - uintmax_t uval; - intmax_t sval; - - switch (type) - { - case gconf_type_void: - abort (); - - case gconf_type_string: - *(const char**)target = string; - break; - - case gconf_type_short: - if (string_to_signed (&sval, string, SHRT_MIN, SHRT_MAX) == 0) - *(short*)target = sval; - else - return 1; - break; - - case gconf_type_ushort: - if (string_to_unsigned (&uval, string, USHRT_MAX, &gconf_current_locus) == 0) - *(unsigned short*)target = uval; - else - return 1; - break; - - case gconf_type_bool: - return string_to_bool (string, (int*)target); - - case gconf_type_int: - if (string_to_signed (&sval, string, INT_MIN, INT_MAX) == 0) - *(int*)target = sval; - else - return 1; - break; - - case gconf_type_uint: - if (string_to_unsigned (&uval, string, UINT_MAX, &gconf_current_locus) == 0) - *(unsigned int*)target = uval; - else - return 1; - break; - - case gconf_type_long: - if (string_to_signed (&sval, string, LONG_MIN, LONG_MAX) == 0) - *(long*)target = sval; - else - return 1; - break; - - case gconf_type_ulong: - if (string_to_unsigned (&uval, string, ULONG_MAX, &gconf_current_locus) == 0) - *(unsigned long*)target = uval; - else - return 1; - break; - - case gconf_type_size: - if (string_to_unsigned (&uval, string, SIZE_MAX, &gconf_current_locus) == 0) - *(size_t*)target = uval; - else - return 1; - break; - - case gconf_type_intmax: - return string_to_signed ((intmax_t*)target, string, - INTMAX_MIN, INTMAX_MAX); - - case gconf_type_uintmax: - return string_to_unsigned ((uintmax_t*)target, string, UINTMAX_MAX, - &gconf_current_locus); - - case gconf_type_time: - /*FIXME: Use getdate */ - if (string_to_unsigned (&uval, string, (time_t)-1, &gconf_current_locus) == 0) - *(time_t*)target = uval; - else - return 1; - break; - - case gconf_type_ipv4: - if (inet_aton (string, (struct in_addr *)target)) - { - gconf_error (&gconf_current_locus, 0, _("%s: not a valid IP address"), string); - return 1; - } - break; - - case gconf_type_host: - if (string_to_host ((struct in_addr *)target, string)) - { - gconf_error (&gconf_current_locus, 0, - _("%s: not a valid IP address or hostname"), string); - return 1; - } - break; - - case gconf_type_sockaddr: - return string_to_sockaddr ((struct gconf_sockaddr *)target, string); - - /* FIXME: */ - case gconf_type_cidr: - gconf_error (&gconf_current_locus, 0, _("INTERNAL ERROR at %s:%d"), __FILE__, - __LINE__); - abort(); - - case gconf_type_section: - gconf_error (&gconf_current_locus, 0, - _("Invalid use of block statement")); - return 1; - } - return 0; -} - -struct gconf_prop -{ - size_t size; - gl_listelement_equals_fn eqfn; -}; - -static bool -string_eq (const void *elt1, const void *elt2) -{ - return strcmp ((const char *)elt1, (const char *)elt2) == 0; -} - -#define __gconf_name_cat__(a,b) a ## b -#define NUMEQ(type) __gconf_name_cat__(type,_eq) -#define __DECL_NUMEQ(type,ctype) \ - static bool \ - NUMEQ(type) (const void *elt1, const void *elt2) \ - { \ - return memcmp (elt1, elt2, sizeof (ctype)) == 0; \ - } -#define DECL_NUMEQ(type) __DECL_NUMEQ(type,type) - -DECL_NUMEQ(short) -DECL_NUMEQ(int) -DECL_NUMEQ(long) -DECL_NUMEQ(size_t) -DECL_NUMEQ(uintmax_t) -DECL_NUMEQ(intmax_t) -DECL_NUMEQ(time_t) -__DECL_NUMEQ(in_addr, struct in_addr) -__DECL_NUMEQ(gconf_sockaddr, struct gconf_sockaddr) - -struct gconf_prop gconf_prop_tab[] = { - { 0, NULL }, /* gconf_type_void */ - { sizeof (char*), string_eq }, /* gconf_type_string */ - { sizeof (short), NUMEQ (short) }, /* gconf_type_short */ - { sizeof (unsigned short), NUMEQ (short) }, /* gconf_type_ushort */ - { sizeof (int), NUMEQ (int) }, /* gconf_type_int */ - { sizeof (unsigned int), NUMEQ (int) }, /* gconf_type_uint */ - { sizeof (long), NUMEQ (long) }, /* gconf_type_long */ - { sizeof (unsigned long), NUMEQ (long) }, /* gconf_type_ulong */ - { sizeof (size_t), NUMEQ (size_t) }, /* gconf_type_size */ - /* gconf_type_off,*/ - { sizeof (uintmax_t), NUMEQ (uintmax_t) }, /* gconf_type_uintmax */ - { sizeof (intmax_t), NUMEQ (intmax_t) }, /* gconf_type_intmax */ - { sizeof (time_t), NUMEQ (time_t) }, /* gconf_type_time */ - { sizeof (int), NUMEQ (int) }, /* gconf_type_bool */ - { sizeof (struct in_addr), NUMEQ (in_addr) }, /* gconf_type_ipv4 */ - { 0, NULL }, /* FIXME: gconf_type_cidr */ - { sizeof (struct in_addr), NUMEQ (in_addr) }, /* gconf_type_host */ - { sizeof (struct gconf_sockaddr), NUMEQ (gconf_sockaddr) }, - /* gconf_type_sockaddr */ - { 0, NULL } /* gconf_type_section */ -}; -#define gconf_prop_count \ - (sizeof (gconf_prop_tab) / sizeof (gconf_prop_tab[0])) - -static void -process_ident (struct gconf_keyword *kwp, gconf_value_t *value) -{ - void *target; - - if (!kwp) - return; - - target = target_ptr (kwp); - - if (kwp->callback) - kwp->callback (gconf_callback_set_value, - &gconf_current_locus, /* FIXME */ - target, - value, - &kwp->callback_data); - else if (value->type == GCONF_TYPE_ARRAY) - { - gconf_error (&gconf_current_locus, 0, - _("too many arguments to `%s'; missing semicolon?"), - kwp->ident); - return; - } - else if (value->type == GCONF_TYPE_LIST) - { - if (GCONF_IS_LIST (kwp->type)) - { - gl_list_iterator_t itr = gl_list_iterator (value->v.list); - enum gconf_data_type type = GCONF_TYPE (kwp->type); - int num = 1; - const void *p; - gl_list_t list; - size_t size; - - if (type >= gconf_prop_count - || (size = gconf_prop_tab[type].size) == 0) - { - gconf_error (&gconf_current_locus, 0, - _("INTERNAL ERROR at %s:%d: " - "unhandled data type %d"), - __FILE__, __LINE__, type); - abort (); - } - - list = gl_list_create_empty (&gl_linked_list_implementation, - gconf_prop_tab[type].eqfn, - NULL, - listel_dispose, - false); - - while (gl_list_iterator_next (&itr, &p, NULL)) - { - const gconf_value_t *vp = p; - - if (vp->type != GCONF_TYPE_STRING) - gconf_error (&gconf_current_locus, 0, - _("%s: incompatible data type in list item #%d"), - kwp->ident, num); - else if (type == gconf_type_string) - gl_list_add_last (list, vp->v.string); - else - { - void *ptr = xmalloc (size); - if (gconf_string_convert (ptr, type, vp->v.string) == 0) - gl_list_add_last (list, ptr); - else - free (ptr); - } - } - gl_list_iterator_free (&itr); - *(gl_list_t*)target = list; - } - else - { - gconf_error (&gconf_current_locus, 0, - _("incompatible data type for `%s'"), - kwp->ident); - return; - } - } - else if (GCONF_IS_LIST (kwp->type)) - { - gl_list_t list; - enum gconf_data_type type = GCONF_TYPE (kwp->type); - size_t size; - void *ptr; - - if (type >= gconf_prop_count - || (size = gconf_prop_tab[type].size) == 0) - { - gconf_error (&gconf_current_locus, 0, - _("INTERNAL ERROR at %s:%d: unhandled data type %d"), - __FILE__, __LINE__, type); - abort(); - } - - list = gl_list_create_empty (&gl_linked_list_implementation, - gconf_prop_tab[type].eqfn, - NULL, - listel_dispose, - false); - if (type == gconf_type_string) - gl_list_add_last (list, value->v.string); - else - { - ptr = xmalloc (size); - if (gconf_string_convert (ptr, type, value->v.string)) - { - free (ptr); - gl_list_free (list); - return; - } - gl_list_add_last (list, ptr); - } - *(gl_list_t*)target = list; - } - else - gconf_string_convert (target, GCONF_TYPE (kwp->type), value->v.string); -} - diff --git a/gconf/gconf-lex.l b/gconf/gconf-lex.l deleted file mode 100644 index 1379640..0000000 --- a/gconf/gconf-lex.l +++ b/dev/null @@ -1,476 +0,0 @@ -/* gconf - General purpose configuration parser. -*- c -*- */ -%{ -/* gconf - General purpose configuration parser. - Copyright (C) 2007, 2008, 2009 Sergey Poznyakoff - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 3 of the License, or (at your - option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif -#include <gconf.h> -#include <gconf-gram.h> -#include <unistd.h> -#include <fcntl.h> -#include <ctype.h> -#include <stdlib.h> -#include <errno.h> - -#define obstack_chunk_alloc malloc -#define obstack_chunk_free free -#include <obstack.h> -#include <xalloc.h> -#include <wordsplit.h> - -#if ENABLE_NLS -# include "gettext.h" -# define _(msgid) gettext (msgid) -#else -# define _(msgid) msgid -#endif - -static char *multiline_delimiter; -static size_t multiline_delimiter_len; -static int multiline_unescape; /* Unescape here-document contents */ -static int (*char_to_strip) (char); /* Strip matching characters of each - here-document line */ - -gconf_locus_t gconf_current_locus; /* Input file location */ -/* Line correction. Equals to the number of #line directives inserted into - the input by the preprocessor instance. The external preprocessor, if - any, counts these as input lines and therefore the line numbers in *its* - #line directives are offset by the value of XLINES. - - Uff, running two preprocessors is confusing... -*/ -static size_t xlines; -static struct obstack stk; - -static void multiline_begin (char *); -static void multiline_add (char *); -static char *multiline_strip_tabs (char *text); -static void line_add_unescape_last (char *text, size_t len); -static int ident (void); -static int isemptystr (int off); - -static void parse_line (char *text, gconf_locus_t *ploc, size_t *pxlines); -static void parse_line_cpp (char *text, gconf_locus_t *ploc, size_t *pxlines); - -#undef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - do \ - { \ - if (gconf_preprocessor) \ - result = fread (buf, 1, max_size, yyin); \ - else \ - result = gconf_preproc_fill_buffer(buf, max_size); \ - } \ - while (0) - -%} - - -%x COMMENT ML STR - -WS [ \t\f][ \t\f]* -ID [a-zA-Z_][a-zA-Z_0-9-]+ -P [1-9][0-9]* - -%% - /* C-style comments */ -"/*" BEGIN (COMMENT); -<COMMENT>[^*\n]* /* eat anything that's not a '*' */ -<COMMENT>"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ -<COMMENT>\n ++gconf_current_locus.line; -<COMMENT>"*"+"/" BEGIN (INITIAL); - /* Line directive */ -^[ \t]*#[ \t]*{P}[ \t]+\".*\".*\n { parse_line_cpp (yytext, - &gconf_current_locus, - &xlines); } -^[ \t]*#[ \t]*line[ \t].*\n { parse_line (yytext, &gconf_current_locus, - &xlines); } - /* End-of-line comments */ -#.*\n { gconf_current_locus.line++; } -#.* /* end-of-file comment */; -"//".*\n { gconf_current_locus.line++; } -"//".* /* end-of-file comment */; - /* Identifiers */ -<INITIAL>{ID} return ident (); - /* Strings */ -[a-zA-Z0-9_\.\*/:@-]+ { gconf_line_begin (); - gconf_line_add (yytext, yyleng); - yylval.string = gconf_line_finish (); - return STRING; } - /* Quoted strings */ -\"[^\\"\n]*\" { gconf_line_begin (); - gconf_line_add (yytext + 1, yyleng - 2); - yylval.string = gconf_line_finish (); - return QSTRING; } -\"[^\\"\n]*\\. | -\"[^\\"\n]*\\\n { BEGIN (STR); - gconf_line_begin (); - line_add_unescape_last (yytext + 1, yyleng - 1); } -<STR>[^\\"\n]*\\. | -<STR>\"[^\\"\n]*\\\n { line_add_unescape_last (yytext, yyleng); } -<STR>[^\\"\n]*\" { BEGIN(INITIAL); - if (yyleng > 1) - gconf_line_add (yytext, yyleng - 1); - yylval.string = gconf_line_finish (); - return QSTRING; } - /* Multiline strings */ -"<<"(-" "?)?\\?{ID}[ \t]*#.*\n | -"<<"(-" "?)?\\?{ID}[ \t]*"//".*\n | -"<<"(-" "?)?\\?{ID}[ \t]*\n | -"<<"(-" "?)?\"{ID}\"[ \t]*#.*\n | -"<<"(-" "?)?\"{ID}\"[ \t]*"//".*\n | -"<<"(-" "?)?\"{ID}\"[ \t]*\n { - BEGIN (ML); - multiline_begin (yytext+2); - gconf_current_locus.line++; } - /* Ignore m4 line statements */ -<ML>^"#line ".*\n { gconf_current_locus.line++; } -<ML>.*\n { char *p = multiline_strip_tabs (yytext); - - if (!strncmp (p, multiline_delimiter, multiline_delimiter_len) - && isemptystr (p + multiline_delimiter_len - yytext)) - { - free (multiline_delimiter); - multiline_delimiter = NULL; - BEGIN (INITIAL); - yylval.string = gconf_line_finish (); - return MSTRING; - } - gconf_current_locus.line++; - multiline_add (p); } -{WS} ; - /* Other tokens */ -\n { gconf_current_locus.line++; } -[,;{}()] return yytext[0]; -. { if (isascii (yytext[0]) && isprint (yytext[0])) - gconf_error (&gconf_current_locus, 0, _("stray character %c"), yytext[0]); - else - gconf_error (&gconf_current_locus, 0, _("stray character \\%03o"), - (unsigned char) yytext[0]); } -%% - -pid_t gconf_preproc_pid; - -int -yywrap () -{ - if (yyin) - gconf_preproc_extrn_shutdown (gconf_preproc_pid); - else - gconf_preproc_done (); - gconf_current_locus.file = NULL; - return 1; -} - -int -gconf_lex_begin (const char *name) -{ - if (yy_flex_debug > 0) - yy_flex_debug = 0; - obstack_init (&stk); - if (gconf_preprocessor) - { - int fd; - - fd = open (name, O_RDONLY); - if (fd == -1) - { - gconf_error (NULL, errno, _("Cannot open `%s'"), name); - return 1; - } - close (fd); - - yyin = gconf_preproc_extrn_start (name, &gconf_preproc_pid); - if (!yyin) - { - gconf_error (NULL, errno, - _("Unable to start external preprocessor `%s'"), - gconf_preprocessor); - return 1; - } - } - else - return gconf_preproc_init (name); - - return 0; -} - -void -gconf_lex_end () -{ -} - -static int -isemptystr (int off) -{ - for (; yytext[off] && isspace (yytext[off]); off++) - ; - if (yytext[off] == ';') - { - int i; - for (i = off + 1; yytext[i]; i++) - if (!isspace (yytext[i])) - return 0; - yyless (off); - return 1; - } - return yytext[off] == 0; -} - -char * -multiline_strip_tabs (char *text) -{ - if (char_to_strip) - for (; *text && char_to_strip (*text); text++) - ; - return text; -} - -static int -unquote_char (int c) -{ - static char quote_transtab[] = "\\\\a\ab\bf\fn\nr\rt\t"; - - char *p; - - for (p = quote_transtab; *p; p += 2) - { - if (*p == c) - return p[1]; - } - return -1; -} - -static void -unescape_to_obstack (int c) -{ - if (c != '\n') - { - int t = unquote_char (c); - if (t != -1) - obstack_1grow (&stk, t); - else - { - gconf_warning(&gconf_current_locus, 0, - _("unknown escape sequence '\\%c'"), - c); - obstack_1grow (&stk, c); - } - } -} - -void -gconf_line_add (const char *text, size_t len) -{ - obstack_grow (&stk, text, len); -} - -/* Same, but unescapes the last character from yytext */ -static void -line_add_unescape_last (char *text, size_t len) -{ - obstack_grow (&stk, text, len - 2); - unescape_to_obstack (text[len - 1]); -} - -static void -multiline_add (char *s) -{ - if (multiline_unescape) - { - for (; *s; s++) - { - if (*s == '\\') - { - unescape_to_obstack (s[1]); - ++s; - } - else - obstack_1grow (&stk, *s); - } - } - else - gconf_line_add (s, strlen (s)); -} - -void -gconf_line_begin () -{ - /* FIXME: nothing so far. Maybe prepare stk by calling obstack_finish? */ -} - -static int -is_tab (char c) -{ - return c == '\t'; -} - -static int -is_ws (char c) -{ - return c == '\t' || c == ' '; -} - -void -multiline_begin (char *p) -{ - if (*p == '-') - { - if (*++p == ' ') - { - char_to_strip = is_ws; - p++; - } - else - char_to_strip = is_tab; - } - else - char_to_strip = NULL; - if (*p == '\\') - { - p++; - multiline_unescape = 0; - } - else if (*p == '"') - { - char *q; - - p++; - multiline_unescape = 0; - q = strchr (p, '"'); - multiline_delimiter_len = q - p; - } - else - { - multiline_delimiter_len = strcspn (p, " \t"); - multiline_unescape = 1; - } - - /* Remove trailing newline */ - multiline_delimiter_len--; - multiline_delimiter = xmalloc (multiline_delimiter_len + 1); - memcpy (multiline_delimiter, p, multiline_delimiter_len); - multiline_delimiter[multiline_delimiter_len] = 0; - gconf_line_begin (); -} - -char * -gconf_line_finish () -{ - obstack_1grow (&stk, 0); - return obstack_finish (&stk); -} - -static int -ident () -{ - char *p; - - for (p = yytext; *p && isspace (*p); p++) - ; - obstack_grow (&stk, p, strlen (p)); - obstack_1grow (&stk, 0); - yylval.string = obstack_finish (&stk); - return IDENT; -} - -void -gconf_lex_trace (int n) -{ - yy_flex_debug = -n; -} - -gconf_value_t * -gconf_value_dup(gconf_value_t *input) -{ - gconf_value_t *ptr = obstack_alloc (&stk, sizeof (*ptr)); - *ptr = *input; - return ptr; -} - - -static int -assign_locus (gconf_locus_t *ploc, char *name, char *line, size_t *pxlines) -{ - char *p; - - if (name) - { - if (pxlines && (!ploc->file || strcmp(name, ploc->file))) - *pxlines = 0; - ploc->file = gconf_install_text (name); - } - ploc->line = strtoul (line, &p, 10) - (pxlines ? *pxlines : 0); - return *p != 0; -} - -static void -parse_line (char *text, gconf_locus_t *ploc, size_t *pxlines) -{ - int rc = 1; - struct wordsplit ws; - - if (wordsplit (text, &ws, WRDSF_DEFFLAGS)) - gconf_error (ploc, 0, _("cannot parse #line line")); - else - { - if (ws.ws_wordc == 2) - rc = assign_locus (ploc, NULL, ws.ws_wordv[1], pxlines); - else if (ws.ws_wordc == 3) - rc = assign_locus (ploc, ws.ws_wordv[2], ws.ws_wordv[1], pxlines); - else if (ws.ws_wordc == 4) - { - rc = assign_locus (ploc, ws.ws_wordv[2], ws.ws_wordv[1], 0); - if (rc == 0) - { - char *p; - unsigned long x = strtoul (ws.ws_wordv[3], &p, 10); - rc = *p != 0; - if (rc == 0) - *pxlines = x; - } - } - else - gconf_error (ploc, 0, _("invalid #line statement")); - - if (rc) - gconf_error (ploc, 0, _("malformed #line statement")); - wordsplit_free (&ws); - } -} - -static void -parse_line_cpp (char *text, gconf_locus_t *ploc, size_t *pxlines) -{ - struct wordsplit ws; - - if (wordsplit (text, &ws, WRDSF_DEFFLAGS)) - { - gconf_error (ploc, 0, _("cannot parse #line line")); - return; - } - else if (ws.ws_wordc < 3) - gconf_error (ploc, 0, _("invalid #line statement")); - else - { - if (assign_locus (ploc, ws.ws_wordv[2], ws.ws_wordv[1], pxlines)) - gconf_error (ploc, 0, _("malformed #line statement")); - } - wordsplit_free (&ws); -} - diff --git a/gconf/gconf-preproc.c b/gconf/gconf-preproc.c deleted file mode 100644 index 5bd0a95..0000000 --- a/gconf/gconf-preproc.c +++ b/dev/null @@ -1,728 +0,0 @@ -/* gconf - General purpose configuration parser. - Copyright (C) 2007, 2008, 2009 Sergey Poznyakoff - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 3 of the License, or (at your - option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif -#include <gconf.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/wait.h> -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <string.h> -#include <errno.h> - -#include <xalloc.h> -#include <hash.h> -#include <gl_linked_list.h> -#include <inttostr.h> -#include <wordsplit.h> - -#if ENABLE_NLS -# include "gettext.h" -# define _(msgid) gettext (msgid) -#else -# define _(msgid) msgid -#endif - -bool gconf_log_to_stderr = true; -void (*gconf_log_setup_hook) () = NULL; - -struct input_file_ident -{ - ino_t i_node; - dev_t device; -}; - -struct buffer_ctx -{ - struct buffer_ctx *prev; /* Pointer to previous context */ - gconf_locus_t locus; /* Current input location */ - size_t namelen; /* Length of the file name */ - size_t xlines; /* Number of #line directives output so far */ - struct input_file_ident id; - FILE *infile; -}; - -extern int yy_flex_debug; -static struct buffer_ctx *context_stack; - -#define INFILE context_stack->infile -#define LOCUS context_stack->locus - -static char *linebuf; -static size_t bufsize; -static char *putback_buffer; -static size_t putback_size; -static size_t putback_max; - -static int push_source (const char *name, int once); -static int pop_source (void); -static int parse_include (const char *text, int once); - -static void -putback (const char *str) -{ - size_t len; - - if (!*str) - return; - len = strlen (str) + 1; - if (len > putback_max) - { - putback_max = len; - putback_buffer = xrealloc (putback_buffer, putback_max); - } - strcpy (putback_buffer, str); - putback_size = len - 1; -} - -/* Compute the size of the line - - #line NNN "FILENAME" -*/ -static size_t -pp_line_stmt_size () -{ - char lbuf[INT_BUFSIZE_BOUND(uintmax_t)]; - char xbuf[INT_BUFSIZE_BOUND(uintmax_t)]; - char *lp, *xp; - - lp = umaxtostr (LOCUS.line, lbuf); - xp = umaxtostr (context_stack->xlines + 1, xbuf); - if (context_stack->namelen == 0) - context_stack->namelen = strlen (LOCUS.file); - /* "#line " is 6 chars, two more spaces, two quotes and a linefeed - make another 5, summa facit 11 */ - return 11 + strlen (lp) + strlen (xp) + context_stack->namelen; -} - -static void -pp_line_stmt () -{ - char *p; - size_t ls_size = pp_line_stmt_size (); - size_t pb_size = putback_size + ls_size + 1; - - if (pb_size > putback_max) - { - putback_max = pb_size; - putback_buffer = xrealloc (putback_buffer, putback_max); - } - - p = putback_buffer + putback_size; - context_stack->xlines++; - snprintf (p, putback_max - putback_size, - "#line %lu \"%s\" %lu\n", - (unsigned long) LOCUS.line, - LOCUS.file, (unsigned long) context_stack->xlines); - putback_size += ls_size; -} - -#define STRMATCH(p, len, s) (len >= sizeof(s) \ - && memcmp (p, s, sizeof(s) - 1) == 0 \ - && isspace(p[sizeof(s) - 1])) - -static int -next_line () -{ - ssize_t rc; - - do - { - if (putback_size) - { - if (putback_size + 1 > bufsize) - { - bufsize = putback_size + 1; - linebuf = xrealloc (linebuf, bufsize); - } - strcpy (linebuf, putback_buffer); - rc = putback_size; - putback_size = 0; - } - else if (!context_stack) - return 0; - else - rc = getline (&linebuf, &bufsize, INFILE); - } - while (rc == -1 && pop_source () == 0); - return rc; -} - -size_t -gconf_preproc_fill_buffer (char *buf, size_t size) -{ - size_t bufsize = size; - - while (next_line () > 0) - { - char *p; - size_t len; - int is_line = 0; - - for (p = linebuf; *p && isspace (*p); p++) - ; - if (*p == '#') - { - size_t l; - for (p++; *p && isspace (*p); p++) - ; - l = strlen (p); - if (STRMATCH (p, l, "include_once")) - { - if (parse_include (linebuf, 1)) - putback ("/*include_once*/\n"); - continue; - } - else if (STRMATCH (p, l, "include")) - { - if (parse_include (linebuf, 0)) - putback ("/*include*/\n"); - continue; - } - else if (STRMATCH (p, l, "line")) - is_line = 1; - } - - len = strlen (linebuf); - - if (len > size) - len = size; - - memcpy (buf, linebuf, len); - buf += len; - size -= len; - - if (size == 0) - { - putback (linebuf + len); - break; - } - - if (!is_line && len > 0 && linebuf[len - 1] == '\n') - LOCUS.line++; - } - return bufsize - size; -} - -#define STAT_ID_EQ(st,id) ((id).i_node == (st).st_ino \ - && (id).device == (st).st_dev) - -static struct buffer_ctx * -ctx_lookup (struct stat *st) -{ - struct buffer_ctx *ctx; - - if (!context_stack) - return NULL; - - for (ctx = context_stack->prev; ctx; ctx = ctx->prev) - if (STAT_ID_EQ (*st, ctx->id)) - break; - return ctx; -} - -const char *gconf_preprocessor = NULL; -static gl_list_t include_path; -static gl_list_t std_include_path; - -struct file_data -{ - const char *name; - size_t namelen; - char *buf; - size_t buflen; - int found; -}; - -static int -pp_list_find (gl_list_t list, struct file_data *dptr) -{ - const void *p; - gl_list_iterator_t itr = gl_list_iterator (list); - - while (!dptr->found && gl_list_iterator_next (&itr, &p, NULL)) - { - const char *dir = p; - size_t size = strlen (dir) + 1 + dptr->namelen + 1; - if (size > dptr->buflen) - { - dptr->buflen = size; - dptr->buf = xrealloc (dptr->buf, dptr->buflen); - } - strcpy (dptr->buf, dir); - strcat (dptr->buf, "/"); - strcat (dptr->buf, dptr->name); - dptr->found = access (dptr->buf, F_OK) == 0; - } - gl_list_iterator_free (&itr); - return dptr->found; -} - -gl_list_t -pp_list_create () -{ - return gl_list_create_empty(&gl_linked_list_implementation, - NULL, - NULL, - NULL, - false); -} - -void -gconf_include_path_setup_v (char **dirs) -{ - if (!include_path) - include_path = pp_list_create (); - std_include_path = pp_list_create (); - if (dirs) - { - int i; - for (i = 0; dirs[i]; i++) - /* FIXME: Element never freed */ - gl_list_add_last (std_include_path, xstrdup (dirs[i])); - } -} - -void -gconf_include_path_setup (const char *dir, ...) -{ - const char *p; - char **argv = NULL; - size_t argc = 0; - size_t argi = 0; - va_list ap; - - va_start (ap, dir); - p = dir; - while (1) - { - if (argi == argc) - { - if (argc == 0) - argc = 16; - argv = x2nrealloc (argv, &argc, sizeof (argv[0])); - } - argv[argi++] = (char*) p; - if (!p) - break; - p = va_arg (ap, const char*); - } - gconf_include_path_setup_v (argv); - free (argv); - va_end (ap); -} - -void -gconf_preproc_add_include_dir (char *dir) -{ - if (!include_path) - include_path = pp_list_create (); - gl_list_add_last (include_path, dir); -} - -static Hash_table *incl_sources; - -/* Calculate the hash of a struct input_file_ident. */ -static size_t -incl_hasher (void const *data, unsigned n_buckets) -{ - const struct input_file_ident *id = data; - return (id->i_node + id->device) % n_buckets; -} - -/* Compare two input_file_idents for equality. */ -static bool -incl_compare (void const *data1, void const *data2) -{ - const struct input_file_ident *id1 = data1; - const struct input_file_ident *id2 = data2; - return id1->device == id2->device && id1->i_node == id2->i_node; -} - -static void -incl_free (void *data) -{ - free (data); -} - -static int -source_lookup (struct stat *st) -{ - struct input_file_ident *sample = xmalloc (sizeof (*sample)), *id; - - sample->i_node = st->st_ino; - sample->device = st->st_dev; - - if (!((incl_sources - || (incl_sources = hash_initialize (0, 0, - incl_hasher, - incl_compare, - incl_free))) - && (id = hash_insert (incl_sources, sample)))) - xalloc_die (); - - if (id != sample) - { - free (sample); - return 1; /* Found */ - } - return 0; -} - - -static int -push_source (const char *name, int once) -{ - FILE *fp; - struct buffer_ctx *ctx; - struct stat st; - int rc = stat (name, &st); - - if (context_stack) - { - if (rc) - { - gconf_error (&LOCUS, errno, _("Cannot stat `%s'"), name); - return 1; - } - - if (LOCUS.file && STAT_ID_EQ (st, context_stack->id)) - { - gconf_error (&LOCUS, 0, _("Recursive inclusion")); - return 1; - } - - if ((ctx = ctx_lookup (&st))) - { - gconf_error (&LOCUS, 0, _("Recursive inclusion")); - if (ctx->prev) - gconf_error (&ctx->prev->locus, 0, - _("`%s' already included here"), name); - else - gconf_error (&LOCUS, 0, - _("`%s' already included at top level"), name); - return 1; - } - } - else if (rc) - { - gconf_error (NULL, errno, _("Cannot stat `%s'"), name); - return 1; - } - - if (once && source_lookup (&st)) - return -1; - - fp = fopen (name, "r"); - if (!fp) - { - gconf_error (&LOCUS, errno, _("Cannot open `%s'"), name); - return 1; - } - - /* Push current context */ - ctx = xmalloc (sizeof (*ctx)); - ctx->locus.file = gconf_install_text (name); - ctx->locus.line = 1; - ctx->xlines = 0; - ctx->namelen = strlen (ctx->locus.file); - ctx->id.i_node = st.st_ino; - ctx->id.device = st.st_dev; - ctx->infile = fp; - ctx->prev = context_stack; - context_stack = ctx; - - if (yy_flex_debug) - fprintf (stderr, "Processing file `%s'\n", name); - - pp_line_stmt (); - - return 0; -} - -static int -pop_source () -{ - struct buffer_ctx *ctx; - - if (!context_stack) - return 1; - - fclose (INFILE); - - /* Restore previous context */ - ctx = context_stack->prev; - free (context_stack); - context_stack = ctx; - - if (!context_stack) - { - if (yy_flex_debug) - fprintf (stderr, "End of input\n"); - return 1; - } - - LOCUS.line++; - - if (yy_flex_debug) - fprintf (stderr, "Resuming file `%s' at line %lu\n", - LOCUS.file, (unsigned long) LOCUS.line); - - pp_line_stmt (); - - return 0; -} - -static int -try_file (const char *name, int allow_cwd, int err_not_found, char **newp) -{ - static char *cwd = "."; - struct file_data fd; - - fd.name = name; - fd.namelen = strlen (name); - fd.buf = NULL; - fd.buflen = 0; - fd.found = 0; - - if (!include_path) - gconf_include_path_setup (NULL); - if (allow_cwd) - { - gl_list_node_t node = gl_list_add_last (include_path, cwd); - pp_list_find (include_path, &fd); - gl_list_remove_node (include_path, node); - } - else - pp_list_find (include_path, &fd); - - if (!fd.found) - { - pp_list_find (std_include_path, &fd); - - if (!fd.found && err_not_found) - { - gconf_error (&LOCUS, 0, _("%s: No such file or directory"), name); - *newp = NULL; - } - } - if (fd.found) - *newp = fd.buf; - return fd.found; -} - -static int -parse_include (const char *text, int once) -{ - struct wordsplit ws; - char *tmp = NULL; - char *p = NULL; - int rc = 1; - - if (wordsplit (text, &ws, WRDSF_DEFFLAGS)) - gconf_error (&LOCUS, 0, _("Cannot parse include line")); - else if (ws.ws_wordc != 2) - { - wordsplit_free (&ws); - gconf_error (&LOCUS, 0, _("invalid include statement")); - } - else - { - size_t len; - int allow_cwd; - - p = ws.ws_wordv[1]; - len = strlen (p); - - if (p[0] == '<' && p[len - 1] == '>') - { - allow_cwd = 0; - p[len - 1] = 0; - p++; - } - else - allow_cwd = 1; - - if (p[0] != '/' && try_file (p, allow_cwd, 1, &tmp)) - p = tmp; - } - - if (p) - rc = push_source (p, once); - free (tmp); - wordsplit_free (&ws); - return rc; -} - -int -gconf_preproc_init (const char *name) -{ - return push_source (name, 0); -} - -void -gconf_preproc_done () -{ - if (incl_sources) - hash_free (incl_sources); - free (linebuf); - free (putback_buffer); -} - -int -gconf_preproc_run (const char *config_file, const char *extpp) -{ - size_t i; - char buffer[512]; - - if (gconf_preproc_init (config_file)) - return 1; - if (extpp) - { - FILE *outfile; - char *setup_file; - char *cmd; - - if (try_file ("pp-setup", 1, 0, &setup_file)) - { - asprintf (&cmd, "%s %s -", extpp, setup_file); - free (setup_file); - } - else - cmd = xstrdup (extpp); - //FIXME_DEBUG_F1 (2, "Running preprocessor: `%s'", cmd); - outfile = popen (cmd, "w"); - if (!outfile) - { - gconf_error (NULL, errno, - _("Unable to start external preprocessor `%s'"), cmd); - free (cmd); - return 1; - } - - while ((i = gconf_preproc_fill_buffer (buffer, sizeof buffer))) - fwrite (buffer, 1, i, outfile); - pclose (outfile); - free (cmd); - } - else - { - while ((i = gconf_preproc_fill_buffer (buffer, sizeof buffer))) - fwrite (buffer, 1, i, stdout); - } - gconf_preproc_done (); - return 0; -} - -FILE * -gconf_preproc_extrn_start (const char *file_name, pid_t *ppid) -{ - int pout[2]; - pid_t pid; - int i; - FILE *fp = NULL; - - //FIXME_DEBUG_F1 (2, "Running preprocessor: `%s'", ppcmd); - - pipe (pout); - switch (pid = fork ()) - { - /* The child branch. */ - case 0: - if (pout[1] != 1) - { - close (1); - dup2 (pout[1], 1); - } - - /* Close unneeded descripitors */ - for (i = getdtablesize (); i > 2; i--) - close (i); - - if (!gconf_log_to_stderr) - { - int p[2]; - char *buf = NULL; - size_t size = 0; - FILE *fp; - - signal (SIGCHLD, SIG_DFL); - pipe (p); - switch (pid = fork ()) - { - /* Grandchild */ - case 0: - if (p[1] != 2) - { - close (2); - dup2 (p[1], 2); - } - close (p[0]); - - if (gconf_preproc_run (file_name, gconf_preprocessor)) - exit (127); - exit (0); - - case -1: - /* Fork failed */ - if (gconf_log_setup_hook) - gconf_log_setup_hook (); - gconf_error (NULL, errno, _("Cannot run `%s'"), - gconf_preprocessor); - exit (127); - - default: - /* Sub-master */ - close (p[1]); - fp = fdopen (p[0], "r"); - if (gconf_log_setup_hook) - gconf_log_setup_hook (); - while (getline (&buf, &size, fp) > 0) - gconf_error (NULL, 0, "%s", buf); - } - } - else - { - gconf_preproc_run (file_name, gconf_preprocessor); - } - exit (0); - - case -1: - /* Fork failed */ - gconf_error (NULL, errno, _("Cannot run `%s'"), gconf_preprocessor); - break; - - default: - close (pout[1]); - fp = fdopen (pout[0], "r"); - break; - } - *ppid = pid; - return fp; -} - -void -gconf_preproc_extrn_shutdown (pid_t pid) -{ - int status; - waitpid (pid, &status, 0); -} - diff --git a/gconf/gconf-text.c b/gconf/gconf-text.c deleted file mode 100644 index 0545293..0000000 --- a/gconf/gconf-text.c +++ b/dev/null @@ -1,73 +0,0 @@ -/* gconf - General purpose configuration parser. - Copyright (C) 2007, 2008, 2009 Sergey Poznyakoff - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 3 of the License, or (at your - option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif -#include <gconf.h> -#include <string.h> -#include <hash.h> -#include <xalloc.h> - -static Hash_table *text_table; - -/* Calculate the hash of a string. */ -static size_t -text_hasher (void const *data, unsigned n_buckets) -{ - return hash_string (data, n_buckets); -} - -/* Compare two strings for equality. */ -static bool -text_compare (void const *data1, void const *data2) -{ - return strcmp (data1, data2) == 0; -} - -static void -text_free (void *data) -{ - free (data); -} - -/* Lookup a text. If it does not exist, create it. */ -char * -gconf_install_text (const char *str) -{ - char *text, *s; - - s = xstrdup (str); - - if (!((text_table - || (text_table = hash_initialize (0, 0, - text_hasher, - text_compare, - text_free))) - && (text = hash_insert (text_table, s)))) - xalloc_die (); - - if (s != text) - free (s); - return text; -} - -void -gconf_destroy_text () -{ - if (text_table) - hash_free (text_table); -} diff --git a/gconf/gconf.h b/gconf/gconf.h deleted file mode 100644 index f3d1bf8..0000000 --- a/gconf/gconf.h +++ b/dev/null @@ -1,163 +0,0 @@ -/* gconf - General purpose configuration parser. - Copyright (C) 2007, 2008, 2009 Sergey Poznyakoff - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 3 of the License, or (at your - option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#include <sys/types.h> -#include <unistd.h> -#include <stdlib.h> -#include <stdio.h> -#include <stdbool.h> -#include <gl_linked_list.h> - -typedef struct { - char *file; - int line; -} gconf_locus_t; - -extern gconf_locus_t gconf_locus; - -enum gconf_data_type { - gconf_type_void, - gconf_type_string, - gconf_type_short, - gconf_type_ushort, - gconf_type_int, - gconf_type_uint, - gconf_type_long, - gconf_type_ulong, - gconf_type_size, -/* gconf_type_off,*/ - gconf_type_uintmax, - gconf_type_intmax, - gconf_type_time, - gconf_type_bool, - gconf_type_ipv4, - gconf_type_cidr, - gconf_type_host, - gconf_type_sockaddr, - gconf_type_section -}; - -#define GCONF_LIST 0x8000 -#define GCONF_TYPE_MASK 0x00ff -#define GCONF_TYPE(c) ((c) & GCONF_TYPE_MASK) -#define GCONF_IS_LIST(c) ((c) & GCONF_LIST) - -enum gconf_callback_command { - gconf_callback_section_begin, - gconf_callback_section_end, - gconf_callback_set_value -}; - -#define GCONF_TYPE_STRING 0 -#define GCONF_TYPE_LIST 1 -#define GCONF_TYPE_ARRAY 2 - -typedef struct gconf_value { - int type; - union { - gl_list_t list; - const char *string; - struct { - size_t c; - struct gconf_value *v; - } arg; - } v; -} gconf_value_t; - -typedef int (*gconf_callback_fn) ( - enum gconf_callback_command cmd, - gconf_locus_t * /* locus */, - void * /* varptr */, - gconf_value_t * /* value */, - void * /* cb_data */ - ); - -struct gconf_keyword { - const char *ident; - const char *argname; - const char *docstring; - enum gconf_data_type type; - void *varptr; - size_t offset; - gconf_callback_fn callback; - void *callback_data; - struct gconf_keyword *kwd; -}; - -struct gconf_sockaddr { - int len; - struct sockaddr *sa; -}; - -gconf_value_t *gconf_value_dup(gconf_value_t *input); - -extern void gconf_print_diag(gconf_locus_t *, int, int, const char*); - -void gconf_warning(gconf_locus_t *locus, int errcode, const char *fmt, ...) - __attribute__ ((__format__ (__printf__, 3, 4))); -void gconf_error(gconf_locus_t *locus, int errcode, const char *fmt, ...) - __attribute__ ((__format__ (__printf__, 3, 4))); -void gconf_set_keywords(struct gconf_keyword *kwd); -void gconf_gram_trace(int n); -void gconf_lex_trace (int n); - -int gconf_lex_begin(const char*); -void gconf_lex_end(void); -int gconf_parse (const char *name); - -void gconf_line_begin (void); -void gconf_line_add (const char *text, size_t len); -char *gconf_line_finish (void); - -extern int gconf_string_convert (void *target, enum gconf_data_type type, - const char *string); - -extern gconf_locus_t gconf_current_locus; -extern int gconf_error_count; -extern int gconf_default_port; - -extern const char *gconf_preprocessor; -extern bool gconf_log_to_stderr; -extern void (*gconf_log_setup_hook) (); - -size_t gconf_preproc_fill_buffer (char *buf, size_t size); -void gconf_preproc_add_include_dir (char *dir); -int gconf_preproc_init (const char *name); -void gconf_preproc_done (void); -int gconf_preproc_run (const char *config_file, const char *extpp); - -FILE *gconf_preproc_extrn_start (const char *file, pid_t *ppid); -void gconf_preproc_extrn_shutdown (pid_t pid); - -char *gconf_install_text (const char *str); -void gconf_destroy_text (void); - -void gconf_include_path_setup (const char *dir, ...); -void gconf_include_path_setup_v (char **dirs); - -const char *gconf_data_type_string (enum gconf_data_type type); -void gconf_format_docstring (FILE *stream, const char *docstring, - unsigned level); -void gconf_format_simple_statement (FILE *stream, struct gconf_keyword *kwp, - unsigned level); -void gconf_format_block_statement (FILE *stream, struct gconf_keyword *kwp, - unsigned level); -void gconf_format_statement_array (FILE *stream, struct gconf_keyword *kwp, - unsigned n, - unsigned level); - - - diff --git a/gconf/gnulib.modules b/gconf/gnulib.modules deleted file mode 100644 index 5ba9e5f..0000000 --- a/gconf/gnulib.modules +++ b/dev/null @@ -1,14 +0,0 @@ -# getdtablesize ?? -c-ctype -getline -hash -inttostr -inttypes -linked-list -obstack -regex -stdbool -strtoimax -strtoumax -vasprintf -xalloc diff --git a/gconf/wordsplit.c b/gconf/wordsplit.c deleted file mode 100644 index a5bb13e..0000000 --- a/gconf/wordsplit.c +++ b/dev/null @@ -1,568 +0,0 @@ -/* wordsplit - a word splitter - Copyright (C) 2009 Sergey Poznyakoff - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 3 of the License, or (at your - option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see <http://www.gnu.org/licenses/>. */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#include <ctype.h> -#include <c-ctype.h> -#include <errno.h> -#include <unistd.h> -#include <string.h> -#include <wordsplit.h> - -#include <error.h> -#include <gettext.h> -#define _(msgid) gettext (msgid) -#include <xalloc.h> - -#define isws(c) ((c)==' '||(c)=='\t'||(c)=='\n') -#define isdelim(c,delim) (strchr(delim,(c))!=NULL) - -#define _ARGCV_WORD_SED_EXPR 0x10000 -#define _ARGCV_WORD_MASK 0xf0000 - -#define ALLOC_INIT 128 -#define ALLOC_INCR 128 - -static int -wordsplit_init (struct wordsplit *wsp, const char *input, size_t len, - int flags) -{ - wsp->ws_flags = flags; - if ((wsp->ws_flags & (WRDSF_NOVAR|WRDSF_NOCMD)) - != (WRDSF_NOVAR|WRDSF_NOCMD)) - { - if (wsp->ws_flags & WRDSF_SHOWERR) - error (0, 0, - _("variable expansion and command substitution " - "are not yet supported")); - errno = EINVAL; - return 1; - } - - wsp->ws_input = input; - wsp->ws_len = len; - - if (!(wsp->ws_flags & WRDSF_DOOFFS)) - wsp->ws_offs = 0; - - if (!(wsp->ws_flags & WRDSF_DELIM)) - wsp->ws_delim = " "; - - if (!(wsp->ws_flags & WRDSF_COMMENT)) - wsp->ws_comment = NULL; - - if (wsp->ws_flags & WRDSF_REUSE) - { - wsp->ws_wordn = wsp->ws_wordc + 1; - if (wsp->ws_flags & WRDSF_DOOFFS) - wsp->ws_wordn += wsp->ws_offs; - if (!(wsp->ws_flags & WRDSF_APPEND)) - wsp->ws_wordc = 0; - } - else - { - wsp->ws_wordv = NULL; - wsp->ws_wordc = 0; - wsp->ws_wordn = 0; - } - - wsp->ws_endp = 0; - return 0; -} - -static int -alloc_space (struct wordsplit *wsp) -{ - size_t offs = (wsp->ws_flags & WRDSF_DOOFFS) ? wsp->ws_offs : 0; - char **ptr; - size_t newalloc; - - if (wsp->ws_wordv == NULL) - { - newalloc = offs + ALLOC_INIT; - ptr = calloc (newalloc, sizeof (ptr[0])); - } - else if (wsp->ws_wordn < offs + wsp->ws_wordc + 1) - { - newalloc = offs + wsp->ws_wordc + ALLOC_INCR; - ptr = realloc (wsp->ws_wordv, newalloc * sizeof (ptr[0])); - } - else - return 0; - - if (ptr) - { - wsp->ws_wordn = newalloc; - wsp->ws_wordv = ptr; - } - else - { - if (wsp->ws_flags & WRDSF_ENOMEMABRT) - xalloc_die (); - else if (wsp->ws_flags & WRDSF_SHOWERR) - error (0, 0, _("memory exhausted")); - errno = ENOMEM; - return 1; - } - return 0; -} - -static int -skip_sed_expr(const char *command, size_t i, size_t len) -{ - int state; - - do - { - int delim; - - if (command[i] == ';') - i++; - if (!(command[i] == 's' && i + 3 < len && c_ispunct(command[i+1]))) - break; - - delim = command[++i]; - state = 1; - for (i++; i < len; i++) - { - if (state == 3) - { - if (command[i] == delim || !c_isalnum(command[i])) - break; - } - else if (command[i] == '\\') - i++; - else if (command[i] == delim) - state++; - } - } - while (state == 3 && i < len && command[i] == ';'); - return i; -} - -static size_t -skip_delim (struct wordsplit *wsp) -{ - size_t start = wsp->ws_endp; - if (wsp->ws_flags & WRDSF_SQUEEZE_DELIMS) - { - do - start++; - while (start < wsp->ws_len - && isdelim (wsp->ws_input[start], wsp->ws_delim)); - start--; - } - - if (!(wsp->ws_flags & WRDSF_RETURN_DELIMS)) - start++; - - return start; -} - -#define _WRDS_WORD 1 -#define _WRDS_CONT 2 - -static int -scan_word (struct wordsplit *wsp, size_t *pstart, size_t *pend) -{ - size_t start = *pstart; - size_t len = wsp->ws_len; - const char *command = wsp->ws_input; - const char *delim = wsp->ws_delim; - const char *comment = wsp->ws_comment; - - size_t i = start; - - if (i >= len) - return WRDSE_EOF; - - if (wsp->ws_flags & WRDSF_WS) - { - /* Skip initial whitespace */ - while (i < len && isws (command[i])) - i++; - } - - start = i; - - wsp->ws_flags &= ~_ARGCV_WORD_MASK; - - if (wsp->ws_flags & WRDSF_SED_EXPR - && command[i] == 's' && i + 3 < len && c_ispunct (command[i+1])) - { - wsp->ws_flags |= _ARGCV_WORD_SED_EXPR; - i = skip_sed_expr (command, i, len); - } - else if (!isdelim (command[i], delim)) - { - while (i < len) - { - if (comment && strchr (comment, command[i]) != NULL) - { - size_t j; - for (j = i + 1; j < len && command[j] != '\n'; j++) - ; - *pstart = start; - *pend = i; - wsp->ws_endp = j; - return i > start ? _WRDS_WORD : _WRDS_CONT; - } - - if (wsp->ws_flags & WRDSF_QUOTE) - { - if (command[i] == '\\') - { - if (++i == len) - break; - i++; - continue; - } - - if (command[i] == '\'' || command[i] == '"') - { - size_t j; - for (j = i + 1; j < len && command[j] != command[i]; j++) - if (command[j] == '\\') - j++; - if (j < len && command[j] == command[i]) - i = j + 1; - else - { - wsp->ws_endp = i; - if (wsp->ws_flags & WRDSF_SHOWERR) - error (0, 0, - _("missing closing %c (start near #%lu)"), - command[i], (unsigned long) i); - return WRDSE_QUOTE; - } - } - } - - if (((wsp->ws_flags & WRDSF_WS) && isws (command[i])) - || isdelim (command[i], delim)) - break; - else - i++; - } - } - else if (wsp->ws_flags & WRDSF_RETURN_DELIMS) - i++; - - *pstart = start; - *pend = i; - wsp->ws_endp = i; - - return _WRDS_WORD; -} - -static char quote_transtab[] = "\\\\a\ab\bf\fn\nr\rt\tv\v"; - -int -wordsplit_unquote_char (int c) -{ - char *p; - - for (p = quote_transtab; *p; p += 2) - { - if (*p == c) - return p[1]; - } - return c; -} - -int -wordsplit_quote_char (int c) -{ - char *p; - - for (p = quote_transtab + sizeof(quote_transtab) - 2; - p > quote_transtab; p -= 2) - { - if (*p == c) - return p[-1]; - } - return -1; -} - -#define to_num(c) \ - (isdigit(c) ? c - '0' : (isxdigit(c) ? toupper(c) - 'A' + 10 : 255 )) - -static int -xtonum (int *pval, const char *src, int base, int cnt) -{ - int i, val; - - for (i = 0, val = 0; i < cnt; i++, src++) - { - int n = *(unsigned char*)src; - if (n > 127 || (n = to_num(n)) >= base) - break; - val = val*base + n; - } - *pval = val; - return i; -} - -size_t -wordsplit_quoted_length (const char *str, int quote_hex, int *quote) -{ - size_t len = 0; - - *quote = 0; - for (; *str; str++) - { - if (*str == ' ') - { - len++; - *quote = 1; - } - else if (*str == '"') - { - len += 2; - *quote = 1; - } - else if (*str != '\t' && *str != '\\' && isprint (*str)) - len++; - else if (quote_hex) - len += 3; - else - { - if (wordsplit_quote_char (*str) != -1) - len += 2; - else - len += 4; - } - } - return len; -} - -void -wordsplit_unquote_copy (char *dst, const char *src, size_t n) -{ - int i = 0; - int c; - int expect_delim = 0; - - while (i < n) - { - switch (src[i]) - { - case '\'': - case '"': - if (!expect_delim) - { - const char *p; - - for (p = src+i+1; *p && *p != src[i]; p++) - if (*p == '\\') - p++; - if (*p) - expect_delim = src[i++]; - else - *dst++ = src[i++]; - } - else if (expect_delim == src[i]) - ++i; - else - *dst++ = src[i++]; - break; - - case '\\': - ++i; - if (src[i] == 'x' || src[i] == 'X') - { - if (n - i < 2) - { - *dst++ = '\\'; - *dst++ = src[i++]; - } - else - { - int off = xtonum(&c, src + i + 1, 16, 2); - if (off == 0) - { - *dst++ = '\\'; - *dst++ = src[i++]; - } - else - { - *dst++ = c; - i += off + 1; - } - } - } - else if ((unsigned char)src[i] < 128 && isdigit (src[i])) - { - if (n - i < 1) - { - *dst++ = '\\'; - *dst++ = src[i++]; - } - else - { - int off = xtonum (&c, src+i, 8, 3); - if (off == 0) - { - *dst++ = '\\'; - *dst++ = src[i++]; - } - else - { - *dst++ = c; - i += off; - } - } - } - else - *dst++ = wordsplit_unquote_char (src[i++]); - break; - - default: - *dst++ = src[i++]; - } - } - *dst = 0; -} - -void -wordsplit_quote_copy (char *dst, const char *src, int quote_hex) -{ - for (; *src; src++) - { - if (*src == '"') - { - *dst++ = '\\'; - *dst++ = *src; - } - else if (*src != '\t' && *src != '\\' && isprint (*src)) - *dst++ = *src; - else - { - char tmp[4]; - - if (quote_hex) - { - snprintf (tmp, sizeof tmp, "%%%02X", *(unsigned char*)src); - memcpy (dst, tmp, 3); - dst += 3; - } - else - { - int c = wordsplit_quote_char (*src); - *dst++ = '\\'; - if (c != -1) - *dst++ = c; - else - { - snprintf (tmp, sizeof tmp, "%03o", *(unsigned char*)src); - memcpy (dst, tmp, 3); - dst += 3; - } - } - } - } -} - -int -wordsplit_len (const char *command, size_t len, struct wordsplit *wsp, - int flags) -{ - int rc; - size_t start = 0, end = 0; - - rc = wordsplit_init (wsp, command, len, flags); - if (rc) - return rc; - - for (; (rc = scan_word (wsp, &start, &end)) > 0; start = skip_delim (wsp)) - { - int unquote = 1; - size_t n; - char *p; - - if (rc == _WRDS_CONT) - continue; - - if (alloc_space (wsp)) - return WRDSE_NOSPACE; - - n = end - start; - - if (wsp->ws_flags & WRDSF_QUOTE && - !(wsp->ws_flags & _ARGCV_WORD_SED_EXPR)) - { - if (start < end - && (command[start] == '"' || command[start] == '\'') - && command[end-1] == command[start]) - { - unquote = command[start] == '"'; - start++; - n -= 2; - } - } - else - unquote = 0; - - p = malloc (n + 1); - if (!p) - { - if (wsp->ws_flags & WRDSF_ENOMEMABRT) - xalloc_die (); - if (wsp->ws_flags & WRDSF_SHOWERR) - error (0, 0, _("memory exhausted")); - if (!(wsp->ws_flags & WRDSF_REUSE)) - wordsplit_free (wsp); - errno = ENOMEM; - return WRDSE_NOSPACE; - } - - if (unquote) - wordsplit_unquote_copy (p, &command[start], n); - else - { - memcpy (p, &command[start], n); - p[n] = 0; - } - wsp->ws_wordv[wsp->ws_offs + wsp->ws_wordc] = p; - wsp->ws_wordc++; - - ; - } - if (alloc_space (wsp)) - return WRDSE_NOSPACE; - wsp->ws_wordv[wsp->ws_offs + wsp->ws_wordc] = NULL; - /* FIXME: if (rc) free(ws) */ - return rc; -} - -int -wordsplit (const char *command, struct wordsplit *ws, int flags) -{ - return wordsplit_len (command, strlen (command), ws, flags); -} - -void -wordsplit_free (struct wordsplit *ws) -{ - free (ws->ws_wordv); - ws->ws_wordv = NULL; -} - - - diff --git a/gconf/wordsplit.h b/gconf/wordsplit.h deleted file mode 100644 index d4d1f0c..0000000 --- a/gconf/wordsplit.h +++ b/dev/null @@ -1,88 +0,0 @@ -/* wordsplit - a word splitter - Copyright (C) 2009 Sergey Poznyakoff - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 3 of the License, or (at your - option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program. If not, see <http://www.gnu.org/licenses/>. */ - -struct wordsplit -{ - size_t ws_wordc; - char **ws_wordv; - size_t ws_offs; - size_t ws_wordn; - int ws_flags; - const char *ws_delim; - const char *ws_comment; - - const char *ws_input; - size_t ws_len; - size_t ws_endp; -}; - -/* Append the words found to the array resulting from a previous - call. */ -#define WRDSF_APPEND 0x0001 -/* Insert we_offs initial NULLs in the array ws_wordv. - (These are not counted in the returned ws_wordc.) */ -#define WRDSF_DOOFFS 0x0002 -/* Don't do command substitution. Reserved for future use. */ -#define WRDSF_NOCMD 0x0004 -/* The parameter p resulted from a previous call to - wordsplit(), and wordsplit_free() was not called. Reuse the - allocated storage. */ -#define WRDSF_REUSE 0x0008 -/* Print errors */ -#define WRDSF_SHOWERR 0x0010 -/* Consider it an error if an undefined shell variable - is expanded. */ -#define WRDSF_UNDEF 0x0020 - -/* Don't do variable expansion. Reserved for future use. */ -#define WRDSF_NOVAR 0x0040 -/* Abort on ENOMEM error */ -#define WRDSF_ENOMEMABRT 0x0080 -/* Treat whitespace as delimiters */ -#define WRDSF_WS 0x0100 -/* Handle quotes and escape directives */ -#define WRDSF_QUOTE 0x0200 -/* Replace each input sequence of repeated delimiters with a single - delimiter */ -#define WRDSF_SQUEEZE_DELIMS 0x0400 -/* Return delimiters */ -#define WRDSF_RETURN_DELIMS 0x0800 -/* Treat sed expressions as words */ -#define WRDSF_SED_EXPR 0x1000 -/* ws_delim field is initialized */ -#define WRDSF_DELIM 0x2000 -/* ws_comment field is initialized */ -#define WRDSF_COMMENT 0x4000 - -#define WRDSF_DEFFLAGS \ - (WRDSF_NOVAR | WRDSF_NOCMD | \ - WRDSF_WS | WRDSF_QUOTE | WRDSF_SQUEEZE_DELIMS) - -#define WRDSE_EOF 0 -#define WRDSE_QUOTE 1 -#define WRDSE_NOSPACE 2 - -int wordsplit (const char *s, struct wordsplit *p, int flags); -void wordsplit_free (struct wordsplit *p); - -int wordsplit_unquote_char (int c); -int wordsplit_quote_char (int c); -size_t wordsplit_quoted_length (const char *str, int quote_hex, int *quote); -void wordsplit_unquote_copy (char *dst, const char *src, size_t n); -void wordsplit_quote_copy (char *dst, const char *src, int quote_hex); - - - diff --git a/grecs b/grecs new file mode 160000 +Subproject b6a8ef19274af628364f90a992c146c3123e67d diff --git a/src/Makefile.am b/src/Makefile.am index 993ce0d..c96fbcb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -58,8 +58,8 @@ SUFFIXES=.opt .c .h incdir=$(pkgdatadir)/$(VERSION)/include inc_DATA = $(PP_SETUP_FILE) -LDADD=../gconf/libgconf.a ../gnu/libgnu.a @SQLLIB@ @GPGMELIB@ @MAILUTILS_LIBS@ -INCLUDES = -I$(top_srcdir)/gconf -I$(top_srcdir)/gnu -I../gnu @MAILUTILS_INCLUDES@ +LDADD=../grecs/src/libgrecs.a ../gnu/libgnu.a @SQLLIB@ @GPGMELIB@ @MAILUTILS_LIBS@ +INCLUDES = -I$(top_srcdir)/grecs/src/ -I$(top_srcdir)/gnu -I../gnu @MAILUTILS_INCLUDES@ AM_CPPFLAGS= \ -DSYSCONFDIR=\"$(sysconfdir)\"\ -DLOCALSTATEDIR=\"$(localstatedir)\"\ diff --git a/src/cmdline.opt b/src/cmdline.opt index fd87e5e..3515072 100644 --- a/src/cmdline.opt +++ b/src/cmdline.opt @@ -133,7 +133,7 @@ GROUP(Preprocessor control) OPTION(include-directory,I,DIR, [<add include directory>]) BEGIN - gconf_preproc_add_include_dir (optarg); + grecs_preproc_add_include_dir (optarg); END OPTION(define,D,SYMBOL[=VALUE], @@ -159,13 +159,13 @@ END OPTION(preprocessor,,COMMAND, [<use COMMAND instead of the default preprocessor>]) BEGIN - gconf_preprocessor = optarg; + grecs_preprocessor = optarg; END OPTION(no-preprocessor,,, [<disable preprocessing>]) BEGIN - gconf_preprocessor = NULL; + grecs_preprocessor = NULL; END GROUP(Debugging) @@ -179,13 +179,13 @@ END OPTION(dump-grammar-trace,,, [<dump configuration grammar traces>]) BEGIN - gconf_gram_trace (1); + grecs_gram_trace (1); END OPTION(dump-lex-trace,,, [<dump lexical analyzer traces>]) BEGIN - gconf_lex_trace (1); + grecs_lex_trace (1); END GROUP([<Additional help>]) @@ -202,13 +202,13 @@ void parse_options(int argc, char *argv[]) { GETOPT(argc, argv) - if (pp_cmd_stack_init && gconf_preprocessor) + if (pp_cmd_stack_init && grecs_preprocessor) { char *defs = obstack_finish (&pp_cmd_stack); - char *cmd = xmalloc (strlen (gconf_preprocessor) + strlen (defs) + 1); - strcpy (cmd, gconf_preprocessor); + char *cmd = xmalloc (strlen (grecs_preprocessor) + strlen (defs) + 1); + strcpy (cmd, grecs_preprocessor); strcat (cmd, defs); - gconf_preprocessor = cmd; + grecs_preprocessor = cmd; obstack_free (&pp_cmd_stack, NULL); } } diff --git a/src/config.c b/src/config.c index 11ac92d..60b5792 100644 --- a/src/config.c +++ b/src/config.c @@ -127,18 +127,18 @@ int string_to (const char *what, const char *str, const char **args, int *vals, int *pret, - gconf_locus_t *locus) + grecs_locus_t *locus) { ptrdiff_t x = ARGMATCH (str, args, vals); if (x == (ptrdiff_t)-1) { - gconf_error (locus, 0, _("unknown %s: %s"), what, str); + grecs_error (locus, 0, _("unknown %s: %s"), what, str); return 1; } else if (x == (ptrdiff_t)-2) { - gconf_error (locus, 0, _("ambiguous %s: %s"), what, str); + grecs_error (locus, 0, _("ambiguous %s: %s"), what, str); return 1; } *pret = vals[x]; @@ -169,7 +169,7 @@ notification_event_str (enum notification_event evt) } int -string_to_notification_event (gconf_locus_t *locus, const char *val, +string_to_notification_event (grecs_locus_t *locus, const char *val, enum notification_event *pret) { int rc, res; @@ -203,7 +203,7 @@ notification_target_str (enum notification_target tgt) } int -string_to_notification_target (gconf_locus_t *locus, const char *val, +string_to_notification_target (grecs_locus_t *locus, const char *val, enum notification_target *pret) { int rc, res; @@ -217,35 +217,35 @@ string_to_notification_target (gconf_locus_t *locus, const char *val, int -assert_string_arg (gconf_locus_t *locus, - enum gconf_callback_command cmd, - const gconf_value_t *value) +assert_string_arg (grecs_locus_t *locus, + enum grecs_callback_command cmd, + const grecs_value_t *value) { - if (cmd != gconf_callback_set_value) + if (cmd != grecs_callback_set_value) { - gconf_error (locus, 0, _("Unexpected block statement")); + grecs_error (locus, 0, _("Unexpected block statement")); return 1; } if (!value || value->type != GCONF_TYPE_STRING) { - gconf_error (locus, 0, _("expected scalar value as a tag")); + grecs_error (locus, 0, _("expected scalar value as a tag")); return 1; } return 0; } -gconf_value_t * -get_arg (gconf_locus_t *locus, gconf_value_t *value, unsigned n, int type) +grecs_value_t * +get_arg (grecs_locus_t *locus, grecs_value_t *value, unsigned n, int type) { if (n >= value->v.arg.c) { - gconf_error (locus, 0, _("not enough arguments")); + grecs_error (locus, 0, _("not enough arguments")); return NULL; } value = value->v.arg.v + n; if (value->type != type) { - gconf_error (locus, 0, _("argument %d has wrong type"), n); + grecs_error (locus, 0, _("argument %d has wrong type"), n); return NULL; } return value; @@ -253,10 +253,10 @@ get_arg (gconf_locus_t *locus, gconf_value_t *value, unsigned n, int type) static int -cb_mailer (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_mailer (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { int rc; @@ -265,16 +265,16 @@ cb_mailer (enum gconf_callback_command cmd, return 1; rc = mu_mailer_create (&mailer, value->v.string); if (rc) - gconf_error (locus, 0, _("cannot create mailer `%s': %s"), + grecs_error (locus, 0, _("cannot create mailer `%s': %s"), value->v.string, mu_strerror (rc)); return rc; } static int -cb_email_address (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_email_address (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { int rc; @@ -286,7 +286,7 @@ cb_email_address (enum gconf_callback_command cmd, rc = mu_address_create (&addr, value->v.string); if (rc) { - gconf_error (locus, 0, _("%s: invalid email address: %s"), + grecs_error (locus, 0, _("%s: invalid email address: %s"), value->v.string, mu_strerror (rc)); return rc; } @@ -299,7 +299,7 @@ cb_email_address (enum gconf_callback_command cmd, while (gl_list_iterator_next (&itr, &p, NULL)) { - const gconf_value_t *vp = p; + const grecs_value_t *vp = p; mu_address_t a; if (assert_string_arg (locus, cmd, vp)) return 1; @@ -309,7 +309,7 @@ cb_email_address (enum gconf_callback_command cmd, rc = mu_address_union (&addr, a); else { - gconf_error (locus, 0, _("%s: invalid email address: %s"), + grecs_error (locus, 0, _("%s: invalid email address: %s"), vp->v.string, mu_strerror (rc)); } mu_address_destroy (&a); @@ -320,7 +320,7 @@ cb_email_address (enum gconf_callback_command cmd, break; case GCONF_TYPE_ARRAY: - gconf_error (locus, 0, _("too many arguments")); + grecs_error (locus, 0, _("too many arguments")); return 1; } @@ -329,10 +329,10 @@ cb_email_address (enum gconf_callback_command cmd, } static int -cb_interval (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_interval (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { int rc; @@ -346,7 +346,7 @@ cb_interval (enum gconf_callback_command cmd, /* FIXME 2: Support ISO intervals? */ rc = parse_time_interval (value->v.string, &interval, &endp); if (rc) - gconf_error (locus, 0, _("unrecognized interval format (near `%s')"), + grecs_error (locus, 0, _("unrecognized interval format (near `%s')"), endp); else *(time_t*) varptr = interval; @@ -354,10 +354,10 @@ cb_interval (enum gconf_callback_command cmd, } static int -cb_absolute_name (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_absolute_name (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { char *word; @@ -368,17 +368,17 @@ cb_absolute_name (enum gconf_callback_command cmd, word = safe_file_name ((char*)value->v.string); if (!word || word[0] != '/') - gconf_error (locus, 0, _("must be an absolute file name")); + grecs_error (locus, 0, _("must be an absolute file name")); else *(char**) varptr = word; return 0; } static int -cb_set_umask (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_set_umask (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { char *p; @@ -388,7 +388,7 @@ cb_set_umask (enum gconf_callback_command cmd, return 1; m = strtoul (value->v.string, &p, 8) & 0777; if (*p) - gconf_error (locus, 0, _("invalid umask (near %s)"), p); + grecs_error (locus, 0, _("invalid umask (near %s)"), p); else umask (m); return 0; @@ -431,7 +431,7 @@ static unsigned long stat_types[] = { ARGMATCH_VERIFY (stat_args, stat_types); static int -parse_single_statmask (gconf_locus_t *locus, const gconf_value_t *val, +parse_single_statmask (grecs_locus_t *locus, const grecs_value_t *val, unsigned long *pmask, int *invert) { const char *arg; @@ -439,7 +439,7 @@ parse_single_statmask (gconf_locus_t *locus, const gconf_value_t *val, if (val->type != GCONF_TYPE_STRING) { - gconf_error (locus, 0, _("expected scalar value but found list")); + grecs_error (locus, 0, _("expected scalar value but found list")); return 1; } @@ -462,12 +462,12 @@ parse_single_statmask (gconf_locus_t *locus, const gconf_value_t *val, if (x == (ptrdiff_t)-1) { - gconf_error (locus, 0, _("unknown statistics type: %s"), arg); + grecs_error (locus, 0, _("unknown statistics type: %s"), arg); return 1; } else if (x == (ptrdiff_t)-2) { - gconf_error (locus, 0, _("ambiguous statistics type: %s"), arg); + grecs_error (locus, 0, _("ambiguous statistics type: %s"), arg); return 1; } *pmask = STAT_MASK (stat_types[x]); @@ -475,7 +475,7 @@ parse_single_statmask (gconf_locus_t *locus, const gconf_value_t *val, } static int -parse_statmask (gconf_locus_t *loc, gconf_value_t *val, unsigned long *pmask) +parse_statmask (grecs_locus_t *loc, grecs_value_t *val, unsigned long *pmask) { int err = 0; int invert = 0; @@ -511,7 +511,7 @@ parse_statmask (gconf_locus_t *loc, gconf_value_t *val, unsigned long *pmask) while (gl_list_iterator_next (&itr, &p, NULL)) { - const gconf_value_t *vp = p; + const grecs_value_t *vp = p; unsigned long x; if (parse_single_statmask (loc, vp, &x, &invert)) @@ -530,10 +530,10 @@ parse_statmask (gconf_locus_t *loc, gconf_value_t *val, unsigned long *pmask) } static int -cb_statistics (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_statistics (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { return parse_statmask (locus, value, varptr); @@ -541,10 +541,10 @@ cb_statistics (enum gconf_callback_command cmd, static int -cb_sql_host (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_sql_host (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { struct sqlconn *pconn = varptr; @@ -569,12 +569,12 @@ cb_sql_host (enum gconf_callback_command cmd, unsigned long n = strtoul (p, &end, 10); if (*end) { - gconf_error (locus, 0, _("invalid port number (near %s)"), end); + grecs_error (locus, 0, _("invalid port number (near %s)"), end); return 0; } if (n == 0 || n > USHRT_MAX) { - gconf_error (locus, 0, _("port number out of range 1..%d"), + grecs_error (locus, 0, _("port number out of range 1..%d"), USHRT_MAX); return 0; } @@ -589,20 +589,20 @@ cb_sql_host (enum gconf_callback_command cmd, } static int -cb_sql (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_sql (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { struct sqlconn *pconn; void **pdata = cb_data; switch (cmd) { - case gconf_callback_section_begin: + case grecs_callback_section_begin: if (!value || value->type != GCONF_TYPE_STRING) { - gconf_error(locus, 0, _("tag must be a string")); + grecs_error(locus, 0, _("tag must be a string")); return 0; } pconn = xzalloc (sizeof (*pconn)); @@ -610,79 +610,79 @@ cb_sql (enum gconf_callback_command cmd, *pdata = pconn; break; - case gconf_callback_section_end: + case grecs_callback_section_end: pconn = *pdata; sql_register_conn (pconn); free (pconn); *pdata = NULL; break; - case gconf_callback_set_value: - gconf_error (locus, 0, _("invalid use of block statement")); + case grecs_callback_set_value: + grecs_error (locus, 0, _("invalid use of block statement")); } return 0; } -static struct gconf_keyword sql_kw[] = { +static struct grecs_keyword sql_kw[] = { { "host", N_("host"), N_("Set SQL server hostname or IP address"), - gconf_type_string, NULL, 0, cb_sql_host }, + grecs_type_string, NULL, 0, cb_sql_host }, { "database", N_("dbname"), N_("Set database name"), - gconf_type_string, NULL, offsetof(struct sqlconn, database), }, + grecs_type_string, NULL, offsetof(struct sqlconn, database), }, { "user", N_("name"), N_("Set SQL user name"), - gconf_type_string, NULL, offsetof(struct sqlconn, user) }, + grecs_type_string, NULL, offsetof(struct sqlconn, user) }, { "password", N_("arg"), N_("Set SQL user password"), - gconf_type_string, NULL, offsetof(struct sqlconn, password) }, + grecs_type_string, NULL, offsetof(struct sqlconn, password) }, { NULL } }; static int -cb_syslog_facility (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_syslog_facility (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { if (assert_string_arg (locus, cmd, value)) return 1; if (mu_string_to_syslog_facility (value->v.string, varptr)) - gconf_error (locus, 0, _("Unknown syslog facility `%s'"), + grecs_error (locus, 0, _("Unknown syslog facility `%s'"), value->v.string); return 0; } static int -cb_define_message (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_define_message (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { const char *ident; - if (cmd != gconf_callback_set_value) + if (cmd != grecs_callback_set_value) { - gconf_error (locus, 0, _("Unexpected block statement")); + grecs_error (locus, 0, _("Unexpected block statement")); return 1; } if (!value || value->type != GCONF_TYPE_ARRAY || value->v.arg.c != 2) { - gconf_error (locus, 0, _("expected two arguments")); + grecs_error (locus, 0, _("expected two arguments")); return 1; } if (value->v.arg.v[0].type != GCONF_TYPE_STRING) { - gconf_error (locus, 0, _("first argument not a string")); + grecs_error (locus, 0, _("first argument not a string")); return 1; } ident = value->v.arg.v[0].v.string; if (value->v.arg.v[1].type != GCONF_TYPE_STRING) { - gconf_error (locus, 0, _("second argument not a string")); + grecs_error (locus, 0, _("second argument not a string")); return 1; } @@ -692,17 +692,17 @@ cb_define_message (enum gconf_callback_command cmd, -static struct gconf_keyword syslog_kw[] = { +static struct grecs_keyword syslog_kw[] = { { "facility", N_("name"), N_("Set syslog facility. Arg is one of the following: user, daemon, " "auth, authpriv, mail, cron, local0 through local7 (case-insensitive), " "or a facility number."), - gconf_type_string, &log_facility, 0, cb_syslog_facility }, + grecs_type_string, &log_facility, 0, cb_syslog_facility }, { "tag", N_("string"), N_("Tag syslog messages with this string"), - gconf_type_string, &syslog_tag }, + grecs_type_string, &syslog_tag }, { "print-priority", N_("arg"), N_("Prefix each message with its priority"), - gconf_type_bool, &syslog_include_prio }, + grecs_type_bool, &syslog_include_prio }, { NULL }, }; @@ -731,7 +731,7 @@ static const enum backup_type backup_types[] = ARGMATCH_VERIFY (backup_args, backup_types); static enum backup_type -get_backup_version (gconf_locus_t *locus, const char *ctx, +get_backup_version (grecs_locus_t *locus, const char *ctx, const char *version) { if (version == 0 || *version == 0) @@ -742,19 +742,19 @@ get_backup_version (gconf_locus_t *locus, const char *ctx, if (d == -2) { if (ctx) - gconf_error (locus, 0, _("%s: ambiguous backup type `%s'"), + grecs_error (locus, 0, _("%s: ambiguous backup type `%s'"), ctx, version); else - gconf_error (locus, 0, _("ambiguous backup type `%s'"), version); + grecs_error (locus, 0, _("ambiguous backup type `%s'"), version); return no_backups; } else if (d == -1) { if (ctx) - gconf_error (locus, 0, _("%s: invalid backup type `%s'"), + grecs_error (locus, 0, _("%s: invalid backup type `%s'"), ctx, version); else - gconf_error (locus, 0, _("invalid backup type `%s'"), version); + grecs_error (locus, 0, _("invalid backup type `%s'"), version); return no_backups; } return backup_types[d]; @@ -762,10 +762,10 @@ get_backup_version (gconf_locus_t *locus, const char *ctx, } static int -cb_backup (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_backup (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { enum backup_type *ptype = varptr; @@ -776,20 +776,20 @@ cb_backup (enum gconf_callback_command cmd, return 0; } -static struct gconf_keyword archive_kw[] = { +static struct grecs_keyword archive_kw[] = { { "name", N_("file-or-dir"), N_("Name of archive file or directory"), - gconf_type_string, NULL, offsetof(struct archive_descr, name) }, + grecs_type_string, NULL, offsetof(struct archive_descr, name) }, { "backup", N_("type"), N_("Define backup type"), - gconf_type_string, NULL, offsetof(struct archive_descr, backup_type), + grecs_type_string, NULL, offsetof(struct archive_descr, backup_type), cb_backup }, { NULL } }; static int -cb_archive (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_archive (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { struct archive_descr *arch = varptr; @@ -797,19 +797,19 @@ cb_archive (enum gconf_callback_command cmd, switch (cmd) { - case gconf_callback_section_begin: + case grecs_callback_section_begin: *pdata = arch; /* fallthrough */ - case gconf_callback_set_value: + case grecs_callback_set_value: if (!value) { - gconf_error (locus, 0, _("expected tag")); + grecs_error (locus, 0, _("expected tag")); return 1; } if (value->type != GCONF_TYPE_STRING) { - gconf_error (locus, 0, _("expected scalar value but found list")); + grecs_error (locus, 0, _("expected scalar value but found list")); return 1; } @@ -821,14 +821,14 @@ cb_archive (enum gconf_callback_command cmd, arch->type = archive_directory; else { - gconf_error (locus, 0, _("unknown archive type")); + grecs_error (locus, 0, _("unknown archive type")); return 1; } - if (cmd == gconf_callback_section_begin) + if (cmd == grecs_callback_section_begin) return 0; break; - case gconf_callback_section_end: + case grecs_callback_section_end: break; } @@ -837,13 +837,13 @@ cb_archive (enum gconf_callback_command cmd, if (arch->name == NULL) { - gconf_error (locus, 0, _("at least archive name must be set")); + grecs_error (locus, 0, _("at least archive name must be set")); return 1; } if (arch->type == archive_tar && arch->backup_type != no_backups) { - gconf_warning (locus, 0, _("backup type ignored for this archive type")); + grecs_warning (locus, 0, _("backup type ignored for this archive type")); return 1; } @@ -851,22 +851,22 @@ cb_archive (enum gconf_callback_command cmd, } -static struct gconf_keyword mail_statistics_kw[] = { +static struct grecs_keyword mail_statistics_kw[] = { { "message", N_("text"), N_("Message text"), - gconf_type_string, &admin_stat_message }, + grecs_type_string, &admin_stat_message }, { "statistics", N_("items"), N_("Send mail if one or more of these items are set"), - gconf_type_string, &mail_admin_mask, 0, cb_statistics }, + grecs_type_string, &mail_admin_mask, 0, cb_statistics }, { NULL } }; static int -cb_event (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_event (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { enum notification_event *pev = varptr; @@ -878,10 +878,10 @@ cb_event (enum gconf_callback_command cmd, } static int -cb_recipient (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_recipient (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { enum notification_target *tgt = varptr; @@ -892,38 +892,38 @@ cb_recipient (enum gconf_callback_command cmd, return 0; } -static struct gconf_keyword notify_event_kw[] = { +static struct grecs_keyword notify_event_kw[] = { { "event", N_("ev-id"), N_("Event on which to notify"), - gconf_type_string, NULL, offsetof(struct notification, ev), cb_event }, + grecs_type_string, NULL, offsetof(struct notification, ev), cb_event }, { "recipient", N_("who"), N_("Notify this recipient"), - gconf_type_string, NULL, offsetof(struct notification, tgt), + grecs_type_string, NULL, offsetof(struct notification, tgt), cb_recipient }, { "message", N_("text-or-id"), N_("Text of the notification or identifier of a defined message template"), - gconf_type_string, NULL, offsetof(struct notification, msg) }, + grecs_type_string, NULL, offsetof(struct notification, msg) }, { NULL } }; static int -cb_notify_event (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_notify_event (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { struct notification *ntf; void **pdata = cb_data; switch (cmd) { - case gconf_callback_section_begin: + case grecs_callback_section_begin: ntf = xzalloc (sizeof (*ntf)); *pdata = ntf; break; - case gconf_callback_section_end: + case grecs_callback_section_end: ntf = *pdata; if (!ntf->msg) - gconf_error (locus, 0, _("missing message definition")); + grecs_error (locus, 0, _("missing message definition")); else { struct notification **p = (struct notification **) varptr; @@ -933,8 +933,8 @@ cb_notify_event (enum gconf_callback_command cmd, } break; - case gconf_callback_set_value: - gconf_error (locus, 0, _("invalid use of block statement")); + case grecs_callback_set_value: + grecs_error (locus, 0, _("invalid use of block statement")); } return 0; } @@ -955,10 +955,10 @@ string_to_access_method_type (const char *str) } static int -cb_access_method_type (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_access_method_type (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { enum access_method_type *ptype = varptr; @@ -967,28 +967,28 @@ cb_access_method_type (enum gconf_callback_command cmd, return 1; *ptype = string_to_access_method_type (value->v.string); if (*ptype == method_none) - gconf_error (locus, 0, _("unknown access method: %s"), value->v.string); + grecs_error (locus, 0, _("unknown access method: %s"), value->v.string); return 0; } static int -cb_access_method_params (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_access_method_params (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { struct access_method *meth = varptr; size_t size; - if (cmd != gconf_callback_set_value) + if (cmd != grecs_callback_set_value) { - gconf_error (locus, 0, _("Unexpected block statement")); + grecs_error (locus, 0, _("Unexpected block statement")); return 1; } if (!value || value->type != GCONF_TYPE_LIST) { - gconf_error (locus, 0, _("expected list value")); + grecs_error (locus, 0, _("expected list value")); return 1; } @@ -1009,7 +1009,7 @@ cb_access_method_params (enum gconf_callback_command cmd, for (i = 0; gl_list_iterator_next (&itr, &p, NULL); i++) { - const gconf_value_t *vp = p; + const grecs_value_t *vp = p; if (assert_string_arg (locus, cmd, vp)) break; @@ -1022,20 +1022,20 @@ cb_access_method_params (enum gconf_callback_command cmd, return 0; } -static struct gconf_keyword access_method_kw[] = { +static struct grecs_keyword access_method_kw[] = { { "type", N_("type"), N_("Method type"), - gconf_type_string, NULL, offsetof(struct access_method, type), + grecs_type_string, NULL, offsetof(struct access_method, type), cb_access_method_type }, { "query", N_("string"), N_("Query template"), - gconf_type_string, NULL, offsetof(struct access_method, query) }, + grecs_type_string, NULL, offsetof(struct access_method, query) }, { "params", N_("arg"), N_("Set method parameters"), - gconf_type_string|GCONF_LIST, NULL, 0, + grecs_type_string|GCONF_LIST, NULL, 0, cb_access_method_params }, { NULL } }; int -string_to_access_method_id (gconf_locus_t *locus, +string_to_access_method_id (grecs_locus_t *locus, const char *str, enum access_method_id *idp) { static const char *id_str[] = { @@ -1063,10 +1063,10 @@ string_to_access_method_id (gconf_locus_t *locus, } static int -cb_access_method (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_access_method (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { struct access_method **pmeth, *meth; @@ -1074,10 +1074,10 @@ cb_access_method (enum gconf_callback_command cmd, enum access_method_id id; switch (cmd) { - case gconf_callback_section_begin: + case grecs_callback_section_begin: if (!value || value->type != GCONF_TYPE_STRING) { - gconf_error(locus, 0, _("tag must be a string")); + grecs_error(locus, 0, _("tag must be a string")); return 0; } if (string_to_access_method_id (locus, value->v.string, &id)) @@ -1087,19 +1087,19 @@ cb_access_method (enum gconf_callback_command cmd, *pdata = *pmeth; break; - case gconf_callback_section_end: + case grecs_callback_section_end: meth = *pdata; switch (meth->type) { case method_sql: if (meth->parmc == 0 || !meth->parmv[0]) { - gconf_error (locus, 0, _("SQL connection is not declared")); + grecs_error (locus, 0, _("SQL connection is not declared")); meth->type = method_none; } else if (!sql_connection_exists_p (meth->parmv[0])) { - gconf_error (locus, 0, _("SQL connection `%s' not declared"), + grecs_error (locus, 0, _("SQL connection `%s' not declared"), meth->parmv[0]); meth->type = method_none; } @@ -1112,17 +1112,17 @@ cb_access_method (enum gconf_callback_command cmd, *pdata = NULL; break; - case gconf_callback_set_value: - gconf_error (locus, 0, _("invalid use of block statement")); + case grecs_callback_set_value: + grecs_error (locus, 0, _("invalid use of block statement")); } return 0; } static int -cb_url (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_url (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { mu_url_t *purl = varptr, url; @@ -1133,14 +1133,14 @@ cb_url (enum gconf_callback_command cmd, rc = mu_url_create (&url, value->v.string); if (rc) { - gconf_error (locus, 0, _("cannot create URL `%s': %s"), + grecs_error (locus, 0, _("cannot create URL `%s': %s"), value->v.string, mu_strerror (rc)); return rc; } rc = mu_url_parse (url); if (rc) { - gconf_error (locus, 0, _("cannot parse URL `%s': %s"), + grecs_error (locus, 0, _("cannot parse URL `%s': %s"), value->v.string, mu_strerror (rc)); mu_url_destroy (&url); return rc; @@ -1150,39 +1150,39 @@ cb_url (enum gconf_callback_command cmd, } -static struct gconf_keyword spool_kw[] = { +static struct grecs_keyword spool_kw[] = { { "url", N_("arg"), N_("URL corresponding to this spool"), - gconf_type_string, NULL, offsetof(struct spool, url) }, + grecs_type_string, NULL, offsetof(struct spool, url) }, { "alias", N_("arg"), N_("Aliases"), - gconf_type_string|GCONF_LIST, NULL, offsetof(struct spool, aliases) }, + grecs_type_string|GCONF_LIST, NULL, offsetof(struct spool, aliases) }, { "source", N_("dir"), N_("Source directory"), - gconf_type_string, NULL, offsetof(struct spool, source_dir) }, + grecs_type_string, NULL, offsetof(struct spool, source_dir) }, { "destination", N_("dir"), N_("Destination directory"), - gconf_type_string, NULL, offsetof(struct spool, dest_url), + grecs_type_string, NULL, offsetof(struct spool, dest_url), cb_url }, { "file-sweep-time", N_("interval"), N_("Define file sweep time"), - gconf_type_string, NULL, offsetof(struct spool, file_sweep_time), + grecs_type_string, NULL, offsetof(struct spool, file_sweep_time), cb_interval }, { "access-method", N_("ident"), N_("Define access method"), - gconf_type_section, NULL, offsetof(struct spool, access_method), + grecs_type_section, NULL, offsetof(struct spool, access_method), cb_access_method, NULL, access_method_kw }, { "archive", N_("type: string"), N_("Set up archivation"), - gconf_type_section, NULL, offsetof(struct spool, archive), + grecs_type_section, NULL, offsetof(struct spool, archive), cb_archive, NULL, archive_kw }, { "archive-signatures", NULL, N_("Control implicit signature archivation"), - gconf_type_bool, &archive_signatures }, + grecs_type_bool, &archive_signatures }, { "notify-event", NULL, N_("Configure notification"), - gconf_type_section, NULL, offsetof(struct spool, notification), + grecs_type_section, NULL, offsetof(struct spool, notification), cb_notify_event, NULL, notify_event_kw }, { NULL } }; static int -cb_spool (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_spool (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { struct spool *spool; @@ -1191,10 +1191,10 @@ cb_spool (enum gconf_callback_command cmd, switch (cmd) { - case gconf_callback_section_begin: + case grecs_callback_section_begin: if (!value || value->type != GCONF_TYPE_STRING) { - gconf_error (locus, 0, _("tag must be a string")); + grecs_error (locus, 0, _("tag must be a string")); return 1; } spool = xzalloc (sizeof (*spool)); @@ -1206,32 +1206,32 @@ cb_spool (enum gconf_callback_command cmd, *pdata = spool; break; - case gconf_callback_section_end: + case grecs_callback_section_end: rc = 0; spool = *pdata; if (!spool->source_dir) { - gconf_error (locus, 0, _("source is not given")); + grecs_error (locus, 0, _("source is not given")); rc = 1; } else if (test_dir (spool->source_dir, &ec)) { if (ec) - gconf_error (locus, ec, _("cannot access %s"), spool->source_dir); + grecs_error (locus, ec, _("cannot access %s"), spool->source_dir); else - gconf_error (locus, 0, _("%s is not a directory"), + grecs_error (locus, 0, _("%s is not a directory"), spool->source_dir); rc = 1; } if (!spool->dest_url) { - gconf_error (locus, 0, _("destination is not given")); + grecs_error (locus, 0, _("destination is not given")); rc = 1; } else if (url_to_vtab (spool->dest_url, &spool->vtab)) { - gconf_error (locus, 0, _("unsupported url: %s"), + grecs_error (locus, 0, _("unsupported url: %s"), mu_url_to_string (spool->dest_url)); rc = 1; } @@ -1242,7 +1242,7 @@ cb_spool (enum gconf_callback_command cmd, for (i = 0; i < access_method_count; i++) if (spool->access_method[i]->type == method_external) { - gconf_error (locus, 0, + grecs_error (locus, 0, _("Sorry, method type `external' is not yet supported")); rc = 1; } @@ -1258,18 +1258,18 @@ cb_spool (enum gconf_callback_command cmd, *pdata = NULL; break; - case gconf_callback_set_value: - gconf_error (locus, 0, _("invalid use of block statement")); + case grecs_callback_set_value: + grecs_error (locus, 0, _("invalid use of block statement")); } return 0; } static int -cb_user (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_user (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { int rc; @@ -1281,7 +1281,7 @@ cb_user (enum gconf_callback_command cmd, pw = getpwnam (value->v.string); if (!pw) { - gconf_error (locus, 0, _("no such user: %s"), value->v.string); + grecs_error (locus, 0, _("no such user: %s"), value->v.string); return 1; } @@ -1291,20 +1291,20 @@ cb_user (enum gconf_callback_command cmd, } static int -cb_supp_groups (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_supp_groups (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { - if (cmd != gconf_callback_set_value) + if (cmd != grecs_callback_set_value) { - gconf_error (locus, 0, _("Unexpected block statement")); + grecs_error (locus, 0, _("Unexpected block statement")); return 1; } if (!value || value->type != GCONF_TYPE_LIST) { - gconf_error (locus, 0, _("expected list value")); + grecs_error (locus, 0, _("expected list value")); return 1; } @@ -1322,7 +1322,7 @@ cb_supp_groups (enum gconf_callback_command cmd, itr = gl_list_iterator (value->v.list); for (i = 0; gl_list_iterator_next (&itr, &p, NULL); i++) { - const gconf_value_t *vp = p; + const grecs_value_t *vp = p; struct group *grp; if (assert_string_arg (locus, cmd, vp)) @@ -1330,7 +1330,7 @@ cb_supp_groups (enum gconf_callback_command cmd, grp = getgrnam (vp->v.string); if (!grp) { - gconf_error (locus, 0, _("no such group: %s"), value->v.string); + grecs_error (locus, 0, _("no such group: %s"), value->v.string); break; } wydawca_supp_groups[i] = grp->gr_gid; @@ -1341,121 +1341,121 @@ cb_supp_groups (enum gconf_callback_command cmd, } -static struct gconf_keyword locking_kw[] = { +static struct grecs_keyword locking_kw[] = { { "enable", NULL, N_("Enable or disable locking"), - gconf_type_bool, &enable_locking }, + grecs_type_bool, &enable_locking }, { "directory", N_("dir"), N_("Set directory for lock files"), - gconf_type_string, &lockdir }, + grecs_type_string, &lockdir }, { "expire-time", N_("interval"), N_("Define lock expiration interval"), - gconf_type_string, &lock_expire_time, 0, cb_interval }, + grecs_type_string, &lock_expire_time, 0, cb_interval }, { "retry-attempts", N_("n"), N_("Number of times to retry locking"), - gconf_type_uint, &lock_retry_attempts }, + grecs_type_uint, &lock_retry_attempts }, { "retry-interval", N_("interval"), N_("Delay between locking attempts"), - gconf_type_string, &lock_retry_interval, 0, cb_interval }, + grecs_type_string, &lock_retry_interval, 0, cb_interval }, { NULL } }; static int -cb_locking (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_locking (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { - if (cmd == gconf_callback_set_value) + if (cmd == grecs_callback_set_value) { if (!value || value->type != GCONF_TYPE_STRING) { - gconf_error (locus, 0, _("expected scalar value as a tag")); + grecs_error (locus, 0, _("expected scalar value as a tag")); return 1; } - gconf_string_convert (&enable_locking, gconf_type_bool, value->v.string); + grecs_string_convert (&enable_locking, grecs_type_bool, value->v.string); } return 0; } -static struct gconf_keyword wydawca_kw[] = { +static struct grecs_keyword wydawca_kw[] = { { "daemon", NULL, N_("Enable daemon mode"), - gconf_type_bool, &daemon_mode }, + grecs_type_bool, &daemon_mode }, { "foreground", NULL, N_("Start in foreground even in daemon mode"), - gconf_type_bool, &foreground }, + grecs_type_bool, &foreground }, { "single-process", NULL, N_("Do not spawn subprocesses"), - gconf_type_bool, &single_process }, + grecs_type_bool, &single_process }, { "wakeup-interval", N_("time"), N_("Set wake-up interval"), - gconf_type_string, &wakeup_interval, 0, cb_interval }, + grecs_type_string, &wakeup_interval, 0, cb_interval }, { "pidfile", N_("file"), N_("Set pid file name"), - gconf_type_string, &pidfile }, + grecs_type_string, &pidfile }, { "user", N_("name"), N_("Run with UID and GID of this user"), - gconf_type_string, NULL, 0, cb_user }, + grecs_type_string, NULL, 0, cb_user }, { "group", NULL, N_("Retain these supplementary groups"), - gconf_type_string|GCONF_LIST, NULL, 0, cb_supp_groups }, + grecs_type_string|GCONF_LIST, NULL, 0, cb_supp_groups }, { "locking", NULL, N_("Configure locking"), - gconf_type_section, NULL, 0, + grecs_type_section, NULL, 0, cb_locking, NULL, locking_kw }, { "listen", N_("socket"), N_("Listen on this address"), - gconf_type_sockaddr, &listen_sockaddr, }, + grecs_type_sockaddr, &listen_sockaddr, }, #ifdef WITH_LIBWRAP { "tcp-wrapper", NULL, N_("Configure TCP wrappers"), - gconf_type_section, NULL, 0, + grecs_type_section, NULL, 0, NULL, NULL, tcpwrapper_kw }, #endif { "mailer", N_("url"), N_("Set mailer URL"), - gconf_type_string, &mailer, 0, cb_mailer }, + grecs_type_string, &mailer, 0, cb_mailer }, { "admin-address", N_("email"), N_("Set admin email address"), - gconf_type_string, &admin_address, 0, cb_email_address }, + grecs_type_string, &admin_address, 0, cb_email_address }, { "from-address", N_("email"), N_("Set sender email address"), - gconf_type_string, &from_address, 0, cb_email_address }, + grecs_type_string, &from_address, 0, cb_email_address }, /* FIXME: Must be a built-in type? */ { "file-sweep-time", N_("interval"), N_("Define file sweep time"), - gconf_type_string, &file_sweep_time, 0, cb_interval }, + grecs_type_string, &file_sweep_time, 0, cb_interval }, { "tar-program", N_("prog"), N_("Set tar invocation command line"), - gconf_type_string, &tar_command_name, 0, cb_absolute_name }, + grecs_type_string, &tar_command_name, 0, cb_absolute_name }, { "umask", N_("mask: octal"), N_("Set umask"), - gconf_type_string, NULL, 0, cb_set_umask }, + grecs_type_string, NULL, 0, cb_set_umask }, { "statistics", N_("items"), N_("Print these stats at the end of run"), - gconf_type_string, &print_stats, 0, cb_statistics }, + grecs_type_string, &print_stats, 0, cb_statistics }, { "sql", N_("id: string"), N_("Define SQL database"), - gconf_type_section, NULL, 0, cb_sql, NULL, sql_kw }, + grecs_type_section, NULL, 0, cb_sql, NULL, sql_kw }, { "syslog", NULL, N_("Configure syslog logging"), - gconf_type_section, NULL, 0, NULL, NULL, syslog_kw }, + grecs_type_section, NULL, 0, NULL, NULL, syslog_kw }, { "define-message", N_("ident: string> <text: string"), N_("Define message text"), - gconf_type_string, NULL, 0, cb_define_message }, + grecs_type_string, NULL, 0, cb_define_message }, { "archive", N_("type: string"), N_("Set up archivation"), - gconf_type_section, &default_archive_descr, 0, + grecs_type_section, &default_archive_descr, 0, cb_archive, NULL, archive_kw }, { "mail-statistics", NULL, N_("Send statistics"), - gconf_type_section, NULL, 0, NULL, NULL, mail_statistics_kw }, + grecs_type_section, NULL, 0, NULL, NULL, mail_statistics_kw }, { "notify-event", NULL, N_("Configure notification"), - gconf_type_section, &default_notification, 0, + grecs_type_section, &default_notification, 0, cb_notify_event, NULL, notify_event_kw }, { "access-method", N_("ident"), N_("Define access method"), - gconf_type_section, default_access_method, 0, + grecs_type_section, default_access_method, 0, cb_access_method, NULL, access_method_kw }, { "spool", N_("tag: string"), N_("Define distribution spool"), - gconf_type_section, NULL, 0, + grecs_type_section, NULL, 0, cb_spool, NULL, spool_kw }, { "all-spools", NULL, N_("Service names that request scanning all spools"), - gconf_type_string|GCONF_LIST, &all_spool_aliases }, + grecs_type_string|GCONF_LIST, &all_spool_aliases }, { NULL } }; @@ -1466,8 +1466,8 @@ config_help () static char docstring[] = N_("Configuration file structure for wydawca.\n" "For more information, use `info wydawca configuration'."); - gconf_format_docstring (stdout, docstring, 0); - gconf_format_statement_array (stdout, wydawca_kw, 1, 0); + grecs_format_docstring (stdout, docstring, 0); + grecs_format_statement_array (stdout, wydawca_kw, 1, 0); } void @@ -1476,15 +1476,15 @@ config_init() int i; struct servent *serv; - gconf_set_keywords (wydawca_kw); - gconf_include_path_setup (DEFAULT_VERSION_INCLUDE_DIR, + grecs_set_keywords (wydawca_kw); + grecs_include_path_setup (DEFAULT_VERSION_INCLUDE_DIR, DEFAULT_INCLUDE_DIR, NULL); - gconf_preprocessor = DEFAULT_PREPROCESSOR; - gconf_log_to_stderr = true; + grecs_preprocessor = DEFAULT_PREPROCESSOR; + grecs_log_to_stderr = true; serv = getservbyname (PACKAGE, "tcp"); if (serv != NULL) - gconf_default_port = serv->s_port; + grecs_default_port = serv->s_port; for (i = 0; i < access_method_count; i++) default_access_method[i] = method_new (i, method_builtin); diff --git a/src/diskio.c b/src/diskio.c index 35ba71e..1b03e77 100644 --- a/src/diskio.c +++ b/src/diskio.c @@ -715,7 +715,7 @@ dir_rmsymlink_file (struct file_triplet *trp, const struct spool *spool, } int -dir_test_url (mu_url_t url, gconf_locus_t *locus) +dir_test_url (mu_url_t url, grecs_locus_t *locus) { int rc; const char *dest_dir; @@ -723,16 +723,16 @@ dir_test_url (mu_url_t url, gconf_locus_t *locus) rc = mu_url_sget_path (url, &dest_dir); if (rc) { - gconf_error (locus, 0, _("cannot extract directory part from URL: %s"), + grecs_error (locus, 0, _("cannot extract directory part from URL: %s"), mu_strerror (rc)); return rc; } if (test_dir (dest_dir, &rc)) { if (rc) - gconf_error (locus, rc, _("cannot access %s"), dest_dir); + grecs_error (locus, rc, _("cannot access %s"), dest_dir); else - gconf_error (locus, 0, _("%s is not a directory"), dest_dir); + grecs_error (locus, 0, _("%s is not a directory"), dest_dir); return 1; } return 0; diff --git a/src/tcpwrap.c b/src/tcpwrap.c index eccf21b..ac92b62 100644 --- a/src/tcpwrap.c +++ b/src/tcpwrap.c @@ -26,42 +26,42 @@ int deny_severity = LOG_INFO; int allow_severity = LOG_INFO; static int -cb_syslog_priority (enum gconf_callback_command cmd, - gconf_locus_t *locus, +cb_syslog_priority (enum grecs_callback_command cmd, + grecs_locus_t *locus, void *varptr, - gconf_value_t *value, + grecs_value_t *value, void *cb_data) { if (assert_string_arg (locus, cmd, value)) return 1; if (mu_string_to_syslog_priority (value->v.string, varptr)) - gconf_error (locus, 0, _("Unknown syslog priority `%s'"), + grecs_error (locus, 0, _("Unknown syslog priority `%s'"), value->v.string); return 0; } -struct gconf_keyword tcpwrapper_kw[] = { +struct grecs_keyword tcpwrapper_kw[] = { { "enable", NULL, N_("Enable TCP wrapper access control. Default is \"yes\"."), - gconf_type_bool, &tcpwrap_enable }, + grecs_type_bool, &tcpwrap_enable }, { "daemon", N_("name"), N_("Set daemon name for TCP wrapper lookups. Default is program name."), - gconf_type_string, &tcpwrap_daemon }, + grecs_type_string, &tcpwrap_daemon }, { "allow-table", N_("file"), N_("Use file for positive client address access control " "(default: /etc/hosts.allow)."), - gconf_type_string, &hosts_allow_table }, + grecs_type_string, &hosts_allow_table }, { "deny-table", N_("file"), N_("Use file for negative client address access control " "(default: /etc/hosts.deny)."), - gconf_type_string, &hosts_deny_table }, + grecs_type_string, &hosts_deny_table }, { "allow-syslog-priority", N_("prio"), N_("Log host allows at this syslog priority."), - gconf_type_string, &allow_severity, 0, cb_syslog_priority }, + grecs_type_string, &allow_severity, 0, cb_syslog_priority }, { "deny-syslog-priority", N_("prio"), N_("Log host denies at this syslog priority."), - gconf_type_string, &deny_severity, 0, cb_syslog_priority }, + grecs_type_string, &deny_severity, 0, cb_syslog_priority }, { NULL } }; diff --git a/src/wydawca.c b/src/wydawca.c index d210717..509947b 100644 --- a/src/wydawca.c +++ b/src/wydawca.c @@ -46,7 +46,7 @@ int single_process; time_t wakeup_interval; gl_list_t all_spool_aliases; -struct gconf_sockaddr listen_sockaddr; +struct grecs_sockaddr listen_sockaddr; unsigned wydawca_stat[MAX_STAT]; @@ -215,7 +215,7 @@ logstats () void -gconf_print_diag (gconf_locus_t *locus, int err, int errcode, const char *msg) +grecs_print_diag (grecs_locus_t *locus, int err, int errcode, const char *msg) { if (locus) { @@ -310,9 +310,9 @@ main (int argc, char **argv) collect_uids (argc, argv); if (preprocess_only) - exit (gconf_preproc_run (conffile, gconf_preprocessor) ? EX_CONFIG : 0); + exit (grecs_preproc_run (conffile, grecs_preprocessor) ? EX_CONFIG : 0); - if (gconf_parse (conffile)) + if (grecs_parse (conffile)) exit (EX_CONFIG); if (lint_mode) @@ -330,7 +330,7 @@ main (int argc, char **argv) if (log_to_stderr == -1) log_to_stderr = (!daemon_mode || foreground) && isatty (0); - gconf_log_to_stderr = log_to_stderr; + grecs_log_to_stderr = log_to_stderr; if (!log_to_stderr) { openlog (syslog_tag, LOG_PID, log_facility); diff --git a/src/wydawca.h b/src/wydawca.h index fe6f91b..b390bff 100644 --- a/src/wydawca.h +++ b/src/wydawca.h @@ -54,7 +54,7 @@ #include "progname.h" #include "backupfile.h" #include "inttostr.h" -#include "gconf.h" +#include "grecs.h" #include "gl_list.h" #include "wordsplit.h" @@ -188,7 +188,7 @@ struct file_triplet struct virt_tab { - int (*test_url) (mu_url_t url, gconf_locus_t *loc); + int (*test_url) (mu_url_t url, grecs_locus_t *loc); int (*move_file) (struct file_triplet *trp, const struct spool *spool, enum file_type file_id, @@ -332,7 +332,7 @@ extern int daemon_mode; extern time_t wakeup_interval; extern int foreground; extern int single_process; -extern struct gconf_sockaddr listen_sockaddr; +extern struct grecs_sockaddr listen_sockaddr; extern gl_list_t all_spool_aliases; @@ -440,8 +440,8 @@ int parse_time_interval (const char *str, time_t *pint, const char **endp); /* config.c */ void config_init (void); void config_help (void); -int assert_string_arg (gconf_locus_t *, enum gconf_callback_command, - const gconf_value_t *); +int assert_string_arg (grecs_locus_t *, enum grecs_callback_command, + const grecs_value_t *); /* vtab.c */ @@ -464,7 +464,7 @@ rmsymlink_file (struct file_triplet *trp, const struct spool *spool, /* diskio.c */ -int dir_test_url (mu_url_t url, gconf_locus_t *locus); +int dir_test_url (mu_url_t url, grecs_locus_t *locus); int dir_move_file (struct file_triplet *trp, const struct spool *spool, enum file_type file_id, const char *reldir); int dir_archive_file (struct file_triplet *trp, const struct spool *spool, @@ -537,7 +537,7 @@ void wydawca_lock_init (void); /* tcpwrap.h */ -extern struct gconf_keyword tcpwrapper_kw[]; +extern struct grecs_keyword tcpwrapper_kw[]; int tcpwrap_access(int fd); /* userprivs.c */ diff --git a/tests/Makefile.am b/tests/Makefile.am index aa8b029..8efcdef 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -70,7 +70,7 @@ check-local: atconfig atlocal $(TESTSUITE) # $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin check_PROGRAMS = wstest wsbatch -INCLUDES = -I$(top_srcdir)/gconf -I$(top_srcdir)/gnu -I../gnu -LDADD=../gconf/libgconf.a ../gnu/libgnu.a +INCLUDES = -I$(top_srcdir)/grecs/src -I$(top_srcdir)/gnu -I../gnu +LDADD=../grecs/src/libgrecs.a ../gnu/libgnu.a |