X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=device-src%2Fs3.h;h=c5ec6075378224188f45e4cfbcbabc2af0870ce8;hb=7a410be9a313db41cc40d3f4cc8a4e988cef6046;hp=b3d3b39ba880a3435c2414d1a0c4b67572df55fa;hpb=2627875b7d18858bc1f9f7652811e4d8c15a23eb;p=debian%2Famanda diff --git a/device-src/s3.h b/device-src/s3.h index b3d3b39..c5ec607 100644 --- a/device-src/s3.h +++ b/device-src/s3.h @@ -1,21 +1,21 @@ /* - * Copyright (c) 2005-2008 Zmanda Inc. All Rights Reserved. - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License version 2.1 as - * published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, but + * Copyright (c) 2008, 2009, 2010 Zmanda, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - * - * Contact information: Zmanda Inc., 465 S Mathlida Ave, Suite 300 - * Sunnyvale, CA 94086, USA, or: http://www.zmanda.com + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300 + * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com */ #ifndef __S3_H__ @@ -153,6 +153,7 @@ typedef curl_progress_callback s3_progress_func; S3_ERROR(MissingSecurityHeader), \ S3_ERROR(NoLoggingStatusForKey), \ S3_ERROR(NoSuchBucket), \ + S3_ERROR(NoSuchEntity), \ S3_ERROR(NoSuchKey), \ S3_ERROR(NotImplemented), \ S3_ERROR(NotSignedUp), \ @@ -198,7 +199,7 @@ s3_curl_location_compat(void); * * @note This doesn't guarantee that bucket name is entirely valid, * just that using it as one (or more) subdomain(s) of s3.amazonaws.com - * won't fail; that would prevent the reporting of useful messages from + * won't fail; that would prevent the reporting of useful messages from * the service. * * @param bucket: the bucket name @@ -209,7 +210,7 @@ s3_bucket_location_compat(const char *bucket); /* Initialize S3 operation * - * If an error occurs in this function, diagnostic information is + * If an error occurs in this function, diagnostic information is * printed to stderr. * * @returns: false if an error occurred @@ -226,11 +227,16 @@ s3_init(void); * @param secret_key: the secret key for Amazon Web Services * @param user_token: the user token for Amazon DevPay * @param bucket_location: the location constraint for buckets + * @param storage_class: the storage class for new objects + * @param ca_info: the path to pass to libcurl as the certificate authority. + * see curl_easy_setopt() CURLOPT_CAINFO for more * @returns: the new S3Handle */ S3Handle * -s3_open(const char * access_key, const char *secret_key, const char * user_token, - const char * bucket_location); +s3_open(const char * access_key, const char *secret_key, const char *host, + const char *service_path, gboolean use_subdomain, + const char * user_token, + const char * bucket_location, const char * storage_class, const char * ca_info); /* Deallocate an S3Handle * @@ -256,7 +262,7 @@ s3_reset(S3Handle *hdl); * NULL, that result will not be returned. Caller is not responsible for * freeing any returned strings, although the results are only valid until * the next call to an S3 function with this handle. - * + * * @param hdl: the S3Handle object * @param message: (result) the error message, or NULL if none exists * @param response_code: (result) the HTTP response code (or 0 if none exists) @@ -293,6 +299,24 @@ s3_verbose(S3Handle *hdl, gboolean s3_use_ssl(S3Handle *hdl, gboolean use_ssl); +/* Control the throttling of S3 uploads. Only supported with curl >= 7.15.5. + * + * @param hdl: the S3Handle object + * @param max_send_speed: max speed (bytes/sec) at which to send + * @returns: true if the setting is valid + */ +gboolean +s3_set_max_send_speed(S3Handle *hdl, guint64 max_send_speed); + +/* Control the throttling of S3 downloads. Only supported with curl >= 7.15.5. + * + * @param hdl: the S3Handle object + * @param max_recv_speed: max speed (bytes/sec) at which to receive + * @returns: true if the setting is valid + */ +gboolean +s3_set_max_recv_speed(S3Handle *hdl, guint64 max_recv_speed); + /* Get the error information from the last operation on this handle, * formatted as a string. * @@ -305,7 +329,7 @@ char * s3_strerror(S3Handle *hdl); /* Perform an upload. - * + * * When this function returns, KEY and BUFFER remain the * responsibility of the caller. * @@ -334,7 +358,7 @@ s3_upload(S3Handle *hdl, s3_progress_func progress_func, gpointer progress_data); -/* List all of the files matching the pseudo-glob C{PREFIX*DELIMITER*}, +/* List all of the files matching the pseudo-glob C{PREFIX*DELIMITER*}, * returning only that portion which matches C{PREFIX*DELIMITER}. S3 supports * this particular semantics, making it quite efficient. The returned list * should be freed by the caller. @@ -344,6 +368,7 @@ s3_upload(S3Handle *hdl, * @param prefix: the prefix * @param delimiter: delimiter (any length string) * @param list: (output) the list of files + * @param total_size: (output) sum of size of files * @returns: FALSE if an error occurs */ gboolean @@ -351,7 +376,8 @@ s3_list_keys(S3Handle *hdl, const char *bucket, const char *prefix, const char *delimiter, - GSList **list); + GSList **list, + guint64 *total_size); /* Read an entire file, passing the contents to write_func buffer * by buffer. @@ -398,6 +424,18 @@ gboolean s3_make_bucket(S3Handle *hdl, const char *bucket); +/* Delete a bucket + * + * @note A bucket can not be deleted if it still contains keys + * + * @param hdl: the S3Handle object + * @param bucket: the bucket to delete + * @returns: FALSE if an error occurs + */ +gboolean +s3_delete_bucket(S3Handle *hdl, + const char *bucket); + /* Attempt a RefreshAWSSecurityToken on a token; if it succeeds, the old * token will be freed and replaced by the new. If it fails, the old * token is left unchanged and FALSE is returned. */