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


C++ enif_make_tuple3函数代码示例

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


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

示例1: utc_to_datetime

static ERL_NIF_TERM
utc_to_datetime(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) {
  if(argc != 1) {
    return enif_make_badarg(env);
  }
  unsigned int utc;
  if(!enif_get_uint(env, argv[0], &utc)) {
    return enif_make_badarg(env);
  }

  time_t now = utc;
  struct tm result;
  gmtime_r(&now, &result);
  return enif_make_tuple2(env,
    enif_make_tuple3(env,
      enif_make_int(env, result.tm_year + 1900),
      enif_make_int(env, result.tm_mon + 1),
      enif_make_int(env, result.tm_mday)
    ),
    enif_make_tuple3(env,
      enif_make_int(env, result.tm_hour),
      enif_make_int(env, result.tm_min),
      enif_make_int(env, result.tm_sec)
    )
  );
}
开发者ID:maxlapshin,项目名称:io_libc,代码行数:26,代码来源:io_libc.c

示例2: nif_scheduler_declineOffer

static ERL_NIF_TERM
nif_scheduler_declineOffer(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]){

    ErlNifBinary offerId_binary;
    ErlNifBinary filters_binary;

    state_ptr state = (state_ptr) enif_priv_data(env);
    
    if(state->initilised == 0 ) 
    {
        return enif_make_tuple2(env, 
            enif_make_atom(env, "state_error"), 
            enif_make_atom(env, "scheduler_not_inited"));
    }
    if (!enif_inspect_binary(env, argv[0], &offerId_binary)) 
    {
        return enif_make_tuple3(env, 
                    enif_make_atom(env, "argument_error"), 
                    enif_make_atom(env, "invalid_or_corrupted_parameter"),
                    enif_make_atom(env, "offer_id"));
    }
    if (!enif_inspect_binary(env, argv[1], &filters_binary)) 
    {
        return enif_make_tuple3(env, 
                    enif_make_atom(env, "argument_error"), 
                    enif_make_atom(env, "invalid_or_corrupted_parameter"),
                    enif_make_atom(env, "filters"));
    }

    SchedulerDriverStatus status = scheduler_declineOffer( state->scheduler_state, &offerId_binary, &filters_binary );

    return get_return_value_from_status(env, status);
}
开发者ID:nqn,项目名称:erlang-mesos,代码行数:33,代码来源:scheduler.c

示例3: send_blob_thread

static ERL_NIF_TERM send_blob_thread(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
    union { void* vp; struct make_term_info* p; }mti;
    ERL_NIF_TERM copy;
    if (!enif_get_resource(env, argv[0], msgenv_resource_type, &mti.vp)
	|| !enif_get_local_pid(env,argv[1], &mti.p->to_pid)) {
	return enif_make_badarg(env);
    }
    copy = enif_make_copy(env, mti.p->blob);

    mti.p->send_it = enif_is_identical(argv[2],atom_join);
    if (enif_thread_create("nif_SUITE:send_from_thread", &mti.p->tid,
			   threaded_sender, mti.p, NULL) != 0) {
	return enif_make_badarg(env);
    }
    if (enif_is_identical(argv[2],atom_join)) {
	int err = enif_thread_join(mti.p->tid, NULL);
	assert(err == 0);
	return enif_make_tuple3(env, atom_ok, enif_make_int(env, mti.p->send_res), copy);
    }
    else {
	enif_keep_resource(mti.vp);
	return enif_make_tuple2(env, atom_ok, copy);
    }
}
开发者ID:cristiangreco,项目名称:otp,代码行数:25,代码来源:nif_SUITE.c

示例4: nif_sendmsg

    static ERL_NIF_TERM
