Initial attempt. Tested on one platform with and without the readline library inside GNU SASL.
2005-07-16 Simon Josefsson <[EMAIL PROTECTED]> * readline.m4: New file. 2005-07-16 Simon Josefsson <[EMAIL PROTECTED]> * modules/readline: New file. 2005-07-16 Simon Josefsson <[EMAIL PROTECTED]> * readline.h, readline.c: New files. Index: lib/readline.h =================================================================== RCS file: lib/readline.h diff -N lib/readline.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lib/readline.h 16 Jul 2005 20:29:00 -0000 @@ -0,0 +1,28 @@ +/* readline.h --- Simple implementation of readline. + Copyright (C) 2005 Free Software Foundation, Inc. + Written by Simon Josefsson + + 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 2, 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, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef GL_READLINE_H +#define GL_READLINE_H + +#if HAVE_READLINE_READLINE_H +# include <readline/readline.h> +#else +extern char *readline (const char *prompt); +#endif + +#endif /* GL_READLINE_H */ Index: lib/readline.c =================================================================== RCS file: lib/readline.c diff -N lib/readline.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lib/readline.c 16 Jul 2005 20:29:00 -0000 @@ -0,0 +1,50 @@ +/* readline.c --- Simple implementation of readline. + Copyright (C) 2005 Free Software Foundation, Inc. + Written by Simon Josefsson + + 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 2, 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, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#if HAVE_CONFIG_H +# include "config.h" +#endif + +/* This module is intended to be used when the application only need + the readline interface. If you need more functions from the + readline library, it is recommended to require the readline library + (or improve this module) rather than #if-protect part of your + application (doing so would add assumptions of this module into + your application). The application should use #include + "readline.h", that header file will include <readline/readline.h> + if the real library is present on the system. */ + +#include <stdio.h> +#include <getline.h> + +/* Get specification. */ +#include "readline.h" + +char * +readline (const char *prompt) +{ + char *out = NULL; + size_t size = 0; + + printf ("%s", prompt); + + if (getline (&out, &size, stdin) < 0) + return NULL; + + return out; +} Index: m4/readline.m4 =================================================================== RCS file: m4/readline.m4 diff -N m4/readline.m4 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ m4/readline.m4 16 Jul 2005 20:29:00 -0000 @@ -0,0 +1,22 @@ +# readline.m4 serial 1 +dnl Copyright (C) 2005 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_READLINE], +[ + AC_LIBSOURCES([readline.c, readline.h]) + + AC_CHECK_HEADERS(readline/readline.h) + AC_CHECK_LIB(readline, readline) + if test "$ac_cv_lib_readline_readline" = no; then + AC_LIBOBJ(readline) + gl_PREREQ_READLINE + fi +]) + +# Prerequisites of lib/readline.c. +AC_DEFUN([gl_PREREQ_READLINE], [ + : +]) Index: modules/readline =================================================================== RCS file: modules/readline diff -N modules/readline --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/readline 16 Jul 2005 20:29:00 -0000 @@ -0,0 +1,24 @@ +Description: +Simple implementation of readline. + +Files: +lib/readline.h +lib/readline.c +m4/readline.m4 + +Depends-on: +getline + +configure.ac: +gl_FUNC_READLINE + +Makefile.am: + +Include: +"readline.h" + +License: +GPL + +Maintainer: +all _______________________________________________ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib