From 84adefa331c4159d432d22840663c38f155cd4c1 Mon Sep 17 00:00:00 2001 From: Erlang/OTP Date: Fri, 20 Nov 2009 14:54:40 +0000 Subject: The R13B03 release. --- lib/erl_interface/src/decode/decode_intlist.c | 82 +++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 lib/erl_interface/src/decode/decode_intlist.c (limited to 'lib/erl_interface/src/decode/decode_intlist.c') diff --git a/lib/erl_interface/src/decode/decode_intlist.c b/lib/erl_interface/src/decode/decode_intlist.c new file mode 100644 index 0000000000..65552a4ed4 --- /dev/null +++ b/lib/erl_interface/src/decode/decode_intlist.c @@ -0,0 +1,82 @@ +/* + * %CopyrightBegin% + * + * Copyright Ericsson AB 1998-2009. 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% + */ +/* since Erlang sends int-lists as either lists or strings, this + * function can be used when the caller needs an array but doesn't + * know which type to decode + */ +#include "eidef.h" +#include "eiext.h" +#include "putget.h" + +int ei_decode_intlist(const char *buf, int *index, long *a, int *count) +{ + const unsigned char *s = (const unsigned char *)(buf + *index); + const unsigned char *s0 = s; + int idx; + int len; + int i; + + switch (get8(s)) { + case ERL_STRING_EXT: + len = get16be(s); + + /* transfer and cast chars one at a time into array */ + if (a) { + for (i=0; i