diff options
author | Werner Koch <[email protected]> | 2003-04-29 10:49:57 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2003-04-29 10:49:57 +0000 |
commit | e6203aa72033e5de35c57be44f4e5572d150e9c6 (patch) | |
tree | a669e94af3bcc62fe2263b896bf5fc64699674ce | |
parent | 2003-02-22 Neal H. Walfield <[email protected]> (diff) | |
download | libassuan-e6203aa72033e5de35c57be44f4e5572d150e9c6.tar.gz libassuan-e6203aa72033e5de35c57be44f4e5572d150e9c6.zip |
* libassuan.m4: New. Based on libgrypt.m4.
* Makefile.am (m4data_DATA): New.
* assuan.h (AssuanCommand): Removed.
* assuan-handler.c: Remove the cmd_id element,
(assuan_register_command): Likewise. Note that semantics changed.
(_assuan_register_std_commands): Adjusted.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | Makefile.am | 5 | ||||
-rwxr-xr-x | autogen.sh | 2 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rwxr-xr-x | mkinstalldirs | 73 | ||||
-rw-r--r-- | src/ChangeLog | 11 | ||||
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/assuan-defs.h | 9 | ||||
-rw-r--r-- | src/assuan-handler.c | 93 | ||||
-rw-r--r-- | src/assuan.h | 2 | ||||
-rw-r--r-- | src/libassuan.m4 | 76 |
11 files changed, 162 insertions, 122 deletions
@@ -1,3 +1,10 @@ +2003-04-28 gettextize <[email protected]> + + * Makefile.am (SUBDIRS): Add m4. + (ACLOCAL_AMFLAGS): New variable. + (EXTRA_DIST): New variable. + * configure.ac (AC_CONFIG_FILES): Add po/Makefile.in, + 2003-02-18 Neal H. Walfield <[email protected]> * COPYING: New file. diff --git a/Makefile.am b/Makefile.am index a5cd5a4..a7948ec 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1 +1,4 @@ -SUBDIRS = src doc tests
\ No newline at end of file +SUBDIRS = m4 src doc +ACLOCAL_AMFLAGS = -I m4 + +EXTRA_DIST = config.rpath @@ -154,7 +154,7 @@ echo "Running gettextize... Ignore non-fatal messages." echo "no" | gettextize echo "Running $aclocal" -$aclocal +$aclocal -I m4 echo "Running autoheader..." autoheader echo "Running $automake --gnu -a" diff --git a/configure.ac b/configure.ac index 125bfd3..d936c17 100644 --- a/configure.ac +++ b/configure.ac @@ -141,7 +141,7 @@ AC_REPLACE_FUNCS(isascii) AC_REPLACE_FUNCS(putc_unlocked) AC_REPLACE_FUNCS(memrchr) -AC_CONFIG_FILES([ +AC_CONFIG_FILES([ po/Makefile.in m4/Makefile Makefile src/Makefile src/libassuan-config diff --git a/mkinstalldirs b/mkinstalldirs index 8ab885e..6b3b5fc 100755 --- a/mkinstalldirs +++ b/mkinstalldirs @@ -4,53 +4,9 @@ # Created: 1993-05-16 # Public domain -errstatus=0 -dirmode="" - -usage="\ -Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." - -# process command line arguments -while test $# -gt 0 ; do - case "${1}" in - -h | --help | --h* ) # -h for help - echo "${usage}" 1>&2; exit 0 ;; - -m ) # -m PERM arg - shift - test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; } - dirmode="${1}" - shift ;; - -- ) shift; break ;; # stop option processing - -* ) echo "${usage}" 1>&2; exit 1 ;; # unknown option - * ) break ;; # first non-opt arg - esac -done - -for file -do - if test -d "$file"; then - shift - else - break - fi -done - -case $# in -0) exit 0 ;; -esac +# $Id$ -case $dirmode in -'') - if mkdir -p -- . 2>/dev/null; then - echo "mkdir -p -- $*" - exec mkdir -p -- "$@" - fi ;; -*) - if mkdir -m "$dirmode" -p -- . 2>/dev/null; then - echo "mkdir -m $dirmode -p -- $*" - exec mkdir -m "$dirmode" -p -- "$@" - fi ;; -esac +errstatus=0 for file do @@ -66,24 +22,13 @@ do esac if test ! -d "$pathcomp"; then - echo "mkdir $pathcomp" - - mkdir "$pathcomp" || lasterr=$? - - if test ! -d "$pathcomp"; then - errstatus=$lasterr - else - if test ! -z "$dirmode"; then - echo "chmod $dirmode $pathcomp" + echo "mkdir $pathcomp" - lasterr="" - chmod "$dirmode" "$pathcomp" || lasterr=$? + mkdir "$pathcomp" || lasterr=$? - if test ! -z "$lasterr"; then - errstatus=$lasterr - fi - fi - fi + if test ! -d "$pathcomp"; then + errstatus=$lasterr + fi fi pathcomp="$pathcomp/" @@ -92,8 +37,4 @@ done exit $errstatus -# Local Variables: -# mode: shell-script -# sh-indentation: 3 -# End: # mkinstalldirs ends here diff --git a/src/ChangeLog b/src/ChangeLog index a484cf1..47e2bc2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2003-04-29 Werner Koch <[email protected]> + + * libassuan.m4: New. Based on libgrypt.m4. + * Makefile.am (m4data_DATA): New. + + * assuan.h (AssuanCommand): Removed. + + * assuan-handler.c: Remove the cmd_id element, + (assuan_register_command): Likewise. Note that semantics changed. + (_assuan_register_std_commands): Adjusted. + 2003-02-22 Neal H. Walfield <[email protected]> * Makefile.am (bin_SCRIPTS): Renamed from bin_PROGRAMS. diff --git a/src/Makefile.am b/src/Makefile.am index 041ee17..23ae54b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -19,12 +19,14 @@ ## Process this file with automake to produce Makefile.in -EXTRA_DIST = mkerrors +EXTRA_DIST = mkerrors libassuan.m4 INCLUDES = -I.. -I$(top_srcdir)/include BUILT_SOURCES = assuan-errors.c MOSTLYCLEANFILES = assuan-errors.c bin_SCRIPTS = libassuan-config +m4datadir = $(datadir)/aclocal +m4data_DATA = libassuan.m4 lib_LIBRARIES = libassuan.a include_HEADERS = assuan.h diff --git a/src/assuan-defs.h b/src/assuan-defs.h index 5766024..1f7f1f0 100644 --- a/src/assuan-defs.h +++ b/src/assuan-defs.h @@ -33,7 +33,6 @@ struct cmdtbl_s { const char *name; - int cmd_id; int (*handler)(ASSUAN_CONTEXT, char *line); }; @@ -183,5 +182,13 @@ ssize_t _assuan_simple_read (ASSUAN_CONTEXT ctx, void *buffer, size_t size); ssize_t _assuan_simple_write (ASSUAN_CONTEXT ctx, const void *buffer, size_t size); +#ifdef HAVE_FOPENCOOKIE +/* We have to implement funopen in terms of glibc's fopencookie. */ +FILE *funopen(const void *cookie, cookie_read_function_t *readfn, + cookie_write_function_t *writefn, + cookie_seek_function_t *seekfn, + cookie_close_function_t *closefn); +#endif /*HAVE_FOPENCOOKIE*/ + #endif /*ASSUAN_DEFS_H*/ diff --git a/src/assuan-handler.c b/src/assuan-handler.c index 9d73e0e..f8b85db 100644 --- a/src/assuan-handler.c +++ b/src/assuan-handler.c @@ -25,9 +25,15 @@ #include "assuan-defs.h" + + #define spacep(p) (*(p) == ' ' || *(p) == '\t') #define digitp(a) ((a) >= '0' && (a) <= '9') +static int my_strcasecmp (const char *a, const char *b); + + + static int dummy_handler (ASSUAN_CONTEXT ctx, char *line) { @@ -191,25 +197,24 @@ std_handler_output (ASSUAN_CONTEXT ctx, char *line) /* This is a table with the standard commands and handler for them. - The table is used to initialize a new context and assuciate strings - and handlers with cmd_ids */ + The table is used to initialize a new context and associate strings + with default handlers */ static struct { const char *name; - int cmd_id; int (*handler)(ASSUAN_CONTEXT, char *line); int always; /* always initialize this command */ } std_cmd_table[] = { - { "NOP", ASSUAN_CMD_NOP, std_handler_nop, 1 }, - { "CANCEL", ASSUAN_CMD_CANCEL, std_handler_cancel, 1 }, - { "OPTION", ASSUAN_CMD_OPTION, std_handler_option, 1 }, - { "BYE", ASSUAN_CMD_BYE, std_handler_bye, 1 }, - { "AUTH", ASSUAN_CMD_AUTH, std_handler_auth, 1 }, - { "RESET", ASSUAN_CMD_RESET, std_handler_reset, 1 }, - { "END", ASSUAN_CMD_END, std_handler_end, 1 }, - - { "INPUT", ASSUAN_CMD_INPUT, std_handler_input }, - { "OUTPUT", ASSUAN_CMD_OUTPUT, std_handler_output }, - { "OPTION", ASSUAN_CMD_OPTION, std_handler_option, 1 }, + { "NOP", std_handler_nop, 1 }, + { "CANCEL", std_handler_cancel, 1 }, + { "OPTION", std_handler_option, 1 }, + { "BYE", std_handler_bye, 1 }, + { "AUTH", std_handler_auth, 1 }, + { "RESET", std_handler_reset, 1 }, + { "END", std_handler_end, 1 }, + + { "INPUT", std_handler_input }, + { "OUTPUT", std_handler_output }, + { "OPTION", std_handler_option, 1 }, { NULL } }; @@ -217,54 +222,46 @@ static struct { /** * assuan_register_command: * @ctx: the server context - * @cmd_id: An ID value for the command * @cmd_name: A string with the command name - * @handler: The handler function to be called + * @handler: The handler function to be called or NULL to use a default + * handler. * - * Register a handler to be used for a given command. + * Register a handler to be used for a given command. Note that + * several default handlers are already regsitered with a new context. + * This function however allows to override them. * - * The @cmd_name must be %NULL or an empty string for all @cmd_ids - * below %ASSUAN_CMD_USER because predefined values are used. - * - * Return value: + * Return value: 0 on success or an error code **/ int assuan_register_command (ASSUAN_CONTEXT ctx, - int cmd_id, const char *cmd_name, + const char *cmd_name, int (*handler)(ASSUAN_CONTEXT, char *)) { int i; + const char *s; if (cmd_name && !*cmd_name) cmd_name = NULL; - if (cmd_id < ASSUAN_CMD_USER) - { - if (cmd_name) - return ASSUAN_Invalid_Value; /* must be NULL for these values*/ + if (!cmd_name) + return ASSUAN_Invalid_Value; - for (i=0; std_cmd_table[i].name; i++) - { - if (std_cmd_table[i].cmd_id == cmd_id) - { - cmd_name = std_cmd_table[i].name; - if (!handler) - handler = std_cmd_table[i].handler; - break; - } + if (!handler) + { /* find a default handler. */ + for (i=0; (s=std_cmd_table[i].name) && strcmp (cmd_name, s); i++) + ; + if (!s) + { /* Try again but case insensitive. */ + for (i=0; (s=std_cmd_table[i].name) + && my_strcasecmp (cmd_name, s); i++) + ; } - if (!std_cmd_table[i].name) - return ASSUAN_Invalid_Value; /* not a pre-registered one */ + if (s) + handler = std_cmd_table[i].handler; + if (!handler) + handler = dummy_handler; /* Last resort is the dummy handler. */ } - if (!handler) - handler = dummy_handler; - - if (!cmd_name) - return ASSUAN_Invalid_Value; - -/* fprintf (stderr, "DBG-assuan: registering %d as `%s'\n", cmd_id, cmd_name); */ - if (!ctx->cmdtbl) { ctx->cmdtbl_size = 50; @@ -285,7 +282,6 @@ assuan_register_command (ASSUAN_CONTEXT ctx, } ctx->cmdtbl[ctx->cmdtbl_used].name = cmd_name; - ctx->cmdtbl[ctx->cmdtbl_used].cmd_id = cmd_id; ctx->cmdtbl[ctx->cmdtbl_used].handler = handler; ctx->cmdtbl_used++; return 0; @@ -360,8 +356,7 @@ _assuan_register_std_commands (ASSUAN_CONTEXT ctx) { if (std_cmd_table[i].always) { - rc = assuan_register_command (ctx, std_cmd_table[i].cmd_id, - NULL, NULL); + rc = assuan_register_command (ctx, std_cmd_table[i].name, NULL); if (rc) return rc; } @@ -610,8 +605,6 @@ assuan_get_active_fds (ASSUAN_CONTEXT ctx, int what, FILE * assuan_get_data_fp (ASSUAN_CONTEXT ctx) { - cookie_io_functions_t cookie_fnc; - if (ctx->outbound.data.fp) return ctx->outbound.data.fp; diff --git a/src/assuan.h b/src/assuan.h index 5f53827..f898c26 100644 --- a/src/assuan.h +++ b/src/assuan.h @@ -127,7 +127,7 @@ typedef struct assuan_context_s *ASSUAN_CONTEXT; /*-- assuan-handler.c --*/ int assuan_register_command (ASSUAN_CONTEXT ctx, - int cmd_id, const char *cmd_string, + const char *cmd_string, int (*handler)(ASSUAN_CONTEXT, char *)); int assuan_register_bye_notify (ASSUAN_CONTEXT ctx, void (*fnc)(ASSUAN_CONTEXT)); diff --git a/src/libassuan.m4 b/src/libassuan.m4 new file mode 100644 index 0000000..2afc697 --- /dev/null +++ b/src/libassuan.m4 @@ -0,0 +1,76 @@ +dnl Autoconf macros for libassuan +dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc. +dnl +dnl This file is free software; as a special exception the author gives +dnl unlimited permission to copy and/or distribute it, with or without +dnl modifications, as long as this notice is preserved. +dnl +dnl This file is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the +dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + +dnl AM_PATH_LIBASSUAN([MINIMUM-VERSION, +dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) +dnl Test for libassuan and define LIBASSUAN_CFLAGS and LIBASSUAN_LIBS +dnl +AC_DEFUN(AM_PATH_LIBASSUAN, +[ AC_ARG_WITH(libassuan-prefix, + AC_HELP_STRING([--with-libassuan-prefix=PFX], + [prefix where LIBASSUAN is installed (optional)]), + libassuan_config_prefix="$withval", libassuan_config_prefix="") + if test x$libassuan_config_prefix != x ; then + libassuan_config_args="$libassuan_config_args --prefix=$libassuan_config_prefix" + if test x${LIBASSUAN_CONFIG+set} != xset ; then + LIBASSUAN_CONFIG=$libassuan_config_prefix/bin/libassuan-config + fi + fi + + AC_PATH_PROG(LIBASSUAN_CONFIG, libassuan-config, no) + min_libassuan_version=ifelse([$1], ,0.0.1,$1) + AC_MSG_CHECKING(for LIBASSUAN - version >= $min_libassuan_version) + ok=no + if test "$LIBASSUAN_CONFIG" != "no" ; then + req_major=`echo $min_libassuan_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'` + req_minor=`echo $min_libassuan_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'` + req_micro=`echo $min_libassuan_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'` + libassuan_config_version=`$LIBASSUAN_CONFIG $libassuan_config_args --version` + major=`echo $libassuan_config_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` + minor=`echo $libassuan_config_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'` + micro=`echo $libassuan_config_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'` + if test "$major" -gt "$req_major"; then + ok=yes + else + if test "$major" -eq "$req_major"; then + if test "$minor" -gt "$req_minor"; then + ok=yes + else + if test "$minor" -eq "$req_minor"; then + if test "$micro" -ge "$req_micro"; then + ok=yes + fi + fi + fi + fi + fi + fi + if test $ok = yes; then + LIBASSUAN_CFLAGS=`$LIBASSUAN_CONFIG $libassuan_config_args --cflags` + LIBASSUAN_LIBS=`$LIBASSUAN_CONFIG $libassuan_config_args --libs` + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + LIBASSUAN_CFLAGS="" + LIBASSUAN_LIBS="" + AC_MSG_RESULT(no) + ifelse([$3], , :, [$3]) + fi + AC_SUBST(LIBASSUAN_CFLAGS) + AC_SUBST(LIBASSUAN_LIBS) +]) |