1 /* 2 3 $Id$ 4 5 G N O K I I 6 7 A Linux/Unix toolset and driver for the mobile phones. 8 9 This file is part of gnokii. 10 11 Gnokii is free software; you can redistribute it and/or modify 12 it under the terms of the GNU General Public License as published by 13 the Free Software Foundation; either version 2 of the License, or 14 (at your option) any later version. 15 16 Gnokii is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 GNU General Public License for more details. 20 21 You should have received a copy of the GNU General Public License 22 along with gnokii; if not, write to the Free Software 23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 25 Copyright (C) 2004 BORBELY Zoltan 26 27 This file contains the encoding/decoding functions for the basic types. 28 29 */ 30 31 #ifndef _gnokii_pkt_h 32 #define _gnokii_pkt_h 33 34 #include "compat.h" 35 36 typedef struct { 37 uint8_t *addr; 38 int32_t size; 39 int32_t offs; 40 } pkt_buffer; 41 42 void pkt_buffer_set(pkt_buffer *buf, void *addr, int32_t len); 43 44 void pkt_put_int8(pkt_buffer *buf, int8_t x); 45 void pkt_put_int16(pkt_buffer *buf, int16_t x); 46 void pkt_put_int32(pkt_buffer *buf, int32_t x); 47 void pkt_put_uint8(pkt_buffer *buf, uint8_t x); 48 void pkt_put_uint16(pkt_buffer *buf, uint16_t x); 49 void pkt_put_uint32(pkt_buffer *buf, uint32_t x); 50 void pkt_put_string(pkt_buffer *buf, const char *x); 51 void pkt_put_timestamp(pkt_buffer *buf, const gn_timestamp *x); 52 void pkt_put_bool(pkt_buffer *buf, int x); 53 void pkt_put_bytes(pkt_buffer *buf, const uint8_t *x, uint16_t n); 54 55 int8_t pkt_get_int8(pkt_buffer *buf); 56 int16_t pkt_get_int16(pkt_buffer *buf); 57 int32_t pkt_get_int32(pkt_buffer *buf); 58 uint8_t pkt_get_uint8(pkt_buffer *buf); 59 uint16_t pkt_get_uint16(pkt_buffer *buf); 60 uint32_t pkt_get_uint32(pkt_buffer *buf); 61 char *pkt_get_string(char *s, int slen, pkt_buffer *buf); 62 gn_timestamp *pkt_get_timestamp(gn_timestamp *t, pkt_buffer *buf); 63 int pkt_get_bool(pkt_buffer *buf); 64 uint16_t pkt_get_bytes(uint8_t *s, int len, pkt_buffer *buf); 65 66 #endif 67