Use Client_find_by_session() instead of a few open-coded loops.
[umurmur.git] / src / pds.h
1 /* Copyright (C) 2009-2014, Martin Johansson <martin@fatbob.nu>
2    Copyright (C) 2005-2014, Thorvald Natvig <thorvald@natvig.com>
3
4    All rights reserved.
5
6    Redistribution and use in source and binary forms, with or without
7    modification, are permitted provided that the following conditions
8    are met:
9
10    - Redistributions of source code must retain the above copyright notice,
11      this list of conditions and the following disclaimer.
12    - Redistributions in binary form must reproduce the above copyright notice,
13      this list of conditions and the following disclaimer in the documentation
14      and/or other materials provided with the distribution.
15    - Neither the name of the Developers nor the names of its contributors may
16      be used to endorse or promote products derived from this software without
17      specific prior written permission.
18
19    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22    A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
23    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 #ifndef PDS_H_457865876
32 #define PDS_H_457865876
33
34 #include <stdint.h>
35 #include "types.h"
36
37 typedef struct {
38         uint8_t *data;
39         uint32_t maxsize;
40         uint32_t offset;
41         uint32_t overshoot;
42         bool_t bOk;
43 } pds_t;
44
45 void Pds_append_data(pds_t *pds, const uint8_t *data, uint32_t len);
46 void Pds_append_data_nosize(pds_t *pds, const uint8_t *data, uint32_t len);
47 uint64_t Pds_get_numval(pds_t *pds);
48 void Pds_add_numval(pds_t *pds, const uint64_t value);
49 pds_t *Pds_create(uint8_t *buf, int size);
50 void Pds_free(pds_t *pds);
51 void Pds_add_string(pds_t *pds, const char *str);
52 void Pds_get_string(pds_t *pds, char *str, int maxlen);
53 void Pds_add_double(pds_t *pds, double value);
54 double Pds_get_double(pds_t *pds);
55 int Pds_get_data(pds_t *pds, uint8_t *data, int maxlen);
56 uint8_t Pds_next8(pds_t *pds);
57 int Pds_skip(pds_t *pds, int offset);
58
59
60 #endif