TITLE

AUTHOR
Version 2
CREATEDATE

Table of Contents

Table of contents

Main Page
This is a small library that provides Amazon Web Services binding for C programs.
The AWS4C leverages CURL and OPENSSL libraries for HTTP transfer and cryptographic functions.
The Todo List  list is here.
The bug  list is here. 

Todo List 
 Group internal  
Document .awsAuth file 
 Group internal  
Include license 
 Group internal  
Include regression testing 
 Group internal  
Run thing through valgrind 
 Global s3_do_get  
check the return code 
 Global s3_do_put  
check the return code 
 Global SQSRequest  
check the return code 
 Global unbase64  
Check for errors during decode 
 Global sqs_get_message  
This is really bad. Must get a real message parser 
 Global sqs_list_queues  
This only retrieves just one line in the string.. make that all URLs are returned 
 Global aws_iobuf_new  
Place sentinels at the begining of the buffer 

Module Index
Modules
Here is a list of all modules:
Internal Functions	pagenumConfiguration Functions	pagenumS3 interface functions	pagenumSQS interface functions	pagenumI/O Buffer functions	pagenum

Data Structure Index
Data Structures
Here are the data structures with brief descriptions:
IOBuf (IOBuf structure ) 	pagenum
IOBufNode (IOBuf Node ) 	pagenum

File Index
File List
Here is a list of all files with brief descriptions:
aws4c.c  	pagenum
aws4c.h  	pagenum
s3_get.c  	pagenum
s3_put.c  	pagenum
sqs_example.c  	pagenum

