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

C++ ERL_INT_VALUE函数代码示例

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

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



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

示例1: erl_element

ETERM *body_set_collision_circle(ETERM *fromp, ETERM *argp) {

    // get the args
    ETERM *space_refp = erl_element(1, argp);
    ETERM *idp = erl_element(2, argp);
    ETERM *radiusp = erl_element(3, argp);
    ETERM *collision_typep = erl_element(4, argp);

    erlmunk_space *s;
    int space_id = ERL_REF_NUMBER(space_refp);
    HASH_FIND_INT(erlmunk_spaces, &space_id, s);

    int body_id = ERL_INT_VALUE(idp);
    erlmunk_body *b;
    HASH_FIND_INT(s->bodies, &body_id, b);
    if (b == NULL)
        return NULL;

    cpShape *shape = cpSpaceAddShape(s->space,
                                     cpCircleShapeNew(b->body, ERL_FLOAT_VALUE(radiusp),
                                                      cpvzero));
    cpShapeSetCollisionType(shape, ERL_INT_VALUE(collision_typep));

    // DEBUGF(("body_set_collision_circle has succeeded"));
    return NULL;
}
开发者ID:lrascao,项目名称:erlmunk,代码行数:26,代码来源:erlmunk_space.c


示例2: hello_getattr

static int hello_getattr(const char *path, struct stat *stbuf)
{
	ETERM * response = erl_rpc(FERL_DATA->erlang_fd,"gen_server","call",erl_format("[nefs,{get_attr,~s}]",path));
	ETERM * pattern = erl_format("{directory,Mode,Nlink}");
	ETERM * pattern2 = erl_format("{file,Mode,Nlink,Size}");
        int res = 0;
	memset(stbuf, 0, sizeof(struct stat));

	if(erl_match(pattern, response)) { //directory
		ETERM * Mode = erl_var_content(pattern, "Mode");
		ETERM * Nlink = erl_var_content(pattern, "Nlink");
		if(ERL_IS_INTEGER(Nlink) && ERL_IS_INTEGER(Mode)){
			stbuf->st_mode = S_IFDIR | ERL_INT_VALUE(Mode); //permissions
        	        stbuf->st_nlink = ERL_INT_VALUE(Nlink); // directories have the number of files in them
		}else{
			res = -ENOENT;
		}
	}else if(erl_match(pattern2, response)){ //file
		ETERM * Mode = erl_var_content(pattern2, "Mode");
                ETERM * Nlink = erl_var_content(pattern2, "Nlink");
		ETERM * Size = erl_var_content(pattern2, "Size");
                if(ERL_IS_INTEGER(Nlink) && ERL_IS_INTEGER(Mode) && ERL_IS_INTEGER(Size)){

			stbuf->st_mode = S_IFREG | ERL_INT_VALUE(Mode); //permissions
			stbuf->st_nlink = ERL_INT_VALUE(Nlink); //files only have 1
			stbuf->st_size = ERL_INT_VALUE(Size); // length of the file
                }else{
                        res = -ENOENT;
                }
	}else{
		res = -ENOENT;
	}	

	return res;
}
开发者ID:DBarney,项目名称:efs,代码行数:35,代码来源:hello.c


示例3: main

int main() {
  ETERM *tuplep, *intp;
  ETERM *fnp, *argp;
  int res;
  byte buf[100];
  long allocated, freed;

  erl_init(NULL, 0);

  while (read_cmd(buf) > 0) {
    tuplep = erl_decode(buf);
    fnp    = erl_element(1, tuplep);
    argp   = erl_element(2, tuplep);
    
    if (strncmp(ERL_ATOM_PTR(fnp), "foo", 3) == 0) {
      res = foo(ERL_INT_VALUE(argp));
    } else if (strncmp(ERL_ATOM_PTR(fnp), "bar", 17) == 0) {
      res = bar(ERL_INT_VALUE(argp));
    }

    intp = erl_mk_int(res);
    erl_encode(intp, buf);
    write_cmd(buf, erl_term_len(intp));

    erl_free_compound(tuplep);
    erl_free_term(fnp);
    erl_free_term(argp);
    erl_free_term(intp);
  }
}
开发者ID:dmichael,项目名称:signalers,代码行数:30,代码来源:ei.c


