From cb4b20275ce9d94c7367164024d1b06e372dfd67 Mon Sep 17 00:00:00 2001 From: Amir Mohammad Saied Date: Sun, 18 Jan 2009 09:20:13 +0330 Subject: [PATCH] Readline support for bti Readline support for bti --- Makefile | 3 ++- bti.c | 17 ++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 7fc3a7b..b39efc9 100644 --- a/Makefile +++ b/Makefile @@ -55,10 +55,11 @@ export E Q # We need -lcurl for the curl stuff # We need -lsocket and -lnsl when on Solaris +# We need -lreadline for readline support # We need -lssl and -lcrypto when using libcurl with SSL support # We need -lpthread for the pthread example #LIB_OBJS = -lcurl -lnsl -lssl -lcrypto -LIB_OBJS = -lcurl -lnsl +LIB_OBJS = -lcurl -lnsl -lreadline all: $(PROGRAM) $(MAN_PAGES) diff --git a/bti.c b/bti.c index cf1b164..b5de9e5 100644 --- a/bti.c +++ b/bti.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "bti_version.h" @@ -86,17 +87,14 @@ static void display_version(void) static char *get_string_from_stdin(void) { - char *temp; - char *string; + static char *string = (char *)NULL; + if (string) { + free(string); + string = (char *)NULL; + } - string = zalloc(1000); - if (!string) - return NULL; + string = readline("tweet: "); - if (!fgets(string, 999, stdin)) - return NULL; - temp = strchr(string, '\n'); - *temp = '\0'; return string; } @@ -410,6 +408,7 @@ int main(int argc, char *argv[], char *envp[]) char *dir; #endif + rl_bind_key('\t', rl_insert); session = session_alloc(); if (!session) { fprintf(stderr, "no more memory...\n"); -- 2.39.5