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


C++ ei_x_encode_tuple_header函数代码示例

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


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

示例1: ei_error

static int ei_error(ei_x_buff *x, const char *error, char** res, int res_size) {
  if (x) ei_x_free(x);
  ei_x_new_with_version(x);
  ei_x_encode_tuple_header(x, 2);
  ei_x_encode_atom(x, "error");
  ei_x_encode_atom(x, error);
  if (res_size < x->index)
    (*res) = (char *) driver_alloc(x->index);
  int n = x->index;
  memcpy(*res, x->buff, x->index);
  ei_x_free(x);
  return n;
};
开发者ID:chinnurtb,项目名称:MotionDb,代码行数:13,代码来源:tc.c

示例2: ei_x_encode_k

int ei_x_encode_k(ei_x_buff* x, K r, QOpts* opts) {
    EI(ei_x_encode_tuple_header(x, 2));
    ei_x_buff* types = x;
    ei_x_buff values;
    EI(ei_x_new(&values));
    EIC(ei_x_encode_k_tv(types, &values, r, opts),
            ei_x_free(&values)); // cleanup expression
    // TODO - JMS - is there a way to do this without deep copying data?
    EIC(ei_x_append(types, &values),
            ei_x_free(&values)); // cleanup expression
    EI(ei_x_free(&values));
    return 0;
}
开发者ID:csurface,项目名称:gen_q,代码行数:13,代码来源:q2e.c

示例3: erl_json_ei_end_map

static int erl_json_ei_end_map(void* ctx) {
  State* pState = (State*) ctx;

  flog(stderr, "end map", 0, 0, 0);
  
  if(pState->skip_list_header_for_value) {
    ei_x_encode_tuple_header(&pState->ei_buf, 0);
    pState->skip_list_header_for_value = 0;
  }
  ei_x_encode_empty_list(&pState->ei_buf);

  return 1;
}
开发者ID:kocolosk,项目名称:eep0018,代码行数:13,代码来源:json_parse.c

示例4: 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);

}
开发者ID:DrumTechnologiesLtd,项目名称:FreeSWITCH,代码行数:40,代码来源:ei_helpers.c

示例5: encode_result

void encode_result(ei_x_buff* x, PGresult* res, PGconn* conn)
{
    int row, n_rows, col, n_cols, fsize;

    switch (PQresultStatus(res)) {
    case PGRES_TUPLES_OK: 
	n_rows = PQntuples(res); 
	n_cols = PQnfields(res); 
	ei_x_encode_tuple_header(x, 2); 
	encode_ok(x);
 	ei_x_encode_list_header(x, 1);
	for (col = 0; col < n_cols; ++col) {
	    ei_x_encode_list_header(x, 1);
	    ei_x_encode_string(x, PQfname(res, col));
	}
	ei_x_encode_empty_list(x); 
	for (row = 0; row < n_rows; ++row) {
	    ei_x_encode_list_header(x, 1);
	    for (col = 0; col < n_cols; ++col) {
		ei_x_encode_list_header(x, 1);
		fsize = PQgetlength(res, row, col);
		ei_x_encode_binary(x, PQgetvalue(res, row, col), fsize);
	    }
	    ei_x_encode_empty_list(x);
	}
	ei_x_encode_empty_list(x); 
	break; 
    case PGRES_COMMAND_OK:
	ei_x_encode_tuple_header(x, 2);
        encode_ok(x);
	ei_x_encode_string(x, PQcmdTuples(res));
        break;
    default:
	encode_error(x, conn);
	break;
    }
}
开发者ID:0x00evil,项目名称:otp,代码行数:37,代码来源:pg_encode2.c

示例6: write_to_png_stream

ETERM * write_to_png_stream(ETERM* arg, int c_node) {
	cairo_context * const ctx = get_cairo_context(arg);
	if(!ctx)
		return erl_format("{c_node, ~i, {error, '~s'}}", c_node, ERR_CONTEXT);

	struct png_data out = {};
	const int status = cairo_surface_write_to_png_stream(ctx->sf, write_cb, &out);
	ETERM *term = NULL;

	ei_x_buff req;
	ei_x_new_with_version(&req);
	ei_x_encode_tuple_header(&req, 3);
	ei_x_encode_atom(&req, "c_node");
	ei_x_encode_long(&req, c_node);
	ei_x_encode_tuple_header(&req, 2);
	ei_x_encode_atom(&req, "ok");
	ei_x_encode_binary(&req, out.buf, out.written);

	int index = 0;
	ei_decode_term(req.buff, &index, &term);
	ei_x_free(&req);
	free(out.buf);
	return term;
}
开发者ID:chinnurtb,项目名称:erlycairo,代码行数:24,代码来源:erlycairo.c

示例7: ei_x_new_with_version

  bool CCESUT::TradeUpdate(PTradeUpdateTxnInput pTxnInput) {

    ei_x_buff x;

    ei_x_new_with_version(&x);
    ei_x_encode_tuple_header(&x, 2);
    {
      ei_x_encode_atom(&x, "ok");
      ei_x_encode_tuple_header(&x, 2);
      {
        ei_x_encode_atom(&x, APP ".BH.TU");
        m_Encoder.encode(&x, *pTxnInput);
      }
    }

    int result = driver_output(m_ErlDrvPort, x.buff, x.index);

#ifdef _TRACE
    cout << "[TU] ! " << *pTxnInput << ", result=" << result << '\r' << endl;
#endif
    ei_x_free(&x);

    return result;
  }
