aboutsummaryrefslogtreecommitdiff
path: root/src/vatoi.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/vatoi.cc')
-rw-r--r--src/vatoi.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/vatoi.cc b/src/vatoi.cc
new file mode 100644
index 0000000..9044cc4
--- /dev/null
+++ b/src/vatoi.cc
@@ -0,0 +1,22 @@
+#include "vatoi.hh"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int vatoi(char *p){
+ char param[128];
+ strcpy(param,p);
+ char *offset;
+ int n;
+ if((offset=strchr(param,'k')) || (offset=strchr(param,'K')) ){
+ *offset='\0';
+ n=1024;
+ }
+ else if((offset=strchr(param,'m')) || (offset=strchr(param,'M')) ){
+ *offset='\0';
+ n=1024*1024;
+ }
+ else n=1;
+ n*=atoi(param);
+ return n;
+}