nif_sendmsg(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
{
    int s = -1;
    ErlNifBinary msg = {0};
    int flags = 0;

    ssize_t n = 0;

    if (!enif_get_int(env, argv[0], &s))
        return enif_make_badarg(env);

    if (!enif_inspect_binary(env, argv[1], &msg))
        return enif_make_badarg(env);

    if (!enif_get_int(env, argv[2], &flags))
        return enif_make_badarg(env);

    if (msg.size != sizeof(struct msghdr))
        return enif_make_badarg(env);

    /* Make the binary mutable */
    if (!enif_realloc_binary(&msg, msg.size))
        return error_tuple(env, ENOMEM);

    n = sendmsg(s, (const struct msghdr *)msg.data, flags);

    if (n < 0)
        return error_tuple(env, errno);

    return enif_make_tuple3(env,
            atom_ok,
            enif_make_ulong(env, n),
            enif_make_binary(env, &msg));
}
开发者ID:ExaServe,项目名称:procket,代码行数:35,代码来源:procket.c

示例5: update_callback

void
update_callback(void *arg, int sqlite_operation_type, char const *sqlite_database, char const *sqlite_table, sqlite3_int64 sqlite_rowid)
{
    esqlite_connection *db = (esqlite_connection *)arg;
    esqlite_command *cmd = NULL;
    ERL_NIF_TERM type, table, rowid;
    cmd = command_create();

    if(db == NULL)
        return;

    if(!cmd)
	    return;

    rowid = enif_make_int64(cmd->env, sqlite_rowid);
    table = enif_make_string(cmd->env, sqlite_table, ERL_NIF_LATIN1);

    switch(sqlite_operation_type) {
        case SQLITE_INSERT:
            type = make_atom(cmd->env, "insert");
            break;
        case SQLITE_DELETE:
            type = make_atom(cmd->env, "delete");
            break;
        case SQLITE_UPDATE:
            type = make_atom(cmd->env, "update");
            break;
        default:
            return;
    }
    cmd->type = cmd_notification;
    cmd->arg = enif_make_tuple3(cmd->env, type, table, rowid);
    push_command(cmd->env, db, cmd);
}
开发者ID:mmzeeman,项目名称:esqlite,代码行数:34,代码来源:esqlite3_nif.c

示例6: zdoor_cb

static struct zdoor_result *
zdoor_cb(struct zdoor_cookie *cookie, char *argp, size_t argp_sz)
{
	struct door *d;
	struct req *r;
	ErlNifEnv *env = enif_alloc_env();

	/* we kept the struct door in the biscuit */
	d = (struct door *)cookie->zdc_biscuit;

	/* this request */
	r = req_alloc();

	/* take the rlist lock first, then the req lock */
	enif_rwlock_rwlock(d->rlock);
	enif_mutex_lock(r->lock);

	req_insert(d, r);

	enif_rwlock_rwunlock(d->rlock);

	/* make the request into a binary term to put it into enif_send() */
	ErlNifBinary bin;
	enif_alloc_binary(argp_sz, &bin);
	memcpy(bin.data, argp, argp_sz);
	ERL_NIF_TERM binTerm = enif_make_binary(env, &bin);

	/* send a message back to the session owner */
	enif_send(NULL, &d->owner, env,
		enif_make_tuple3(env,
			enif_make_atom(env, "zdoor"),
			enif_make_resource(env, r),
			binTerm));

	/* now wait until the request has been replied to */
	enif_cond_wait(r->cond, r->lock);

	/* convert the reply into a zdoor_result */
	/* we have to use naked malloc() since libzdoor will use free() */
	struct zdoor_result *res = malloc(sizeof(struct zdoor_result));
	res->zdr_size = r->replen;
	res->zdr_data = r->rep;

	r->rep = NULL;
	r->replen = 0;

	/* yes, we have to unlock and re-lock to avoid lock inversion here */
	enif_mutex_unlock(r->lock);

	/* remove and free the struct req */
	enif_rwlock_rwlock(d->rlock);
	enif_mutex_lock(r->lock);
	req_remove(d, r);
	enif_rwlock_rwunlock(d->rlock);
	req_free(r);

	enif_free_env(env);

	return res;
}
开发者ID:arekinath,项目名称:erlzdoor,代码行数:60,代码来源:jobs.c

示例7: pwrite_nif_impl

static ERL_NIF_TERM pwrite_nif_impl(efile_data_t *d, ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]) {
    ErlNifIOVec vec, *input = &vec;
    Sint64 bytes_written, offset;
    ERL_NIF_TERM tail;

    if(argc != 2 || !enif_is_number(env, argv[0])
                 || !enif_inspect_iovec(env, 64, argv[1], &tail, &input)) {
        return enif_make_badarg(env);
    }

    if(!enif_get_int64(env, argv[0], &offset) || offset < 0) {
        return posix_error_to_tuple(env, EINVAL);
    }

    bytes_written = efile_pwritev(d, offset, input->iov, input->iovcnt);

    if(bytes_written < 0) {
        return posix_error_to_tuple(env, d->posix_errno);
    }

    if(!enif_is_empty_list(env, tail)) {
        ASSERT(bytes_written > 0);
        return enif_make_tuple3(env, am_continue,
            enif_make_int64(env, bytes_written), tail);
    }

    return am_ok;
}
开发者ID:cypherfox,项目名称:otp,代码行数:28,代码来源:prim_file_nif.c

示例8: ewpcap_error