Module Documentation
Internal Functions
Functions
static void __debug (char *fmt,...)
Print debug output. 
static char * __aws_get_iso_date ()
Get Data for authentication of SQS request. 
static char * __aws_get_httpdate ()
Get Request Date. 
static FILE * __aws_getcfg ()
Internal function to get configuration file. 
static int s3_do_get (IOBuf *b, char *const signature, char *const date, char *const resource)
static int s3_do_put (IOBuf *b, char *const signature, char *const date, char *const resource)
static char * __aws_sign (char *const str)
static void __chomp (char *str)
Chomp (remove the trailing '
' from the string. 
static char * unbase64 (unsigned char *input, int length)
Decode base64 into binary. 
static char * __b64_encode (const unsigned char *input, int length)
Encode a binary into base64 buffer. 
static size_t writefunc (void *ptr, size_t size, size_t nmemb, void *stream)
Handles reception of the data. 
static size_t readfunc (void *ptr, size_t size, size_t nmemb, void *stream)
Handles sending of the data. 
static size_t header (void *ptr, size_t size, size_t nmemb, void *stream)
Process incming header. 
static void Dump ()
Dump current state. 
static char * GetStringToSign (char *resource, int resSize, char **date, char *const method, char *const bucket, char *const file)
Get S3 Request signature. 
static int __aws_urlencode (char *src, char *dest, int nDest)
static int SQSRequest (IOBuf *b, char *verb, char *const url)
static char * SQSSign (char *str)
Variables
static int debug = 0
static char * ID = NULL
<flag to control debugging options 
static char * awsKeyID = NULL
<Current ID 
static char * awsKey = NULL
<AWS Key ID 
static char * S3Host = "s3.amazonaws.com"
<AWS Key Material 
static char * SQSHost = "queue.amazonaws.com"
<AWS S3 host 
static char * Bucket = NULL
<AWS SQS host 

Detailed Description
Todo:
Document .awsAuth file 
Todo:
Include license 
Todo:
Include regression testing 
Todo:
Run thing through valgrind 

Function Documentation
static char * __aws_get_httpdate () [static]
Get Request Date. 
For internal use only.

Returns:
date in HTTP format 

Definition at line 249 of file aws4c.c.
References __debug().
Referenced by GetStringToSign().
static char * __aws_get_iso_date () [static]
Get Data for authentication of SQS request. 

Returns:
date in ISO format 
Definition at line 202 of file aws4c.c.
References __debug().
Referenced by sqs_create_queue(), sqs_delete_message(), sqs_get_message(), sqs_get_queueattributes(), sqs_list_queues(), sqs_send_message(), and sqs_set_queuevisibilitytimeout().
static FILE * __aws_getcfg () [static]
Internal function to get configuration file. 

Compose FileName and check 
Definition at line 261 of file aws4c.c.
References __debug().
Referenced by aws_read_config().
static char * __aws_sign (char *const  str) [static]

Definition at line 627 of file aws4c.c.
References __b64_encode(), __debug(), and awsKey.
Referenced by GetStringToSign(), and SQSSign().
static int __aws_urlencode (char * src,   char * dest,   int nDest) [static]

Definition at line 322 of file aws4c.c.
References __debug().
Referenced by sqs_delete_message(), sqs_send_message(), and SQSSign().
static char* __b64_encode (const unsigned char * input,   int length) [static]
Encode a binary into base64 buffer. 

Parameters:
input binary data text 
length length of the input text 
For internal use only.

Returns:
a newly allocated buffer with base64 encoded data 

Definition at line 102 of file aws4c.c.
Referenced by __aws_sign().
static void __chomp (char * str) [static]
Chomp (remove the trailing '
' from the string. 

Parameters:
str string 
Definition at line 125 of file aws4c.c.
Referenced by aws_read_config(), and header().
static void __debug (char * fmt,    ...) [static]
Print debug output. 
For internal use only.

Parameters:
fmt printf like formating string 

If debug flag is not set we won't print anything
Otherwise process the arguments and print the result 
Definition at line 233 of file aws4c.c.
References debug.
Referenced by __aws_get_httpdate(), __aws_get_iso_date(), __aws_getcfg(), __aws_sign(), __aws_urlencode(), aws_read_config(), readfunc(), s3_do_get(), s3_do_put(), sqs_create_queue(), sqs_get_message(), sqs_get_queueattributes(), sqs_list_queues(), sqs_send_message(), sqs_set_queuevisibilitytimeout(), SQSRequest(), and writefunc().
static void Dump () [static]
Dump current state. 
For internal use only.

Definition at line 217 of file aws4c.c.
References awsKey, awsKeyID, Bucket, ID, S3Host, and SQSHost.
static char* GetStringToSign (char * resource,   int resSize,   char ** date,   char *const  method,   char *const  bucket,   char *const  file) [static]
Get S3 Request signature. 
For internal use only.

Parameters:
resource -- URI of the object 
resSize -- size of the resoruce buffer 
date -- HTTP date 
method -- HTTP method 
bucket -- bucket 
file -- file 
Returns:
fills up resource and date parameters, also returns request signature to be used with Authorization header 

Definition at line 299 of file aws4c.c.
References __aws_get_httpdate(), and __aws_sign().
Referenced by s3_get(), and s3_put().
static size_t header (void * ptr,   size_t size,   size_t nmemb,   void * stream) [static]
Process incming header. 

Parameters:
ptr pointer to the incoming data 
size size of the data member 
nmemb number of data memebers 
stream pointer to I/O buffer 
Returns:
number of bytes processed 
Definition at line 171 of file aws4c.c.
References __chomp(), IOBuf::code, IOBuf::eTag, IOBuf::lastMod, IOBuf::len, and IOBuf::result.
Referenced by s3_do_get(), s3_do_put(), and SQSRequest().
static size_t readfunc (void * ptr,   size_t size,   size_t nmemb,   void * stream) [static]
Handles sending of the data. 

Parameters:
ptr pointer to the incoming data 
size size of the data member 
nmemb number of data memebers 
stream pointer to I/O buffer 
Returns:
number of bytes written 
Definition at line 155 of file aws4c.c.
References __debug(), and aws_iobuf_getline().
Referenced by s3_do_put(), and SQSRequest().
static int s3_do_get (IOBuf * b,   char *const  signature,   char *const  date,   char *const  resource) [static]

Todo:
check the return code 
Definition at line 586 of file aws4c.c.
References __debug(), awsKeyID, debug, header(), S3Host, and writefunc().
Referenced by s3_get().
static int s3_do_put (IOBuf * b,   char *const  signature,   char *const  date,   char *const  resource) [static]

Todo:
check the return code 
Definition at line 549 of file aws4c.c.
References __debug(), awsKeyID, debug, header(), IOBuf::len, readfunc(), and S3Host.
Referenced by s3_put().
static int SQSRequest (IOBuf * b,   char * verb,   char *const  url) [static]

Todo:
check the return code 
Definition at line 348 of file aws4c.c.
References __debug(), debug, header(), IOBuf::len, readfunc(), and writefunc().
Referenced by sqs_create_queue(), sqs_delete_message(), sqs_get_message(), sqs_get_queueattributes(), sqs_list_queues(), sqs_send_message(), and sqs_set_queuevisibilitytimeout().
static char* SQSSign (char * str) [static]

Definition at line 377 of file aws4c.c.
References __aws_sign(), and __aws_urlencode().
Referenced by sqs_create_queue(), sqs_delete_message(), sqs_get_message(), sqs_get_queueattributes(), sqs_list_queues(), sqs_send_message(), and sqs_set_queuevisibilitytimeout().
static char* unbase64 (unsigned char * input,   int length) [static]
Decode base64 into binary. 

Parameters:
input base64 text 
length length of the input text 
Returns:
decoded data in newly allocated buffer 
For internal use only.
This function allocates a buffer of the same size as the input buffer and then decodes the given base64 encoded text into binary. The result is placed into the allocated buffer. It is the caller's responsibility to free this buffer 
Allocate and zero the buffer
Decode the input into the newly allocated buffer Todo:
Check for errors during decode 
Return the decoded text 
Definition at line 75 of file aws4c.c.
static size_t writefunc (void * ptr,   size_t size,   size_t nmemb,   void * stream) [static]
Handles reception of the data. 

Parameters:
ptr pointer to the incoming data 
size size of the data member 
nmemb number of data memebers 
stream pointer to I/O buffer 
Returns:
number of bytes processed 
Definition at line 142 of file aws4c.c.
References __debug(), and aws_iobuf_append().
Referenced by s3_do_get(), and SQSRequest().

Variable Documentation
char* awsKey = NULL [static]
<AWS Key ID 

Definition at line 48 of file aws4c.c.
Referenced by __aws_sign(), aws_set_key(), and Dump().
char* awsKeyID = NULL [static]
<Current ID 

Definition at line 47 of file aws4c.c.
Referenced by aws_read_config(), aws_set_keyid(), Dump(), s3_do_get(), s3_do_put(), sqs_create_queue(), sqs_delete_message(), sqs_get_message(), sqs_get_queueattributes(), sqs_list_queues(), sqs_send_message(), and sqs_set_queuevisibilitytimeout().
char* Bucket = NULL [static]
<AWS SQS host 

Definition at line 51 of file aws4c.c.
Referenced by Dump(), s3_get(), s3_put(), and s3_set_bucket().
int debug = 0 [static]

Definition at line 45 of file aws4c.c.
Referenced by __debug(), aws_set_debug(), s3_do_get(), s3_do_put(), and SQSRequest().
char* ID = NULL [static]
<flag to control debugging options 

Definition at line 46 of file aws4c.c.
Referenced by aws_read_config(), aws_set_id(), and Dump().
char* S3Host = "s3.amazonaws.com" [static]
<AWS Key Material 

Definition at line 49 of file aws4c.c.
Referenced by Dump(), s3_do_get(), s3_do_put(), and s3_set_host().
char* SQSHost = "queue.amazonaws.com" [static]
<AWS S3 host 

Definition at line 50 of file aws4c.c.
Referenced by Dump().

Configuration Functions
Functions
void aws_init ()
Initialize the library. 
void aws_set_debug (int d)
Set debuging output. 
void aws_set_id (char *const str)
Set AWS account ID to be read from .awsAuth file. 
void aws_set_key (char *const str)
Set AWS account access key. 
void aws_set_keyid (char *const str)
Set AWS account access key ID. 
int aws_read_config (char *const id)
Read AWS authentication records. 

Function Documentation
void aws_init ()
Initialize the library. 

Definition at line 404 of file aws4c.c.
Referenced by main().
int aws_read_config (char *const  id)
Read AWS authentication records. 

Parameters:
id user ID 
Open File Make sure that file permissions are set right
Read Lines
Skip Comments
Split the line on ':'
If the line is correct Set the IDs
Return error if not found 
Definition at line 428 of file aws4c.c.
References __aws_getcfg(), __chomp(), __debug(), aws_set_id(), aws_set_key(), aws_set_keyid(), awsKeyID, and ID.
Referenced by main().
void aws_set_debug (int d)
Set debuging output. 

Parameters:
d when non-zero causes debugging output to be printed 
Definition at line 408 of file aws4c.c.
References debug.
Referenced by main().
void aws_set_id (char *const  str)
Set AWS account ID to be read from .awsAuth file. 

Parameters:
str account ID 
Definition at line 415 of file aws4c.c.
References ID.
Referenced by aws_read_config().
void aws_set_key (char *const  str)
Set AWS account access key. 

Definition at line 419 of file aws4c.c.
References awsKey.
Referenced by aws_read_config().
void aws_set_keyid (char *const  str)
Set AWS account access key ID. 

Definition at line 423 of file aws4c.c.
References awsKeyID.
Referenced by aws_read_config().

S3 interface functions
Functions
void s3_set_bucket (char *const str)
Select current S3 bucket. 
void s3_set_host (char *const str)
Set S3 host. 
int s3_put (IOBuf *b, char *const file)
Upload the file into currently selected bucket. 
int s3_get (IOBuf *b, char *const file)
Download the file from the current bucket. 

Function Documentation
int s3_get (IOBuf * b,   char *const  file)
Download the file from the current bucket. 

Parameters:
b I/O buffer 
file filename 
Definition at line 532 of file aws4c.c.
References Bucket, GetStringToSign(), and s3_do_get().
Referenced by main().
int s3_put (IOBuf * b,   char *const  file)
Upload the file into currently selected bucket. 

Parameters:
b I/O buffer 
file filename 
Definition at line 514 of file aws4c.c.
References Bucket, GetStringToSign(), and s3_do_put().
Referenced by main().
void s3_set_bucket (char *const  str)
Select current S3 bucket. 

Parameters:
str bucket ID 
Definition at line 502 of file aws4c.c.
References Bucket.
Referenced by main().
void s3_set_host (char *const  str)
Set S3 host. 

Definition at line 506 of file aws4c.c.
References S3Host.
Referenced by main().

SQS interface functions
Functions
int sqs_create_queue (IOBuf *b, char *const name)
Create SQS queue. 
int sqs_list_queues (IOBuf *b, char *const prefix)
Retrieve URL of the queue. 
int sqs_get_queueattributes (IOBuf *b, char *url, int *timeOut, int *nMesg)
Retrieve queue attributes. 
int sqs_set_queuevisibilitytimeout (IOBuf *b, char *url, int sec)
Set queue visibility timeout. 
int sqs_send_message (IOBuf *b, char *const url, char *const msg)
Send a message to the queue. 
int sqs_get_message (IOBuf *b, char *const url, char *id)
Retrieve a message from the queue. 
int sqs_delete_message (IOBuf *bf, char *const url, char *receipt)
Delete processed message from the queue. 

Function Documentation
int sqs_create_queue (IOBuf * b,   char *const  name)
Create SQS queue. 

Parameters:
b I/O buffer 
name queue name 
Returns:
on success return 0, otherwise error code 
Definition at line 664 of file aws4c.c.
References __aws_get_iso_date(), __debug(), awsKeyID, SQS_REQ_TAIL, SQSRequest(), and SQSSign().
Referenced by main().
int sqs_delete_message (IOBuf * bf,   char *const  url,   char * receipt)
Delete processed message from the queue. 

Parameters:
bf I/O buffer 
url queue url. Use sqs_list_queues to retrieve 
receipt Message receipt handle. 
Returns:
on success return 0, otherwise error code 
Definition at line 1037 of file aws4c.c.
References __aws_get_iso_date(), __aws_urlencode(), awsKeyID, SQS_REQ_TAIL, SQSRequest(), and SQSSign().
Referenced by main().
int sqs_get_message (IOBuf * b,   char *const  url,   char * id)
Retrieve a message from the queue. 

Parameters:
b I/O buffer 
url queue url. Use sqs_list_queues to retrieve 
id Message receipt handle. 
Returns:
on success return 0, otherwise error code
Message contents are placed into I/O buffer Caller has to allocate enough memory for the receipt handle 1024 bytes should be enough 
Todo:
This is really bad. Must get a real message parser 
Handle a body already being processed.. 
Definition at line 943 of file aws4c.c.
References __aws_get_iso_date(), __debug(), aws_iobuf_append(), aws_iobuf_free(), aws_iobuf_getline(), aws_iobuf_new(), awsKeyID, IOBuf::code, IOBuf::result, SQS_REQ_TAIL, SQSRequest(), and SQSSign().
Referenced by main().
int sqs_get_queueattributes (IOBuf * b,   char * url,   int * timeOut,   int * nMesg)
Retrieve queue attributes. 

Parameters:
b I/O buffer 
url queue url. Use sqs_list_queues to retrieve 
timeOut queue visibility timeout 
nMesg approximate number of messages in the queue 
Returns:
on success return 0, otherwise error code 
Definition at line 785 of file aws4c.c.
References __aws_get_iso_date(), __debug(), aws_iobuf_getline(), awsKeyID, SQS_REQ_TAIL, SQSRequest(), and SQSSign().
Referenced by main().
int sqs_list_queues (IOBuf * b,   char *const  prefix)
Retrieve URL of the queue. 

Parameters:
b I/O buffer 
prefix queue prefix. better use the whole name 
Returns:
on success return 0, otherwise error code
URL is placed into the I/O buffer. User get_line to retrieve it 
Todo:
This only retrieves just one line in the string.. make that all URLs are returned 
Parse Out the List Of Queues 
Definition at line 708 of file aws4c.c.
References __aws_get_iso_date(), __debug(), aws_iobuf_append(), aws_iobuf_free(), aws_iobuf_getline(), aws_iobuf_new(), awsKeyID, IOBuf::code, IOBuf::result, SQS_REQ_TAIL, SQSRequest(), and SQSSign().
Referenced by main().
int sqs_send_message (IOBuf * b,   char *const  url,   char *const  msg)
Send a message to the queue. 

Parameters:
b I/O buffer 
url queue url. Use sqs_list_queues to retrieve 
msg a message to send 
Returns:
on success return 0, otherwise error code 
Definition at line 889 of file aws4c.c.
References __aws_get_iso_date(), __aws_urlencode(), __debug(), awsKeyID, SQS_REQ_TAIL, SQSRequest(), and SQSSign().
Referenced by main().
int sqs_set_queuevisibilitytimeout (IOBuf * b,   char * url,   int sec)
Set queue visibility timeout. 

Parameters:
b I/O buffer 
url queue url. Use sqs_list_queues to retrieve 
sec queue visibility timeout 
Returns:
on success return 0, otherwise error code 
Definition at line 845 of file aws4c.c.
References __aws_get_iso_date(), __debug(), awsKeyID, SQS_REQ_TAIL, SQSRequest(), and SQSSign().
Referenced by main().

I/O Buffer functions
Functions
IOBuf * aws_iobuf_new ()
Create a new I/O buffer. 
void aws_iobuf_append (IOBuf *B, char *d, int len)
Append data to I/O buffer. 
int aws_iobuf_getline (IOBuf *B, char *Line, int size)
Read the next line from the buffer. 
void aws_iobuf_free (IOBuf *bf)
Release IO Buffer. 

Function Documentation
void aws_iobuf_append (IOBuf * B,   char * d,   int len)
Append data to I/O buffer. 

Parameters:
B I/O buffer 
d pointer to the data to be appended 
len length of the data to be appended 
Definition at line 1114 of file aws4c.c.
References IOBufNode::buf, current, first, len, IOBufNode::next, and pos.
Referenced by main(), sqs_get_message(), sqs_list_queues(), and writefunc().
void aws_iobuf_free (IOBuf * bf)
Release IO Buffer. 

Parameters:
bf I/O buffer to be deleted 
Release Things
Walk down the list and release blocks 
Definition at line 1173 of file aws4c.c.
References eTag, first, lastMod, IOBufNode::next, and result.
Referenced by main(), sqs_get_message(), and sqs_list_queues().
int aws_iobuf_getline (IOBuf * B,   char * Line,   int size)
Read the next line from the buffer. 

Parameters:
B I/O buffer 
Line character array to store the read line in 
size size of the character array Line 
Returns:
number of characters read or 0 
Definition at line 1144 of file aws4c.c.
References IOBufNode::buf, current, len, IOBufNode::next, and pos.
Referenced by DumpResult(), main(), readfunc(), sqs_get_message(), sqs_get_queueattributes(), and sqs_list_queues().
IOBuf* aws_iobuf_new ()
Create a new I/O buffer. 
\return a newly allocated I/O buffer 
Definition at line 1092 of file aws4c.c.
References code, current, eTag, first, lastMod, len, pos, and result.
Referenced by main(), sqs_get_message(), and sqs_list_queues().

Data Structure Documentation
IOBuf Struct Reference
IOBuf structure. 
#include <aws4c.h>
Collaboration diagram for IOBuf:
IMAGE

Data Fields
IOBufNode * first
IOBufNode * current
char * pos
char * result
char * lastMod
char * eTag
int len
int code

Detailed Description
IOBuf structure. 
Definition at line 11 of file aws4c.h.

Field Documentation
IOBufNode* IOBuf::first

Definition at line 13 of file aws4c.h.
Referenced by aws_iobuf_append(), aws_iobuf_free(), and aws_iobuf_new().
IOBufNode* IOBuf::current

Definition at line 14 of file aws4c.h.
Referenced by aws_iobuf_append(), aws_iobuf_getline(), and aws_iobuf_new().
char* IOBuf::pos

Definition at line 15 of file aws4c.h.
Referenced by aws_iobuf_append(), aws_iobuf_getline(), and aws_iobuf_new().
char* IOBuf::result

Definition at line 17 of file aws4c.h.
Referenced by aws_iobuf_free(), aws_iobuf_new(), DumpResult(), header(), main(), sqs_get_message(), and sqs_list_queues().
char* IOBuf::lastMod

Definition at line 18 of file aws4c.h.
Referenced by aws_iobuf_free(), aws_iobuf_new(), DumpResult(), header(), and main().
char* IOBuf::eTag

Definition at line 19 of file aws4c.h.
Referenced by aws_iobuf_free(), aws_iobuf_new(), DumpResult(), header(), and main().
int IOBuf::len

Definition at line 20 of file aws4c.h.
Referenced by aws_iobuf_append(), aws_iobuf_getline(), aws_iobuf_new(), DumpResult(), header(), main(), s3_do_put(), and SQSRequest().
int IOBuf::code

Definition at line 21 of file aws4c.h.
Referenced by aws_iobuf_new(), DumpResult(), header(), main(), sqs_get_message(), and sqs_list_queues().

The documentation for this struct was generated from the following file:
aws4c.h

IOBufNode Struct Reference
IOBuf Node. 
#include <aws4c.h>

Data Fields
char * buf
struct _IOBufNode * next

Detailed Description
IOBuf Node. 
Definition at line 4 of file aws4c.h.

Field Documentation
char* IOBufNode::buf

Definition at line 6 of file aws4c.h.
Referenced by aws_iobuf_append(), and aws_iobuf_getline().
struct _IOBufNode* IOBufNode::next [read]

Definition at line 7 of file aws4c.h.
Referenced by aws_iobuf_append(), aws_iobuf_free(), and aws_iobuf_getline().

The documentation for this struct was generated from the following file:
aws4c.h

File Documentation
aws4c.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <sys/stat.h>
#include <curl/curl.h>
#include <openssl/hmac.h>
#include <openssl/evp.h>
#include <openssl/bio.h>
#include <openssl/buffer.h>
#include "aws4c.h"

Include dependency graph for aws4c.c:
IMAGE

Defines
#define SQS_REQ_TAIL  "&Signature=%s" "&SignatureVersion=1" "&Timestamp=%s" "&Version=2009-02-01"
Functions
static void __debug (char *fmt,...)
Print debug output. 
static char * __aws_get_iso_date ()
Get Data for authentication of SQS request. 
static char * __aws_get_httpdate ()
Get Request Date. 
static FILE * __aws_getcfg ()
Internal function to get configuration file. 
static int s3_do_get (IOBuf *b, char *const signature, char *const date, char *const resource)
static int s3_do_put (IOBuf *b, char *const signature, char *const date, char *const resource)
static char * __aws_sign (char *const str)
static void __chomp (char *str)
Chomp (remove the trailing '
' from the string. 
static char * unbase64 (unsigned char *input, int length)
Decode base64 into binary. 
static char * __b64_encode (const unsigned char *input, int length)
Encode a binary into base64 buffer. 
static size_t writefunc (void *ptr, size_t size, size_t nmemb, void *stream)
Handles reception of the data. 
static size_t readfunc (void *ptr, size_t size, size_t nmemb, void *stream)
Handles sending of the data. 
static size_t header (void *ptr, size_t size, size_t nmemb, void *stream)
Process incming header. 
static void Dump ()
Dump current state. 
static char * GetStringToSign (char *resource, int resSize, char **date, char *const method, char *const bucket, char *const file)
Get S3 Request signature. 
static int __aws_urlencode (char *src, char *dest, int nDest)
static int SQSRequest (IOBuf *b, char *verb, char *const url)
static char * SQSSign (char *str)
void aws_init ()
Initialize the library. 
void aws_set_debug (int d)
Set debuging output. 
void aws_set_id (char *const str)
Set AWS account ID to be read from .awsAuth file. 
void aws_set_key (char *const str)
Set AWS account access key. 
void aws_set_keyid (char *const str)
Set AWS account access key ID. 
int aws_read_config (char *const id)
Read AWS authentication records. 
void s3_set_bucket (char *const str)
Select current S3 bucket. 
void s3_set_host (char *const str)
Set S3 host. 
int s3_put (IOBuf *b, char *const file)
Upload the file into currently selected bucket. 
int s3_get (IOBuf *b, char *const file)
Download the file from the current bucket. 
int sqs_create_queue (IOBuf *b, char *const name)
Create SQS queue. 
int sqs_list_queues (IOBuf *b, char *const prefix)
Retrieve URL of the queue. 
int sqs_get_queueattributes (IOBuf *b, char *url, int *timeOut, int *nMesg)
Retrieve queue attributes. 
int sqs_set_queuevisibilitytimeout (IOBuf *b, char *url, int sec)
Set queue visibility timeout. 
int sqs_send_message (IOBuf *b, char *const url, char *const msg)
Send a message to the queue. 
int sqs_get_message (IOBuf *b, char *const url, char *id)
Retrieve a message from the queue. 
int sqs_delete_message (IOBuf *bf, char *const url, char *receipt)
Delete processed message from the queue. 
IOBuf * aws_iobuf_new ()
Create a new I/O buffer. 
void aws_iobuf_append (IOBuf *B, char *d, int len)
Append data to I/O buffer. 
int aws_iobuf_getline (IOBuf *B, char *Line, int size)
Read the next line from the buffer. 
void aws_iobuf_free (IOBuf *bf)
Release IO Buffer. 
Variables
static int debug = 0
static char * ID = NULL
<flag to control debugging options 
static char * awsKeyID = NULL
<Current ID 
static char * awsKey = NULL
<AWS Key ID 
static char * S3Host = "s3.amazonaws.com"
<AWS Key Material 
static char * SQSHost = "queue.amazonaws.com"
<AWS S3 host 
static char * Bucket = NULL
<AWS SQS host 

Define Documentation
#define SQS_REQ_TAIL  "&Signature=%s" "&SignatureVersion=1" "&Timestamp=%s" "&Version=2009-02-01"

Definition at line 653 of file aws4c.c.
Referenced by sqs_create_queue(), sqs_delete_message(), sqs_get_message(), sqs_get_queueattributes(), sqs_list_queues(), sqs_send_message(), and sqs_set_queuevisibilitytimeout().

aws4c.h File Reference

This graph shows which files directly or indirectly include this file:
IMAGE

Data Structures
struct IOBufNode
IOBuf Node. 
struct IOBuf
IOBuf structure. 
Functions
void aws_init ()
Initialize the library. 
void aws_set_id (char *const str)
Set AWS account ID to be read from .awsAuth file. 
void aws_set_key (char *const str)
Set AWS account access key. 
void aws_set_keyid (char *const str)
Set AWS account access key ID. 
int aws_read_config (char *const ID)
Read AWS authentication records. 
void aws_set_debug (int d)
Set debuging output. 
void s3_set_bucket (char *const str)
Select current S3 bucket. 
int s3_get (IOBuf *b, char *const file)
Download the file from the current bucket. 
int s3_put (IOBuf *b, char *const file)
Upload the file into currently selected bucket. 
void s3_set_host (char *const str)
Set S3 host. 
int sqs_create_queue (IOBuf *b, char *const name)
Create SQS queue. 
int sqs_list_queues (IOBuf *b, char *const prefix)
Retrieve URL of the queue. 
int sqs_get_queueattributes (IOBuf *b, char *url, int *TimeOut, int *nMesg)
Retrieve queue attributes. 
int sqs_set_queuevisibilitytimeout (IOBuf *b, char *url, int sec)
Set queue visibility timeout. 
int sqs_get_message (IOBuf *b, char *const url, char *id)
Retrieve a message from the queue. 
int sqs_send_message (IOBuf *b, char *const url, char *const msg)
Send a message to the queue. 
int sqs_delete_message (IOBuf *bf, char *const url, char *receipt)
Delete processed message from the queue. 
IOBuf * aws_iobuf_new ()
Create a new I/O buffer. 
void aws_iobuf_append (IOBuf *B, char *d, int len)
Append data to I/O buffer. 
int aws_iobuf_getline (IOBuf *B, char *Line, int size)
Read the next line from the buffer. 
void aws_iobuf_free (IOBuf *bf)
Release IO Buffer. 

s3_get.c File Reference
#include <stdio.h>
#include <getopt.h>
#include <stdlib.h>
#include "aws4c.h"

Include dependency graph for s3_get.c:
IMAGE

Functions
int main (int argc, char *argv[])

Function Documentation
int main (int argc,   char * argv[])

Definition at line 9 of file s3_get.c.
References aws_init(), aws_iobuf_free(), aws_iobuf_getline(), aws_iobuf_new(), aws_read_config(), aws_set_debug(), IOBuf::code, IOBuf::eTag, IOBuf::lastMod, IOBuf::len, IOBuf::result, s3_get(), s3_set_bucket(), and s3_set_host().

s3_put.c File Reference
#include <stdio.h>
#include <getopt.h>
#include <stdlib.h>
#include <string.h>
#include "aws4c.h"

Include dependency graph for s3_put.c:
IMAGE

Functions
int main (int argc, char *argv[])

Function Documentation
int main (int argc,   char * argv[])

Definition at line 10 of file s3_put.c.
References aws_init(), aws_iobuf_append(), aws_iobuf_getline(), aws_iobuf_new(), aws_read_config(), aws_set_debug(), IOBuf::code, IOBuf::eTag, IOBuf::lastMod, IOBuf::len, IOBuf::result, s3_put(), and s3_set_bucket().

sqs_example.c File Reference
#include <stdio.h>
#include <getopt.h>
#include <stdlib.h>
#include <string.h>
#include "aws4c.h"

Include dependency graph for sqs_example.c:
IMAGE

Functions
void DumpResult (int rv, IOBuf *bf)
This is an example that shows how to use SQS functions of AWS4C The example performs the following actions. 
int main (int argc, char *argv[])

Function Documentation
void DumpResult (int rv,   IOBuf * bf)
This is an example that shows how to use SQS functions of AWS4C The example performs the following actions. 
Initializes the library Creates the queue Obtains the full URL of the queue Gets get queue parameters Sets visibility timeout of the queue Puts a number of messages into the queue Reads a number of messages from the queue Delets the processed messages a helper function that prints out a result of the operation and data returned by the server 
Definition at line 24 of file sqs_example.c.
References aws_iobuf_getline(), IOBuf::code, IOBuf::eTag, IOBuf::lastMod, IOBuf::len, and IOBuf::result.
Referenced by main().
int main (int argc,   char * argv[])

Initialized the library
Create the Queue
Note failure to create the queue means either genuine error or simply the fact that the queue already exist for most applications it is okay to continue even if this operation fails
Get the URL of the queue Most applications require the full URL of the queue which might be different from the queue name passwd to the SQSCreate queue
Send a few messages
Now receive them back 
Definition at line 44 of file sqs_example.c.
References aws_init(), aws_iobuf_free(), aws_iobuf_getline(), aws_iobuf_new(), aws_read_config(), aws_set_debug(), IOBuf::code, DumpResult(), sqs_create_queue(), sqs_delete_message(), sqs_get_message(), sqs_get_queueattributes(), sqs_list_queues(), sqs_send_message(), and sqs_set_queuevisibilitytimeout().

Index
INDEX