/* * %CopyrightBegin% * * Copyright Ericsson AB 1998-2010. All Rights Reserved. * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. * * %CopyrightEnd% */ #include "eidef.h" #include "eiext.h" #include "putget.h" #include "erl_interface.h" /* * This file is actually part of the erl_interface library, * not the newer 'ei' library. The header file is still in "ei.h" */ /* FIXME: is this to be completed? */ #if (0) int ei_decode_term(const char *buf, int *index, void *t) { const char *s = buf + *index; const char *s0 = s; if (t) { ETERM *tmp; /* this decodes and advances s */ if (!(tmp = erl_decode_buf((unsigned char **)&s))) return -1; *(ETERM **)t = tmp; *index += s - s0; return 0; } else { int tmpindex = *index; long ttype; int arity; int i; /* these are all the external types */ switch ((ttype = get8(s))) { case ERL_SMALL_INTEGER_EXT: case ERL_INTEGER_EXT: case ERL_SMALL_BIG_EXT: return ei_decode_long(buf,index,NULL); case ERL_FLOAT_EXT: case NEW_FLOAT_EXT: return ei_decode_double(buf,index,NULL); case ERL_ATOM_EXT: return ei_decode_atom(buf,index,NULL); case ERL_REFERENCE_EXT: case ERL_NEW_REFERENCE_EXT: return ei_decode_ref(buf,index,NULL); case ERL_PORT_EXT: return ei_decode_port(buf,index,NULL); case ERL_PID_EXT: return ei_decode_pid(buf,index,NULL); case ERL_SMALL_TUPLE_EXT: case ERL_LARGE_TUPLE_EXT: if (ei_decode_tuple_header(buf,index,&arity) < 0) return -1; for (i=0; i