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

C++ ei_decode_tuple_header函数代码示例

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

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



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

示例1: read_pointer

couchfile_pointer_info* read_pointer(char* buf, int pos)
{
//Parse KP pair into a couchfile_pointer_info {K, {ptr, reduce_value, subtreesize}}
    couchfile_pointer_info *p = malloc(sizeof(couchfile_pointer_info));
    p->writerq_resource = NULL;
    //DBG("%u,%u,%u,%u\n", buf[pos+0], buf[pos+1], buf[pos+2], buf[pos+3]);
    ei_decode_tuple_header(buf, &pos, NULL); //arity 2
    term_to_buf(&p->key, buf, &pos);
    ei_decode_tuple_header(buf, &pos, NULL); //arity 3
    ei_decode_ulonglong(buf, &pos, (unsigned long long*) &p->pointer);
    term_to_buf(&p->reduce_value, buf, &pos);
    ei_decode_ulonglong(buf, &pos, (unsigned long long*) &p->subtreesize);

    return p;
}
开发者ID:Damienkatz,项目名称:couchdb,代码行数:15,代码来源:couch_btree.c


示例2: find_first_gteq

int find_first_gteq(char* buf, int pos, void* key, compare_info* lu, int at_least)
{
    int list_arity, inner_arity;
    int list_pos = 0, cmp_val;
    off_t pair_pos = 0;
    if(ei_decode_list_header(buf, &pos, &list_arity) < 0)
    {
        return ERROR_PARSE;
    }
    while(list_pos < list_arity)
    {
        //{<<"key", some other term}
        pair_pos = pos; //Save pos of kv/kp pair tuple

        if(ei_decode_tuple_header(buf, &pos, &inner_arity) < 0)
        {
            return ERROR_PARSE;
        }

        lu->last_cmp_key = (*lu->from_ext)(lu, buf,pos);
        cmp_val = (*lu->compare) (lu->last_cmp_key, key);
        lu->last_cmp_val = cmp_val;
        lu->list_pos = list_pos;
        if(cmp_val >= 0 && list_pos >= at_least)
        {
            break;
        }
        ei_skip_term(buf, &pos); //skip over the key
        ei_skip_term(buf, &pos); //skip over the value
        list_pos++;
    }
    return pair_pos;
}
开发者ID:Damienkatz,项目名称:couchdb,代码行数:33,代码来源:couch_btree.c


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


示例4: prepared_bind

static int prepared_bind(sqlite3_drv_t *drv, char *buffer, int buffer_size) {
  int result;
  unsigned int prepared_index;
  long long_prepared_index;
  int index = 0, type, size;
  sqlite3_stmt *statement;

#ifdef DEBUG
  fprintf(drv->log, "Finalizing prepared statement: %.*s\n", buffer_size, buffer);
  fflush(drv->log);
#endif

  ei_decode_version(buffer, &index, NULL);
  ei_decode_tuple_header(buffer, &index, &size);
  // assert(size == 2);
  ei_decode_long(buffer, &index, &long_prepared_index);
  prepared_index = (unsigned int) long_prepared_index;

  if (prepared_index >= drv->prepared_count) {
    return output_error(drv, SQLITE_MISUSE,
                        "Trying to bind non-existent prepared statement");
  }

  statement = drv->prepared_stmts[prepared_index];
  result =
      bind_parameters(drv, buffer, buffer_size, &index, statement, &type, &size);
  if (result == SQLITE_OK) {
    return output_ok(drv);
  } else {
    return result; // error has already been output
  }
}
开发者ID:mwpark,项目名称:sqlite-erlang,代码行数:32,代码来源:sqlite3_drv.c


示例5: handle_write

