示例#1
0
static void send_errno_result(int value)
{
    ei_x_buff x;
    ei_x_new_with_version(&x);
    ei_x_encode_tuple_header(&x, 2);
    ei_x_encode_long(&x, value);
    ei_x_encode_long(&x, erl_errno);
    send_bin_term(&x);
    ei_x_free(&x);
}
示例#2
0
static void cmd_ei_set_get_tracelevel(char* buf, int len)
{
    int  index = 0;
    long level = 0;
    long ret   = 0;
    ei_x_buff x;

    if (ei_decode_long(buf, &index, &level) < 0) {
	fail("expected long");
    }
    
    ei_set_tracelevel((int)level);

    ret = (long) ei_get_tracelevel();

    ei_x_new_with_version(&x);
    ei_x_encode_tuple_header(&x, 2);
    ei_x_encode_atom(&x, "tracelevel");
    ei_x_encode_long(&x, ret);
    send_bin_term(&x);
    ei_x_free(&x);
}
示例#3
0
static void cmd_ei_rpc(char* buf, int len)
{
    int index = 0, n;
    long fd;
    erlang_pid pid;
    ei_x_buff x, rpc_x;
    int r;
    char mod[MAXATOMLEN], func[MAXATOMLEN];

#if 0 && defined(__WIN32__) 
    DebugBreak();
#endif

    if (ei_decode_long(buf, &index, &fd) < 0)
	fail("expected long");
    if (ei_decode_pid(buf, &index, &pid) < 0)
	fail("expected pid (node)");
    if (ei_decode_tuple_header(buf, &index, &n) < 0 && n < 2)
	fail("expected tuple {module, function}");
    if (ei_decode_atom(buf, &index, mod) < 0)
	fail("expected atom (module)");
    if (ei_decode_atom(buf, &index, func) < 0)
	fail("expected atom (function)");
    message("pid %s %d %d %d\n", pid.node, pid.num, pid.serial, pid.creation);
    message("{%s, %s}\n", mod, func);
    if (ei_x_new(&rpc_x) < 0)
	fail("ei_x_new");
    if (ei_rpc(&ec, fd, mod, func, &buf[index], len - index, &rpc_x) < 0)
	fail("ei_rpc");
    if (ei_x_new_with_version(&x) < 0)
 	fail("ei_x_new_with_version");
    if (ei_x_append(&x, &rpc_x) < 0)
	fail("append");
    send_bin_term(&x);
    /*send_errno_result(ei_send(&ec, fd, &pid, x.buff, x.index));*/
    ei_x_free(&x);
    ei_x_free(&rpc_x);
}
示例#4
0
static void cmd_ei_connect_init(char* buf, int len)
{
    int index = 0, r = 0;
    int type, size;
    long l;
    char b[100];
    char cookie[MAXATOMLEN], * cp = cookie;
    ei_x_buff res;
    if (ei_decode_long(buf, &index, &l) < 0)
	fail("expected int");
    sprintf(b, "c%ld", l);
    /* FIXME don't use internal and maybe use skip?! */
    ei_get_type_internal(buf, &index, &type, &size);
    if (ei_decode_atom(buf, &index, cookie) < 0)
	fail("expected atom (cookie)");
    if (cookie[0] == '\0')
	cp = NULL;
    r = ei_connect_init(&ec, b, cp, 0);
    ei_x_new_with_version(&res);
    ei_x_encode_long(&res, r);
    send_bin_term(&res);
    ei_x_free(&res);
}
示例#5
0
static void
send_printed3(char* format, char* p1, char* p2, int fl)
{
    char* b = NULL;
    char fn[100], * tmp = getenv("temp");
    FILE* f;
    int n, index = 0, ver;
    ei_x_buff x;

    ei_x_new(&x);
    if (fl) {
	ei_x_format(&x, format, *(float*)p1, *(float*)p2);
    } else {
	ei_x_format(&x, format, p1, p2);
    }
#ifdef VXWORKS
    tmp = ".";
#else
    if (tmp == NULL) tmp = "/tmp";
#endif
    strcpy(fn, tmp);
    strcat(fn, "/ei_print_test.txt");
    f = fopen(fn, "w+");
    ei_decode_version(x.buff, &index, &ver);
    n = ei_print_term(f, x.buff, &index);
    fseek(f, 0, SEEK_SET);
    b = malloc(n+1);
    fread(b, 1, n, f);
    b[n] = '\0';
    fclose(f);
    x.index = 0;
    ei_x_format(&x, "~s", b);
    send_bin_term(&x);
    free(b);
    ei_x_free(&x);
}