Intentation consistency and misc formatting fixes

This commit is contained in:
gergely.erdelyi 2009-05-23 16:35:50 +00:00
parent f2e422d208
commit 7d468f3b94
13 changed files with 620 additions and 634 deletions

View File

@ -11,223 +11,222 @@ typedef struct
%feature("director") DBG_Hooks; %feature("director") DBG_Hooks;
%inline %{ %inline %{
int idaapi DBG_Callback(void *ud, int notification_code, va_list va); int idaapi DBG_Callback(void *ud, int notification_code, va_list va);
class DBG_Hooks class DBG_Hooks
{ {
public: public:
virtual ~DBG_Hooks() {}; virtual ~DBG_Hooks() {};
bool hook() { return hook_to_notification_point(HT_DBG, DBG_Callback, this); }; bool hook() { return hook_to_notification_point(HT_DBG, DBG_Callback, this); };
bool unhook() { return unhook_from_notification_point(HT_DBG, DBG_Callback, this); }; bool unhook() { return unhook_from_notification_point(HT_DBG, DBG_Callback, this); };
/* Hook functions to be overridden in Python */ /* Hook functions to be overridden in Python */
virtual void dbg_process_start(pid_t pid, virtual void dbg_process_start(pid_t pid,
thid_t tid, thid_t tid,
ea_t ea, ea_t ea,
char *name, char *name,
ea_t base, ea_t base,
asize_t size) { }; asize_t size) { };
virtual void dbg_process_exit(pid_t pid, virtual void dbg_process_exit(pid_t pid,
thid_t tid, thid_t tid,
ea_t ea, ea_t ea,
int exit_code) { }; int exit_code) { };
virtual void dbg_process_attach(pid_t pid, virtual void dbg_process_attach(pid_t pid,
thid_t tid, thid_t tid,
ea_t ea, ea_t ea,
char *name, char *name,
ea_t base, ea_t base,
asize_t size) { }; asize_t size) { };
virtual void dbg_process_detach(pid_t pid, virtual void dbg_process_detach(pid_t pid,
thid_t tid, thid_t tid,
ea_t ea) { }; ea_t ea) { };
virtual void dbg_thread_start(pid_t pid, virtual void dbg_thread_start(pid_t pid,
thid_t tid, thid_t tid,
ea_t ea) { }; ea_t ea) { };
virtual void dbg_thread_exit(pid_t pid, virtual void dbg_thread_exit(pid_t pid,
thid_t tid, thid_t tid,
ea_t ea, ea_t ea,
int exit_code) { }; int exit_code) { };
virtual void dbg_library_load(pid_t pid, virtual void dbg_library_load(pid_t pid,
thid_t tid, thid_t tid,
ea_t ea, ea_t ea,
char *name, char *name,
ea_t base, ea_t base,
asize_t size) { }; asize_t size) { };
virtual void dbg_library_unload(pid_t pid, virtual void dbg_library_unload(pid_t pid,
thid_t tid, thid_t tid,
ea_t ea, ea_t ea,
char *libname) { }; char *libname) { };
virtual void dbg_information(pid_t pid, virtual void dbg_information(pid_t pid,
thid_t tid, thid_t tid,
ea_t ea, ea_t ea,
char *info) { }; char *info) { };
virtual int dbg_exception(pid_t pid, virtual int dbg_exception(pid_t pid,
thid_t tid, thid_t tid,
ea_t ea, ea_t ea,
int code, int code,
bool can_cont, bool can_cont,
ea_t exc_ea, ea_t exc_ea,
char *info) { return 0; }; char *info) { return 0; };
virtual void dbg_suspend_process(void) { }; virtual void dbg_suspend_process(void) { };
virtual int dbg_bpt(thid_t tid, ea_t breakpoint_ea) { return 0; }; virtual int dbg_bpt(thid_t tid, ea_t breakpoint_ea) { return 0; };
virtual int dbg_trace(thid_t tid, ea_t ip) { return 0; }; virtual int dbg_trace(thid_t tid, ea_t ip) { return 0; };
virtual void dbg_request_error(ui_notification_t failed_command, virtual void dbg_request_error(ui_notification_t failed_command,
dbg_notification_t failed_dbg_notification) { }; dbg_notification_t failed_dbg_notification) { };
virtual void dbg_step_into(void) { }; virtual void dbg_step_into(void) { };
virtual void dbg_step_over(void) { }; virtual void dbg_step_over(void) { };
virtual void dbg_run_to(thid_t tid) { }; virtual void dbg_run_to(thid_t tid) { };
virtual void dbg_step_until_ret(void) { }; virtual void dbg_step_until_ret(void) { };
}; };
int idaapi DBG_Callback(void *ud, int notification_code, va_list va) int idaapi DBG_Callback(void *ud, int notification_code, va_list va)
{ {
class DBG_Hooks *proxy = (class DBG_Hooks *)ud; class DBG_Hooks *proxy = (class DBG_Hooks *)ud;
debug_event_t *event; debug_event_t *event;
thid_t tid; thid_t tid;
int *warn; int *warn;
ea_t ip; ea_t ip;
ui_notification_t failed_command; ui_notification_t failed_command;
dbg_notification_t failed_dbg_notification; dbg_notification_t failed_dbg_notification;
ea_t breakpoint_ea; ea_t breakpoint_ea;
try { try {
switch (notification_code) switch (notification_code)
{ {
case dbg_process_start: case dbg_process_start:
event = va_arg(va, debug_event_t *); event = va_arg(va, debug_event_t *);
proxy->dbg_process_start(event->pid, proxy->dbg_process_start(event->pid,
event->tid, event->tid,
event->ea, event->ea,
event->modinfo.name, event->modinfo.name,
event->modinfo.base, event->modinfo.base,
event->modinfo.size); event->modinfo.size);
return 0; return 0;
case dbg_process_exit: case dbg_process_exit:
event = va_arg(va, debug_event_t *); event = va_arg(va, debug_event_t *);
proxy->dbg_process_exit(event->pid, proxy->dbg_process_exit(event->pid,
event->tid, event->tid,
event->ea, event->ea,
event->exit_code); event->exit_code);
return 0; return 0;
case dbg_process_attach: case dbg_process_attach:
event = va_arg(va, debug_event_t *); event = va_arg(va, debug_event_t *);
proxy->dbg_process_attach(event->pid, proxy->dbg_process_attach(event->pid,
event->tid, event->tid,
event->ea, event->ea,
event->modinfo.name, event->modinfo.name,
event->modinfo.base, event->modinfo.base,
event->modinfo.size); event->modinfo.size);
return 0; return 0;
case dbg_process_detach: case dbg_process_detach:
event = va_arg(va, debug_event_t *); event = va_arg(va, debug_event_t *);
proxy->dbg_process_detach(event->pid, proxy->dbg_process_detach(event->pid,
event->tid, event->tid,
event->ea); event->ea);
return 0; return 0;
case dbg_thread_start: case dbg_thread_start:
event = va_arg(va, debug_event_t *); event = va_arg(va, debug_event_t *);
proxy->dbg_thread_start(event->pid, proxy->dbg_thread_start(event->pid,
event->tid, event->tid,
event->ea); event->ea);
return 0; return 0;
case dbg_thread_exit: case dbg_thread_exit:
event = va_arg(va, debug_event_t *); event = va_arg(va, debug_event_t *);
proxy->dbg_thread_exit(event->pid, proxy->dbg_thread_exit(event->pid,
event->tid, event->tid,
event->ea, event->ea,
event->exit_code); event->exit_code);
return 0; return 0;
case dbg_library_load: case dbg_library_load:
event = va_arg(va, debug_event_t *); event = va_arg(va, debug_event_t *);
proxy->dbg_library_load(event->pid, proxy->dbg_library_load(event->pid,
event->tid, event->tid,
event->ea, event->ea,
event->modinfo.name, event->modinfo.name,
event->modinfo.base, event->modinfo.base,
event->modinfo.size); event->modinfo.size);
return 0; return 0;
case dbg_library_unload: case dbg_library_unload:
event = va_arg(va, debug_event_t *); event = va_arg(va, debug_event_t *);
proxy->dbg_library_unload(event->pid, proxy->dbg_library_unload(event->pid,
event->tid, event->tid,
event->ea, event->ea,
event->info); event->info);
return 0; return 0;
case dbg_information: case dbg_information:
event = va_arg(va, debug_event_t *); event = va_arg(va, debug_event_t *);
proxy->dbg_information(event->pid, proxy->dbg_information(event->pid,
event->tid, event->tid,
event->ea, event->ea,
event->info); event->info);
return 0; return 0;
case dbg_exception: case dbg_exception:
event = va_arg(va, debug_event_t *); event = va_arg(va, debug_event_t *);
warn = va_arg(va, int *); warn = va_arg(va, int *);
*warn = proxy->dbg_exception(event->pid, *warn = proxy->dbg_exception(event->pid,
event->tid, event->tid,
event->ea, event->ea,
event->exc.code, event->exc.code,
event->exc.can_cont, event->exc.can_cont,
event->exc.ea, event->exc.ea,
event->exc.info); event->exc.info);
return 0; return 0;
case dbg_suspend_process: case dbg_suspend_process:
proxy->dbg_suspend_process(); proxy->dbg_suspend_process();
return 0; return 0;
case dbg_bpt: case dbg_bpt:
tid = va_arg(va, thid_t); tid = va_arg(va, thid_t);
breakpoint_ea = va_arg(va, ea_t); breakpoint_ea = va_arg(va, ea_t);
warn = va_arg(va, int *); warn = va_arg(va, int *);
*warn = proxy->dbg_bpt(tid, breakpoint_ea); *warn = proxy->dbg_bpt(tid, breakpoint_ea);
return 0; return 0;
case dbg_trace: case dbg_trace:
tid = va_arg(va, thid_t); tid = va_arg(va, thid_t);
ip = va_arg(va, ea_t); ip = va_arg(va, ea_t);
return proxy->dbg_bpt(tid, ip); return proxy->dbg_bpt(tid, ip);
case dbg_request_error: case dbg_request_error:
failed_command = (ui_notification_t)va_arg(va, int); failed_command = (ui_notification_t)va_arg(va, int);
failed_dbg_notification = (dbg_notification_t)va_arg(va, int); failed_dbg_notification = (dbg_notification_t)va_arg(va, int);
proxy->dbg_request_error(failed_command, failed_dbg_notification); proxy->dbg_request_error(failed_command, failed_dbg_notification);
return 0; return 0;
case dbg_step_into: case dbg_step_into:
proxy->dbg_step_into(); proxy->dbg_step_into();
return 0; return 0;
case dbg_step_over: case dbg_step_over:
proxy->dbg_step_over(); proxy->dbg_step_over();
return 0; return 0;
case dbg_run_to: case dbg_run_to:
tid = va_arg(va, thid_t); tid = va_arg(va, thid_t);
proxy->dbg_run_to(tid); proxy->dbg_run_to(tid);
return 0; return 0;
case dbg_step_until_ret: case dbg_step_until_ret:
proxy->dbg_step_until_ret(); proxy->dbg_step_until_ret();
return 0; return 0;
} }
} }
catch (Swig::DirectorException &e) catch (Swig::DirectorException &e)
{ {
msg("Exception in IDP Hook function:\n"); msg("Exception in IDP Hook function:\n");
if (PyErr_Occurred()) if (PyErr_Occurred())
{ {
PyErr_Print(); PyErr_Print();
} }
} }
} }
%} %}