static void handle_write(const char *req, int *req_index)
{
    if (!uart_is_open(uart)) {
        send_error_response("ebadf");
        return;
    }

    int term_size;
    if (ei_decode_tuple_header(req, req_index, &term_size) < 0 ||
            term_size != 2)
        errx(EXIT_FAILURE, "expecting {data, timeout}");

    int term_type;
    if (ei_get_type(req, req_index, &term_type, &term_size) < 0 ||
            term_type != ERL_BINARY_EXT)
        errx(EXIT_FAILURE, "expecting data as a binary");

    uint8_t *to_write = malloc(term_size);
    long amount_to_write;
    if (ei_decode_binary(req, req_index, to_write, &amount_to_write) < 0)
        errx(EXIT_FAILURE, "decode binary error?");

    long timeout;
    if (ei_decode_long(req, req_index, &timeout) < 0)
        errx(EXIT_FAILURE, "expecting timeout");

    // uart_write always invokes a callback when it completes (error or no error).
    uart_write(uart, to_write, amount_to_write, timeout);
}
开发者ID:johnhamelink,项目名称:nerves_uart,代码行数:29,代码来源:nerves_uart.c


示例6: resize

static void resize(Cmd *cmd) {
  char *buff = cmd->data;
  int len = cmd->size;
  Gd *gd = cmd->gd;
  int index = 0;
  unsigned long width, height, srcW, srcH;
  gdImagePtr destination = NULL;
  
  ei_decode_version(buff, &index, NULL);
  ei_decode_tuple_header(buff, &index, NULL);
  ei_decode_ulong(buff, &index, &width);
  ei_decode_ulong(buff, &index, &height);
  
  if (NULL == gd->image) {
    driver_failure_atom(gd->port, "null_image");
    return;
  }
  
  srcW = gdImageSX(gd->image);
  srcH = gdImageSY(gd->image);
  
  destination = gdImageCreateTrueColor(width, height);
  
  if (NULL == destination) {
    driver_failure_posix(gd->port, ENOMEM);
    return;
  }
  
  gdImageCopyResampled(destination, gd->image, 0, 0, 0, 0, width, height, srcW, srcH);
  gdImageDestroy(gd->image);
  gd->image = destination;
  
  send_atom(gd->port, "ok");
}
开发者ID:alepharchives,项目名称:ef_gd,代码行数:34,代码来源:gd_drv.c


示例7: my_decode_tuple_header

int my_decode_tuple_header(const char *buf, int *index, struct my_obj* obj)
{
    int ret = ei_decode_tuple_header(buf, index, &obj->u.arity);
    if (ret == 0 && obj)
        obj->nterms = obj->u.arity;
    return ret;
}
开发者ID:Dasudian,项目名称:otp,代码行数:7,代码来源:ei_decode_encode_test.c


示例8: crop

static void crop(Cmd *cmd) {
  char *buff = cmd->data;
  int len = cmd->size;
  Gd *gd = cmd->gd;
  int index = 0;
  long width, height;
  int srcW, srcH, srcX, srcY, destX, destY, playX, playY;
  gdImagePtr destination = NULL;
  
  ei_decode_version(buff, &index, NULL);
  ei_decode_tuple_header(buff, &index, NULL);
  ei_decode_long(buff, &index, &width);
  ei_decode_long(buff, &index, &height);
  
  if (NULL == gd->image) {
    driver_failure_atom(gd->port, "null_image");
    return;
  }
  
  srcW = gdImageSX(gd->image);
  srcH = gdImageSY(gd->image);
  
  destination = gdImageCreateTrueColor(width, height);
  if (NULL == destination) {
    driver_failure_posix(gd->port, ENOMEM);
    return;
  }
  gdImageFilledRectangle(destination, 0, 0, width, height, gdImageColorAllocate(destination, 255, 255, 255));
  destX = (width - srcW) / 2;
  destY = (height - srcH) / 2;
  gdImageCopy(destination, gd->image, destX, destY, 0, 0, srcW, srcH);
  gdImageDestroy(gd->image);
  gd->image = destination;
  send_atom(gd->port, "ok");
}
开发者ID:alepharchives,项目名称:ef_gd,代码行数:35,代码来源:gd_drv.c


示例9: process_data

