当前位置: 首页>>代码示例>>C++>>正文


C++ prepare_data函数代码示例

本文整理汇总了C++中prepare_data函数的典型用法代码示例。如果您正苦于以下问题:C++ prepare_data函数的具体用法?C++ prepare_data怎么用?C++ prepare_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了prepare_data函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: test_select

void
test_select(void)
{
  grn_obj *v;

  prepare_data();

  cut_assert_not_null((cond = grn_expr_create(&context, NULL, 0)));
  v = grn_expr_add_var(&context, cond, NULL, 0);
  GRN_RECORD_INIT(v, 0, grn_obj_id(&context, docs));
  grn_expr_append_obj(&context, cond, v, GRN_OP_PUSH, 1);
  GRN_TEXT_SETS(&context, &textbuf, "size");
  grn_expr_append_const(&context, cond, &textbuf, GRN_OP_PUSH, 1);
  grn_expr_append_op(&context, cond, GRN_OP_GET_VALUE, 2);
  GRN_UINT32_SET(&context, &intbuf, 14);
  grn_expr_append_const(&context, cond, &intbuf, GRN_OP_PUSH, 1);
  grn_expr_append_op(&context, cond, GRN_OP_EQUAL, 2);
  grn_expr_compile(&context, cond);

  res = grn_table_create(&context, NULL, 0, NULL,
                         GRN_TABLE_HASH_KEY|GRN_OBJ_WITH_SUBREC, docs, NULL);
  cut_assert_not_null(res);

  cut_assert_not_null((expr = grn_expr_create(&context, NULL, 0)));
  grn_expr_append_obj(&context, expr, docs, GRN_OP_PUSH, 1);
  grn_expr_append_obj(&context, expr, cond, GRN_OP_PUSH, 1);
  grn_expr_append_obj(&context, expr, res, GRN_OP_PUSH, 1);
  GRN_UINT32_SET(&context, &intbuf, GRN_OP_OR);
  grn_expr_append_const(&context, expr, &intbuf, GRN_OP_PUSH, 1);
  grn_expr_append_op(&context, expr, GRN_OP_TABLE_SELECT, 4);

  grn_expr_exec(&context, expr, 0);

  grn_test_assert_select(&context,
                         gcut_take_new_list_string("moge moge moge",
                                                   "hoge fuga fuga",
                                                   "moge hoge hoge",
                                                   NULL),
                         res,
                         "body");
}
开发者ID:ryoqun,项目名称:groonga,代码行数:41,代码来源:test-table-select.c

示例2: __near_agent_handover_push_data

int __near_agent_handover_push_data(enum ho_agent_carrier carrier,
					struct carrier_data *data)
{
	DBusMessage *message;
	DBusMessage *reply;
	DBusError error;
	struct near_handover_agent *agent = NULL;

	agent = g_hash_table_lookup(ho_agent_hash, GINT_TO_POINTER(carrier));
	if (!agent)
		return -ESRCH;

	message = dbus_message_new_method_call(agent->sender,
			agent->path, NFC_HANDOVER_AGENT_INTERFACE,
			"PushOOB");
	if (!message)
		return -ENOMEM;

	prepare_data(message, data);

	dbus_error_init(&error);

	reply = dbus_connection_send_with_reply_and_block(connection, message,
					DBUS_TIMEOUT_USE_DEFAULT, &error);

	dbus_message_unref(message);

	if (reply) {
		dbus_message_unref(reply);
		return 0;
	}

	if (dbus_error_is_set(&error)) {
			near_error("PushOOB failed: %s", error.message);
			dbus_error_free(&error);
	} else {
		near_error("PushOOB failed");
	}

	return -EIO;
}
开发者ID:justinc1985,项目名称:IntelRangeley,代码行数:41,代码来源:agent.c

示例3: main

