本文整理汇总了C++中ei_x_encode_atom函数的典型用法代码示例。如果您正苦于以下问题:C++ ei_x_encode_atom函数的具体用法?C++ ei_x_encode_atom怎么用?C++ ei_x_encode_atom使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ei_x_encode_atom函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: erlang_srdb1_insert_update
/**
* Insert a row into a specified table, update on duplicate key.
* \param _h structure representing database connection
* \param _k key names
* \param _v values of the keys
* \param _n number of key=value pairs
*/
int erlang_srdb1_insert_update(const db1_con_t* _h, const db_key_t* _k, const db_val_t* _v,
const int _n)
{
ei_x_buff argbuf;
int retcode;
if ((!_h) || (!_k) || (!_v) || (!_n)) {
LM_ERR("invalid parameter value\n");
return -1;
}
LM_DBG("erlang_srdb1_insert_update table %.*s\n",CON_TABLE(_h)->len, CON_TABLE(_h)->s);
ei_x_new(&argbuf);
//encode tuple {db_op, table, [cols], [keys], [vals]}
ei_x_encode_tuple_header(&argbuf, 5);
ei_x_encode_atom(&argbuf,"insert_update");
ei_x_encode_atom_len(&argbuf,CON_TABLE(_h)->s,CON_TABLE(_h)->len);
ei_x_encode_list_header(&argbuf, 0); //_c
// ei_x_encode_list_header(&argbuf, 0); //_k
srdb1_encode_k(_k, NULL, _v, _n, &argbuf); //_k
srdb1_encode_v(_k, _v, _n, &argbuf); //_v
retcode=erl_bind.do_erlang_call(&(CON_ERLANG(_h)->con),&(CON_ERLANG(_h)->regname), &argbuf, NULL /*&retbuf*/);
ei_x_free(&argbuf);
if (retcode<0) {
// if(retbuf.buff) shm_free(retbuf.buff);
return retcode;
}
return 0;
}
示例2: ei_x_encode_kstring
int ei_x_encode_kstring(ei_x_buff* types, ei_x_buff* values, K r, QOpts* opts) {
EI(ei_x_encode_atom(types, "string"));
if(r->n == 0) {
EI(ei_x_encode_empty_list(values));
} else {
EI(ei_x_encode_string_len(values, (const char*)kC(r), r->n));
}
return 0;
}
示例3: ei_x_encode_time
int ei_x_encode_time(ei_x_buff* types, ei_x_buff* values, K r, QOpts* opts) {
EI(ei_x_encode_atom(types, "time"));
int v = r->i;
if(opts->day_seconds_is_q_time) {
v = msec_to_sec(v);
}
EI(ei_x_encode_ki_val(values, v));
return 0;
}
示例4: error
static void
error() {
ei_x_buff result;
D("%s", "Error !");
check(ei_x_new_with_version(&result));
check(ei_x_encode_tuple_header(&result, 2));
check(ei_x_encode_atom(&result, "error"));
// if (recording)
assert(recording);
check(ei_x_encode_atom(&result, "already_started"));
//else
//check(ei_x_encode_atom(&result, "not_started"));
write_cmd(&result);
ei_x_free(&result);
}
示例5: ok
static void
ok() {
ei_x_buff result;
check(ei_x_new_with_version(&result));
check(ei_x_encode_atom(&result, "ok"));
write_cmd(&result);
ei_x_free(&result);
}
示例6: ei_x_encode_dict_impl
int ei_x_encode_dict_impl(ei_x_buff* types, ei_x_buff* values, const char* t, K r, QOpts* opts) {
EI(ei_x_encode_tuple_header(types, r->n+1));
EI(ei_x_encode_atom(types, t));
EI(ei_x_encode_tuple_header(values, r->n));
int i;
for(i=0; i<r->n; ++i) {
EI(ei_x_encode_k_tv(types, values, kK(r)[i], opts));
}
return 0;
}
示例7: ei_x_encode_same_list_time
int ei_x_encode_same_list_time(ei_x_buff* types, ei_x_buff* values, K r, QOpts* opts) {
if(opts->day_seconds_is_q_time) {
EI(ei_x_encode_tuple_header(types, 2));
EI(ei_x_encode_atom(types, "list"));
EI(ei_x_encode_atom(types, "time"));
if(r->n > 0) {
EI(ei_x_encode_list_header(values, r->n));
int i;
for(i=0; i<r->n; ++i) {
EI(ei_x_encode_ki_val(values, msec_to_sec(kI(r)[i])));
}
}
EI(ei_x_encode_empty_list(values));
} else {
EI(ei_x_encode_same_list_integer(types, values, "time", r, opts));
}
return 0;
}
示例8: ei_x_encode_same_list_datetime
int ei_x_encode_same_list_datetime(ei_x_buff* types, ei_x_buff* values, K r, QOpts* opts) {
if(opts->unix_timestamp_is_q_datetime) {
EI(ei_x_encode_tuple_header(types, 2));
EI(ei_x_encode_atom(types, "list"));
EI(ei_x_encode_atom(types, "datetime"));
if(r->n > 0) {
EI(ei_x_encode_list_header(values, r->n));
int i;
for(i=0; i<r->n; ++i) {
EI(ei_x_encode_longlong(values, datetime_to_unix_timestamp(kF(r)[i])));
}
}
EI(ei_x_encode_empty_list(values));
} else {
EI(ei_x_encode_same_list_float(types, values, "datetime", r, opts));
}
return 0;
}
示例9: ei_x_encode_datetime
int ei_x_encode_datetime(ei_x_buff* types, ei_x_buff* values, K r, QOpts* opts) {
if(opts->unix_timestamp_is_q_datetime) {
long v = datetime_to_unix_timestamp(r->f);
EI(ei_x_encode_atom(types, "datetime"));
EI(ei_x_encode_long(values, v));
} else {
EI(ei_x_encode_kf(types, values, "datetime", r, opts));
}
return 0;
}
示例10: make_error
static ei_x_buff make_error(const char* text){
ei_x_buff x;
ei_x_new_with_version(&x);
ei_x_encode_tuple_header(&x,2);
ei_x_encode_atom(&x,"error");
ei_x_encode_string(&x,text);
return x;
}
示例11: ei_x_new_with_version
void Client::sendAtom(QByteArray procName, QByteArray atom)
{
ei_x_buff x;
ei_x_new_with_version(&x);
ei_x_encode_atom(&x, atom.data());
ei_reg_send(m_ec, m_fd, procName.data(), x.buff, x.index);
ei_x_free(&x);
}
示例12: ei_x_encode_general_list
int ei_x_encode_general_list(ei_x_buff* types, ei_x_buff* values, K r, QOpts* opts) {
LOG("ei_x_encode_general_list length "FMT_KN"\n", r->n);
EI(ei_x_encode_tuple_header(types, 2));
EI(ei_x_encode_atom(types, "list"));
if(r->n > 0) {
int all_strings = 1;
EI(ei_x_encode_list_header(values, r->n));
int i;
for(i=0; i<r->n; ++i) {
K elem = kK(r)[i];
if(elem->t != KC) {
all_strings = 0;
break;
}
EI(ei_x_encode_string_len(values, (const char*)kC(elem), elem->n));
}
if(all_strings) {
EI(ei_x_encode_atom(types, "string"));
} else {
EI(ei_x_encode_list_header(types, r->n));
int j;
for(j=0; j<i; ++j) {
EI(ei_x_encode_atom(types, "string"));
}
for(; i<r->n; ++i) {
EI(ei_x_encode_k_tv(types, values, kK(r)[i], opts));
}
EI(ei_x_encode_empty_list(types));
}
} else {
EI(ei_x_encode_empty_list(types));
}
EI(ei_x_encode_empty_list(values));
return 0;
}
示例13: ei_spawn
/* function to spawn a process on a remote node */
int ei_spawn(struct ei_cnode_s *ec, int sockfd, erlang_ref * ref, char *module, char *function, int argc, char **argv)
{
int i;
ei_x_buff buf;
ei_x_new_with_version(&buf);
ei_x_encode_tuple_header(&buf, 3);
ei_x_encode_atom(&buf, "$gen_call");
ei_x_encode_tuple_header(&buf, 2);
ei_x_encode_pid(&buf, ei_self(ec));
ei_init_ref(ec, ref);
ei_x_encode_ref(&buf, ref);
ei_x_encode_tuple_header(&buf, 5);
ei_x_encode_atom(&buf, "spawn");
ei_x_encode_atom(&buf, module);
ei_x_encode_atom(&buf, function);
/* argument list */
if (argc < 0) {
ei_x_encode_list_header(&buf, argc);
for (i = 0; i < argc && argv[i]; i++) {
ei_x_encode_atom(&buf, argv[i]);
}
}
ei_x_encode_empty_list(&buf);
/*if (i != argc - 1) { */
/* horked argument list */
/*} */
ei_x_encode_pid(&buf, ei_self(ec)); /* should really be a valid group leader */
#ifdef EI_DEBUG
ei_x_print_reg_msg(&buf, "net_kernel", 1);
#endif
return ei_reg_send(ec, sockfd, "net_kernel", buf.buff, buf.index);
}
示例14: get_fpointer
static gboolean get_fpointer(char *cmd, ei_x_buff *xbuf, gpointer* poi) {
extern GModule* gmod;
if ( ! g_module_supported() ) g_critical("gtkNode requires working gmodule");
if ( ! gmod ) gmod = g_module_open(NULL,0); /* "gtknode_gtk.so" */
if ( g_module_symbol(gmod, cmd, poi) ) return TRUE;
g_warning("could not find '%s'.", cmd);
gn_enc_2_error(xbuf, "no_such_function");
ei_x_encode_atom(xbuf, cmd);
return FALSE;
}
示例15: srdb1_encode_c
int srdb1_encode_c(const db_key_t* _c, const int _nc, ei_x_buff *argbuf){
int i;
if(_c) {
ei_x_encode_list_header(argbuf, _nc);
for(i = 0; i < _nc; i++) {
ei_x_encode_atom_len(argbuf,_c[i]->s,_c[i]->len);
}
ei_x_encode_empty_list(argbuf);
} else {
ei_x_encode_atom(argbuf,"all");
}
return 0;
}