decode_result process_data(ErlDrvData handle,unsigned char* buf, ErlDrvSizeT* sz,char*& html_content,char*& url_address){

	int index = 0,size=0,type=0,ver=0;
	if (ei_decode_version((char*)buf, &index,&ver)){
		//data encoding version mismatch
		return decode_result{false,std::pair<std::string,std::string>("",""),
			"data encoding version mismatch"};
	}
	else if (ei_get_type((char*)buf,&index,&type,&size)){
		//must be a binary
		return decode_result{false,std::pair<std::string,std::string>("",""),
			"must be a binary"};
	} else{
		int tuple_arity;
		ei_decode_tuple_header((char*)buf,&index,&tuple_arity);
		ei_get_type((char*)buf,&index,&type,&size);
		url_address = (char*)driver_alloc((size+2)*sizeof(char));
		ei_decode_string((char*)buf,&index,url_address);
		ei_get_type((char*)buf,&index,&type,&size);
		//cout << "Html Content Size " << size << endl;
		html_content = (char*)driver_alloc((size+2)*sizeof(char));
		ei_decode_string((char*)buf,&index,html_content);
		*sz = size;
		std::string url_address_str(url_address);
		std::string html_content_str(html_content);
		return decode_result{true,std::pair<std::string,std::string>(url_address_str,html_content_str),NULL};
	}
}
开发者ID:mjamroz90,项目名称:erlCrawler,代码行数:28,代码来源:parse_html_driver.cpp


示例10: next_pointer

int next_pointer(GEOSCommand *command, int argc, char *name, void** data) {
	int arity;
	char atom[MAXATOMLEN];
	unsigned long pointer;


	//decode tuple
	if(ei_decode_tuple_header(command->param_bytes, &command->index, &arity)) {
		return -1;
	}

	//verify if it's the right label
	if(arity!=argc) {
		return -1;
	}


	//decode pointer label
	if(ei_decode_atom(command->param_bytes,&command->index, atom)) {
		return -1;
	}

	if(strcmp(atom,name)) {
		return -1;
	}
	//decode the pointer
	if(ei_decode_ulong(command->param_bytes, &command->index, &pointer)) {
		return -1;
	}

	*data = (void *) pointer;
	return 0;
}
开发者ID:alepharchives,项目名称:erlgeo,代码行数:33,代码来源:erl_geos_util.c


示例11: output

static void output(ErlDrvData drv_data, char *buf, ErlDrvSizeT) {

  driver_data_t *data = (driver_data_t *)drv_data;

  int result = 0;
  int index = 0, version, arity;

  ei_decode_version(buf, &index, &version);
  ei_decode_tuple_header(buf, &index, &arity);

  if (2 == arity) {

    result = ergen_driver_do_txn(data->driver, buf, &index);

    if(result) {
      ergen_drv_output_bool(data->port, result);
    } else {
      ergen_drv_output_error1(data->port, "badmatch", "cmd");
    }

    return;
  }

  ergen_drv_output_error0(data->port, "badarg");
}
开发者ID:tomaon,项目名称:ergen,代码行数:25,代码来源:ERGenDM_drv.C


示例12: handle_elixir_request

/**
 * @brief Decode and forward requests from Elixir to the appropriate handlers
 * @param req the undecoded request
 * @param cookie
 */
static void handle_elixir_request(const char *req, void *cookie)
{
    (void) cookie;

    // Commands are of the form {Command, Arguments}:
    // { atom(), term() }
    int req_index = sizeof(uint16_t);
    if (ei_decode_version(req, &req_index, NULL) < 0)
        errx(EXIT_FAILURE, "Message version issue?");

    int arity;
    if (ei_decode_tuple_header(req, &req_index, &arity) < 0 ||
            arity != 2)
        errx(EXIT_FAILURE, "expecting {cmd, args} tuple");

    char cmd[MAXATOMLEN];
    if (ei_decode_atom(req, &req_index, cmd) < 0)
        errx(EXIT_FAILURE, "expecting command atom");

    for (struct request_handler *rh = request_handlers; rh->name != NULL; rh++) {
        if (strcmp(cmd, rh->name) == 0) {
            rh->handler(req, &req_index);
            return;
        }
    }
    errx(EXIT_FAILURE, "unknown command: %s", cmd);
}
开发者ID:johnhamelink,项目名称:nerves_uart,代码行数:32,代码来源:nerves_uart.c


