From 09649615575b7a3286892a433479512df2a7eb40 Mon Sep 17 00:00:00 2001 From: iphydf Date: Mon, 23 Mar 2020 00:46:02 +0000 Subject: [PATCH] Migrate format-source script to new apidsl web app. This one is unfortunately a little more complicated to use. I may add a simpler API later, but for now, it's JSON-based (because I couldn't get binary data to work without it getting mangled somewhere along the way - JSON is at least text-transport-safe). --- other/astyle/format-source | 24 ++++++++++++++++++++++-- toxcore/tox.api.h | 10 +++++----- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/other/astyle/format-source b/other/astyle/format-source index c2238841..7fa8b677 100755 --- a/other/astyle/format-source +++ b/other/astyle/format-source @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -ex @@ -30,8 +30,28 @@ if ! which "$APIDSL"; then fi fi +TO_JSON='s/\\/\\\\/g;s/\n/\\n/g;s/"/\\"/g;s/^(.*)$/"$1"/' +FROM_JSON='s/\\"/"/g;s/^"(.*)"$/$1/;s/\\\\/\\/g;s/\\n/\n/g' + +apidsl_request() { + TMPFILE=$(mktemp /tmp/apidsl.XXXXXX) + curl -o "$TMPFILE" -X POST --data @<( + echo '["Request",'; + cat $2; + echo ']') https://apidsl2.herokuapp.com/$1 + if grep '\[1,"' "$TMPFILE" > /dev/null; then + echo "Error: $(grep -o '".*"' /tmp/apidsl-$$ | perl -0777 -pe "$FROM_JSON")" >&2 + rm "$TMPFILE" + exit 1 + fi + perl -0777 -pe 's/^\[0,(.*)\]$/$1/' "$TMPFILE" + rm "$TMPFILE" +} + apidsl_curl() { - curl -X POST --data-binary @"$1" https://apidsl.herokuapp.com/apidsl + apidsl_request "c" <( + apidsl_request "parse" <( + perl -0777 -pe "$TO_JSON" $1)) | perl -0777 -pe "$FROM_JSON" } # Check if apidsl generated sources are up to date. diff --git a/toxcore/tox.api.h b/toxcore/tox.api.h index c0901d0a..87c3219a 100644 --- a/toxcore/tox.api.h +++ b/toxcore/tox.api.h @@ -2279,9 +2279,9 @@ namespace conference { namespace peer { /** - * Return the number of online peers in the conference. The unsigned - * integers less than this number are the valid values of peer_number for - * the functions querying these peers. Return value is unspecified on + * Return the number of online peers in the conference. The unsigned + * integers less than this number are the valid values of peer_number for + * the functions querying these peers. Return value is unspecified on * failure. */ const uint32_t count(uint32_t conference_number) @@ -2330,8 +2330,8 @@ namespace conference { namespace offline_peer { /** - * Return the number of offline peers in the conference. The unsigned - * integers less than this number are the valid values of offline_peer_number for + * Return the number of offline peers in the conference. The unsigned + * integers less than this number are the valid values of offline_peer_number for * the functions querying these peers. Return value is unspecified on failure. */ const uint32_t count(uint32_t conference_number)