2018-03-13 10:20:50 +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-13 10:20:50 +00:00
|
|
|
#ifndef _HCL_S_H_
|
|
|
|
#define _HCL_S_H_
|
|
|
|
|
|
|
|
#include <hcl.h>
|
|
|
|
|
|
|
|
typedef struct hcl_server_proto_t hcl_server_proto_t;
|
|
|
|
typedef struct hcl_server_worker_t hcl_server_worker_t;
|
|
|
|
typedef struct hcl_server_t hcl_server_t;
|
|
|
|
|
|
|
|
enum hcl_server_option_t
|
|
|
|
{
|
|
|
|
HCL_SERVER_TRAIT,
|
|
|
|
HCL_SERVER_LOG_MASK,
|
2018-03-16 14:57:34 +00:00
|
|
|
HCL_SERVER_WORKER_MAX_COUNT,
|
2018-03-13 10:20:50 +00:00
|
|
|
HCL_SERVER_WORKER_STACK_SIZE,
|
2018-03-14 14:40:05 +00:00
|
|
|
HCL_SERVER_WORKER_IDLE_TIMEOUT,
|
|
|
|
HCL_SERVER_ACTOR_HEAP_SIZE,
|
2018-03-17 05:44:40 +00:00
|
|
|
HCL_SERVER_ACTOR_MAX_RUNTIME,
|
2018-04-09 15:54:54 +00:00
|
|
|
HCL_SERVER_SCRIPT_INCLUDE_PATH,
|
|
|
|
HCL_SERVER_MODULE_INCTX
|
2018-03-13 10:20:50 +00:00
|
|
|
};
|
|
|
|
typedef enum hcl_server_option_t hcl_server_option_t;
|
|
|
|
|
|
|
|
enum hcl_server_trait_t
|
|
|
|
{
|
2018-03-14 10:14:38 +00:00
|
|
|
#if defined(HCL_BUILD_DEBUG)
|
|
|
|
HCL_SERVER_TRAIT_DEBUG_GC = (1 << 0),
|
2021-02-09 14:54:54 +00:00
|
|
|
HCL_SERVER_TRAIT_DEBUG_BIGINT = (1 << 1)
|
2018-03-14 10:14:38 +00:00
|
|
|
#endif
|
2018-03-13 10:20:50 +00:00
|
|
|
};
|
|
|
|
typedef enum hcl_server_trait_t hcl_server_trait_t;
|
|
|
|
|
2018-03-16 05:56:05 +00:00
|
|
|
#define HCL_SERVER_WID_INVALID ((hcl_oow_t)-1)
|
|
|
|
#define HCL_SERVER_WID_MAX (HCL_SERVER_WID_INVALID - 1)
|
2018-03-13 10:20:50 +00:00
|
|
|
|
2018-03-14 10:14:38 +00:00
|
|
|
typedef void (*hcl_server_log_write_t) (
|
|
|
|
hcl_server_t* server,
|
2018-03-16 05:56:05 +00:00
|
|
|
hcl_oow_t wid,
|
2021-02-08 15:42:24 +00:00
|
|
|
hcl_bitmask_t mask,
|
2018-03-14 10:14:38 +00:00
|
|
|
const hcl_ooch_t* msg,
|
|
|
|
hcl_oow_t len
|
|
|
|
);
|
2018-03-20 10:36:00 +00:00
|
|
|
|
2018-03-14 10:14:38 +00:00
|
|
|
struct hcl_server_prim_t
|
|
|
|
{
|
|
|
|
hcl_server_log_write_t log_write;
|
|
|
|
};
|
|
|
|
typedef struct hcl_server_prim_t hcl_server_prim_t;
|
|
|
|
|
|
|
|
|
2018-03-13 10:20:50 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
HCL_EXPORT hcl_server_t* hcl_server_open (
|
2018-03-14 10:14:38 +00:00
|
|
|
hcl_mmgr_t* mmgr,
|
|
|
|
hcl_oow_t xtnsize,
|
|
|
|
hcl_server_prim_t* prim,
|
|
|
|
hcl_errnum_t* errnum
|
2018-03-13 10:20:50 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
HCL_EXPORT void hcl_server_close (
|
|
|
|
hcl_server_t* server
|
|
|
|
);
|
|
|
|
|
|
|
|
HCL_EXPORT int hcl_server_start (
|
2018-03-14 14:40:05 +00:00
|
|
|
hcl_server_t* server,
|
|
|
|
const hcl_bch_t* addrs
|
2018-03-13 10:20:50 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
HCL_EXPORT void hcl_server_stop (
|
|
|
|
hcl_server_t* server
|
|
|
|
);
|
|
|
|
|
|
|
|
HCL_EXPORT int hcl_server_setoption (
|
|
|
|
hcl_server_t* server,
|
|
|
|
hcl_server_option_t id,
|
|
|
|
const void* value
|
|
|
|
);
|
|
|
|
|
|
|
|
HCL_EXPORT int hcl_server_getoption (
|
|
|
|
hcl_server_t* server,
|
|
|
|
hcl_server_option_t id,
|
|
|
|
void* value
|
|
|
|
);
|
|
|
|
|
2018-03-14 10:14:38 +00:00
|
|
|
HCL_EXPORT void* hcl_server_getxtn (
|
|
|
|
hcl_server_t* server
|
|
|
|
);
|
2018-03-13 10:20:50 +00:00
|
|
|
|
2018-03-14 10:14:38 +00:00
|
|
|
HCL_EXPORT hcl_mmgr_t* hcl_server_getmmgr (
|
|
|
|
hcl_server_t* server
|
|
|
|
);
|
2018-03-13 10:20:50 +00:00
|
|
|
|
|
|
|
|
2018-03-14 10:14:38 +00:00
|
|
|
HCL_EXPORT hcl_cmgr_t* hcl_server_getcmgr (
|
|
|
|
hcl_server_t* server
|
|
|
|
);
|
2018-03-13 10:20:50 +00:00
|
|
|
|
2018-03-14 10:14:38 +00:00
|
|
|
HCL_EXPORT void hcl_server_setcmgr (
|
|
|
|
hcl_server_t* server,
|
|
|
|
hcl_cmgr_t* cmgr
|
|
|
|
);
|
|
|
|
|
|
|
|
HCL_EXPORT hcl_errnum_t hcl_server_geterrnum (
|
|
|
|
hcl_server_t* server
|
|
|
|
);
|
2018-03-13 10:20:50 +00:00
|
|
|
|
2018-03-14 14:40:05 +00:00
|
|
|
HCL_EXPORT const hcl_ooch_t* hcl_server_geterrstr (
|
|
|
|
hcl_server_t* server
|
|
|
|
);
|
|
|
|
|
|
|
|
HCL_EXPORT const hcl_ooch_t* hcl_server_geterrmsg (
|
|
|
|
hcl_server_t* server
|
|
|
|
);
|
|
|
|
|
2018-03-14 10:14:38 +00:00
|
|
|
HCL_EXPORT void hcl_server_seterrnum (
|
|
|
|
hcl_server_t* server,
|
|
|
|
hcl_errnum_t errnum
|
|
|
|
);
|
|
|
|
|
2018-03-14 14:40:05 +00:00
|
|
|
HCL_EXPORT void hcl_server_seterrbfmt (
|
|
|
|
hcl_server_t* server,
|
|
|
|
hcl_errnum_t errnum,
|
|
|
|
const hcl_bch_t* fmt,
|
|
|
|
...
|
|
|
|
);
|
|
|
|
|
|
|
|
HCL_EXPORT void hcl_server_seterrufmt (
|
|
|
|
hcl_server_t* server,
|
|
|
|
hcl_errnum_t errnum,
|
|
|
|
const hcl_uch_t* fmt,
|
|
|
|
...
|
|
|
|
);
|
|
|
|
|
2018-03-14 10:14:38 +00:00
|
|
|
HCL_EXPORT void hcl_server_logbfmt (
|
|
|
|
hcl_server_t* server,
|
2018-04-26 04:39:20 +00:00
|
|
|
hcl_bitmask_t mask,
|
2018-03-14 10:14:38 +00:00
|
|
|
const hcl_bch_t* fmt,
|
|
|
|
...
|
|
|
|
);
|
|
|
|
|
|
|
|
HCL_EXPORT void hcl_server_logufmt (
|
|
|
|
hcl_server_t* server,
|
2018-04-26 04:39:20 +00:00
|
|
|
hcl_bitmask_t mask,
|
2018-03-14 10:14:38 +00:00
|
|
|
const hcl_uch_t* fmt,
|
|
|
|
...
|
|
|
|
);
|
2018-03-13 10:20:50 +00:00
|
|
|
|
2018-03-18 15:29:16 +00:00
|
|
|
|
|
|
|
HCL_EXPORT void* hcl_server_allocmem (
|
|
|
|
hcl_server_t* server,
|
|
|
|
hcl_oow_t size
|
|
|
|
);
|
|
|
|
|
|
|
|
HCL_EXPORT void* hcl_server_callocmem (
|
|
|
|
hcl_server_t* server,
|
|
|
|
hcl_oow_t size
|
|
|
|
);
|
|
|
|
|
|
|
|
HCL_EXPORT void* hcl_server_reallocmem (
|
|
|
|
hcl_server_t* server,
|
|
|
|
void* ptr,
|
|
|
|
hcl_oow_t size
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
HCL_EXPORT void hcl_server_freemem (
|
|
|
|
hcl_server_t* server,
|
|
|
|
void* ptr
|
|
|
|
);
|
|
|
|
|
2018-04-10 13:57:17 +00:00
|
|
|
|
2018-04-10 09:17:00 +00:00
|
|
|
HCL_EXPORT int hcl_server_proto_feed_reply (
|
|
|
|
hcl_server_proto_t* proto,
|
|
|
|
const hcl_ooch_t* ptr,
|
|
|
|
hcl_oow_t len,
|
|
|
|
int escape
|
|
|
|
);
|
|
|
|
|
2023-10-14 14:14:45 +00:00
|
|
|
HCL_EXPORT int hcl_server_proto_feed_reply_bytes (
|
|
|
|
hcl_server_proto_t* proto,
|
|
|
|
const hcl_bch_t* ptr,
|
|
|
|
hcl_oow_t len,
|
|
|
|
int escape
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
HCL_EXPORT int hcl_server_proto_handle_request (
|
|
|
|
hcl_server_proto_t* proto
|
|
|
|
);
|
|
|
|
|
2018-03-13 10:20:50 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
2024-04-14 09:33:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|