2 * librouteros - src/ros_parse.c
3 * Copyright (C) 2009 Florian octo Forster
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; only version 2 of the License is applicable.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Florian octo Forster <octo at verplant.org>
22 #ifndef _ISOC99_SOURCE
23 # define _ISOC99_SOURCE
26 #ifndef _POSIX_C_SOURCE
27 # define _POSIX_C_SOURCE 200112L
42 #include "routeros_api.h"
44 _Bool sstrtob (const char *str) /* {{{ */
49 if (strcasecmp ("true", str) == 0)
52 } /* }}} _Bool sstrtob */
54 unsigned int sstrtoui (const char *str) /* {{{ */
64 ret = (unsigned int) strtoul (str, &endptr, /* base = */ 10);
65 if ((endptr == str) || (errno != 0))
69 } /* }}} unsigned int sstrtoui */
71 double sstrtod (const char *str) /* {{{ */
81 ret = strtod (str, &endptr);
82 if ((endptr == str) || (errno != 0))
86 } /* }}} double sstrtod */
88 int sstrto_rx_tx_counters (const char *str, /* {{{ */
89 uint64_t *rx, uint64_t *tx)
94 if ((rx == NULL) || (tx == NULL))
106 *rx = (uint64_t) strtoull (ptr, &endptr, /* base = */ 10);
107 if ((endptr == str) || (errno != 0))
113 assert (endptr != NULL);
114 if ((*endptr != '/') && (*endptr != ','))
120 *tx = (uint64_t) strtoull (ptr, &endptr, /* base = */ 10);
121 if ((endptr == str) || (errno != 0))
129 } /* }}} int sstrto_rx_tx_counters */
131 /* vim: set ts=2 sw=2 noet fdm=marker : */