|
APIRef
IntroductionThe public AWS4C functions are divided into four groups: Configuration Functionsaws_initvoid aws_init ( ) Initialize the library. This function must be the first AWS4C function called. aws_read_configint aws_read_config ( char * const id ) Read AWS authentication records. Parameters:
This function loads AWS authentication credentials corresponding to the user identified by the user ID from ~/.awsAuth file. All subsequent S3 and SQS operations will use these credentials. This function must be called before the first SQS or S3 operation. It can be called again when the credential switch is required. See the Developer's Guide for details about the ~/.awsAuth file. aws_set_debugvoid aws_set_debug ( int d ) Enable debugging output. Parameters:
This function controls whether debugging output is printed out. Calling it with a non-zero parameter results in the printing of the debug messages. aws_set_rrsvoid aws_set_rrs ( int rrs ) Enable Reduced Redundancy Storage Parameters:
This function controls whether normal or reduced redundancy storage class is used for the put operations. Calling this function with non-zero parameter will force all subsequent PUT operations to use reduced redundancy storage. Reduced redundancy objects are not replicated as many times as the standard S3 objects, hence they are slightly cheaper to store.
aws_set_idaws_set_keyaws_set_keyidIO Buffer FunctionsIOBufIOBuf is a data structure that holds the data to be sent to the AWS service or results of AWS operation. The structure has the following fields of interest:
aws_iobuf_newIOBuf* aws_iobuf_new ( ) Create a new I/O buffer. Returns: a newly allocated I/O buffer aws_iobuf_appendvoid aws_iobuf_append ( IOBuf * B, char * d, int len ) Append data to I/O buffer. Parameters:
aws_iobuf_getlineint aws_iobuf_getline ( IOBuf * B, char * Line, int size) Read the next line from the buffer. Parameters:
Returns: Number of characters read or 0 aws_iobuf_freevoid aws_iobuf_free ( IOBuf * bf ) Release IO Buffer. Parameters:
S3 Interface Functionss3_set_hostvoid s3_set_host ( char *const str ) Sets S3 host. The AWS4C sets the default host to ‘s3.amazonaws.com`; you only need to call this function if you want to use a different Simple Storage Services host. Parameters:
s3_set_bucketvoid s3_set_bucket ( char *const str ) Select current S3 bucket. All subsequent S3 operations will be performed on this bucket. Parameters:
s3_set_mimevoid s3_set_mime ( char * const str ) Set the mime type for the S3 put operation. All subsequent S3 PUT operations will use this mime type. s3_set_aclSet access control policy for the S3 put operations. The access control policy should be one of the Amazon's canned access control policies such as 'public-read', 'public-read-write' or 'authenticated-read' s3_getint s3_get ( IOBuf * b, char * const file) Downloads the file from the current bucket and places the data into the I/O buffer. Parameters:
Returns: 0 on success or an error code on failure. Also check the return code in I/O buffer. For more information see Checking results of AWS operation. s3_getint s3_delete ( IOBuf * b, char * const file) Deletes the specified file from the current bucket. Parameters:
Returns: 0 on success or an error code on failure. Also check the return code in I/O buffer. If operation was performed successfully the HTTP return code should be "204 No Content". For more information see Checking results of AWS operation. Note: If the specified file doesn't not exist in the bucket the operation still will complete successfully with the return code 0 and HTTP return code 204. s3_putint s3_put ( IOBuf * b, char * const file ) Uploads the file into currently selected bucket and takes the data from I/O buffer. Parameters:
Returns: 0 on success or an error code on failure. Also check the return code in I/O buffer. For more information see Checking results of AWS operation. SQS Interface Functionssqs_create_queueint sqs_create_queue ( IOBuf * b, char * const name ) Create an SQS queue. Parameters:
Returns: 0 on success, or an error code on failure sqs_list_queuesint sqs_list_queues ( IOBuf b ,char * const prefix ) Retrieves URL of the queue. Parameters:
Returns: 0 on success, or an error code on failure URL is placed into the I/O buffer. Use aws_iobuf_get_line to retrieve it sqs_get_queueattributesint sqs_get_queueattributes ( IOBuf * b, char * url, int * timeOut, int * nMesg ) Retrieve queue’s default visibility timeout and approximate number of messages. Parameters:
Returns: 0 on success, or an error code on failure Note that given the distributed nature of the SQS service it is not possible to get the exact number of messages in the queue. This function tries its best to get an approximate number, which is good enough for capacity estimation. sqs_set_queuevisibilitytimeoutint sqs_set_queuevisibilitytimeout ( IOBuf * b, char * url, int sec ) Set the queue's visibility timeout. Parameters:
Returns: 0 on success, or an error code on failure sqs_send_messageint sqs_send_message ( IOBuf * b, char * const url, char *const msg ) Send a message to the queue. Parameters:
Returns: 0 on success, or an error code on failure sqs_get_messageint sqs_get_message ( IOBuf * b, char const url, char * id ) Retrieve a message from the queue. Parameters:
Returns: 0 on success, or an error code on failure Message contents are placed into the I/O buffer Caller must allocate at least 1024 bytes of memory for the receipt. sqs_delete_messageint sqs_delete_message ( IOBuf * bf, char *const url, char * receipt ) Delete a processed message from the queue. Parameters:
Returns: 0 on success, or an error code on failure |