Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add some comments and an MIT license

  • Loading branch information...
commit b84db49781025502e1deb28d5fd6cd24a56f64fe 1 parent 7fecbfc
@decklin authored
Showing with 60 additions and 0 deletions.
  1. +29 −0 LICENSE
  2. +5 −0 README
  3. +26 −0 curlicue
View
29 LICENSE
@@ -0,0 +1,29 @@
+Curlicue
+========
+
+The contents of this package are:
+
+ Copyright © 2010 Decklin Foster <decklin@red-bean.com>
+
+And distributed under the following license ("MIT"):
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
View
5 README
@@ -107,6 +107,11 @@ Dependencies
OpenSSL is used for HMAC-SHA1 signing and nonce generation.
+Copyright
+---------
+
+See LICENSE.
+
Thanks
------
View
26 curlicue
@@ -1,5 +1,20 @@
#!/bin/sh
+# Curlicue - an OAuth wrapper for curl
+#
+# Copyright © 2010 Decklin Foster <decklin@red-bean.com>
+# Please see README for usage information and LICENSE for license.
+
+# General notes:
+#
+# Because HTTP responses from the OAuth "dance" will be percent-encoded,
+# we will require that all external data supplied by the the user must
+# also be percent-encoded. Then we just treat everything as opaque,
+# encoded strings. Annoying, perhaps, but we can retain some measure of
+# sanity.
+
+# There is no url_decode (see above).
+
url_encode() {
string="$1"
while [ "$string" ]; do
@@ -12,6 +27,9 @@ url_encode() {
echo
}
+# This doesn't actually *decode* anything. Arguably it should. $1 is the
+# name of another function that processes each pair (as two args).
+
parse_query_string() {
local IFS='&'
for i in $2; do
@@ -19,6 +37,9 @@ parse_query_string() {
done
}
+# This list is tiring, but we can't just let random files set any old
+# variable.
+
load_creds() {
case "$1" in
oauth_consumer_key) oauth_consumer_key="$2";;
@@ -88,6 +109,9 @@ if [ -z "$oauth_consumer_key" -o -z "$oauth_consumer_secret" ]; then
exit 1
fi
+# The remaining args in $@ go directly to curl. Fools that we are, we
+# attempt to parse them here. Only one URL is supported.
+
for i; do
case "$prev" in
-d|--data) url_params="$i";;
@@ -101,6 +125,8 @@ for i; do
prev="$i"
done
+# This is where the magic happens.
+
params="$(mk_params "$url_params" | join '&')"
base_string="$method&$(url_encode "$url")&$(url_encode "$params")"
signing_key="$oauth_consumer_secret&$oauth_token_secret"
Please sign in to comment.
Something went wrong with that request. Please try again.