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

C++ ei_x_free函数代码示例

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

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



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

示例1: ei_x_encode_list_header

void *erlXML_StartElementHandler(expat_data *d,
				 const XML_Char *name,
				 const XML_Char **atts)
{
   int i;

   ei_x_encode_list_header(&event_buf, 1);
   ei_x_encode_tuple_header(&event_buf, 2);
   ei_x_encode_long(&event_buf, XML_START);
   ei_x_encode_tuple_header(&event_buf, 2);
   encode_name(name);
   ei_x_append(&event_buf, &xmlns_buf);
   ei_x_free(&xmlns_buf);
   ei_x_new(&xmlns_buf);

   for (i = 0; atts[i]; i += 2) {}

   if (i > 0)
   {
      ei_x_encode_list_header(&event_buf, i/2);

      for (i = 0; atts[i]; i += 2)
      {
	 ei_x_encode_tuple_header(&event_buf, 2);
	 encode_name(atts[i]);
	 ei_x_encode_binary(&event_buf, atts[i+1], strlen(atts[i+1]));
      }
   }

   ei_x_encode_empty_list(&event_buf);

   return NULL;
}
开发者ID:Buttacavoli,项目名称:ejabberd,代码行数:33,代码来源:expat_erl.c


示例2: ei_rpc_to

/*
* Now returns non-negative number for success, negative for failure.
*/
int ei_rpc_to(ei_cnode *ec, int fd, char *mod, char *fun,
	      const char *buf, int len)
{

    ei_x_buff x;
    erlang_pid *self = ei_self(ec);
    self->num = fd;

    /* encode header */
    ei_x_new_with_version(&x);
    ei_x_encode_tuple_header(&x, 2);  /* A */
    
    self->num = fd;
    ei_x_encode_pid(&x, self);	      /* A 1 */
    
    ei_x_encode_tuple_header(&x, 5);  /* B A 2 */
    ei_x_encode_atom(&x, "call");     /* B 1 */
    ei_x_encode_atom(&x, mod);	      /* B 2 */
    ei_x_encode_atom(&x, fun);	      /* B 3 */
    ei_x_append_buf(&x, buf, len);    /* B 4 */
    ei_x_encode_atom(&x, "user");     /* B 5 */

    /* ei_x_encode_atom(&x,"user"); */
    ei_send_reg_encoded(fd, self, "rex", x.buff, x.index);
    ei_x_free(&x);
	
    return 0;
} /* rpc_to */
开发者ID:JeromeDeBretagne,项目名称:otp,代码行数:31,代码来源:ei_connect.c


示例3: ei_x_new_with_version

  bool CCESUT::TradeOrder(PTradeOrderTxnInput pTxnInput,
                          INT32 iTradeType, bool bExecutorIsAccountOwner) {
    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.TO");
        ei_x_encode_tuple_header(&x, 3);
        {
          m_Encoder.encode(&x, "trade_type", iTradeType);
          m_Encoder.encode(&x, "executor_is_account_owner", bExecutorIsAccountOwner);
          m_Encoder.encode(&x, *pTxnInput);
        }
      }
    }

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

#ifdef _TRACE
    cout << "[TO] ! " << *pTxnInput << ", result=" << result << '\r' << endl;
#endif

    ei_x_free(&x);

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


示例4: json_parse_to_ei

