diff options
-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-- | doc/wydawca.texi | 4 | ||||
-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/triplet.c | 6 | ||||
-rw-r--r-- | src/wydawca.c | 10 | ||||
-rw-r--r-- | src/wydawca.h | 14 | ||||
-rw-r--r-- | tests/Makefile.am | 4 |
28 files changed, 325 insertions, 3580 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 --- /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/doc/wydawca.texi b/doc/wydawca.texi index 5e00dcf..c5eb691 100644 --- a/doc/wydawca.texi +++ b/doc/wydawca.texi @@ -1279,8 +1279,8 @@ archive-signatures no; @UNREVISED A @dfn{distribution spool} defines the location of the source directory and the corresponding distribution (or @dfn{destination}) -directory. It may also set the archivation type being used for that -directory, various access methods and notifications, thus overriding +directory. It may also set archivation type, +various access methods and notifications for that directory, thus overriding global settings. Distribution spool is defined in the configuration file by the diff --git a/gconf/.gitignore b/gconf/.gitignore deleted file mode 100644 index 42c88b2..0000000 --- a/gconf/.gitignore +++ /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 +++ /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 +++ /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 +++ /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? */ |