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


C++ ei_x_new_with_version函数代码示例

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


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

示例1: 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:alepharchives,项目名称:flussonic,代码行数:25,代码来源:ffmpeg_io.c

示例2: 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

示例3: 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:616050468,项目名称:gtknode,代码行数:30,代码来源:gtknode_cnode.c

示例4: erl_send

/* 
 * Sends an Erlang message to a process at an Erlang node
 */
int erl_send(int fd, ETERM *to ,ETERM *msg)
{
    erlang_pid topid;
    ei_x_buff x;
    int r;

    ei_x_new_with_version(&x);
    ei_x_encode_term(&x, msg);
    /* make the to-pid */
    if (!ERL_IS_PID(to)) {
	ei_x_free(&x);
	erl_errno = EINVAL;
	return -1;
    }

    if (to->uval.pidval.node.latin1) {
	strcpy(topid.node, to->uval.pidval.node.latin1);
    }
    else {
	strcpy(topid.node, to->uval.pidval.node.utf8);
    }    
    topid.num = ERL_PID_NUMBER(to);
    topid.serial = ERL_PID_SERIAL(to);
    topid.creation = ERL_PID_CREATION(to);
    r = ei_send(fd, &topid, x.buff, x.index);
    ei_x_free(&x);
    return r == 0;
}
开发者ID:0x00evil,项目名称:otp,代码行数:31,代码来源:erl_connect.c

示例5: 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:616050468,项目名称:otp,代码行数:31,代码来源:ei_connect.c

示例6: einode_thread

static DWORD WINAPI
#else
static void*
#endif
    einode_thread(void* num)
{
    int n = (int)num;
    ei_cnode ec;
    char myname[100], destname[100];
    int r, fd;

    sprintf(myname, "ei%d", n);
    sprintf(destname, "mth%d", n);
    printf("thread %d (%s %s) connecting\n", n, myname, destname);
    r = ei_connect_init(&ec, myname, cookie, 0);
    fd = ei_connect(&ec, (char*)desthost);
    if (r == 0 && fd >= 0) {
	ei_x_buff x;
	ei_x_new_with_version(&x);
	ei_x_encode_string(&x, myname);
	ei_reg_send(&ec, fd, destname, x.buff, x.index);
	ei_x_free(&x);
	//SleepEx(100);
	shutdown(fd, SD_SEND);
	closesocket(fd);
    } else {
	printf("coudn't connect fd %d r %d\n", fd, r); //	DebugBreak();
    }
    printf("done thread %d\n", n);
    return 0;
}
开发者ID:3112517927,项目名称:otp,代码行数:31,代码来源:einode.c

示例7: 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

示例8: 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:alepharchives,项目名称:flussonic,代码行数:7,代码来源:ffmpeg_io.c

示例9: ei_x_new_with_version

  bool CDMSUT::TradeCleanup(PTradeCleanupTxnInput 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.TC");
        m_Encoder.encode(&x, *pTxnInput);
      }
    }

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

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

    ei_x_free(&x);

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

示例10: current_tree_finished

static int
current_tree_finished(struct exmpp_xml_ctx *ctx)
{
	ei_x_buff *trees;

	trees = ctx->complete_trees;
	if (trees == NULL) {
		/* Allocate the complete trees list. */
		trees = driver_alloc(sizeof(*trees));
		if (trees == NULL)
			return (-1);
		ei_x_new_with_version(trees);
		ctx->complete_trees = trees;
	}

	/* Append the current tree to the complete trees list. */
	ei_x_encode_list_header(trees, 1);
	ei_x_append(trees, ctx->current_tree);
	ctx->complete_trees_ready = 1;

	/* Reset the current tree. */
	reset_current_tree(ctx);

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

示例11: epcap_response

    void
epcap_response(u_char *user, const struct pcap_pkthdr *hdr, const u_char *pkt)
{
    EPCAP_STATE *ep = (EPCAP_STATE *)user;
    ei_x_buff msg = {0};

    IS_FALSE(ei_x_new_with_version(&msg));

    /* {packet, DatalinkType, Time, ActualLength, Packet} */
    IS_FALSE(ei_x_encode_tuple_header(&msg, 5));
    IS_FALSE(ei_x_encode_atom(&msg, "packet"));

    /* DataLinkType */
    IS_FALSE(ei_x_encode_long(&msg, ep->datalink));

    /* {MegaSec, Sec, MicroSec} */
    IS_FALSE(ei_x_encode_tuple_header(&msg, 3));
    IS_FALSE(ei_x_encode_long(&msg, abs(hdr->ts.tv_sec / 1000000)));
    IS_FALSE(ei_x_encode_long(&msg, hdr->ts.tv_sec % 1000000));
    IS_FALSE(ei_x_encode_long(&msg, hdr->ts.tv_usec));

    /* ActualLength} */
    IS_FALSE(ei_x_encode_long(&msg, hdr->len));

    /* Packet */
    IS_FALSE(ei_x_encode_binary(&msg, pkt, hdr->caplen));

    /* } */

    epcap_send_free(&msg);
}
开发者ID:kostyushkin,项目名称:epcap,代码行数:31,代码来源:epcap.c

示例12: 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

示例13: 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

示例14: 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:616050468,项目名称:gtknode,代码行数:34,代码来源:gtknode_cnode.c

示例15: handle_winch

void handle_winch(int sig){
  ei_x_buff eixb;
  ei_x_new_with_version(&eixb);
  tuple(&eixb, 2);
  atom(&eixb, "sigwinch", 8);
  atom(&eixb, "sigwinch", 8);
  driver_output(stpt->drv_port, eixb.buff, eixb.index);
}
开发者ID:sofuture,项目名称:cecho,代码行数:8,代码来源:cecho.c


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