/
githubmirror
/
nvme-cli
Обзор
Документация
Войти
/
githubmirror
/
nvme-cli
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v3.0-b.4
shared/parse-util.c
41 строка
803 B
Martin Belanger
shared: rename everything to the shr_ namespace
28 июл 2026, 10:55
28 июл 2026, 10:55
8876cbc
Код
Авторство
О чём код?
// SPDX-License-Identifier: LGPL-2.1-or-later /* * This file is part of nvme-cli. * Copyright (c) 2026 Dell Technologies Inc. or its subsidiaries. * * Authors: Martin Belanger <martin.belanger@dell.com> */ #include <errno.h> #include <string.h> #include <strings.h> #include <ccan/array_size/array_size.h> #include "parse-util.h" int shr_parse_bool(const char *value, bool *out) { static const char * const yes[] = { "1", "yes", "y", "true", "t", "on" }; static const char * const no[] = { "0", "no", "n", "false", "f", "off" }; size_t i; for (i = 0; i < ARRAY_SIZE(yes); i++) { if (!strcasecmp(value, yes[i])) { *out = true; return 0; } } for (i = 0; i < ARRAY_SIZE(no); i++) { if (!strcasecmp(value, no[i])) { *out = false; return 0; } } return -EINVAL; }