summaryrefslogtreecommitdiffstats
path: root/plugins/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/utils.c')
-rw-r--r--plugins/utils.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/plugins/utils.c b/plugins/utils.c
index aff1790..77d6a6f 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -23,13 +23,15 @@
23*****************************************************************************/ 23*****************************************************************************/
24 24
25#include "common.h" 25#include "common.h"
26#include "utils.h" 26#include "./utils.h"
27#include "utils_base.h" 27#include "utils_base.h"
28#include <stdarg.h> 28#include <stdarg.h>
29#include <limits.h> 29#include <limits.h>
30#include <string.h> 30#include <string.h>
31#include <errno.h> 31#include <errno.h>
32 32
33#include <stdbool.h>
34
33#include <arpa/inet.h> 35#include <arpa/inet.h>
34 36
35extern void print_usage (void); 37extern void print_usage (void);
@@ -188,6 +190,33 @@ bool is_percentage (char *number) {
188 return false; 190 return false;
189} 191}
190 192
193bool is_percentage_expression (const char str[]) {
194 if (!str) {
195 return false;
196 }
197
198 size_t len = strlen(str);
199
200 if (str[len-1] != '%') {
201 return false;
202 }
203
204 char *foo = calloc(sizeof(char), len + 1);
205
206 if (!foo) {
207 die (STATE_UNKNOWN, _("calloc failed \n"));
208 }
209
210 strcpy(foo, str);
211 foo[len-1] = '\0';
212
213 bool result = is_numeric(foo);
214
215 free(foo);
216
217 return result;
218}
219
191bool is_integer (char *number) { 220bool is_integer (char *number) {
192 long int n; 221 long int n;
193 222