void json_parse_to_ei(ErlDrvData session, const unsigned char* s, int len, int opts) {
  int parseValue = opts & EEP0018_PARSE_VALUE;
  
  unsigned char* yajl_msg = 0;
  unsigned char* msg = 0;
  ErlDrvPort port = (ErlDrvPort) session;

  /*
   * initialize yajl parser
   */
  State state;
  init(&state, opts);
  
  yajl_parser_config conf = { YAJL_ALLOW_COMMENTS }; // , YAJL_CHECK_UTF8 };
  yajl_handle handle = yajl_alloc(&callbacks, &conf, &state);

  /* start parser */
  yajl_status stat;
  if(parseValue) stat = yajl_parse(handle, (const unsigned char*) "[ ", 2);
  stat = yajl_parse(handle, s, len);
  if(parseValue) stat = yajl_parse(handle, (const unsigned char*) " ]", 2);

  /*
   * sometimes the parser is still stuck inside a JSON token. This finishs
   * the token no matter what.
   */
  if(stat == yajl_status_insufficient_data)
    stat = yajl_parse(handle, (const unsigned char*) " ", 1);

  /* 
   * get an error message on errors
   */
  switch(stat) {
    case yajl_status_ok: break;
    case yajl_status_insufficient_data: 
      msg = (unsigned char*)"Insufficient data"; 
      break;
    default:
      msg = yajl_msg = yajl_get_error(handle, 0, s, len);
      break;
  }

  /* 
   * if result is not ok: we write {error, "reason"} instead. This is 
   * something that will never be encoded from any JSON data.
   */
  if(msg) {
    ei_x_free(&state.ei_buf);
    ei_x_new_with_version(&state.ei_buf);

    ei_x_encode_tuple_header(&state.ei_buf, 2);
    ei_x_encode_atom_len(&state.ei_buf, "error", 5);
    ei_x_encode_string_len(&state.ei_buf, (const char*) msg, strlen((const char*) msg));

    if(yajl_msg) yajl_free_error(yajl_msg);
  } 

  send_data(port, EEP0018_EI, state.ei_buf.buff, state.ei_buf.index);
  deinit(&state);
}
开发者ID:radiospiel,项目名称:eep0018,代码行数:60,代码来源:json_parse.c


示例5: reply_avframe

void reply_avframe(AVPacket *pkt, AVCodec *codec) {
  ei_x_buff x;
  ei_x_new_with_version(&x);
  struct video_frame r;

  r.content = codec->type == AVMEDIA_TYPE_VIDEO ? frame_content_video :
    codec->type == AVMEDIA_TYPE_AUDIO ? frame_content_audio : 0;

  r.dts = pkt->dts / 90.0;
  r.pts = pkt->pts / 90.0;
  r.stream_id = 0;
  r.codec = codec->id == AV_CODEC_ID_H264 ? frame_codec_h264 :
    codec->id == AV_CODEC_ID_AAC ? frame_codec_aac : 0;

  r.flavor = pkt->flags & CODEC_FLAG_GLOBAL_HEADER ? frame_flavor_config :
    pkt->flags & AV_PKT_FLAG_KEY ? frame_flavor_keyframe : 
    frame_flavor_frame;

  r.track_id = codec->type == AVMEDIA_TYPE_VIDEO ? 1 : 2;
  r.body.data = pkt->data;
  r.body.size = pkt->size;
  write_video_frame(&x, r);
  write_x(&x);
  ei_x_free(&x);
}
开发者ID:brahimalaya,项目名称:flussonic,代码行数:25,代码来源:ffmpeg_io.c


示例6: get_bin_term

/*
 * Reads an Erlang term.
 *
 * Only accepts 't' (term) or 'e' (end of test),
 * exits program on error
 * returns 1 on 'e', 0 on 't'
 */
int get_bin_term(ei_x_buff* x, ei_term* term)
{
    int len, version;

    ei_x_free(x);
    x->buff = read_packet(&len);
    x->buffsz = len;
    x->index = 0;
    switch (x->buff[x->index++]) {
    case 'e':
	return 1;
    case 't':
	if (ei_decode_version(x->buff, &x->index, &version) < 0
	    || ei_decode_ei_term(x->buff, &x->index, term) < 0) {
	    fail("Failed to decode term");
	    exit(0);
	}
	return 0;
    default:
	fprintf(stderr, "Garbage received: ");
	dump(x->buff, len, 16);
	putc('\n', stderr);
	fail("C program received garbage");
	exit(1);
    }
}
开发者ID:3112517927,项目名称:otp,代码行数:33,代码来源:ei_runner.c


示例7: reply_atom

void reply_atom(char *a) {
  ei_x_buff x;
  ei_x_new_with_version(&x);
  ei_x_encode_atom(&x, a);
  write_x(&x);
  ei_x_free(&x);
}
开发者ID:brahimalaya,项目名称:flussonic,代码行数:7,代码来源:ffmpeg_io.c


示例8: cmd_ei_send_funs

