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:

Go to the source code of this file.

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.
IOBufaws_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"


Generated by Doxygen