From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 0EFFA4765E0 for ; Tue, 22 Dec 2020 14:14:26 +0300 (MSK) Received: by mail-lf1-f41.google.com with SMTP id l11so31144362lfg.0 for ; Tue, 22 Dec 2020 03:14:26 -0800 (PST) From: Cyrill Gorcunov Date: Tue, 22 Dec 2020 14:14:04 +0300 Message-Id: <20201222111408.48368-2-gorcunov@gmail.com> In-Reply-To: <20201222111408.48368-1-gorcunov@gmail.com> References: <20201222111408.48368-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v6 1/5] cfg: add cfg_isnumber helper List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml Cc: Vladislav Shpilevoy We will need it to figure out if parameter is a numeric value when doing configuration check. Part-of #5446 Acked-by: Serge Petrenko Signed-off-by: Cyrill Gorcunov --- src/cfg.c | 9 +++++++++ src/cfg.h | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/src/cfg.c b/src/cfg.c index 46cff1999..cf07d5817 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -57,6 +57,15 @@ cfg_geti(const char *param) return val; } +bool +cfg_isnumber(const char *param) +{ + cfg_get(param); + bool ret = !!lua_isnumber(tarantool_L, -1); + lua_pop(tarantool_L, 1); + return ret; +} + int cfg_getb(const char *param) { diff --git a/src/cfg.h b/src/cfg.h index 140bdddb8..e2955e6b2 100644 --- a/src/cfg.h +++ b/src/cfg.h @@ -40,6 +40,12 @@ extern "C" { int cfg_geti(const char *param); +/** + * Test if cfg parameter is a number. + */ +bool +cfg_isnumber(const char *param); + /** * Gets boolean parameter of cfg. * Returns -1 in case of nil -- 2.26.2