static void cmd_ei_send_funs(char* buf, int len)
{
    int index = 0, n;
    long fd;
    erlang_pid pid;
    ei_x_buff x;
    erlang_fun fun1, fun2;

    if (ei_decode_long(buf, &index, &fd) < 0)
	fail("expected long");
    if (ei_decode_pid(buf, &index, &pid) < 0)
	fail("expected pid (node)");
    if (ei_decode_tuple_header(buf, &index, &n) < 0)
	fail("expected tuple");
    if (n != 2)
	fail("expected tuple");
    if (ei_decode_fun(buf, &index, &fun1) < 0)
	fail("expected Fun1");
    if (ei_decode_fun(buf, &index, &fun2) < 0)
	fail("expected Fun2");
    if (ei_x_new_with_version(&x) < 0)
	fail("ei_x_new_with_version");
    if (ei_x_encode_tuple_header(&x, 2) < 0)
	fail("encode tuple header");
    if (ei_x_encode_fun(&x, &fun1) < 0)
	fail("encode fun1");
    if (ei_x_encode_fun(&x, &fun2) < 0)
	fail("encode fun2");
    free_fun(&fun1);
    free_fun(&fun2);
    send_errno_result(ei_send(fd, &pid, x.buff, x.index));
    ei_x_free(&x);
}
开发者ID:3112517927,项目名称:otp,代码行数:33,代码来源:ei_connect_test.c


示例9: gn_handle_read

/* called from gtk main loop when there's data on the cnode socket */
gboolean gn_handle_read(GIOChannel *source,GIOCondition cond,gpointer data){
  erlang_msg msg;
  ei_x_buff xbuf;
  
  /*   fd = g_io_channel_unix_get_fd(source); */
  ei_x_new_with_version(&xbuf);
  switch ( ei_xreceive_msg(fd, &msg, &xbuf) ){
  case ERL_TICK:
    break;			/* ignore */
  case ERL_MSG:
    switch (msg.msgtype) {
    case ERL_SEND:
    case ERL_REG_SEND:
      reply(&msg, &xbuf);
      break;
    case ERL_LINK:
    case ERL_UNLINK:
    case ERL_GROUP_LEADER:
      break;			/* ignore */
    case ERL_EXIT:
    case ERL_EXIT2:
    case ERL_NODE_LINK:
      gtk_main_quit();		/* crash and burn */
      return FALSE;
    }
    break;
  case ERL_ERROR:
    gtk_main_quit();		/* crash and burn */
    return FALSE;
  }
  ei_x_free(&xbuf);
  return TRUE;
}
开发者ID:XinliNiu,项目名称:jungerl,代码行数:34,代码来源:gtkNode_cnode.c


示例10: ei_x_encode_table

int ei_x_encode_table(ei_x_buff* types, ei_x_buff* values, K r, QOpts* opts) {

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

    EI(ei_x_encode_tuple_header(values, 2));

    ei_x_buff column_types;
    ei_x_new_with_version(&column_types);
    EIC(ei_x_encode_k_tv(&column_types, values, kK(r->k)[0], opts),
            ei_x_free(&column_types));
    ei_x_free(&column_types);

    EI(ei_x_encode_k_tv(types, values, kK(r->k)[1], opts));
    return 0;
}
开发者ID:csurface,项目名称:gen_q,代码行数:16,代码来源:q2e.c


示例11: send_atom

static void send_atom(ErlDrvPort port, const char *str) {
  ei_x_buff x;
  ei_x_new_with_version(&x);
  ei_x_encode_atom(&x, str);
  driver_output(port, x.buff, x.index);
  ei_x_free(&x);
}
开发者ID:alepharchives,项目名称:ef_gd,代码行数:7,代码来源:gd_drv.c


示例12: gn_start_cnode

int gn_start_cnode(char **argv) {
  extern ei_cnode ec;
  char rem_node_name[MAXATOMLEN] = "";  /* other node name */
  ei_x_buff xbuf;
  erlang_pid *self = ei_self(&ec);

  strcat(rem_node_name,REMNODE);
  strcat(rem_node_name,"@");
  strcat(rem_node_name,REMHOST);
  rem_regname = g_strdup(REMREG);
  g_print("I am %s, you are %s (%d)\n", NODE_NAME, rem_node_name, ERL_DIST_VSN);

  ei_set_compat_rel(ERL_DIST_VSN); /* erlnode version of dist. protocol */

  if ( ei_connect_init(&ec, NODE_NAME, COOKIE, CREATION) < 0 )
    g_critical("ei_connect_init");

  if ( (fd = ei_connect(&ec, rem_node_name)) < 0 )
    g_critical("ei_connect failed.\nwrong cookie? erl-dist version mismatch?");

  self->num = fd;               /* bug?? in ei_reg_send_tmo */

  ei_x_new_with_version(&xbuf);
  gn_wrap_ans("handshake", &xbuf);
  ei_x_encode_empty_list(&xbuf);
  gn_send(&xbuf);
  ei_x_free(&xbuf);

  return fd;
}
开发者ID:charlesdaniel,项目名称:gtknode,代码行数:30,代码来源:gtknode_cnode.c


