From 3d25ede46fe4d17a467d3630ef1780aecae9d955 Mon Sep 17 00:00:00 2001 From: zhlong Date: Wed, 24 Jun 2020 09:50:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BAAPI=E6=B7=BB=E5=8A=A0=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E9=85=8D=E7=BD=AE=E5=9E=8B=E5=86=85=E5=AE=B9=E7=9A=84?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/include/mk_common.h | 7 +++++++ api/source/mk_common.cpp | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/api/include/mk_common.h b/api/include/mk_common.h index 6363d22e..d93f1124 100755 --- a/api/include/mk_common.h +++ b/api/include/mk_common.h @@ -101,6 +101,13 @@ API_EXPORT void API_CALL mk_env_init1(int thread_num, */ API_EXPORT void API_CALL mk_set_option(const char *key, const char *val); +/** + * 获取配置项的值 + * @param key 配置项名 + */ +API_EXPORT const char * API_CALL mk_get_option(const char *key); + + /** * 创建http[s]服务器 * @param port htt监听端口,推荐80,传入0则随机分配 diff --git a/api/source/mk_common.cpp b/api/source/mk_common.cpp index 0baa311c..ce36924e 100644 --- a/api/source/mk_common.cpp +++ b/api/source/mk_common.cpp @@ -119,6 +119,17 @@ API_EXPORT void API_CALL mk_set_option(const char *key, const char *val) { mINI::Instance()[key] = val; } +API_EXPORT const char * API_CALL mk_get_option(const char *key) +{ + assert(key); + if (mINI::Instance().find(key) == mINI::Instance().end()) { + WarnL << "key:" << key << " not existed!"; + return nullptr; + } + return mINI::Instance()[key].data(); +} + + API_EXPORT uint16_t API_CALL mk_http_server_start(uint16_t port, int ssl) { ssl = MAX(0,MIN(ssl,1)); try {