示例13: trace_file_output

/*
** Data sent from erlang to port.
*/
static void trace_file_output(ErlDrvData handle, char *buf,
			      ErlDrvSizeT len)
{
  int index = 1;
  ei_print_term(stdout, buf, &index);
  erts_printf("\n");
  /* erts_printf("output: %d: %u\n", rc, (unsigned char)buff[0]); */
  int arity;
  char atom[MAXATOMLEN];
  char type[MAXATOMLEN];
  char pidstr[100];
  index = 1;
  erlang_pid pid;
  if(!ei_decode_tuple_header(buf, &index, &arity)) {
    if(!ei_decode_atom(buf, &index, atom)) {
      if(strcmp("trace", atom) == 0) {
        if(!ei_decode_pid(buf, &index, &pid)) {
          if(!ei_decode_atom(buf, &index, type)) {
            snprintf(pidstr, 100, "<0.%d.%d>", pid.num, pid.serial);
            erts_printf("%s: %s\n", pidstr, type);
            dispatch(pidstr, type, index, buf);
          }
        }
      }
    }
  }
}
开发者ID:jtuple,项目名称:dt_trace,代码行数:30,代码来源:dt_trace.c


示例14: iconv_erl_control

static int iconv_erl_control(ErlDrvData drv_data,
			     unsigned int command,
			     char *buf, int len,
			     char **rbuf, int rlen)
{
   int i;
   int size;
   int index = 0;
   int avail;
   size_t inleft, outleft;
   ErlDrvBinary *b;
   char *from, *to, *string, *stmp, *rstring, *rtmp;
   iconv_t cd;

   ei_decode_version(buf, &index, &i);
   ei_decode_tuple_header(buf, &index, &i);
   ei_get_type(buf, &index, &i, &size);
   from = malloc(size + 1); 
   ei_decode_string(buf, &index, from);

   ei_get_type(buf, &index, &i, &size);
   to = malloc(size + 1); 
   ei_decode_string(buf, &index, to);
  
   ei_get_type(buf, &index, &i, &size);
   stmp = string = malloc(size + 1); 
   ei_decode_string(buf, &index, string);
  
   cd = iconv_open(to, from);

   if(cd == (iconv_t) -1)
   {
      cd = iconv_open("ascii", "ascii");
      if(cd == (iconv_t) -1)
	{
	  cd = iconv_open("ascii", "ascii");
	}
   }
   
   outleft = avail = 4*size;
   inleft = size;
   rtmp = rstring = malloc(avail);
   iconv(cd, &stmp, &inleft, &rtmp, &outleft);
   
   size = rtmp - rstring;

   //printf("size=%d, res=%s\r\n", size, rstring);
   
   *rbuf = (char*)(b = driver_alloc_binary(size));
   memcpy(b->orig_bytes, rstring, size);

   free(from);
   free(to);
   free(string);
   free(rstring);
   iconv_close(cd);
   
   return size;
}
开发者ID:trimnguye,项目名称:ChatServer,代码行数:59,代码来源:iconv_erl.c


示例15: do_wattroff

void do_wattroff(state *st) {
  int arity;
  long slot, attrs;
  ei_decode_tuple_header(st->args, &(st->index), &arity);
  ei_decode_long(st->args, &(st->index), &slot);
  ei_decode_long(st->args, &(st->index), &attrs);
  encode_ok_reply(st, wattroff(st->win[slot], (int)attrs));
}
开发者ID:Ma3aXuCT,项目名称:cecho,代码行数:8,代码来源:cecho.c


示例16: do_move

void do_move(state *st) {
  int arity;
  long y, x;
  ei_decode_tuple_header(st->args, &(st->index), &arity);
  ei_decode_long(st->args, &(st->index), &y);
  ei_decode_long(st->args, &(st->index), &x);
  encode_ok_reply(st, move((int)y, (int)x));
}
开发者ID:Ma3aXuCT,项目名称:cecho,代码行数:8,代码来源:cecho.c