示例4: is_printable_list

static int is_printable_list(const ETERM* term)
{
    while (ERL_TYPE(term) == ERL_LIST) {
	ETERM* head = HEAD(term);

	if (!ERL_IS_BYTE(head)) {
	    return 0;
	}
	if (ERL_INT_VALUE(head) < ' ') {
	    switch (ERL_INT_VALUE(head)) {
	    case '\n':
	    case '\r':
	    case '\t':
	    case '\v':
	    case '\b':
	    case '\f':
		break;
	    default:
		return 0;
	    }
	}
	term = TAIL(term);
    }

    return ERL_IS_EMPTY_LIST(term);
}
开发者ID:billysvensson,项目名称:otp,代码行数:26,代码来源:erl_eterm.c


示例5: new_image_blank

ETERM * new_image_blank(ETERM *arg, int c_node) { 
    int stride, cbufsize, status, key_length;
    ETERM *width, *height;
    cairo_context *ctx = NULL;             
    width = erl_element(1, arg);
    height = erl_element(2, arg);
    stride = ERL_INT_VALUE(width) * 4;
    cbufsize = ERL_INT_VALUE(height) * stride;
    ctx = malloc(sizeof(cairo_context));
    if (ctx) {
        ctx->cbuf = (byte *)malloc(cbufsize);
        if (ctx->cbuf) {
            memset(ctx->cbuf, 0, cbufsize);
            ctx->sf = cairo_image_surface_create_for_data(ctx->cbuf, 
                    CAIRO_FORMAT_ARGB32, ERL_INT_VALUE(width), 
                    ERL_INT_VALUE(height), stride);
            ctx->cr = cairo_create(ctx->sf);
            return erl_format("{c_node, ~i, {ok, ~i}}", c_node, ctx);
        } else {
            free(ctx);
            return erl_format("{c_node, ~i, {error, '~s'}}", c_node, ERR_CONTEXT);
        }
    } else {
        return erl_format("{c_node, ~i, {error, '~s'}}", c_node, ERR_CONTEXT);
    }
    erl_free_term(width);
    erl_free_term(height);
}
开发者ID:chinnurtb,项目名称:erlycairo,代码行数:28,代码来源:erlycairo.c


示例6: main

int main(int argc, char **argv) {
  int fd;                                  /* fd to Erlang node */
  
  int loop = 1;                            /* Loop flag */
  int got;                                 /* Result of receive */
  unsigned char buf[BUFSIZE];              /* Buffer for incoming message */
  ErlMessage emsg;                         /* Incoming message */
  
  ETERM *fromp, *tuplep, *fnp, *argp, *resp;
  int res;
  
  erl_init(NULL, 0);

  if (erl_connect_init(1, "secretcookie", 0) == -1)
    erl_err_quit("erl_connect_init");
  
  if ((fd = erl_connect("[email protected]")) < 0)
    erl_err_quit("erl_connect");
  fprintf(stderr, "Connected to [email protected]\n\r");
  
  while (loop) {

    got = erl_receive_msg(fd, buf, BUFSIZE, &emsg);
    if (got == ERL_TICK) {
      /* ignore */
    } else if (got == ERL_ERROR) {
      loop = 0;
    } else {
      
      if (emsg.type == ERL_REG_SEND) {
	fromp = erl_element(1, emsg.msg);
	tuplep = erl_element(2, emsg.msg);
	fnp = erl_element(1, tuplep);
	argp = erl_element(2, tuplep);
        
	if (strncmp(ERL_ATOM_PTR(fnp), "foo", 3) == 0) {
	  res = foo(ERL_INT_VALUE(argp));
	} else if (strncmp(ERL_ATOM_PTR(fnp), "bar", 3) == 0) {
	  res = bar(ERL_INT_VALUE(argp));
	}
        
	resp = erl_format("{cnode, ~i}", res);
	erl_send(fd, fromp, resp);
        
	erl_free_term(emsg.from); erl_free_term(emsg.msg);
	erl_free_term(fromp); erl_free_term(tuplep);
	erl_free_term(fnp); erl_free_term(argp);
	erl_free_term(resp);
      }
    }
  }
}
开发者ID:serhiimelnik,项目名称:LearnErlang,代码行数:52,代码来源:cnode_c.c


