/* SYNTAX: SET [-clear] [<key> [<value>] */ static void cmd_set(char *data) { GHashTable *optlist; GSList *sets, *tmp; const char *last_section; char *key, *value; void *free_arg; int found, clear; if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST | PARAM_FLAG_OPTIONS, "set", &optlist, &key, &value)) return; clear = g_hash_table_lookup(optlist, "clear") != NULL; last_section = ""; found = 0; sets = settings_get_sorted(); for (tmp = sets; tmp != NULL; tmp = tmp->next) { SETTINGS_REC *rec = tmp->data; if (((clear || *value != '\0') && g_strcasecmp(rec->key, key) != 0) || (*value == '\0' && *key != '\0' && stristr(rec->key, key) == NULL)) continue; if (strcmp(last_section, rec->section) != 0) { /* print section */ printtext(NULL, NULL, MSGLEVEL_CLIENTCRAP, "%_[ %s ]", rec->section); last_section = rec->section; } if (clear || *value != '\0') { /* change the setting */ switch (rec->type) { case SETTING_TYPE_BOOLEAN: set_boolean(key, clear ? FALSE : value); break; case SETTING_TYPE_INT: settings_set_int(key, clear ? 0 : atoi(value)); break; case SETTING_TYPE_STRING: settings_set_str(key, clear ? "" : value); break; } signal_emit("setup changed", 0); } set_print(rec); found = TRUE; if (clear || *value != '\0') break; } g_slist_free(sets); if (!found) printtext(NULL, NULL, MSGLEVEL_CLIENTERROR, "Unknown setting %s", key); cmd_params_free(free_arg); }
/* SYNTAX: TOGGLE <key> [on|off|toggle] */ static void cmd_toggle(const char *data) { char *key, *value; void *free_arg; int type; if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST | PARAM_FLAG_STRIP_TRAILING_WS, &key, &value)) return; if (*key == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); type = settings_get_type(key); if (type == SETTING_TYPE_ANY) printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_SET_UNKNOWN, key); else if (type != SETTING_TYPE_BOOLEAN) printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_SET_NOT_BOOLEAN, key); else { set_boolean(key, *value != '\0' ? value : "TOGGLE"); set_print(settings_get_record(key)); signal_emit("setup changed", 0); } cmd_params_free(free_arg); }
int set_pass_peer (char *word, char *value, int context, void *item) { switch (context & ~CONTEXT_DEFAULT) { case CONTEXT_LAC: if (set_boolean (word, value, &(((struct lac *) item)->pass_peer))) return -1; break; case CONTEXT_LNS: if (set_boolean (word, value, &(((struct lns *) item)->pass_peer))) return -1; break; default: snprintf (filerr, sizeof (filerr), "'%s' not valid in this context\n", word); return -1; } return 0; }
static int load_constants(struct load_state *S, ktap_proto *f) { int i,n; n = READ_INT(S); f->sizek = n; f->k = NEW_VECTOR(S, n * sizeof(ktap_value)); for (i = 0; i < n; i++) set_nil(&f->k[i]); for (i=0; i < n; i++) { ktap_value *o = &f->k[i]; int t = READ_CHAR(S); switch (t) { case KTAP_TNIL: set_nil(o); break; case KTAP_TBOOLEAN: set_boolean(o, READ_CHAR(S)); break; case KTAP_TNUMBER: /* * todo: kernel not support fp, check double when * loading */ set_number(o, READ_NUMBER(S)); break; case KTAP_TSTRING: set_string(o, READ_STRING(S)); break; default: kp_error(S->ks, "ktap: load_constants: " "unknow ktap_value\n"); return -1; } } n = READ_INT(S); f->p = NEW_VECTOR(S, n * sizeof(ktap_proto)); f->sizep = n; for (i = 0; i < n; i++) f->p[i] = NULL; for (i = 0; i < n; i++) { f->p[i] = kp_newproto(S->ks); if (load_function(S, f->p[i])) return -1; } return 0; }
int set_papchap (char *word, char *value, int context, void *item) { int result; char *c; struct lac *l = (struct lac *) item; struct lns *n = (struct lns *) item; if (set_boolean (word, value, &result)) return -1; c = strchr (word, ' '); c++; switch (context & ~CONTEXT_DEFAULT) { case CONTEXT_LAC: if (c[0] == 'p') /* PAP */ if (word[2] == 'f') l->pap_refuse = result; else l->pap_require = result; else if (c[0] == 'a') /* Authentication */ if (word[2] == 'f') l->authself = !result; else l->authpeer = result; else /* CHAP */ if (word[2] == 'f') l->chap_refuse = result; else l->chap_require = result; break; case CONTEXT_LNS: if (c[0] == 'p') /* PAP */ if (word[2] == 'f') n->pap_refuse = result; else n->pap_require = result; else if (c[0] == 'a') /* Authentication */ if (word[2] == 'f') n->authself = !result; else n->authpeer = result; else /* CHAP */ if (word[2] == 'f') n->chap_refuse = result; else n->chap_require = result; break; default: snprintf (filerr, sizeof (filerr), "'%s' not valid in this context\n", word); return -1; } return 0; }
bool parmlist_get_bool(struct parmlist *ctx, const char *name, bool default_v) { struct parmlist_entry *p = parmlist_get(ctx, name); bool ret; if (p == NULL) return default_v; if (!set_boolean(p->value, &ret)) { DEBUG(0,("lp_bool(%s): value is not boolean!\n", p->value)); return default_v; } return ret; }
int set_debugstate (char *word, char *value, int context, void *item) { switch (context & ~CONTEXT_DEFAULT) { case CONTEXT_GLOBAL: if (set_boolean (word, value, &(((struct global *) item)->debug_state))) return -1; break; default: snprintf (filerr, sizeof (filerr), "'%s' not valid in this context\n", word); return -1; } return 0; }
/** * Parse a string containing a boolean value. * * val will be set to the read value. * * @retval true if a boolean value was parsed, false otherwise. */ _PUBLIC_ bool conv_str_bool(const char * str, bool * val) { char * end = NULL; long lval; if (str == NULL || *str == '\0') { return false; } lval = strtol(str, &end, 10 /* base */); if (end == NULL || *end != '\0' || end == str) { return set_boolean(str, val); } *val = (lval) ? true : false; return true; }
int set_ipsec_saref (char *word, char *value, int context, void *item) { struct global *g = ((struct global *) item); switch (context & ~CONTEXT_DEFAULT) { case CONTEXT_GLOBAL: if (set_boolean (word, value, &(g->ipsecsaref))) return -1; if(g->ipsecsaref) { l2tp_log(LOG_WARNING, "Enabling IPsec SAref processing for L2TP transport mode SAs\n"); } break; default: snprintf (filerr, sizeof (filerr), "'%s' not valid in this context\n", word); return -1; } return 0; }
/* SYNTAX: TOGGLE <key> [on|off|toggle] */ static void cmd_toggle(const char *data) { char *key, *value; void *free_arg; int type; if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST, &key, &value)) return; if (*key == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); type = settings_get_type(key); if (type == -1) printtext(NULL, NULL, MSGLEVEL_CLIENTERROR, "Unknown setting %_%s", key); else if (type != SETTING_TYPE_BOOLEAN) printtext(NULL, NULL, MSGLEVEL_CLIENTERROR, "Setting %_%s%_ isn't boolean, use /SET", key); else { set_boolean(key, *value != '\0' ? value : "TOGGLE"); set_print(settings_get_record(key)); } cmd_params_free(free_arg); }
int set_flow (char *word, char *value, int context, void *item) { int v; set_boolean (word, value, &v); if (v < 0) return -1; switch (context & ~CONTEXT_DEFAULT) { case CONTEXT_LAC: if (v) { if (((struct lac *) item)->call_rws < 0) ((struct lac *) item)->call_rws = 0; } else { ((struct lac *) item)->call_rws = -1; } break; case CONTEXT_LNS: if (v) { if (((struct lns *) item)->call_rws < 0) ((struct lns *) item)->call_rws = 0; } else { ((struct lns *) item)->call_rws = -1; } break; default: snprintf (filerr, sizeof (filerr), "'%s' not valid in this context\n", word); return -1; } return 0; }
bool do_common_parameter(vscan_config_struct *vscan_config, const char *param, const char *value) { /* we assume we handled a common parameter */ bool ret = True; if ( StrCaseCmp("max file size", param) == 0 ) { /* FIXME: sanity check missing! what, if value is out of range? atoi returns int - what about LFS? atoi should be avoided! */ /* FIXME: changed atoi to atoll, but atoll might not be available on all platforms! */ vscan_config->common.max_size = atoll(value); DEBUG(3, ("max file size is: %lld\n", (long long)vscan_config->common.max_size)); } else if ( StrCaseCmp("verbose file logging", param) == 0 ) { set_boolean(value, &vscan_config->common.verbose_file_logging); DEBUG(3, ("verbose file logging is: %d\n", vscan_config->common.verbose_file_logging)); } else if ( StrCaseCmp("scan on open", param) == 0 ) { set_boolean(value, &vscan_config->common.scan_on_open); DEBUG(3, ("scan on open: %d\n", vscan_config->common.scan_on_open)); } else if ( StrCaseCmp("scan on close", param) == 0 ) { set_boolean(value, &vscan_config->common.scan_on_close); DEBUG(3, ("scan on close is: %d\n", vscan_config->common.scan_on_close)); } else if ( StrCaseCmp("deny access on error", param) == 0 ) { set_boolean(value, &vscan_config->common.deny_access_on_error); DEBUG(3, ("deny access on error is: %d\n", vscan_config->common.deny_access_on_error)); } else if ( StrCaseCmp("deny access on minor error", param) == 0 ) { set_boolean(value, &vscan_config->common.deny_access_on_minor_error); DEBUG(3, ("deny access on minor error is: %d\n", vscan_config->common.deny_access_on_minor_error)); } else if ( StrCaseCmp("send warning message", param) == 0 ) { set_boolean(value, &vscan_config->common.send_warning_message); DEBUG(3, ("send warning message is: %d\n", vscan_config->common.send_warning_message)); } else if ( StrCaseCmp("infected file action", param) == 0 ) { if (StrCaseCmp("quarantine", value) == 0) { vscan_config->common.infected_file_action = INFECTED_QUARANTINE; } else if (StrCaseCmp("delete", value) == 0) { vscan_config->common.infected_file_action = INFECTED_DELETE; } else if (StrCaseCmp("nothing", value) == 0) { vscan_config->common.infected_file_action = INFECTED_DO_NOTHING; } else { DEBUG(2, ("samba-vscan: badly formed infected file action in configuration file, parameter %s\n", value)); } DEBUG(3, ("infected file action is: %d\n", vscan_config->common.infected_file_action)); } else if ( StrCaseCmp("quarantine directory", param) == 0 ) { fstrcpy(vscan_config->common.quarantine_dir, value); DEBUG(3, ("quarantine directory is: %s\n", vscan_config->common.quarantine_dir)); } else if ( StrCaseCmp("quarantine prefix", param) == 0 ) { fstrcpy(vscan_config->common.quarantine_prefix, value); DEBUG(3, ("quarantine prefix is: %s\n", vscan_config->common.quarantine_prefix)); } else if ( StrCaseCmp("max lru files entries", param) == 0 ) { vscan_config->common.max_lrufiles = atoi(value); DEBUG(3, ("max lru files entries is: %d\n", vscan_config->common.max_lrufiles)); } else if ( StrCaseCmp("lru file entry lifetime", param) == 0 ) { vscan_config->common.lrufiles_invalidate_time = atol(value); DEBUG(3, ("lru file entry lifetime is: %li\n", (long)vscan_config->common.lrufiles_invalidate_time)); } else if ( StrCaseCmp("exclude file types", param) == 0 ) { pstrcpy(vscan_config->common.exclude_file_types, value); DEBUG(3, ("exclude file type list is: %s\n", vscan_config->common.exclude_file_types)); } else if ( StrCaseCmp("exclude file regexp", param) == 0 ) { pstrcpy(vscan_config->common.exclude_file_regexp, value); DEBUG(3, ("exclude file regexp is: %s\n", vscan_config->common.exclude_file_regexp)); } else { /* unknown common parameter, it must be handled by corresponding module */ DEBUG(5, ("unkown common parameter: %s\n", param)); ret = False; } return ret; }
struct config* parse_config(FILE *input) { struct config *config = malloc(sizeof(struct config)); if (config == NULL) { stats_error_log("malloc() error"); return NULL; } init_proto_config(&config->carbon_config); if (config->carbon_config.ring == NULL) { stats_error_log("failed to allocate ring"); free(config); return NULL; } config->carbon_config.bind = strdup("127.0.0.1:2003"); init_proto_config(&config->statsd_config); config->statsd_config.bind = strdup("127.0.0.1:8125"); yaml_parser_t parser; yaml_event_t event; if (!yaml_parser_initialize(&parser)) { stats_log("failed to initialize yaml parser"); goto parse_err; } yaml_parser_set_input_file(&parser, input); struct proto_config *protoc = NULL; char *strval; long numval; int shard_count = -1; int map_nesting = 0; bool in_document = false; bool keep_going = true; bool is_key = false; bool update_bind = false; bool update_send_queue = false; bool update_validate = false; bool update_tcp_cork = false; bool always_resolve_dns = false; bool expect_shard_map = false; while (keep_going) { if (!yaml_parser_parse(&parser, &event)) { goto parse_err; } switch(event.type) { case YAML_NO_EVENT: case YAML_STREAM_START_EVENT: break; // nothing to do case YAML_STREAM_END_EVENT: keep_going = false; break; case YAML_DOCUMENT_START_EVENT: if (in_document) { stats_error_log("config should not have nested documents"); goto parse_err; } in_document = true; break; case YAML_DOCUMENT_END_EVENT: in_document = false; break; case YAML_SEQUENCE_START_EVENT: case YAML_SEQUENCE_END_EVENT: stats_error_log("unexpectedly got sequence"); goto parse_err; break; case YAML_MAPPING_START_EVENT: is_key = true; map_nesting++; break; case YAML_MAPPING_END_EVENT: map_nesting--; break; case YAML_ALIAS_EVENT: stats_error_log("don't know how to handle yaml aliases"); goto parse_err; break; case YAML_SCALAR_EVENT: strval = (char *) event.data.scalar.value; switch (map_nesting) { case 0: stats_error_log("unexpectedly got scalar outside of a map"); goto parse_err; break; case 1: if (strcmp(strval, "carbon") == 0) { protoc = &config->carbon_config; config->carbon_config.initialized = true; } else if (strcmp(strval, "statsd") == 0) { protoc = &config->statsd_config; config->statsd_config.initialized = true; } else { stats_error_log("unexpectedly got map value: \"%s\"", strval); goto parse_err; } break; case 2: if (is_key) { if (strcmp(strval, "bind") == 0) { update_bind = true; } else if (strcmp(strval, "max_send_queue") == 0) { update_send_queue = true; } else if (strcmp(strval, "shard_map") == 0) { shard_count = -1; expect_shard_map = true; } else if (strcmp(strval, "validate") == 0) { update_validate = true; } else if (strcmp(strval, "tcp_cork") == 0) { update_tcp_cork = true; } else if (strcmp(strval, "always_resolve_dns") == 0) { always_resolve_dns = true; } } else { if (update_bind) { free(protoc->bind); protoc->bind = strdup(strval); update_bind = false; } else if (update_send_queue) { if (!convert_number(strval, &numval)) { stats_error_log("max_send_queue was not a number: %s", strval); } protoc->max_send_queue = numval; update_send_queue = false; } else if (update_validate) { if (!set_boolean(strval, &protoc->enable_validation)) { goto parse_err; } update_validate = false; } else if (update_tcp_cork) { if (!set_boolean(strval, &protoc->enable_tcp_cork)) { goto parse_err; } update_tcp_cork = false; } else if (always_resolve_dns) { if (!set_boolean(strval, &protoc->always_resolve_dns)) { goto parse_err; } } } break; case 3: if (!expect_shard_map) { stats_error_log("was not expecting shard map"); goto parse_err; } else if (is_key) { if (!convert_number(strval, &numval)) { stats_error_log("shard key was not a number: \"%s\"", strval); goto parse_err; } shard_count++; if (numval != shard_count) { stats_error_log("expected to see shard key %d, instead saw %d", shard_count, numval); goto parse_err; } } else { if (statsrelay_list_expand(protoc->ring) == NULL) { stats_error_log("unable to expand list"); goto parse_err; } if ((protoc->ring->data[protoc->ring->size - 1] = strdup(strval)) == NULL) { stats_error_log("failed to copy string"); goto parse_err; } } } is_key = !is_key; break; default: stats_error_log("unhandled yaml event"); goto parse_err; } yaml_event_delete(&event); } yaml_parser_delete(&parser); return config; parse_err: destroy_config(config); yaml_event_delete(&event); yaml_parser_delete(&parser); return NULL; }
XPathObject::XPathObject(bool value) : impl(std::make_shared<XPathObject_Impl>()) { set_boolean(value); }
static gboolean entry_billable_handler (xmlNodePtr node, gpointer entry_pdata) { struct entry_pdata *pdata = entry_pdata; return set_boolean (node, pdata->entry, gncEntrySetBillable); }
static gboolean entry_btaxincluded_handler (xmlNodePtr node, gpointer entry_pdata) { struct entry_pdata *pdata = entry_pdata; return set_boolean (node, pdata->entry, gncEntrySetBillTaxIncluded); }
static gboolean vendor_taxtableoverride_handler (xmlNodePtr node, gpointer vendor_pdata) { struct vendor_pdata* pdata = static_cast<decltype (pdata)> (vendor_pdata); return set_boolean (node, pdata->vendor, gncVendorSetTaxTableOverride); }
static gboolean vendor_active_handler (xmlNodePtr node, gpointer vendor_pdata) { struct vendor_pdata* pdata = static_cast<decltype (pdata)> (vendor_pdata); return set_boolean (node, pdata->vendor, gncVendorSetActive); }
static gboolean entry_itaxincluded_handler (xmlNodePtr node, gpointer entry_pdata) { struct entry_pdata* pdata = static_cast<decltype (pdata)> (entry_pdata); return set_boolean (node, pdata->entry, gncEntrySetInvTaxIncluded); }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Set current render session pause state ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void BlenderSync::set_session_pause_state(BL::Scene b_scene, bool state) { PointerRNA oct_scene = RNA_pointer_get(&b_scene.ptr, "octane"); set_boolean(oct_scene, "preview_pause", state); } //get_session_pause_state()
/* SYNTAX: SET [-clear | -default] [<key> [<value>]] */ static void cmd_set(char *data) { GHashTable *optlist; char *key, *value; void *free_arg; int clear, set_default; SETTINGS_REC *rec; if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_GETREST | PARAM_FLAG_OPTIONS, "set", &optlist, &key, &value)) return; clear = g_hash_table_lookup(optlist, "clear") != NULL; set_default = g_hash_table_lookup(optlist, "default") != NULL; if (*key == '\0') clear = set_default = FALSE; if (!(clear || set_default || *value != '\0')) set_print_pattern(key); else { rec = settings_get_record(key); if (rec != NULL) { /* change the setting */ switch (rec->type) { case SETTING_TYPE_BOOLEAN: if (clear) settings_set_bool(key, FALSE); else if (set_default) settings_set_bool(key, rec->default_value.v_bool); else set_boolean(key, value); break; case SETTING_TYPE_INT: if (clear) settings_set_int(key, 0); else if (set_default) settings_set_int(key, rec->default_value.v_int); else set_int(key, value); break; case SETTING_TYPE_CHOICE: if (clear || set_default) settings_set_choice(key, rec->choices[rec->default_value.v_int]); else set_choice(key, value); break; case SETTING_TYPE_STRING: settings_set_str(key, clear ? "" : set_default ? rec->default_value.v_string : value); break; case SETTING_TYPE_TIME: if (!settings_set_time(key, clear ? "0" : set_default ? rec->default_value.v_string : value)) printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_INVALID_TIME); break; case SETTING_TYPE_LEVEL: if (!settings_set_level(key, clear ? "" : set_default ? rec->default_value.v_string : value)) printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_INVALID_LEVEL); break; case SETTING_TYPE_SIZE: if (!settings_set_size(key, clear ? "0" : set_default ? rec->default_value.v_string : value)) printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_INVALID_SIZE); break; case SETTING_TYPE_ANY: /* Unpossible! */ break; } signal_emit("setup changed", 0); printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_SET_TITLE, rec->section); set_print(rec); } else printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_SET_UNKNOWN, key); } cmd_params_free(free_arg); }
static gboolean entry_billable_handler (xmlNodePtr node, gpointer entry_pdata) { struct entry_pdata* pdata = static_cast<decltype (pdata)> (entry_pdata); return set_boolean (node, pdata->entry, gncEntrySetBillable); }
static gboolean customer_active_handler (xmlNodePtr node, gpointer cust_pdata) { struct customer_pdata *pdata = cust_pdata; return set_boolean (node, pdata->customer, gncCustomerSetActive); }
CL_XPathObject::CL_XPathObject(bool value) : impl(new CL_XPathObject_Impl) { set_boolean(value); }
static void popt_common_credentials_callback(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, const void *data) { if (reason == POPT_CALLBACK_REASON_PRE) { cmdline_credentials = cli_credentials_init(talloc_autofree_context()); return; } if (reason == POPT_CALLBACK_REASON_POST) { cli_credentials_guess(cmdline_credentials, cmdline_lp_ctx); if (!dont_ask) { cli_credentials_set_cmdline_callbacks(cmdline_credentials); } return; } switch(opt->val) { case 'U': { char *lp; cli_credentials_parse_string(cmdline_credentials, arg, CRED_SPECIFIED); /* This breaks the abstraction, including the const above */ if ((lp=strchr_m(arg,'%'))) { lp[0]='\0'; lp++; /* Try to prevent this showing up in ps */ memset(lp,0,strlen(lp)); } } break; case OPT_PASSWORD: cli_credentials_set_password(cmdline_credentials, arg, CRED_SPECIFIED); /* Try to prevent this showing up in ps */ memset(discard_const(arg),0,strlen(arg)); break; case 'A': cli_credentials_parse_file(cmdline_credentials, arg, CRED_SPECIFIED); break; case 'P': /* Later, after this is all over, get the machine account details from the secrets.ldb */ cli_credentials_set_machine_account_pending(cmdline_credentials, cmdline_lp_ctx); break; case OPT_KERBEROS: { bool use_kerberos = true; /* Force us to only use kerberos */ if (arg) { if (!set_boolean(arg, &use_kerberos)) { fprintf(stderr, "Error parsing -k %s\n", arg); exit(1); break; } } cli_credentials_set_kerberos_state(cmdline_credentials, use_kerberos ? CRED_MUST_USE_KERBEROS : CRED_DONT_USE_KERBEROS); break; } case OPT_SIMPLE_BIND_DN: cli_credentials_set_bind_dn(cmdline_credentials, arg); break; } }
static gboolean customer_taxtableoverride_handler (xmlNodePtr node, gpointer cust_pdata) { struct customer_pdata *pdata = cust_pdata; return set_boolean (node, pdata->customer, gncCustomerSetTaxTableOverride); }