示例17: do_keypad

void do_keypad(state *st) {
  int arity, bf;
  long slot;
  ei_decode_tuple_header(st->args, &(st->index), &arity);
  ei_decode_long(st->args, &(st->index), &slot);
  ei_decode_boolean(st->args, &(st->index), &bf);
  encode_ok_reply(st, keypad(st->win[slot], bf));
}
开发者ID:Ma3aXuCT,项目名称:cecho,代码行数:8,代码来源:cecho.c


示例18: erl_self

ETERM *erl_global_whereis(int fd, const char *name, char *node)
{
  char buf[EISMALLBUF];
  char *bufp=buf;
  char tmpbuf[64];
  int index = 0;
  erlang_pid *self = erl_self();
  erlang_pid epid;
  ETERM *opid;
  erlang_msg msg;
  int i;
  int version,arity,msglen;

  self->num = fd;		/* FIXME looks strange to change something?! */

  ei_encode_version(buf,&index);
  ei_encode_tuple_header(buf,&index,2);
  ei_encode_pid(buf,&index,self);               /* PidFrom */
  ei_encode_tuple_header(buf,&index,5);
  ei_encode_atom(buf,&index,"call");            /* call */
  ei_encode_atom(buf,&index,"global");          /* Mod */
  ei_encode_atom(buf,&index,"whereis_name");    /* Fun */
  ei_encode_list_header(buf,&index,1);          /* Args: [ name ] */
  ei_encode_atom(buf,&index,name);
  ei_encode_empty_list(buf,&index);
  ei_encode_atom(buf,&index,"user");            /* user */

  /* make the rpc call */
  if (ei_send_reg_encoded(fd,self,"rex",buf,index)) return NULL;

  while (1) {
    index = EISMALLBUF;
    if (!(i = ei_recv_internal(fd,&bufp,&index,&msg,&msglen,1,0))) continue;
    else break;
  }

  if (i != ERL_SEND) return NULL;
    
  /* expecting { rex, pid } */
  index = 0;
  if (ei_decode_version(buf,&index,&version) 
      || ei_decode_tuple_header(buf,&index,&arity) 
      || (arity != 2) 
      || ei_decode_atom(buf,&index,tmpbuf) 
      || strcmp(tmpbuf,"rex")
      || ei_decode_pid(buf,&index,&epid))
    return NULL; /* bad response from other side */

  /* put the pid into a format for the caller */
  index = 0;
  ei_encode_pid(buf,&index,&epid);
  opid = erl_decode((unsigned char*)buf);

  /* extract the nodename for the caller */
  if (node) strcpy(node,epid.node);

  return opid;
}
开发者ID:system,项目名称:erlang-otp,代码行数:58,代码来源:global_whereis.c


示例19: do_mvaddch

void do_mvaddch(state *st) {
  int arity;
  long y, x, ch;
  ei_decode_tuple_header(st->args, &(st->index), &arity);
  ei_decode_long(st->args, &(st->index), &y);
  ei_decode_long(st->args, &(st->index), &x);
  ei_decode_long(st->args, &(st->index), &ch);
  encode_ok_reply(st, mvaddch((int)y, (int)x, (chtype)ch));
}
开发者ID:Ma3aXuCT,项目名称:cecho,代码行数:9,代码来源:cecho.c


示例20: do_init_pair

void do_init_pair(state *st) {
  int arity;
  long pairnum, fcolor, bcolor;
  ei_decode_tuple_header(st->args, &(st->index), &arity);
  ei_decode_long(st->args, &(st->index), &pairnum);
  ei_decode_long(st->args, &(st->index), &fcolor);
  ei_decode_long(st->args, &(st->index), &bcolor);
  encode_ok_reply(st, init_pair((int)pairnum, (int)fcolor, (int)bcolor));
}
开发者ID:Ma3aXuCT,项目名称:cecho,代码行数:9,代码来源:cecho.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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