void main() {
	char c = ' ';

	while (c != 'q') {
		clear_screen();
		cout << "Press:" << endl;
		cout << "'d' to prepare computation Data" << endl;
		cout << "'m' to prepare Model" << endl;
		cout << "'s' to prepare Sources" << endl;
		cout << "'r' to prepare Receivers" << endl;
		
		cout << "'q' to Quit" << endl;

		cin >> c;

		if (c == 'd') prepare_data();
		if (c == 'm') prepare_model();
		if (c == 's') prepare_source();
		if (c == 'r') prepare_receivers();
	}
}
开发者ID:SeizmoFMFI,项目名称:2DFD,代码行数:21,代码来源:main.cpp

示例4: test_allow_update

void
test_allow_update(gconstpointer data)
{
  grn_obj *v;

  prepare_data();

  expr = grn_expr_create(&context, NULL, 0);
  cut_assert_not_null(expr);
  v = grn_expr_add_var(&context, expr, NULL, 0);
  cut_assert_not_null(v);
  GRN_RECORD_INIT(v, 0, grn_obj_id(&context, docs));
  PARSE(expr,
        gcut_data_get_string(data, "query"),
        GRN_EXPR_SYNTAX_QUERY | GRN_EXPR_ALLOW_COLUMN | GRN_EXPR_ALLOW_UPDATE);

  res = grn_table_select(&context, docs, expr, NULL, GRN_OP_OR);
  cut_assert_not_null(res);
  grn_test_assert_select(&context,
                         gcut_data_get_pointer(data, "expected_keys"),
                         res,
                         "body");
}
开发者ID:darashi,项目名称:groonga,代码行数:23,代码来源:test-expr-query.c

示例5: test_equal_by_existent_reference_key

void
test_equal_by_existent_reference_key(void)
{
  grn_obj *v;

  prepare_data();

  GRN_EXPR_CREATE_FOR_QUERY(&context, docs, cond, v);
  cut_assert_not_null(cond);
  cut_assert_not_null(v);
  PARSE(cond, "author == \"morita\"", GRN_EXPR_SYNTAX_SCRIPT);
  res = grn_table_select(&context, docs, cond, NULL, GRN_OP_OR);
  cut_assert_not_null(res);

  grn_test_assert_select(&context,
                         gcut_take_new_list_string(
                           "fuga fuga",
                           "hoge",
                           "poyo moge hoge moge moge moge",
                           NULL),
                         res,
                         "body");
}
开发者ID:WEIC-DEV,项目名称:groonga,代码行数:23,代码来源:test-table-select.c

示例6: test_match

void
test_match(void)
{
  grn_obj *v;

  prepare_data();

  cut_assert_not_null((cond = grn_expr_create(&context, NULL, 0)));
  v = grn_expr_add_var(&context, cond, NULL, 0);
  GRN_RECORD_INIT(v, 0, grn_obj_id(&context, docs));
  grn_expr_append_obj(&context, cond, v, GRN_OP_PUSH, 1);
  GRN_TEXT_SETS(&context, &text_buf, "body");
  grn_expr_append_const(&context, cond, &text_buf, GRN_OP_PUSH, 1);
  grn_expr_append_op(&context, cond, GRN_OP_GET_VALUE, 2);
  GRN_TEXT_SETS(&context, &text_buf, "moge");
  grn_expr_append_const(&context, cond, &text_buf, GRN_OP_PUSH, 1);
  grn_expr_append_op(&context, cond, GRN_OP_MATCH, 2);
  grn_expr_compile(&context, cond);

  res = grn_table_create(&context, NULL, 0, NULL,
                         GRN_TABLE_HASH_KEY|GRN_OBJ_WITH_SUBREC, docs, NULL);
  cut_assert_not_null(res);

  cut_assert_not_null(grn_table_select(&context, docs, cond, res, GRN_OP_OR));

  grn_test_assert_select(&context,
                         gcut_take_new_list_string("moge moge moge",
                                                   "hoge moge moge moge",
                                                   "moge hoge hoge",
                                                   "moge hoge fuga fuga",
                                                   "moge hoge moge moge moge",
                                                   "poyo moge hoge "
                                                     "moge moge moge",
                                                   NULL),
                         res,
                         "body");
}
开发者ID:WEIC-DEV,项目名称:groonga,代码行数:37,代码来源:test-table-select.c

示例7: dlm_timeout_warn