示例7: line_to

ETERM * line_to(ETERM* arg, int c_node) {
    ETERM *x, *y;
    cairo_context *ctx = get_cairo_context(arg);
    if (ctx) {
        x = erl_element(2, arg);  
        y = erl_element(3, arg); 
        cairo_line_to(ctx->cr, ERL_INT_VALUE(x), ERL_INT_VALUE(y));
        erl_free_term(x);
        erl_free_term(y);
        return erl_format("{c_node, ~i, ok}", c_node);
    } else { 
        return erl_format("{c_node, ~i, {error, '~s'}}", c_node, ERR_CONTEXT);
    }
}
开发者ID:chinnurtb,项目名称:erlycairo,代码行数:14,代码来源:erlycairo.c


示例8: set_queue_len

response_t set_queue_len(int len, ETERM *tuplep, q_data_t **q_data, thread_data_t *data) {

    int q_num, cq_idx;
    ETERM *arg;
    response_t r;

    if(erl_size(tuplep) > 2) {

        arg = erl_element(3, tuplep);
        q_num = ERL_INT_VALUE(arg);
        erl_free_term(arg);

        syslog(LOG_NOTICE,"[%d] q_num: %d, len: %d\n\r", data->idx, q_num, len);

        if((cq_idx = get_queue_idx(q_num, q_data)) >= 0) {

            if(nfq_set_queue_maxlen(q_data[cq_idx]->qh, len) >= 0) {
                r.cs = erl_mk_atom("ok");
                r.rsp = erl_mk_atom("ok");
            } else {
                r.cs = erl_mk_atom("error");
                r.rsp = erl_mk_estring("failed to set queue max length", strlen("failed to set queue max length"));
            }

        } else {
            r.cs = erl_mk_atom("error");
            r.rsp = erl_mk_estring("no such queue", strlen("no such queue"));
        }

    } else {
        r.cs = erl_mk_atom("error");
        r.rsp = erl_mk_estring("argument missing", strlen("argument missing"));
    }
    return r;
}
开发者ID:apofiget,项目名称:nfq_listener,代码行数:35,代码来源:nfq_node.c


示例9: get_atts_types

att_type* get_atts_types(ETERM* term)
{
	lst point;
	int len = erl_length(term), i;
	att_type* res = (att_type*) malloc(len * sizeof(att_type));
	att_type tmp;
	next(term, &point);
	
	for (i=0; i<len; i++) 
	{
		switch (ERL_INT_VALUE(point.head)) 
		{
			case 0:
				tmp = nominal;
				break;

			case 1:
				tmp = continuous;
				break;
		}
		res[i] = tmp;
		next(term, &point);
	}

	return res;
}
开发者ID:tjacek,项目名称:ML2,代码行数:26,代码来源:mllib.cpp


示例10: port_gpio_write

/**
* @brief Port interface for gpio_write
*/
int
port_gpio_write (int pin, ETERM *valuet)
{
   int value;
   value = ERL_INT_VALUE(valuet);
   return gpio_write(pin, value);
}
开发者ID:Novakov,项目名称:erlang_ale,代码行数:10,代码来源:gpio_port.c


示例11: curve_to

