2018-03-15 15:27:34 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2016-2018 Chung, Hyung-Hwan. All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
|
|
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
2024-04-14 09:33:15 +00:00
|
|
|
#if 0
|
2018-03-15 15:27:34 +00:00
|
|
|
|
|
|
|
#ifndef _HCL_C_H_
|
|
|
|
#define _HCL_C_H_
|
|
|
|
|
|
|
|
#include <hcl.h>
|
|
|
|
|
2018-03-17 16:07:51 +00:00
|
|
|
typedef struct hcl_client_t hcl_client_t;
|
|
|
|
|
2018-03-20 10:36:00 +00:00
|
|
|
enum hcl_client_option_t
|
|
|
|
{
|
|
|
|
HCL_CLIENT_TRAIT,
|
|
|
|
HCL_CLIENT_LOG_MASK,
|
|
|
|
};
|
|
|
|
typedef enum hcl_client_option_t hcl_client_option_t;
|
|
|
|
|
|
|
|
enum hcl_client_trait_t
|
|
|
|
{
|
2018-03-21 10:38:10 +00:00
|
|
|
/* no trait defined at this moment. XXXX is just a placeholder */
|
|
|
|
HCL_CLIENT_XXXX = (1 << 0)
|
2018-03-20 10:36:00 +00:00
|
|
|
};
|
|
|
|
typedef enum hcl_client_trait_t hcl_client_trait_t;
|
|
|
|
|
2018-03-21 10:38:10 +00:00
|
|
|
/* ========================================================================= */
|
|
|
|
|
2018-03-21 15:17:46 +00:00
|
|
|
enum hcl_client_state_t
|
|
|
|
{
|
|
|
|
HCL_CLIENT_STATE_START,
|
|
|
|
HCL_CLIENT_STATE_IN_REPLY_NAME,
|
|
|
|
HCL_CLIENT_STATE_IN_REPLY_VALUE_START,
|
|
|
|
HCL_CLIENT_STATE_IN_REPLY_VALUE_UNQUOTED,
|
|
|
|
HCL_CLIENT_STATE_IN_REPLY_VALUE_QUOTED,
|
|
|
|
HCL_CLIENT_STATE_IN_REPLY_VALUE_QUOTED_TRAILER,
|
|
|
|
HCL_CLIENT_STATE_IN_ATTR_KEY,
|
|
|
|
HCL_CLIENT_STATE_IN_ATTR_VALUE_START,
|
|
|
|
HCL_CLIENT_STATE_IN_ATTR_VALUE_UNQUOTED,
|
|
|
|
HCL_CLIENT_STATE_IN_ATTR_VALUE_QUOTED,
|
|
|
|
HCL_CLIENT_STATE_IN_ATTR_VALUE_QUOTED_TRAILER,
|
|
|
|
|
|
|
|
HCL_CLIENT_STATE_IN_LENGTH_BOUNDED_DATA,
|
|
|
|
HCL_CLIENT_STATE_IN_CHUNKED_DATA
|
|
|
|
};
|
|
|
|
typedef enum hcl_client_state_t hcl_client_state_t;
|
|
|
|
|
|
|
|
/* ========================================================================= */
|
|
|
|
|
2018-03-21 10:38:10 +00:00
|
|
|
enum hcl_client_reply_type_t
|
|
|
|
{
|
|
|
|
HCL_CLIENT_REPLY_TYPE_OK = 0,
|
|
|
|
HCL_CLIENT_REPLY_TYPE_ERROR = 1
|
|
|
|
};
|
|
|
|
typedef enum hcl_client_reply_type_t hcl_client_reply_type_t;
|
|
|
|
|
2018-03-20 10:36:00 +00:00
|
|
|
typedef void (*hcl_client_log_write_t) (
|
|
|
|
hcl_client_t* client,
|
2018-04-26 04:39:20 +00:00
|
|
|
hcl_bitmask_t mask,
|
2018-03-20 10:36:00 +00:00
|
|
|
const hcl_ooch_t* msg,
|
|
|
|
hcl_oow_t len
|
|
|
|
);
|
|
|
|
|
2018-03-21 15:17:46 +00:00
|
|
|
typedef int (*hcl_client_start_reply_t) (
|
2018-03-21 10:38:10 +00:00
|
|
|
hcl_client_t* client,
|
|
|
|
hcl_client_reply_type_t type,
|
|
|
|
const hcl_ooch_t* dptr,
|
|
|
|
hcl_oow_t dlen
|
|
|
|
);
|
|
|
|
|
2018-03-21 15:17:46 +00:00
|
|
|
typedef int (*hcl_client_feed_attr_t) (
|
2018-03-21 10:38:10 +00:00
|
|
|
hcl_client_t* client,
|
|
|
|
const hcl_oocs_t* key,
|
|
|
|
const hcl_oocs_t* val
|
|
|
|
);
|
|
|
|
|
2018-03-21 15:17:46 +00:00
|
|
|
typedef int (*hcl_client_start_data_t) (
|
2018-03-21 10:38:10 +00:00
|
|
|
hcl_client_t* client
|
|
|
|
);
|
|
|
|
|
2018-03-21 15:17:46 +00:00
|
|
|
typedef int (*hcl_client_feed_data_t) (
|
2018-03-21 10:38:10 +00:00
|
|
|
hcl_client_t* client,
|
|
|
|
const void* ptr,
|
|
|
|
hcl_oow_t len
|
|
|
|
);
|
|
|
|
|
2018-03-21 15:17:46 +00:00
|
|
|
typedef int (*hcl_client_end_data_t) (
|
2018-03-21 10:38:10 +00:00
|
|
|
hcl_client_t* client
|
|
|
|
);
|
|
|
|
|
|
|
|
enum hcl_client_end_reply_state_t
|
|
|
|
{
|
|
|
|
HCL_CLIENT_END_REPLY_STATE_OK,
|
2018-03-21 15:17:46 +00:00
|
|
|
HCL_CLIENT_END_REPLY_STATE_REVOKED
|
2018-03-21 10:38:10 +00:00
|
|
|
};
|
|
|
|
typedef enum hcl_client_end_reply_state_t hcl_client_end_reply_state_t;
|
|
|
|
|
2018-03-21 15:17:46 +00:00
|
|
|
typedef int (*hcl_client_end_reply_t) (
|
2018-03-21 10:38:10 +00:00
|
|
|
hcl_client_t* client,
|
|
|
|
hcl_client_end_reply_state_t state
|
|
|
|
);
|
|
|
|
|
2018-03-20 10:36:00 +00:00
|
|
|
struct hcl_client_prim_t
|
|
|
|
{
|
2018-03-21 10:38:10 +00:00
|
|
|
hcl_client_log_write_t log_write;
|
|
|
|
|
|
|
|
hcl_client_start_reply_t start_reply; /* mandatory */
|
|
|
|
hcl_client_feed_attr_t feed_attr; /* optional */
|
|
|
|
hcl_client_feed_data_t feed_data; /* optional */
|
|
|
|
hcl_client_end_reply_t end_reply; /* mandatory */
|
2018-03-20 10:36:00 +00:00
|
|
|
};
|
|
|
|
typedef struct hcl_client_prim_t hcl_client_prim_t;
|
|
|
|
|
2018-03-21 10:38:10 +00:00
|
|
|
/* ========================================================================= */
|
2018-03-17 16:07:51 +00:00
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
HCL_EXPORT hcl_client_t* hcl_client_open (
|
|
|
|
hcl_mmgr_t* mmgr,
|
|
|
|
hcl_oow_t xtnsize,
|
2018-03-20 10:36:00 +00:00
|
|
|
hcl_client_prim_t* prim,
|
2018-03-17 16:07:51 +00:00
|
|
|
hcl_errnum_t* errnum
|
|
|
|
);
|
|
|
|
|
|
|
|
HCL_EXPORT void hcl_client_close (
|
|
|
|
hcl_client_t* client
|
|
|
|
);
|
|
|
|
|
2018-03-21 15:17:46 +00:00
|
|
|
HCL_EXPORT void hcl_client_reset (
|
|
|
|
hcl_client_t* client
|
|
|
|
);
|
|
|
|
|
|
|
|
HCL_EXPORT int hcl_client_feed (
|
|
|
|
hcl_client_t* client,
|
|
|
|
const void* ptr,
|
|
|
|
hcl_oow_t len,
|
|
|
|
hcl_oow_t* xlen
|
2018-03-18 15:29:16 +00:00
|
|
|
);
|
|
|
|
|
2018-03-21 15:17:46 +00:00
|
|
|
HCL_EXPORT hcl_client_state_t hcl_client_getstate (
|
2018-03-18 15:29:16 +00:00
|
|
|
hcl_client_t* client
|
|
|
|
);
|
|
|
|
|
2018-03-20 10:36:00 +00:00
|
|
|
HCL_EXPORT int hcl_client_setoption (
|
|
|
|
hcl_client_t* client,
|
|
|
|
hcl_client_option_t id,
|
|
|
|
const void* value
|
2018-03-18 15:29:16 +00:00
|
|
|
);
|
|
|
|
|
2018-03-20 10:36:00 +00:00
|
|
|
HCL_EXPORT int hcl_client_getoption (
|
|
|
|
hcl_client_t* client,
|
|
|
|
hcl_client_option_t id,
|
|
|
|
void* value
|
2018-03-18 15:29:16 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
2018-03-20 10:36:00 +00:00
|
|
|
HCL_EXPORT void* hcl_client_getxtn (
|
|
|
|
hcl_client_t* client
|
2018-03-18 15:29:16 +00:00
|
|
|
);
|
|
|
|
|
2018-03-20 10:36:00 +00:00
|
|
|
HCL_EXPORT hcl_mmgr_t* hcl_client_getmmgr (
|
|
|
|
hcl_client_t* client
|
2018-03-18 15:29:16 +00:00
|
|
|
);
|
|
|
|
|
2018-03-20 10:36:00 +00:00
|
|
|
HCL_EXPORT hcl_cmgr_t* hcl_client_getcmgr (
|
|
|
|
hcl_client_t* client
|
2018-03-18 15:29:16 +00:00
|
|
|
);
|
|
|
|
|
2018-03-20 10:36:00 +00:00
|
|
|
HCL_EXPORT void hcl_client_setcmgr (
|
2018-03-18 15:29:16 +00:00
|
|
|
hcl_client_t* client,
|
2018-03-20 10:36:00 +00:00
|
|
|
hcl_cmgr_t* cmgr
|
2018-03-18 15:29:16 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
HCL_EXPORT hcl_errnum_t hcl_client_geterrnum (
|
|
|
|
hcl_client_t* client
|
|
|
|
);
|
|
|
|
|
|
|
|
HCL_EXPORT const hcl_ooch_t* hcl_client_geterrstr (
|
|
|
|
hcl_client_t* client
|
|
|
|
);
|
|
|
|
|
|
|
|
HCL_EXPORT const hcl_ooch_t* hcl_client_geterrmsg (
|
|
|
|
hcl_client_t* client
|
|
|
|
);
|
|
|
|
|
|
|
|
HCL_EXPORT void hcl_client_seterrnum (
|
|
|
|
hcl_client_t* client,
|
|
|
|
hcl_errnum_t errnum
|
|
|
|
);
|
|
|
|
|
2018-03-21 10:38:10 +00:00
|
|
|
HCL_EXPORT void hcl_client_seterrbfmt (
|
|
|
|
hcl_client_t* client,
|
|
|
|
hcl_errnum_t errnum,
|
|
|
|
const hcl_bch_t* fmt,
|
|
|
|
...
|
|
|
|
);
|
2018-03-18 15:29:16 +00:00
|
|
|
|
2018-03-21 10:38:10 +00:00
|
|
|
HCL_EXPORT void hcl_client_seterrufmt (
|
|
|
|
hcl_client_t* client,
|
|
|
|
hcl_errnum_t errnum,
|
|
|
|
const hcl_uch_t* fmt,
|
|
|
|
...
|
|
|
|
);
|
2018-03-18 15:29:16 +00:00
|
|
|
|
2018-03-21 10:38:10 +00:00
|
|
|
HCL_EXPORT void hcl_client_logbfmt (
|
|
|
|
hcl_client_t* client,
|
2018-04-26 04:39:20 +00:00
|
|
|
hcl_bitmask_t mask,
|
2018-03-21 10:38:10 +00:00
|
|
|
const hcl_bch_t* fmt,
|
|
|
|
...
|
|
|
|
);
|
2018-03-18 15:29:16 +00:00
|
|
|
|
2018-03-21 10:38:10 +00:00
|
|
|
HCL_EXPORT void hcl_client_logufmt (
|
|
|
|
hcl_client_t* client,
|
2018-04-26 04:39:20 +00:00
|
|
|
hcl_bitmask_t mask,
|
2018-03-21 10:38:10 +00:00
|
|
|
const hcl_uch_t* fmt,
|
|
|
|
...
|
|
|
|
);
|
2018-03-18 15:29:16 +00:00
|
|
|
|
|
|
|
HCL_EXPORT void* hcl_client_allocmem (
|
|
|
|
hcl_client_t* client,
|
|
|
|
hcl_oow_t size
|
|
|
|
);
|
|
|
|
|
|
|
|
HCL_EXPORT void* hcl_client_callocmem (
|
|
|
|
hcl_client_t* client,
|
|
|
|
hcl_oow_t size
|
|
|
|
);
|
|
|
|
|
|
|
|
HCL_EXPORT void* hcl_client_reallocmem (
|
|
|
|
hcl_client_t* client,
|
|
|
|
void* ptr,
|
|
|
|
hcl_oow_t size
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
HCL_EXPORT void hcl_client_freemem (
|
|
|
|
hcl_client_t* client,
|
|
|
|
void* ptr
|
|
|
|
);
|
2018-03-20 10:36:00 +00:00
|
|
|
|
2018-03-17 16:07:51 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-03-15 15:27:34 +00:00
|
|
|
#endif
|
2024-04-14 09:33:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|