* Remove r_types_os and add r_types_base instead

- Now bindings are fully working
* Update r_bin vapi
* Fix r_bin example for python bindings
This commit is contained in:
Nibble 2010-02-20 18:24:45 +01:00
parent cdf7939df0
commit 71ae9afdc4
6 changed files with 76 additions and 79 deletions

View File

@ -2,7 +2,7 @@
#define _INCLUDE_R_TYPES_H_
#include <r_userconf.h>
#include <r_types_os.h>
#include <r_types_base.h>
/* provide a per-module debug-enabled feature */
#if R_DEBUG
@ -49,16 +49,16 @@
#define BITS2BYTES(x) ((x/8)+((x%8)?1:0))
#define ut64 unsigned long long
#define st64 long long
#define ut32 unsigned int
#define st32 int
#define ut16 unsigned short
#define ut8 unsigned char
#define st8 char
#define R_TRUE 1
#define R_FALSE 0
/* types */
#undef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 64
#undef _GNU_SOURCE
#define _GNU_SOURCE
// do we really need those undefs?
//#undef _XOPEN_SOURCE
//#define _XOPEN_SOURCE
//#undef _POSIX_C_SOURCE
//#define _POSIX_C_SOURCE
/* allocating */
#include <stdio.h>
@ -80,6 +80,40 @@ static inline int ERR(char *str, ...)
#define IS_PRINTABLE(x) (x>=' '&&x<='~')
#define IS_WHITESPACE(x) (x==' '||x=='\t')
/* operating system */
#undef __BSD__
#undef __UNIX__
#undef __WINDOWS__
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#define __BSD__ 1
#endif
#if __WIN32__ || __CYGWIN__ || MINGW32
#define __addr_t_defined
#include <windows.h>
#ifdef USE_SOCKETS
#include <winsock.h>
#undef USE_SOCKETS
#endif
#define __WINDOWS__ 1
#else
#define __UNIX__ 1
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/time.h>
#if __UNIX__
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#endif
#include <unistd.h>
/* Move outside */
#define _perror(str,file,line) \
{ char buf[128];sprintf(buf, "%s:%d %s", file,line,str);perror(buf); }
@ -87,26 +121,10 @@ static inline int ERR(char *str, ...)
#define eprintf(x,y...) fprintf(stderr,x,##y)
/* limits */
#define UT64_MAX 0xFFFFFFFFFFFFFFFFLL
#define UT64_GT0 0x8000000000000000LL
#define UT64_LT0 0x7FFFFFFFFFFFFFFFLL
#define UT64_MIN 0LL
#define UT64_32U 0xFFFFFFFF00000000LL
#define UT32_MIN 0
#define UT32_GT0 0x80000000
#define UT32_LT0 0x7FFFFFFF
#define UT32_MAX 0xFFFFFFFF
#define R_MAX(x,y) (x>y)?x:y
#define R_MIN(x,y) (x>y)?y:x
#define R_ABS(x) ((x<0)?-x:x)
#define R_FAIL -1
#define R_FALSE 0
#define R_TRUE 1
#define R_TRUFAE 2
#define R_FREE(x) { free(x); x = NULL; }
#if __WINDOWS__
@ -115,13 +133,11 @@ static inline int ERR(char *str, ...)
#define HAVE_REGEXP 1
#endif
#if 0
/* hacks for vala-list.h interaction */
#define list_entry_vala(pos, type, member) ((type)((char*)pos-(unsigned long)(&((type)0)->member)))
#define ralist_iterator(x) x->next
#define ralist_get(x,y) list_entry_vala(x, y, list); x=x->next
#define ralist_next(x) (x=x->next, (x != head))
#define ralist_free(x) (x)
#endif
#endif

View File

@ -0,0 +1,28 @@
#ifndef _INCLUDE_R_TYPES_BASE_H_
#define _INCLUDE_R_TYPES_BASE_H_
#define ut64 unsigned long long
#define st64 long long
#define ut32 unsigned int
#define st32 int
#define ut16 unsigned short
#define ut8 unsigned char
#define st8 char
#define R_FAIL -1
#define R_FALSE 0
#define R_TRUE 1
#define R_TRUFAE 2
/* limits */
#define UT64_MAX 0xFFFFFFFFFFFFFFFFLL
#define UT64_GT0 0x8000000000000000LL
#define UT64_LT0 0x7FFFFFFFFFFFFFFFLL
#define UT64_MIN 0LL
#define UT64_32U 0xFFFFFFFF00000000LL
#define UT32_MIN 0
#define UT32_GT0 0x80000000
#define UT32_LT0 0x7FFFFFFF
#define UT32_MAX 0xFFFFFFFF
#endif

View File

@ -1,47 +0,0 @@
#ifndef _INCLUDE_R_TYPES_OS_H_
#define _INCLUDE_R_TYPES_OS_H_
/* types */
#undef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 64
#undef _GNU_SOURCE
#define _GNU_SOURCE
// do we really need those undefs?
//#undef _XOPEN_SOURCE
//#define _XOPEN_SOURCE
//#undef _POSIX_C_SOURCE
//#define _POSIX_C_SOURCE
/* operating system */
#undef __BSD__
#undef __UNIX__
#undef __WINDOWS__
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#define __BSD__ 1
#endif
#if __WIN32__ || __CYGWIN__ || MINGW32
#define __addr_t_defined
#include <windows.h>
#ifdef USE_SOCKETS
#include <winsock.h>
#undef USE_SOCKETS
#endif
#define __WINDOWS__ 1
#else
#define __UNIX__ 1
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/time.h>
#if __UNIX__
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#endif
#include <unistd.h>
#endif

View File

@ -1,4 +1,5 @@
r_asm
r_bin
r_config
r_core
r_line
@ -12,4 +13,3 @@ r_diff
r_lib
r_search
r_syscall
r_bin

View File

@ -1,6 +1,6 @@
/* radare - LGPL - Copyright 2009 nibble<.ds@gmail.com> */
[CCode (cheader_filename="r_bin.h,r_flist.h,r_types.h", cprefix="r_bin_", lower_case_cprefix="r_bin_")]
[CCode (cheader_filename="r_bin.h,r_flist.h,r_types_base.h", cprefix="r_bin_", lower_case_cprefix="r_bin_")]
namespace Radare {
[Compact]
[CCode (cname="RBin", free_function="r_bin_free", cprefix="r_bin_")]

View File

@ -4,6 +4,6 @@ b = RBin ()
b.load("/bin/ls", None)
baddr= b.get_baddr()
print '-> Sections'
for i in b.get_symbols ():
for i in b.get_sections ():
print 'offset=0x%08x va=0x%08x size=%05i %s' % (
i.offset, baddr+i.rva, i.size, i.name)