1
/* ``The contents of this file are subject to the Erlang Public License,
2
* Version 1.1, (the "License"); you may not use this file except in
3
* compliance with the License. You should have received a copy of the
4
* Erlang Public License along with this software. If not, it can be
5
* retrieved via the world wide web at http://www.erlang.org/.
7
* Software distributed under the License is distributed on an "AS IS"
8
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9
* the License for the specific language governing rights and limitations
12
* The Initial Developer of the Original Code is Ericsson Utvecklings AB.
13
* Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
14
* AB. All Rights Reserved.''
18
unsigned int decode16(unsigned char**);
19
unsigned char *encode16(unsigned char*, unsigned int);
20
unsigned int decode32(unsigned char**);
21
unsigned char *encode32(unsigned char*, unsigned int);
24
int decode(char **data) {
25
return decode32((unsigned char**) data);
28
unsigned char *encode(unsigned char *buffer, int data) {
29
return encode32(buffer, (unsigned int)data);
32
unsigned int decode_color(char **data) {
36
unsigned char *encode_color(unsigned char *buffer, unsigned int color) {
37
return encode(buffer, color);
40
unsigned int decode16(unsigned char **data) {
41
unsigned int value = 0;
43
value = (value << 8) + (*data)[1];
48
unsigned char *encode16(unsigned char *buffer, unsigned int data) {
49
buffer[1] = data & 0xff;
50
buffer[0] = (data >> 8) & 0xff;
54
unsigned int decode32(unsigned char **data) {
55
unsigned int value = 0;
57
value = (value << 8) + (*data)[1];
58
value = (value << 8) + (*data)[2];
59
value = (value << 8) + (*data)[3];
64
unsigned char *encode32(unsigned char *buffer, unsigned int data) {
65
buffer[3] = data & 0xff;
66
buffer[2] = (data >> 8) & 0xff;
67
buffer[1] = (data >> 16) & 0xff;
68
buffer[0] = (data >> 24) & 0xff;