ETERM * curve_to(ETERM* arg, int c_node) {
    ETERM *c1x, *c1y, *c2x, *c2y, *x, *y;
    cairo_context *ctx = get_cairo_context(arg);
    if (ctx) {
        c1x = erl_element(2, arg);  
        c1y = erl_element(3, arg); 
        c2x = erl_element(4, arg);  
        c2y = erl_element(5, arg);
        x = erl_element(6, arg);  
        y = erl_element(7, arg);
        cairo_curve_to(ctx->cr, ERL_INT_VALUE(c1x), 
            val(c1y),
            val(c2x),
            val(c2y),
            val(x),
            val(y));
        erl_free_term(c1x);
        erl_free_term(c1y);
        erl_free_term(c2x);
        erl_free_term(c2y);
        erl_free_term(x);
        erl_free_term(y);
        return erl_format("{c_node, ~i, ok}", c_node);
    } else { 
        return erl_format("{c_node, ~i, {error, '~s'}}", c_node, ERR_CONTEXT);
    }
}
开发者ID:chinnurtb,项目名称:erlycairo,代码行数:27,代码来源:erlycairo.c


示例12: process_command

static int process_command(byte *buf)
{
  int retval = 0;
  ETERM *pattern, *tuple, *cmd, *port, *data;
  pattern = erl_format("{Cmd, Port, Data}");
  tuple = erl_decode(buf);
  if (erl_match(pattern, tuple))
    {
      cmd = erl_var_content(pattern, "Cmd");
      port = erl_var_content(pattern, "Port");
      data = erl_var_content(pattern, "Data");
      switch (ERL_INT_VALUE(cmd))
	{
	case CMD_AUTH:
	  retval = process_auth(port, data);
	  break;
	case CMD_ACCT:
	  retval = process_acct(port, data);
	  break;
	};
      erl_free_term(cmd);
      erl_free_term(port);
      erl_free_term(data);
    }
  erl_free_term(pattern);
  erl_free_term(tuple);
  return retval;
}
开发者ID:0879dc,项目名称:ejabberd,代码行数:28,代码来源:epam.c


示例13: iolist_to_buf

static void iolist_to_buf(const ETERM* term, char** bufp)
{
    char* dest = *bufp;

    while (ERL_IS_CONS(term)) {
	ETERM* obj = HEAD(term);

	if (ERL_IS_BYTE(obj)) {
	    *dest++ = ERL_INT_VALUE(obj);
	} else if (ERL_IS_CONS(obj)) {
	    iolist_to_buf(obj, &dest);
	} else if (ERL_IS_BINARY(obj)) {
	    memcpy(dest, ERL_BIN_PTR(obj), ERL_BIN_SIZE(obj));
	    dest += ERL_BIN_SIZE(obj);
	} else {
	    /*
	     * Types have been checked by caller.
	     */
	  if (!ERL_IS_EMPTY_LIST(obj)) return;
	  /* ASSERT(ERL_IS_EMPTY_LIST(obj)); */
	}
	term = TAIL(term);
    }
    if (ERL_IS_BINARY(term)) {
	memcpy(dest, ERL_BIN_PTR(term), ERL_BIN_SIZE(term));
	dest += ERL_BIN_SIZE(term);
    } else {
	/*
	 * Types have been checked by caller.
	 */
      if (!ERL_IS_EMPTY_LIST(term)) return;
      /* ASSERT(ERL_IS_EMPTY_LIST(term));*/
    }
    *bufp = dest;
}
开发者ID:billysvensson,项目名称:otp,代码行数:35,代码来源:erl_eterm.c


示例14: erl_mk_empty_list

ETERM *erl_mk_estring(const char *s, int len)
{
    ETERM *ep;
    int i;

    if ((!s) || (len < 0)) return NULL;

    /*
     * ASSERT(s != NULL);
     * ASSERT(len >= 0);
     */

    ep = erl_mk_empty_list();
    for (i = len-1; i >= 0; i--) {
	ETERM* integer;
	ETERM* cons;

	integer = erl_alloc_eterm(ERL_INTEGER);
	ERL_COUNT(integer) = 1;
	ERL_INT_VALUE(integer) = (unsigned char)s[i];

	cons = erl_alloc_eterm(ERL_LIST);
	ERL_COUNT(cons) = 1;
	HEAD(cons) = integer;
	TAIL(cons) = ep;
	ep = cons;
    }
    return ep;
}
开发者ID:billysvensson,项目名称:otp,代码行数:29,代码来源:erl_eterm.c


示例15: print_string