void dlm_timeout_warn(struct dlm_lkb *lkb)
{
	struct sk_buff *uninitialized_var(send_skb);
	struct dlm_lock_data *data;
	size_t size;
	int rv;

	size = nla_total_size(sizeof(struct dlm_lock_data)) +
	       nla_total_size(0); /* why this? */

	rv = prepare_data(DLM_CMD_TIMEOUT, &send_skb, size);
	if (rv < 0)
		return;

	data = mk_data(send_skb);
	if (!data) {
		nlmsg_free(send_skb);
		return;
	}

	fill_data(data, lkb);

	send_data(send_skb);
}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:24,代码来源:netlink.c

示例8: not_transient

static PyObject *Revision_set_object_data(
	Revision *self, PyObject *args, PyObject *kwds)
{
	PyObject *ob_arg = NULL, *data_arg = NULL;
	static char *kwlist[] = { "ob", "data", NULL };

	if (!PyArg_ParseTupleAndKeywords(
		    args, kwds, "O!O:Revision.set_object_data", kwlist,
		    &ObjectType, &ob_arg, &data_arg))
		return NULL;

	if (!xorn_revision_is_transient(self->rev))
		return not_transient();

	xorn_obtype_t type = xorn_obtype_none;
	const void *data = NULL;

	if (prepare_data(data_arg, &type, &data) == -1) {
		char buf[BUFSIZ];
		snprintf(buf, BUFSIZ,
			 "Revision.set_object_data() argument 'data' (pos 2) "
			 "must be of xorn.storage object type, not %.50s",
			 data_arg->ob_type->tp_name);
		PyErr_SetString(PyExc_TypeError, buf);
		return NULL;
	}

	if (type != xornsch_obtype_text) {
		xorn_object_t attached_to;

		if (xorn_get_object_location(self->rev, ((Object *)ob_arg)->ob,
					     &attached_to, NULL) != -1 &&
		    attached_to != NULL) {
			PyErr_SetString(PyExc_ValueError,
					"Cannot set attached object to "
					"something other than text");
			return NULL;
		}
	}

	if (type != xornsch_obtype_net && type != xornsch_obtype_component) {
		size_t count;

		if (xorn_get_objects_attached_to(
			    self->rev, ((Object *)ob_arg)->ob,
			    NULL, &count) != -1 && count != 0) {
			PyErr_SetString(
				PyExc_ValueError,
				"Cannot set object with attached objects to "
				"something other than net or component");
			return NULL;
		}
	}

	if (xorn_set_object_data(self->rev, ((Object *)ob_arg)->ob,
				 type, data) == -1)
		return PyErr_NoMemory();

	Py_INCREF(Py_None);
	return Py_None;
}
开发者ID:SayCV,项目名称:geda-gaf,代码行数:61,代码来源:revision.c

示例9: test_scan_search

