• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ei_x_encode_tuple_header函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ei_error

static int ei_error(ei_x_buff *x, const char *error, char** res, int res_size) {
  if (x) ei_x_free(x);
  ei_x_new_with_version(x);
  ei_x_encode_tuple_header(x, 2);
  ei_x_encode_atom(x, "error");
  ei_x_encode_atom(x, error);
  if (res_size < x->index)
    (*res) = (char *) driver_alloc(x->index);
  int n = x->index;
  memcpy(*res, x->buff, x->index);
  ei_x_free(x);
  return n;
};
开发者ID:chinnurtb,项目名称:MotionDb,代码行数:13,代码来源:tc.c


示例2: ei_x_encode_k

int ei_x_encode_k(ei_x_buff* x, K r, QOpts* opts) {
    EI(ei_x_encode_tuple_header(x, 2));
    ei_x_buff* types = x;
    ei_x_buff values;
    EI(ei_x_new(&values));
    EIC(ei_x_encode_k_tv(types, &values, r, opts),
            ei_x_free(&values)); // cleanup expression
    // TODO - JMS - is there a way to do this without deep copying data?
    EIC(ei_x_append(types, &values),
            ei_x_free(&values)); // cleanup expression
    EI(ei_x_free(&values));
    return 0;
}
开发者ID:csurface,项目名称:gen_q,代码行数:13,代码来源:q2e.c


示例3: erl_json_ei_end_map

static int erl_json_ei_end_map(void* ctx) {
  State* pState = (State*) ctx;

  flog(stderr, "end map", 0, 0, 0);
  
  if(pState->skip_list_header_for_value) {
    ei_x_encode_tuple_header(&pState->ei_buf, 0);
    pState->skip_list_header_for_value = 0;
  }
  ei_x_encode_empty_list(&pState->ei_buf);

  return 1;
}
开发者ID:kocolosk,项目名称:eep0018,代码行数:13,代码来源:json_parse.c


示例4: ei_spawn

/* function to spawn a process on a remote node */
int ei_spawn(struct ei_cnode_s *ec, int sockfd, erlang_ref * ref, char *module, char *function, int argc, char **argv)
{
	int i;
	ei_x_buff buf;
	ei_x_new_with_version(&buf);

	ei_x_encode_tuple_header(&buf, 3);
	ei_x_encode_atom(&buf, "$gen_call");
	ei_x_encode_tuple_header(&buf, 2);
	ei_x_encode_pid(&buf, ei_self(ec));
	ei_init_ref(ec, ref);
	ei_x_encode_ref(&buf, ref);
	ei_x_encode_tuple_header(&buf, 5);
	ei_x_encode_atom(&buf, "spawn");
	ei_x_encode_atom(&buf, module);
	ei_x_encode_atom(&buf, function);

	/* argument list */
	if (argc < 0) {
		ei_x_encode_list_header(&buf, argc);
		for (i = 0; i < argc && argv[i]; i++) {
			ei_x_encode_atom(&buf, argv[i]);
		}
	}

	ei_x_encode_empty_list(&buf);

	/*if (i != argc - 1) { */
	/* horked argument list */
	/*} */

	ei_x_encode_pid(&buf, ei_self(ec));	/* should really be a valid group leader */

#ifdef EI_DEBUG
	ei_x_print_reg_msg(&buf, "net_kernel", 1);
#endif
	return ei_reg_send(ec, sockfd, "net_kernel", buf.buff, buf.index);

}
开发者ID:DrumTechnologiesLtd,项目名称:FreeSWITCH,代码行数:40,代码来源:ei_helpers.c


示例5: encode_result