示例13: erlang_srdb1_insert_update

/**
  * Insert a row into a specified table, update on duplicate key.
  * \param _h structure representing database connection
  * \param _k key names
  * \param _v values of the keys
  * \param _n number of key=value pairs
 */
 int erlang_srdb1_insert_update(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v,
	const int _n)
 {
	ei_x_buff argbuf;
	int retcode;

	if ((!_h) || (!_k) || (!_v) || (!_n)) {
		LM_ERR("invalid parameter value\n");
		return -1;
	}
	LM_DBG("erlang_srdb1_insert_update table %.*s\n",CON_TABLE(_h)->len, CON_TABLE(_h)->s);
	ei_x_new(&argbuf);
	//encode tuple {db_op, table, [cols], [keys], [vals]}
	ei_x_encode_tuple_header(&argbuf, 5);
	ei_x_encode_atom(&argbuf,"insert_update");
	ei_x_encode_atom_len(&argbuf,CON_TABLE(_h)->s,CON_TABLE(_h)->len);

	ei_x_encode_list_header(&argbuf, 0); //_c
//	ei_x_encode_list_header(&argbuf, 0); //_k
	srdb1_encode_k(_k, NULL, _v, _n, &argbuf); //_k
	srdb1_encode_v(_k, _v, _n, &argbuf); //_v

	retcode=erl_bind.do_erlang_call(&(CON_ERLANG(_h)->con),&(CON_ERLANG(_h)->regname), &argbuf, NULL /*&retbuf*/);
	ei_x_free(&argbuf);
	if (retcode<0) {
//		if(retbuf.buff) shm_free(retbuf.buff);
		return retcode;
	}
	return 0;
}
开发者ID:majastanislawska,项目名称:sip-router-erlang-module,代码行数:37,代码来源:db_erlang_srdb1.c


示例14: send_hash

static void send_hash(ErlDrvPort port, unsigned long hash) {
  ei_x_buff x;
  ei_x_new_with_version(&x);
  ei_x_encode_ulong(&x, hash);
  driver_output(port, x.buff, x.index);
  // printf("sent hash %d\n", hash);
  ei_x_free(&x);
}
开发者ID:Jasson,项目名称:devdb,代码行数:8,代码来源:murmur_drv.c


示例15: main

/*-----------------------------------------------------------------
 * MAIN
 *----------------------------------------------------------------*/
int main(int argc, char *argv[])
{
    byte*     buf;
    int       size = BUF_SIZE;

    if (argc > 1) {
	test(argc, argv);
	return 0;
    }

    fprintf(stderr, "gssapi started\r\n");

    if ((buf = malloc(size)) == NULL)
	return -1;
    
    while ( (buf = read_cmd(buf, &size)) ) {
	int res = 0;
	int index = 0;
	int version, arity;
	char command[MAXATOMLEN];
	ei_x_buff result;
	port_func func;

	/* Ensure that we are receiving the binary term by reading and 
	 * stripping the version byte */
	EI(ei_decode_version(buf, &index, &version));
    
	/* Our marshalling spec is that we are expecting a tuple {Command, Arg1} */
	EI(ei_decode_tuple_header(buf, &index, &arity));
    
	EI(arity != 2);
    
	EI(ei_decode_atom(buf, &index, command));

	/* Prepare the output buffer that will hold {ok, Result} or {error, Reason} */
	EI(ei_x_new_with_version(&result) || ei_x_encode_tuple_header(&result, 2));
    
/* 	fprintf(stderr, "command: %s\r\n", command); */
	func = lookup_func(command);

	if (func) {
	    res = func(buf, index, &result);
	} else {
	    EI(ei_x_encode_atom(&result, "error") || ei_x_encode_atom(&result, "unsupported_command"));
	}

	write_cmd(&result);

	ei_x_free(&result);
    }

/* error: */
    fprintf(stderr, "No more command, exiting\r\n");

    return 0;
}
开发者ID:GlenWalker,项目名称:egssapi,代码行数:59,代码来源:gssapi_drv.c