void
test_scan_search(void)
{
  grn_obj *cond, *expr, *v, textbuf, intbuf;
  GRN_TEXT_INIT(&textbuf, 0);
  GRN_UINT32_INIT(&intbuf, 0);

  prepare_data(&textbuf, &intbuf);

  cut_assert_not_null((cond = grn_expr_create(&context, NULL, 0)));
  v = grn_expr_add_var(&context, cond, NULL, 0);
  GRN_RECORD_INIT(v, 0, grn_obj_id(&context, docs));
  grn_expr_append_obj(&context, cond, v);
  GRN_TEXT_SETS(&context, &textbuf, "size");
  grn_expr_append_const(&context, cond, &textbuf);
  grn_expr_append_op(&context, cond, GRN_OP_OBJ_GET_VALUE, 2);
  GRN_UINT32_SET(&context, &intbuf, 14);
  grn_expr_append_const(&context, cond, &intbuf);
  grn_expr_append_op(&context, cond, GRN_OP_EQUAL, 2);
  grn_expr_compile(&context, cond);

  cut_assert_not_null((expr = grn_expr_create(&context, NULL, 0)));

  v = grn_expr_add_var(&context, expr, NULL, 0);

  GRN_BULK_REWIND(&textbuf);
  grn_expr_append_const(&context, expr, &textbuf);
  GRN_UINT32_SET(&context, &intbuf, GRN_TABLE_HASH_KEY|GRN_OBJ_WITH_SUBREC);
  grn_expr_append_const(&context, expr, &intbuf);
  grn_expr_append_obj(&context, expr, docs);
  GRN_UINT32_SET(&context, &intbuf, 0);
  grn_expr_append_const(&context, expr, &intbuf);
  grn_expr_append_op(&context, expr, GRN_OP_TABLE_CREATE, 4);

  grn_expr_append_obj(&context, expr, v);
  grn_expr_append_op(&context, expr, GRN_OP_VAR_SET_VALUE, 2);

  grn_expr_append_obj(&context, expr, docs);
  grn_expr_append_obj(&context, expr, cond);
  grn_expr_append_obj(&context, expr, v);
  GRN_UINT32_SET(&context, &intbuf, GRN_SEL_OR);
  grn_expr_append_const(&context, expr, &intbuf);
  grn_expr_append_op(&context, expr, GRN_OP_TABLE_SCAN, 4);

  grn_expr_append_obj(&context, expr, index_body);
  GRN_TEXT_SETS(&context, &textbuf, "moge");
  grn_expr_append_const(&context, expr, &textbuf);
  grn_expr_append_obj(&context, expr, v);
  GRN_UINT32_SET(&context, &intbuf, GRN_SEL_AND);
  grn_expr_append_const(&context, expr, &intbuf);
  grn_expr_append_op(&context, expr, GRN_OP_OBJ_SEARCH, 4);

  grn_expr_append_obj(&context, expr, v);
  GRN_TEXT_SETS(&context, &textbuf, ".size .:score .body");
  grn_expr_append_const(&context, expr, &textbuf);
  GRN_BULK_REWIND(&textbuf);
  grn_expr_append_obj(&context, expr, &textbuf);
  grn_expr_append_op(&context, expr, GRN_OP_JSON_PUT, 3);

  grn_expr_exec(&context, expr);

  cut_assert_equal_substring("[[14, 4, \"moge moge moge\"], [14, 2, \"moge hoge hoge\"]]",
                             GRN_TEXT_VALUE(&textbuf), GRN_TEXT_LEN(&textbuf));

  grn_test_assert(grn_obj_close(&context, expr));
  grn_test_assert(grn_obj_close(&context, cond));
  grn_test_assert(grn_obj_close(&context, &textbuf));
  grn_test_assert(grn_obj_close(&context, &intbuf));
}
开发者ID:ikdttr,项目名称:groonga,代码行数:69,代码来源:test-expr.c

示例10:

		SerializerBase& BinarySerializer::operator%(SerializationData<BinarySerializer>&& var)
		{
			sprawl::String str = var.val.Str();
			*this % prepare_data(str, var.name, var.PersistToDB);
			return *this;
		}
开发者ID:ShadauxCat,项目名称:Sprawl,代码行数:6,代码来源:BinarySerializer.cpp

示例11: osalDbgCheck