void
ewpcap_error(EWPCAP_STATE *ep, char *msg)
{
    int rv = 0;

    if (ep->p == NULL)
        return;

    /* {ewpcap_error, Ref, Error} */
    rv = enif_send(
             NULL,
             &ep->pid,
             ep->env,
             enif_make_tuple3(ep->env,
                              atom_ewpcap_error,
                              enif_make_copy(ep->env, ep->ref),
                              enif_make_string(ep->env, msg, ERL_NIF_LATIN1)
                             )
         );

    if (!rv)
        pcap_breakloop(ep->p);

    enif_clear_env(ep->env);
}
开发者ID:hfeeki,项目名称:ewpcap,代码行数:25,代码来源:ewpcap.c

示例9: _reading_thread

static void*
_reading_thread (void* arg)
{
  CAN_handle* handle  = arg;
  ErlNifEnv*  env     = enif_alloc_env();
  //ERL_NIF_TERM device =   enif_make_int(env, handle->device);
  handle->threaded = 1;
  while (handle->threaded)
    {
      int status;
      ERL_NIF_TERM msg = _receive_can_messages(env, handle, handle->chunk_size, handle->timeout);
      if (!enif_get_int(env, msg, &status))
        {
          enif_send(env, &handle->receiver, env, enif_make_tuple3(env, can_atom, handle->devpath_bin, msg));
          enif_clear_env(env);
        }
      else if (status == 0)
        {
          enif_clear_env(env);
        }
      else break;
    }
  enif_free_env(env);
  return 0;
}
开发者ID:qoocku,项目名称:erleos,代码行数:25,代码来源:CAN_nif.c

示例10: macros

static ERL_NIF_TERM macros(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
    const ERL_NIF_TERM* a;
    ERL_NIF_TERM lists, tuples;
    int arity;
    if (!enif_get_tuple(env, argv[0], &arity, &a) || arity != 9) {
	return enif_make_badarg(env);
    }
    
    lists = enif_make_list(env,9,
			   enif_make_list1(env,a[0]),
			   enif_make_list2(env,a[0],a[1]),
			   enif_make_list3(env,a[0],a[1],a[2]),
			   enif_make_list4(env,a[0],a[1],a[2],a[3]),
			   enif_make_list5(env,a[0],a[1],a[2],a[3],a[4]),
			   enif_make_list6(env,a[0],a[1],a[2],a[3],a[4],a[5]),
			   enif_make_list7(env,a[0],a[1],a[2],a[3],a[4],a[5],a[6]),
			   enif_make_list8(env,a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7]),
			   enif_make_list9(env,a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8]));
    tuples = enif_make_list(env,9,
			    enif_make_tuple1(env,a[0]),
			    enif_make_tuple2(env,a[0],a[1]),
			    enif_make_tuple3(env,a[0],a[1],a[2]),
			    enif_make_tuple4(env,a[0],a[1],a[2],a[3]),
			    enif_make_tuple5(env,a[0],a[1],a[2],a[3],a[4]),
			    enif_make_tuple6(env,a[0],a[1],a[2],a[3],a[4],a[5]),
			    enif_make_tuple7(env,a[0],a[1],a[2],a[3],a[4],a[5],a[6]),
			    enif_make_tuple8(env,a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7]),
			    enif_make_tuple9(env,a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8]));
    return enif_make_tuple2(env,lists,tuples);
}
开发者ID:cristiangreco,项目名称:otp,代码行数:31,代码来源:nif_SUITE.c

示例11: update

//key, incr, ttl, timestamp
static ERL_NIF_TERM update(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) {

    int ttl=0, timestamp=0, incr=0, next=0;
    CHECK(enif_get_string(env, argv[0], keybuff, KEY_MAX_LEN, ERL_NIF_LATIN1));
    CHECK(enif_get_int(env, argv[1], &incr));
    CHECK(enif_get_int(env, argv[2], &ttl));
    CHECK(enif_get_int(env, argv[3], &timestamp));

    metronome_item * item = find_in_hash(keybuff, timestamp);
    item->ttl = ttl;

    if(item->timestamp + ttl > timestamp) {
        item->value += incr;
        next = item->timestamp + ttl - timestamp;
    } else {
        item->value = incr;
        item->timestamp = timestamp;
        next = ttl;
    }

    //
    return enif_make_tuple3(env,
                            enif_make_atom(env, "ok"),
                            enif_make_int(env, item->value),
                            enif_make_int(env, next)
                           );
}
开发者ID:flaboy,项目名称:metronome,代码行数:28,代码来源:metronome.c

示例12: nif_scheduler_reconcileTasks

