views:

92

answers:

2

I am trying to use *ei_get_type()* (ei) but I am having trouble finding where the 'type' field is documented. I've looked in ei.h but all I could find was a list of constants starting with "ERL_".

#define ERL_SMALL_INTEGER_EXT 'a'
#define ERL_INTEGER_EXT       'b'
#define ERL_FLOAT_EXT         'c'
#define ERL_ATOM_EXT          'd'
#define ERL_REFERENCE_EXT     'e'
#define ERL_NEW_REFERENCE_EXT 'r'
#define ERL_PORT_EXT          'f'
#define ERL_PID_EXT           'g'
#define ERL_SMALL_TUPLE_EXT   'h'
#define ERL_LARGE_TUPLE_EXT   'i'
#define ERL_NIL_EXT           'j'
#define ERL_STRING_EXT        'k'
#define ERL_LIST_EXT          'l'
#define ERL_BINARY_EXT        'm'
#define ERL_SMALL_BIG_EXT     'n'
#define ERL_LARGE_BIG_EXT     'o'
#define ERL_NEW_FUN_EXT   'p'
#define ERL_FUN_EXT           'u'

Is this the correct list? I am unsure because the prototype of *er_get_type()* has *int ** for the type field whereas the ei.h file defines char the above constants.

NOTE: There are other 'constants' used in the 'erl_interface' package that aren't listed here.

+2  A: 

According to the rest of the c codes in Erlang (odbcserver.c, show_msg.c) this is what you should compare the value to.

Apparently these are the byte values used by the external binary format to mark the types of elements, and the get8 macro in putget.h simply returns this value.

Zed
What's the difference between "SMALL_TUPLE" and "LARGE_TUPLE" ??
jldupont
What's a "SMALL_INTEGER" ? 16 bits?? How about a "LARGE_BIG" ????
jldupont
A: 

Hi, I'd been using ei to encode/decode erlang terms from a cnode from a couple of months now, and the constants you mention seems OK. The ones I'm using are:

LONG -> a

ATOM -> d

TUPLE -> h

EMPTY_LIST -> j

STRING -> k

LIST -> l

BINARY -> m

in the kind of messages I've to parse, I only receive these types.

ppolv