本文整理汇总了C++中parse_boolean函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_boolean函数的具体用法?C++ parse_boolean怎么用?C++ parse_boolean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_boolean函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: log_assert
// * read customization data provided by customization package
void Timed::init_customization()
{
iodata::storage *storage = new iodata::storage ;
storage->set_primary_path(customization_path()) ;
storage->set_validator(customization_data_validator(), "customization_t") ;
iodata::record *c = storage->load() ;
log_assert(c, "loading customization settings failed") ;
if(storage->source()==0)
log_info("customization loaded from '%s'", customization_path()) ;
else
log_warning("customization file '%s' corrupted or non-existing, using default values", customization_path()) ;
format24_by_default = parse_boolean(c->get("format24")->str()) ;
nitz_supported = parse_boolean(c->get("useNitz")->str()) ;
auto_time_by_default = parse_boolean(c->get("autoTime")->str()) ;
guess_tz_by_default = parse_boolean(c->get("guessTz")->str()) ;
tz_by_default = c->get("tz")->str() ;
if (not nitz_supported and auto_time_by_default)
{
log_warning("automatic time update disabled because nitz is not supported in the device") ;
auto_time_by_default = false ;
}
delete c ;
delete storage ;
}
开发者ID:special,项目名称:timed,代码行数:30,代码来源:timed.cpp
示例2: resource_parse_line
static cairo_bool_t
resource_parse_line (char *name, cairo_xcb_resources_t *resources)
{
char *value;
value = strchr (name, ':');
if (value == NULL)
return FALSE;
*value++ = 0;
name = skip_spaces (name);
value = skip_spaces (value);
if (strcmp (name, "Xft.antialias") == 0)
parse_boolean (value, &(resources->xft_antialias));
else if (strcmp (name, "Xft.lcdfilter") == 0)
parse_integer (value, &(resources->xft_lcdfilter));
else if (strcmp (name, "Xft.rgba") == 0)
parse_integer (value, &(resources->xft_rgba));
else if (strcmp (name, "Xft.hinting") == 0)
parse_boolean (value, &(resources->xft_hinting));
else if (strcmp (name, "Xft.hintstyle") == 0)
parse_integer (value, &(resources->xft_hintstyle));
return TRUE;
}
开发者ID:AZed,项目名称:cairo,代码行数:27,代码来源:cairo-xcb-resources.c
示例3: set_global_parameter
//!
//!
//!
//! @param[in] key
//! @param[in] val
//!
//! @pre
//!
//! @post
//!
static void set_global_parameter(char *key, char *val)
{
if (strcmp(key, "debug") == 0) {
print_debug = parse_boolean(val);
set_debug(print_debug);
} else if (strcmp(key, "argv") == 0) {
print_argv = parse_boolean(val);
} else if (strcmp(key, "work") == 0) {
set_work_dir(val);
} else if (strcmp(key, "work_size") == 0) {
set_work_limit(parse_bytes(val));
} else if (strcmp(key, "cache") == 0) {
set_cache_dir(val);
} else if (strcmp(key, "cache_size") == 0) {
set_cache_limit(parse_bytes(val));
} else if (strcmp(key, "purge_cache") == 0) {
purge_cache = parse_boolean(val);
} else if (strcmp(key, "cloud_cert") == 0) {
euca_strncpy(cloud_cert_path, val, sizeof(cloud_cert_path));
} else if (strcmp(key, "service_key") == 0) {
euca_strncpy(service_key_path, val, sizeof(service_key_path));
} else {
err("unknown global parameter '%s'", key);
}
LOGINFO("GLOBAL: %s=%s\n", key, val);
}
开发者ID:AsherBond,项目名称:eucalyptus,代码行数:36,代码来源:imager.c
示例4: calloc
struct rmonitor_file_watch_info *initialize_watch(const char *fname, struct jx *watch_spec) {
struct rmonitor_file_watch_info *f;
f = calloc(1, sizeof(*f));
f->delete_if_found = parse_boolean(fname, watch_spec, "delete-if-found", 0 /* default false */);
f->from_start = parse_boolean(fname, watch_spec, "from-start", 0 /* default false */);
f->from_start_if_truncated = parse_boolean(fname, watch_spec, "from-start-if-truncated", 1 /* default true */);
f->filename = fname;
f->exists = 0;
f->position = 0;
f->last_size = 0;
f->last_mtime = 0;
f->last_ino = 0;
f->event_with_pattern = 0;
initialize_watch_events(f, watch_spec);
struct stat s;
if(stat(fname, &s) == 0) {
f->exists = 1;
f->last_ino = s.st_ino;
if(!f->from_start) {
f->position = s.st_size;
f->last_size = s.st_size;
f->last_mtime = s.st_mtime;
}
}
return f;
}
开发者ID:dthain,项目名称:cctools,代码行数:34,代码来源:rmonitor_file_watch.c
示例5: parse_proc_cmdline
static int parse_proc_cmdline(void) {
char *line, *w, *state;
int r;
size_t l;
if (detect_container(NULL) > 0)
return 0;
r = read_one_line_file("/proc/cmdline", &line);
if (r < 0) {
log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
return 0;
}
FOREACH_WORD_QUOTED(w, l, line, state) {
char *word;
word = strndup(w, l);
if (!word) {
r = log_oom();
goto finish;
}
if (startswith(word, "fstab=")) {
r = parse_boolean(word + 6);
if (r < 0)
log_warning("Failed to parse fstab switch %s. Ignoring.", word + 6);
else
arg_enabled = r;
} else if (startswith(word, "rd.fstab=")) {
if (in_initrd()) {
r = parse_boolean(word + 6);
if (r < 0)
log_warning("Failed to parse fstab switch %s. Ignoring.", word + 6);
else
arg_enabled = r;
}
} else if (startswith(word, "fstab.") ||
(in_initrd() && startswith(word, "rd.fstab."))) {
log_warning("Unknown kernel switch %s. Ignoring.", word);
}
free(word);
}
开发者ID:intgr,项目名称:systemd,代码行数:48,代码来源:fstab-generator.c
示例6: condition_test_virtualization
static int condition_test_virtualization(Condition *c) {
int b, v;
assert(c);
assert(c->parameter);
assert(c->type == CONDITION_VIRTUALIZATION);
v = detect_virtualization();
if (v < 0)
return v;
/* First, compare with yes/no */
b = parse_boolean(c->parameter);
if (v > 0 && b > 0)
return true;
if (v == 0 && b == 0)
return true;
/* Then, compare categorization */
if (VIRTUALIZATION_IS_VM(v) && streq(c->parameter, "vm"))
return true;
if (VIRTUALIZATION_IS_CONTAINER(v) && streq(c->parameter, "container"))
return true;
/* Finally compare id */
return v != VIRTUALIZATION_NONE && streq(c->parameter, virtualization_to_string(v));
}
开发者ID:devkral,项目名称:systemd,代码行数:30,代码来源:condition.c
示例7: condition_test_virtualization
static int condition_test_virtualization(Condition *c) {
int b, v;
assert(c);
assert(c->parameter);
assert(c->type == CONDITION_VIRTUALIZATION);
if (streq(c->parameter, "private-users"))
return running_in_userns();
v = detect_virtualization();
if (v < 0)
return v;
/* First, compare with yes/no */
b = parse_boolean(c->parameter);
if (b >= 0)
return b == !!v;
/* Then, compare categorization */
if (streq(c->parameter, "vm"))
return VIRTUALIZATION_IS_VM(v);
if (streq(c->parameter, "container"))
return VIRTUALIZATION_IS_CONTAINER(v);
/* Finally compare id */
return v != VIRTUALIZATION_NONE && streq(c->parameter, virtualization_to_string(v));
}
开发者ID:Like-all,项目名称:tinysystemd-substrate,代码行数:29,代码来源:condition.c
示例8: parse_module
void parse_module(struct context *ctx, const char *cmd, const char *arg)
{
/* Label and description can be internationalized */
if (G_strcasecmp(cmd, "label") == 0) {
ctx->module->label = translate(xstrdup(arg));
return;
}
if (G_strcasecmp(cmd, "description") == 0) {
ctx->module->description = translate(xstrdup(arg));
return;
}
if (G_strcasecmp(cmd, "keywords") == 0) {
G_add_keyword(translate(xstrdup(arg)));
return;
}
if (G_strcasecmp(cmd, "overwrite") == 0) {
ctx->module->overwrite = parse_boolean(ctx, arg);
return;
}
if (G_strcasecmp(cmd, "end") == 0) {
ctx->state = S_TOPLEVEL;
return;
}
fprintf(stderr, _("Unknown module parameter \"%s\" at line %d\n"),
cmd, ctx->line);
}
开发者ID:caomw,项目名称:grass,代码行数:32,代码来源:parse.c
示例9: link_update_llmnr_support
static int link_update_llmnr_support(Link *l) {
_cleanup_free_ char *b = NULL;
int r;
assert(l);
r = sd_network_link_get_llmnr(l->ifindex, &b);
if (r < 0)
goto clear;
r = parse_boolean(b);
if (r < 0) {
if (streq(b, "resolve"))
l->llmnr_support = SUPPORT_RESOLVE;
else
goto clear;
} else if (r > 0)
l->llmnr_support = SUPPORT_YES;
else
l->llmnr_support = SUPPORT_NO;
return 0;
clear:
l->llmnr_support = SUPPORT_YES;
return r;
}
开发者ID:robertalks,项目名称:systemd,代码行数:28,代码来源:resolved-link.c
示例10: set_local_rtc
static int set_local_rtc(sd_bus *bus, char **args, unsigned n) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
int r, b;
assert(args);
assert(n == 2);
polkit_agent_open_if_enabled();
b = parse_boolean(args[1]);
if (b < 0) {
log_error("Failed to parse local RTC setting: %s", args[1]);
return b;
}
r = sd_bus_call_method(bus,
"org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
"SetLocalRTC",
&error,
NULL,
"bbb", b, arg_adjust_system_clock, arg_ask_password);
if (r < 0)
log_error("Failed to set local RTC: %s", bus_error_message(&error, -r));
return r;
}
开发者ID:chenyf,项目名称:systemd,代码行数:28,代码来源:timedatectl.c
示例11: config_parse_bool
int config_parse_bool(const char* unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
int k;
bool *b = data;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
k = parse_boolean(rvalue);
if (k < 0) {
log_syntax(unit, LOG_ERR, filename, line, -k,
"Failed to parse boolean value, ignoring: %s", rvalue);
return 0;
}
*b = !!k;
return 0;
}
开发者ID:ariscop,项目名称:systemd,代码行数:29,代码来源:conf-parser.c
示例12: set_ntp
static int set_ntp(sd_bus *bus, char **args, unsigned n) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
int b, r;
assert(args);
assert(n == 2);
polkit_agent_open_if_enabled();
b = parse_boolean(args[1]);
if (b < 0) {
log_error("Failed to parse NTP setting: %s", args[1]);
return b;
}
r = sd_bus_call_method(bus,
"org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
"SetNTP",
&error,
NULL,
"bb", b, arg_ask_password);
if (r < 0)
log_error("Failed to set ntp: %s", bus_error_message(&error, -r));
return r;
}
开发者ID:GuillaumeSeren,项目名称:systemd,代码行数:28,代码来源:timedatectl.c
示例13: condition_test_virtualization
static int condition_test_virtualization(Condition *c) {
int b, v;
const char *id;
assert(c);
assert(c->parameter);
assert(c->type == CONDITION_VIRTUALIZATION);
v = detect_virtualization(&id);
if (v < 0)
return v;
/* First, compare with yes/no */
b = parse_boolean(c->parameter);
if (v > 0 && b > 0)
return true;
if (v == 0 && b == 0)
return true;
/* Then, compare categorization */
if (v == VIRTUALIZATION_VM && streq(c->parameter, "vm"))
return true;
if (v == VIRTUALIZATION_CONTAINER && streq(c->parameter, "container"))
return true;
/* Finally compare id */
return v > 0 && streq(c->parameter, id);
}
开发者ID:blaskovic,项目名称:systemd-rhel,代码行数:31,代码来源:condition.c
示例14: read_only_image
static int read_only_image(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int b = true, r;
if (argc > 2) {
b = parse_boolean(argv[2]);
if (b < 0)
return log_error_errno(b, "Failed to parse boolean argument: %s", argv[2]);
}
r = acquire_bus(&bus);
if (r < 0)
return r;
(void) polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = sd_bus_call_method(
bus,
"org.freedesktop.portable1",
"/org/freedesktop/portable1",
"org.freedesktop.portable1.Manager",
"MarkImageReadOnly",
&error,
NULL,
"sb", argv[1], b);
if (r < 0)
return log_error_errno(r, "Could not mark image read-only: %s", bus_error_message(&error, r));
return 0;
}
开发者ID:l10n-tw,项目名称:systemd,代码行数:31,代码来源:portablectl.c
示例15: config_parse_bool
int config_parse_bool(
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
int k;
bool *b = data;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
if ((k = parse_boolean(rvalue)) < 0) {
log_error("[%s:%u] Failed to parse boolean value, ignoring: %s", filename, line, rvalue);
return 0;
}
*b = !!k;
return 0;
}
开发者ID:olegchir,项目名称:systemd,代码行数:26,代码来源:conf-parser.c
示例16: config_parse_tristate
int config_parse_tristate(
const char *filename,
unsigned line,
const char *section,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
int k;
int *b = data;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
/* Tristates are like booleans, but can also take the 'default' value, i.e. "-1" */
k = parse_boolean(rvalue);
if (k < 0) {
log_error("[%s:%u] Failed to parse boolean value, ignoring: %s", filename, line, rvalue);
return 0;
}
*b = !!k;
return 0;
}
开发者ID:olegchir,项目名称:systemd,代码行数:29,代码来源:conf-parser.c
示例17: set_ntp
static int set_ntp(DBusConnection *bus, char **args, unsigned n) {
_cleanup_dbus_message_unref_ DBusMessage *reply = NULL;
dbus_bool_t interactive = true, b;
int r;
assert(args);
assert(n == 2);
polkit_agent_open_if_enabled();
r = parse_boolean(args[1]);
if (r < 0) {
log_error("Failed to parse NTP setting: %s", args[1]);
return r;
}
b = r;
return bus_method_call_with_reply(
bus,
"org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
"org.freedesktop.timedate1",
"SetNTP",
&reply,
NULL,
DBUS_TYPE_BOOLEAN, &b,
DBUS_TYPE_BOOLEAN, &interactive,
DBUS_TYPE_INVALID);
}
开发者ID:felipec,项目名称:udev-fc,代码行数:30,代码来源:timedatectl.c
示例18: scope_deserialize_item
static int scope_deserialize_item(Unit *u, const char *key, const char *value, FDSet *fds) {
Scope *s = SCOPE(u);
assert(u);
assert(key);
assert(value);
assert(fds);
if (streq(key, "state")) {
ScopeState state;
state = scope_state_from_string(value);
if (state < 0)
log_unit_debug(u, "Failed to parse state value: %s", value);
else
s->deserialized_state = state;
} else if (streq(key, "was-abandoned")) {
int k;
k = parse_boolean(value);
if (k < 0)
log_unit_debug(u, "Failed to parse boolean value: %s", value);
else
s->was_abandoned = k;
} else
log_unit_debug(u, "Unknown serialization key: %s", key);
return 0;
}
开发者ID:OpenDZ,项目名称:systemd,代码行数:30,代码来源:scope.c
示例19: config_parse_quickack
int config_parse_quickack(const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
_cleanup_route_free_ Route *n = NULL;
Network *network = userdata;
int k, r;
assert(filename);
assert(section);
assert(lvalue);
assert(rvalue);
assert(data);
r = route_new_static(network, filename, section_line, &n);
if (r < 0)
return r;
k = parse_boolean(rvalue);
if (k < 0) {
log_syntax(unit, LOG_ERR, filename, line, k, "Failed to parse TCP quickack, ignoring: %s", rvalue);
return 0;
}
n->quickack = !!k;
n = NULL;
return 0;
}
开发者ID:Werkov,项目名称:systemd,代码行数:35,代码来源:networkd-route.c
示例20: parse_boolean
struct cmd_results *cmd_tiling_drag(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "tiling_drag", EXPECTED_EQUAL_TO, 1))) {
return error;
}
config->tiling_drag = parse_boolean(argv[0], config->tiling_drag);
return cmd_results_new(CMD_SUCCESS, NULL);
}
开发者ID:thejan2009,项目名称:sway,代码行数:10,代码来源:tiling_drag.c
注:本文中的parse_boolean函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论