//.........这里部分代码省略.........
  nav_sins.calib_params.sw[0][0] = *gyr_scale_x;
  nav_sins.calib_params.sw[1][0] = *gyr_scale_y;
  nav_sins.calib_params.sw[2][0] = *gyr_scale_z;

  nav_sins.ref_params.mag_dec = deg2rad(*mag_declinate);
  nav_sins.calib_params.bm_marg[0][0] = *mag_bias_x;
  nav_sins.calib_params.bm_marg[1][0] = *mag_bias_y;
  nav_sins.calib_params.bm_marg[2][0] = *mag_bias_z;

  nav_sins.calib_params.sm_marg[0][0] = *mag_scale_x;
  nav_sins.calib_params.sm_marg[1][0] = *mag_scale_y;
  nav_sins.calib_params.sm_marg[2][0] = *mag_scale_z;

  nav_sins.calib_params.no_m_marg[0][0] = *mag_nort_x;
  nav_sins.calib_params.no_m_marg[1][0] = *mag_nort_y;
  nav_sins.calib_params.no_m_marg[2][0] = *mag_nort_z;

  /*
  nav_sins.calib_params.no_a[0][0] = *acc_nort_0;
  nav_sins.calib_params.no_a[1][0] = *acc_nort_1;
  nav_sins.calib_params.no_a[2][0] = *acc_nort_2;
  nav_sins.calib_params.no_a[3][0] = *acc_nort_3;
  nav_sins.calib_params.no_a[4][0] = *acc_nort_4;
  nav_sins.calib_params.no_a[5][0] = *acc_nort_5;

  nav_sins.calib_params.no_w[0][0] = *gyr_nort_0;
  nav_sins.calib_params.no_w[1][0] = *gyr_nort_1;
  nav_sins.calib_params.no_w[2][0] = *gyr_nort_2;
  nav_sins.calib_params.no_w[3][0] = *gyr_nort_3;
  nav_sins.calib_params.no_w[4][0] = *gyr_nort_4;
  nav_sins.calib_params.no_w[5][0] = *gyr_nort_5;
  */


  nav_sins.calib_params.ba[0][0] = *acc_bias_x;
  nav_sins.calib_params.ba[1][0] = *acc_bias_y;
  nav_sins.calib_params.ba[2][0] = *acc_bias_z;

  nav_sins.calib_params.bw[0][0] = *gyr_bias_x;
  nav_sins.calib_params.bw[1][0] = *gyr_bias_y;
  nav_sins.calib_params.bw[2][0] = *gyr_bias_z;

  nav_sins.calib_params.sa[0][0] = *acc_scale_x;
  nav_sins.calib_params.sa[1][0] = *acc_scale_y;
  nav_sins.calib_params.sa[2][0] = *acc_scale_z;

  nav_sins.calib_params.sw[0][0] = *gyr_scale_x;
  nav_sins.calib_params.sw[1][0] = *gyr_scale_y;
  nav_sins.calib_params.sw[2][0] = *gyr_scale_z;

  nav_sins.marg_b.eu_bs_mag[0][0] = M_PI;
  nav_sins.marg_b.eu_bs_mag[1][0] = 0.0;
  nav_sins.marg_b.eu_bs_mag[2][0] = -M_PI;

  nav_sins.ref_params.eu_vh_base[0][0] = *eu_vh_roll;
  nav_sins.ref_params.eu_vh_base[1][0] = *eu_vh_pitch;
  nav_sins.ref_params.eu_vh_base[2][0] = *eu_vh_yaw;

  nav_sins.ref_params.eu_vh_base[0][0] = *eu_vh_roll;
  nav_sins.ref_params.eu_vh_base[1][0] = *eu_vh_pitch;
  nav_sins.ref_params.eu_vh_base[2][0] = *eu_vh_yaw;

  nav_sins.ref_params.zupt_source     = *zupt_src;
  nav_sins.ref_params.glrt_gamma      = *gamma;
  nav_sins.ref_params.glrt_acc_sigma  = *acc_sigma;
  nav_sins.ref_params.glrt_gyr_sigma  = *gyr_sigma;
  nav_sins.ref_params.glrt_n          = *samples;
  nav_sins.ref_params.sns_extr_en     = *en_extr;
  nav_sins.ref_params.sns_vel_th      = *sns_v_th;

  dbg_in_fill_gnss(this->gps);
  prepare_data_gnss(this->gps);
  dbg_in_fill_other(baro, odo, marg);
  dbg_in_append_log();
  prepare_data(baro, odo, marg);

  nav_sins.run();

#if defined(BOARD_BEZVODIATEL)

  if (NAV_RUN_STATIONARY_AUTONOMOUS == nav_sins.run_mode ||
      NAV_RUN_STATIONARY_PRIMARY    == nav_sins.run_mode) {
    blue_led_on();
    red_led_on();
  } else {
    blue_led_off();
    red_led_off();
  }

#endif

  navi2acs();
  navi2mavlink();
  debug2mavlink();

  dbg_out_fill(nav_sins.navi_data);
  dbg_out_append_log();

  stop_time_measurement(marg.dT);
}
开发者ID:barthess,项目名称:u2,代码行数:101,代码来源:navi6d_wrapper.cpp

