本文整理汇总了C++中set_prop函数的典型用法代码示例。如果您正苦于以下问题:C++ set_prop函数的具体用法?C++ set_prop怎么用?C++ set_prop使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_prop函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cmd_debug_show_cursors
static void cmd_debug_show_cursors(struct watchman_client *client, json_t *args)
{
w_root_t *root;
json_t *resp, *cursors;
w_ht_iter_t i;
/* resolve the root */
if (json_array_size(args) != 2) {
send_error_response(client,
"wrong number of arguments for 'debug-show-cursors'");
return;
}
root = resolve_root_or_err(client, args, 1, false);
if (!root) {
return;
}
resp = make_response();
w_root_lock(root);
cursors = json_object_of_size(w_ht_size(root->cursors));
if (w_ht_first(root->cursors, &i)) do {
w_string_t *name = w_ht_val_ptr(i.key);
set_prop(cursors, name->buf, json_integer(i.value));
} while (w_ht_next(root->cursors, &i));
w_root_unlock(root);
set_prop(resp, "cursors", cursors);
send_and_dispose_response(client, resp);
w_root_delref(root);
}
示例2: cmd_watch
/* watch /root */
static void cmd_watch(struct watchman_client *client, json_t *args)
{
w_root_t *root;
json_t *resp;
/* resolve the root */
if (json_array_size(args) != 2) {
send_error_response(client, "wrong number of arguments to 'watch'");
return;
}
root = resolve_root_or_err(client, args, 1, true);
if (!root) {
return;
}
resp = make_response();
w_root_lock(root);
if (root->failure_reason) {
set_prop(resp, "error", json_string_nocheck(root->failure_reason->buf));
} else if (root->cancelled) {
set_prop(resp, "error", json_string_nocheck("root was cancelled"));
} else {
set_prop(resp, "watch", json_string_nocheck(root->root_path->buf));
}
send_and_dispose_response(client, resp);
w_root_unlock(root);
w_root_delref(root);
}
示例3: if
std::unique_ptr<cbmc_solverst::solvert> cbmc_solverst::get_default()
{
auto solver=util_make_unique<solvert>();
if(options.get_bool_option("beautify") ||
!options.get_bool_option("sat-preprocessor")) // no simplifier
{
// simplifier won't work with beautification
solver->set_prop(util_make_unique<satcheck_no_simplifiert>());
}
else // with simplifier
{
solver->set_prop(util_make_unique<satcheckt>());
}
solver->prop().set_message_handler(get_message_handler());
auto bv_cbmc=util_make_unique<bv_cbmct>(ns, solver->prop());
if(options.get_option("arrays-uf")=="never")
bv_cbmc->unbounded_array=bv_cbmct::unbounded_arrayt::U_NONE;
else if(options.get_option("arrays-uf")=="always")
bv_cbmc->unbounded_array=bv_cbmct::unbounded_arrayt::U_ALL;
solver->set_prop_conv(std::move(bv_cbmc));
return solver;
}
示例4: cmd_find
/* find /root [patterns] */
static void cmd_find(struct watchman_client *client, json_t *args)
{
w_root_t *root;
w_query *query;
char *errmsg = NULL;
struct w_query_field_list field_list;
w_query_res res;
json_t *response;
json_t *file_list;
char clockbuf[128];
/* resolve the root */
if (json_array_size(args) < 2) {
send_error_response(client, "not enough arguments for 'find'");
return;
}
root = resolve_root_or_err(client, args, 1, false);
if (!root) {
return;
}
query = w_query_parse_legacy(root, args, &errmsg, 2, NULL, NULL, NULL);
if (errmsg) {
send_error_response(client, "%s", errmsg);
free(errmsg);
w_root_delref(root);
return;
}
w_query_legacy_field_list(&field_list);
if (client->client_mode) {
query->sync_timeout = 0;
}
if (!w_query_execute(query, root, &res, NULL, NULL)) {
send_error_response(client, "query failed: %s", res.errmsg);
w_query_result_free(&res);
w_root_delref(root);
w_query_delref(query);
return;
}
w_query_delref(query);
file_list = w_query_results_to_json(&field_list,
res.num_results, res.results);
w_query_result_free(&res);
response = make_response();
if (clock_id_string(res.root_number, res.ticks, clockbuf, sizeof(clockbuf))) {
set_prop(response, "clock", json_string_nocheck(clockbuf));
}
set_prop(response, "files", file_list);
send_and_dispose_response(client, response);
w_root_delref(root);
}
示例5: w_log
static json_t *build_subscription_results(
struct watchman_client_subscription *sub,
w_root_t *root)
{
w_query_res res;
json_t *response;
json_t *file_list;
char clockbuf[128];
w_log(W_LOG_DBG, "running subscription rules! since %" PRIu32 "\n",
sub->since.ticks);
// Subscriptions never need to sync explicitly; we are only dispatched
// at settle points which are by definition sync'd to the present time
sub->query->sync_timeout = 0;
if (!w_query_execute(sub->query, root, &res, subscription_generator, sub)) {
w_log(W_LOG_ERR, "error running subscription query: %s", res.errmsg);
w_query_result_free(&res);
return NULL;
}
w_log(W_LOG_DBG, "subscription generated %" PRIu32 " results\n",
res.num_results);
file_list = w_query_results_to_json(&sub->field_list,
res.num_results, res.results);
w_query_result_free(&res);
if (res.num_results == 0) {
return NULL;
}
response = make_response();
if (clock_id_string(sub->since.ticks, clockbuf, sizeof(clockbuf))) {
set_prop(response, "since", json_string_nocheck(clockbuf));
}
if (clock_id_string(res.ticks, clockbuf, sizeof(clockbuf))) {
set_prop(response, "clock", json_string_nocheck(clockbuf));
}
sub->since.is_timestamp = false;
sub->since.ticks = res.ticks;
set_prop(response, "files", file_list);
set_prop(response, "root", json_string(root->root_path->buf));
set_prop(response, "subscription", json_string(sub->name->buf));
return response;
}
示例6: cmd_debug_ageout
/* debug-ageout */
static void cmd_debug_ageout(struct watchman_client *client, json_t *args)
{
w_root_t *root;
json_t *resp;
int min_age;
/* resolve the root */
if (json_array_size(args) != 3) {
send_error_response(client,
"wrong number of arguments for 'debug-ageout'");
return;
}
root = resolve_root_or_err(client, args, 1, false);
if (!root) {
return;
}
min_age = json_integer_value(json_array_get(args, 2));
resp = make_response();
w_root_lock(root);
w_root_perform_age_out(root, min_age);
w_root_unlock(root);
set_prop(resp, "ageout", json_true());
send_and_dispose_response(client, resp);
w_root_delref(root);
}
示例7: cmd_debug_recrawl
static void cmd_debug_recrawl(struct watchman_client *client, json_t *args)
{
w_root_t *root;
json_t *resp;
/* resolve the root */
if (json_array_size(args) != 2) {
send_error_response(client,
"wrong number of arguments for 'debug-recrawl'");
return;
}
root = resolve_root_or_err(client, args, 1, false);
if (!root) {
return;
}
resp = make_response();
w_root_lock(root);
w_root_schedule_recrawl(root, "debug-recrawl");
w_root_unlock(root);
set_prop(resp, "recrawl", json_true());
send_and_dispose_response(client, resp);
w_root_delref(root);
}
示例8: send_error_response
void send_error_response(struct watchman_client *client,
const char *fmt, ...)
{
char buf[WATCHMAN_NAME_MAX];
va_list ap;
json_t *resp = make_response();
json_t *errstr;
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
errstr = typed_string_to_json(buf, W_STRING_MIXED);
set_prop(resp, "error", errstr);
json_incref(errstr);
w_perf_add_meta(&client->perf_sample, "error", errstr);
if (client->current_command) {
char *command = NULL;
command = json_dumps(client->current_command, 0);
w_log(W_LOG_ERR, "send_error_response: %s failed: %s\n",
command, buf);
free(command);
} else {
w_log(W_LOG_ERR, "send_error_response: %s\n", buf);
}
send_and_dispose_response(client, resp);
}
示例9: w_log_to_clients
void w_log_to_clients(int level, const char *buf)
{
json_t *json = NULL;
w_ht_iter_t iter;
if (!clients) {
return;
}
pthread_mutex_lock(&w_client_lock);
if (w_ht_first(clients, &iter)) do {
struct watchman_client *client = w_ht_val_ptr(iter.value);
if (client->log_level != W_LOG_OFF && client->log_level >= level) {
json = make_response();
if (json) {
set_prop(json, "log", json_string_nocheck(buf));
if (!enqueue_response(client, json, true)) {
json_decref(json);
}
}
}
} while (w_ht_next(clients, &iter));
pthread_mutex_unlock(&w_client_lock);
}
示例10: read_prop
int read_prop(MNL_CONFIG_T* prConfig, const char* name)
{
FILE *fp = fopen(name, "rb");
char *key, *val;
if (!fp){
MNL_MSG("%s: open %s fail!\n",__FUNCTION__,name);
return -1;
}
while(fgets(propbuf, sizeof(propbuf), fp))
{
if (get_prop(propbuf, &key, &val))
{
MNL_MSG("%s: Get Property fails!!\n", __FUNCTION__);
fclose(fp);
return -1;
}
if (!key || !val)
continue;
//MNL_MSG("%s: Get Property: '%s' => '%s'\n", __FUNCTION__, key, val);
if (set_prop(prConfig, key,val))
{
MNL_ERR("%s: Set Property fails!!\n", __FUNCTION__);
fclose(fp);
return -1;
}
}
fclose(fp);
return 0;
}
示例11: annotate_with_clock
/* Add the current clock value to the response.
* must be called with the root locked */
void annotate_with_clock(w_root_t *root, json_t *resp) {
char buf[128];
if (current_clock_id_string(root, buf, sizeof(buf))) {
set_prop(resp, "clock", json_string_nocheck(buf));
}
}
示例12: print_props
static void
print_props(topo_hdl_t *thp, tnode_t *node)
{
int i, err;
nvlist_t *nvl;
struct prop_args *pp;
if (pcnt == 0)
return;
for (i = 0; i < pcnt; ++i) {
pp = pargs[i];
if (pp->group == NULL)
continue;
/*
* If we have a valid value, this is a request to
* set a property. Otherwise, just print the property
* group and any specified properties.
*/
if (pp->value == NULL) {
if (pp->prop == NULL) {
/*
* Print all properties in this group
*/
if ((nvl = topo_prop_getprops(node, &err))
== NULL) {
(void) fprintf(stderr, "%s: failed to "
"get %s: %s\n", g_pname,
pp->group,
topo_strerror(err));
continue;
} else {
print_all_props(thp, node, nvl,
pp->group);
nvlist_free(nvl);
continue;
}
}
if (topo_prop_getprop(node, pp->group, pp->prop,
NULL, &nvl, &err) < 0) {
(void) fprintf(stderr, "%s: failed to get "
"%s.%s: %s\n", g_pname,
pp->group, pp->prop,
topo_strerror(err));
continue;
} else {
print_pgroup(thp, node, pp->group, NULL,
NULL, 0);
print_prop_nameval(thp, node, nvl);
nvlist_free(nvl);
}
} else {
set_prop(thp, node, NULL, pp);
}
}
}
示例13: json_object
json_t *make_response(void)
{
json_t *resp = json_object();
set_prop(resp, "version", json_string_nocheck(PACKAGE_VERSION));
return resp;
}
示例14: cmd_get_pid
/* get-pid */
void cmd_get_pid(struct watchman_client *client, json_t *args)
{
json_t *resp = make_response();
unused_parameter(args);
set_prop(resp, "pid", json_integer(getpid()));
send_and_dispose_response(client, resp);
}
示例15: cmd_get_sockname
/* get-sockname */
void cmd_get_sockname(struct watchman_client *client, json_t *args)
{
json_t *resp = make_response();
unused_parameter(args);
set_prop(resp, "sockname", json_string(get_sock_name()));
send_and_dispose_response(client, resp);
}