Welcome to little lamb

Code » limb » release » tree

[release] / src / liblimb / obuffer.h / obuffer_parse_level.c

/* This file is part of limb                           https://lila.oss/limb
 * Copyright (C) 2023 Olivier Brunel                          jjk@jjacky.com */
/* SPDX-License-Identifier: GPL-2.0-only */
#include <limb/bytestr.h>
#include <limb/obuffer.h>

u8
obuffer_parse_level(const char *str, size_t len)
{
    const char *levels[] = { "silent", "quiet", "normal", "verbose", "debug", "maximum", 0 };
    int m = byte_get_match(NULL, str, len, levels);
    if (m < 0) return (u8) -1;
    u8 lvl[] = { OLVL_SILENT, OLVL_QUIET, OLVL_NORMAL, OLVL_VERBOSE, OLVL_DEBUG, OLVL_MAXIMUM };
    return lvl[m];
}