static int print_string(FILE* fp, const ETERM* ep)
{
    int ch_written = 0; /* counter of written chars */
  
    putc('"', fp);
    ch_written++;
    while (ERL_IS_CONS(ep)) {
	int c = ERL_INT_VALUE(HEAD(ep));

	if (c >= ' ') {
	    putc(c, fp);
	    ch_written++;
	}
	else {
	    switch (c) {
	    case '\n': fputs("\\n", fp); ch_written += 2; break;
	    case '\r': fputs("\\r", fp); ch_written += 2; break;
	    case '\t': fputs("\\t", fp); ch_written += 2; break;
	    case '\v': fputs("\\v", fp); ch_written += 2; break;
	    case '\b': fputs("\\b", fp); ch_written += 2; break;
	    case '\f': fputs("\\f", fp); ch_written += 2; break;
		break;
	    default:
		ch_written += fprintf(fp, "\\%o", c);
		break;
	    }
	}
	ep = TAIL(ep);
    }
    putc('"', fp);
    ch_written++;
    return ch_written;
}
开发者ID:billysvensson,项目名称:otp,代码行数:33,代码来源:erl_eterm.c


示例16: process_command

static int
process_command(unsigned char *buf)
{
  int retval = 0;
  ETERM *pattern, *tuple, *cmd, *port, *data;
  pattern = erl_format("{Cmd, Port, Data}");
  tuple = erl_decode(buf);
  if (erl_match(pattern, tuple)) {
    cmd = erl_var_content(pattern, "Cmd");
    port = erl_var_content(pattern, "Port");
    data = erl_var_content(pattern, "Data");
    switch (ERL_INT_VALUE(cmd)) {
    case CMD_SALT:
      retval = process_encode_salt(port, data);
      break;
    case CMD_HASHPW:
      retval = process_hashpw(port, data);
      break;
    };
    erl_free_term(cmd);
    erl_free_term(port);
    erl_free_term(data);
  }
  erl_free_term(pattern);
  erl_free_term(tuple);
  return retval;
}
开发者ID:chinnurtb,项目名称:erlang-bcrypt-wo_autotools,代码行数:27,代码来源:bcrypt_erlang.c


示例17: erlix_uint_to_fix

static VALUE erlix_uint_to_fix(VALUE self){
    ErlixTerm *euint;
    unsigned int l;
    Data_Get_Struct(self,ErlixTerm,euint);
    l=ERL_INT_VALUE(euint->term);
    return INT2FIX(l);
}
开发者ID:KDr2,项目名称:erlix,代码行数:7,代码来源:erlix_uint.c


示例18: erl_alloc_eterm

/*
 * Create an INTEGER. Depending on its value it 
 * may end up as a BigNum.
 */
ETERM *erl_mk_int (int i)
{
    ETERM *ep;

    ep = erl_alloc_eterm(ERL_INTEGER);
    ERL_COUNT(ep) = 1;
    ERL_INT_VALUE(ep) = i;
    return ep;
}
开发者ID:billysvensson,项目名称:otp,代码行数:13,代码来源:erl_eterm.c


示例19: val

double val(ETERM *arg) {
    if (ERL_IS_INTEGER(arg))
        return ERL_INT_VALUE(arg);
    else if (ERL_IS_FLOAT(arg))
        return ERL_FLOAT_VALUE(arg);
    else {
        exit(EXIT_FAILURE);
        return 0;
    }
}
开发者ID:chinnurtb,项目名称:erlycairo,代码行数:10,代码来源:erlycairo.c


示例20: set_line_width

ETERM * set_line_width(ETERM* arg, int c_node) {
    ETERM *width;
    cairo_context *ctx = get_cairo_context(arg);
    if (ctx) {
        width = erl_element(2, arg);   
        cairo_set_line_width(ctx->cr, ERL_INT_VALUE(width));
        erl_free_term(width);
        return erl_format("{c_node, ~i, ok}", c_node);
    } else { 
        return erl_format("{c_node, ~i, {error, '~s'}}", c_node, ERR_CONTEXT);
    }
}
开发者ID:chinnurtb,项目名称:erlycairo,代码行数:12,代码来源:erlycairo.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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