2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

Move the <isc/readline.h> header to bin/dig/readline.h

The <isc/readline.h> header provided a compatibility shim to use when
other non-GNU readline libraries are in use.  The two places where
readline library is being used is nslookup and nsupdate, so the header
file has been moved to bin/dig directory and it's directly included from
bin/nsupdate.

This also conceals any readline headers exposed from the libisc headers.
This commit is contained in:
Ondřej Surý
2021-02-11 14:13:27 +01:00
committed by Mark Andrews
parent 00b5f4c389
commit d1448a4c2a
8 changed files with 15 additions and 6 deletions

View File

@@ -66,7 +66,6 @@ libisc_la_HEADERS = \
include/isc/radix.h \
include/isc/random.h \
include/isc/ratelimiter.h \
include/isc/readline.h \
include/isc/refcount.h \
include/isc/regex.h \
include/isc/region.h \

View File

@@ -1,56 +0,0 @@
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#pragma once
/*
* A little wrapper around readline(), add_history() and free() to make using
* the readline code simpler.
*/
#if defined(HAVE_READLINE_LIBEDIT)
#include <editline/readline.h>
#elif defined(HAVE_READLINE_EDITLINE)
#include <editline.h>
#elif defined(HAVE_READLINE_READLINE)
/* Prevent deprecated functions being declared. */
#define _FUNCTION_DEF 1
/* Ensure rl_message() gets prototype. */
#define USE_VARARGS 1
#define PREFER_STDARG 1
#include <readline/history.h>
#include <readline/readline.h>
#endif
#if !defined(HAVE_READLINE_LIBEDIT) && !defined(HAVE_READLINE_EDITLINE) && \
!defined(HAVE_READLINE_READLINE)
#include <stdio.h>
#include <stdlib.h>
#define RL_MAXCMD (128 * 1024)
static inline char *
readline(const char *prompt) {
char *line, *buf = malloc(RL_MAXCMD);
fprintf(stdout, "%s", prompt);
fflush(stdout);
line = fgets(buf, RL_MAXCMD, stdin);
if (line == NULL) {
free(buf);
return (NULL);
}
return (buf);
};
#define add_history(line)
#endif