mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
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).
This commit is contained in:
parent
40dd88596e
commit
0964961557
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user