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


C++ driver_mk_atom函数代码示例

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


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

示例1: output

static void output(ErlDrvData drv_data,
		   char *buf, ErlDrvSizeT len)
{
    Otp9302Data *data = (Otp9302Data *) drv_data;
    ErlDrvTermData td_port = driver_mk_port(data->port);
    ErlDrvTermData td_receiver = driver_caller(data->port);
    ErlDrvTermData td_job = driver_mk_atom("job");
    unsigned int key = (unsigned int) (ErlDrvSInt) data->port;
    long id[5];
    Otp9302AsyncData *ad[5];
    int i;

    for (i = 0; i < sizeof(ad)/sizeof(ad[0]); i++) {
	ad[i] = driver_alloc(sizeof(Otp9302AsyncData));
	if (!ad[i])
	    abort();

	ad[i]->smp = data->smp;
	ad[i]->port = data->port;
	ad[i]->block = 0;
	ad[i]->refc = 1;
	ad[i]->term_data.port = td_port;
	ad[i]->term_data.receiver = td_receiver;
	ad[i]->term_data.msg = td_job;
	ad[i]->msgq = &data->msgq;
    }
    ad[0]->block = 1;
    ad[0]->term_data.msg = driver_mk_atom("block");
    ad[2]->term_data.msg = driver_mk_atom("cancel");
    ad[4]->term_data.msg = driver_mk_atom("end_of_jobs");
    for (i = 0; i < sizeof(id)/sizeof(id[0]); i++)
	id[i] = driver_async(data->port, &key, async_invoke, ad[i], driver_free);
    if (id[2] > 0)
	driver_async_cancel(id[2]);
}
开发者ID:caox,项目名称:otp,代码行数:35,代码来源:otp_9302_drv.c

示例2: process

static void process(ErlDrvData handle, ErlIOVec *ev) {
    baberl_drv_t* driver_data = (baberl_drv_t*) handle;
    ErlDrvBinary* args = ev->binv[1];
    char *data = args->orig_bytes;
    char *from_encoding, *to_encoding, *text;
    converted_text_t cv;

    from_encoding = read_string(&data);
    to_encoding = read_string(&data);
    text = read_string(&data);

    cv.error = 0;
    convert_text(from_encoding, to_encoding, text, strlen(text), &cv);

    if (cv.error == 0) {
        ErlDrvTermData spec[] = {ERL_DRV_ATOM, driver_mk_atom("ok"),
                                 ERL_DRV_BUF2BINARY, cv.text, cv.text_size,
                                 ERL_DRV_TUPLE, 2
                                };
        driver_output_term(driver_data->port, spec, sizeof(spec) / sizeof(spec[0]));
    }
    else {
        ErlDrvTermData spec[] = {ERL_DRV_ATOM, driver_mk_atom("error"),
                                 ERL_DRV_ATOM, driver_mk_atom("iconv_coding"),
                                 ERL_DRV_TUPLE, 2
                                };
        driver_output_term(driver_data->port, spec, sizeof(spec) / sizeof(spec[0]));
    }

    driver_free(from_encoding);
    driver_free(to_encoding);
    driver_free(text);
    driver_free(cv.text);
}
开发者ID:kevsmith,项目名称:baberl,代码行数:34,代码来源:baberl_drv.c

示例3: fill_passwd

