This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
pxz-hos-client-cpp-module/src/hos_client.h

157 lines
7.2 KiB
C
Raw Normal View History

2020-09-11 16:13:02 +08:00
/*************************************************************************
2021-04-23 09:57:58 +08:00
> File Name: hos_client.h
2020-09-11 16:13:02 +08:00
> Author: pxz
> Created Time: Thu 10 Sep 2020 03:13:59 PM CST
************************************************************************/
#ifndef __HOS_CLIENT_INIT__
#define __HOS_CLIENT_INIT__
struct hos_instance_s;
typedef struct hos_instance_s *hos_instance;
2020-09-11 16:13:02 +08:00
2020-09-21 19:19:18 +08:00
#define HOS_CLIENT_OK 0
/* fd mode */
#define FILE_MODE 0x00
#define BUFF_MODE 0x01
#define APPEND_MODE 0x02 /* 默认不追加 */
/* hos 错误码 */
enum hoserrors
{
HOS_PARAMETER_ERROR = -1,
2021-04-23 09:57:58 +08:00
HOS_FILE_NOT_EXIST = -2,
HOS_FD_IS_INVALID = -3,
2020-09-21 19:19:18 +08:00
HOS_FD_NOT_ENOUGH = -4,
2020-10-20 17:20:27 +08:00
HOS_SEND_FAILED = -5,
2021-04-23 09:57:58 +08:00
HOS_RUNTIME_LOG_FAILED = -6,
HOS_CONF_ERROR = -7,
HOS_BUCKET_NOT_EXIST = -8,
2021-04-28 18:29:29 +08:00
HOS_INSTANCE_NOT_INIT = -9,
HOS_INSTANCE_NOT_ENABLE = -10,
2020-09-21 19:19:18 +08:00
};
/* s3 的错误码 */
enum s3errors
{
2020-09-21 19:19:18 +08:00
//From Core Aws::S3::S3Error + 1//
//////////////////////////////////////////////////////////////////////////////////////////
2020-09-21 19:19:18 +08:00
INCOMPLETE_SIGNATURE = 1,
INTERNAL_FAILURE = 2,
INVALID_ACTION = 3,
INVALID_CLIENT_TOKEN_ID = 4,
INVALID_PARAMETER_COMBINATION = 5,
INVALID_QUERY_PARAMETER = 6,
INVALID_PARAMETER_VALUE = 7,
MISSING_ACTION = 8, // SDK should never allow
MISSING_AUTHENTICATION_TOKEN = 9, // SDK should never allow
MISSING_PARAMETER = 10, // SDK should never allow
OPT_IN_REQUIRED = 11,
REQUEST_EXPIRED = 12,
SERVICE_UNAVAILABLE = 13,
THROTTLING = 14,
VALIDATION = 15,
ACCESS_DENIED = 16,
RESOURCE_NOT_FOUND = 17, // Shared with multiple services
UNRECOGNIZED_CLIENT = 18, // Most likely caused by an invalid access key or secret key
MALFORMED_QUERY_STRING = 19,
SLOW_DOWN = 20,
REQUEST_TIME_TOO_SKEWED = 21,
INVALID_SIGNATURE = 22,
SIGNATURE_DOES_NOT_MATCH = 23,
INVALID_ACCESS_KEY_ID = 24,
REQUEST_TIMEOUT = 25,
NETWORK_CONNECTION = 100, // General failure to send message to service
// These are needed for logical reasons
2020-09-21 19:19:18 +08:00
UNKNOWN = 101,
CLIENT_SIGNING_FAILURE = 102, // Client failed to sign the request
USER_CANCELLED = 103, // User cancelled the request
SERVICE_EXTENSION_START_RANGE = 129,
BUCKET_ALREADY_EXISTS= SERVICE_EXTENSION_START_RANGE + 1,
BUCKET_ALREADY_OWNED_BY_YOU,
NO_SUCH_BUCKET,
NO_SUCH_KEY,
NO_SUCH_UPLOAD,
OBJECT_ALREADY_IN_ACTIVE_TIER,
OBJECT_NOT_IN_ACTIVE_TIER
};
typedef void (*put_finished_callback)(bool result, const char *bucket, const char *object, const char *errmsg, size_t errorcode, void *userdata);
2020-09-21 19:19:18 +08:00
2021-04-23 09:57:58 +08:00
/*************************************************************************************
2021-04-23 09:57:58 +08:00
* hos_init_instance
* conf_path
* thread_num 线
* hos
*************************************************************************************/
2021-09-06 15:26:20 +08:00
hos_instance hos_init_instance(const char *conf_path, const char *module, size_t thread_num);
2020-09-21 19:19:18 +08:00
/*************************************************************************************
2021-04-26 13:59:36 +08:00
* hos_get_instance
* hos_instance result true
2020-09-21 19:19:18 +08:00
*************************************************************************************/
2021-04-26 13:59:36 +08:00
hos_instance hos_get_instance();
int hos_get_init_instance_errorcode();
const char *hos_get_init_instance_errormsg();
const char *hos_get_upload_endpoint();
/*************************************************************************************
2021-04-23 09:57:58 +08:00
* hos_upload_file
* hos_instance instance
* const char * bucket
2020-10-09 14:20:39 +08:00
* const char * file_path
2020-09-21 19:19:18 +08:00
* put_finished_callback callback upload操作结束时调用的回调函数
2020-10-09 14:20:39 +08:00
* void *userdata
* size_t thread_id 线id
2020-09-21 19:19:18 +08:00
* int 0hoserros错误码
*************************************************************************************/
2021-04-28 18:29:29 +08:00
int hos_upload_file(const char *bucket, const char *file_path, put_finished_callback callback, void* userdata, size_t thread_id);
2020-09-21 19:19:18 +08:00
/*************************************************************************************
2021-04-23 09:57:58 +08:00
* hos_upload_buf
* hos_instance instance
2020-09-21 19:19:18 +08:00
* const char * bucket
* const char * object
2020-10-09 14:20:39 +08:00
* const char *buf buf
* size_t buf_len buf的长度
2020-09-21 19:19:18 +08:00
* put_finished_callback callback upload操作结束时调用的回调函数
2020-10-09 14:20:39 +08:00
* void *userdata
* size_t thread_id 线id
2020-09-21 19:19:18 +08:00
* int 0hoserros错误码
*************************************************************************************/
2021-04-28 18:29:29 +08:00
int hos_upload_buf(const char *bucket, const char *object, const char *buf, size_t buf_len, put_finished_callback callback, void *userdata, size_t thread_id);
2020-09-21 19:19:18 +08:00
/*************************************************************************************
* hos_open_fd
2021-04-23 09:57:58 +08:00
* const char * bucket
2020-09-21 19:19:18 +08:00
* const char * object
* put_finished_callback callback upload操作结束时调用的回调函数
2021-04-23 09:57:58 +08:00
* void *data
2020-09-21 19:19:18 +08:00
* size_t thread_id 线ID
* int mode (FILE OR BUFFER, APPEND OR NOT)
* long fd(fd >0)hoserros错误码
2020-09-21 19:19:18 +08:00
*************************************************************************************/
long hos_open_fd(const char *bucket, const char *object, put_finished_callback callback, void *userdata, size_t thread_id);
2020-09-21 19:19:18 +08:00
/*************************************************************************************
2021-04-23 09:57:58 +08:00
* hos_write
* size_t fd hos_open_fd返回的fd
2020-09-21 19:19:18 +08:00
* const char * stream
* size_t stream
* size_t thread_id 线ID
2020-10-09 14:20:39 +08:00
* size_t position append模式下的每段内容编号
2021-04-23 09:57:58 +08:00
* int 0hoserror
2020-09-21 19:19:18 +08:00
*************************************************************************************/
int hos_write(size_t fd, const char *stream, size_t stream_len);
2020-09-21 19:19:18 +08:00
/*************************************************************************************
* hos_close_fd
* size_t fd fd
* size_t thread_id 线ID
* int 0hoserros错误码
*************************************************************************************/
int hos_close_fd(size_t fd);
/*************************************************************************************
2021-04-23 09:57:58 +08:00
* hos_shutdown_instance
2020-09-21 19:19:18 +08:00
* int 0hoserros错误码
*************************************************************************************/
2021-04-23 09:57:58 +08:00
int hos_shutdown_instance();
2020-09-11 16:13:02 +08:00
#endif