示例12: while

static void *read_data(void *privdata)
{
	struct dvb_open_descriptor *open_dev;
	int timeout;
	int ret, read_ret = -1, fd, i;
	char databuf[REMOTE_BUF_SIZE];
	char buf[REMOTE_BUF_SIZE + 32], *p;
	size_t size;
	size_t count;
	struct pollfd __fds[NUM_FOPEN];
	nfds_t __numfds;

	timeout = 10; /* ms */
	while (1) {
		pthread_mutex_lock(&dvb_read_mutex);
		if (!numfds) {
			pthread_mutex_unlock(&dvb_read_mutex);
			break;
		}
		__numfds = numfds;
		memcpy(__fds, fds, sizeof(fds));
		pthread_mutex_unlock(&dvb_read_mutex);

		ret = poll(__fds, __numfds, timeout);
		if (!ret)
			continue;
		if (ret < 0) {
			err("poll");
			continue;
		}

		for (i = 0; i < __numfds; i++) {
			if (__fds[i].revents & (POLLERR | POLLHUP | POLLNVAL))
				continue;
			if (__fds[i].revents)
				break;
		}

		/*
		 * it means that one error condition happened.
		 * Likely the file was closed.
		 */
		if (i == __numfds)
			continue;

		fd = __fds[i].fd;

		if (!desc_root)
			break;

		open_dev = get_open_dev(fd);
		if (!open_dev) {
			err("Couldn't find opened file %d", fd);
			continue;
		}

		count = REMOTE_BUF_SIZE;
		read_ret = dvb_dev_read(open_dev, databuf, count);
		if (verbose) {
			if (read_ret < 0)
				dbg("#%d: read error: %d on %p", fd, read_ret, open_dev);
			else
				dbg("#%d: read %d bytes (count %d)", fd, read_ret, count);
		}

		/* Initialize to the start of the buffer */
		p = buf;
		size = sizeof(buf);

		ret = prepare_data(p, size, "%i%s%i%i", 0, "data_read",
				   read_ret, fd);
		if (ret < 0) {
			err("Failed to prepare answer to dvb_read()");
			break;
		}

		p += ret;
		size -= ret;

		if (read_ret > 0) {
			if (read_ret > size) {
				dbg("buffer to short to store read data!");
				read_ret = -EOVERFLOW;
			} else {
				memcpy(p, databuf, read_ret);
				p += read_ret;
			}
		}

		ret = send_buf(dvb_fd, buf, p - buf);
		if (ret < 0) {
			err("Error %d sending buffer\n", ret);
			if (ret == ECONNRESET) {
				close_all_devs();
				break;
			}
			continue;
		}
	}

//.........这里部分代码省略.........
开发者ID:cz172638,项目名称:v4l-utils,代码行数:101,代码来源:dvbv5-daemon.c

示例13: dev_get_stats

static int dev_get_stats(uint32_t seq, char *cmd, int fd,
			 char *inbuf, ssize_t insize)
{
	struct dvb_v5_fe_parms_priv *parms = (void *)dvb->fe_parms;
	struct dvb_v5_stats *st = &parms->stats;
	struct dvb_v5_fe_parms *par = (void *)parms;
	int ret, i;
	char buf[REMOTE_BUF_SIZE], *p = buf;
	size_t size = sizeof(buf);

	if (verbose)
		dbg("dev_get_stats called");

	ret = __dvb_fe_get_stats(par);
	if (ret < 0)
		goto error;

	ret = prepare_data(p, size, "%i%s%i%i", seq, cmd, ret, st->prev_status);
	if (ret < 0)
		goto error;

	p += ret;
	size -= ret;

	for (i = 0; i < DTV_NUM_STATS_PROPS; i++) {
		ret = prepare_data(p, size, "%i%i",
				   st->prop[i].cmd,
				   st->prop[i].u.data);
		if (ret < 0)
			goto error;

		p += ret;
		size -= ret;
	}
	for (i = 0; i < MAX_DTV_STATS; i++) {
		struct dvb_v5_counters *prev = st->prev;
		struct dvb_v5_counters *cur = st->cur;

		ret = prepare_data(p, size, "%i%i%i",
				   st->has_post_ber[i],
				   st->has_pre_ber[i],
				   st->has_per[i]);
		if (ret < 0)
			goto error;

		p += ret;
		size -= ret;

		ret = prepare_data(p, size,
				   "%lu%lu%lu%lu%lu%lu%lu%lu%lu%lu%lu%lu",
				   prev->pre_bit_count,
				   prev->pre_bit_error,
				   prev->post_bit_count,
				   prev->post_bit_error,
				   prev->block_count,
				   prev->block_error,
				   cur->pre_bit_count,
				   cur->pre_bit_error,
				   cur->post_bit_count,
				   cur->post_bit_error,
				   cur->block_count,
				   cur->block_error);

		if (ret < 0)
			goto error;

		p += ret;
		size -= ret;
	}

	return send_buf(fd, buf, p - buf);
error:
	return send_data(fd, "%i%s%i", seq, cmd, ret);
}
开发者ID:cz172638,项目名称:v4l-utils,代码行数:74,代码来源:dvbv5-daemon.c

示例14: dev_get_parms

static int dev_get_parms(uint32_t seq, char *cmd, int fd,
			 char *inbuf, ssize_t insize)
{
	struct dvb_v5_fe_parms_priv *parms = (void *)dvb->fe_parms;
	struct dvb_v5_fe_parms *par = (void *)parms;
	struct dvb_frontend_info *info = &par->info;
	int ret, i;
	char buf[REMOTE_BUF_SIZE], lnb_name[80] = "", *p = buf;
	size_t size = sizeof(buf);

	if (verbose)
		dbg("dev_get_parms called");

	ret = __dvb_fe_get_parms(par);
	if (ret < 0)
		goto error;

	/* Send first the public params */

	ret = prepare_data(p, size, "%i%s%i%s%i%i%i%i%i%i%i", seq, cmd, ret,
			   info->name, info->frequency_min,
			   info->frequency_max, info->frequency_stepsize,
			   info->frequency_tolerance, info->symbol_rate_min,
			   info->symbol_rate_max, info->symbol_rate_tolerance);
	if (ret < 0)
		goto error;

	p += ret;
	size -= ret;

	if (par->lnb)
		strcpy(lnb_name, par->lnb->name);

	ret = prepare_data(p, size, "%i%i%i%i%i%i%i%s%i%i%i%i%s%s",
			   par->version, par->has_v5_stats, par->current_sys,
			   par->num_systems, par->legacy_fe, par->abort,
		           par->lna, lnb_name,
			   par->sat_number, par->freq_bpf, par->diseqc_wait,
			   par->verbose, par->default_charset,
			   par->output_charset);
	if (ret < 0)
		goto error;

	p += ret;
	size -= ret;

	for (i = 0; i < MAX_DELIVERY_SYSTEMS; i++) {
		ret = prepare_data(p, size, "%i", par->systems[i]);
		if (ret < 0)
			goto error;

		p += ret;
		size -= ret;
	}

	/* Now, send the private ones - except for stats */

	ret = prepare_data(p, size, "%i%i%i%i",
			   parms->n_props,
			   parms->country,
			   parms->high_band,
			   parms->freq_offset);
	if (ret < 0)
		goto error;

	p += ret;
	size -= ret;

	for (i = 0; i < parms->n_props; i++) {
		ret = prepare_data(p, size, "%i%i",
				   parms->dvb_prop[i].cmd,
				   parms->dvb_prop[i].u.data);
		if (ret < 0)
			goto error;

		p += ret;
		size -= ret;
	}

	strcpy(output_charset, par->output_charset);
	strcpy(default_charset, par->default_charset);

	return send_buf(fd, buf, p - buf);
error:
	return send_data(fd, "%i%s%i", seq, cmd, ret);
}
开发者ID:cz172638,项目名称:v4l-utils,代码行数:86,代码来源:dvbv5-daemon.c

示例15: test_parse

void
test_parse(gconstpointer data)
{
  grn_obj *v;

  prepare_data();

  cond = grn_expr_create(&context, NULL, 0);
  cut_assert_not_null(cond);
  v = grn_expr_add_var(&context, cond, NULL, 0);
  cut_assert_not_null(v);
  GRN_RECORD_INIT(v, 0, grn_obj_id(&context, docs));
  PARSE(cond, gcut_data_get_string(data, "query_hoge_moge"),
              gcut_data_get_int(data, "query_hoge_moge_parse_level"));
  PARSE(cond, gcut_data_get_string(data, "query_poyo"),
              gcut_data_get_int(data, "query_poyo_parse_level"));
  grn_expr_append_op(&context, cond, GRN_OP_AND, 2);
  grn_test_assert_expr(
    &context,
    "#<expr\n"
    "  vars:{\n"
    "    $1:#<record:no_key:docs id:0(nonexistent)>\n"
    "  },\n"
    "  codes:{\n"
    "    0:<get_value(), modify:2, "
    "value:#<column:var_size docs.body range:Text type:scalar compress:none>>,\n"
    "    1:<push(), modify:0, value:\"hoge\">,\n"
    "    2:<match(), modify:4, value:(NULL)>,\n"
    "    3:<get_value(), modify:2, "
    "value:#<column:var_size docs.body range:Text type:scalar compress:none>>,\n"
    "    4:<push(), modify:0, value:\"moge\">,\n"
    "    5:<match(), modify:0, value:(NULL)>,\n"
    "    6:<and(), modify:4, value:(NULL)>,\n"
    "    7:<get_value(), modify:2, "
    "value:#<column:var_size docs.body range:Text type:scalar compress:none>>,\n"
    "    8:<push(), modify:0, value:\"poyo\">,\n"
    "    9:<match(), modify:0, value:(NULL)>,\n"
    "    10:<and(), modify:0, value:(NULL)>\n"
    "  }\n"
    ">",
    cond);
  res = grn_table_create(&context, NULL, 0, NULL,
                         GRN_TABLE_HASH_KEY|GRN_OBJ_WITH_SUBREC, docs, NULL);
  cut_assert_not_null(res);
  cut_assert_not_null(grn_table_select(&context, docs, cond, res, GRN_OP_OR));

  grn_test_assert_select(&context,
                         gcut_take_new_list_string("poyo moge hoge "
                                                   "moge moge moge",
                                                   NULL),
                         res,
                         "body");
  grn_test_assert(grn_obj_close(&context, res));
  res = NULL;
  grn_test_assert(grn_obj_close(&context, cond));
  cond = NULL;

  cond = grn_expr_create(&context, NULL, 0);
  cut_assert_not_null(cond);
  v = grn_expr_add_var(&context, cond, NULL, 0);
  cut_assert_not_null(v);
  GRN_RECORD_INIT(v, 0, grn_obj_id(&context, docs));
  PARSE(cond, gcut_data_get_string(data, "query_size"),
              gcut_data_get_int(data, "query_size_parse_level"));
  grn_test_assert_expr(
    &context,
    "#<expr\n"
    "  vars:{\n"
    "    $1:#<record:no_key:docs id:0(nonexistent)>\n"
    "  },\n"
    "  codes:{\n"
    "    0:<get_value(), modify:2, "
    "value:#<column:fix_size docs.size range:UInt32 type:scalar compress:none>>,\n"
    "    1:<push(), modify:0, value:14>,\n"
    "    2:<equal(), modify:0, value:(NULL)>\n"
    "  }\n"
    ">",
    cond);
  res = grn_table_create(&context, NULL, 0, NULL,
                         GRN_TABLE_HASH_KEY|GRN_OBJ_WITH_SUBREC, docs, NULL);
  cut_assert_not_null(res);
  cut_assert_not_null(grn_table_select(&context, docs, cond, res, GRN_OP_OR));

  grn_test_assert_select(&context,
                         gcut_take_new_list_string("moge moge moge",
                                                   "hoge fuga fuga",
                                                   "moge hoge hoge",
                                                   NULL),
                         res,
                         "body");
}
开发者ID:tamano,项目名称:groonga,代码行数:91,代码来源:test-expr-parse.c


注:本文中的prepare_data函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。