static void
fill_passwd (ErlDrvTermData *data, struct passwd *pwd,
             char **name,
             char **passwd)
{
  char *pw_name = pwd->pw_name;
  char *pw_passwd = pwd->pw_passwd;

  size_t len_name = strlen (pw_name);
  size_t len_passwd = strlen (pw_passwd);

  if (name)
    {
      *name = (char *) driver_alloc (sizeof (char) * (len_name + 1));
      memcpy (*name, pw_name, sizeof (char) * (len_name + 1));

      pw_name = *name;
    }

  if (passwd)
    {
      *passwd = (char *) driver_alloc (sizeof (char *) * (len_passwd + 1));
      memcpy (*passwd, pw_passwd, sizeof (char) * (len_passwd + 1));

      pw_passwd = *passwd;
    }

  *data++ = ERL_DRV_ATOM;
  *data++ = driver_mk_atom ("pw_name");
  *data++ = ERL_DRV_STRING;
  *data++ = (ErlDrvTermData) pw_name;
  *data++ = strlen (pwd->pw_name);
  *data++ = ERL_DRV_TUPLE;
  *data++ = 2;

  *data++ = ERL_DRV_ATOM;
  *data++ = driver_mk_atom ("pw_passwd");
  *data++ = ERL_DRV_STRING;
  *data++ = (ErlDrvTermData) pw_passwd;
  *data++ = strlen (pwd->pw_name);
  *data++ = ERL_DRV_TUPLE;
  *data++ = 2;

  *data++ = ERL_DRV_ATOM;
  *data++ = driver_mk_atom ("pw_uid");
  *data++ = ERL_DRV_UINT;
  *data++ = pwd->pw_uid;
  *data++ = ERL_DRV_TUPLE;
  *data++ = 2;

  *data++ = ERL_DRV_ATOM;
  *data++ = driver_mk_atom ("pw_gid");
  *data++ = ERL_DRV_UINT;
  *data++ = pwd->pw_gid;
  *data++ = ERL_DRV_TUPLE;
  *data++ = 2;
  
  *data++ = ERL_DRV_TUPLE;
  *data++ = 4;
}
开发者ID:chinnurtb,项目名称:erlang-pwd,代码行数:60,代码来源:pwd_drv.c

示例4: dthread_lib_init

void dthread_lib_init()
{
    dterm_lib_init();
    am_data = driver_mk_atom("data");
    am_ok = driver_mk_atom("ok");
    am_error = driver_mk_atom("error");
}
开发者ID:relabsoss,项目名称:uart,代码行数:7,代码来源:dthread.c

示例5: unkown

// Unkown Command
static void unkown(bdb_drv_t *bdb_drv, ErlIOVec *ev) {
  // Return {error, unkown_command}
  ErlDrvTermData spec[] = {ERL_DRV_ATOM, driver_mk_atom("error"),
			   ERL_DRV_ATOM, driver_mk_atom("uknown_command"),
			   ERL_DRV_TUPLE, 2};
  driver_output_term(bdb_drv->port, spec, sizeof(spec) / sizeof(spec[0]));
}
开发者ID:mattwilliamson,项目名称:erl_bdb,代码行数:8,代码来源:bdb_drv.c

示例6: send_geometry

void send_geometry(GEOSCommand *command, GEOSGeometry *geom) {
	//GEOSContextHandle_t context = command->driver_data->handle;
	//int type = GEOSGeomTypeId_r(context, geom);

	if(geom == NULL) {

		ErlDrvTermData spec[] = {ERL_DRV_ATOM, driver_mk_atom("ok"),
			   ERL_DRV_ATOM, driver_mk_atom("ggeom"),
			   ERL_DRV_ATOM, driver_mk_atom("empty"),
			   ERL_DRV_TUPLE, 2,
			   ERL_DRV_TUPLE, 2};

		driver_output_term(command->driver_data->port, spec, sizeof(spec) / sizeof(spec[0]));

		return;
	}
	ErlDrvTermData spec[] = {ERL_DRV_ATOM, driver_mk_atom("ok"),
			   ERL_DRV_ATOM, driver_mk_atom("ggeom"),
			 //  ERL_DRV_INT, (ErlDrvTermData) type,
			   ERL_DRV_INT, (ErlDrvTermData) geom,
			   ERL_DRV_TUPLE, 2,
			   ERL_DRV_TUPLE, 2};

  	driver_output_term(command->driver_data->port, spec, sizeof(spec) / sizeof(spec[0]));
}
开发者ID:alepharchives,项目名称:erlgeo,代码行数:25,代码来源:erl_geos_util.c

