radare2/libr/util/t/rax2.c
pancake 34435b1285 * Mental note: %lld/%llx does not exist on windows
- Use the macro PFMT64{xod} in case
2010-04-14 13:02:23 +02:00

44 lines
762 B
C

/* radare - LGPL - Copyright 2007-2009 pancake<nopcode.org> */
#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"VERSION"\n");
return 0;
}
}
for(i=1; i<argc; i++)
rax( argv[i] );
return 0;
}