commit 91cfa92a0d58379f882eb01ce3e78b5f3fc6cfa5 from: Omar Polo date: Mon Jan 10 10:23:19 2022 UTC fix -hopefully once and for all- the readline stuff It's incredible how hard is to find an optional dependency that's needed only for some targets. I don't want to use a subdir because kamiftp needs the whole compat stuff as everything else, damn! commit - bbcba3edad343a751fe9bebefddfc812a26cc057 commit + 91cfa92a0d58379f882eb01ce3e78b5f3fc6cfa5 blob - 88f814bd083282ec3980e7633b13701cdafa4656 blob + aa78d8efcc2c684d5bec7c145bda3449743d1355 --- configure.ac +++ configure.ac @@ -131,6 +131,23 @@ AC_CHECK_LIB(util, imsg_init, [], [ AC_LIBOBJ(ohash) ]) +# Check for readline +AS_CASE([$host_os], + [*openbsd*], [ + AC_DEFINE([HAVE_READLINE], 1, [1 if readline found]) + READLINE_CFLAGS='' + READLINE_LIBS='-lreadline' + ], [ + PKG_CHECK_MODULES([READLINE], [readline], [ + AC_DEFINE([HAVE_READLINE], 0, []) + ], [ + AC_DEFINE([HAVE_READLINE], 0, []) + ]) + ] +) +AC_SUBST(READLINE_CFLAGS) +AC_SUBST(READLINE_LIBS) + # Save our CFLAGS/CPPFLAGS/LDFLAGS for the Makefile and restore the old user # variables. AC_SUBST(AM_CPPFLAGS) blob - db48a7233c4f6f374cf5263aa19af899f5bf900b blob + 170543df04000f49c5b768a7fb112363f48baab1 --- kamiftp/Makefile.am +++ kamiftp/Makefile.am @@ -13,7 +13,10 @@ man1_MANS = kamiftp.1 LDADD = $(LIBOBJS) -AM_CPPFLAGS += -DKAMID_VERSION='"@VERSION@"' \ +kamiftp_CFLAGS = @READLINE_CFLAGS@ +kamiftp_LDFLAGS= @READLINE_LIBS@ + +AM_CPPFLAGS = -DKAMID_VERSION='"@VERSION@"' \ -I$(top_srcdir)/ \ -I$(top_srcdir)/compat \ -I$(top_srcdir)/lib blob - 96e71e43189f2deed268092a49e080c462282053 blob + b0658bdccc660cc673ad11784f437adf7b2dbf3b --- kamiftp/ftp.c +++ kamiftp/ftp.c @@ -34,8 +34,10 @@ #include #include +#ifdef HAVE_READLINE #include #include +#endif #ifndef nitems #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) @@ -87,6 +89,33 @@ int pwdfid; #define ASSERT_EMPTYBUF() assert(EVBUFFER_LENGTH(buf) == 0) +#if !HAVE_READLINE +char * +readline(const char *prompt) +{ + char *ch, *line = NULL; + size_t linesize = 0; + ssize_t linelen; + + printf("%s", prompt); + fflush(stdout); + + linelen = getline(&line, &linesize, stdin); + if (linelen == -1) + return NULL; + + if ((ch = strchr(line, '\n')) != NULL) + *ch = '\0'; + return line; +} + +void +add_history(const char *line) +{ + return; +} +#endif + static char * read_line(const char *prompt) {