summaryrefslogtreecommitdiffstats
path: root/src/common.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2018-03-17 17:29:28 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2018-03-17 17:29:28 +0100
commit09ecae700f224a23cfd8f63f98cebeccbe768cc0 (patch)
tree83fbfb551cc9330a02dfb6762e2c4b8e6015eecb /src/common.c
parent331f0ef77e62140d0ee9252c33b23b383aa73084 (diff)
Use new functions check_command(), skip_comma_in_command() and get_int_from_command() to parse command line arguments
Diffstat (limited to 'src/common.c')
-rw-r--r--src/common.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/common.c b/src/common.c
index 2e12b07..3b1f45b 100644
--- a/src/common.c
+++ b/src/common.c
@@ -286,3 +286,28 @@ time_t td_ntfs2utc (int64_t ntfstime)
{
return (ntfstime - (NTFS_TIME_OFFSET)) / 10000000;
}
+
+int check_command(char **current_cmd, const char *cmd, size_t n)
+{
+ const int res=strncmp(*current_cmd, cmd, n);
+ if(res==0)
+ (*current_cmd)+=n;
+ return res;
+}
+
+void skip_comma_in_command(char **current_cmd)
+{
+ while(*current_cmd[0]==',')
+ (*current_cmd)++;
+}
+
+uint64_t get_int_from_command(char **current_cmd)
+{
+ uint64_t tmp=0;
+ while(*current_cmd[0] >='0' && *current_cmd[0] <= '9')
+ {
+ tmp = tmp * 10 + *current_cmd[0] - '0';
+ (*current_cmd)++;
+ }
+ return tmp;
+}