static ERL_NIF_TERM
nif_scheduler_reconcileTasks(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
    unsigned int length ;

    state_ptr state = (state_ptr) enif_priv_data(env);
    
    if(state->initilised == 0 ) 
    {
        return enif_make_tuple2(env, 
            enif_make_atom(env, "state_error"), 
            enif_make_atom(env, "scheduler_not_inited"));
    }

    if(!enif_is_list(env, argv[0])) 
    {
        return enif_make_tuple3(env, 
                    enif_make_atom(env, "argument_error"), 
                    enif_make_atom(env, "invalid_or_corrupted_parameter"),
                    enif_make_atom(env, "task_status_array"));
    };

    if(!enif_get_list_length(env, argv[0], &length))
    {
        return enif_make_tuple3(env, 
                    enif_make_atom(env, "argument_error"), 
                    enif_make_atom(env, "invalid_or_corrupted_parameter"),
                    enif_make_atom(env, "task_status_array"));

    }
    
    ErlNifBinary binary_arr[length];
    if(!inspect_array_of_binary_objects(env, argv[0], &binary_arr ))
    {
        return enif_make_tuple3(env, 
                    enif_make_atom(env, "argument_error"), 
                    enif_make_atom(env, "invalid_or_corrupted_parameter"),
                    enif_make_atom(env, "task_status_array"));
    }   

    BinaryNifArray binaryNifArrayHolder ;
    binaryNifArrayHolder.length = length;
    binaryNifArrayHolder.obj = &binary_arr[0];

    SchedulerDriverStatus status =  scheduler_reconcileTasks( state->scheduler_state, &binaryNifArrayHolder);
    return get_return_value_from_status(env, status);
}
开发者ID:nqn,项目名称:erlang-mesos,代码行数:47,代码来源:scheduler.c

示例13: _load

static ERL_NIF_TERM _load(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]){
	UNUSED(argc);

	ErlNifBinary in,out;
	struct jpeg_decompress_struct cinfo;
	struct error_mgr jerr;
	unsigned int width, height;

	enif_inspect_binary(env,argv[0],&in);

	cinfo.err = jpeg_std_error(&jerr.pub);
	jerr.pub.error_exit = error_exit;
	if (setjmp(jerr.setjmp_buffer)) {
		jpeg_destroy_decompress(&cinfo);
		return -1;
	}

	jpeg_create_decompress(&cinfo);

	jpeg_mem_src(&cinfo, in.data, in.size);
	jpeg_read_header (&cinfo, TRUE);

	width = cinfo.image_width;
	height = cinfo.image_height;

	enif_alloc_binary(width*height*3,&out);

	cinfo.do_block_smoothing = TRUE;
	cinfo.do_fancy_upsampling = TRUE;
	cinfo.out_color_space = JCS_RGB;

	jpeg_start_decompress(&cinfo);

	JSAMPROW rowp[1];
	unsigned long location = 0;

	rowp[0] = (unsigned char*) malloc(cinfo.output_width*cinfo.num_components);

	unsigned int i = 0;
	while (cinfo.output_scanline < cinfo.output_height){
		jpeg_read_scanlines(&cinfo, rowp, 1);
		for( i=0; i<cinfo.image_width*cinfo.num_components;i++)
			out.data[location++] = rowp[0][i];
	}

	free(rowp[0]);

	jpeg_finish_decompress (&cinfo);
	jpeg_destroy_decompress (&cinfo);

	return	enif_make_tuple2(env,
				enif_make_atom(env,"ok"),
				enif_make_tuple3(env,
					enif_make_int(env,width),
					enif_make_int(env,height),
					enif_make_binary(env, &out)
				)
			);
}
开发者ID:DAOCUONG,项目名称:evercam-media,代码行数:59,代码来源:lib_elixir_motiondetection.c

示例14: make_term_tuple

static ERL_NIF_TERM make_term_tuple(struct make_term_info* mti, int n)
{
    ERL_NIF_TERM t[3];
    t[0] = pull_term(mti);
    t[1] = pull_term(mti);
    t[2] = pull_term(mti);
    return enif_make_tuple3(mti->dst_env, t[0], t[1], t[2]);	      
}
开发者ID:cristiangreco,项目名称:otp,代码行数:8,代码来源:nif_SUITE.c

示例15: geef_library_version

ERL_NIF_TERM geef_library_version(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
{
	int major, minor, rev;

	git_libgit2_version(&major, &minor, &rev);

	return enif_make_tuple3(env, enif_make_int(env, major), enif_make_int(env, minor), enif_make_int(env, rev));
}
开发者ID:CODECOMMUNITY,项目名称:geef,代码行数:8,代码来源:library.c


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