示例7: erl_luam_maybe_atom

void
erl_luam_maybe_atom(lua_drv_t *driver_data, char *buf, int index)
{
  long i;
  int is_atom;
  char *atom;
  ei_decode_long(buf, &index, &i);

  lua_getglobal(driver_data->L, "erlang");
  lua_getfield(driver_data->L, -1, "t_atom");
  lua_getmetatable(driver_data->L, -3);
  is_atom = lua_rawequal(driver_data->L, -1, -2);
  lua_pop(driver_data->L, 3);

  if (is_atom) {
      atom = (char*)lua_touserdata(driver_data->L, i);
      ErlDrvTermData spec[] = {
          ERL_DRV_ATOM, ATOM_OK,
            ERL_DRV_ATOM, ATOM_OK,
            ERL_DRV_ATOM, driver_mk_atom(atom),
            ERL_DRV_TUPLE,  2,
          ERL_DRV_TUPLE, 2
      };
      erl_drv_output_term(driver_data->drvport, spec, sizeof(spec) / sizeof(spec[0]));
  } else {
      ErlDrvTermData spec[] = {
          ERL_DRV_ATOM, ATOM_OK,
          ERL_DRV_ATOM, driver_mk_atom("false"),
          ERL_DRV_TUPLE, 2
      };
      erl_drv_output_term(driver_data->drvport, spec, sizeof(spec) / sizeof(spec[0]));
  }
}
开发者ID:cjimison,项目名称:erlualib,代码行数:33,代码来源:commands.c

示例8: emonk_start

static ErlDrvData
emonk_start(ErlDrvPort port, char *cmd)
{
    uint rt_max, gc_max, gc_last, ctx;
    emonk_drv_t* drv = NULL;
    ErlDrvData ret = ERL_DRV_ERROR_GENERAL;
    emonk_settings_t settings;
    
    if(parse_settings(cmd, &settings) < 0)
    {
        ret = ERL_DRV_ERROR_BADARG;
        goto error;
    }
    
    drv = (emonk_drv_t*) driver_alloc(sizeof(emonk_drv_t));
    if(drv == NULL) goto error;

    drv->port = port;
    drv->ok = driver_mk_atom("ok");
    drv->error = driver_mk_atom("error");
    drv->undefined = driver_mk_atom("undefined");
    drv->bad_cmd = driver_mk_atom("bad_command");
    
    drv->vm = init_vm(&settings);
    if(drv->vm == NULL) goto error;
    
    return (ErlDrvData) drv;

error:
    if(drv != NULL) driver_free(drv);
    return ret;
}
开发者ID:kocolosk,项目名称:emonk,代码行数:32,代码来源:emonk_drv.c

示例9: gl_dispatch

void gl_dispatch(int op, char *bp,ErlDrvTermData caller,WXEBinRef *bins[]){
  if(caller != gl_active) {
    wxGLCanvas * current = glc[caller];
    if(current) { gl_active = caller; current->SetCurrent();}
    else {
      ErlDrvTermData rt[] = // Error msg
	{ERL_DRV_ATOM, driver_mk_atom((char *) "_egl_error_"),
	 ERL_DRV_INT,  op,
	 ERL_DRV_ATOM, driver_mk_atom((char *) "no_gl_context"),
	 ERL_DRV_TUPLE,3};
      driver_send_term(WXE_DRV_PORT,caller,rt,8);
      return ;
    }
  };
  char * bs[3];
  int bs_sz[3];
  for(int i=0; i<3; i++) {
    if(bins[i]) {
      bs[i] = bins[i]->base;
      bs_sz[i] = bins[i]->size;
    }
    else 
      bs[i] = NULL;
  }
  wxe_gl_dispatch(op, bp, WXE_DRV_PORT, caller, bs, bs_sz);
}
开发者ID:Andy-Richards,项目名称:otp,代码行数:26,代码来源:wxe_gl.cpp