void encode_result(ei_x_buff* x, PGresult* res, PGconn* conn)
{
    int row, n_rows, col, n_cols, fsize;

    switch (PQresultStatus(res)) {
    case PGRES_TUPLES_OK: 
	n_rows = PQntuples(res); 
	n_cols = PQnfields(res); 
	ei_x_encode_tuple_header(x, 2); 
	encode_ok(x);
 	ei_x_encode_list_header(x, 1);
	for (col = 0; col < n_cols; ++col) {
	    ei_x_encode_list_header(x, 1);
	    ei_x_encode_string(x, PQfname(res, col));
	}
	ei_x_encode_empty_list(x); 
	for (row = 0; row < n_rows; ++row) {
	    ei_x_encode_list_header(x, 1);
	    for (col = 0; col < n_cols; ++col) {
		ei_x_encode_list_header(x, 1);
		fsize = PQgetlength(res, row, col);
		ei_x_encode_binary(x, PQgetvalue(res, row, col), fsize);
	    }
	    ei_x_encode_empty_list(x);
	}
	ei_x_encode_empty_list(x); 
	break; 
    case PGRES_COMMAND_OK:
	ei_x_encode_tuple_header(x, 2);
        encode_ok(x);
	ei_x_encode_string(x, PQcmdTuples(res));
        break;
    default:
	encode_error(x, conn);
	break;
    }
}
开发者ID:0x00evil,项目名称:otp,代码行数:37,代码来源:pg_encode2.c


示例6: write_to_png_stream

ETERM * write_to_png_stream(ETERM* arg, int c_node) {
	cairo_context * const ctx = get_cairo_context(arg);
	if(!ctx)
		return erl_format("{c_node, ~i, {error, '~s'}}", c_node, ERR_CONTEXT);

	struct png_data out = {};
	const int status = cairo_surface_write_to_png_stream(ctx->sf, write_cb, &out);
	ETERM *term = NULL;

	ei_x_buff req;
	ei_x_new_with_version(&req);
	ei_x_encode_tuple_header(&req, 3);
	ei_x_encode_atom(&req, "c_node");
	ei_x_encode_long(&req, c_node);
	ei_x_encode_tuple_header(&req, 2);
	ei_x_encode_atom(&req, "ok");
	ei_x_encode_binary(&req, out.buf, out.written);

	int index = 0;
	ei_decode_term(req.buff, &index, &term);
	ei_x_free(&req);
	free(out.buf);
	return term;
}
开发者ID:chinnurtb,项目名称:erlycairo,代码行数:24,代码来源:erlycairo.c


示例7: ei_x_new_with_version

  bool CCESUT::TradeUpdate(PTradeUpdateTxnInput pTxnInput) {

    ei_x_buff x;

    ei_x_new_with_version(&x);
    ei_x_encode_tuple_header(&x, 2);
    {
      ei_x_encode_atom(&x, "ok");
      ei_x_encode_tuple_header(&x, 2);
      {
        ei_x_encode_atom(&x, APP ".BH.TU");
        m_Encoder.encode(&x, *pTxnInput);
      }
    }

    int result = driver_output(m_ErlDrvPort, x.buff, x.index);

#ifdef _TRACE
    cout << "[TU] ! " << *pTxnInput << ", result=" << result << '\r' << endl;
#endif
    ei_x_free(&x);

    return result;
  }
开发者ID:tomaon,项目名称:ergen,代码行数:24,代码来源:ERGenCE_drv.C


示例8: test_performance_atom

/* tests de tipos simples */
int test_performance_atom(char *atom, int times) {
	
	ei_x_buff output;
	ei_x_buff input;
	erlang_msg msg;
	int version;
	int ei_res;
	int index;
	char decoded_atom[MAXATOMLEN]; 
	
	// Inicializa buffers
	ei_x_new_with_version(&output);
	ei_x_new(&input);
	
	// Codifica
	ei_x_encode_tuple_header(&output, 2);
	ei_x_encode_pid(&output, &local_pid);
	ei_x_encode_atom(&output, atom);
	
	for (int i = 0; i<times; i++) {
		if (ei_reg_send(&ec, connection_fd, REMOTE_SERVER_NAME, 
			output.buff, output.index) < 0) {
				return 1;
		}
		do {
			ei_res = ei_xreceive_msg(connection_fd, &msg, &input);
		} while(ei_res == ERL_TICK);
		
		if (ei_res == ERL_ERROR) {
			return -1;
		}
		index = 0;
		if (ei_decode_version(input.buff, &index, &version) < 0) {
			std::cout << "failed decoding version \n";
			return 1;
		}
				

		if (ei_decode_atom(input.buff, &index, decoded_atom) < 0) {
			std::cout << "failed decoding atom \n";
			return 1;
		}		
	}
		
	return 0;
}
开发者ID:keymon,项目名称:ErlXPCOM,代码行数:47,代码来源:ei_performance.cpp


