aboutsummaryrefslogtreecommitdiff
path: root/src/vatoi.cc
blob: 9044cc43169db8e3d1114ebc53dd2af5b43342bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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;
}