2 * UCW Library -- Basic Extended Types
4 * (c) 2014 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
11 #include <ucw/mempool.h>
12 #include <ucw/strtonum.h>
13 #include <ucw/xtypes.h>
15 static const char *xt_int_parse(const char *str, void *dest, struct mempool *pool UNUSED)
17 return str_to_int(dest, str, NULL, 10 | STN_WHOLE | STN_MINUS | STN_PLUS | STN_HEX | STN_BIN | STN_OCT);
20 static const char *xt_int_format(void *src, u32 fmt UNUSED, struct mempool *pool)
22 return mp_printf(pool, "%d", *(int *)src);
25 const struct xtype xt_int = {
28 .parse = xt_int_parse,
29 .format = xt_int_format,