View File

@ -38,7 +38,7 @@
bool CompileEx_wrap(const char *file, bool del_macros, bool CompileEx_wrap(const char *file, bool del_macros,
char *errbuf, size_t errbufsize) char *errbuf, size_t errbufsize)
{ {
return !CompileEx(file, del_macros, errbuf, errbufsize); return !CompileEx(file, del_macros, errbuf, errbufsize);
} }
%} %}
@ -46,7 +46,7 @@ bool CompileEx_wrap(const char *file, bool del_macros,
%inline %{ %inline %{
bool Compile_wrap(const char *file, char *errbuf, size_t errbufsize) bool Compile_wrap(const char *file, char *errbuf, size_t errbufsize)
{ {
return !Compile(file, errbuf, errbufsize); return !Compile(file, errbuf, errbufsize);
} }
%} %}
@ -54,7 +54,7 @@ bool Compile_wrap(const char *file, char *errbuf, size_t errbufsize)
%inline %{ %inline %{
bool calcexpr_wrap(ea_t where,const char *line, idc_value_t *rv, char *errbuf, size_t errbufsize) bool calcexpr_wrap(ea_t where,const char *line, idc_value_t *rv, char *errbuf, size_t errbufsize)
{ {
return !calcexpr(where, line, rv, errbuf, errbufsize); return !calcexpr(where, line, rv, errbuf, errbufsize);
} }
%} %}
@ -62,7 +62,7 @@ bool calcexpr_wrap(ea_t where,const char *line, idc_value_t *rv, char *errbuf, s
%inline %{ %inline %{
bool calc_idc_expr_wrap(ea_t where,const char *line, idc_value_t *rv, char *errbuf, size_t errbufsize) bool calc_idc_expr_wrap(ea_t where,const char *line, idc_value_t *rv, char *errbuf, size_t errbufsize)
{ {
return !calc_idc_expr(where, line, rv, errbuf, errbufsize); return !calc_idc_expr(where, line, rv, errbuf, errbufsize);
} }
%} %}
@ -72,7 +72,7 @@ bool calc_idc_expr_wrap(ea_t where,const char *line, idc_value_t *rv, char *errb
%inline %{ %inline %{
bool CompileLine_wrap(const char *line, char *errbuf, size_t errbufsize) bool CompileLine_wrap(const char *line, char *errbuf, size_t errbufsize)
{ {
return !CompileLine(line, errbuf, errbufsize); return !CompileLine(line, errbuf, errbufsize);
} }
%} %}

View File

@ -38,10 +38,10 @@
%inline %{ %inline %{
ea_t get_fchunk_referer(ea_t ea, size_t idx) ea_t get_fchunk_referer(ea_t ea, size_t idx)
{ {
func_t *pfn = get_fchunk(ea); func_t *pfn = get_fchunk(ea);
func_parent_iterator_t dummy(pfn); // read referer info func_parent_iterator_t dummy(pfn); // read referer info
if ( idx >= pfn->refqty || pfn->referers == NULL ) if (idx >= pfn->refqty || pfn->referers == NULL)
return BADADDR; return BADADDR;
return pfn->referers[idx]; return pfn->referers[idx];
} }
%} %}

View File

@ -124,7 +124,7 @@ typedef long long longlong;
/* Small wrapper to get the inf structure */ /* Small wrapper to get the inf structure */
idainfo *get_inf_structure(void) idainfo *get_inf_structure(void)
{ {
return &inf; return &inf;
} }
} }
@ -147,7 +147,7 @@ idainfo *get_inf_structure(void)
%include "xref.i" %include "xref.i"
%inline { %inline {
void set_script_timeout(int timeout); void set_script_timeout(int timeout);
void enable_extlang_python(bool enable); void enable_extlang_python(bool enable);
void enable_python_cli(bool enable); void enable_python_cli(bool enable);
} }

View File

@ -3,53 +3,51 @@
%include "idd.hpp" %include "idd.hpp"
%inline %{ %inline %{
char get_event_module_name(const debug_event_t* ev, char *buf, size_t bufsize) char get_event_module_name(const debug_event_t* ev, char *buf, size_t bufsize)
{ {
qstrncpy(buf, ev->modinfo.name, bufsize); qstrncpy(buf, ev->modinfo.name, bufsize);
return true; return true;
} }
ea_t get_event_module_base(const debug_event_t* ev) ea_t get_event_module_base(const debug_event_t* ev)
{ {
return ev->modinfo.base; return ev->modinfo.base;
} }
asize_t get_event_module_size(const debug_event_t* ev) asize_t get_event_module_size(const debug_event_t* ev)
{ {
return ev->modinfo.size; return ev->modinfo.size;
} }
char get_event_exc_info(const debug_event_t* ev, char *buf, size_t bufsize) char get_event_exc_info(const debug_event_t* ev, char *buf, size_t bufsize)
{ {
qstrncpy(buf, ev->exc.info, bufsize); qstrncpy(buf, ev->exc.info, bufsize);
return true; return true;
} }
char get_event_info(const debug_event_t* ev, char *buf, size_t bufsize) char get_event_info(const debug_event_t* ev, char *buf, size_t bufsize)
{ {
qstrncpy(buf, ev->info, bufsize); qstrncpy(buf, ev->info, bufsize);
return true; return true;
} }
ea_t get_event_bpt_hea(const debug_event_t* ev) ea_t get_event_bpt_hea(const debug_event_t* ev)
{ {
return ev->bpt.hea; return ev->bpt.hea;
} }
uint get_event_exc_code(const debug_event_t* ev) uint get_event_exc_code(const debug_event_t* ev)
{ {
return ev->exc.code; return ev->exc.code;
} }
ea_t get_event_exc_ea(const debug_event_t* ev) ea_t get_event_exc_ea(const debug_event_t* ev)
{ {
return ev->exc.ea; return ev->exc.ea;
} }
bool can_exc_continue(const debug_event_t* ev) bool can_exc_continue(const debug_event_t* ev)
{ {
return ev->exc.can_cont; return ev->exc.can_cont;
} }
%} %}

View File

@ -66,216 +66,215 @@
%feature("director") IDB_Hooks; %feature("director") IDB_Hooks;
%inline %{ %inline %{
int idaapi IDB_Callback(void *ud, int notification_code, va_list va); int idaapi IDB_Callback(void *ud, int notification_code, va_list va);
class IDB_Hooks class IDB_Hooks
{ {
public: public:
virtual ~IDB_Hooks() {}; virtual ~IDB_Hooks() {};
bool hook() { return hook_to_notification_point(HT_IDB, IDB_Callback, this); } bool hook() { return hook_to_notification_point(HT_IDB, IDB_Callback, this); }
bool unhook() { return unhook_from_notification_point(HT_IDB, IDB_Callback, this); } bool unhook() { return unhook_from_notification_point(HT_IDB, IDB_Callback, this); }
/* Hook functions to override in Python */ /* Hook functions to override in Python */
virtual int byte_patched(ea_t ea) { return 0; }; virtual int byte_patched(ea_t ea) { return 0; };
virtual int cmt_changed(ea_t, bool repeatable_cmt) { return 0; }; virtual int cmt_changed(ea_t, bool repeatable_cmt) { return 0; };
virtual int ti_changed(ea_t ea, const type_t *type, const p_list *fnames) { msg("ti_changed hook not supported yet\n"); return 0; }; virtual int ti_changed(ea_t ea, const type_t *type, const p_list *fnames) { msg("ti_changed hook not supported yet\n"); return 0; };
virtual int op_ti_changed(ea_t ea, int n, const type_t *type, const p_list *fnames) { msg("op_ti_changed hook not supported yet\n"); return 0; }; virtual int op_ti_changed(ea_t ea, int n, const type_t *type, const p_list *fnames) { msg("op_ti_changed hook not supported yet\n"); return 0; };
virtual int op_type_changed(ea_t ea, int n) { return 0; }; virtual int op_type_changed(ea_t ea, int n) { return 0; };
virtual int enum_created(enum_t id) { return 0; }; virtual int enum_created(enum_t id) { return 0; };
virtual int enum_deleted(enum_t id) { return 0; }; virtual int enum_deleted(enum_t id) { return 0; };
virtual int enum_bf_changed(enum_t id) { return 0; }; virtual int enum_bf_changed(enum_t id) { return 0; };
virtual int enum_renamed(enum_t id) { return 0; }; virtual int enum_renamed(enum_t id) { return 0; };
virtual int enum_cmt_changed(enum_t id) { return 0; }; virtual int enum_cmt_changed(enum_t id) { return 0; };
virtual int enum_const_created(enum_t id, const_t cid) { return 0; }; virtual int enum_const_created(enum_t id, const_t cid) { return 0; };
virtual int enum_const_deleted(enum_t id, const_t cid) { return 0; }; virtual int enum_const_deleted(enum_t id, const_t cid) { return 0; };
virtual int struc_created(tid_t struc_id) { return 0; }; virtual int struc_created(tid_t struc_id) { return 0; };
virtual int struc_deleted(tid_t struc_id) { return 0; }; virtual int struc_deleted(tid_t struc_id) { return 0; };
virtual int struc_renamed(struc_t *sptr) { return 0; }; virtual int struc_renamed(struc_t *sptr) { return 0; };
virtual int struc_expanded(struc_t *sptr) { return 0; }; virtual int struc_expanded(struc_t *sptr) { return 0; };
virtual int struc_cmt_changed(tid_t struc_id) { return 0; }; virtual int struc_cmt_changed(tid_t struc_id) { return 0; };
virtual int struc_member_created(struc_t *sptr, member_t *mptr) { return 0; }; virtual int struc_member_created(struc_t *sptr, member_t *mptr) { return 0; };
virtual int struc_member_deleted(struc_t *sptr, tid_t member_id) { return 0; }; virtual int struc_member_deleted(struc_t *sptr, tid_t member_id) { return 0; };
virtual int struc_member_renamed(struc_t *sptr, member_t *mptr) { return 0; }; virtual int struc_member_renamed(struc_t *sptr, member_t *mptr) { return 0; };
virtual int struc_member_changed(struc_t *sptr, member_t *mptr) { return 0; }; virtual int struc_member_changed(struc_t *sptr, member_t *mptr) { return 0; };
virtual int thunk_func_created(func_t *pfn) { return 0; }; virtual int thunk_func_created(func_t *pfn) { return 0; };
virtual int func_tail_appended(func_t *pfn, func_t *tail) { return 0; }; virtual int func_tail_appended(func_t *pfn, func_t *tail) { return 0; };
virtual int func_tail_removed(func_t *pfn, ea_t tail_ea) { return 0; }; virtual int func_tail_removed(func_t *pfn, ea_t tail_ea) { return 0; };
virtual int tail_owner_changed(func_t *tail, ea_t owner_func) { return 0; }; virtual int tail_owner_changed(func_t *tail, ea_t owner_func) { return 0; };
virtual int func_noret_changed(func_t *pfn) { return 0; }; virtual int func_noret_changed(func_t *pfn) { return 0; };
virtual int segm_added(segment_t *s) { return 0; }; virtual int segm_added(segment_t *s) { return 0; };
virtual int segm_deleted(ea_t startEA) { return 0; }; virtual int segm_deleted(ea_t startEA) { return 0; };
virtual int segm_start_changed(segment_t *s) { return 0; }; virtual int segm_start_changed(segment_t *s) { return 0; };
virtual int segm_end_changed(segment_t *s) { return 0; }; virtual int segm_end_changed(segment_t *s) { return 0; };
virtual int segm_moved(ea_t from, ea_t to, asize_t size) { return 0; }; virtual int segm_moved(ea_t from, ea_t to, asize_t size) { return 0; };
}; };
int idaapi IDB_Callback(void *ud, int notification_code, va_list va) int idaapi IDB_Callback(void *ud, int notification_code, va_list va)
{ {
class IDB_Hooks *proxy = (class IDB_Hooks *)ud; class IDB_Hooks *proxy = (class IDB_Hooks *)ud;
ea_t ea, ea2; ea_t ea, ea2;
bool repeatable_cmt; bool repeatable_cmt;
type_t *type; type_t *type;
/* p_list *fnames; */ /* p_list *fnames; */
int n; int n;
enum_t id; enum_t id;
const_t cid; const_t cid;
tid_t struc_id; tid_t struc_id;
struc_t *sptr; struc_t *sptr;
member_t *mptr; member_t *mptr;
tid_t member_id; tid_t member_id;
func_t *pfn; func_t *pfn;
func_t *tail; func_t *tail;
segment_t *seg; segment_t *seg;
asize_t size; asize_t size;
try { try {
switch (notification_code) switch (notification_code)
{ {
case idb_event::byte_patched: case idb_event::byte_patched:
ea = va_arg(va, ea_t); ea = va_arg(va, ea_t);
return proxy->byte_patched(ea); return proxy->byte_patched(ea);
case idb_event::cmt_changed: case idb_event::cmt_changed:
ea = va_arg(va, ea_t); ea = va_arg(va, ea_t);
repeatable_cmt = va_arg(va, int); repeatable_cmt = va_arg(va, int);
return proxy->cmt_changed(ea, repeatable_cmt); return proxy->cmt_changed(ea, repeatable_cmt);
#if 0 #if 0
case idb_event::ti_changed: case idb_event::ti_changed:
ea = va_arg(va, ea_t); ea = va_arg(va, ea_t);
type = va_arg(va, type_t *); type = va_arg(va, type_t *);
fnames = va_arg(va, fnames); fnames = va_arg(va, fnames);
return proxy->ti_changed(ea, type, fnames); return proxy->ti_changed(ea, type, fnames);
case idb_event::op_ti_changed: case idb_event::op_ti_changed:
ea = va_arg(va, ea_t); ea = va_arg(va, ea_t);
n = va_arg(va, int); n = va_arg(va, int);
type = va_arg(va, type_t *); type = va_arg(va, type_t *);
fnames = va_arg(va, fnames); fnames = va_arg(va, fnames);
return proxy->op_ti_changed(ea, n, type, fnames); return proxy->op_ti_changed(ea, n, type, fnames);
#endif #endif
case idb_event::op_type_changed: case idb_event::op_type_changed:
ea = va_arg(va, ea_t); ea = va_arg(va, ea_t);
n = va_arg(va, int); n = va_arg(va, int);
return proxy->op_type_changed(ea, n); return proxy->op_type_changed(ea, n);
case idb_event::enum_created: case idb_event::enum_created:
id = va_arg(va, enum_t); id = va_arg(va, enum_t);
return proxy->enum_created(id); return proxy->enum_created(id);
case idb_event::enum_deleted: case idb_event::enum_deleted:
id = va_arg(va, enum_t); id = va_arg(va, enum_t);
return proxy->enum_deleted(id); return proxy->enum_deleted(id);
case idb_event::enum_bf_changed: case idb_event::enum_bf_changed:
id = va_arg(va, enum_t); id = va_arg(va, enum_t);
return proxy->enum_bf_changed(id); return proxy->enum_bf_changed(id);
case idb_event::enum_cmt_changed: case idb_event::enum_cmt_changed:
id = va_arg(va, enum_t); id = va_arg(va, enum_t);
return proxy->enum_cmt_changed(id); return proxy->enum_cmt_changed(id);
case idb_event::enum_const_created: case idb_event::enum_const_created:
id = va_arg(va, enum_t); id = va_arg(va, enum_t);
cid = va_arg(va, const_t); cid = va_arg(va, const_t);
return proxy->enum_const_created(id, cid); return proxy->enum_const_created(id, cid);
case idb_event::enum_const_deleted: case idb_event::enum_const_deleted:
id = va_arg(va, enum_t); id = va_arg(va, enum_t);
cid = va_arg(va, const_t); cid = va_arg(va, const_t);
return proxy->enum_const_deleted(id, cid); return proxy->enum_const_deleted(id, cid);
case idb_event::struc_created: case idb_event::struc_created:
struc_id = va_arg(va, tid_t); struc_id = va_arg(va, tid_t);
return proxy->struc_created(struc_id); return proxy->struc_created(struc_id);
case idb_event::struc_deleted: case idb_event::struc_deleted:
struc_id = va_arg(va, tid_t); struc_id = va_arg(va, tid_t);
return proxy->struc_deleted(struc_id); return proxy->struc_deleted(struc_id);
case idb_event::struc_renamed: case idb_event::struc_renamed:
sptr = va_arg(va, struc_t *); sptr = va_arg(va, struc_t *);
return proxy->struc_renamed(sptr); return proxy->struc_renamed(sptr);
case idb_event::struc_expanded: case idb_event::struc_expanded:
sptr = va_arg(va, struc_t *); sptr = va_arg(va, struc_t *);
return proxy->struc_expanded(sptr); return proxy->struc_expanded(sptr);
case idb_event::struc_cmt_changed: case idb_event::struc_cmt_changed:
struc_id = va_arg(va, tid_t); struc_id = va_arg(va, tid_t);
return proxy->struc_cmt_changed(struc_id); return proxy->struc_cmt_changed(struc_id);
case idb_event::struc_member_created: case idb_event::struc_member_created:
sptr = va_arg(va, struc_t *); sptr = va_arg(va, struc_t *);
mptr = va_arg(va, member_t *); mptr = va_arg(va, member_t *);
return proxy->struc_member_created(sptr, mptr); return proxy->struc_member_created(sptr, mptr);
case idb_event::struc_member_deleted: case idb_event::struc_member_deleted:
sptr = va_arg(va, struc_t *); sptr = va_arg(va, struc_t *);
member_id = va_arg(va, tid_t); member_id = va_arg(va, tid_t);
return proxy->struc_member_deleted(sptr, member_id); return proxy->struc_member_deleted(sptr, member_id);
case idb_event::struc_member_renamed: case idb_event::struc_member_renamed:
sptr = va_arg(va, struc_t *); sptr = va_arg(va, struc_t *);
mptr = va_arg(va, member_t *); mptr = va_arg(va, member_t *);
return proxy->struc_member_renamed(sptr, mptr); return proxy->struc_member_renamed(sptr, mptr);
case idb_event::struc_member_changed: case idb_event::struc_member_changed:
sptr = va_arg(va, struc_t *); sptr = va_arg(va, struc_t *);
mptr = va_arg(va, member_t *); mptr = va_arg(va, member_t *);
return proxy->struc_member_changed(sptr, mptr); return proxy->struc_member_changed(sptr, mptr);
case idb_event::thunk_func_created: case idb_event::thunk_func_created:
pfn = va_arg(va, func_t *); pfn = va_arg(va, func_t *);
return proxy->thunk_func_created(pfn); return proxy->thunk_func_created(pfn);
case idb_event::func_tail_appended: case idb_event::func_tail_appended:
pfn = va_arg(va, func_t *); pfn = va_arg(va, func_t *);
tail = va_arg(va, func_t *); tail = va_arg(va, func_t *);
return proxy->func_tail_appended(pfn, tail); return proxy->func_tail_appended(pfn, tail);
case idb_event::func_tail_removed: case idb_event::func_tail_removed:
pfn = va_arg(va, func_t *); pfn = va_arg(va, func_t *);
ea = va_arg(va, ea_t); ea = va_arg(va, ea_t);
return proxy->func_tail_removed(pfn, ea); return proxy->func_tail_removed(pfn, ea);
case idb_event::tail_owner_changed: case idb_event::tail_owner_changed:
tail = va_arg(va, func_t *); tail = va_arg(va, func_t *);
ea = va_arg(va, ea_t); ea = va_arg(va, ea_t);
return proxy->tail_owner_changed(tail, ea); return proxy->tail_owner_changed(tail, ea);
case idb_event::func_noret_changed: case idb_event::func_noret_changed:
pfn = va_arg(va, func_t *); pfn = va_arg(va, func_t *);
return proxy->func_noret_changed(pfn); return proxy->func_noret_changed(pfn);
case idb_event::segm_added: case idb_event::segm_added:
seg = va_arg(va, segment_t *); seg = va_arg(va, segment_t *);
return proxy->segm_added(seg); return proxy->segm_added(seg);
case idb_event::segm_deleted: case idb_event::segm_deleted:
ea = va_arg(va, ea_t); ea = va_arg(va, ea_t);
return proxy->segm_deleted(ea); return proxy->segm_deleted(ea);
case idb_event::segm_start_changed: case idb_event::segm_start_changed:
seg = va_arg(va, segment_t *); seg = va_arg(va, segment_t *);
return proxy->segm_start_changed(seg); return proxy->segm_start_changed(seg);
case idb_event::segm_end_changed: case idb_event::segm_end_changed:
seg = va_arg(va, segment_t *); seg = va_arg(va, segment_t *);
return proxy->segm_end_changed(seg); return proxy->segm_end_changed(seg);
case idb_event::segm_moved: case idb_event::segm_moved:
ea = va_arg(va, ea_t); ea = va_arg(va, ea_t);
ea2 = va_arg(va, ea_t); ea2 = va_arg(va, ea_t);
size = va_arg(va, asize_t); size = va_arg(va, asize_t);
return proxy->segm_moved(ea, ea2, size); return proxy->segm_moved(ea, ea2, size);
} }
} }
catch (Swig::DirectorException &e) catch (Swig::DirectorException &e)
{ {
msg("Exception in IDP Hook function:\n"); msg("Exception in IDP Hook function:\n");
if (PyErr_Occurred()) if (PyErr_Occurred())
{ {
PyErr_Print(); PyErr_Print();
} }
} }
} }
@ -290,18 +289,18 @@ int idaapi IDB_Callback(void *ud, int notification_code, va_list va)
// returns: 1: success, 0: failure // returns: 1: success, 0: failure
inline const int assemble(ea_t ea, ea_t cs, ea_t ip, bool use32, const char *line) inline const int assemble(ea_t ea, ea_t cs, ea_t ip, bool use32, const char *line)
{ {
int inslen; int inslen;
char buf[256]; // FIXME: Shouldn't be longer than this... is there a MAX_INSTR_LENGTH anywhere? char buf[256]; // FIXME: Shouldn't be longer than this... is there a MAX_INSTR_LENGTH anywhere?
if (ph.notify != NULL) if (ph.notify != NULL)
{ {
inslen = ph.notify(ph.assemble, ea, cs, ip, use32, line, buf); inslen = ph.notify(ph.assemble, ea, cs, ip, use32, line, buf);
if (inslen > 0) if (inslen > 0)
{ {
patch_many_bytes(ea, buf, inslen); patch_many_bytes(ea, buf, inslen);
return 1; return 1;
} }
} }
return 0; return 0;
} }
%} %}

View File

@ -41,28 +41,28 @@ void refresh_lists(void)
%pythoncode %{ %pythoncode %{
def asklong(defval, format): def asklong(defval, format):
res, val = _idaapi._asklong(defval, format) res, val = _idaapi._asklong(defval, format)
if res == 1: if res == 1:
return val return val
else: else:
return None return None
def askaddr(defval, format): def askaddr(defval, format):
res, ea = _idaapi._askaddr(defval, format) res, ea = _idaapi._askaddr(defval, format)
if res == 1: if res == 1:
return ea return ea
else: else:
return None return None
def askseg(defval, format): def askseg(defval, format):
res, sel = _idaapi._askseg(defval, format) res, sel = _idaapi._askseg(defval, format)
if res == 1: if res == 1:
return sel return sel
else: else:
return None return None
%} %}
@ -75,60 +75,60 @@ def askseg(defval, format):
%{ %{
bool idaapi py_menu_item_callback(void *userdata) bool idaapi py_menu_item_callback(void *userdata)
{ {
PyObject *func, *args, *result; PyObject *func, *args, *result;
bool ret = 0; bool ret = 0;
// userdata is a tuple of ( func, args ) // userdata is a tuple of ( func, args )
// func and args are borrowed references from userdata // func and args are borrowed references from userdata
func = PyTuple_GET_ITEM(userdata, 0); func = PyTuple_GET_ITEM(userdata, 0);
args = PyTuple_GET_ITEM(userdata, 1); args = PyTuple_GET_ITEM(userdata, 1);
// call the python function // call the python function
result = PyEval_CallObject(func, args); result = PyEval_CallObject(func, args);
// we cannot raise an exception in the callback, just print it. // we cannot raise an exception in the callback, just print it.
if (!result) { if (!result) {
PyErr_Print(); PyErr_Print();
return 0; return 0;
} }
// if the function returned a non-false value, then return 1 to ida, // if the function returned a non-false value, then return 1 to ida,
// overwise return 0 // overwise return 0
if (PyObject_IsTrue(result)) { if (PyObject_IsTrue(result)) {
ret = 1; ret = 1;
} }
Py_DECREF(result); Py_DECREF(result);
return ret; return ret;
} }
%} %}
%rename (add_menu_item) wrap_add_menu_item; %rename (add_menu_item) wrap_add_menu_item;
%inline %{ %inline %{
bool wrap_add_menu_item ( bool wrap_add_menu_item (
const char *menupath, const char *menupath,
const char *name, const char *name,
const char *hotkey, const char *hotkey,
int flags, int flags,
PyObject *pyfunc, PyObject *pyfunc,
PyObject *args) { PyObject *args) {
// FIXME: probably should keep track of this data, and destroy it when the menu item is removed // FIXME: probably should keep track of this data, and destroy it when the menu item is removed
PyObject *cb_data; PyObject *cb_data;
if (args == Py_None) { if (args == Py_None) {
Py_DECREF(Py_None); Py_DECREF(Py_None);
args = PyTuple_New( 0 ); args = PyTuple_New( 0 );
if (!args) if (!args)
return 0; return 0;
} }
if(!PyTuple_Check(args)) { if(!PyTuple_Check(args)) {
PyErr_SetString(PyExc_TypeError, "args must be a tuple or None"); PyErr_SetString(PyExc_TypeError, "args must be a tuple or None");
return 0; return 0;
} }
cb_data = Py_BuildValue("(OO)", pyfunc, args); cb_data = Py_BuildValue("(OO)", pyfunc, args);
return add_menu_item(menupath, name, hotkey, flags, py_menu_item_callback, (void *)cb_data); return add_menu_item(menupath, name, hotkey, flags, py_menu_item_callback, (void *)cb_data);
} }
%} %}
@ -143,51 +143,51 @@ uint32 choose_choose(PyObject *self,
%{ %{
uint32 idaapi choose_sizer(void *self) uint32 idaapi choose_sizer(void *self)
{ {
PyObject *pyres; PyObject *pyres;
uint32 res; uint32 res;
pyres = PyObject_CallMethod((PyObject *)self, "sizer", ""); pyres = PyObject_CallMethod((PyObject *)self, "sizer", "");
res = PyInt_AsLong(pyres); res = PyInt_AsLong(pyres);
Py_DECREF(pyres); Py_DECREF(pyres);
return res; return res;
} }
char * idaapi choose_getl(void *self, uint32 n, char *buf) char * idaapi choose_getl(void *self, uint32 n, char *buf)
{ {
PyObject *pyres; PyObject *pyres;
char *res; char *res;
char tmp[1024]; char tmp[1024];
pyres = PyObject_CallMethod((PyObject *)self, "getl", "l", n); pyres = PyObject_CallMethod((PyObject *)self, "getl", "l", n);
if (!pyres) if (!pyres)
{ {
strcpy(buf, "<Empty>"); strcpy(buf, "<Empty>");
return buf; return buf;
} }
res = PyString_AsString(pyres); res = PyString_AsString(pyres);
if (res) if (res)
{ {
strcpy(buf, res); strcpy(buf, res);
res = buf; res = buf;
} }
else else
{ {
strcpy(buf, "<Empty>"); strcpy(buf, "<Empty>");
res = buf; res = buf;
} }
Py_DECREF(pyres); Py_DECREF(pyres);
return res; return res;
} }
void idaapi choose_enter(void *self, uint32 n) void idaapi choose_enter(void *self, uint32 n)
{ {
PyObject_CallMethod((PyObject *)self, "enter", "l", n); PyObject_CallMethod((PyObject *)self, "enter", "l", n);
return; return;
} }
uint32 choose_choose(void *self, uint32 choose_choose(void *self,
@ -196,35 +196,35 @@ uint32 choose_choose(void *self,
int x1,int y1, int x1,int y1,
int width) int width)
{ {
PyObject *pytitle; PyObject *pytitle;
char deftitle[] = "Choose"; char deftitle[] = "Choose";
char *title = NULL; char *title = NULL;
if ((pytitle = PyObject_GetAttrString((PyObject *)self, "title"))) if ((pytitle = PyObject_GetAttrString((PyObject *)self, "title")))
{ {
title = PyString_AsString(pytitle); title = PyString_AsString(pytitle);
} }
return choose( return choose(
flags, flags,
x0, y0, x0, y0,
x1, y1, x1, y1,
self, self,
width, width,
&choose_sizer, &choose_sizer,
&choose_getl, &choose_getl,
title ? title : deftitle, title ? title : deftitle,
1, 1,
1, 1,
NULL, /* del */ NULL, /* del */
NULL, /* inst */ NULL, /* inst */
NULL, /* update */ NULL, /* update */
NULL, /* edit */ NULL, /* edit */
&choose_enter, &choose_enter,
NULL, /* destroy */ NULL, /* destroy */
NULL, /* popup_names */ NULL, /* popup_names */
NULL /* get_icon */ NULL /* get_icon */
); );
} }
%} %}

View File

@ -120,7 +120,7 @@
%inline %{ %inline %{
int mem2base_wrap(char *buf, int len, ea_t ea, long fpos) int mem2base_wrap(char *buf, int len, ea_t ea, long fpos)
{ {
return mem2base((void *)buf, ea, ea+len, fpos); return mem2base((void *)buf, ea, ea+len, fpos);
} }
%} %}

View File

@ -22,12 +22,12 @@
%include "segment.hpp" %include "segment.hpp"
%inline %{ %inline %{
sel_t get_defsr(segment_t *s, int reg) sel_t get_defsr(segment_t *s, int reg)
{ {
return s->defsr[reg]; return s->defsr[reg];
} }
void set_defsr(segment_t *s, int reg, sel_t value) void set_defsr(segment_t *s, int reg, sel_t value)
{ {
s->defsr[reg] = value; s->defsr[reg] = value;
} }
%} %}

View File

@ -9,6 +9,6 @@
// Add a get_member() member function to struc_t. // Add a get_member() member function to struc_t.
// This helps to access the members array in the class. // This helps to access the members array in the class.
%extend struc_t { %extend struc_t {
member_t * get_member(int index) { return &(self->members[index]); } member_t * get_member(int index) { return &(self->members[index]); }
} }

View File

@ -29,85 +29,85 @@
%define %cstring_output_maxstr_none(TYPEMAP, SIZE) %define %cstring_output_maxstr_none(TYPEMAP, SIZE)
%typemap (default) SIZE { %typemap (default) SIZE {
$1 = MAXSTR; $1 = MAXSTR;
} }
%typemap(in,numinputs=0) (TYPEMAP, SIZE) { %typemap(in,numinputs=0) (TYPEMAP, SIZE) {
#ifdef __cplusplus #ifdef __cplusplus
$1 = ($1_ltype) new char[MAXSTR+1]; $1 = ($1_ltype) new char[MAXSTR+1];
#else #else
$1 = ($1_ltype) malloc(MAXSTR+1); $1 = ($1_ltype) malloc(MAXSTR+1);
#endif #endif
} }
%typemap(out) ssize_t { %typemap(out) ssize_t {
/* REMOVING ssize_t return value in $symname */ /* REMOVING ssize_t return value in $symname */
} }
%typemap(argout) (TYPEMAP,SIZE) { %typemap(argout) (TYPEMAP,SIZE) {
if (result > 0) if (result > 0)
{ {
resultobj = PyString_FromString($1); resultobj = PyString_FromString($1);
} }
else else
{ {
Py_INCREF(Py_None); Py_INCREF(Py_None);
resultobj = Py_None; resultobj = Py_None;
} }
#ifdef __cplusplus #ifdef __cplusplus
delete [] $1; delete [] $1;
#else #else
free($1); free($1);
#endif #endif
} }
%enddef %enddef
%define %cstring_bounded_output_none(TYPEMAP,MAX) %define %cstring_bounded_output_none(TYPEMAP,MAX)
%typemap(in, numinputs=0) TYPEMAP(char temp[MAX+1]) { %typemap(in, numinputs=0) TYPEMAP(char temp[MAX+1]) {
$1 = ($1_ltype) temp; $1 = ($1_ltype) temp;
} }
%typemap(argout,fragment="t_output_helper") TYPEMAP { %typemap(argout,fragment="t_output_helper") TYPEMAP {
PyObject *o; PyObject *o;
$1[MAX] = 0; $1[MAX] = 0;
if ($1 > 0) if ($1 > 0)
{ {
o = PyString_FromString($1); o = PyString_FromString($1);
} }
else else
{ {
o = Py_None; o = Py_None;
Py_INCREF(Py_None); Py_INCREF(Py_None);
} }
$result = t_output_helper($result,o); $result = t_output_helper($result,o);
} }
%enddef %enddef
%define %binary_output_or_none(TYPEMAP, SIZE) %define %binary_output_or_none(TYPEMAP, SIZE)
%typemap (default) SIZE { %typemap (default) SIZE {
$1 = MAXSPECSIZE; $1 = MAXSPECSIZE;
} }
%typemap(in,numinputs=0) (TYPEMAP, SIZE) { %typemap(in,numinputs=0) (TYPEMAP, SIZE) {
#ifdef __cplusplus #ifdef __cplusplus
$1 = (char *) new char[MAXSPECSIZE+1]; $1 = (char *) new char[MAXSPECSIZE+1];
#else #else
$1 = (char *) malloc(MAXSPECSIZE+1); $1 = (char *) malloc(MAXSPECSIZE+1);
#endif #endif
} }
%typemap(out) ssize_t { %typemap(out) ssize_t {
/* REMOVING ssize_t return value in $symname */ /* REMOVING ssize_t return value in $symname */
} }
%typemap(argout) (TYPEMAP,SIZE) { %typemap(argout) (TYPEMAP,SIZE) {
if (result > 0) if (result > 0)
{ {
resultobj = PyString_FromStringAndSize((char *)$1, result); resultobj = PyString_FromStringAndSize((char *)$1, result);
} }
else else
{ {
Py_INCREF(Py_None); Py_INCREF(Py_None);
resultobj = Py_None; resultobj = Py_None;
} }
#ifdef __cplusplus #ifdef __cplusplus
delete [] (char *)$1; delete [] (char *)$1;
#else #else
free((char *)$1); free((char *)$1);
#endif #endif
} }
%enddef %enddef
@ -145,11 +145,11 @@
} }
%enddef %enddef
// Check that the argument is a callable Python object // Check that the argument is a callable Python object
%typemap(in) PyObject *pyfunc { %typemap(in) PyObject *pyfunc {
if (!PyCallable_Check($input)) { if (!PyCallable_Check($input)) {
PyErr_SetString(PyExc_TypeError, "Expecting a callable object"); PyErr_SetString(PyExc_TypeError, "Expecting a callable object");
return NULL; return NULL;
} }
$1 = $input; $1 = $input;
} }

View File

@ -142,18 +142,18 @@
%inline %{ %inline %{
til_t * load_til(const char *tildir, const char *name) til_t * load_til(const char *tildir, const char *name)
{ {
char errbuf[4096]; char errbuf[4096];
til_t *res; til_t *res;
res = load_til(tildir, name, errbuf, sizeof(errbuf)); res = load_til(tildir, name, errbuf, sizeof(errbuf));
if (!res) if (!res)
{ {
PyErr_SetString(PyExc_RuntimeError, errbuf); PyErr_SetString(PyExc_RuntimeError, errbuf);
return NULL; return NULL;
} }
return res; return res;
} }
%} %}
@ -161,18 +161,18 @@ til_t * load_til(const char *tildir, const char *name)
%inline %{ %inline %{
til_t * load_til_header_wrap(const char *tildir, const char *name) til_t * load_til_header_wrap(const char *tildir, const char *name)
{ {
char errbuf[4096]; char errbuf[4096];
til_t *res; til_t *res;
res = load_til_header(tildir, name, errbuf, sizeof(errbuf));; res = load_til_header(tildir, name, errbuf, sizeof(errbuf));;
if (!res) if (!res)
{ {
PyErr_SetString(PyExc_RuntimeError, errbuf); PyErr_SetString(PyExc_RuntimeError, errbuf);
return NULL; return NULL;
} }
return res; return res;
} }
%} %}
@ -184,10 +184,8 @@ int idc_parse_types(const char *input, int flags)
{ {
int hti = ((flags >> 4) & 7) << HTI_PAK_SHIFT; int hti = ((flags >> 4) & 7) << HTI_PAK_SHIFT;
if ( (flags & 1) != 0 ) if ((flags & 1) != 0)
{
hti |= HTI_FIL; hti |= HTI_FIL;
}
return parse_types2(input, (flags & 2) == 0 ? msg : NULL, hti); return parse_types2(input, (flags & 2) == 0 ? msg : NULL, hti);
} }
@ -201,12 +199,10 @@ char *idc_get_type(ea_t ea, char *buf, size_t bufsize)
{ {
int code = print_type_to_one_line(buf, bufsize, idati, type, int code = print_type_to_one_line(buf, bufsize, idati, type,
NULL, NULL, fnames); NULL, NULL, fnames);
if ( code == T_NORMAL ) if (code == T_NORMAL)
{
return buf; return buf;
} } \
} \ return NULL;
return NULL;
} }
char *idc_guess_type(ea_t ea, char *buf, size_t bufsize) char *idc_guess_type(ea_t ea, char *buf, size_t bufsize)
@ -218,78 +214,75 @@ char *idc_guess_type(ea_t ea, char *buf, size_t bufsize)
{ {
int code = print_type_to_one_line(buf, bufsize, idati, type, int code = print_type_to_one_line(buf, bufsize, idati, type,
NULL, NULL, fnames); NULL, NULL, fnames);
if ( code == T_NORMAL ) if (code == T_NORMAL)
{
return buf; return buf;
} } \
} \ return NULL;
return NULL;
} }
int idc_set_local_type(int ordinal, const char *dcl, int flags) int idc_set_local_type(int ordinal, const char *dcl, int flags)
{ {
if (dcl == NULL || dcl[0] == '\0') if (dcl == NULL || dcl[0] == '\0')
{ {
if (!del_numbered_type(idati, ordinal)) if (!del_numbered_type(idati, ordinal))
return 0; return 0;
} }
else else
{ {
qstring name; qstring name;
qtype type; qtype type;
qtype fields; qtype fields;
if (!parse_decl(idati, dcl, &name, &type, &fields, flags)) if (!parse_decl(idati, dcl, &name, &type, &fields, flags))
return 0; return 0;
if (ordinal <= 0) if (ordinal <= 0)
{ {
if (!name.empty()) if (!name.empty())
ordinal = get_type_ordinal(idati, name.c_str()); ordinal = get_type_ordinal(idati, name.c_str());
if (ordinal <= 0) if (ordinal <= 0)
ordinal = alloc_type_ordinal(idati); ordinal = alloc_type_ordinal(idati);
} }
if (!set_numbered_type(idati, ordinal, 0, name.c_str(), type.c_str(), fields.c_str())) if (!set_numbered_type(idati, ordinal, 0, name.c_str(), type.c_str(), fields.c_str()))
return 0; return 0;
} }
return ordinal; return ordinal;
} }
int idc_get_local_type(int ordinal, int flags, char *buf, size_t maxsize) int idc_get_local_type(int ordinal, int flags, char *buf, size_t maxsize)
{ {
const type_t *type; const type_t *type;
const p_list *fields; const p_list *fields;
if (!get_numbered_type(idati, ordinal, &type, &fields)) if (!get_numbered_type(idati, ordinal, &type, &fields))
{ {
buf[0] = 0; buf[0] = 0;
return false; return false;
} }
qstring res; qstring res;
const char *name = get_numbered_type_name(idati, ordinal); const char *name = get_numbered_type_name(idati, ordinal);
if (print_type_to_qstring(&res, NULL, 2, 40, flags, idati, type, name, NULL, fields) <= 0) if (print_type_to_qstring(&res, NULL, 2, 40, flags, idati, type, name, NULL, fields) <= 0)
{ {
buf[0] = 0; buf[0] = 0;
return false; return false;
} }
qstrncpy(buf, res.c_str(), maxsize); qstrncpy(buf, res.c_str(), maxsize);
return true; return true;
} }
char idc_get_local_type_name(int ordinal, char *buf, size_t bufsize) char idc_get_local_type_name(int ordinal, char *buf, size_t bufsize)
{ {
const char *name = get_numbered_type_name(idati, ordinal); const char *name = get_numbered_type_name(idati, ordinal);
if (name == NULL) if (name == NULL)
return false; return false;
qstrncpy(buf, name, bufsize); qstrncpy(buf, name, bufsize);
return true; return true;
} }
%} %}

View File

@ -6,7 +6,7 @@
%inline { %inline {
insn_t * get_current_instruction() insn_t * get_current_instruction()
{ {
return &cmd; return &cmd;
} }
} }
@ -14,12 +14,9 @@ insn_t * get_current_instruction()
%inline { %inline {
op_t *get_instruction_operand(insn_t *ins, int n) op_t *get_instruction_operand(insn_t *ins, int n)
{ {
if (!ins) if (!ins)
{ return NULL;
return NULL; return &(ins->Operands[n]);
}
return &(ins->Operands[n]);
} }
} }