示例10: testcase_printf

void
testcase_printf(TestCaseState_t *tcs, char *frmt, ...)
{
    InternalTestCaseState_t *itcs = (InternalTestCaseState_t *) tcs;
    ErlDrvTermData msg[12];
    va_list va;
    va_start(va, frmt);
#if HAVE_VSNPRINTF
    vsnprintf(itcs->comment_buf, COMMENT_BUF_SZ, frmt, va);
#else
    vsprintf(itcs->comment_buf, frmt, va);
#endif
    va_end(va);

    msg[0] = ERL_DRV_ATOM;
    msg[1] = (ErlDrvTermData) driver_mk_atom("print");

    msg[2] = ERL_DRV_PORT;
    msg[3] = itcs->port_id;

    msg[4] = ERL_DRV_ATOM;
    msg[5] = driver_mk_atom(itcs->visible.testcase_name);

    msg[6] = ERL_DRV_STRING;
    msg[7] = (ErlDrvTermData) itcs->comment_buf;
    msg[8] = (ErlDrvTermData) strlen(itcs->comment_buf);

    msg[9] = ERL_DRV_TUPLE;
    msg[10] = (ErlDrvTermData) 4;

    erl_drv_output_term(itcs->port_id, msg, 11);
}
开发者ID:NaughtyCode,项目名称:otp,代码行数:32,代码来源:testcase_driver.c

示例11: erl_send_error

void erl_send_error(GEOSCommand *command, char *atom) {
	
	ErlDrvTermData spec[] = {ERL_DRV_ATOM, driver_mk_atom("error"),
                           ERL_DRV_ATOM, driver_mk_atom(atom),
                           ERL_DRV_TUPLE, 2}; 
	driver_output_term(command->driver_data->port, spec, sizeof(spec) / sizeof(spec[0]));

}
开发者ID:alepharchives,项目名称:erlgeo,代码行数:8,代码来源:erl_geos_util.c

示例12: del

// Delete a record from the database
static void del(bdb_drv_t *bdb_drv, ErlIOVec *ev) {
  ErlDrvBinary* data = ev->binv[1];
  char *bytes = data->orig_bytes;
  char *key_bytes = bytes+1;
  
  DB *db = bdb_drv->db;
  DBT key;
  int status;
  
  bzero(&key, sizeof(DBT));
    
  key.data = key_bytes;
  key.size = KEY_SIZE;
  
  status = db->del(db, NULL, &key, 0);
  db->sync(db, 0);
  
  if(status == 0) {
  	// Delete went OK, return atom 'ok'
    ErlDrvTermData spec[] = {ERL_DRV_ATOM, driver_mk_atom("ok")};
    
    driver_output_term(bdb_drv->port, spec, sizeof(spec) / sizeof(spec[0]));
    
  } else {
  	// There was an error
    char *error_reason;

    switch(status) {
    case DB_NOTFOUND:
      error_reason = "not_found";
      break;
    case DB_LOCK_DEADLOCK:
      error_reason = "deadlock";
      break;
    case DB_SECONDARY_BAD:
      error_reason = "bad_secondary_index";
      break;
    case EINVAL:
      error_reason = "bad_flag";
      break;
    case EACCES:
      error_reason = "readonly";
      break;
    case DB_RUNRECOVERY:
      error_reason = "run_recovery";
      break;
    default:
      error_reason = "unknown";
    }
    
    // Return tuple {error, Reason}
    ErlDrvTermData spec[] = {ERL_DRV_ATOM, driver_mk_atom("error"),
			     ERL_DRV_ATOM, driver_mk_atom(error_reason),
			     ERL_DRV_TUPLE, 2};

    driver_output_term(bdb_drv->port, spec, sizeof(spec) / sizeof(spec[0]));
  }
}
开发者ID:mattwilliamson,项目名称:erl_bdb,代码行数:59,代码来源:bdb_drv.c

