Commit 35c3f8bf authored by IOhannes m zmölnig's avatar IOhannes m zmölnig

New upstream version 1.4.2

parent ab5e13be
language: c
env:
global:
- PDVERSION='0.47-1'
- secure: "DA85V8jBW8C6n6z9qiGufU1BK1atVUsvnceHIuf0pG64faZBNLg93J3SfyV2/NN0C4AVAaVHSM+F8XR8Ba8GdxHbW8OGJR+vcgr6ZFg5Qai/xmMJm5MfcR/oPFj8nuMnT61rb6Jm5QpuURRwAjio+x7wCHQJkkpH1TiQF9mV2Tk="
matrix:
include:
- env: PLATFORM='linux64'
os: linux
dist: trusty
sudo: required
compiler: gcc
- env: PLATFORM='linux32' CHROOTDIR='/opt/crosscompilation'
os: linux
dist: trusty
sudo: required
compiler: gcc
- env: PLATFORM='osx'
os: osx
- env: PLATFORM='windows'
os: linux
dist: trusty
sudo: required
compiler: gcc
before_install: bash ./travis-build/${PLATFORM}_before_install.sh
script: bash ./travis-build/${PLATFORM}_script.sh
after_success: bash ./travis-build/${PLATFORM}_pack.sh
deploy:
skip_cleanup: true
provider: script
script: bash ./travis-build/upload.sh
on:
all_branches: true
Changelog
---------
1.4.2: Argo in Shipyard
- Update of build scripts and documentation
- Usage of CI for build
1.4.1: Orpheus's Lyre
- Bug fix:
-- [json-encode] and [json-decode]: Correctly freeing JSON object
......
......@@ -21,6 +21,11 @@ define forWindows
-liconv -lnettle -lssh2 -lgcrypt -lgpg-error -lcrypto \
-lws2_32 -lgdi32 -lcrypt32 -lz
cflags += -mthreads -DCURL_STATICLIB
datafiles += cacert.pem
endef
define forDarwin
datafiles += cacert.pem *.dylib
endef
lib.setup.sources = src/purest_json
......@@ -55,4 +60,4 @@ deken:
cd "$(deken.tmp)"; \
$(deken.pack) "$(deken.file).$(deken.ext)" "$(deken.folder)"; \
rm -rf "$(deken.folder)"; \
mv "$(deken.file).$(deken.ext)" ..
mv "$(deken.file).$(deken.ext)" ..;
......@@ -49,11 +49,15 @@ Downloads are available via [deken](https://github.com/pure-data/deken)
which is included in Pd since version 0.47. Packages for Debian and Ubuntu
are available as `pd-purest-json`.
## Binary downloads
## Downloads of development versions
Binary packages can be found at http://ix.residuum.org/pd/purest_json.html
For each commit, a build in [Travis](https://travis-ci.org/residuum/PuRestJson)
is triggered. These builds generate deken-like packages, that are available
from https://ssl-account.com/cloud.residuum.org/index.php/s/380C60JAabnO7jk
Currently only Windows and Linux packages are available.
The format for the files is `<Travis-build-number>_<Date-in-YYYY-MM-DD>_<dekenfilename>`.
Those downloads may not work, but represent the current state of development.
## How to build PuREST JSON
......
#!/usr/bin/python
# Converts the project Wiki to html and adds it as manual.
#
# Adapted from https://gist.github.com/mrexmelle/659abc02ae1295d60647
from grip import export
from os import listdir, rename
from os.path import splitext
import os
import subprocess
import sys
from bs4 import BeautifulSoup
dirName = "../PuRestJson.wiki/"
exportDir = "manual/"
wikiDir = '/tmp/PuRestJson.wiki/'
exportDir = 'manual/'
for fileName in listdir(dirName):
if fileName.endswith(".md"):
export(dirName + fileName, False, None, None, None, True, True, False, exportDir + splitext(fileName)[0] + ".html")
if len(sys.argv) > 1:
exportDir = sys.argv[1]
if len(sys.argv) > 2:
wikiDir = sys.argv[2]
rename(exportDir + "Home.html", exportDir + "index.html")
print 'Input directory: ', wikiDir
print 'Output directory: ', exportDir
# rename all files containing '[' and ']' in names,
# because Windows does not like those.
for f in os.listdir(wikiDir):
cleaned = f.replace('[', '').replace(']', '').replace(':', '')
if f != cleaned:
os.rename(wikiDir + f, wikiDir + cleaned)
# convert md files one-by-one.
for f in os.listdir(wikiDir):
if f.endswith('.md'):
print 'Converting: ', f
baseFile = os.path.splitext(os.path.basename(f))[0];
htmlFile = baseFile + '.html'
subprocess.call(['grip', wikiDir + f, '--export', '--no-inline',
exportDir + htmlFile])
# edit links to css, images and other pages.
htmlDoc = open(exportDir + htmlFile)
soup = BeautifulSoup(htmlDoc, 'lxml')
for s in soup.findAll('link'):
s.extract()
css = soup.new_tag('link')
css.attrs['rel'] = 'stylesheet'
css.attrs['href'] = 'style.css'
soup.head.append(css)
# internal links.
for a in soup.findAll('a'):
if a['href'].startswith('https://github.com/residuum/PuRestJson/wiki/'):
a['href'] = a['href']\
.replace('https://github.com/residuum/PuRestJson/wiki/', '')\
.replace('%5B', '')\
.replace('%5D', '')\
.replace(':', '') + '.html'
# images with link to itself.
for img in soup.findAll('img'):
if img['src'].startswith('https://camo.githubusercontent.com'):
img['src'] = img['data-canonical-src']\
.replace('https://raw.github.com/residuum/PuRestJson/master/manual/','')
del img['data-canonical-src']
a = img.parent
del a['href']
# write changes back to file
htmlDoc.close()
html = soup.prettify('utf-8')
with open(exportDir + htmlFile, 'w') as edited:
edited.write(html)
os.rename(exportDir + "Home.html", exportDir + "index.html")
#!/bin/sh
#
# This script finds all of the dependecies from Fink and included them
# into current folder so that it becomes a libdir to be installed into
# ~/Library/Pd or /Library/Pd <hans@eds.org>
if [ -z "$1" ]; then
PD_APP_LIB=`pwd`
else
PD_APP_LIB=$1
fi
echo " "
for pd_darwin in `find . -name '*.pd_darwin'`; do
LIBS=`otool -L $pd_darwin | sed -n 's|.*/sw/lib/\(.*\.dylib\).*|\1|p'`
if [ "x$LIBS" != "x" ]; then
echo "`echo $pd_darwin | sed 's|.*/\(.*\.pd_darwin$\)|\1|'` is using:"
for lib in $LIBS; do
echo " $lib"
install -vp /sw/lib/$lib $PD_APP_LIB
new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'`
install_name_tool -id @loader_path/$new_lib $PD_APP_LIB/$new_lib
install_name_tool -change /sw/lib/$lib @loader_path/$new_lib $pd_darwin
done
echo " "
fi
done
# needs to run 3 times:
# - once to start the process
# - once to catch dylibs that depend on dylibs
# - once again because ... three is a magic number, or something like that
for n in {1..3}; do
for dylib in $PD_APP_LIB/*.dylib; do
LIBS=`otool -L $dylib | sed -n 's|.*/sw/lib/\(.*\.dylib\).*|\1|p'`
if [ "x$LIBS" != "x" ]; then
echo "`echo $dylib | sed 's|.*/\(.*\.dylib\)|\1|'` is using:"
for lib in $LIBS; do
echo " $lib"
new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'`
if [ -e $PD_APP_LIB/$new_lib ]; then
echo "$PD_APP_LIB/$new_lib already exists, skipping copy."
else
install -vp /sw/lib/$lib $PD_APP_LIB
fi
install_name_tool -id @loader_path/$new_lib $PD_APP_LIB/$new_lib
install_name_tool -change /sw/lib/$lib @loader_path/$new_lib $dylib
done
echo " "
fi
done
done
#!/bin/sh
#
# This script finds all of the dependecies from Fink and included them
# into current folder so that it becomes a libdir to be installed into
# ~/Library/Pd or /Library/Pd <hans@eds.org>
if [ -z "$1" ]; then
PD_APP_LIB=`pwd`
else
PD_APP_LIB=$1
fi
echo " "
for pd_darwin in `find . -name '*.pd_darwin'`; do
LIBS=`otool -L $pd_darwin | sed -n 's|.*/usr/local/opt/\(.*\.dylib\).*|\1|p'`
if [ "x$LIBS" != "x" ]; then
echo "`echo $pd_darwin | sed 's|.*/\(.*\.pd_darwin$\)|\1|'` is using:"
for lib in $LIBS; do
echo " $lib"
install -vp /usr/local/opt/$lib $PD_APP_LIB
new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'`
install_name_tool -id @loader_path/$new_lib $PD_APP_LIB/$new_lib
install_name_tool -change /usr/local/opt/$lib @loader_path/$new_lib $pd_darwin
done
echo " "
fi
done
for dylib in $PD_APP_LIB/*.dylib; do
LIBS=`otool -L $dylib | sed -n 's|.*/usr/local/opt/\(.*\.dylib\).*|\1|p'`
if [ "x$LIBS" != "x" ]; then
echo "`echo $dylib | sed 's|.*/\(.*\.dylib\)|\1|'` is using:"
for lib in $LIBS; do
echo " $lib"
new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'`
if [ -e $PD_APP_LIB/$new_lib ]; then
echo "$PD_APP_LIB/$new_lib already exists, skipping copy."
else
install -vp /usr/local/opt/$lib $PD_APP_LIB
fi
install_name_tool -id @loader_path/$new_lib $PD_APP_LIB/$new_lib
install_name_tool -change /usr/local/opt/$lib @loader_path/$new_lib $dylib
done
echo " "
fi
done
# run it one more time to catch dylibs that depend on dylibs
for dylib in $PD_APP_LIB/*.dylib; do
LIBS=`otool -L $dylib | sed -n 's|.*/usr/local/opt/\(.*\.dylib\).*|\1|p'`
if [ "x$LIBS" != "x" ]; then
echo "`echo $dylib | sed 's|.*/\(.*\.dylib\)|\1|'` is using:"
for lib in $LIBS; do
echo " $lib"
new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'`
if [ -e $PD_APP_LIB/$new_lib ]; then
echo "$PD_APP_LIB/$new_lib already exists, skipping copy."
else
install -vp /usr/local/opt/$lib $PD_APP_LIB
fi
install_name_tool -id @loader_path/$new_lib $PD_APP_LIB/$new_lib
install_name_tool -change /usr/local/opt/$lib @loader_path/$new_lib $dylib
done
echo " "
fi
done
# seems like we need it one last time! phew...
for dylib in $PD_APP_LIB/*.dylib; do
LIBS=`otool -L $dylib | sed -n 's|.*/usr/local/opt/\(.*\.dylib\).*|\1|p'`
if [ "x$LIBS" != "x" ]; then
echo "`echo $dylib | sed 's|.*/\(.*\.dylib\)|\1|'` is using:"
for lib in $LIBS; do
echo " $lib"
new_lib=`echo $lib | sed 's|.*/\(.*\.dylib\)|\1|'`
if [ -e $PD_APP_LIB/$new_lib ]; then
echo "$PD_APP_LIB/$new_lib already exists, skipping copy."
else
install -vp /usr/local/opt/$lib $PD_APP_LIB
fi
install_name_tool -id @loader_path/$new_lib $PD_APP_LIB/$new_lib
install_name_tool -change /usr/local/opt/$lib @loader_path/$new_lib $dylib
done
echo " "
fi
done
class Liboauth < Formula
desc "C library for the OAuth Core RFC 5849 standard"
homepage "http://liboauth.sourceforge.net"
url "https://downloads.sourceforge.net/project/liboauth/liboauth-1.0.3.tar.gz"
sha256 "0df60157b052f0e774ade8a8bac59d6e8d4b464058cc55f9208d72e41156811f"
revision 1
bottle do
cellar :any
sha256 "3d5b00cf3fc8ed4032b1e5e618ab0bfbc962414373ac9bf45a5ee883a4277a07" => :yosemite
sha256 "9bbd1a6e6cb7c089f3971858b84674545f4125e088072399bace245c29562f03" => :mavericks
sha256 "6a022751288301f6cca5cbce0022f8bac7b225df7adfd5b1cbb11a29f01c75ad" => :mountain_lion
end
depends_on "openssl"
option :universal
def install
ENV['CC']="gcc -arch i386 -arch x86_64"
ENV['CXX']="g++ -arch i386 -arch x86_64"
ENV['CPP']="gcc -E"
ENV['CXXCPP']="g++ -E"
ENV.universal_binary if build.universal?
system "./configure", "--disable-dependency-tracking",
"--prefix=#{prefix}",
"--disable-curl"
system "make", "install"
end
end
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>PuREST JSON - Basic Usage</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="page">
<div class="preview-page">
<div class="container">
<div class="repository-with-sidebar repo-container ">
<div class="repository-content context-loader-container">
<div id="readme" class="boxed-group flush clearfix announce instapaper_body md">
<h3>
<span class="octicon octicon-book"></span>
Basic Usage
</h3>
<div class="markdown-body entry-content">
<p><a href="index.html">Home</a></p>
<p>The following examples are in the patch <code>examples/purest-json-test.pd</code>.</p>
<h2>Querying Webservices</h2>
<p>You can use <code>[rest]</code> to query webservices. I will explain this querying the history of the Makefile in the repository. You will see the handling of arrays in this example.</p>
<p><img alt="Webservice Example" src="webservice-example.png" /></p>
<p>As you can see, the webservice from Github returns an object with only one array. This array is then parsed by an instance of [json-decode].</p>
<p><code>data: list commits [ { "parents": [ { "id": "32656d8170c9660909510100999ae09f749bc9e0" } ]\, "author": { "name": "Thomas Mayer"\, "login": "residuum"\, "email": "thomas@residuum.org" }\, "url": "\\/residuum\\/PuRestJson\\/commit\\/121eee893155d0270d1ce3ad78e5162d0f4cf376"\, "id": "121eee893155d0270d1ce3ad78e5162d0f4cf376"\, "committed_date": "2011-09-21T12:13:36-07:00"\, "authored_date": "2011-09-21T12:13:36-07:00"\, "message": "Used Pd-extended library template"\, "tree": "71022e1263b04d1d5636c5d7c16b6245ce209417"\, "committer": { "name": "Thomas Mayer"\, "login": "residuum"\, "email": "thomas@residuum.org" } }\, { "parents": [ { "id": "ea2b4a170392549c286a784a0a137ad6402758d2" } ]\, "author": { "name": "Thomas Mayer"\, "login": "residuum"\, "email": "thomas@residuum.org" }\, "url": "\\/residuum\\/PuRestJson\\/commit\\/be8d04384403afd836ce5cd8d008ac8075d32b18"\, "id": "be8d04384403afd836ce5cd8d008ac8075d32b18"\, "committed_date": "2011-09-15T15:11:44-07:00"\, "authored_date": "2011-09-15T15:11:44-07:0*</code></p>
<p>Each array member is then parsed individually by [json-decode], i.e. each member of the object is then output as list on the left outlet, followed by a bang on the right outlet.</p>
<div class="highlight"><pre>array-decode: list parents [ { &quot;id&quot;: &quot;32656d8170c9660909510100999ae09f749bc9e0&quot; } ]
array-decode: list author { &quot;name&quot;: &quot;Thomas Mayer&quot;\, &quot;login&quot;: &quot;residuum&quot;\, &quot;email&quot;: &quot;thomas@residuum.org&quot; }
array-decode: list url /residuum/PuRestJson/commit/121eee893155d0270d1ce3ad78e5162d0f4cf376
array-decode: list id 121eee893155d0270d1ce3ad78e5162d0f4cf376
array-decode: list committed_date 2011-09-21T12:13:36-07:00
array-decode: list authored_date 2011-09-21T12:13:36-07:00
array-decode: list message Used Pd-extended library template
array-decode: list tree 71022e1263b04d1d5636c5d7c16b6245ce209417
array-decode: list committer { &quot;name&quot;: &quot;Thomas Mayer&quot;\, &quot;login&quot;: &quot;residuum&quot;\, &quot;email&quot;: &quot;thomas@residuum.org&quot; }
array-done: bang
array-decode: list parents [ { &quot;id&quot;: &quot;ea2b4a170392549c286a784a0a137ad6402758d2&quot; } ]
array-decode: list author { &quot;name&quot;: &quot;Thomas Mayer&quot;\, &quot;login&quot;: &quot;residuum&quot;\, &quot;email&quot;: &quot;thomas@residuum.org&quot; }
array-decode: list url /residuum/PuRestJson/commit/be8d04384403afd836ce5cd8d008ac8075d32b18
array-decode: list id be8d04384403afd836ce5cd8d008ac8075d32b18
array-decode: list committed_date 2011-09-15T15:11:44-07:00
array-decode: list authored_date 2011-09-15T15:11:44-07:00
array-decode: list message Removed doxygen.
array-decode: list tree f4b2f6ea08b6dc656c016413d9ca6425da98b974
array-decode: list committer { &quot;name&quot;: &quot;Thomas Mayer&quot;\, &quot;login&quot;: &quot;residuum&quot;\, &quot;email&quot;: &quot;thomas@residuum.org&quot; }
array-done: bang
...
</pre></div>
<h2>Using CouchDB</h2>
<p>This example will show the usage of diverse HTTP request methods, GET, PUT, and DELETE. You will also see, how you can add data to PUT requests.</p>
<p><img alt="CouchDB Example" src="couchdb-example.png" /></p>
<p>A CouchDB running on the same computer is implied.</p>
<p>Here is the output from the main example in examples/purest-json-test.pd with explanations.</p>
<p>First, we create the database and get info about the database:</p>
<div class="highlight"><pre>couchdb return: list ok 1
couchdb return: list db_name test
couchdb return: list doc_count 0
couchdb return: list doc_del_count 0
couchdb return: list update_seq 0
couchdb return: list purge_seq 0
couchdb return: list compact_running 0
couchdb return: list disk_size 79
couchdb return: list instance_start_time 1.31733e+15
couchdb return: list disk_format_version 5
couchdb return: list committed_update_seq 0
</pre></div>
<p>After that, we build a JSON document and store it in the database:</p>
<div class="highlight"><pre>json-encoded data: symbol \{ &quot;value&quot;: &quot;440&quot;\\, &quot;duration&quot;: &quot;1000&quot;\\, &quot;start&quot;: &quot;10&quot;\\, &quot;name&quot;: &quot;first note&quot;\\, &quot;var&quot;: [ &quot;yabba&quot;\\, &quot;dabba&quot;\\, &quot;doo&quot; ]\\, &quot;on&quot;: &quot;TRUE&quot; \}
decode json data: list value 440
decode json data: list duration 1000
decode json data: list start 10
decode json data: list name first note
decode json data: list var [ &quot;yabba&quot;\\, &quot;dabba&quot;\\, &quot;doo&quot; ]
decode json data: list on 1
couchdb return: list ok 1
couchdb return: list id 1
couchdb return: list rev 1-b7a3cb13c20812a4c7845e9a86f92099`
</pre></div>
<p>Then we query the database for the stored document and use it to drive a simple ramp:</p>
<div class="highlight"><pre><span class="n">id</span><span class="o">:</span> <span class="mi">1</span>
<span class="n">couchdb</span> <span class="k">return</span><span class="o">:</span> <span class="n">list</span> <span class="n">_id</span> <span class="mi">1</span>
<span class="n">couchdb</span> <span class="k">return</span><span class="o">:</span> <span class="n">list</span> <span class="n">_rev</span> <span class="mi">1</span><span class="o">-</span><span class="n">b7a3cb13c20812a4c7845e9a86f92099</span>
<span class="n">couchdb</span> <span class="k">return</span><span class="o">:</span> <span class="n">list</span> <span class="n">value</span> <span class="mi">440</span>
<span class="n">couchdb</span> <span class="k">return</span><span class="o">:</span> <span class="n">list</span> <span class="n">duration</span> <span class="mi">1000</span>
<span class="n">couchdb</span> <span class="k">return</span><span class="o">:</span> <span class="n">list</span> <span class="n">start</span> <span class="mi">10</span>
<span class="n">name</span><span class="o">:</span> <span class="n">first</span> <span class="n">note</span>
<span class="n">couchdb</span> <span class="k">return</span><span class="o">:</span> <span class="n">list</span> <span class="n">name</span> <span class="n">first</span> <span class="n">note</span>
<span class="n">couchdb</span> <span class="k">return</span><span class="o">:</span> <span class="n">list</span> <span class="n">var</span> <span class="o">[</span> <span class="s2">&quot;yabba&quot;</span><span class="o">\\,</span> <span class="s2">&quot;dabba&quot;</span><span class="o">\\,</span> <span class="s2">&quot;doo&quot;</span> <span class="o">]</span>
<span class="n">couchdb</span> <span class="k">return</span><span class="o">:</span> <span class="n">list</span> <span class="n">on</span> <span class="mi">1</span>
</pre></div>
<p>In the end we delete the database:</p>
<div class="highlight"><pre>couchdb return: list ok 1
</pre></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div>&nbsp;</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>PuREST JSON - Compilation</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="page">
<div class="preview-page">
<div class="container">
<div class="repository-with-sidebar repo-container ">
<div class="repository-content context-loader-container">
<div id="readme" class="boxed-group flush clearfix announce instapaper_body md">
<h3>
<span class="octicon octicon-book"></span>
Compilation
</h3>
<div class="markdown-body entry-content">
<p><a href="index.html">Home</a></p>
<p>Compilation should be working on Linux, Windows with MinGW and Mac OS X. You will need header files of Puredata, as well as <a href="http://curl.haxx.se/">libcurl</a>, <a href="https://github.com/json-c/json-c">json-c</a>, and <a href="http://liboauth.sourceforge.net/">liboauth</a>.</p>
<p>The package build script is based on the <a href="https://puredata.info/docs/developer/LibraryTemplate">Pd library template</a>.</p>
<p>With version 0.11, json-c have changed the library path and name. If your system has an older version of json-c, you have to apply the patch <code>old-json-c-version.patch</code> via <code>patch -p1 < old-json-c-version.patch</code>. </p>
<p>When you use static versions of libcurl, i.e. on Windows and Mac OS X, you will need the file <a href="http://curl.haxx.se/docs/caextract.html">cacert.pem from the libcurl website</a>. Put the downloaded file in the directory of PuREST JSON.</p>
<p>If you have gotten the source code from git, you will first have to init the <a href="http://troydhanson.github.io/uthash/">uthash</a> submodule by running <code>git submodule update --init</code>.</p>
<h2>Linux</h2>
<p>You need build-essentials, header files for puredata, libjson0, libcurl4, liboauth. If you have Debian or a derivative (e.g. Ubuntu, Linux Mint), you can install the build utils and needed headers with <code>apt-get install build-essentials puredata-dev libjson0-dev libcurl4-openssl-dev liboauth-dev</code>. If you are not root, prefix the command with <code>sudo</code>.</p>
<p>Drop the sources in a directory and run <code>make</code>. You will get files with a suffix of pd_linux for each object (json-decode.pd_linux, json-encode.pd_linux, rest.pd_linux, oauth.pd_linux). These are needed to use the library.</p>
<h3>Building a deb package (Optional for Debian Based Distributions)</h3>
<p>Install the package devscript with <code>apt-get install devscript</code>.</p>
<p>Run <code>make dpkg-deb</code>, you will get a deb file in the parent folder. The resulting package will have the following name structure: <code>pd-purest-json_{version}_{debian_architecture}.deb</code>, e.g. <code>pd-purest-json_0.11_i386.deb</code>. Install this file with <code>dpkg -i pd-purest-json_0.11_i386.deb</code>.</p>
<h2>Windows with MinGW</h2>
<p><em>This section is outdated and probably will not work</em></p>
<p>You need to install MinGW on your computer. Follow the instructions on <a href="http://puredata.info/docs/developer/WindowsMinGW">http://puredata.info/docs/developer/WindowsMinGW</a> leaving out Cygwin. If you do not plan to compile Pd-extended, you may stop after following the instructions for "MinGW extras".</p>
<p>Install the additional packages:
* pthreads-w32, from the MinGW shell via <code>mingw-get install pthreads-w32</code>.</p>
<ul>
<li>
<p>libcurl, from <a href="http://curl.haxx.se/download.html#Win32">http://curl.haxx.se/download.html#Win32</a> Choose Win32 generic, libcurl</p>
</li>
<li>
<p>json-c, from <a href="http://blog.stranadurakov.com/projects/mingw-libraries/">http://blog.stranadurakov.com/projects/mingw-libraries/</a> or use the latest json-c version from github (see above) and build it yourself.</p>
</li>
<li>
<p>(TODO: how-to use liboauth)</p>
</li>
</ul>
<p>Extract the latter zip files and put the contents in the correct MinGW folders.</p>
<p>If you encounter an error with two definition of boolean, delete the line <code>typedef int boolean;</code> from the file %MinGW%/include/json/json_object.h.</p>
<p>Navigate to the folder of purest_json in MinGW Shell and run <code>make</code>. You will get four dll files (json-decode.dll, json-encode.dll, rest-json.dll, libpurest_json.dll).</p>
<p>To use the library, you will also need the dll from the libcurl download, and rename libcurl.dll to libcurl-4.dll. This will not run on current releases (Pd-extended 0.42 or Pd vanilla 0.43), only on <a href="http://blinky.at.or.at:8888/auto-build/">Pd-extended 0.43 auto-builds</a>.</p>
<h2>Compilation on Mac OS X</h2>
<p>I do not have a Mac available, so the following instructions are probably not entirely correct:</p>
<h3>Using Fink</h3>
<p>You will need to install <a href="http://pdb.finkproject.org/pdb/package.php/json-c">json-c</a>, <a href="http://pdb.finkproject.org/pdb/package.php/libcurl4">libcurl4</a> and <a href="http://pdb.finkproject.org/pdb/package.php/libcurl4-shibs">libcurl4-shibs</a> via <a href="http://www.finkproject.org/">Fink</a> by running</p>
<p><code>fink install json-c libcurl4 libcurl4-shibs</code> </p>
<p>You also need <a href="http://liboauth.sourceforge.net/index.html">liboauth</a>. Download the source code, extract the archive (e.g. from the command line with <code>tar -xf liboauth-1.0.0.tar.gz</code>) and run</p>
<p><code>./configure</code></p>
<p><code>make</code></p>
<p><code>make install</code></p>
<p>to build and install liboauth.</p>
<p>You will need to set up part of the <a href="https://puredata.info/docs/developer/MacOSXFink">Pd build environment on your computer</a></p>
<p>Run <code>make</code> in the purest_json folder.</p>
<p>If the build succeeded, run <code>./embed-MacOSX-dependencies.sh</code> to embed the dependencies in the shared library.</p>
<p>On the Mac OS X system that runs Pd, you will need SSL certificates to verify the signatures. You can <a href="http://curl.haxx.se/docs/caextract.html">download certificates in PEM format from cURL website</a>. Copy the file <code>cacert.pem</code> in the same directory as rest.pd_darwin and oauth.pd_darwin, as the library expects the file to reside there.</p>
<h3>Using Homebrew</h3>
<p><a href="http://brew.sh/">Homebrew</a> looks like the newer and recommended way to get third party libraries on Mac OS X. This has not been tested, but the basic steps are outlined here anyway.</p>
<p>The dependencies should be installable by running</p>
<p><code>brew install json-c curl liboauth</code> </p>
<p>After <a href="https://puredata.info/docs/developer">setting up the build environment for Pd</a>, you should be able to build PuREST JSON by running <code>make</code> in the purest_json folder.</p>
<p>If the build succeeded, run <code>./embed-MacOSX-dependencies.sh</code> to embed the dependencies in the shared library.</p>
<h2>Cross-compilation for Windows on UNIX-like systems (Linux / *BSD / Mac OS X) with MXE</h2>
<p>Get the development version of MXE from <a href="https://github.com/mxe/mxe">their Github repository</a> and setup MXE, so that the cross compilation tools are in your PATH environmental variable.</p>
<p>Build the required libraries by running <code>make curl json-c liboauth pthreads</code>.</p>
<p>You will need a source of Pd, and pd.dll from a Windows version. Put them in folders with the following structure:</p>
<div class="highlight"><pre>pd/src/(source files including m_pd.h)
pd/bin/pd.dll
</pre></div>
<p>Now run <code>make</code> with some environmental variables to tell the compiler to use the cross compiler, and where to find the Pd source and pd.dll. Here is an example from my setup:</p>
<div class="highlight"><pre>make \
UNAME=MINGW \
CROSS_PATH=/home/thomas/code/mxe/usr/ \
CROSS=i686-pc-mingw32 \
PD_PATH=/home/thomas/code/pd
</pre></div>
<p>Good luck.</p>
<p>On the Windows system that runs Pd, you will need SSL certificates to verify the signatures. You can <a href="http://curl.haxx.se/docs/caextract.html">download certificates in PEM format from cURL website</a>. Copy the file <code>cacert.pem</code> in the same directory as rest.dll and oauth.dll, as the library expects the file to reside there.</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div>&nbsp;</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>PuREST JSON - Contributing and Code Documentation</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="page">
<div class="preview-page">
<div class="container">
<div class="repository-with-sidebar repo-container ">
<div class="repository-content context-loader-container">
<div id="readme" class="boxed-group flush clearfix announce instapaper_body md">
<h3>
<span class="octicon octicon-book"></span>
Contributing and Code Documentation
</h3>
<div class="markdown-body entry-content">
<p><a href="index.html">Home</a></p>
<p>If you want to contribute to the development of the software, every help is much appreciated. </p>
<h2>Bugs And Wishes</h2>
<p>If you found any bugs in the software or would like a feature implemented, please open a new issue on <a href="https://github.com/residuum/PuRestJson/issues">the bug tracker</a> or send an email to <a href="mailto:purest-json-bugs@ix.residuum.org"><a href="mailto:purest-json-bugs@ix.residuum.org">purest-json-bugs@ix.residuum.org</a></a>.</p>
<h2>Development</h2>
<p>Feel free to fork the project and submit pull requests, if you want to implement some features or fix some bugs. If possible, please open a new issue on <a href="https://github.com/residuum/PuRestJson/issues">the bug tracker</a>, so that noone else tries to fix or implement the same issue.</p>
<p>If you need some help with writing externals for Pd, read the <a href="http://iem.at/pd/externals-HOWTO/">excellent how-to on that subject</a>.</p>
<h3>Code structure</h3>
<p>The whole project in written in C99. C code is in subfolder <code>src/</code>. Every object and the library itself has a .c and a corresponding .h file. <code>purest_json.c</code> is only used to setup the library. <code>#define</code>s are done only in the .h files. <code>purest_json.h</code> is <code>#include</code>d in all objects.</p>
<p>Every object contains functions with a structure of <code>&lt;OBJECT&gt;_&lt;FUNCTION&gt;</code>with the exception of setup functions. Only functions that Pd needs to call are exported, and only exported functions are declared in the .h file, all other functions are static.</p>
<p>Shared functions used by more than one object are in directory <code>src/inc</code>. The functions are prefixed with the name of the file, e.g. <code>ctw.c</code> includes functions named <code>ctw_&lt;FUNCTION&gt;</code>.</p>
<h3>Order of Functions And Declarations in .c Files</h3>
<ol>
<li><code>#include</code>s</li>
<li><code>t_class</code> declaration</li>
<li><code>struct</code> declarations</li>
<li>prototypes for static functions</li>
<li>implementation of static functions</li>
<li>setup functions</li>
<li>functions reacting to messages</li>
<li>constructor function</li>
<li>destructor function</li>
</ol>
<h3>Names of Setup Functions</h3>
<p>When Pd tries to load an object, it is looking for the file with the correct platform specific suffix (.pd_linux, .pd_darwin, .dll, .pd_freebsd) and the same name, e.g. to create <code>[json-encode]</code>, Pd on Windows looks for a file <code>json-encode.dll</code>.</p>
<p>In this library file, Pd looks for a setup function according, depending on the name of the object:</p>
<ul>
<li>If the name contains a special character, that cannot be used in a C symbol (<code>-</code>, <code>~</code>, <code>.</code>, etc.), then this special character is converted to a hex representation using <code>sprintf(symname+i, "0x%02x", c);</code> where <code>c</code> is the special character. This resulting name is prefixed by <code>setup_</code>. So the function for creating <code>[json-encode]</code> must be called <code>setup_json0x2dencode</code>.</li>
<li>If the name can be converted to a C symbol, then the setup function must be the object name suffixed with <code>_setup</code>. So the function for creating <code>[urlparams]</code> must be called <code>urlparams_setup</code>.</li>
</ul>
<h3>Names of Other Exported Functions</h3>
<p>If an object has a hyphen (<code>-</code>) in its name, then this is replaced by an underscore (<code>_</code>)</p>
<ul>
<li>Creation functions: <code>&lt;OBJECT&gt;_new</code>, e.g. <code>rest_new</code>.</li>
<li>Destruction functions: <code>&lt;OBJECT&gt;_free</code>, e.g. <code>rest_free</code>. Not every object needs to clean up on destruction, do not create this function then.</li>
<li>Generic message functions: If the function should be called based on the type of content, then the corresponding function is <code>&lt;OBJECT&gt;_&lt;TYPE&gt;</code>, e.g. <code>json_decode_symbol</code>, <code>json_encode_bang</code>.</li>
<li>HTTP request messages <code>[GET(</code>, <code>[POST(</code>, <code>[PUT(</code>, <code>[DELETE(</code>, <code>[HEAD(</code>, <code>[PATCH(</code>, <code>[TRACE(</code>, and <code>[OPTIONS(</code>: <code>&lt;OBJECT&gt;_command</code>, e.g. <code>[GET(</code> on <code>[rest]</code> calls <code>rest_command</code>.</li>
<li>Message functions: Every <code>[MESSAGE(</code> for the object has a corresponding function <code>&lt;OBJECT&gt;_&lt;MESSAGE&gt;</code>, e.g. <code>[cancel(</code> on <code>[oauth]</code> calls the function <code>oauth_cancel</code>.</li>
</ul>
<h3>Names of Static Functions</h3>
<p>Static functions are prefixed with the name of the corresponding file without the .c extension, and an underscore. Function prototypes are declared in .c files before implementations. Sometimes, the object names are abbreviated:</p>
<ul>
<li><code>json-decode.c</code> =&gt; <code>jdec_</code></li>
<li><code>json-encode.c</code> =&gt; <code>jenc_</code></li>
<li><code>oauth.c</code> =&gt; <code>oauth_</code></li>
<li><code>rest.c</code> =&gt; <code>rest_</code></li>
<li><code>urlparams.c</code> =&gt; <code>urlp_</code></li>
</ul>
<h3>Content of Included Files</h3>
<p>All .c files that do not have a matching .h file contain only static functions and are <code>#include</code>d in files defining the objects. These source files are in subfolder <code>src/inc/</code>. They have the following properties:</p>
<h4>ctw.c</h4>
<p>ctw is short for <strong>c</strong>url <strong>t</strong>hread <strong>w</strong>rapper. As the name suggests, it contain functions for using threading for making requests with libcurl. </p>
<p>This file is used in <code>[oauth]</code> and <code>[rest]</code>. In both objects, a <code>struct _ctw</code> is the first member, so that casting is possible. </p>
<p>All functions are prefixed with <code>ctw_</code>.</p>
<h4>kvp.c</h4>
<p>kvp is short for <strong>k</strong>ey <strong>v</strong>alue <strong>p</strong>air. Three structs are defined in this file,<code>struct _v</code>, <code>struct _kvp</code>, and <code>struct _kvp_store</code>. <code>struct _kvp</code> is a key value pair, while <code>struct _kvp_store</code> includes a hash table of key value pair. <code>struct _v</code> is a value, containing a union of <code>t_float</code>, <code>char *</code> and <code>int</code> to distinguish between floats, strings and integers for JSON.</p>
<p>This file is used in <code>[json-encode]</code> and <code>[urlparams]</code>. In both objects, a <code>struct _kvp_store</code> is the first member, so that casting is possible.</p>
<p>All functions are prefixed with <code>kvp_</code>.</p>
<h4>string.c</h4>
<p>Utility functions for creating and freeing memory for <code>char *</code> and the corresponding <code>size_t</code>. </p>
<p>This file is used in <code>[json-decode]</code>, <code>[json-encode]</code>, <code>[oauth]</code>, <code>[rest]</code>, and <code>[urlparams]</code>.</p>
<p>All functions are prefixed with <code>string_</code>.</p>
<h4>strlist.c</h4>
<p>Utility functions for creating and freeing memory for a linked list of <code>char *</code> and the corresponding <code>size_t</code>. </p>
<p>This file is used in <code>[oauth]</code> and <code>[rest]</code>.</p>
<p>All functions are prefixed with <code>strlist_</code>.</p>
<h3>Reasons for using C99</h3>
<ul>
<li>Variadic macros</li>
<li>In older implementations <code>json_object_object_foreach</code> requires C99: <a href="https://github.com/json-c/json-c/pull/73">https://github.com/json-c/json-c/pull/73</a></li>
<li>C99 forces the memory layout for using casting to structs: <a href="http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf">§ 6.2.5, 20 of the standard</a>: </li>
</ul>
<blockquote>
<p>A structure type describes a sequentially allocated nonempty set of member objects
(and, in certain circumstances, an incomplete array), each of which has an optionally
specified name and possibly distinct type.</p>
</blockquote>
<h3>Special Cases</h3>
<ul>
<li><code>static char *string_remove_backslashes(char *source_string, size_t *memsize)</code> in <code>string.c</code> is surrounded by a <code>#ifndef NO_BACKSLASHES</code>. This function is not needed for <code>[urlparams]</code>, and therefore this is used to not get warnings on compilation.</li>
<li>There are only a few platform specific <code>#define</code>s, those are all declared in <code>purest_json.h</code>.</li>
<li><code>[json-encode]</code> can contain arrays, while <code>[urlparams]</code> cannot, so a <code>#define</code> is used in <code>kvp.c</code> to remove array functions and struct members for <code>[urlparams]</code>.</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<div>&nbsp;</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>PuREST JSON - Using JSON Data as Pitch Generator</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="page">
<div class="preview-page">
<div class="container">
<div class="repository-with-sidebar repo-container ">
<div class="repository-content context-loader-container">
<div id="readme" class="boxed-group flush clearfix announce instapaper_body md">
<h3>