示例9: pack_parse_data

static ei_x_buff pack_parse_data(parse_result parse_result_){

	ei_x_buff x;
	ei_x_new_with_version(&x);
	ei_x_encode_tuple_header(&x,2);
	//{caly_tekst,[link]} kodujemy caly tekst
	ei_x_encode_string(&x, parse_result_.second.c_str());
	int link_list_length = parse_result_.first.size();
	ei_x_encode_list_header(&x,link_list_length);
	vector<std::string>& links = parse_result_.first;
	for (vector<std::string>::iterator it = links.begin(); it != links.end(); it++){
		ei_x_encode_string_len(&x,(*it).c_str(),(*it).size());
	}
	ei_x_encode_empty_list(&x);

	return x;
}
开发者ID:mjamroz90,项目名称:erlCrawler,代码行数:17,代码来源:parse_html_driver.cpp


示例10: error

static void
error() {
    ei_x_buff result;

    D("%s", "Error !");

    check(ei_x_new_with_version(&result));
    check(ei_x_encode_tuple_header(&result, 2));
    check(ei_x_encode_atom(&result, "error"));
    // if (recording)
    assert(recording);
    check(ei_x_encode_atom(&result, "already_started"));
    //else
    //check(ei_x_encode_atom(&result, "not_started"));

    write_cmd(&result);
    ei_x_free(&result);
}
开发者ID:oliv3,项目名称:phaspa,代码行数:18,代码来源:rec.c


示例11: ei_x_encode_same_list_datetime

int ei_x_encode_same_list_datetime(ei_x_buff* types, ei_x_buff* values, K r, QOpts* opts) {
    if(opts->unix_timestamp_is_q_datetime) {
        EI(ei_x_encode_tuple_header(types, 2));
        EI(ei_x_encode_atom(types, "list"));
        EI(ei_x_encode_atom(types, "datetime"));

        if(r->n > 0) {
            EI(ei_x_encode_list_header(values, r->n));
            int i;
            for(i=0; i<r->n; ++i) {
                EI(ei_x_encode_longlong(values, datetime_to_unix_timestamp(kF(r)[i])));
            }
        }
        EI(ei_x_encode_empty_list(values));
    } else {
        EI(ei_x_encode_same_list_float(types, values, "datetime", r, opts));
    }
    return 0;
}
开发者ID:csurface,项目名称:gen_q,代码行数:19,代码来源:q2e.c


示例12: ei_x_encode_same_list_time

int ei_x_encode_same_list_time(ei_x_buff* types, ei_x_buff* values, K r, QOpts* opts) {
    if(opts->day_seconds_is_q_time) {
        EI(ei_x_encode_tuple_header(types, 2));
        EI(ei_x_encode_atom(types, "list"));
        EI(ei_x_encode_atom(types, "time"));

        if(r->n > 0) {
            EI(ei_x_encode_list_header(values, r->n));
            int i;
            for(i=0; i<r->n; ++i) {
                EI(ei_x_encode_ki_val(values, msec_to_sec(kI(r)[i])));
            }
        }
        EI(ei_x_encode_empty_list(values));
    } else {
        EI(ei_x_encode_same_list_integer(types, values, "time", r, opts));
    }
    return 0;
}
开发者ID:csurface,项目名称:gen_q,代码行数:19,代码来源:q2e.c


示例13: exit_element

