summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/common-utils.c
diff options
context:
space:
mode:
authorshishir gowda <shishirng@gluster.com>2011-03-31 04:57:05 +0000
committerVijay Bellur <vijay@dev.gluster.com>2011-03-31 05:04:42 -0700
commitc68b1e28ae9b7528aa844764e719c7267976be83 (patch)
treef95bdf6b659069b1eac659ee56e7ce5d1df6ec0c /libglusterfs/src/common-utils.c
parent58974b02b6ebb65ee1f7baf23b0fe6c3e7fcf8cd (diff)
TOP: Validate command options
Signed-off-by: shishir gowda <shishirng@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 2628 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2628
Diffstat (limited to 'libglusterfs/src/common-utils.c')
-rw-r--r--libglusterfs/src/common-utils.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index 21506636c..0d850740e 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -1773,3 +1773,34 @@ gf_array_insertionsort (void *A, int l, int r, size_t elem_size,
}
}
}
+
+int
+gf_is_str_int (const char *value)
+{
+ int flag = 0;
+ char *str = NULL;
+ char *fptr = NULL;
+
+ GF_VALIDATE_OR_GOTO ("", value, out);
+
+ str = strdup (value);
+ if (!str)
+ goto out;
+
+ fptr = str;
+
+ while (*str) {
+ if (!isdigit(*str)) {
+ flag = 1;
+ goto out;
+ }
+ str++;
+ }
+
+out:
+ if (fptr)
+ GF_FREE (fptr);
+
+ return flag;
+}
+