/*
- *
- * Version $Id$
- */
+ Bacula® - The Network Backup Solution
+
+ Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
+
+ The main author of Bacula is Kern Sibbald, with contributions from
+ many others, a complete list can be found in the file AUTHORS.
+ This program is Free Software; you can redistribute it and/or
+ modify it under the terms of version three of the GNU Affero General Public
+ License as published by the Free Software Foundation and included
+ in the file LICENSE.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+ Bacula® is a registered trademark ofKern Sibbald.
+ The licensor of Bacula is the Free Software Foundation Europe
+ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+ Switzerland, email:ftf@fsfeurope.org.
+*/
/*
- Copyright (C) 2000-2006 Kern Sibbald
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as amended with additional clauses defined in the
- file LICENSE in the main source directory.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- the file LICENSE for additional details.
-
+ *
+ * Written by John Walker, MM
+ *
*/
-
/* Serialisation support functions from serial.c. */
extern void serial_int16(uint8_t * * const ptr, const int16_t v);
extern uint64_t unserial_uint64(uint8_t * * const ptr);
extern btime_t unserial_btime(uint8_t * * const ptr);
extern float64_t unserial_float64(uint8_t * * const ptr);
-extern void unserial_string(uint8_t * * const ptr, char * const str);
+extern void unserial_string(uint8_t * * const ptr, char * const str, int max);
/*
/* ser_length -- Determine length in bytes of serialised into a
buffer x. */
-#define ser_length(x) (ser_ptr - (uint8_t *)(x))
-#define unser_length(x) (ser_ptr - (uint8_t *)(x))
+#define ser_length(x) ((uint32_t)(ser_ptr - (uint8_t *)(x)))
+#define unser_length(x) ((uint32_t)(ser_ptr - (uint8_t *)(x)))
/* ser_end(x, s) -- End serialisation into a buffer x of size s. */
#define ser_end(x, s) ASSERT(ser_length(x) <= (s))
/* Binary byte stream not requiring serialisation (length obtained by sizeof) */
#define unser_buffer(x) unser_bytes((x), (sizeof (x)))
-/* Binary string not requiring serialization */
-#define unser_string(x) unserial_string(&ser_ptr, (x))
+/* Binary string not requiring serialization (length obtained from max) */
+#define unser_nstring(x,max) unserial_string(&ser_ptr, (x), (int)(max))
+
+/* Binary string not requiring serialisation (length obtained by sizeof) */
+#define unser_string(x) unserial_string(&ser_ptr, (x), sizeof(x))
#endif /* __SERIAL_H_ */