本文整理汇总了C++中set_prop函数的典型用法代码示例。如果您正苦于以下问题:C++ set_prop函数的具体用法?C++ set_prop怎么用?C++ set_prop使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_prop函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:niclasr,项目名称:watchman,代码行数:33,代码来源:debug.c
示例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);
}
开发者ID:Kingside,项目名称:watchman,代码行数:31,代码来源:watch.c
示例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;
}
开发者ID:theyoucheng,项目名称:cbmc,代码行数:28,代码来源:cbmc_solvers.cpp
示例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);
}
开发者ID:0-wiz-0,项目名称:watchman,代码行数:60,代码来源:find.c
示例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;
}
开发者ID:CSRedRat,项目名称:watchman,代码行数:49,代码来源:subscribe.c
示例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);
}
开发者ID:niclasr,项目名称:watchman,代码行数:32,代码来源:debug.c
示例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);
}
开发者ID:niclasr,项目名称:watchman,代码行数:28,代码来源:debug.c
示例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);
}
开发者ID:arnonhongklay,项目名称:watchman,代码行数:30,代码来源:listener.c
示例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);
}
开发者ID:CamphorRain,项目名称:watchman,代码行数:26,代码来源:listener.c
示例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;
}
开发者ID:AwaisKing,项目名称:mt6577_aosp_source,代码行数:29,代码来源:mnl_common_6620.c
示例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));
}
}
开发者ID:1514louluo,项目名称:watchman,代码行数:9,代码来源:clockspec.c
示例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);
}
}
}
开发者ID:CoryXie,项目名称:opensolaris,代码行数:59,代码来源:fmtopo.c
示例13: json_object
json_t *make_response(void)
{
json_t *resp = json_object();
set_prop(resp, "version", json_string_nocheck(PACKAGE_VERSION));
return resp;
}
开发者ID:CamphorRain,项目名称:watchman,代码行数:8,代码来源:listener.c
示例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);
}
开发者ID:CCoder123,项目名称:watchman,代码行数:11,代码来源:info.c
示例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);
}
开发者ID:CCoder123,项目名称:watchman,代码行数:11,代码来源:info.c
示例16: cmd_trigger_delete
/* trigger-del /root triggername
* Delete a trigger from a root
*/
static void cmd_trigger_delete(struct watchman_client *client, json_t *args)
{
w_root_t *root;
json_t *resp;
json_t *jname;
w_string_t *tname;
bool res;
root = resolve_root_or_err(client, args, 1, false);
if (!root) {
return;
}
if (json_array_size(args) != 3) {
send_error_response(client, "wrong number of arguments");
w_root_delref(root);
return;
}
jname = json_array_get(args, 2);
if (!json_is_string(jname)) {
send_error_response(client, "expected 2nd parameter to be trigger name");
w_root_delref(root);
return;
}
tname = json_to_w_string_incref(jname);
w_root_lock(root, "trigger-del");
res = w_ht_del(root->commands, w_ht_ptr_val(tname));
w_root_unlock(root);
if (res) {
w_state_save();
}
w_string_delref(tname);
resp = make_response();
set_prop(resp, "deleted", json_boolean(res));
json_incref(jname);
set_prop(resp, "trigger", jname);
send_and_dispose_response(client, resp);
w_root_delref(root);
}
开发者ID:iamchenxin,项目名称:watchman,代码行数:46,代码来源:trigger.c
示例17: cmd_shutdown
static void cmd_shutdown(struct watchman_client *client, json_t *args) {
json_t *resp = make_response();
unused_parameter(args);
w_log(W_LOG_ERR, "shutdown-server was requested, exiting!\n");
w_request_shutdown();
set_prop(resp, "shutdown-server", json_true());
send_and_dispose_response(client, resp);
}
开发者ID:iamchenxin,项目名称:watchman,代码行数:10,代码来源:listener-user.c
示例18: gmx_atomprop_query
gmx_bool gmx_atomprop_query(gmx_atomprop_t aps,
int eprop, const char *resnm, const char *atomnm,
real *value)
{
gmx_atomprop *ap = (gmx_atomprop*) aps;
int j;
#define MAXQ 32
char atomname[MAXQ], resname[MAXQ];
gmx_bool bExact;
set_prop(aps, eprop);
if ((strlen(atomnm) > MAXQ-1) || (strlen(resnm) > MAXQ-1))
{
if (debug)
{
fprintf(debug, "WARNING: will only compare first %d characters\n",
MAXQ-1);
}
}
if (isdigit(atomnm[0]))
{
int i;
/* put digit after atomname */
for (i = 1; i < MAXQ-1 && atomnm[i] != '\0'; i++)
{
atomname[i-1] = atomnm[i];
}
atomname[i-1] = atomnm[0];
atomname[i] = '\0';
}
else
{
strncpy(atomname, atomnm, MAXQ-1);
}
strncpy(resname, resnm, MAXQ-1);
j = get_prop_index(&(ap->prop[eprop]), ap->restype, resname,
atomname, &bExact);
if (eprop == epropVDW && !ap->bWarnVDW)
{
vdw_warning(stdout);
ap->bWarnVDW = TRUE;
}
if (j >= 0)
{
*value = ap->prop[eprop].value[j];
return TRUE;
}
else
{
*value = ap->prop[eprop].def;
return FALSE;
}
}
开发者ID:MelroLeandro,项目名称:gromacs,代码行数:55,代码来源:atomprop.cpp
示例19: cmd_trigger
/* trigger /root triggername [watch patterns] -- cmd to run
* Sets up a trigger so that we can execute a command when a change
* is detected */
void cmd_trigger(struct watchman_client *client, json_t *args)
{
w_root_t *root;
struct watchman_trigger_command *cmd;
json_t *resp;
json_t *trig;
char *errmsg = NULL;
root = resolve_root_or_err(client, args, 1, true);
if (!root) {
return;
}
if (json_array_size(args) < 3) {
send_error_response(client, "not enough arguments");
goto done;
}
trig = json_array_get(args, 2);
if (json_is_string(trig)) {
trig = build_legacy_trigger(client, args);
if (!trig) {
goto done;
}
} else {
// Add a ref so that we don't need to conditionally decref later
// for the legacy case later
json_incref(trig);
}
cmd = w_build_trigger_from_def(root, trig, &errmsg);
json_decref(trig);
if (!cmd) {
send_error_response(client, "%s", errmsg);
goto done;
}
w_root_lock(root);
w_ht_replace(root->commands, w_ht_ptr_val(cmd->triggername),
w_ht_ptr_val(cmd));
w_root_unlock(root);
w_state_save();
resp = make_response();
set_prop(resp, "triggerid", json_string_nocheck(cmd->triggername->buf));
send_and_dispose_response(client, resp);
done:
if (errmsg) {
free(errmsg);
}
w_root_delref(root);
}
开发者ID:jadedgnome,项目名称:watchman,代码行数:58,代码来源:trigger.c
示例20: add_prop
JSBool
add_prop(JSContext* jscx, JSObject* jsobj, jsval key, jsval* rval)
{
JSObject* obj = NULL;
if(JSVAL_IS_NULL(*rval) || !JSVAL_IS_OBJECT(*rval)) return JS_TRUE;
obj = JSVAL_TO_OBJECT(*rval);
if(JS_ObjectIsFunction(jscx, obj)) return set_prop(jscx, jsobj, key, rval);
return JS_TRUE;
}
开发者ID:Jonnyliu,项目名称:phoneyc,代码行数:11,代码来源:context.c
注:本文中的set_prop函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论