2009-02-05 21:08:46 +00:00
|
|
|
#ifndef _INCLUDE_UTIL_R_
|
|
|
|
#define _INCLUDE_UTIL_R_
|
|
|
|
|
2010-02-15 21:59:26 +00:00
|
|
|
#include <r_types.h>
|
2009-04-04 19:38:59 +00:00
|
|
|
#include <btree.h>
|
2010-02-15 21:59:26 +00:00
|
|
|
#include <r_list.h> // radare linked list
|
|
|
|
#include <r_flist.h> // radare fixed pointer array iterators
|
|
|
|
#include <list.h> // kernel linked list
|
2009-12-24 02:17:53 +00:00
|
|
|
/* profiling */
|
|
|
|
#include <sys/time.h>
|
2010-05-24 09:15:32 +00:00
|
|
|
#ifdef HAVE_LIB_GMP
|
|
|
|
#include <gmp.h>
|
|
|
|
#endif
|
2009-12-16 19:14:06 +00:00
|
|
|
|
2010-02-15 21:59:26 +00:00
|
|
|
/* empty classes */
|
|
|
|
typedef struct { } RSystem;
|
2010-02-18 17:58:28 +00:00
|
|
|
typedef struct { } RStr;
|
2010-02-15 21:59:26 +00:00
|
|
|
typedef struct { } RLog;
|
|
|
|
|
2009-12-22 12:27:43 +00:00
|
|
|
typedef struct r_mem_pool_t {
|
2009-09-22 11:27:33 +00:00
|
|
|
void **nodes;
|
|
|
|
int ncount;
|
|
|
|
int npool;
|
|
|
|
//
|
|
|
|
int nodesize;
|
|
|
|
int poolsize;
|
|
|
|
int poolcount;
|
2010-01-26 00:28:33 +00:00
|
|
|
} RMemoryPool;
|
2009-09-22 11:27:33 +00:00
|
|
|
|
2009-12-22 12:27:43 +00:00
|
|
|
typedef struct r_buf_t {
|
2009-09-08 01:08:46 +00:00
|
|
|
ut8 *buf;
|
|
|
|
int length;
|
2010-01-23 12:42:44 +00:00
|
|
|
int cur;
|
2009-09-08 01:08:46 +00:00
|
|
|
ut64 base;
|
2010-01-26 00:28:33 +00:00
|
|
|
} RBuffer;
|
2009-09-08 01:08:46 +00:00
|
|
|
|
2009-03-27 11:28:25 +00:00
|
|
|
/* r_cache */
|
|
|
|
// TOTHINK: move into a separated library?
|
2009-12-22 12:27:43 +00:00
|
|
|
typedef struct r_cache_item_t {
|
2009-07-08 11:49:55 +00:00
|
|
|
ut64 addr;
|
2009-03-27 11:28:25 +00:00
|
|
|
char *str;
|
|
|
|
struct list_head list;
|
2010-01-26 00:28:33 +00:00
|
|
|
} RCacheItem;
|
2009-03-27 11:28:25 +00:00
|
|
|
|
2009-12-22 12:27:43 +00:00
|
|
|
typedef struct r_cache_t {
|
2009-12-16 19:14:06 +00:00
|
|
|
ut64 start;
|
|
|
|
ut64 end;
|
2009-03-27 11:28:25 +00:00
|
|
|
struct list_head items;
|
2010-01-26 00:28:33 +00:00
|
|
|
} RCache;
|
2009-03-27 11:28:25 +00:00
|
|
|
|
2009-12-24 02:17:53 +00:00
|
|
|
typedef struct r_prof_t {
|
|
|
|
struct timeval begin;
|
|
|
|
double result;
|
2010-01-26 00:28:33 +00:00
|
|
|
} RProfile;
|
2009-12-24 02:17:53 +00:00
|
|
|
|
|
|
|
/* numbers */
|
|
|
|
typedef struct r_num_t {
|
|
|
|
ut64 (*callback)(void *userptr, const char *str, int *ok);
|
2010-03-30 15:37:15 +00:00
|
|
|
// RNumCallback callback;
|
2009-12-24 02:17:53 +00:00
|
|
|
ut64 value;
|
|
|
|
void *userptr;
|
2010-01-26 00:28:33 +00:00
|
|
|
} RNum;
|
|
|
|
typedef ut64 (*RNumCallback)(RNum *self, const char *str, int *ok);
|
2009-12-24 02:17:53 +00:00
|
|
|
|
2010-03-03 01:41:41 +00:00
|
|
|
typedef struct r_range_item_t {
|
|
|
|
ut64 fr;
|
|
|
|
ut64 to;
|
|
|
|
ut8 *data;
|
|
|
|
int datalen;
|
|
|
|
} RRangeItem;
|
|
|
|
|
|
|
|
typedef struct r_range_t {
|
|
|
|
int count;
|
|
|
|
int changed;
|
2010-06-04 21:47:35 +00:00
|
|
|
RList *ranges;
|
2010-03-03 01:41:41 +00:00
|
|
|
} RRange;
|
|
|
|
|
|
|
|
#ifdef R_API
|
2010-03-04 00:46:25 +00:00
|
|
|
/* bitsize */
|
|
|
|
enum {
|
|
|
|
R_SYS_BITS_8 = 1,
|
|
|
|
R_SYS_BITS_16 = 2,
|
|
|
|
R_SYS_BITS_32 = 4,
|
|
|
|
R_SYS_BITS_64 = 8,
|
|
|
|
};
|
2010-03-03 01:41:41 +00:00
|
|
|
|
2010-02-22 01:42:29 +00:00
|
|
|
/* arch */
|
2010-02-22 11:42:43 +00:00
|
|
|
// TODO: This must deprecate DEFAULT_ARCH??
|
2010-02-22 01:42:29 +00:00
|
|
|
#if __i386__
|
2010-02-22 11:42:43 +00:00
|
|
|
#define R_SYS_ARCH "x86"
|
2010-03-04 00:46:25 +00:00
|
|
|
#define R_SYS_BITS R_SYS_BITS_32
|
2010-02-22 01:42:29 +00:00
|
|
|
#elif __x86_64__
|
2010-03-05 12:18:44 +00:00
|
|
|
#define R_SYS_ARCH "x86"
|
2010-03-04 11:43:16 +00:00
|
|
|
#define R_SYS_BITS (R_SYS_BITS_32 | R_SYS_BITS_64)
|
2010-02-22 01:42:29 +00:00
|
|
|
#elif __POWERPC__
|
|
|
|
#define R_SYS_ARCH "powerpc"
|
2010-03-04 00:46:25 +00:00
|
|
|
#define R_SYS_BITS R_SYS_BITS_32
|
2010-02-22 01:42:29 +00:00
|
|
|
#elif __arm__
|
|
|
|
#define R_SYS_ARCH "arm"
|
2010-03-04 00:46:25 +00:00
|
|
|
#define R_SYS_BITS R_SYS_BITS_32
|
2010-02-22 01:42:29 +00:00
|
|
|
#elif __sparc__
|
|
|
|
#define R_SYS_ARCH "sparc"
|
2010-03-04 00:46:25 +00:00
|
|
|
#define R_SYS_BITS R_SYS_BITS_32
|
2010-02-22 01:42:29 +00:00
|
|
|
#elif __mips__
|
|
|
|
#define R_SYS_ARCH "mips"
|
2010-03-04 00:46:25 +00:00
|
|
|
#define R_SYS_BITS R_SYS_BITS_32
|
2010-02-22 01:42:29 +00:00
|
|
|
#else
|
|
|
|
#define R_SYS_ARCH "unknown"
|
2010-03-04 00:46:25 +00:00
|
|
|
#define R_SYS_BITS R_SYS_BITS_32
|
2010-02-22 01:42:29 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* os */
|
|
|
|
#if __APPLE__
|
|
|
|
#define R_SYS_OS "darwin"
|
|
|
|
#elif __linux__
|
|
|
|
#define R_SYS_OS "linux"
|
2010-03-04 00:46:25 +00:00
|
|
|
#elif __WIN32__ || __CYGWIN__ || MINGW32
|
|
|
|
#define R_SYS_OS "windows"
|
2010-02-22 01:42:29 +00:00
|
|
|
#elif __NetBSD__
|
|
|
|
#define R_SYS_OS "netbsd"
|
|
|
|
#elif __OpenBSD__
|
|
|
|
#define R_SYS_OS "openbsd"
|
|
|
|
#elif __FreeBSD__
|
|
|
|
#define R_SYS_OS "freebsd"
|
|
|
|
#else
|
|
|
|
#define R_SYS_OS "unknown"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* endian */
|
|
|
|
#if LIL_ENDIAN
|
|
|
|
#define R_SYS_ENDIAN "little"
|
|
|
|
#else
|
|
|
|
#define R_SYS_ENDIAN "big"
|
|
|
|
#endif
|
|
|
|
|
2010-02-15 21:59:26 +00:00
|
|
|
R_API RNum *r_num_new(RNumCallback cb, void *ptr);
|
2009-12-24 02:17:53 +00:00
|
|
|
|
2010-01-23 12:42:44 +00:00
|
|
|
#define R_BUF_CUR -1
|
2010-02-15 21:59:26 +00:00
|
|
|
R_API RBuffer *r_buf_new();
|
|
|
|
R_API int r_buf_set_bits(RBuffer *b, int bitoff, int bitsize, ut64 value);
|
|
|
|
R_API int r_buf_set_bytes(RBuffer *b, ut8 *buf, int length);
|
|
|
|
R_API int r_buf_read_at(RBuffer *b, ut64 addr, ut8 *buf, int len);
|
|
|
|
R_API int r_buf_fread_at(RBuffer *b, ut64 addr, ut8 *buf, const char *fmt, int n);
|
|
|
|
R_API int r_buf_write_at(RBuffer *b, ut64 addr, const ut8 *buf, int len);
|
2010-03-18 23:36:28 +00:00
|
|
|
R_API int r_buf_fwrite_at (RBuffer *b, ut64 addr, ut8 *buf, const char *fmt, int n);
|
2010-02-15 21:59:26 +00:00
|
|
|
R_API void r_buf_free(RBuffer *b);
|
2009-12-24 02:17:53 +00:00
|
|
|
|
|
|
|
R_API struct r_mem_pool_t* r_mem_pool_deinit(struct r_mem_pool_t *pool);
|
|
|
|
R_API struct r_mem_pool_t *r_mem_pool_new(int nodesize, int poolsize, int poolcount);
|
|
|
|
R_API struct r_mem_pool_t *r_mem_pool_free(struct r_mem_pool_t *pool);
|
|
|
|
R_API void* r_mem_pool_alloc(struct r_mem_pool_t *pool);
|
|
|
|
R_API int r_mem_count(ut8 **addr);
|
2010-01-26 00:28:33 +00:00
|
|
|
R_API RCache* r_cache_new();
|
2009-05-20 12:41:04 +00:00
|
|
|
R_API void r_cache_free(struct r_cache_t *c);
|
2009-07-08 11:49:55 +00:00
|
|
|
R_API char *r_cache_get(struct r_cache_t *c, ut64 addr);
|
|
|
|
R_API int r_cache_set(struct r_cache_t *c, ut64 addr, char *str);
|
|
|
|
R_API int r_cache_validate(struct r_cache_t *c, ut64 from, ut64 to);
|
|
|
|
R_API int r_cache_invalidate(struct r_cache_t *c, ut64 from, ut64 to);
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2009-09-17 12:02:44 +00:00
|
|
|
R_API void r_prof_start(struct r_prof_t *p);
|
|
|
|
R_API double r_prof_end(struct r_prof_t *p);
|
2009-03-13 11:28:36 +00:00
|
|
|
|
2010-04-08 16:01:45 +00:00
|
|
|
R_API int r_mem_eq(ut8 *a, ut8 *b, int len);
|
2009-09-19 19:54:22 +00:00
|
|
|
R_API void r_mem_copybits(ut8 *dst, const ut8 *src, int bits);
|
2009-09-17 12:02:44 +00:00
|
|
|
R_API void r_mem_copyloop (ut8 *dest, const ut8 *orig, int dsize, int osize);
|
|
|
|
R_API void r_mem_copyendian (ut8 *dest, const ut8 *orig, int size, int endian);
|
|
|
|
R_API int r_mem_cmp_mask(const ut8 *dest, const ut8 *orig, const ut8 *mask, int len);
|
2009-07-16 00:30:20 +00:00
|
|
|
R_API const ut8 *r_mem_mem(const ut8 *haystack, int hlen, const ut8 *needle, int nlen);
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2010-03-12 11:15:35 +00:00
|
|
|
#define r_num_abs(x) x>0?x:-x
|
2009-07-08 11:49:55 +00:00
|
|
|
R_API void r_num_minmax_swap(ut64 *a, ut64 *b);
|
2009-12-22 12:27:43 +00:00
|
|
|
R_API void r_num_minmax_swap_i(int *a, int *b); // XXX this can be a cpp macro :??
|
2009-07-08 11:49:55 +00:00
|
|
|
R_API ut64 r_num_math(struct r_num_t *num, const char *str);
|
|
|
|
R_API ut64 r_num_get(struct r_num_t *num, const char *str);
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2009-04-02 10:23:32 +00:00
|
|
|
/* TODO ..use as uppercase maybe? they are macros! */
|
2010-02-22 11:42:43 +00:00
|
|
|
#define r_offsetof(type, member) ((unsigned long) &((type*)0)->member)
|
2009-02-05 21:08:46 +00:00
|
|
|
#define strnull(x) (!x||!*x)
|
|
|
|
#define iswhitechar(x) (x==' '||x=='\t'||x=='\n'||x=='\r')
|
|
|
|
#define iswhitespace(x) (x==' '||x=='\t')
|
2009-04-21 10:11:07 +00:00
|
|
|
#define isseparator(x) (x==' '||x=='\t'||x=='\n'||x=='\r'||x==' '|| \
|
2010-01-26 00:28:33 +00:00
|
|
|
x==','||x==';'||x==':'||x=='['||x==']'||x=='('||x==')'||x=='{'||x=='}')
|
2009-02-05 21:08:46 +00:00
|
|
|
#define ishexchar(x) ((x>='0'&&x<='9') || (x>='a'&&x<='f') || (x>='A'&&x<='F')) {
|
|
|
|
|
2010-02-22 11:42:43 +00:00
|
|
|
/* strings */
|
2010-03-30 22:30:25 +00:00
|
|
|
#define r_str_write(x,y) write (x, y, strlen(y))
|
2010-04-08 10:29:47 +00:00
|
|
|
R_API int r_str_rwx(const char *str);
|
|
|
|
R_API const char *r_str_rwx_i(int rwx);
|
2010-03-30 23:06:26 +00:00
|
|
|
R_API void r_str_writef(int fd, const char *fmt, ...);
|
2010-02-22 23:26:13 +00:00
|
|
|
R_API char **r_str_argv(const char *str, int *_argc);
|
|
|
|
R_API void r_str_argv_free(char **argv);
|
2010-02-15 21:59:26 +00:00
|
|
|
R_API char *r_str_new(char *str);
|
2009-08-22 01:54:24 +00:00
|
|
|
R_API const char *r_str_bool(int b);
|
2009-05-20 12:41:04 +00:00
|
|
|
R_API const char *r_str_ansi_chrn(const char *str, int n);
|
|
|
|
R_API int r_str_ansi_len(const char *str);
|
|
|
|
R_API int r_str_word_count(const char *string);
|
2009-08-14 01:44:12 +00:00
|
|
|
R_API int r_str_char_count(const char *string, char ch);
|
2009-05-20 12:41:04 +00:00
|
|
|
R_API int r_str_word_set0(char *str);
|
2009-07-16 10:38:49 +00:00
|
|
|
R_API char *r_str_word_get0(char *str, int idx);
|
2009-05-20 12:41:04 +00:00
|
|
|
R_API char *r_str_word_get_first(const char *string);
|
|
|
|
R_API char *r_str_chop(char *str);
|
2009-04-06 22:53:25 +00:00
|
|
|
R_API const char *r_str_chop_ro(const char *str);
|
2009-04-11 16:49:09 +00:00
|
|
|
R_API char *r_str_trim(char *str);
|
2009-12-31 00:34:15 +00:00
|
|
|
R_API char *r_str_trim_head(char *str);
|
|
|
|
R_API char *r_str_trim_tail(char *str);
|
|
|
|
R_API char *r_str_trim_head_tail(char *str);
|
2009-05-20 12:41:04 +00:00
|
|
|
R_API int r_str_hash(const char *str);
|
2010-04-09 11:24:40 +00:00
|
|
|
R_API ut64 r_str_hash64(const char *str);
|
2009-05-20 12:41:04 +00:00
|
|
|
R_API char *r_str_clean(char *str);
|
|
|
|
R_API int r_str_nstr(char *from, char *to, int size);
|
|
|
|
R_API char *r_str_lchr(char *str, char chr);
|
|
|
|
R_API int r_str_nchr(const char *str, char chr);
|
|
|
|
R_API char *r_str_ichr(char *str, char chr);
|
|
|
|
R_API int r_str_ccmp(const char *dst, const char *orig, int ch);
|
|
|
|
R_API int r_str_cmp(const char *dst, const char *orig, int len);
|
|
|
|
R_API int r_str_ccpy(char *dst, char *orig, int ch);
|
|
|
|
R_API const char *r_str_get(const char *str);
|
|
|
|
R_API char *r_str_dup(char *ptr, const char *string);
|
2009-07-05 14:49:47 +00:00
|
|
|
R_API char *r_str_dup_printf(const char *fmt, ...);
|
2009-05-20 12:41:04 +00:00
|
|
|
R_API void *r_str_free(void *ptr);
|
|
|
|
R_API int r_str_inject(char *begin, char *end, char *str, int maxlen);
|
|
|
|
R_API int r_str_delta(char *p, char a, char b);
|
2010-03-04 00:46:25 +00:00
|
|
|
R_API void r_str_filter(char *str, int len);
|
2009-05-20 12:41:04 +00:00
|
|
|
|
|
|
|
R_API int r_str_re_match(const char *str, const char *reg);
|
|
|
|
R_API int r_str_re_replace(const char *str, const char *reg, const char *sub);
|
|
|
|
R_API char *r_str_sub(char *string, char *pat, char *rep, int global);
|
|
|
|
R_API int r_str_escape(char *buf);
|
2010-06-20 22:48:06 +00:00
|
|
|
R_API char *r_str_unscape(char *buf);
|
2009-05-20 12:41:04 +00:00
|
|
|
R_API char *r_str_home(const char *str);
|
|
|
|
R_API char *r_str_concat(char *ptr, const char *string);
|
|
|
|
R_API char *r_str_concatf(char *ptr, const char *fmt, ...);
|
2010-04-14 20:28:45 +00:00
|
|
|
R_API char *r_str_concatch(char *x, char y);
|
2010-02-21 19:21:36 +00:00
|
|
|
R_API void r_str_case(char *str, int up);
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2009-05-20 12:41:04 +00:00
|
|
|
R_API int r_hex_pair2bin(const char *arg);
|
2010-04-08 16:01:45 +00:00
|
|
|
R_API int r_hex_str2binmask(const char *in, ut8 *out, ut8 *mask);
|
2009-07-08 11:49:55 +00:00
|
|
|
R_API int r_hex_str2bin(const char *in, ut8 *out);
|
|
|
|
R_API int r_hex_bin2str(const ut8 *in, int len, char *out);
|
2009-07-24 13:38:53 +00:00
|
|
|
R_API char *r_hex_bin2strdup(const ut8 *in, int len);
|
2009-07-08 11:49:55 +00:00
|
|
|
R_API int r_hex_to_byte(ut8 *val, ut8 c);
|
2010-05-14 21:04:10 +00:00
|
|
|
R_API st64 r_hex_bin_truncate (ut64 in, int n);
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2009-05-20 12:41:04 +00:00
|
|
|
R_API char *r_file_path(const char *bin);
|
2010-03-03 10:35:03 +00:00
|
|
|
R_API const char *r_file_basename (const char *path);
|
2010-02-20 05:40:02 +00:00
|
|
|
R_API const char *r_file_abspath(const char *file);
|
2009-05-20 12:41:04 +00:00
|
|
|
R_API char *r_file_slurp(const char *str, int *usz);
|
2010-04-13 19:19:54 +00:00
|
|
|
//R_API char *r_file_slurp_range(const char *str, ut64 off, ut64 sz);
|
|
|
|
R_API char *r_file_slurp_range(const char *str, ut64 off, int sz, int *osz);
|
2009-05-20 12:41:04 +00:00
|
|
|
R_API char *r_file_slurp_random_line(const char *file);
|
2009-07-08 11:49:55 +00:00
|
|
|
R_API ut8 *r_file_slurp_hexpairs(const char *str, int *usz);
|
|
|
|
R_API int r_file_dump(const char *file, const ut8 *buf, int len);
|
2009-05-20 12:41:04 +00:00
|
|
|
R_API int r_file_rm(const char *file);
|
|
|
|
R_API int r_file_exist(const char *str);
|
|
|
|
R_API char *r_file_slurp_line(const char *file, int line, int context);
|
|
|
|
|
2010-03-12 17:46:11 +00:00
|
|
|
R_API ut64 r_sys_now();
|
2010-04-14 21:56:27 +00:00
|
|
|
R_API void r_sys_perror(const char *fun);
|
2010-03-30 22:03:59 +00:00
|
|
|
R_API int r_sys_mkdir(const char *dir);
|
2009-05-20 12:41:04 +00:00
|
|
|
R_API int r_sys_sleep(int secs);
|
|
|
|
R_API int r_sys_usleep(int usecs);
|
2009-04-03 11:11:17 +00:00
|
|
|
R_API const char *r_sys_getenv(const char *key);
|
2010-04-12 00:22:52 +00:00
|
|
|
R_API int r_sys_setenv(const char *key, const char *value);
|
2010-02-19 18:59:22 +00:00
|
|
|
R_API char *r_sys_getcwd();
|
2009-12-30 10:03:18 +00:00
|
|
|
R_API char *r_sys_cmd_str_full(const char *cmd, const char *input, int *len, char **sterr);
|
2010-04-12 00:22:52 +00:00
|
|
|
#if __WINDOWS__
|
|
|
|
R_API char *r_sys_cmd_str_w32(const char *cmd);
|
|
|
|
#endif
|
2010-02-02 10:09:52 +00:00
|
|
|
R_API int r_sys_cmd(const char *cmd);
|
2010-02-15 21:59:26 +00:00
|
|
|
R_API char *r_sys_cmd_str(const char *cmd, const char *input, int *len);
|
2010-04-13 19:19:54 +00:00
|
|
|
R_API char *r_sys_cmd_strf(const char *cmd, ...);
|
2010-02-15 21:59:26 +00:00
|
|
|
//#define r_sys_cmd_str(cmd, input, len) r_sys_cmd_str_full(cmd, input, len, 0)
|
2010-06-30 00:30:07 +00:00
|
|
|
R_API void r_sys_backtrace(void);
|
2009-12-22 12:27:43 +00:00
|
|
|
R_API int r_alloca_init();
|
|
|
|
R_API ut8 *r_alloca_bytes(int len);
|
|
|
|
R_API char *r_alloca_str(const char *str);
|
|
|
|
R_API int r_alloca_ret_i(int n);
|
2010-02-15 21:59:26 +00:00
|
|
|
|
|
|
|
/* LOG */
|
2010-07-11 22:50:00 +00:00
|
|
|
R_API void r_log_msg(const char *str);
|
|
|
|
R_API void r_log_error(const char *str);
|
|
|
|
R_API void r_log_file(const char *str);
|
|
|
|
R_API void r_log_progress(const char *str, int percent);
|
2010-03-03 01:41:41 +00:00
|
|
|
|
|
|
|
/* Ranges */
|
|
|
|
R_API RRange *r_range_new();
|
|
|
|
R_API RRange *r_range_new_from_string(const char *string);
|
|
|
|
R_API RRange *r_range_free(RRange *r);
|
|
|
|
R_API struct r_range_item_t *r_range_item_get(RRange *r, ut64 addr);
|
|
|
|
R_API ut64 r_range_size(RRange *r);
|
|
|
|
R_API int r_range_add_from_string(RRange *rgs, const char *string);
|
|
|
|
R_API struct r_range_item_t *r_range_add(RRange *rgs, ut64 from, ut64 to, int rw);
|
|
|
|
R_API int r_range_sub(RRange *rgs, ut64 from, ut64 to);
|
2010-06-04 21:47:35 +00:00
|
|
|
R_API void r_range_merge(RRange *rgs, RRange *r);
|
2010-03-03 01:41:41 +00:00
|
|
|
R_API int r_range_contains(RRange *rgs, ut64 addr);
|
|
|
|
R_API int r_range_sort(RRange *rgs);
|
|
|
|
R_API void r_range_percent(RRange *rgs);
|
|
|
|
R_API int r_range_list(RRange *rgs, int rad);
|
|
|
|
R_API int r_range_get_n(RRange *rgs, int n, ut64 *from, ut64 *to);
|
|
|
|
R_API RRange *r_range_inverse(RRange *rgs, ut64 from, ut64 to, int flags);
|
2010-03-30 15:37:15 +00:00
|
|
|
R_API int r_range_overlap(ut64 a0, ut64 a1, ut64 b0, ut64 b1, int *d);
|
2010-05-23 23:31:22 +00:00
|
|
|
|
|
|
|
/* big */
|
2010-05-24 09:15:32 +00:00
|
|
|
#ifdef HAVE_LIB_GMP
|
|
|
|
#define RNumBig mpz_t
|
|
|
|
#else
|
|
|
|
#define R_BIG_SIZE 10000
|
2010-05-23 23:31:22 +00:00
|
|
|
typedef struct r_num_big_t {
|
2010-05-24 09:15:32 +00:00
|
|
|
char dgts[R_BIG_SIZE];
|
2010-05-23 23:31:22 +00:00
|
|
|
int sign, last;
|
|
|
|
} RNumBig;
|
2010-05-24 09:15:32 +00:00
|
|
|
#endif
|
2010-05-24 00:27:05 +00:00
|
|
|
|
|
|
|
R_API RNumBig *r_big_new(RNumBig *b);
|
|
|
|
R_API void r_big_free(RNumBig *b);
|
2010-05-23 23:31:22 +00:00
|
|
|
R_API void r_big_sub(RNumBig *a, RNumBig *b, RNumBig *c);
|
|
|
|
R_API void r_big_print(RNumBig *n);
|
2010-05-24 16:35:08 +00:00
|
|
|
R_API void r_big_set(RNumBig *a, RNumBig *b);
|
|
|
|
R_API void r_big_set_st(RNumBig *n, int v);
|
|
|
|
R_API void r_big_set_st64(RNumBig *n, st64 v);
|
2010-05-24 00:27:05 +00:00
|
|
|
R_API void r_big_set_str(RNumBig *n, const char *str);
|
2010-05-23 23:31:22 +00:00
|
|
|
R_API void r_big_add (RNumBig *c, RNumBig *a, RNumBig *b);
|
|
|
|
R_API void r_big_sub(RNumBig *c, RNumBig *a, RNumBig *b);
|
|
|
|
R_API int r_big_cmp(RNumBig *a, RNumBig *b);
|
2010-05-24 16:35:08 +00:00
|
|
|
R_API int r_big_cmp_st(RNumBig *n, int v);
|
2010-05-23 23:31:22 +00:00
|
|
|
R_API void r_big_shift(RNumBig *n, int d);
|
|
|
|
R_API void r_big_mul (RNumBig *c, RNumBig *a, RNumBig *b);
|
2010-05-24 16:35:08 +00:00
|
|
|
R_API void r_big_mul_ut (RNumBig *c, RNumBig *a, ut32 b);
|
2010-05-23 23:31:22 +00:00
|
|
|
R_API void r_big_div(RNumBig *c, RNumBig *a, RNumBig *b);
|
2010-05-24 16:35:08 +00:00
|
|
|
R_API void r_big_div_ut(RNumBig *a, RNumBig *b, ut32 c);
|
|
|
|
R_API int r_big_divisible_ut(RNumBig *n, ut32 v);
|
2010-05-24 00:27:05 +00:00
|
|
|
R_API void r_big_mod(RNumBig *c, RNumBig *a, RNumBig *b);
|
2009-12-24 02:17:53 +00:00
|
|
|
#endif
|
2009-10-12 15:41:52 +00:00
|
|
|
|
2009-02-05 21:08:46 +00:00
|
|
|
#endif
|