summaryrefslogtreecommitdiff
path: root/gl/readline.c
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2005-08-15 09:51:48 +0000
committerSimon Josefsson <simon@josefsson.org>2005-08-15 09:51:48 +0000
commit8e0624d585f1506bdf0eb37916d63f6e77df7005 (patch)
tree9f740c24c3667874eef92b63fc178dbcc322f9e0 /gl/readline.c
parent6aed4ab2ad244c396d9e17045af94abf3d038b1a (diff)
downloadgnutls-8e0624d585f1506bdf0eb37916d63f6e77df7005.tar.gz
Update.
Diffstat (limited to 'gl/readline.c')
-rw-r--r--gl/readline.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/gl/readline.c b/gl/readline.c
new file mode 100644
index 0000000000..3a6b3dfdd9
--- /dev/null
+++ b/gl/readline.c
@@ -0,0 +1,51 @@
+/* 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 Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1, 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 Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser 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. */
+
+/* Get specification. */
+#include "readline.h"
+
+#include <stdio.h>
+#include <getline.h>
+
+char *
+readline (const char *prompt)
+{
+ char *out = NULL;
+ size_t size = 0;
+
+ if (prompt)
+ fputs (prompt, stdout);
+
+ if (getline (&out, &size, stdin) < 0)
+ return NULL;
+
+ return out;
+}