diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2020-10-01 14:04:36 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2020-10-01 14:04:36 (GMT) |
commit | f1ba03cea5b82699a984c80bd2deac14fdc8df18 (patch) | |
tree | ebe777c3e0b83f4c4cec9212731da9ebe0a0cfd3 /src/H5FDs3comms.h | |
parent | 10343c197906415388f2a4c8d292e21d25cf7381 (diff) | |
download | hdf5-f1ba03cea5b82699a984c80bd2deac14fdc8df18.zip hdf5-f1ba03cea5b82699a984c80bd2deac14fdc8df18.tar.gz hdf5-f1ba03cea5b82699a984c80bd2deac14fdc8df18.tar.bz2 |
Source formatted
Diffstat (limited to 'src/H5FDs3comms.h')
-rw-r--r-- | src/H5FDs3comms.h | 148 |
1 files changed, 53 insertions, 95 deletions
diff --git a/src/H5FDs3comms.h b/src/H5FDs3comms.h index 90c6650..5d939f8 100644 --- a/src/H5FDs3comms.h +++ b/src/H5FDs3comms.h @@ -52,7 +52,7 @@ * *****************************************************************************/ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ #ifdef H5_HAVE_ROS3_VFD @@ -69,8 +69,7 @@ /* hexadecimal string of pre-computed sha256 checksum of the empty string * hex(sha256sum("")) */ -#define EMPTY_SHA256 \ -"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" +#define EMPTY_SHA256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" /* string length (plus null terminator) * example ISO8601-format string: "20170713T145903Z" (YYYYmmdd'T'HHMMSS'_') @@ -98,8 +97,7 @@ * *--------------------------------------------------------------------------- */ -#define ISO8601NOW(dest, now_gm) \ -strftime((dest), ISO8601_SIZE, "%Y%m%dT%H%M%SZ", (now_gm)) +#define ISO8601NOW(dest, now_gm) strftime((dest), ISO8601_SIZE, "%Y%m%dT%H%M%SZ", (now_gm)) /*--------------------------------------------------------------------------- * @@ -117,9 +115,7 @@ strftime((dest), ISO8601_SIZE, "%Y%m%dT%H%M%SZ", (now_gm)) * *--------------------------------------------------------------------------- */ -#define RFC7231NOW(dest, now_gm) \ -strftime((dest), RFC7231_SIZE, "%a, %d %b %Y %H:%M:%S GMT", (now_gm)) - +#define RFC7231NOW(dest, now_gm) strftime((dest), RFC7231_SIZE, "%a, %d %b %Y %H:%M:%S GMT", (now_gm)) /* Reasonable maximum length of a credential string. * Provided for error-checking S3COMMS_FORMAT_CREDENTIAL (below). @@ -131,7 +127,6 @@ strftime((dest), RFC7231_SIZE, "%a, %d %b %Y %H:%M:%S GMT", (now_gm)) */ #define S3COMMS_MAX_CREDENTIAL_SIZE 155 - /*--------------------------------------------------------------------------- * * Macro: H5FD_S3COMMS_FORMAT_CREDENTIAL() @@ -162,16 +157,14 @@ strftime((dest), RFC7231_SIZE, "%a, %d %b %Y %H:%M:%S GMT", (now_gm)) * *--------------------------------------------------------------------------- */ -#define S3COMMS_FORMAT_CREDENTIAL(dest, access, iso8601_date, region, service) \ -HDsnprintf((dest), S3COMMS_MAX_CREDENTIAL_SIZE, \ - "%s/%s/%s/%s/aws4_request", \ - (access), (iso8601_date), (region), (service)) +#define S3COMMS_FORMAT_CREDENTIAL(dest, access, iso8601_date, region, service) \ + HDsnprintf((dest), S3COMMS_MAX_CREDENTIAL_SIZE, "%s/%s/%s/%s/aws4_request", (access), (iso8601_date), \ + (region), (service)) /********************* * PUBLIC STRUCTURES * *********************/ - /*---------------------------------------------------------------------------- * * Structure: hrb_node_t @@ -256,15 +249,14 @@ HDsnprintf((dest), S3COMMS_MAX_CREDENTIAL_SIZE, */ typedef struct hrb_node_t { unsigned long magic; - char *name; - char *value; - char *cat; - char *lowername; + char * name; + char * value; + char * cat; + char * lowername; struct hrb_node_t *next; } hrb_node_t; #define S3COMMS_HRB_NODE_MAGIC 0x7F5757UL - /*---------------------------------------------------------------------------- * * Structure: hrb_t @@ -332,17 +324,16 @@ typedef struct hrb_node_t { *---------------------------------------------------------------------------- */ typedef struct { - unsigned long magic; - char *body; - size_t body_len; - hrb_node_t *first_header; - char *resource; - char *verb; - char *version; + unsigned long magic; + char * body; + size_t body_len; + hrb_node_t * first_header; + char * resource; + char * verb; + char * version; } hrb_t; #define S3COMMS_HRB_MAGIC 0x6DCC84UL - /*---------------------------------------------------------------------------- * * Structure: parsed_url_t @@ -396,16 +387,15 @@ typedef struct { *---------------------------------------------------------------------------- */ typedef struct { - unsigned long magic; - char *scheme; /* required */ - char *host; /* required */ - char *port; - char *path; - char *query; + unsigned long magic; + char * scheme; /* required */ + char * host; /* required */ + char * port; + char * path; + char * query; } parsed_url_t; #define S3COMMS_PARSED_URL_MAGIC 0x21D0DFUL - /*---------------------------------------------------------------------------- * * Structure: s3r_t @@ -486,12 +476,12 @@ typedef struct { */ typedef struct { unsigned long magic; - CURL *curlhandle; + CURL * curlhandle; size_t filesize; - char *httpverb; - parsed_url_t *purl; - char *region; - char *secret_id; + char * httpverb; + parsed_url_t * purl; + char * region; + char * secret_id; unsigned char *signing_key; } s3r_t; @@ -505,9 +495,7 @@ extern "C" { * DECLARATION OF HTTP FIELD LIST ROUTINES * *******************************************/ -H5_DLL herr_t H5FD_s3comms_hrb_node_set(hrb_node_t **L, - const char *name, - const char *value); +H5_DLL herr_t H5FD_s3comms_hrb_node_set(hrb_node_t **L, const char *name, const char *value); /*********************************************** * DECLARATION OF HTTP REQUEST BUFFER ROUTINES * @@ -515,9 +503,7 @@ H5_DLL herr_t H5FD_s3comms_hrb_node_set(hrb_node_t **L, H5_DLL herr_t H5FD_s3comms_hrb_destroy(hrb_t **buf); -H5_DLL hrb_t * H5FD_s3comms_hrb_init_request(const char *verb, - const char *resource, - const char *host); +H5_DLL hrb_t *H5FD_s3comms_hrb_init_request(const char *verb, const char *resource, const char *host); /************************************* * DECLARATION OF S3REQUEST ROUTINES * @@ -527,78 +513,50 @@ H5_DLL herr_t H5FD_s3comms_s3r_close(s3r_t *handle); H5_DLL size_t H5FD_s3comms_s3r_get_filesize(s3r_t *handle); -H5_DLL s3r_t * H5FD_s3comms_s3r_open(const char url[], - const char region[], - const char id[], - const unsigned char signing_key[]); +H5_DLL s3r_t *H5FD_s3comms_s3r_open(const char url[], const char region[], const char id[], + const unsigned char signing_key[]); -H5_DLL herr_t H5FD_s3comms_s3r_read(s3r_t *handle, - haddr_t offset, - size_t len, - void *dest); +H5_DLL herr_t H5FD_s3comms_s3r_read(s3r_t *handle, haddr_t offset, size_t len, void *dest); /********************************* * DECLARATION OF OTHER ROUTINES * *********************************/ -H5_DLL struct tm * gmnow(void); +H5_DLL struct tm *gmnow(void); -H5_DLL herr_t H5FD_s3comms_aws_canonical_request(char *canonical_request_dest, - int cr_size, - char *signed_headers_dest, - int sh_size, - hrb_t *http_request); +H5_DLL herr_t H5FD_s3comms_aws_canonical_request(char *canonical_request_dest, int cr_size, + char *signed_headers_dest, int sh_size, hrb_t *http_request); -H5_DLL herr_t H5FD_s3comms_bytes_to_hex(char *dest, - const unsigned char *msg, - size_t msg_len, - hbool_t lowercase); +H5_DLL herr_t H5FD_s3comms_bytes_to_hex(char *dest, const unsigned char *msg, size_t msg_len, + hbool_t lowercase); H5_DLL herr_t H5FD_s3comms_free_purl(parsed_url_t *purl); -H5_DLL herr_t H5FD_s3comms_HMAC_SHA256(const unsigned char *key, - size_t key_len, - const char *msg, - size_t msg_len, - char *dest); +H5_DLL herr_t H5FD_s3comms_HMAC_SHA256(const unsigned char *key, size_t key_len, const char *msg, + size_t msg_len, char *dest); -H5_DLL herr_t H5FD_s3comms_load_aws_profile(const char *name, - char *key_id_out, - char *secret_access_key_out, - char *aws_region_out); +H5_DLL herr_t H5FD_s3comms_load_aws_profile(const char *name, char *key_id_out, char *secret_access_key_out, + char *aws_region_out); -H5_DLL herr_t H5FD_s3comms_nlowercase(char *dest, - const char *s, - size_t len); +H5_DLL herr_t H5FD_s3comms_nlowercase(char *dest, const char *s, size_t len); -H5_DLL herr_t H5FD_s3comms_parse_url(const char *str, - parsed_url_t **purl); +H5_DLL herr_t H5FD_s3comms_parse_url(const char *str, parsed_url_t **purl); -H5_DLL herr_t H5FD_s3comms_percent_encode_char(char *repr, - const unsigned char c, - size_t *repr_len); +H5_DLL herr_t H5FD_s3comms_percent_encode_char(char *repr, const unsigned char c, size_t *repr_len); -H5_DLL herr_t H5FD_s3comms_signing_key(unsigned char *md, - const char *secret, - const char *region, - const char *iso8601now); +H5_DLL herr_t H5FD_s3comms_signing_key(unsigned char *md, const char *secret, const char *region, + const char *iso8601now); -H5_DLL herr_t H5FD_s3comms_tostringtosign(char *dest, - const char *req_str, - const char *now, - const char *region); +H5_DLL herr_t H5FD_s3comms_tostringtosign(char *dest, const char *req_str, const char *now, + const char *region); -H5_DLL herr_t H5FD_s3comms_trim(char *dest, - char *s, - size_t s_len, - size_t *n_written); +H5_DLL herr_t H5FD_s3comms_trim(char *dest, char *s, size_t s_len, size_t *n_written); -H5_DLL herr_t H5FD_s3comms_uriencode(char *dest, const char *s, size_t s_len, - hbool_t encode_slash, size_t *n_written); +H5_DLL herr_t H5FD_s3comms_uriencode(char *dest, const char *s, size_t s_len, hbool_t encode_slash, + size_t *n_written); #ifdef __cplusplus } #endif #endif /* H5_HAVE_ROS3_VFD */ - |