mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-13 07:57:35 +00:00
db1135b405
- include directory in CFLAGS and waitfordeps.sh - fixed VERSION macro
45 lines
789 B
C
45 lines
789 B
C
/* radare - LGPL - Copyright 2007-2012 pancake<nopcode.org> */
|
|
|
|
#include <r_userconf.h>
|
|
#include <r_util.h>
|
|
|
|
static int rax(const char *str) {
|
|
ut64 n;
|
|
if (*str=='q')
|
|
return 0;
|
|
n = r_num_math(NULL, str);
|
|
if (str[0]=='0'&&str[1]=='x')
|
|
printf("%"PFMT64d"\n", n);
|
|
else printf("0x%"PFMT64x"\n", n);
|
|
return 1;
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
int i;
|
|
char buf[1024];
|
|
|
|
if (argc == 1) {
|
|
while(!feof(stdin)) {
|
|
fgets(buf, 1023, stdin);
|
|
if (feof(stdin)) break;
|
|
buf[strlen(buf)-1] = '\0';
|
|
if (!rax(buf)) break;
|
|
}
|
|
return 0;
|
|
}
|
|
if (argv[1][0]=='-') {
|
|
switch(argv[1][1]) {
|
|
case 'h':
|
|
printf("Usage: rax2 [-hV] [expression]\n");
|
|
return 0;
|
|
case 'V':
|
|
printf("rax2 v"R2_VERSION"\n");
|
|
return 0;
|
|
}
|
|
}
|
|
for(i=1; i<argc; i++)
|
|
rax( argv[i] );
|
|
return 0;
|
|
}
|