开发者ID:tomaon,项目名称:ergen,代码行数:24,代码来源:ERGenCE_drv.C

示例8: test_performance_atom

/* tests de tipos simples */
int test_performance_atom(char *atom, int times) {
	
	ei_x_buff output;
	ei_x_buff input;
	erlang_msg msg;
	int version;
	int ei_res;
	int index;
	char decoded_atom[MAXATOMLEN]; 
	
	// Inicializa buffers
	ei_x_new_with_version(&output);
	ei_x_new(&input);
	
	// Codifica
	ei_x_encode_tuple_header(&output, 2);
	ei_x_encode_pid(&output, &local_pid);
	ei_x_encode_atom(&output, atom);
	
	for (int i = 0; i<times; i++) {
		if (ei_reg_send(&ec, connection_fd, REMOTE_SERVER_NAME, 
			output.buff, output.index) < 0) {
				return 1;
		}
		do {
			ei_res = ei_xreceive_msg(connection_fd, &msg, &input);
		} while(ei_res == ERL_TICK);
		
		if (ei_res == ERL_ERROR) {
			return -1;
		}
		index = 0;
		if (ei_decode_version(input.buff, &index, &version) < 0) {
			std::cout << "failed decoding version \n";
			return 1;
		}
				

		if (ei_decode_atom(input.buff, &index, decoded_atom) < 0) {
			std::cout << "failed decoding atom \n";
			return 1;
		}		
	}
		
	return 0;
}
开发者ID:keymon,项目名称:ErlXPCOM,代码行数:47,代码来源:ei_performance.cpp

示例9: pack_parse_data

static ei_x_buff pack_parse_data(parse_result parse_result_){

	ei_x_buff x;
	ei_x_new_with_version(&x);
	ei_x_encode_tuple_header(&x,2);
	//{caly_tekst,[link]} kodujemy caly tekst
	ei_x_encode_string(&x, parse_result_.second.c_str());
	int link_list_length = parse_result_.first.size();
	ei_x_encode_list_header(&x,link_list_length);
	vector<std::string>& links = parse_result_.first;
	for (vector<std::string>::iterator it = links.begin(); it != links.end(); it++){
		ei_x_encode_string_len(&x,(*it).c_str(),(*it).size());
	}
	ei_x_encode_empty_list(&x);

	return x;
}
开发者ID:mjamroz90,项目名称:erlCrawler,代码行数:17,代码来源:parse_html_driver.cpp

示例10: 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);
}
开发者ID:oliv3,项目名称:phaspa,代码行数:18,代码来源:rec.c

示例11: 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;
}
开发者ID:csurface,项目名称:gen_q,代码行数:19,代码来源:q2e.c

示例12: 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;
}
开发者ID:csurface,项目名称:gen_q,代码行数:19,代码来源:q2e.c

示例13: exit_element

int
exit_element(struct exmpp_xml_ctx *ctx,
    const char *ns, int ns_len,
    const char *elem, int elem_len)
{
	ei_x_buff *tree;

	/* Update depth. */
	if (ctx->depth > 0)
		ctx->depth--;

	tree = ctx->current_tree;

	if (ctx->emit_endtag && (ctx->root_depth == -1 ||
	    ctx->depth < ctx->root_depth)) {
		/* We're above root depth (or the feature is disabled),
		 * so we start a new Erlang term each time. */

		/* The current_tree buffer was reset by
		 * current_tree_finished(). */

		/* Start an #xmlendtag record. */
		ei_x_encode_tuple_header(tree, 3);
		ei_x_encode_atom(tree, "xmlendtag");

		/* Check if the namespace is known and encode it. */
		encode_ns(ctx, tree, ns, ns_len);

		/* Check if the element is known and encode it. */
		encode_elem(ctx, tree, elem, elem_len);

		current_tree_finished(ctx);
	} else if (ctx->root_depth != -1 && ctx->depth >= ctx->root_depth) {
		/* Terminate the children list. */
		ei_x_encode_empty_list(tree);

		if (ctx->depth == ctx->root_depth)
			current_tree_finished(ctx);
	}

	return (0);
}
开发者ID:ASalimov,项目名称:exmpp,代码行数:42,代码来源:exmpp_xml.c

示例14: erl_json_ei_map_key

static int erl_json_ei_map_key(void* ctx, const unsigned char* buf, unsigned int len) {
  State* pState = (State*) ctx;

  flog(stderr, "map key", 0, buf, len);

  list_header_for_value(pState);
  
  ei_x_encode_tuple_header(&pState->ei_buf, 2);

  switch(keys_as(pState)) {
    case EEP0018_PARSE_KEYS_AS_ATOM:
      ei_x_encode_atom_len(&pState->ei_buf, buf, len);
      break;
    case EEP0018_PARSE_KEYS_AS_BINARY:
      ei_x_encode_binary(&pState->ei_buf, buf, len);
      break;
  }

  pState->skip_list_header_for_value = -1;
  
  return 1;
}
开发者ID:kocolosk,项目名称:eep0018,代码行数:22,代码来源:json_parse.c

示例15: 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;
}
开发者ID:csurface,项目名称:gen_q,代码行数:39,代码来源:q2e.c


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