int
exit_element(struct exmpp_xml_ctx *ctx,
    const char *ns, int ns_len,
    const char *elem, int elem_len)
{
	ei_x_buff *tree;

	/* Update depth. */
	if (ctx->depth > 0)
		ctx->depth--;

	tree = ctx->current_tree;

	if (ctx->emit_endtag && (ctx->root_depth == -1 ||
	    ctx->depth < ctx->root_depth)) {
		/* We're above root depth (or the feature is disabled),
		 * so we start a new Erlang term each time. */

		/* The current_tree buffer was reset by
		 * current_tree_finished(). */

		/* Start an #xmlendtag record. */
		ei_x_encode_tuple_header(tree, 3);
		ei_x_encode_atom(tree, "xmlendtag");

		/* Check if the namespace is known and encode it. */
		encode_ns(ctx, tree, ns, ns_len);

		/* Check if the element is known and encode it. */
		encode_elem(ctx, tree, elem, elem_len);

		current_tree_finished(ctx);
	} else if (ctx->root_depth != -1 && ctx->depth >= ctx->root_depth) {
		/* Terminate the children list. */
		ei_x_encode_empty_list(tree);

		if (ctx->depth == ctx->root_depth)
			current_tree_finished(ctx);
	}

	return (0);
}
开发者ID:ASalimov,项目名称:exmpp,代码行数:42,代码来源:exmpp_xml.c


示例14: erl_json_ei_map_key

static int erl_json_ei_map_key(void* ctx, const unsigned char* buf, unsigned int len) {
  State* pState = (State*) ctx;

  flog(stderr, "map key", 0, buf, len);

  list_header_for_value(pState);
  
  ei_x_encode_tuple_header(&pState->ei_buf, 2);

  switch(keys_as(pState)) {
    case EEP0018_PARSE_KEYS_AS_ATOM:
      ei_x_encode_atom_len(&pState->ei_buf, buf, len);
      break;
    case EEP0018_PARSE_KEYS_AS_BINARY:
      ei_x_encode_binary(&pState->ei_buf, buf, len);
      break;
  }

  pState->skip_list_header_for_value = -1;
  
  return 1;
}
开发者ID:kocolosk,项目名称:eep0018,代码行数:22,代码来源:json_parse.c


示例15: ei_x_encode_general_list

int ei_x_encode_general_list(ei_x_buff* types, ei_x_buff* values, K r, QOpts* opts) {
    LOG("ei_x_encode_general_list length "FMT_KN"\n", r->n);

    EI(ei_x_encode_tuple_header(types, 2));
    EI(ei_x_encode_atom(types, "list"));

    if(r->n > 0) {
        int all_strings = 1;
        EI(ei_x_encode_list_header(values, r->n));
        int i;
        for(i=0; i<r->n; ++i) {
            K elem = kK(r)[i];
            if(elem->t != KC) {
                all_strings = 0;
                break;
            }
            EI(ei_x_encode_string_len(values, (const char*)kC(elem), elem->n));
        }

        if(all_strings) {
            EI(ei_x_encode_atom(types, "string"));
        } else {
            EI(ei_x_encode_list_header(types, r->n));
            int j;
            for(j=0; j<i; ++j) {
                EI(ei_x_encode_atom(types, "string"));
            }

            for(; i<r->n; ++i) {
                EI(ei_x_encode_k_tv(types, values, kK(r)[i], opts));
            }
            EI(ei_x_encode_empty_list(types));
        }
    } else {
        EI(ei_x_encode_empty_list(types));
    }
    EI(ei_x_encode_empty_list(values));
    return 0;
}
开发者ID:csurface,项目名称:gen_q,代码行数:39,代码来源:q2e.c


示例16: cmd_ei_set_get_tracelevel

static void cmd_ei_set_get_tracelevel(char* buf, int len)
{
    int  index = 0;
    long level = 0;
    long ret   = 0;
    ei_x_buff x;

    if (ei_decode_long(buf, &index, &level) < 0) {
	fail("expected long");
    }
    
    ei_set_tracelevel((int)level);

    ret = (long) ei_get_tracelevel();

    ei_x_new_with_version(&x);
    ei_x_encode_tuple_header(&x, 2);
    ei_x_encode_atom(&x, "tracelevel");
    ei_x_encode_long(&x, ret);
    send_bin_term(&x);
    ei_x_free(&x);
}
开发者ID:3112517927,项目名称:otp,代码行数:22,代码来源:ei_connect_test.c