示例13: start

static ErlDrvData start(ErlDrvPort port, char *cmd) {
  spidermonkey_drv_t *retval = (spidermonkey_drv_t*) driver_alloc(sizeof(spidermonkey_drv_t));
  retval->port = port;
  retval->shutdown = 0;
  retval->atom_ok = driver_mk_atom((char *) "ok");
  retval->atom_error = driver_mk_atom((char *) "error");
  retval->atom_unknown_cmd = driver_mk_atom((char *) "unknown_command");
  return (ErlDrvData) retval;
}
开发者ID:jonte,项目名称:erlang_js,代码行数:9,代码来源:spidermonkey_drv.c

示例14: send_txn_tstat

static void send_txn_tstat(ErlDrvPort port, ErlDrvTermData pid, DB_TXN_ACTIVE *tasp)
{
    char *name = tasp->name ? tasp->name : "<null>";
    int name_len = strlen(name);
    char tid_str[32];
    char *status_str;
    switch (tasp->status)
    {
        case TXN_ABORTED:
            status_str = "aborted";
            break;
        case TXN_COMMITTED:
            status_str = "committed";
            break;
        case TXN_PREPARED:
            status_str = "prepared";
            break;
        case TXN_RUNNING:
            status_str = "running";
            break;
        default:
            status_str = "undefined";
            break;
    }

    int tid_str_len = snprintf(tid_str, sizeof(tid_str), "%lu", (unsigned long) tasp->tid);

    ErlDrvTermData response[] = {
        ERL_DRV_ATOM, driver_mk_atom("txn"),
        STATS_TUPLE(tasp, txnid),               /* Transaction ID */
        STATS_TUPLE(tasp, parentid),            /* Transaction ID of parent */
        STATS_TUPLE(tasp, pid),                 /* Process owning txn ID - pid_t */
            ERL_DRV_ATOM, driver_mk_atom("tid"),/* OSX has 32-bit ints in erlang, so return as */
            ERL_DRV_STRING, (ErlDrvTermData) tid_str, tid_str_len, /* a string */
        ERL_DRV_TUPLE, 2,
        STATS_LSN_TUPLE(tasp, lsn),             /* LSN when transaction began */
        STATS_LSN_TUPLE(tasp, read_lsn),        /* Read LSN for MVCC */
        STATS_TUPLE(tasp, mvcc_ref),            /* MVCC reference count */

        // Start of list
            ERL_DRV_ATOM, driver_mk_atom("status"),
            ERL_DRV_ATOM, driver_mk_atom(status_str),
        ERL_DRV_TUPLE, 2,

            ERL_DRV_ATOM, driver_mk_atom("name"),
            ERL_DRV_STRING, (ErlDrvTermData) name, name_len,
        ERL_DRV_TUPLE, 2,


        // End of list
        ERL_DRV_NIL,
        ERL_DRV_LIST, 9+1,
        ERL_DRV_TUPLE, 2
    };
    driver_send_term(port, pid, response, sizeof(response) / sizeof(response[0]));
}
开发者ID:gburd,项目名称:bdberl,代码行数:56,代码来源:bdberl_stats.c

示例15: send_pointer

void send_pointer(GEOSCommand *command, char *name, void *pointer) {

  ErlDrvTermData spec[] = {ERL_DRV_ATOM, driver_mk_atom("ok"),
			   ERL_DRV_ATOM, driver_mk_atom(name),
                           ERL_DRV_INT, (ErlDrvTermData) pointer,
                           ERL_DRV_TUPLE, 2,
                           ERL_DRV_TUPLE, 2}; 

  driver_output_term(command->driver_data->port, spec, sizeof(spec) / sizeof(spec[0]));

}
开发者ID:alepharchives,项目名称:erlgeo,代码行数:11,代码来源:erl_geos_util.c


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