示例16: ok

static void
ok() {
    ei_x_buff result;

    check(ei_x_new_with_version(&result));
    check(ei_x_encode_atom(&result, "ok"));

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


示例17: send_errno_result

static void send_errno_result(int value)
{
    ei_x_buff x;
    ei_x_new_with_version(&x);
    ei_x_encode_tuple_header(&x, 2);
    ei_x_encode_long(&x, value);
    ei_x_encode_long(&x, erl_errno);
    send_bin_term(&x);
    ei_x_free(&x);
}
开发者ID:3112517927,项目名称:otp,代码行数:10,代码来源:ei_connect_test.c


示例18: ei_x_new_with_version

void Client::sendMessage(QByteArray procName, QVariant value)
{
    ei_x_buff x;
    ei_x_new_with_version(&x);

    encode(value, &x);
    ei_reg_send(m_ec, m_fd, procName.data(), x.buff, x.index);

    ei_x_free(&x);
}
开发者ID:willpenington,项目名称:mailslot,代码行数:10,代码来源:client.cpp


示例19: control

static ErlDrvSSizeT control(ErlDrvData drvstate, unsigned int command,
			    char *args, ErlDrvSizeT argslen,
			    char **rbuf, ErlDrvSizeT rbuflen) {
  state *st = (state *)drvstate;
  init_state(st, args, argslen);

  switch (command) {
  case ENDWIN: do_endwin(st); break;
  case INITSCR: do_initscr(st); break;
  case REFRESH: do_refresh(st); break;
  case CBREAK: do_cbreak(st); break;
  case NOCBREAK: do_nocbreak(st); break;
  case ECHO: do_echo(st); break;
  case NOECHO: do_noecho(st); break;
  case ADDCH: do_addch(st); break;
  case ADDSTR: do_addstr(st); break;
  case MOVE: do_move(st); break;
  case GETYX: do_getyx(st); break;
  case GETMAXYX: do_getmaxyx(st); break;
  case CURS_SET: do_curs_set(st); break;
  case WERASE: do_werase(st); break;
  case HAS_COLORS: do_has_colors(st); break;
  case START_COLOR: do_start_color(st); break;
  case INIT_PAIR: do_init_pair(st); break;
  case WATTRON: do_wattron(st); break;
  case WATTROFF: do_wattroff(st); break;
  case NL: do_nl(st); break;
  case NONL: do_nonl(st); break;
  case SCROLLOK: do_scrollok(st); break;
  case MVADDCH: do_mvaddch(st); break;
  case MVADDSTR: do_mvaddstr(st); break;
  case NEWWIN: do_newwin(st); break;
  case DELWIN: do_delwin(st); break;
  case WMOVE: do_wmove(st); break;
  case WADDSTR: do_waddstr(st); break;
  case WADDCH: do_waddch(st); break;
  case MVWADDSTR: do_mvwaddstr(st); break;
  case MVWADDCH: do_mvwaddch(st); break;
  case WREFRESH: do_wrefresh(st); break;
  case WHLINE: do_whline(st); break;
  case WVLINE: do_wvline(st); break;
  case WBORDER: do_wborder(st); break;
  case BOX: do_box(st); break;
  case KEYPAD: do_keypad(st); break;
  default: break;
  }

  int rlen = st->eixb.index;
  ErlDrvBinary *response = driver_alloc_binary(rlen);
  memcpy(response->orig_bytes, st->eixb.buff, rlen);
  ei_x_free(&(st->eixb));
  *rbuf = (char *)response;
  return rlen;
}
开发者ID:Ma3aXuCT,项目名称:cecho,代码行数:54,代码来源:cecho.c


示例20: key_size

static void key_size(bloom_drv_t *driver) {
  long result;
  ei_x_buff x;
  result = bloom_key_size(driver->bloom);
  
  ei_x_new_with_version(&x);
  ei_x_encode_long(&x, result);
  
  driver_output(driver->port, x.buff, x.index);
  ei_x_free(&x);
}
开发者ID:JiamingXiao,项目名称:dynomite,代码行数:11,代码来源:bloom_drv.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ ei_x_new_with_version函数代码示例发布时间:2022-05-30
下一篇:
C++ ei_x_encode_tuple_header函数代码示例发布时间: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