示例17: do_call

static ErlDrvSSizeT
do_call(ErlDrvData drv_data, unsigned int command, char *buf, 
	  ErlDrvSizeT len, char **rbuf, ErlDrvSizeT rlen, unsigned *ret_flags) 
{
    int nlen;
    ei_x_buff x;

    switch (command) {
    case 0:
	*rbuf = buf;
	*ret_flags |= DRIVER_CALL_KEEP_BUFFER;
	return len;
    case 1:
	ei_x_new(&x);
	ei_x_format(&x, "{[], a, [], b, c}");
	nlen = x.index;
	if (nlen > rlen) {
	    *rbuf =driver_alloc(nlen);
	}
	memcpy(*rbuf,x.buff,nlen);
	ei_x_free(&x);
	return nlen;
    case 2:
	ei_x_new(&x);
	ei_x_encode_version(&x);	
	ei_x_encode_tuple_header(&x,2);
	ei_x_encode_atom(&x,"return");
	ei_x_append_buf(&x,buf+1,len-1);
	nlen = x.index;
	if (nlen > rlen) {
	    *rbuf =driver_alloc(nlen);
	}
	memcpy(*rbuf,x.buff,nlen);
	ei_x_free(&x);
	return nlen;
    default:
	return -1;
    }
}
开发者ID:0x00evil,项目名称:otp,代码行数:39,代码来源:port_call_drv.c


示例18: get_size

static void get_size(Cmd *cmd) {
  char *buff = cmd->data;
  int len = cmd->size;
  Gd *gd = cmd->gd;
  unsigned int x;
  unsigned int y;
  ei_x_buff b;
  
  if (gd->image == NULL) {
    driver_failure_atom(gd->port, "null_image");
    return;
  }
  
  x = gdImageSX(gd->image);
  y = gdImageSY(gd->image);
  
  ei_x_new_with_version(&b);
  ei_x_encode_tuple_header(&b, 2);
  ei_x_encode_long(&b, x);
  ei_x_encode_long(&b, y);
  driver_output(gd->port, b.buff, b.index);
  ei_x_free(&b);
}
开发者ID:alepharchives,项目名称:ef_gd,代码行数:23,代码来源:gd_drv.c


示例19: make_attribute_legacy

int
make_attribute_legacy(struct exmpp_xml_ctx *ctx,
    const char *attr, int attr_len,
    const char *value, int value_len)
{
	ei_x_buff *tree;

	tree = ctx->current_tree;

	/* Start a simple tuple. */
	ei_x_encode_list_header(tree, 1);
	ei_x_encode_tuple_header(tree, 2);

	/* Check if the attribute is known and encode it. */
	encode_attr(ctx, tree, attr, attr_len);

	/* Encode the value. */
	if (value_len == -1)
		ei_x_encode_string(tree, value);
	else
		ei_x_encode_string_len(tree, value, value_len);

	return (0);
}
开发者ID:ASalimov,项目名称:exmpp,代码行数:24,代码来源:exmpp_xml.c


示例20: make_declared_ns_in_buf

int
make_declared_ns_in_buf(struct exmpp_xml_ctx *ctx, ei_x_buff *buf,
    const char *ns, int ns_len,
    const char *prefix, int prefix_len)
{

	/* Start declared namespace entry. */
	ei_x_encode_list_header(buf, 1);
	ei_x_encode_tuple_header(buf, 2);

	/* Check if the namespace is known and encode it. */
	encode_ns(ctx, buf, ns, ns_len);

	/* Encode prefix. */
	if (prefix != NULL)
		if (prefix_len == -1)
			ei_x_encode_string(buf, prefix);
		else
			ei_x_encode_string_len(buf, prefix, prefix_len);
	else
		ei_x_encode_atom(buf, "none");

	return (0);
}
开发者ID:ASalimov,项目名称:exmpp,代码行数:24,代码来源:exmpp_xml.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ei_x_free函数代码示例发布时间:2022-05-30
下一篇:
C++ ei_x_encode_atom函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap