Compare commits
13 Commits
ba5a6374b6
...
v1.2.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
74fcb06828
|
|||
|
8cf1abf135
|
|||
|
b87fbc93a6
|
|||
|
ac1a21eac8
|
|||
|
6934550068
|
|||
|
cda7e1b1f3
|
|||
|
14c6d285fc
|
|||
|
ab5941aaef
|
|||
|
84d6c658e8
|
|||
|
a89fadf860
|
|||
|
4023155b67
|
|||
|
4ed58dd89a
|
|||
|
022668fb23
|
@@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required (VERSION 3.0)
|
cmake_minimum_required (VERSION 3.0...3.27)
|
||||||
project (json-rpc-shell VERSION 1.1.0 LANGUAGES C)
|
project (json-rpc-shell VERSION 1.2.0 LANGUAGES C)
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
option (WANT_READLINE "Use GNU Readline for the UI (better)" ON)
|
option (WANT_READLINE "Use GNU Readline for the UI (better)" ON)
|
||||||
@@ -13,22 +13,29 @@ if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUCC)
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# For custom modules
|
# For custom modules
|
||||||
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
set (CMAKE_MODULE_PATH
|
||||||
|
"${PROJECT_SOURCE_DIR}/cmake;${PROJECT_SOURCE_DIR}/liberty/cmake")
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
find_package (Curses)
|
find_package (Curses)
|
||||||
|
find_package (Ncursesw)
|
||||||
find_package (PkgConfig REQUIRED)
|
find_package (PkgConfig REQUIRED)
|
||||||
pkg_check_modules (dependencies REQUIRED libcurl jansson)
|
|
||||||
# Note that cURL can link to a different version of libssl than we do,
|
# Note that cURL can link to a different version of libssl than we do,
|
||||||
# in which case the results are undefined
|
# in which case the results are undefined
|
||||||
pkg_check_modules (libssl REQUIRED libssl libcrypto)
|
pkg_check_modules (dependencies REQUIRED libcurl jansson libssl libcrypto)
|
||||||
find_package (LibEV REQUIRED)
|
find_package (LibEV REQUIRED)
|
||||||
pkg_check_modules (ncursesw ncursesw)
|
|
||||||
|
|
||||||
set (project_libraries ${dependencies_LIBRARIES}
|
set (project_libraries ${dependencies_LIBRARIES} ${LibEV_LIBRARIES})
|
||||||
${libssl_LIBRARIES} ${LibEV_LIBRARIES})
|
include_directories (${dependencies_INCLUDE_DIRS} ${LibEV_INCLUDE_DIRS})
|
||||||
include_directories (${dependencies_INCLUDE_DIRS}
|
link_directories (${dependencies_LIBRARY_DIRS})
|
||||||
${libssl_INCLUDE_DIRS} ${LibEV_INCLUDE_DIRS})
|
|
||||||
|
if ("${CMAKE_SYSTEM_NAME}" MATCHES "BSD")
|
||||||
|
# Need this for SIGWINCH in FreeBSD and OpenBSD respectively;
|
||||||
|
# our POSIX version macros make it undefined
|
||||||
|
add_definitions (-D__BSD_VISIBLE=1 -D_BSD_SOURCE=1)
|
||||||
|
elseif (APPLE)
|
||||||
|
add_definitions (-D_DARWIN_C_SOURCE)
|
||||||
|
endif ()
|
||||||
|
|
||||||
# -liconv may or may not be a part of libc
|
# -liconv may or may not be a part of libc
|
||||||
find_library (iconv_LIBRARIES iconv)
|
find_library (iconv_LIBRARIES iconv)
|
||||||
@@ -36,15 +43,18 @@ if (iconv_LIBRARIES)
|
|||||||
list (APPEND project_libraries ${iconv_LIBRARIES})
|
list (APPEND project_libraries ${iconv_LIBRARIES})
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if ("${CMAKE_SYSTEM_NAME}" MATCHES "BSD")
|
include (CheckCSourceRuns)
|
||||||
# Need this for SIGWINCH in FreeBSD and OpenBSD respectively;
|
set (CMAKE_REQUIRED_LIBRARIES ${project_libraries})
|
||||||
# our POSIX version macros make it undefined
|
get_property (CMAKE_REQUIRED_INCLUDES
|
||||||
add_definitions (-D__BSD_VISIBLE=1 -D_BSD_SOURCE=1)
|
DIRECTORY "${PROJECT_SOURCE_DIR}" PROPERTY INCLUDE_DIRECTORIES)
|
||||||
endif ()
|
CHECK_C_SOURCE_RUNS ("#include <iconv.h>
|
||||||
|
int main () { return iconv_open (\"UTF-8//TRANSLIT\", \"ISO-8859-1\")
|
||||||
|
== (iconv_t) -1; }" ICONV_ACCEPTS_TRANSLIT)
|
||||||
|
|
||||||
if (ncursesw_FOUND)
|
if (Ncursesw_FOUND)
|
||||||
list (APPEND project_libraries ${ncursesw_LIBRARIES})
|
list (APPEND project_libraries ${Ncursesw_LIBRARIES})
|
||||||
include_directories (${ncursesw_INCLUDE_DIRS})
|
include_directories (${Ncursesw_INCLUDE_DIRS})
|
||||||
|
link_directories (${Ncursesw_LIBRARY_DIRS})
|
||||||
elseif (CURSES_FOUND)
|
elseif (CURSES_FOUND)
|
||||||
list (APPEND project_libraries ${CURSES_LIBRARY})
|
list (APPEND project_libraries ${CURSES_LIBRARY})
|
||||||
include_directories (${CURSES_INCLUDE_DIR})
|
include_directories (${CURSES_INCLUDE_DIR})
|
||||||
@@ -99,7 +109,8 @@ install (FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
|||||||
find_program (ASCIIDOCTOR_EXECUTABLE asciidoctor)
|
find_program (ASCIIDOCTOR_EXECUTABLE asciidoctor)
|
||||||
find_program (A2X_EXECUTABLE a2x)
|
find_program (A2X_EXECUTABLE a2x)
|
||||||
if (NOT ASCIIDOCTOR_EXECUTABLE AND NOT A2X_EXECUTABLE)
|
if (NOT ASCIIDOCTOR_EXECUTABLE AND NOT A2X_EXECUTABLE)
|
||||||
message (FATAL_ERROR "Neither asciidoctor nor a2x were found")
|
message (WARNING "Neither asciidoctor nor a2x were found, "
|
||||||
|
"falling back to a substandard manual page generator")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
foreach (page ${PROJECT_NAME})
|
foreach (page ${PROJECT_NAME})
|
||||||
@@ -121,6 +132,14 @@ foreach (page ${PROJECT_NAME})
|
|||||||
"${PROJECT_SOURCE_DIR}/${page}.adoc"
|
"${PROJECT_SOURCE_DIR}/${page}.adoc"
|
||||||
DEPENDS ${page}.adoc
|
DEPENDS ${page}.adoc
|
||||||
COMMENT "Generating man page for ${page}" VERBATIM)
|
COMMENT "Generating man page for ${page}" VERBATIM)
|
||||||
|
else ()
|
||||||
|
set (ASCIIMAN ${PROJECT_SOURCE_DIR}/liberty/tools/asciiman.awk)
|
||||||
|
add_custom_command (OUTPUT ${page_output}
|
||||||
|
COMMAND env LC_ALL=C asciidoc-release-version=${PROJECT_VERSION}
|
||||||
|
awk -f ${ASCIIMAN} "${PROJECT_SOURCE_DIR}/${page}.adoc"
|
||||||
|
> ${page_output}
|
||||||
|
DEPENDS ${page}.adoc ${ASCIIMAN}
|
||||||
|
COMMENT "Generating man page for ${page}" VERBATIM)
|
||||||
endif ()
|
endif ()
|
||||||
endforeach ()
|
endforeach ()
|
||||||
|
|
||||||
|
|||||||
4
NEWS
4
NEWS
@@ -1,4 +1,4 @@
|
|||||||
Unreleased
|
1.2.0 (2024-12-24)
|
||||||
|
|
||||||
* Add a backend for co-processes, such as language servers
|
* Add a backend for co-processes, such as language servers
|
||||||
|
|
||||||
@@ -8,6 +8,8 @@ Unreleased
|
|||||||
|
|
||||||
* Miscellaneous libedit (editline) fixes
|
* Miscellaneous libedit (editline) fixes
|
||||||
|
|
||||||
|
* Miscellaneous portability improvements
|
||||||
|
|
||||||
* json-rpc-test-server: implement OpenRPC discovery
|
* json-rpc-test-server: implement OpenRPC discovery
|
||||||
|
|
||||||
* json-rpc-test-server: only serve regular files
|
* json-rpc-test-server: only serve regular files
|
||||||
|
|||||||
18
README.adoc
18
README.adoc
@@ -29,19 +29,17 @@ The rest of this README will concern itself with externalities.
|
|||||||
|
|
||||||
Packages
|
Packages
|
||||||
--------
|
--------
|
||||||
Regular releases are sporadic. git master should be stable enough. You can get
|
Regular releases are sporadic. git master should be stable enough.
|
||||||
a package with the latest development version from Archlinux's AUR.
|
You can get a package with the latest development version using Arch Linux's
|
||||||
|
https://aur.archlinux.org/packages/json-rpc-shell-git[AUR],
|
||||||
|
or as a https://git.janouch.name/p/nixexprs[Nix derivation].
|
||||||
|
|
||||||
Building
|
Building
|
||||||
--------
|
--------
|
||||||
Build dependencies: CMake, pkg-config, asciidoctor or asciidoc,
|
Build dependencies: CMake, pkg-config, liberty (included),
|
||||||
liberty (included), http-parser (included) +
|
http-parser (included), asciidoctor or asciidoc (recommended but optional) +
|
||||||
Runtime dependencies: libev, Jansson, cURL, openssl,
|
Runtime dependencies:
|
||||||
readline or libedit >= 2013-07-12,
|
libev, Jansson, cURL, openssl, readline or libedit >= 2013-07-12
|
||||||
|
|
||||||
Avoid libedit if you can, in general it works but at the moment history is
|
|
||||||
acting up and I have no clue about fixing it. Multiline editing is also
|
|
||||||
misbehaving there.
|
|
||||||
|
|
||||||
$ git clone --recursive https://git.janouch.name/p/json-rpc-shell.git
|
$ git clone --recursive https://git.janouch.name/p/json-rpc-shell.git
|
||||||
$ mkdir json-rpc-shell/build
|
$ mkdir json-rpc-shell/build
|
||||||
|
|||||||
@@ -7,5 +7,7 @@
|
|||||||
#cmakedefine HAVE_READLINE
|
#cmakedefine HAVE_READLINE
|
||||||
#cmakedefine HAVE_EDITLINE
|
#cmakedefine HAVE_EDITLINE
|
||||||
|
|
||||||
|
#cmakedefine01 ICONV_ACCEPTS_TRANSLIT
|
||||||
|
|
||||||
#endif // ! CONFIG_H
|
#endif // ! CONFIG_H
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,9 @@ Synopsis
|
|||||||
|
|
||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
:colon: :
|
||||||
The _ENDPOINT_ must be either an HTTP or a WebSocket URL, with or without TLS
|
The _ENDPOINT_ must be either an HTTP or a WebSocket URL, with or without TLS
|
||||||
(i.e. one of the _+++http+++://_, _+++https+++://_, _ws://_, _wss://_ schemas).
|
(i.e. one of the _http{colon}//_, _https{colon}//_, _ws://_, _wss://_ schemas).
|
||||||
|
|
||||||
*json-rpc-shell* will use it to send any JSON-RPC 2.0 requests you enter on its
|
*json-rpc-shell* will use it to send any JSON-RPC 2.0 requests you enter on its
|
||||||
command line. The server's response will be parsed and validated, stripping it
|
command line. The server's response will be parsed and validated, stripping it
|
||||||
|
|||||||
@@ -601,7 +601,7 @@ input_el_on_return (EditLine *editline, int key)
|
|||||||
int len = info->lastchar - info->buffer;
|
int len = info->lastchar - info->buffer;
|
||||||
int point = info->cursor - info->buffer;
|
int point = info->cursor - info->buffer;
|
||||||
|
|
||||||
wchar_t *line = calloc (sizeof *info->buffer, len + 1);
|
wchar_t *line = xcalloc (len + 1, sizeof *info->buffer);
|
||||||
memcpy (line, info->buffer, sizeof *info->buffer * len);
|
memcpy (line, info->buffer, sizeof *info->buffer * len);
|
||||||
|
|
||||||
if (*line)
|
if (*line)
|
||||||
@@ -762,7 +762,7 @@ input_el_hide (struct input *input)
|
|||||||
int len = info->lastchar - info->buffer;
|
int len = info->lastchar - info->buffer;
|
||||||
int point = info->cursor - info->buffer;
|
int point = info->cursor - info->buffer;
|
||||||
|
|
||||||
wchar_t *line = calloc (sizeof *info->buffer, len + 1);
|
wchar_t *line = xcalloc (len + 1, sizeof *info->buffer);
|
||||||
memcpy (line, info->buffer, sizeof *info->buffer * len);
|
memcpy (line, info->buffer, sizeof *info->buffer * len);
|
||||||
el_cursor (self->editline, len - point);
|
el_cursor (self->editline, len - point);
|
||||||
el_wdeletestr (self->editline, len);
|
el_wdeletestr (self->editline, len);
|
||||||
@@ -1225,7 +1225,7 @@ await_try_cancel (struct app_context *ctx)
|
|||||||
|
|
||||||
static void on_config_attribute_change (struct config_item *item);
|
static void on_config_attribute_change (struct config_item *item);
|
||||||
|
|
||||||
static struct config_schema g_config_connection[] =
|
static const struct config_schema g_config_connection[] =
|
||||||
{
|
{
|
||||||
{ .name = "tls_ca_file",
|
{ .name = "tls_ca_file",
|
||||||
.comment = "OpenSSL CA bundle file",
|
.comment = "OpenSSL CA bundle file",
|
||||||
@@ -1236,7 +1236,7 @@ static struct config_schema g_config_connection[] =
|
|||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct config_schema g_config_attributes[] =
|
static const struct config_schema g_config_attributes[] =
|
||||||
{
|
{
|
||||||
#define XX(x, y, z) { .name = y, .comment = z, .type = CONFIG_ITEM_STRING, \
|
#define XX(x, y, z) { .name = y, .comment = z, .type = CONFIG_ITEM_STRING, \
|
||||||
.on_change = on_config_attribute_change },
|
.on_change = on_config_attribute_change },
|
||||||
@@ -4076,11 +4076,10 @@ main (int argc, char *argv[])
|
|||||||
setlocale (LC_CTYPE, "");
|
setlocale (LC_CTYPE, "");
|
||||||
|
|
||||||
char *encoding = nl_langinfo (CODESET);
|
char *encoding = nl_langinfo (CODESET);
|
||||||
#ifdef __linux__
|
|
||||||
// XXX: not quite sure if this is actually desirable
|
// XXX: not quite sure if this is actually desirable
|
||||||
// TODO: instead retry with JSON_ENSURE_ASCII
|
// TODO: instead retry with JSON_ENSURE_ASCII
|
||||||
encoding = xstrdup_printf ("%s//TRANSLIT", encoding);
|
if (ICONV_ACCEPTS_TRANSLIT)
|
||||||
#endif // __linux__
|
encoding = xstrdup_printf ("%s//TRANSLIT", encoding);
|
||||||
|
|
||||||
if ((g_ctx.term_from_utf8 = iconv_open (encoding, "UTF-8"))
|
if ((g_ctx.term_from_utf8 = iconv_open (encoding, "UTF-8"))
|
||||||
== (iconv_t) -1
|
== (iconv_t) -1
|
||||||
|
|||||||
2
liberty
2
liberty
Submodule liberty updated: d71c47f8ce...1930f138d4
Reference in New Issue
Block a user